/* ====================================
 * iPhone-style Loading Bar
 * ==================================== */

/* Container cho loading bar */
#page-loading-bar {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    height: 3px;
    z-index: 999999;
    background: transparent;
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.3s ease;
}

#page-loading-bar.active {
    opacity: 1;
}

/* Thanh loading chính */
#page-loading-bar .progress-bar {
    position: absolute;
    top: 0;
    left: 0;
    height: 100%;
    background: linear-gradient(90deg,
            #007aff 0%,
            /* iOS Blue */
            #5ac8fa 50%,
            /* iOS Light Blue */
            #007aff 100%);
    box-shadow: 0 0 10px rgba(0, 122, 255, 0.5);
    border-radius: 0 3px 3px 0;
    transition: width 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    will-change: width;
}

/* Hiệu ứng shimmer/glow */
#page-loading-bar .progress-bar::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(90deg,
            transparent 0%,
            rgba(255, 255, 255, 0.3) 50%,
            transparent 100%);
    animation: shimmer 1.5s infinite;
}

/* Pulsing light effect ở đầu thanh */
#page-loading-bar .progress-bar::after {
    content: '';
    position: absolute;
    top: -2px;
    right: -2px;
    width: 8px;
    height: 8px;
    background: rgba(0, 122, 255, 0.8);
    border-radius: 50%;
    box-shadow:
        0 0 8px rgba(0, 122, 255, 0.8),
        0 0 12px rgba(0, 122, 255, 0.6),
        0 0 16px rgba(0, 122, 255, 0.4);
    animation: pulse 1s ease-in-out infinite;
}

/* Animation cho shimmer effect */
@keyframes shimmer {
    0% {
        transform: translateX(-100%);
    }

    100% {
        transform: translateX(100%);
    }
}

/* Animation cho pulsing light */
@keyframes pulse {

    0%,
    100% {
        opacity: 1;
        transform: scale(1);
    }

    50% {
        opacity: 0.6;
        transform: scale(1.3);
    }
}

/* Spinner nhỏ (optional - hiển thị khi load lâu) */
#page-loading-spinner {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    z-index: 999998;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease;
}

#page-loading-spinner.active {
    opacity: 1;
}

.loading-spinner {
    width: 40px;
    height: 40px;
    border: 3px solid rgba(0, 122, 255, 0.1);
    border-top-color: #007aff;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

/* Overlay mờ (optional) */
#page-loading-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(255, 255, 255, 0.8);
    z-index: 999997;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease;
    backdrop-filter: blur(2px);
    -webkit-backdrop-filter: blur(2px);
}

#page-loading-overlay.active {
    opacity: 1;
    pointer-events: auto;
}

/* Dark mode support */
@media (prefers-color-scheme: dark) {
    #page-loading-bar .progress-bar {
        background: linear-gradient(90deg,
                #0a84ff 0%,
                #64d2ff 50%,
                #0a84ff 100%);
        box-shadow: 0 0 10px rgba(10, 132, 255, 0.5);
    }

    #page-loading-bar .progress-bar::after {
        background: rgba(10, 132, 255, 0.8);
        box-shadow:
            0 0 8px rgba(10, 132, 255, 0.8),
            0 0 12px rgba(10, 132, 255, 0.6),
            0 0 16px rgba(10, 132, 255, 0.4);
    }

    #page-loading-overlay.active {
        background: rgba(0, 0, 0, 0.5);
    }

    .loading-spinner {
        border-color: rgba(10, 132, 255, 0.1);
        border-top-color: #0a84ff;
    }
}

/* Responsive */
@media (max-width: 768px) {
    #page-loading-bar {
        height: 2px;
    }

    .loading-spinner {
        width: 32px;
        height: 32px;
        border-width: 2.5px;
    }
}