/* ==========================================================================
   Loading States for Page Transitions
   ========================================================================== */

/* ==========================================================================
   Page Transition Animations
   ========================================================================== */

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes fadeOut {
    from {
        opacity: 1;
    }
    to {
        opacity: 0;
    }
}

.page-content-wrapper--loading {
    opacity: 0.6;
    pointer-events: none;
    transition: opacity 0.3s ease;
}

.loading-wrapper {
    min-height: calc(100vh - 70px);
    position: static !important;
}

.page-transition-loading {
    width: 100%;
}

/* Dash Loading overlay container - cover viewport minus navbar and center content */
/* When using custom_spinner, Dash wraps it differently - ensure it's positioned relative to viewport */
.page-transition-loading > div {
    position: fixed !important;
    top: 70px !important;
    left: 0 !important;
    right: 0 !important;
    bottom: 0 !important;
    width: 100vw !important;
    height: calc(100vh - 70px) !important;
    max-height: calc(100vh - 70px) !important;
    min-height: calc(100vh - 70px) !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    z-index: 1000 !important;
    /* Prevent it from expanding with page content */
    overflow: hidden !important;
}

/* Custom spinner wrapper - center the DMC Loader */
.page-transition-loading > div > div {
    position: absolute !important;
    top: 50% !important;
    left: 50% !important;
    transform: translate(-50%, -50%) !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
}

/* Dash Loading spinner container - center the custom spinner */
.page-transition-loading ._dash-loading,
.loading-wrapper ._dash-loading,
._dash-loading {
    position: relative !important;
    top: auto !important;
    left: auto !important;
    transform: none !important;
    margin: 0 !important;
    z-index: 1001 !important;
}

/* Ensure DMC Loader (custom spinner) is centered */
.page-transition-loading .mantine-Loader-root,
.page-transition-loading > div .mantine-Loader-root,
.page-transition-loading > div > div .mantine-Loader-root {
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    margin: 0 auto !important;
}

.loading-overlay {
    position: fixed;
    top: 70px; /* Below header */
    left: 0;
    right: 0;
    bottom: 0;
    background-color: rgba(255, 255, 255, 0.9);
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: center;
    animation: fadeIn 0.2s ease-in;
}

/* ==========================================================================
   Sidebar Loading States
   ========================================================================== */

.sidebar__nav-link--loading {
    position: relative;
    opacity: 0.7;
    pointer-events: none;
}

.sidebar__nav-link--loading::after {
    content: '';
    position: absolute;
    right: 15px;
    top: 50%;
    transform: translateY(-50%);
    width: 16px;
    height: 16px;
    border: 2px solid #0C1E35;
    border-radius: 50%;
    border-top-color: transparent;
    animation: spin 0.8s linear infinite;
}

.sidebar-loading-indicator {
    display: inline-block;
    margin-left: 8px;
    vertical-align: middle;
}

@keyframes spin {
    to {
        transform: translateY(-50%) rotate(360deg);
    }
}

.sidebar--transitioning .sidebar__nav-link {
    transition: opacity 0.3s ease;
}

.sidebar--transitioning .sidebar__nav-link:not(.active) {
    opacity: 0.6;
}


/* ==========================================================================
   Responsive Design
   ========================================================================== */

@media (max-width: 768px) {
    .skeleton-table-header,
    .skeleton-table-row {
        display: block;
    }

    .skeleton-header-cell,
    .skeleton-cell {
        width: 100% !important;
        margin-bottom: 8px;
    }

    .loading-container {
        min-height: 300px;
    }

    .loading-overlay {
        top: 60px;
    }
}

@media (min-width: 769px) and (max-width: 1024px) {
    .skeleton-card {
        margin-bottom: 15px;
    }
}

