/**
 * Page Loading Indicator
 * Progress bar at top + overlay for slow loads
 */

/* ============================================================================
   PROGRESS BAR
   ============================================================================ */
.page-loader-bar {
    position: fixed;
    top: 0;
    left: 0;
    width: 0;
    height: 3px;
    background: linear-gradient(90deg, #7fd1de, #304e96, #7fd1de);
    background-size: 200% 100%;
    z-index: 999999;
    pointer-events: none;
    opacity: 0;
    visibility: hidden;
}

.page-loader-bar.active {
    opacity: 1;
    visibility: visible;
    animation: loader-progress 2s ease-out forwards, loader-shimmer 1s linear infinite;
}

@keyframes loader-progress {
    0% { width: 0; }
    20% { width: 30%; }
    50% { width: 60%; }
    80% { width: 80%; }
    100% { width: 95%; }
}

@keyframes loader-shimmer {
    0% { background-position: 200% 0; }
    100% { background-position: -200% 0; }
}

/* ============================================================================
   OVERLAY
   ============================================================================ */
.page-loader-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    width: 100%;
    height: 100%;
    background: rgba(255, 255, 255, 0.85);
    z-index: 999998;
    display: none;
    align-items: center;
    justify-content: center;
    flex-direction: column;
}

.page-loader-overlay.active {
    display: flex;
}

/* Dark mode */
[data-theme="dark"] .page-loader-overlay {
    background: rgba(20, 20, 30, 0.9);
}

/* ============================================================================
   SPINNER
   ============================================================================ */
.page-loader-spinner {
    width: 40px;
    height: 40px;
    border: 3px solid rgba(48, 78, 150, 0.2);
    border-top-color: #304e96;
    border-radius: 50%;
    animation: loader-spin 0.8s linear infinite;
}

[data-theme="dark"] .page-loader-spinner {
    border-color: rgba(127, 209, 222, 0.2);
    border-top-color: #7fd1de;
}

@keyframes loader-spin {
    to { transform: rotate(360deg); }
}

/* ============================================================================
   LOADING TEXT
   ============================================================================ */
.page-loader-text {
    margin-top: 16px;
    font-size: 0.9rem;
    color: #304e96;
    font-weight: 500;
}

.page-loader-text::after {
    content: '...';
    animation: loader-dots 1s steps(3, end) infinite;
}

@keyframes loader-dots {
    0% { content: ''; }
    33% { content: '.'; }
    66% { content: '..'; }
    100% { content: '...'; }
}

[data-theme="dark"] .page-loader-text {
    color: #7fd1de;
}

/* ============================================================================
   PREVENT DOUBLE-CLICK
   ============================================================================ */
body.page-loading a,
body.page-loading button[type="submit"] {
    pointer-events: none;
    cursor: wait;
}

body.page-loading {
    cursor: wait;
}

/* ============================================================================
   MOBILE
   ============================================================================ */
@media (max-width: 767px) {
    .page-loader-bar {
        height: 4px;
    }

    .page-loader-spinner {
        width: 36px;
        height: 36px;
    }

    .page-loader-text {
        font-size: 0.85rem;
    }
}

/* ============================================================================
   REDUCED MOTION
   ============================================================================ */
@media (prefers-reduced-motion: reduce) {
    .page-loader-bar,
    .page-loader-bar.active {
        animation: none;
        width: 100%;
    }

    .page-loader-spinner {
        animation: none;
    }

    .page-loader-text::after {
        animation: none;
    }
}

/* ============================================================================
   PRINT
   ============================================================================ */
@media print {
    .page-loader-bar,
    .page-loader-overlay {
        display: none !important;
    }
}
