/* ==========================================================================
   AssessFlow Enterprise SPA Engine Styles
   ========================================================================== */

/* ── Top Progress Loader Bar ────────────────────────────────────────────── */
#spa-loader-bar {
    position: fixed;
    top: 0;
    left: 0;
    width: 0%;
    height: 3px;
    background: linear-gradient(90deg, var(--accent-color, #3b82f6), #8b5cf6, #ec4899);
    box-shadow: 0 0 10px rgba(59, 130, 246, 0.7), 0 0 5px rgba(139, 92, 246, 0.5);
    z-index: 999999;
    opacity: 0;
    pointer-events: none;
    transition: width 0.25s cubic-bezier(0.4, 0, 0.2, 1), opacity 0.3s ease;
}

#spa-loader-bar.active {
    opacity: 1;
}

#spa-loader-bar.finish {
    width: 100% !important;
    opacity: 0;
    transition: width 0.15s ease-out, opacity 0.4s ease 0.15s;
}

/* ── Content View Transitions ──────────────────────────────────────────── */
#app-main-content {
    transition: opacity 0.18s cubic-bezier(0.4, 0, 0.2, 1), transform 0.18s cubic-bezier(0.4, 0, 0.2, 1);
    will-change: opacity, transform;
}

.spa-fade-out {
    opacity: 0.15 !important;
    transform: translateY(3px) scale(0.998);
}

.spa-fade-in {
    animation: spaContentFadeIn 0.25s ease-out forwards;
}

@keyframes spaContentFadeIn {
    from {
        opacity: 0.2;
        transform: translateY(-4px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* ── Enterprise Level Loading Spinner System ────────────────────────────── */
.af-spinner-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    min-height: 160px;
    z-index: 9999;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    background: rgba(15, 23, 42, 0.45) !important;
    border-radius: inherit;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.2s ease, visibility 0.2s ease;
    pointer-events: all;
}

.af-spinner-overlay.is-active {
    opacity: 1 !important;
    visibility: visible !important;
}

.af-spinner-overlay-fixed {
    position: fixed !important;
    top: 0 !important;
    left: 0 !important;
    right: 0 !important;
    bottom: 0 !important;
    width: 100vw !important;
    height: 100vh !important;
    z-index: 9999999 !important;
    border-radius: 0 !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    background: rgba(15, 23, 42, 0.5) !important;
}

.af-spinner-overlay-fixed.is-active {
    opacity: 1 !important;
    visibility: visible !important;
}

/* Modal Card Wrapper around Spinner */
.af-spinner-card {
    display: flex !important;
    flex-direction: column !important;
    align-items: center !important;
    justify-content: center !important;
    padding: 32px 48px !important;
    background: #ffffff !important;
    border: 1px solid rgba(203, 213, 225, 0.8) !important;
    box-shadow: 0 25px 50px -12px rgba(15, 23, 42, 0.35), 0 0 0 1px rgba(0, 0, 0, 0.05) !important;
    border-radius: 20px !important;
    animation: afSpinnerPopIn 0.25s cubic-bezier(0.34, 1.56, 0.64, 1) !important;
}

[data-theme="dark"] .af-spinner-card {
    background: #1e293b !important;
    border: 1px solid rgba(255, 255, 255, 0.15) !important;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.6), 0 0 30px rgba(59, 130, 246, 0.25) !important;
}

/* sticky centering only for inline (non-fixed) overlays */
.af-spinner-overlay:not(.af-spinner-overlay-fixed) .af-spinner-card {
    position: sticky;
    top: 50%;
    transform: translateY(-50%);
}

/* fixed overlay: let flexbox handle centering, no position override needed */
.af-spinner-overlay-fixed .af-spinner-card {
    position: static !important;
}

@keyframes afSpinnerPopIn {
    from {
        opacity: 0;
        transform: scale(0.9);
    }
    to {
        opacity: 1;
        transform: scale(1);
    }
}

/* Standalone Enterprise Spinner Widget */
.af-spinner {
    position: relative !important;
    display: inline-flex !important;
    align-items: center !important;
    justify-content: center !important;
    box-sizing: border-box !important;
}

/* Sizes */
.af-spinner-sm { width: 26px !important; height: 26px !important; }
.af-spinner-md { width: 48px !important; height: 48px !important; }
.af-spinner-lg { width: 68px !important; height: 68px !important; }
.af-spinner-xl { width: 88px !important; height: 88px !important; }

/* Dual Orbits & Pulsing Core */
.af-spinner-ring {
    position: absolute !important;
    inset: 0 !important;
    border-radius: 50% !important;
    border: 3.5px solid rgba(203, 213, 225, 0.4) !important;
    border-top-color: #2563eb !important;
    border-right-color: #7c3aed !important;
    animation: afSpinnerRotate 0.85s linear infinite !important;
}

.af-spinner-ring-outer {
    position: absolute !important;
    inset: -7px !important;
    border-radius: 50% !important;
    border: 3px solid rgba(203, 213, 225, 0.3) !important;
    border-bottom-color: #db2777 !important;
    border-left-color: #4f46e5 !important;
    animation: afSpinnerRotateReverse 1.3s linear infinite !important;
}

[data-theme="dark"] .af-spinner-ring {
    border-color: rgba(255, 255, 255, 0.15) !important;
    border-top-color: #3b82f6 !important;
    border-right-color: #a855f7 !important;
}

[data-theme="dark"] .af-spinner-ring-outer {
    border-color: rgba(255, 255, 255, 0.1) !important;
    border-bottom-color: #f43f5e !important;
    border-left-color: #6366f1 !important;
}

.af-spinner-sm .af-spinner-ring-outer { inset: -5px !important; border-width: 2px !important; }
.af-spinner-sm .af-spinner-ring { border-width: 2.5px !important; }
.af-spinner-xl .af-spinner-ring-outer { inset: -9px !important; border-width: 3.5px !important; }

.af-spinner-core {
    width: 35% !important;
    height: 35% !important;
    background: linear-gradient(135deg, #2563eb, #7c3aed) !important;
    border-radius: 50% !important;
    box-shadow: 0 0 12px rgba(37, 99, 235, 0.7) !important;
    animation: afSpinnerPulse 1.1s ease-in-out infinite alternate !important;
}

@keyframes afSpinnerRotate {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

@keyframes afSpinnerRotateReverse {
    0% { transform: rotate(360deg); }
    100% { transform: rotate(0deg); }
}

@keyframes afSpinnerPulse {
    0% {
        transform: scale(0.8);
        opacity: 0.85;
    }
    100% {
        transform: scale(1.2);
        opacity: 1;
    }
}

/* Crisp Text below spinner */
.af-spinner-text {
    margin-top: 18px !important;
    font-size: 0.95rem !important;
    font-weight: 700 !important;
    letter-spacing: 0.03em !important;
    color: #0f172a !important;
    text-align: center !important;
    opacity: 1 !important;
    background: none !important;
    -webkit-text-fill-color: #0f172a !important;
    -webkit-background-clip: initial !important;
}

[data-theme="dark"] .af-spinner-text {
    color: #f8fafc !important;
    -webkit-text-fill-color: #f8fafc !important;
}

/* ── Toast Notifications System ────────────────────────────────────────── */
#spa-toast-container {
    position: fixed;
    bottom: 24px;
    right: 24px;
    z-index: 999990;
    display: flex;
    flex-direction: column;
    gap: 10px;
    max-width: 380px;
    width: calc(100% - 48px);
    pointer-events: none;
}

.spa-toast {
    pointer-events: auto;
    background: rgba(30, 41, 59, 0.92);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid rgba(255, 255, 255, 0.12);
    color: #f8fafc;
    border-radius: 10px;
    padding: 12px 16px;
    box-shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.4), 0 8px 10px -6px rgba(0, 0, 0, 0.3);
    display: flex;
    align-items: center;
    justify-content: space-between;
    font-size: 0.875rem;
    animation: spaToastSlideIn 0.3s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

.spa-toast-success {
    border-left: 4px solid #10b981;
}

.spa-toast-error {
    border-left: 4px solid #ef4444;
}

.spa-toast-info {
    border-left: 4px solid #3b82f6;
}

@keyframes spaToastSlideIn {
    from {
        opacity: 0;
        transform: translateY(20px) scale(0.95);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

.spa-toast-hiding {
    animation: spaToastSlideOut 0.25s ease-in forwards !important;
}

@keyframes spaToastSlideOut {
    to {
        opacity: 0;
        transform: translateX(30px) scale(0.9);
    }
}

/* ── SPA Active Link Indicator ────────────────────────────────────────── */
.nav-link.spa-active-route {
    position: relative;
}

.nav-link.spa-active-route::after {
    content: '';
    position: absolute;
    bottom: -2px;
    left: 15%;
    right: 15%;
    height: 2px;
    background: var(--accent-color, #3b82f6);
    border-radius: 2px;
    box-shadow: 0 0 8px var(--accent-color, #3b82f6);
}
