﻿#top-loading-bar {
    position: fixed;
    top: 0;
    left: 0;
    height: 3px;
    width: 0%;
    z-index: 99999;
    opacity: 0;
    pointer-events: none;
    border-radius: 0 999px 999px 0;
    /* Brand gradient — swap colors to match your theme */
    background: linear-gradient( 90deg, #6366f1 0%, #8b5cf6 35%, #06b6d4 70%, #22d3ee 100% );
    /* Soft multi-layer glow */
    box-shadow: 0 0 6px rgba(99, 102, 241, 0.55), 0 0 14px rgba(139, 92, 246, 0.45), 0 0 26px rgba(6, 182, 212, 0.35);
    /* Smooth, springy feel */
    transition: width 0.45s cubic-bezier(0.22, 1, 0.36, 1), opacity 0.35s ease;
}

    #top-loading-bar.active {
        opacity: 1;
    }

    /* Animated shimmer sweep (like YouTube) */
    #top-loading-bar::after {
        content: '';
        position: absolute;
        inset: 0;
        border-radius: inherit;
        background: linear-gradient( 90deg, transparent 0%, rgba(255, 255, 255, 0.55) 50%, transparent 100% );
        opacity: 0;
        transform: translateX(-100%);
    }

    #top-loading-bar.active::after {
        opacity: 1;
        animation: loading-shimmer 1.4s cubic-bezier(0.4, 0, 0.2, 1) infinite;
    }

@keyframes loading-shimmer {
    0% {
        transform: translateX(-100%);
    }

    100% {
        transform: translateX(100%);
    }
}

/* Pulsing head dot */
#top-loading-bar::before {
    content: '';
    position: absolute;
    right: -2px;
    top: 50%;
    width: 10px;
    height: 10px;
    border-radius: 50%;
    transform: translateY(-50%) scale(0);
    background: #ffffff;
    box-shadow: 0 0 8px 2px rgba(255, 255, 255, 0.9), 0 0 16px 4px rgba(139, 92, 246, 0.7), 0 0 24px 6px rgba(99, 102, 241, 0.5);
    transition: transform 0.25s ease;
}

#top-loading-bar.active::before {
    transform: translateY(-50%) scale(1);
    animation: loading-pulse 1.2s ease-in-out infinite;
}

@keyframes loading-pulse {
    0%, 100% {
        opacity: 1;
        transform: translateY(-50%) scale(1);
    }

    50% {
        opacity: 0.65;
        transform: translateY(-50%) scale(0.75);
    }
}

/* Dark mode tweak */
[data-bs-theme="dark"] #top-loading-bar {
    background: linear-gradient( 90deg, #818cf8 0%, #a78bfa 35%, #22d3ee 70%, #67e8f9 100% );
    box-shadow: 0 0 6px rgba(129, 140, 248, 0.65), 0 0 16px rgba(167, 139, 250, 0.55), 0 0 30px rgba(34, 211, 238, 0.4);
}

/* Indeterminate state */
#top-loading-bar.indeterminate {
    width: 30% !important;
    background: linear-gradient( 90deg, transparent 0%, #6366f1 25%, #8b5cf6 50%, #06b6d4 75%, transparent 100% );
    background-size: 200% 100%;
    animation: loading-indeterminate 1.2s linear infinite;
}

@keyframes loading-indeterminate {
    0% {
        background-position: 200% 0;
    }

    100% {
        background-position: -200% 0;
    }
}

/* Reduced motion */
@media (prefers-reduced-motion: reduce) {
    #top-loading-bar,
    #top-loading-bar::after,
    #top-loading-bar::before,
    #top-loading-bar.indeterminate {
        animation: none !important;
        transition: opacity 0.2s ease !important;
    }
}
