/**
 * Global Navigation Overlay
 * Masks the prerender flash during Blazor navigation
 * Positioned to cover only main content area, not navigation
 *
 * UPDATED: Handles both enhanced navigation and full page reloads
 */

/* CRITICAL: Default state is VISIBLE to prevent blank screens */
/* After page loads, content should NEVER be hidden again */
.main-panel {
    opacity: 1 !important;
    pointer-events: auto !important;
    transition: opacity 0.05s ease-in-out !important; /* Ultra-fast 50ms transition */
}

/* Only hide during very initial load (first 2 seconds) */
/* This rule has lower specificity and only applies on fresh page load */
html:not([data-page-loaded]) body:not(.blazor-loaded) .main-panel {
    opacity: 0 !important;
    pointer-events: none !important;
    transition: none !important;
}

/* After Blazor starts, ALWAYS show content regardless of any other state */
/* This overrides everything with highest specificity */
html[data-page-loaded] .main-panel {
    opacity: 1 !important;
    pointer-events: auto !important;
    transition: opacity 0.05s ease-in-out !important;
}

/* Deprecated: No longer hide during navigation - causes blank screens
body.navigating .main-panel {
    opacity: 0.3;
    pointer-events: none;
}
*/

#navigation-overlay {
    position: fixed;
    /* Cover main content area only, not sidebar/topbar */
    top: 0;
    left: 260px; /* Sidebar width */
    right: 0;
    bottom: 0;
    background: rgba(255, 255, 255, 0.95); /* Slightly opaque to better mask flash */
    z-index: 1040; /* Below modals (1050+) but above main content */
    display: none;
    opacity: 0;
    transition: none; /* No transition by default - JS controls instant show */
    pointer-events: none;
}

#navigation-overlay.active {
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 1;
    pointer-events: auto;
}

/* No transition when showing - JS handles instant display */
#navigation-overlay.active:not(.fading-out) {
    display: flex;
    opacity: 1;
    pointer-events: auto;
    transition: none; /* Instant appearance, no fade-in */
}

/* Fade out animation - balanced for smooth disappearance */
#navigation-overlay.fading-out {
    opacity: 0;
    transition: opacity 0.2s ease-out; /* 200ms fade-out for smooth exit */
}

/* Responsive adjustments */
/* When sidebar is collapsed/minimized */
@media (max-width: 991px) {
    #navigation-overlay {
        left: 0; /* Full width on smaller screens */
        top: 70px; /* Below topbar on mobile */
    }
}

/* When sidebar is in mini/collapsed mode */
body.sidebar_minimize #navigation-overlay {
    left: 80px; /* Mini sidebar width */
}

/* Simple spinner */
.navigation-spinner {
    width: 40px;
    height: 40px;
    border: 4px solid #f3f3f3;
    border-top: 4px solid #3498db;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

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

/* Optional: fade out the current page content during navigation */
body.navigating .page-inner {
    opacity: 0.7;
    pointer-events: none;
}
