﻿/* ===================================================================
   LOADING.CSS - SMART LOADING INDICATORS
   Overlay uses opacity + pointer-events (never display:none)
   so CSS transitions always fire correctly.
   =================================================================== */

/* ===================================================================
   FULL PAGE OVERLAY (navigation — shows after 2s threshold)
   =================================================================== */

.page-loader-overlay {
    position: fixed;
    inset: 0;
    background: rgba(255, 255, 255, 0.92);
    backdrop-filter: blur(6px);
    -webkit-backdrop-filter: blur(6px);
    z-index: 9999;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.25s ease;
}

    .page-loader-overlay.active {
        opacity: 1;
        pointer-events: auto;
    }

.page-loader-content {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1rem;
    background: transparent !important;
    border: none !important;
    box-shadow: none !important;
    padding: 0 !important;
    border-radius: 0 !important;
}

.page-loader-spinner {
    width: 44px;
    height: 44px;
    border: 3px solid rgba(255, 255, 255, 0.15);
    border-top-color: var(--accent-primary, #2563eb);
    border-radius: 50%;
    animation: spin 0.75s linear infinite;
}

.page-loader-text {
    font-size: 0.9rem;
    color: #e5e7eb;
    font-weight: 500;
    letter-spacing: 0.05em;
    background: transparent !important;
    border: none !important;
    box-shadow: none !important;
}

/* ===================================================================
   TOP PROGRESS BAR (fetch/AJAX — shows after 2s threshold)
   =================================================================== */

.progress-bar-container {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    height: 3px;
    z-index: 10000;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.2s ease;
}

    .progress-bar-container.active {
        opacity: 1;
    }

.progress-bar {
    height: 100%;
    width: 0%;
    background: var(--accent-primary, #2563eb);
    box-shadow: 0 0 8px var(--accent-primary, #2563eb);
    transition: width 0.3s ease;
    animation: progressPulse 1.8s ease-in-out infinite;
}

@keyframes progressPulse {
    0%, 100% {
        width: 15%;
        margin-left: 0;
    }

    50% {
        width: 40%;
        margin-left: 30%;
    }
}

/* When JS sets an explicit width, stop the pulse animation */
.progress-bar[style*="width"] {
    animation: none;
}

/* ===================================================================
   BUTTON LOADER
   =================================================================== */

.btn-loading {
    position: relative;
    color: transparent !important;
    pointer-events: none;
}

    .btn-loading::after {
        content: '';
        position: absolute;
        width: 15px;
        height: 15px;
        top: 50%;
        left: 50%;
        margin: -8px 0 0 -8px;
        border: 2px solid currentColor;
        border-top-color: transparent;
        border-radius: 50%;
        animation: spin 0.6s linear infinite;
    }

/* ===================================================================
   INLINE LOADER
   =================================================================== */

.inline-loader {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.75rem;
}

.inline-loader-spinner {
    width: 18px;
    height: 18px;
    border: 2px solid var(--border-color, #e5e7eb);
    border-top-color: var(--accent-primary, #2563eb);
    border-radius: 50%;
    animation: spin 0.75s linear infinite;
}

.inline-loader-text {
    font-size: 0.85rem;
    color: var(--text-secondary, #6b7280);
}

/* ===================================================================
   SKELETON LOADER
   =================================================================== */

.skeleton {
    background: linear-gradient( 90deg, var(--border-color, #e5e7eb) 0%, var(--bg-secondary, #f9fafb) 50%, var(--border-color, #e5e7eb) 100% );
    background-size: 200% 100%;
    animation: skeletonMove 1.6s ease-in-out infinite;
    border-radius: 6px;
}

.skeleton-text {
    height: 1em;
    margin-bottom: 0.4rem;
}

.skeleton-text-sm {
    height: 0.75em;
}

.skeleton-text-lg {
    height: 1.5em;
}

.skeleton-card {
    height: 200px;
}

.skeleton-circle {
    border-radius: 50%;
}

/* ===================================================================
   LOADING STATE UTILITIES
   =================================================================== */

.loading-blur {
    filter: blur(2px);
    pointer-events: none;
    user-select: none;
    transition: filter 0.2s ease;
}

.loading-dim {
    opacity: 0.45;
    pointer-events: none;
    transition: opacity 0.2s ease;
}

/* ===================================================================
   KEYFRAMES
   =================================================================== */

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

@keyframes skeletonMove {
    0% {
        background-position: 200% 0;
    }

    100% {
        background-position: -200% 0;
    }
}

/* ===================================================================
   DARK MODE
   =================================================================== */

@media (prefers-color-scheme: dark) {
    .page-loader-overlay {
        background: rgba(17, 24, 39, 0.92);
    }

    .skeleton {
        background: linear-gradient( 90deg, var(--border-color, #374151) 0%, var(--bg-secondary, #1f2937) 50%, var(--border-color, #374151) 100% );
        background-size: 200% 100%;
        animation: skeletonMove 1.6s ease-in-out infinite;
    }
}

/* ===================================================================
   REDUCED MOTION
   =================================================================== */

@media (prefers-reduced-motion: reduce) {
    .page-loader-spinner,
    .inline-loader-spinner,
    .btn-loading::after,
    .skeleton {
        animation: none !important;
    }

    .progress-bar {
        animation: none !important;
        width: 100% !important;
    }

    .page-loader-overlay,
    .progress-bar-container {
        transition: none !important;
    }
}

/* ===================================================================
   RESPONSIVE
   =================================================================== */

@media (max-width: 768px) {
    .page-loader-spinner {
        width: 36px;
        height: 36px;
    }

    .page-loader-text {
        font-size: 0.82rem;
    }
}
