/* ==========================================
   TOAST NOTIFICATIONS
   ========================================== */

.toast-container {
    position: fixed;
    bottom: 20px;
    right: 20px;
    z-index: 9999;
    display: flex;
    flex-direction: column;
    gap: 12px;
    max-width: 400px;
    pointer-events: none;
}

@media (max-width: 640px) {
    .toast-container {
        left: 20px;
        right: 20px;
        max-width: none;
    }
}

.toast-card {
    display: flex;
    align-items: stretch;
    background: white;
    border-radius: 12px;
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.15), 0 4px 10px rgba(0, 0, 0, 0.1);
    overflow: hidden;
    min-width: 320px;
    max-width: 100%;
    animation: slideInRight 0.3s ease-out;
    pointer-events: auto;
    transition: transform 0.2s ease, opacity 0.2s ease;
}

.toast-card:hover {
    transform: translateX(-4px);
}

.toast-card.fade-out {
    animation: slideOutRight 0.3s ease-out forwards;
}

@keyframes slideInRight {
    from {
        transform: translateX(100%);
        opacity: 0;
    }
    to {
        transform: translateX(0);
        opacity: 1;
    }
}

@keyframes slideOutRight {
    from {
        transform: translateX(0);
        opacity: 1;
    }
    to {
        transform: translateX(100%);
        opacity: 0;
    }
}

.toast-accent {
    width: 6px;
    flex-shrink: 0;
}

.toast-card.success .toast-accent {
    background: linear-gradient(180deg, #10b981, #059669);
}

.toast-card.error .toast-accent {
    background: linear-gradient(180deg, #ef4444, #dc2626);
}

.toast-card.info .toast-accent {
    background: linear-gradient(180deg, #3b82f6, #2563eb);
}

.toast-body {
    flex: 1;
    padding: 16px 12px;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.toast-title {
    font-size: 0.9375rem;
    font-weight: 600;
    margin: 0;
    color: #111827;
}

.toast-card.success .toast-title {
    color: #059669;
}

.toast-card.error .toast-title {
    color: #dc2626;
}

.toast-card.info .toast-title {
    color: #2563eb;
}

.toast-text {
    font-size: 0.875rem;
    margin: 0;
    color: #6b7280;
    line-height: 1.4;
}

.toast-close {
    padding: 12px;
    background: transparent;
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s ease;
    flex-shrink: 0;
}

.toast-close:hover {
    background: rgba(0, 0, 0, 0.05);
}

.toast-close svg {
    width: 18px;
    height: 18px;
    stroke: #9ca3af;
}

/* ==========================================
   SECTION LOADER
   ========================================== */

.section-loader {
    position: absolute;
    inset: 0;
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: center;
    animation: fadeIn 0.2s ease-out;
}

/* Mobile: Fixed positioning for full viewport coverage */
@media (max-width: 768px) {
    .section-loader {
        position: fixed;
        top: 0;
        left: 0;
        right: 0;
        bottom: 0;
    }
}

.section-loader.fade-out {
    animation: fadeOut 0.3s ease-out forwards;
}

.section-loader-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(255, 255, 255, 0.85);
    backdrop-filter: blur(4px);
}

/* Mobile: Fixed backdrop for full viewport coverage */
@media (max-width: 768px) {
    .section-loader-backdrop {
        position: fixed;
        top: 0;
        left: 0;
        right: 0;
        bottom: 0;
    }
}

.section-loader-spinner {
    position: relative;
    z-index: 1001;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 16px;
}

/* ==========================================
   SQUARE LOADER ANIMATION
   ========================================== */

@keyframes loader_5191 {
    from {
        opacity: 0;
    }
    to {
        opacity: 1;
    }
}

.loader {
    position: relative;
    width: 50px;
    height: 50px;
    z-index: 1001;
}

.square {
    background: hsl(var(--primary));
    width: 10px;
    height: 10px;
    position: absolute;
    top: 50%;
    left: 50%;
    margin-top: -5px;
    margin-left: -5px;
    border-radius: 2px;
}

#sq1 {
    margin-top: -25px;
    margin-left: -25px;
    animation: loader_5191 675ms ease-in-out 0s infinite alternate;
}

#sq2 {
    margin-top: -25px;
    animation: loader_5191 675ms ease-in-out 75ms infinite alternate;
}

#sq3 {
    margin-top: -25px;
    margin-left: 15px;
    animation: loader_5191 675ms ease-in-out 150ms infinite;
}

#sq4 {
    margin-left: -25px;
    animation: loader_5191 675ms ease-in-out 225ms infinite;
}

#sq5 {
    animation: loader_5191 675ms ease-in-out 300ms infinite;
}

#sq6 {
    margin-left: 15px;
    animation: loader_5191 675ms ease-in-out 375ms infinite;
}

#sq7 {
    margin-top: 15px;
    margin-left: -25px;
    animation: loader_5191 675ms ease-in-out 450ms infinite;
}

#sq8 {
    margin-top: 15px;
    animation: loader_5191 675ms ease-in-out 525ms infinite;
}

#sq9 {
    margin-top: 15px;
    margin-left: 15px;
    animation: loader_5191 675ms ease-in-out 600ms infinite;
}

/* ==========================================
   MAIN CONTENT LOADER (for sidebar navigation)
   ========================================== */

.main-content-loader {
    position: absolute;
    inset: 0;
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: center;
    animation: fadeIn 0.2s ease-out;
}

.main-content-loader-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(255, 255, 255, 0.9);
    backdrop-filter: blur(6px);
}

.main-content-loader-spinner {
    position: relative;
    z-index: 1001;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 16px;
}

.spinner-icon {
    width: 48px;
    height: 48px;
    animation: rotate 1s linear infinite;
}

.spinner-path {
    stroke: hsl(var(--primary));
    stroke-linecap: round;
    animation: dash 1.5s ease-in-out infinite;
}

.spinner-text {
    font-size: 0.875rem;
    font-weight: 500;
    color: hsl(var(--foreground));
    margin: 0;
}

@keyframes rotate {
    100% {
        transform: rotate(360deg);
    }
}

@keyframes dash {
    0% {
        stroke-dasharray: 1, 150;
        stroke-dashoffset: 0;
    }
    50% {
        stroke-dasharray: 90, 150;
        stroke-dashoffset: -35;
    }
    100% {
        stroke-dasharray: 90, 150;
        stroke-dashoffset: -124;
    }
}

@keyframes fadeIn {
    from {
        opacity: 0;
    }
    to {
        opacity: 1;
    }
}

@keyframes fadeOut {
    from {
        opacity: 1;
    }
    to {
        opacity: 0;
    }
}

/* ==========================================
   BUTTON LOADER
   ========================================== */

.btn-spinner {
    display: inline-block;
    animation: rotate 1s linear infinite;
    margin-right: 8px;
}

.btn-spinner .spinner-path {
    stroke: currentColor;
    stroke-linecap: round;
    animation: dash 1.5s ease-in-out infinite;
}

/* ==========================================
   ENHANCED BUTTON STATES
   ========================================== */

button:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

button[data-original-content] {
    position: relative;
}

/* ==========================================
   FORM FIELD ENHANCEMENTS
   ========================================== */

.form-select:focus,
.form-control:focus {
    outline: none;
    border-color: hsl(var(--primary));
    box-shadow: 0 0 0 3px hsla(var(--primary-rgb), 0.1);
}

/* Highlight calculated fields */
input[readonly].calculated-field {
    background: hsl(var(--muted) / 0.3);
    border-color: hsl(var(--primary) / 0.3);
}

/* ==========================================
   MOBILE RESPONSIVENESS
   ========================================== */

@media (max-width: 768px) {
    .section-loader-spinner {
        gap: 12px;
    }
    
    .spinner-icon {
        width: 40px;
        height: 40px;
    }
    
    .spinner-text {
        font-size: 0.8125rem;
    }
    
    .toast-card {
        min-width: 280px;
    }
    
    .toast-body {
        padding: 14px 10px;
    }
    
    .toast-title {
        font-size: 0.875rem;
    }
    
    .toast-text {
        font-size: 0.8125rem;
    }
}

/* ==========================================
   DARK MODE SUPPORT
   ========================================== */

.dark .toast-card {
    background: hsl(var(--card));
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.3), 0 4px 10px rgba(0, 0, 0, 0.2);
}

.dark .toast-title {
    color: hsl(var(--foreground));
}

.dark .toast-text {
    color: hsl(var(--muted-foreground));
}

.dark .toast-close:hover {
    background: rgba(255, 255, 255, 0.1);
}

.dark .section-loader-backdrop {
    background: rgba(0, 0, 0, 0.7);
}

.dark .spinner-text {
    color: hsl(var(--foreground));
}

/* ==========================================
   ACCESSIBILITY
   ========================================== */

@media (prefers-reduced-motion: reduce) {
    .toast-card,
    .section-loader,
    .spinner-icon,
    .btn-spinner {
        animation: none !important;
    }
    
    .toast-card {
        opacity: 1;
        transform: none;
    }
}

/* Focus visible for keyboard navigation */
.toast-close:focus-visible {
    outline: 2px solid hsl(var(--primary));
    outline-offset: 2px;
}
