/* Forces Light Mode (overrides system dark) */
body.force-light {
    --bg-color: #ffffff;
    --text-color: #333333;
    /* Update other app-specific variables here */
}

/* Forces Dark Mode (overrides system light) */
body.force-dark {
    --bg-color: #121212;
    --text-color: #e0e0e0;
    /* Update other app-specific variables here */
}
/* --- LOADER & THEME VARIABLES --- */
/* 1. Define Variables */
:root {
    --bg-canvas: #ffffff;
    --text-primary: #333333;
    --text-secondary: #888888;
    --accent-color: #1b6ec2;
    --track-color: #e9ecef;
    /* Error Palette - NEUTRALIZED (No more red) */
    --error-bg: #ffffff;
    --error-text: #333333;
    --error-border: #e0e0e0;
    --error-shadow: 0 4px 20px rgba(0,0,0,0.08);
    --error-btn-bg: #1b6ec2;
    --error-btn-text: #ffffff;
    /* Default fallback if JS fails (rare) */
    --loading-text: "Please wait...";
    --error-message-text: "Please reload to continue";
    --reload-btn-text: "Reload";
}

/* 2. Dark Mode Override */
@media (prefers-color-scheme: dark) {
    :root {
        --bg-canvas: #121212;
        --text-primary: #e0e0e0;
        --text-secondary: #666666;
        --accent-color: #3a8ee6;
        --track-color: #2d2d2d;
        /* Error Palette Dark - Neutral Surface */
        --error-bg: #333333;
        --error-text: #e0e0e0;
        --error-border: #444444;
        --error-shadow: 0 10px 40px rgba(0,0,0,0.4);
        --error-btn-bg: #3a8ee6;
        --error-btn-text: #121212;
    }
}

/* 3. Base Styles & Transition */
body {
    background-color: var(--bg-canvas);
    color: var(--text-primary);
    margin: 0;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    transition: background-color 0.5s ease, color 0.5s ease;
    min-height: 100vh;
    width: 100%;
    /* NOTE: overflow: hidden might prevent scrolling in your app if you don't use a specific scroll container. 
       If your app won't scroll, remove this line. */
    overflow-x: hidden;
    overflow-y: auto;
}

/* --- THE LOADER CONTENT --- */
/* #app styles removed to prevent affecting layout later */

.loader-container {
    /* Center using fixed positioning relative to viewport */
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 280px;
    text-align: center;
    z-index: 9999; /* Ensure it floats above everything */
}

/* The App Title */
.app-title {
    font-size: 1.75rem;
    font-weight: 800;
    letter-spacing: -0.5px;
    margin-bottom: 40px;
    color: var(--text-primary);
    opacity: 0;
    animation: fade-in-up 0.8s ease-out forwards;
}

/* The Progress Track */
.progress-track {
    height: 3px;
    width: 100%;
    background-color: var(--track-color);
    border-radius: 2px;
    overflow: hidden;
    position: relative;
}

/* The Moving Bar */
.progress-fill {
    height: 100%;
    background-color: var(--accent-color);
    width: var(--blazor-load-percentage, 0%);
    transition: width 0.1s linear;
    border-radius: 2px;
    box-shadow: 0 0 10px rgba(27, 110, 194, 0.3);
}

/* The Text Indicator */
.progress-text {
    margin-top: 15px;
    font-size: 0.75rem;
    color: var(--text-secondary);
    font-weight: 600;
    letter-spacing: 0.5px;
    text-transform: uppercase;
    font-variant-numeric: tabular-nums;
    opacity: 0;
    animation: fade-in 1s ease-out 0.3s forwards;
}

    .progress-text::after {
        content: var(--blazor-load-percentage-text, var(--loading-text));
    }

/* --- ANIMATIONS --- */
@keyframes fade-in-up {
    from {
        opacity: 0;
        transform: translateY(15px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes fade-in {
    from {
        opacity: 0;
    }

    to {
        opacity: 1;
    }
}

/* --- APP ENTRY TRANSITION --- */
/* Target the loaded app content (first child that isn't the loader) */
#app > :not(.loader-container):first-of-type {
    animation: app-entry 0.8s cubic-bezier(0.2, 0.8, 0.2, 1) forwards;
    opacity: 0;
    /* Ensures the app itself tries to fill the screen initially */
    width: 100%;
    height: 100%;
}

@keyframes app-entry {
    0% {
        opacity: 0;
        transform: translateY(20px) scale(0.99);
    }

    100% {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

/* --- BLAZOR ERROR UI (Subtle Notification) --- */
#blazor-error-ui {
    position: fixed;
    bottom: 2rem;
    left: 50%;
    transform: translateX(-50%);
    z-index: 1000;
    background: var(--error-bg);
    color: var(--error-text);
    border: 1px solid var(--error-border);
    box-shadow: var(--error-shadow);
    border-radius: 12px;
    padding: 0.8rem 1.2rem;
    display: flex !important;
    flex-direction: row;
    align-items: center;
    gap: 1rem;
    white-space: nowrap;
    /* Hides the "An unhandled error..." text node if it exists */
    font-size: 0;
    animation: slide-up-fade 0.4s cubic-bezier(0.16, 1, 0.3, 1);
    visibility: hidden;
}

    #blazor-error-ui[style*="display: block"] {
        visibility: visible;
    }

    /* Inject the localized, subtle message */
    #blazor-error-ui::before {
        content: var(--error-message-text);
        font-size: 0.9rem;
        font-weight: 500;
        margin-right: auto;
    }

    #blazor-error-ui .reload {
        color: var(--error-btn-text);
        text-decoration: none;
        font-weight: 600;
        /* FIX: Set font-size to 0 to hide original text */
        font-size: 0;
        padding: 0.4rem 1rem;
        background: var(--error-btn-bg);
        border-radius: 6px;
        transition: all 0.2s;
    }

        /* Inject localized button text */
        #blazor-error-ui .reload::after {
            content: var(--reload-btn-text);
            /* FIX: Restore readable font-size for the replacement text */
            font-size: 0.85rem;
        }

        #blazor-error-ui .reload:hover {
            filter: brightness(1.1);
            transform: translateY(-1px);
        }

    #blazor-error-ui .dismiss {
        cursor: pointer;
        font-style: normal;
        opacity: 0.4;
        transition: opacity 0.2s;
        display: flex;
        align-items: center;
        justify-content: center;
        font-size: 1.2rem;
        width: 24px;
        height: 24px;
        margin-left: 0.5rem;
        color: var(--text-primary);
    }

        #blazor-error-ui .dismiss:hover {
            opacity: 1;
        }

@keyframes slide-up-fade {
    from {
        opacity: 0;
        transform: translate(-50%, 20px);
    }

    to {
        opacity: 1;
        transform: translate(-50%, 0);
    }
}

/* --- BLAZOR ERROR BOUNDARY (Component Crash) --- */
.blazor-error-boundary {
    background-color: var(--bg-canvas);
    border: 1px solid var(--error-border);
    border-radius: 8px;
    padding: 3rem;
    margin: 1rem;
    color: var(--text-secondary);
    text-align: center;
    opacity: 0.8;
}

    .blazor-error-boundary::after {
        content: "Content temporarily unavailable.";
        font-weight: 500;
        display: block;
        margin-bottom: 0.5rem;
        font-size: 0.95rem;
        color: var(--text-primary);
    }
