/* ==========================================================================
   AssessFlow Enterprise SPA Engine Styles (Google Design System)
   ========================================================================== */

/* ── Top Progress Loader Bar — Iconic Google 4-Color Gradient ─────────────── */
#spa-loader-bar {
    position: fixed;
    top: 0;
    left: 0;
    width: 0%;
    height: 3px;
    background: linear-gradient(90deg, #4285f4 0%, #ea4335 33%, #fbbc04 66%, #34a853 100%);
    box-shadow: 0 0 10px rgba(66, 133, 244, 0.6), 0 0 5px rgba(52, 168, 83, 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(19, 19, 20, 0.55) !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(19, 19, 20, 0.6) !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(218, 220, 224, 0.9) !important;
    box-shadow: 0 4px 12px 4px rgba(60, 64, 67, 0.15), 0 16px 32px 6px rgba(60, 64, 67, 0.15) !important;
    border-radius: 16px !important;
    animation: afSpinnerPopIn 0.25s cubic-bezier(0.34, 1.56, 0.64, 1) !important;
}

[data-theme="dark"] .af-spinner-card {
    background: #1e1f20 !important;
    border: 1px solid rgba(255, 255, 255, 0.12) !important;
    box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.6), 0 0 30px rgba(66, 133, 244, 0.2) !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 — Google 4-Color Palette */
.af-spinner-ring {
    position: absolute !important;
    inset: 0 !important;
    border-radius: 50% !important;
    border: 3.5px solid rgba(218, 220, 224, 0.4) !important;
    border-top-color: #4285f4 !important;
    border-right-color: #ea4335 !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(218, 220, 224, 0.3) !important;
    border-bottom-color: #34a853 !important;
    border-left-color: #fbbc04 !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: #8ab4f8 !important;
    border-right-color: #f28b82 !important;
}

[data-theme="dark"] .af-spinner-ring-outer {
    border-color: rgba(255, 255, 255, 0.1) !important;
    border-bottom-color: #81c995 !important;
    border-left-color: #fdd663 !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, #4285f4, #1a73e8) !important;
    border-radius: 50% !important;
    box-shadow: 0 0 12px rgba(66, 133, 244, 0.6) !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: 600 !important;
    letter-spacing: 0.02em !important;
    color: #202124 !important;
    text-align: center !important;
    opacity: 1 !important;
    background: none !important;
    -webkit-text-fill-color: #202124 !important;
    -webkit-background-clip: initial !important;
}

[data-theme="dark"] .af-spinner-text {
    color: #e3e3e3 !important;
    -webkit-text-fill-color: #e3e3e3 !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, 31, 32, 0.95);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid rgba(255, 255, 255, 0.12);
    color: #e3e3e3;
    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;
}

[data-theme="light"] .spa-toast {
    background: #ffffff;
    border: 1px solid #dadce0;
    color: #202124;
    box-shadow: 0 4px 12px rgba(60, 64, 67, 0.15);
}

.spa-toast-success {
    border-left: 4px solid #34a853 !important;
}

.spa-toast-error {
    border-left: 4px solid #ea4335 !important;
}

.spa-toast-info {
    border-left: 4px solid #4285f4 !important;
}

@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, #1a73e8);
    border-radius: 2px;
    box-shadow: 0 0 8px var(--accent-soft, rgba(26, 115, 232, 0.4));
}
