/**
 * Zibll HTMX Booster - Master Stylesheet
 * Gradient Progress Bar, Multi-Style Spinners, Transitions & Benchmark HUD
 */

/* ==========================================================================
   1. DUAL-TONE GRADIENT PROGRESS BAR (Thanh tiến trình tải trang đỉnh màn hình)
   ========================================================================== */
#zibll-htmx-progress {
    position: fixed;
    top: 0;
    left: 0;
    width: 0%;
    height: var(--zibll-htmx-height, 3px);
    background: var(--zibll-htmx-color, #ff3c6a);
    background: linear-gradient(90deg, var(--zibll-htmx-color, #ff3c6a) 0%, var(--zibll-htmx-color2, #6c5ce7) 100%);
    box-shadow: 0 0 10px var(--zibll-htmx-color, #ff3c6a), 0 0 5px rgba(255, 60, 106, 0.5);
    z-index: 9999999;
    pointer-events: none;
    opacity: 0;
    transition: width 0.25s cubic-bezier(0.1, 0.9, 0.2, 1), opacity 0.3s ease;
    border-radius: 0 2px 2px 0;
}

#zibll-htmx-progress.active {
    opacity: 1;
}

#zibll-htmx-progress .progress-peg {
    display: block;
    position: absolute;
    right: 0px;
    width: 100px;
    height: 100%;
    box-shadow: 0 0 14px var(--zibll-htmx-color2, #6c5ce7), 0 0 8px var(--zibll-htmx-color, #ff3c6a);
    border-radius: 100%;
    opacity: 1.0;
    transform: rotate(3deg) translate(0px, -4px);
}

/* ==========================================================================
   2. MULTI-STYLE HEADER LOADING SPINNERS (Biểu tượng xoay tròn Header đa phong cách)
   ========================================================================== */
#zibll-htmx-spinner {
    position: fixed;
    top: 20px;
    left: 20px;
    right: auto;
    z-index: 9999999;
    pointer-events: none;
    opacity: 0;
    transform: scale(0.8);
    transition: opacity 0.2s ease, transform 0.2s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    display: flex;
    align-items: center;
    justify-content: center;
}

#zibll-htmx-spinner.active {
    opacity: 1;
    transform: scale(1);
}

/* Vị trí trên PC */
#zibll-htmx-spinner.pos-left {
    left: 20px;
    right: auto;
}
#zibll-htmx-spinner.pos-right {
    right: 20px;
    left: auto;
}

/* Kiểu 1: Gradient Ring (Vòng xoay phát sáng Gradient - Mặc định) */
#zibll-htmx-spinner.style-ring .spinner-icon {
    width: 26px;
    height: 26px;
    box-sizing: border-box;
    border: solid 3px transparent;
    border-top-color: var(--zibll-htmx-color, #ff3c6a);
    border-right-color: var(--zibll-htmx-color2, #6c5ce7);
    border-radius: 50%;
    animation: zibll-htmx-spin 0.65s linear infinite;
    filter: drop-shadow(0 0 6px var(--zibll-htmx-color, #ff3c6a));
}

/* Kiểu 2: Glowing Pulse (Chấm tròn đập nhịp phát sáng) */
#zibll-htmx-spinner.style-pulse .spinner-icon {
    width: 16px;
    height: 16px;
    border-radius: 50%;
    background: var(--zibll-htmx-color, #ff3c6a);
    box-shadow: 0 0 0 0 rgba(255, 60, 106, 0.7);
    animation: zibll-htmx-pulse 1.2s infinite cubic-bezier(0.66, 0, 0, 1);
}

/* Kiểu 3: Modern Dots (3 Chấm nảy chuyển động) */
#zibll-htmx-spinner.style-dots .spinner-icon {
    display: flex;
    align-items: center;
    gap: 4px;
}
#zibll-htmx-spinner.style-dots .dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: var(--zibll-htmx-color, #ff3c6a);
    animation: zibll-htmx-dot-bounce 0.8s infinite ease-in-out both;
}
#zibll-htmx-spinner.style-dots .dot:nth-child(1) {
    animation-delay: -0.32s;
    background: var(--zibll-htmx-color, #ff3c6a);
}
#zibll-htmx-spinner.style-dots .dot:nth-child(2) {
    animation-delay: -0.16s;
    background: var(--zibll-htmx-color2, #6c5ce7);
}
#zibll-htmx-spinner.style-dots .dot:nth-child(3) {
    animation-delay: 0s;
    background: var(--zibll-htmx-color, #ff3c6a);
}

/* Kiểu 4: Classic Spinner (Vòng tròn cổ điển đơn sắc) */
#zibll-htmx-spinner.style-classic .spinner-icon {
    width: 24px;
    height: 24px;
    box-sizing: border-box;
    border: solid 2.5px rgba(255, 255, 255, 0.2);
    border-top-color: var(--zibll-htmx-color, #ff3c6a);
    border-radius: 50%;
    animation: zibll-htmx-spin 0.7s linear infinite;
}

@keyframes zibll-htmx-spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

@keyframes zibll-htmx-pulse {
    0% { transform: scale(0.9); box-shadow: 0 0 0 0 rgba(255, 60, 106, 0.7); }
    70% { transform: scale(1.15); box-shadow: 0 0 0 12px rgba(255, 60, 106, 0); }
    100% { transform: scale(0.9); box-shadow: 0 0 0 0 rgba(255, 60, 106, 0); }
}

@keyframes zibll-htmx-dot-bounce {
    0%, 80%, 100% { transform: scale(0); opacity: 0.3; }
    40% { transform: scale(1.0); opacity: 1; filter: drop-shadow(0 0 4px var(--zibll-htmx-color, #ff3c6a)); }
}

@media (max-width: 767px) {
    #zibll-htmx-spinner {
        top: 14px;
        left: 10px;
        right: auto !important;
    }
    #zibll-htmx-spinner.style-ring .spinner-icon,
    #zibll-htmx-spinner.style-classic .spinner-icon {
        width: 18px;
        height: 18px;
        border-width: 2px;
    }
    #zibll-htmx-spinner.style-pulse .spinner-icon {
        width: 12px;
        height: 12px;
    }
}

/* ==========================================================================
   3. BENCHMARK HUD BADGE (Đo thời gian tải trang SPA)
   ========================================================================== */
#zibll-htmx-benchmark {
    position: fixed;
    bottom: 25px;
    right: 25px;
    z-index: 9999998;
    background: rgba(18, 18, 24, 0.88);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    color: #fff;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    font-size: 11px;
    font-weight: 600;
    letter-spacing: 0.3px;
    padding: 5px 12px;
    border-radius: 20px;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.25), 0 0 0 1px rgba(255, 255, 255, 0.1);
    pointer-events: none;
    opacity: 0;
    transform: translateY(10px) scale(0.92);
    transition: opacity 0.25s ease, transform 0.25s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    display: flex;
    align-items: center;
    gap: 5px;
}

#zibll-htmx-benchmark.show {
    opacity: 1;
    transform: translateY(0) scale(1);
}

#zibll-htmx-benchmark .bm-icon {
    color: #ffd32a;
    font-size: 12px;
}

#zibll-htmx-benchmark .bm-time {
    color: #2ed573;
    font-weight: 700;
}

@media (max-width: 767px) {
    #zibll-htmx-benchmark {
        bottom: 70px;
        right: 15px;
        font-size: 10px;
        padding: 4px 10px;
    }
}

/* ==========================================================================
   4. PAGE TRANSITION EFFECTS (Hiệu ứng chuyển cảnh trang)
   ========================================================================== */
.zibll-htmx-container {
    transition-property: opacity, transform, filter;
    transition-duration: var(--zibll-htmx-speed, 200ms);
    transition-timing-function: cubic-bezier(0.4, 0, 0.2, 1);
    will-change: opacity, transform;
}

/* Hiệu ứng Làm mờ (Fade) */
.zibll-transition-fade.htmx-swapping,
.zibll-transition-fade.zibll-htmx-loading {
    opacity: 0.25;
    filter: blur(1px);
}
.zibll-transition-fade.htmx-settling {
    opacity: 1;
    filter: blur(0px);
}

/* Hiệu ứng Trượt nhẹ (Slide Up) */
.zibll-transition-slide-up.htmx-swapping,
.zibll-transition-slide-up.zibll-htmx-loading {
    opacity: 0;
    transform: translateY(15px);
}
.zibll-transition-slide-up.htmx-settling {
    opacity: 1;
    transform: translateY(0);
}

/* Hiệu ứng Phóng to nhẹ (Zoom / Scale) */
.zibll-transition-zoom.htmx-swapping,
.zibll-transition-zoom.zibll-htmx-loading {
    opacity: 0;
    transform: scale(0.985);
}
.zibll-transition-zoom.htmx-settling {
    opacity: 1;
    transform: scale(1);
}

/* Hiệu ứng Tức thì (Instant) */
.zibll-transition-none.htmx-swapping,
.zibll-transition-none.htmx-settling {
    transition: none !important;
}

/* ==========================================================================
   5. HTMX REQUEST INDICATOR
   ========================================================================== */
.htmx-request.zibll-htmx-spinner {
    display: inline-block;
}
.zibll-htmx-spinner {
    display: none;
}
