/* ==========================================
   BOX OFFICE TABLE — RPN Box Office
   ========================================== */

/* ---- Date Filter ---- */
.boxoffice-date-filter {
    display: flex;
    align-items: center;
    gap: 16px;
    margin-bottom: 12px;
    flex-wrap: wrap;
}

.date-filter__quick {
    display: flex;
    gap: 6px;
}

.date-filter__btn {
    padding: 6px 16px;
    border-radius: 20px;
    border: 1px solid var(--border-default);
    background: var(--bg-card);
    font-size: 13px;
    font-weight: 600;
    color: var(--text-secondary);
    cursor: pointer;
    transition: all 0.2s;
    font-family: inherit;
}

.date-filter__btn:hover {
    border-color: var(--brand-red);
    color: var(--brand-red);
}

.date-filter__btn.active {
    background: var(--brand-red);
    border-color: var(--brand-red);
    color: #fff;
}

.date-filter__custom {
    display: flex;
    align-items: center;
    gap: 6px;
    margin-left: auto;
}

.date-filter__input {
    padding: 5px 10px;
    border-radius: 6px;
    border: 1px solid var(--border-default);
    font-size: 12px;
    font-family: inherit;
    color: var(--text-primary);
    background: var(--bg-card);
}

.date-filter__input:focus {
    outline: none;
    border-color: var(--brand-red);
}

.date-filter__separator {
    color: var(--text-tertiary);
    font-size: 13px;
}

.date-filter__apply {
    padding: 5px 14px;
    border-radius: 6px;
    border: none;
    background: var(--brand-red);
    color: #fff;
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
    font-family: inherit;
    transition: all 0.2s;
}

.date-filter__apply:hover {
    background: #c62a38;
    box-shadow: var(--shadow-glow-red);
}

/* ---- Count-up animation helpers ---- */
[data-countup] {
    font-variant-numeric: tabular-nums;
}

/* ---- Progress Bar ---- */
.boxoffice-progress {
    display: flex;
    align-items: center;
    gap: var(--space-4);
    padding: var(--space-3) 0;
}

.boxoffice-progress__bar {
    flex: 0 0 200px;
    height: 6px;
    background: var(--bg-elevated);
    border-radius: var(--radius-full);
    overflow: hidden;
}

.boxoffice-progress__fill {
    height: 100%;
    background: var(--gradient-cyan);
    border-radius: var(--radius-full);
    transition: width 0.3s ease;
}

.boxoffice-progress__fill--pulse {
    width: 100%;
    animation: progress-pulse 2s ease-in-out infinite;
}

@keyframes progress-pulse {
    0%, 100% { opacity: 0.3; transform: scaleX(0.3); transform-origin: left; }
    50% { opacity: 1; transform: scaleX(1); }
}

.boxoffice-progress__text {
    font-size: var(--text-xs);
    color: var(--accent-cyan);
    animation: pulse 1.5s ease-in-out infinite;
}

/* ---- Summary ---- */
.boxoffice-summary {
    display: flex;
    align-items: center;
    gap: var(--space-3);
    padding: var(--space-2) 0;
    flex-wrap: wrap;
}

.boxoffice-summary__badge {
    font-size: var(--text-xs);
    color: var(--accent-emerald);
    background: var(--accent-emerald-soft);
    padding: 2px 10px;
    border-radius: var(--radius-full);
    font-weight: 600;
}

.boxoffice-summary__text {
    font-size: var(--text-sm);
    color: var(--text-secondary);
}

.boxoffice-summary__time {
    font-size: var(--text-xs);
    color: var(--text-tertiary);
    margin-left: auto;
}

/* ---- Total Revenue Row (BO-style) ---- */
.boxoffice-total-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: var(--space-5) var(--space-6);
    background: linear-gradient(135deg, rgba(226, 51, 64, 0.06) 0%, rgba(252, 157, 166, 0.08) 100%);
    border: 1px solid rgba(226, 51, 64, 0.15);
    border-radius: var(--radius-lg);
    margin-bottom: var(--space-4);
    flex-wrap: wrap;
    gap: var(--space-4);
}

.boxoffice-total__label {
    font-size: var(--text-lg);
    font-weight: 700;
    color: var(--text-primary);
    letter-spacing: -0.01em;
}

.boxoffice-total__stats {
    display: flex;
    align-items: center;
    gap: var(--space-5);
}

.boxoffice-total__item {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2px;
}

.boxoffice-total__value {
    font-family: var(--font-display);
    font-weight: 800;
    font-size: var(--text-2xl);
    color: var(--text-primary);
    line-height: 1.1;
}

.boxoffice-total__value--revenue {
    color: var(--brand-red);
    font-size: var(--text-3xl);
}

.boxoffice-total__unit {
    font-size: var(--text-xs);
    color: var(--text-tertiary);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    font-weight: 500;
}

.boxoffice-total__divider {
    width: 1px;
    height: 36px;
    background: var(--border-subtle);
}

/* ---- Box Office Table ---- */
.boxoffice-header-row {
    display: grid;
    grid-template-columns: 50px 1fr 90px 90px 190px;
    gap: var(--space-4);
    padding: var(--space-3) var(--space-4);
    background: var(--bg-elevated);
    border-radius: var(--radius-md);
    margin-bottom: var(--space-2);
    position: sticky;
    top: 0;
    z-index: 5;
}

.boxoffice-col {
    font-size: var(--text-xs);
    color: var(--text-tertiary);
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    display: flex;
    align-items: center;
}

.boxoffice-col--rank {
    justify-content: center;
}

.boxoffice-col--num,
.boxoffice-col--revenue {
    justify-content: flex-end;
    flex-direction: column;
    align-items: flex-end;
    gap: 1px;
}

/* ---- Box Office Row ---- */
.boxoffice-row {
    display: grid;
    grid-template-columns: 50px 1fr 90px 90px 190px;
    gap: var(--space-4);
    padding: var(--space-3) var(--space-4);
    background: var(--bg-card);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-md);
    margin-bottom: var(--space-1);
    align-items: center;
    transition: all var(--transition-fast);
}

.boxoffice-row:hover {
    background: var(--bg-card-hover);
    border-color: var(--border-default);
    transform: translateX(2px);
}

.boxoffice-row--top {
    border-color: var(--border-default);
}

.boxoffice-row--top:nth-child(3) {
    background: linear-gradient(135deg, rgba(226, 51, 64, 0.04) 0%, var(--bg-card) 100%);
    border-color: rgba(226, 51, 64, 0.15);
}

/* ---- Rank ---- */
.boxoffice-rank {
    font-family: var(--font-display);
    font-weight: 700;
    font-size: var(--text-lg);
    color: var(--text-tertiary);
    text-align: center;
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.boxoffice-rank--1 { font-size: 1.5rem; }
.boxoffice-rank--2 { font-size: 1.4rem; }
.boxoffice-rank--3 { font-size: 1.3rem; }

/* ---- Movie Column ---- */
.boxoffice-col--movie {
    display: flex;
    align-items: center;
    gap: var(--space-3);
    min-width: 0;
}

.boxoffice-poster {
    width: 40px;
    min-width: 40px;
    max-width: 40px;
    height: 56px;
    max-height: 56px;
    border-radius: 4px;
    object-fit: cover;
    object-position: top center;
    flex-shrink: 0;
    box-shadow: 0 2px 8px rgba(0,0,0,0.3);
}

.boxoffice-poster--placeholder {
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--bg-elevated);
    border: 1px solid var(--border-subtle);
    font-size: 18px;
}

.boxoffice-movie-info {
    display: flex;
    flex-direction: column;
    gap: 2px;
    min-width: 0;
}

.boxoffice-movie-name {
    font-weight: 600;
    font-size: var(--text-sm);
    color: var(--text-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* ---- Numbers ---- */
.boxoffice-num {
    font-family: var(--font-display);
    font-weight: 600;
    font-size: var(--text-base);
    color: var(--text-primary);
}

.boxoffice-num-label {
    font-size: 10px;
    color: var(--text-tertiary);
    font-weight: 400;
}

/* ---- Revenue ---- */
.boxoffice-revenue {
    font-family: var(--font-display);
    font-weight: 700;
    font-size: 15px;
    color: #E23340;
    white-space: nowrap;
}

/* ---- Section ---- */
.boxoffice-section {
    margin-bottom: var(--space-10);
}

.boxoffice-section .section-header {
    margin-bottom: var(--space-3);
}

.boxoffice-note {
    font-size: var(--text-xs);
    color: var(--text-tertiary);
    padding: var(--space-3) var(--space-4);
    background: var(--bg-card);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-md);
    margin-top: var(--space-3);
    display: flex;
    align-items: center;
    gap: var(--space-2);
}

/* Mobile-only movie name (shown inside ticket col on mobile) */
.boxoffice-mobile-name {
    display: none;
}

/* Mobile-only ticket stats in showtimes col (hidden on desktop) */
.boxoffice-num--tickets-mobile,
.boxoffice-num-label--tickets-mobile,
.boxoffice-stats-divider {
    display: none;
}

/* ---- Responsive ---- */
@media (max-width: 1200px) {
    .boxoffice-header-row,
    .boxoffice-row {
        grid-template-columns: 40px 1fr 80px 80px 160px;
    }
    
    .boxoffice-total-row {
        flex-direction: column;
        align-items: flex-start;
    }
}

/* ==========================================
   MOBILE: BoxOfficeVietnam-inspired card layout
   ========================================== */
@media (max-width: 768px) {
    /* ---- Date filter ---- */
    .boxoffice-date-filter { gap: 8px; }
    .date-filter__custom { margin-left: 0; width: 100%; justify-content: space-between; }
    .date-filter__input { flex: 1; min-width: 0; font-size: 13px; padding: 8px; }
    .date-filter__apply { padding: 8px 16px; font-size: 13px; }

    /* ---- Header row: hidden ---- */
    .boxoffice-header-row { display: none; }

    /* ---- Total row ---- */
    .boxoffice-total-row { padding: 16px; gap: 8px; }
    .boxoffice-total__label { font-size: 14px; width: 100%; }
    .boxoffice-total__stats { width: 100%; justify-content: space-between; }
    .boxoffice-total__value { font-size: var(--text-xl); }
    .boxoffice-total__value--revenue { font-size: var(--text-2xl); }
    .boxoffice-total__divider { height: 28px; }

    /* ============================================
       CARD LAYOUT — boxofficevietnam.com style
       
       2 columns: [poster area] [content area]
       Rank = overlay badge on poster
       Content = name → revenue → vé + suất chiếu
       ============================================ */
    .boxoffice-row {
        position: relative;
        display: grid;
        grid-template-columns: 100px 1fr;
        grid-template-rows: auto auto auto;
        gap: 4px 14px;
        padding: 14px;
        margin-bottom: 8px;
        border-radius: var(--radius-lg);
        border-left: 5px solid var(--border-subtle);
        align-items: start;
    }
    .boxoffice-row:hover { transform: none; }

    /* Top 3 colored borders */
    .boxoffice-row--top:nth-child(2) {
        border-left-color: #E23340;
        background: linear-gradient(135deg, rgba(226,51,64,0.04) 0%, var(--bg-card) 100%);
    }
    .boxoffice-row--top:nth-child(3) {
        border-left-color: #FF6B35;
        background: linear-gradient(135deg, rgba(255,107,53,0.04) 0%, var(--bg-card) 100%);
    }
    .boxoffice-row--top:nth-child(4) {
        border-left-color: #FFB800;
        background: linear-gradient(135deg, rgba(255,184,0,0.04) 0%, var(--bg-card) 100%);
    }

    /* ---- Col 1: RANK — overlay badge on poster ---- */
    .boxoffice-row > .boxoffice-col:nth-child(1) {
        position: absolute;
        top: 10px;
        left: 10px;
        z-index: 2;
    }
    .boxoffice-rank {
        width: 28px;
        height: 28px;
        font-size: 14px;
        background: rgba(0,0,0,0.6);
        color: #fff;
        border-radius: 6px;
        backdrop-filter: blur(4px);
    }
    .boxoffice-rank--1,
    .boxoffice-rank--2,
    .boxoffice-rank--3 {
        font-size: 1.1rem;
        background: none;
    }

    /* ---- Col 2: POSTER — left column, spans all rows ---- */
    .boxoffice-row > .boxoffice-col:nth-child(2) {
        grid-row: 1 / 4;
        grid-column: 1;
        align-self: stretch;
    }
    .boxoffice-col--movie { flex-direction: column; gap: 0; }
    .boxoffice-poster {
        width: 100%;
        min-width: unset;
        max-width: 100px;
        height: 140px;
        max-height: 140px;
        border-radius: 8px;
        box-shadow: 0 4px 16px rgba(0,0,0,0.3);
        object-fit: cover;
    }
    .boxoffice-movie-info { display: none; }

    /* ---- Col 3: SHOWTIMES — row 3 right ---- */
    .boxoffice-row > .boxoffice-col:nth-child(3) {
        display: flex !important;
        grid-row: 3;
        grid-column: 2;
        flex-direction: row;
        align-items: baseline;
        gap: 4px;
        justify-content: flex-end;
    }
    .boxoffice-col:nth-child(3) { display: flex !important; }

    /* ---- Col 4: NAME at row 1, TICKETS hidden (shown via JS in col3 area) ---- */
    .boxoffice-row > .boxoffice-col:nth-child(4) {
        grid-row: 1;
        grid-column: 2;
        flex-direction: column;
        align-items: flex-start;
        gap: 2px;
    }
    
    /* Hide ticket number from row 1 — will show via col3 area */
    .boxoffice-row > .boxoffice-col:nth-child(4) .boxoffice-num,
    .boxoffice-row > .boxoffice-col:nth-child(4) .boxoffice-num-label {
        display: none;
    }

    /* Mobile movie name — big bold like BOVN */
    .boxoffice-mobile-name {
        display: block;
        font-size: 15px;
        font-weight: 800;
        color: var(--text-primary);
        line-height: 1.25;
        letter-spacing: -0.01em;
        margin-bottom: 2px;
    }

    .boxoffice-num { font-size: 13px; }
    .boxoffice-num-label { font-size: 10px; }

    /* ---- Col 5: REVENUE — row 2, BIG RED ---- */
    .boxoffice-row > .boxoffice-col:nth-child(5) {
        grid-row: 2;
        grid-column: 2;
        flex-direction: column;
        align-items: flex-start;
        gap: 0;
        padding: 4px 0;
    }
    .boxoffice-revenue {
        font-family: var(--font-display);
        font-size: 20px;
        font-weight: 800;
        color: #E23340;
        letter-spacing: -0.02em;
        line-height: 1.2;
    }
    .boxoffice-row > .boxoffice-col:nth-child(5) .boxoffice-num-label {
        font-size: 10px;
        color: var(--text-tertiary);
        font-style: italic;
    }

    /* ---- Col 3: SHOWTIMES + TICKETS stats at bottom-right ---- */
    .boxoffice-row > .boxoffice-col:nth-child(3) .boxoffice-num { font-size: 12px; }
    .boxoffice-row > .boxoffice-col:nth-child(3) .boxoffice-num-label { font-size: 9px; }

    /* Show mobile-only ticket stats in showtimes row */
    .boxoffice-num--tickets-mobile,
    .boxoffice-num-label--tickets-mobile {
        display: inline !important;
    }
    .boxoffice-stats-divider {
        display: inline !important;
        color: var(--text-tertiary);
        margin: 0 4px;
        font-size: 12px;
    }
}

/* Extra small phones */
@media (max-width: 380px) {
    .boxoffice-row {
        grid-template-columns: 80px 1fr;
        padding: 10px;
        gap: 3px 10px;
    }
    .boxoffice-poster { height: 115px; max-height: 115px; max-width: 80px; }
    .boxoffice-mobile-name { font-size: 13px; }
    .boxoffice-revenue { font-size: 17px; }
}

/* ==========================================
   LIGHT THEME — Box Office Overrides
   ========================================== */

[data-theme="light"] .boxoffice-poster {
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
}

[data-theme="light"] .boxoffice-row--top:nth-child(3) {
    background: linear-gradient(135deg, rgba(226,51,64,0.03) 0%, var(--bg-card) 100%);
    border-color: rgba(226,51,64,0.1);
}

@media (max-width: 768px) {
    [data-theme="light"] .boxoffice-rank {
        background: rgba(0,0,0,0.5);
    }
}
