/* ===========================================
   Qualify Page Styles - Enhanced v2
   =========================================== */

:root {
    --bg-dark: #0a0a0f;
    --bg-medium: #12121a;
    --bg-light: #1a1a24;
    --accent-red: #e8002d;
    --accent-gold: #ffd700;
    --text-primary: #ffffff;
    --text-secondary: rgba(255, 255, 255, 0.7);
    --text-muted: rgba(255, 255, 255, 0.4);
    --border-color: rgba(255, 255, 255, 0.08);
    --red: #e8002d;
}

/* Section */
.qualify-section {
    padding: 80px 5vw 120px;
    background: #0e0e1a;
    min-height: 100vh;
    position: relative;
}

.qualify-section::before {
    content: '';
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: radial-gradient(ellipse 60% 50% at 50% 0%, rgba(232, 0, 45, 0.08) 0%, transparent 70%);
    pointer-events: none;
    z-index: 0;
}

.qualify-container {
    max-width: 1200px;
    margin: 0 auto;
    position: relative;
    z-index: 1;
}

/* Section Header */
.section-header {
    text-align: center;
    margin-bottom: 52px;
}

.section-header .eyebrow {
    text-transform: uppercase;
    letter-spacing: 0.2em;
    color: var(--muted);
    font-size: 0.9rem;
    margin-bottom: 1rem;
}


.section-header h1 {
    font-size: clamp(2rem, 5vw, 4rem);
    font-weight: 900;
    margin: 0 0 1rem;
    letter-spacing: 0.06em;
    color: var(--text-primary);
    line-height: 1;
}

.section-description {
    color: var(--text-secondary);
    font-size: 1.05rem;
}

/* Loading State */
.loading-state {
    text-align: center;
    padding: 80px;
    color: var(--text-muted);
}

.spinner {
    width: 40px;
    height: 40px;
    border: 3px solid rgba(255, 255, 255, 0.1);
    border-top-color: #e8002d;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
    margin: 0 auto 16px;
}

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

/* Empty State */
.empty-state-block {
    text-align: center;
    padding: 80px 40px;
    color: var(--text-muted);
    border: 1px solid var(--border-color);
    border-radius: 20px;
    background: rgba(255, 255, 255, 0.02);
    display: flex;
    flex-direction: column;
    align-items: center;
}

.empty-state-block h3 {
    color: var(--text-secondary);
    margin: 0 0 8px;
}

/* Premium Countdown Block */
.countdown-premium {
    text-align: center;
    margin: 0 auto 32px;
    width: 100%;
    background: linear-gradient(145deg, rgba(20, 20, 30, 0.6), rgba(10, 10, 15, 0.8));
    border: 1px solid rgba(230, 0, 46, 0.3);
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.4), inset 0 0 20px rgba(230, 0, 46, 0.05);
    border-radius: 20px;
    padding: clamp(24px, 5vw, 36px) clamp(12px, 3vw, 24px);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    position: relative;
    overflow: hidden;
    animation: fadeInDown 0.6s ease;
}

.countdown-premium::before {
    content: '';
    position: absolute;
    top: 0;
    left: 10%;
    right: 10%;
    height: 2px;
    background: linear-gradient(90deg, transparent, rgba(230, 0, 46, 0.8), transparent);
    box-shadow: 0 0 15px rgba(230, 0, 46, 0.6);
}

.countdown-label {
    font-size: 0.9rem;
    letter-spacing: 4px;
    color: var(--red);
    font-weight: 800;
    margin-bottom: 24px;
    text-transform: uppercase;
    text-shadow: 0 0 8px rgba(230, 0, 46, 0.4);
}

.is-live .countdown-label {
    animation: pulse-text-live 1.5s infinite;
}

@keyframes pulse-text-live {
    0%, 100% { opacity: 1; text-shadow: 0 0 8px rgba(230, 0, 46, 0.6); }
    50% { opacity: 0.6; text-shadow: none; }
}

.countdown-timer-wrapper {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: clamp(8px, 2vw, 20px);
    flex-wrap: wrap;
}


.cd-box {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    background: rgba(0, 0, 0, 0.4);
    border: 1px solid rgba(255, 255, 255, 0.05);
    border-radius: 16px;
    width: clamp(70px, 18vw, 90px);
    height: clamp(80px, 20vw, 100px);
    box-shadow: inset 0 2px 10px rgba(0, 0, 0, 0.5), 0 4px 12px rgba(0, 0, 0, 0.3);
    position: relative;
    transition: transform 0.3s ease, box-shadow 0.3s ease;
}

.cd-box {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    background: rgba(0, 0, 0, 0.4);
    border: 1px solid rgba(255, 255, 255, 0.05);
    border-radius: 16px;
    width: 90px;
    height: 100px;
    box-shadow: inset 0 2px 10px rgba(0, 0, 0, 0.5), 0 4px 12px rgba(0, 0, 0, 0.3);
    position: relative;
    transition: transform 0.3s ease, box-shadow 0.3s ease;
}

.cd-num {
    font-size: clamp(2rem, 8vw, 3.5rem);
    font-weight: 900;
    font-family: 'Rajdhani', monospace;
    color: #fff;
    line-height: 1;
    text-shadow: 0 0 15px rgba(255, 255, 255, 0.2);
}

.cd-text {
    font-size: clamp(0.6rem, 2vw, 0.7rem);
    letter-spacing: clamp(1px, 0.5vw, 2px);
    color: rgba(255, 255, 255, 0.5);
    margin-top: 8px;
    font-weight: 600;
}

.cd-separator {
    font-size: clamp(2rem, 8vw, 3.5rem);
    color: rgba(230, 0, 46, 0.5);
    font-weight: 300;
    align-self: center;
    margin-top: -20px;
    animation: pulse-sep 1.5s infinite;
}

@keyframes pulse-sep {
    0%, 100% { opacity: 1; text-shadow: 0 0 12px rgba(230, 0, 46, 0.6); }
    50% { opacity: 0.3; text-shadow: none; }
}

.countdown-date-info {
    margin-top: 24px;
    font-size: 0.9rem;
    color: rgba(255, 255, 255, 0.5);
    letter-spacing: 1px;
}

@keyframes fadeInDown {
    from {
        opacity: 0;
        transform: translateY(-20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Event Info Bar */
.event-info-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 24px;
    background: linear-gradient(135deg, #13131f 0%, #16162b 100%);
    border: 1px solid rgba(232, 0, 45, 0.25);
    border-radius: 16px;
    padding: 24px 32px;
    margin-bottom: 28px;
    box-shadow: 0 4px 30px rgba(232, 0, 45, 0.08);
}

.event-series-tag {
    display: inline-block;
    background: #e8002d;
    color: #fff;
    font-size: 0.68rem;
    font-weight: 800;
    letter-spacing: 0.18em;
    padding: 4px 12px;
    border-radius: 4px;
    margin-bottom: 10px;
    text-transform: uppercase;
}

.event-titles h2 {
    margin: 0 0 4px;
    font-size: 1.45rem;
    font-weight: 900;
    color: #fff;
    letter-spacing: 0.02em;
}

.event-titles p {
    margin: 0;
    color: var(--text-muted);
    font-size: 0.9rem;
}

.event-info-right {
    display: flex;
    gap: 32px;
    align-items: center;
    flex-shrink: 0;
}

.event-stat {
    text-align: center;
}

.stat-value {
    display: block;
    font-size: 1.8rem;
    font-weight: 900;
    color: #fff;
    line-height: 1;
    margin-bottom: 4px;
}

.stat-label {
    font-size: 0.7rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.12em;
}

/* Body Layout */
.qualify-body {
    display: flex;
    flex-direction: column;
    gap: 32px;
}

.qualify-body.no-map {
    display: flex;
}

/* Track Map Panel */
.track-map-panel {
    background: linear-gradient(160deg, #13131f, #0d0d18);
    border: 1px solid var(--border-color);
    border-radius: 16px;
    padding: 30px;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
}

.track-map-panel img {
    width: 100%;
    max-height: 450px;
    object-fit: contain;
    border-radius: 8px;
    filter: brightness(0.9) contrast(1.15);
    transition: filter 0.3s;
}

.track-map-panel img:hover {
    filter: brightness(1) contrast(1.2);
}

/* Results Panel */
.results-panel {
    background: linear-gradient(160deg, #13131f, #0e0e1c);
    border: 1px solid var(--border-color);
    border-radius: 16px;
    overflow: hidden;
    box-shadow: 0 8px 40px rgba(0, 0, 0, 0.3);
}

/* Header Row */
.results-header-row {
    display: grid;
    grid-template-columns: 60px 1fr 150px 160px;
    padding: 14px 0;
    background: #1a1a2e;
    border-bottom: 2px solid #e8002d;
    font-size: 0.68rem;
    font-weight: 700;
    letter-spacing: 0.18em;
    color: rgba(255, 255, 255, 0.45);
    text-transform: uppercase;
}

.results-header-row .col-pos {
    display: flex;
    justify-content: center;
    align-items: center;
}

/* Result Row */
.result-row-item {
    display: grid;
    grid-template-columns: 60px 1fr 150px 160px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.04);
    transition: background 0.2s;
    min-height: 60px;
    animation: slideIn 0.3s ease both;
}

@keyframes slideIn {
    from {
        opacity: 0;
        transform: translateX(-8px);
    }

    to {
        opacity: 1;
        transform: translateX(0);
    }
}

.result-row-item:last-child {
    border-bottom: none;
}

.result-row-item:hover {
    background: rgba(255, 255, 255, 0.03);
}

.result-row-item.top1 {
    background: rgba(255, 215, 0, 0.06);
}

.result-row-item.top2 {
    background: rgba(192, 192, 192, 0.04);
}

.result-row-item.top3 {
    background: rgba(205, 127, 50, 0.04);
}

.result-row-item.top1:hover {
    background: rgba(255, 215, 0, 0.09);
}

.result-row-item .col-pos {
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.25rem;
    font-weight: 900;
    border-right: 3px solid transparent;
    padding: 0 16px;
    font-variant-numeric: tabular-nums;
}

.result-row-item.top1 .col-pos {
    color: #FFD700;
    border-right-color: #FFD700;
}

.result-row-item.top2 .col-pos {
    color: #C0C0C0;
    border-right-color: #C0C0C0;
}

.result-row-item.top3 .col-pos {
    color: #CD7F32;
    border-right-color: #CD7F32;
}

.col-driver {
    display: flex;
    align-items: center;
    padding: 0 20px;
    font-weight: 600;
    font-size: 1rem;
}

.driver-name-text .first-name {
    font-weight: 500;
    opacity: 0.8;
    font-size: 0.82em;
    text-transform: uppercase;
}

.driver-name-text .last-name {
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.col-time {
    display: flex;
    align-items: center;
    padding: 0 20px;
    font-family: 'Courier New', monospace;
    font-size: 1rem;
    font-weight: 700;
    color: rgba(255, 255, 255, 0.85);
    letter-spacing: 0.05em;
}

.result-row-item.top1 .col-time {
    color: #FFD700;
}

.col-gap {
    display: flex;
    align-items: center;
    padding: 0 20px;
    font-family: 'Courier New', monospace;
    font-size: 1rem;
    color: #ffffff;
    letter-spacing: 0.03em;
}

.col-gap.pole {
    color: #e8002d;
    font-size: 0.72rem;
    font-weight: 800;
    letter-spacing: 0.08em;
    text-transform: uppercase;
}

span.pole {
    background: rgba(232, 0, 45, 0.15);
    border: 1px solid rgba(232, 0, 45, 0.4);
    border-radius: 4px;
    padding: 3px 8px;
}

/* Risky Zone Row */
.risky-zone-row {
    width: 100%;
    box-sizing: border-box;
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 60px;
    margin: 0;
    padding: 0 24px;
    background: rgba(138, 43, 226, 0.05); /* very subtle purple bg */
    border-top: 1px solid rgba(138, 43, 226, 0.4);
    border-bottom: 1px solid rgba(138, 43, 226, 0.4);
    border-left: none;
    border-right: none;
    border-radius: 0;
    box-shadow: 0 0 15px rgba(138, 43, 226, 0.1);
    opacity: 0.9;
}

.risky-text {
    font-size: 0.8rem;
    font-weight: 800;
    color: #b366ff; /* light purple text */
    letter-spacing: 0.25em;
    text-transform: uppercase;
    display: flex;
    align-items: center;
    gap: 12px;
}

.risky-arrow {
    display: flex;
    flex-direction: column;
    gap: -4px; /* overlap slightly */
    color: #e8002d; /* Keep arrows red to imply danger, or change to purple if requested "màu tím chủ đạo" but danger usually red. Let's make them purple too for consistency with "khung viền cần có màu tím chủ đạo" */
    color: #b366ff;
    animation: bounceDown 2s infinite;
}

@keyframes bounceDown {
    0%, 20%, 50%, 80%, 100% {
        transform: translateY(0);
    }
    40% {
        transform: translateY(-5px);
    }
    60% {
        transform: translateY(-3px);
    }
}


/* History Section */
.history-card {
    background: linear-gradient(135deg, rgba(255, 255, 255, 0.03), rgba(255, 255, 255, 0.01));
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 12px;
    padding: 24px;
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.history-card:hover {
    background: linear-gradient(135deg, rgba(232, 0, 45, 0.1), rgba(232, 0, 45, 0.02));
    border-color: rgba(232, 0, 45, 0.3);
    transform: translateY(-4px);
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
}

.hc-title {
    font-size: 1.2rem;
    font-weight: 800;
    color: #fff;
    margin: 0;
}

.hc-sub {
    font-size: 0.85rem;
    color: var(--text-muted);
    margin: 0;
    line-height: 1.4;
}

.hc-meta {
    margin-top: auto;
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding-top: 16px;
    border-top: 1px solid rgba(255, 255, 255, 0.05);
    font-size: 0.8rem;
    color: var(--text-muted);
}

.hc-meta-item {
    display: flex;
    align-items: center;
    gap: 6px;
}

/* Responsive */
@media (max-width: 1024px) {

    .results-header-row,
    .result-row-item {
        grid-template-columns: 56px 1fr 130px 130px;
    }
}

@media (max-width: 900px) {
    .qualify-body {
        gap: 20px;
    }

    .track-map-panel img {
        max-height: 280px;
    }

    .event-info-bar {
        flex-direction: column;
        align-items: flex-start;
    }

    .event-info-right {
        width: 100%;
        justify-content: space-around;
    }
}

@media (max-width: 600px) {
    .qualify-section {
        padding: 90px 2vw 80px;
    }

    .results-header-row,
    .result-row-item {
        grid-template-columns: 36px 1fr 85px 75px;
        padding: 10px 4px;
    }

    .result-row-item .col-pos {
        padding: 0 4px;
        font-size: 1.05rem;
    }

    .col-driver {
        padding: 0 6px;
        font-size: 0.85rem;
    }

    .col-time {
        padding: 0 4px;
        font-size: 0.85rem;
    }

    .col-gap {
        padding: 0 4px;
        font-size: 0.85rem;
    }

    .countdown-timer-wrapper {
        display: grid !important;
        grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
        gap: 12px !important;
        max-width: 320px;
        margin: 0 auto;
    }


    .cd-box {
        width: 100% !important;
        height: 85px !important;
        border-radius: 12px !important;
    }

    .cd-num {
        font-size: 2.2rem !important;
    }

    .cd-text {
        font-size: 0.6rem !important;
        letter-spacing: 1px !important;
        margin-top: 4px !important;
    }

    .cd-separator {
        display: none !important;
    }

    .countdown-label {
        font-size: 0.75rem !important;
        letter-spacing: 2px !important;
        margin-bottom: 20px !important;
    }

    .countdown-date-info {
        font-size: 0.75rem !important;
        margin-top: 20px !important;
        line-height: 1.4;
    }
}


