/* ============================================================
 * Tournament Round Robin — Timeline view
 * Chronological timeline of matches for a given tournament.
 * ============================================================ */

.bracket-toolbar {
    display: flex;
    flex-wrap: wrap;
    gap: 0.75rem;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 1rem;
}

.bracket-toolbar.bracket-toolbar-compact {
    padding: 0.5rem 0.75rem;
    background: var(--bg-primary, #ffffff);
    border: 1px solid var(--border-color, rgba(0, 0, 0, 0.06));
    border-radius: 10px;
}

.bracket-toolbar .bracket-toolbar-meta {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.9rem;
    color: var(--text-primary, #0f172a);
}

.bracket-toolbar .bracket-toolbar-meta i {
    color: #0d9488;
}

.bracket-toolbar .bracket-tournament-select {
    min-width: 220px;
    max-width: 100%;
    flex: 1 1 220px;
}

.bracket-toolbar .bracket-live-indicator {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.85rem;
    color: var(--text-secondary, #6c757d);
    padding: 0.35rem 0.75rem;
    border-radius: 999px;
    background: var(--bg-tertiary, rgba(13, 148, 136, 0.08));
    white-space: nowrap;
}

.bracket-toolbar .bracket-live-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #10b981;
    box-shadow: 0 0 0 0 rgba(16, 185, 129, 0.7);
    animation: bracket-pulse 1.6s infinite;
}

@keyframes bracket-pulse {
    0%   { box-shadow: 0 0 0 0 rgba(16, 185, 129, 0.7); }
    70%  { box-shadow: 0 0 0 10px rgba(16, 185, 129, 0); }
    100% { box-shadow: 0 0 0 0 rgba(16, 185, 129, 0); }
}

/* ---------- Summary pills ---------- */
.bracket-summary {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
    gap: 0.75rem;
    margin-bottom: 1rem;
}

.bracket-summary .summary-pill {
    background: var(--bg-primary, #ffffff);
    border: 1px solid var(--border-color, rgba(0, 0, 0, 0.06));
    border-radius: 10px;
    padding: 0.75rem 1rem;
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.bracket-summary .pill-icon {
    width: 36px;
    height: 36px;
    border-radius: 9px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1rem;
    color: #ffffff;
    background: linear-gradient(135deg, #0d9488, #14b8a6);
    flex-shrink: 0;
}

.bracket-summary .pill-icon.scheduled { background: linear-gradient(135deg, #64748b, #94a3b8); }
.bracket-summary .pill-icon.live      { background: linear-gradient(135deg, #ef4444, #f97316); }
.bracket-summary .pill-icon.completed { background: linear-gradient(135deg, #0d9488, #10b981); }

.bracket-summary .pill-value {
    font-size: 1.15rem;
    font-weight: 700;
    color: var(--text-primary, #0f172a);
    line-height: 1;
}

.bracket-summary .pill-label {
    font-size: 0.75rem;
    color: var(--text-secondary, #64748b);
    letter-spacing: 0.03em;
    text-transform: uppercase;
}

/* ---------- Status filter chips ---------- */
.bracket-filter-chips {
    display: flex;
    flex-wrap: wrap;
    gap: 0.4rem;
    margin-bottom: 1rem;
}

.bracket-filter-chips .chip {
    appearance: none;
    border: 1px solid var(--border-color, rgba(0, 0, 0, 0.08));
    background: var(--bg-primary, #ffffff);
    color: var(--text-secondary, #64748b);
    padding: 0.35rem 0.85rem;
    border-radius: 999px;
    font-size: 0.8rem;
    font-weight: 600;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    transition: all 0.15s ease;
}

.bracket-filter-chips .chip:hover {
    color: var(--text-primary, #0f172a);
    border-color: rgba(13, 148, 136, 0.3);
}

.bracket-filter-chips .chip.active {
    background: #0d9488;
    color: #ffffff;
    border-color: #0d9488;
}

.bracket-filter-chips .chip .chip-count {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 20px;
    height: 18px;
    padding: 0 6px;
    border-radius: 999px;
    background: rgba(0, 0, 0, 0.08);
    font-size: 0.7rem;
    font-weight: 700;
}

.bracket-filter-chips .chip.active .chip-count {
    background: rgba(255, 255, 255, 0.25);
}

/* ---------- Timeline ---------- */
.bracket-timeline {
    position: relative;
    padding: 0.25rem 0 0.25rem 0;
}

.timeline-day {
    position: relative;
    margin-bottom: 1.25rem;
}

.timeline-day-header {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    padding: 0.4rem 0.75rem;
    margin-bottom: 0.6rem;
    background: linear-gradient(135deg, rgba(13, 148, 136, 0.12), rgba(20, 184, 166, 0.05));
    border-left: 3px solid #0d9488;
    border-radius: 6px;
    font-weight: 700;
    color: var(--text-primary, #0f172a);
    font-size: 0.9rem;
}

.timeline-day-header .day-date {
    font-size: 0.95rem;
}

.timeline-day-header .day-weekday {
    color: var(--text-secondary, #64748b);
    font-weight: 500;
    font-size: 0.8rem;
}

.timeline-day-header .day-count {
    margin-left: auto;
    font-size: 0.72rem;
    color: var(--text-secondary, #64748b);
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.timeline-track {
    position: relative;
    padding-left: 40px;
}

.timeline-track::before {
    content: '';
    position: absolute;
    left: 17px;
    top: 4px;
    bottom: 4px;
    width: 2px;
    background: linear-gradient(to bottom, rgba(13, 148, 136, 0.25), rgba(13, 148, 136, 0.08));
    border-radius: 2px;
}

.timeline-entry {
    position: relative;
    display: grid;
    grid-template-columns: 70px 1fr;
    gap: 0.75rem;
    align-items: stretch;
    margin-bottom: 0.6rem;
}

.timeline-entry::before {
    content: '';
    position: absolute;
    left: -31px;
    top: 50%;
    width: 14px;
    height: 14px;
    border-radius: 50%;
    background: #ffffff;
    border: 3px solid #64748b;
    transform: translateY(-50%);
    z-index: 1;
    transition: all 0.2s ease;
}

.timeline-entry.status-scheduled::before { border-color: #64748b; }
.timeline-entry.status-live::before {
    border-color: #ef4444;
    background: #fee2e2;
    box-shadow: 0 0 0 4px rgba(239, 68, 68, 0.15);
    animation: timeline-live-dot 1.6s infinite;
}

@keyframes timeline-live-dot {
    0%, 100% { box-shadow: 0 0 0 4px rgba(239, 68, 68, 0.15); }
    50%      { box-shadow: 0 0 0 8px rgba(239, 68, 68, 0.05); }
}

.timeline-entry.status-completed::before {
    border-color: #0d9488;
    background: #d1fae5;
}

.timeline-time {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    justify-content: center;
    padding: 0.25rem 0;
}

.timeline-time .time-value {
    font-size: 1rem;
    font-weight: 700;
    color: var(--text-primary, #0f172a);
    line-height: 1;
}

.timeline-time .time-meta {
    font-size: 0.7rem;
    color: var(--text-secondary, #94a3b8);
    margin-top: 0.2rem;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.timeline-card {
    background: var(--bg-primary, #ffffff);
    border: 1px solid var(--border-color, rgba(0, 0, 0, 0.06));
    border-radius: 10px;
    padding: 0.7rem 0.9rem;
    cursor: default;
    transition: transform 0.15s ease, box-shadow 0.15s ease, border-color 0.15s ease;
    display: grid;
    grid-template-columns: 1fr auto 1fr;
    gap: 0.5rem;
    align-items: center;
    min-height: 64px;
}

.timeline-card.is-clickable {
    cursor: pointer;
}

.timeline-card.is-clickable:hover {
    transform: translateY(-1px);
    box-shadow: 0 6px 16px rgba(13, 148, 136, 0.15);
    border-color: rgba(13, 148, 136, 0.3);
}

.timeline-entry.status-live .timeline-card {
    border-color: rgba(239, 68, 68, 0.4);
    background: linear-gradient(135deg, rgba(239, 68, 68, 0.06), rgba(249, 115, 22, 0.03));
}

.timeline-entry.status-completed .timeline-card {
    border-color: rgba(13, 148, 136, 0.2);
}

.timeline-card .team {
    display: flex;
    flex-direction: column;
    gap: 0.15rem;
    min-width: 0;
}

.timeline-card .team.team-right { text-align: right; }

.timeline-card .team-label {
    font-size: 0.62rem;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--text-secondary, #94a3b8);
    font-weight: 600;
}

.timeline-card .team-name {
    font-size: 0.92rem;
    font-weight: 600;
    color: var(--text-primary, #0f172a);
    line-height: 1.25;
    word-break: break-word;
    overflow-wrap: anywhere;
}

.timeline-card .team-name.winner {
    color: #0d9488;
    font-weight: 700;
}

.timeline-card .team-name.winner::after {
    content: ' ✓';
    color: #0d9488;
    font-weight: 700;
}

.timeline-card .center-block {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 0.2rem;
    min-width: 72px;
    padding: 0 0.5rem;
    border-left: 1px solid var(--border-color, rgba(0, 0, 0, 0.05));
    border-right: 1px solid var(--border-color, rgba(0, 0, 0, 0.05));
}

.timeline-card .score-big {
    font-size: 1rem;
    font-weight: 800;
    color: var(--text-primary, #0f172a);
    letter-spacing: 0.02em;
    line-height: 1;
    white-space: nowrap;
}

.timeline-entry.status-live .score-big {
    color: #ef4444;
}

.timeline-entry.status-completed .score-big {
    color: #0d9488;
}

.timeline-card .vs-tag {
    font-size: 0.8rem;
    font-weight: 700;
    color: var(--text-secondary, #94a3b8);
    letter-spacing: 0.05em;
}

.timeline-card .status-tag {
    font-size: 0.62rem;
    font-weight: 600;
    letter-spacing: 0.05em;
    text-transform: uppercase;
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
    padding: 2px 7px;
    border-radius: 999px;
    background: rgba(100, 116, 139, 0.12);
    color: var(--text-secondary, #64748b);
    white-space: nowrap;
}

.timeline-entry.status-live .status-tag {
    background: rgba(239, 68, 68, 0.12);
    color: #ef4444;
}

.timeline-entry.status-completed .status-tag {
    background: rgba(13, 148, 136, 0.12);
    color: #0d9488;
}

.timeline-card .cat-tag {
    font-size: 0.62rem;
    font-weight: 700;
    letter-spacing: 0.05em;
    padding: 1px 6px;
    border-radius: 4px;
    background: rgba(14, 165, 233, 0.15);
    color: #0369a1;
    text-transform: uppercase;
}

/* ---------- Team Standings ---------- */
.bracket-standings {
    margin-top: 1.5rem;
    background: var(--bg-primary, #ffffff);
    border: 1px solid var(--border-color, rgba(0, 0, 0, 0.06));
    border-radius: 12px;
    overflow: hidden;
}

.bracket-standings .standings-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.85rem 1rem;
    border-bottom: 1px solid var(--border-color, rgba(0, 0, 0, 0.05));
    background: linear-gradient(135deg, rgba(13, 148, 136, 0.08), rgba(16, 185, 129, 0.06));
}

.bracket-standings .standings-header h4 {
    margin: 0;
    font-size: 1rem;
    color: var(--text-primary, #0f172a);
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
}

.bracket-standings .standings-rule {
    font-size: 0.72rem;
    font-weight: 600;
    color: #0d9488;
    background: rgba(13, 148, 136, 0.12);
    padding: 0.25rem 0.6rem;
    border-radius: 999px;
    letter-spacing: 0.02em;
}

.bracket-standings .standings-body {
    display: grid;
    gap: 0.6rem;
    padding: 0.85rem;
}

.bracket-standings .standings-empty {
    padding: 2rem 1.5rem;
    text-align: center;
    color: var(--text-secondary, #64748b);
}

.bracket-standings .standings-empty i {
    display: block;
    font-size: 2rem;
    color: #0d9488;
    margin-bottom: 0.6rem;
}

.bracket-standings .standings-empty strong {
    color: var(--text-primary, #0f172a);
    display: block;
    margin-bottom: 0.25rem;
}

.bracket-standings .standings-empty em {
    font-style: normal;
    color: #0d9488;
    font-weight: 600;
}

.bracket-standings .standings-footnote {
    padding: 0.6rem 1rem;
    border-top: 1px solid var(--border-color, rgba(0, 0, 0, 0.04));
    font-size: 0.78rem;
    color: var(--text-secondary, #64748b);
    background: var(--bg-tertiary, #f8fafc);
}

.bracket-standings .standings-footnote i {
    color: #0d9488;
    margin-right: 0.3rem;
}

/* Squad row — one for Team A, one for Team B */
.squad-row {
    display: grid;
    grid-template-columns: auto 1fr auto auto;
    align-items: center;
    gap: 0.9rem;
    padding: 0.85rem 1rem;
    border-radius: 12px;
    border: 1px solid var(--border-color, rgba(0, 0, 0, 0.06));
    background: var(--bg-primary, #ffffff);
    position: relative;
}

.squad-row::before {
    content: '';
    position: absolute;
    left: 0;
    top: 8px;
    bottom: 8px;
    width: 4px;
    border-radius: 4px;
    background: #64748b;
}

.squad-row.side-a::before { background: linear-gradient(to bottom, #0d9488, #14b8a6); }
.squad-row.side-b::before { background: linear-gradient(to bottom, #dc2626, #f97316); }

.squad-row.side-a {
    background: linear-gradient(135deg, rgba(13, 148, 136, 0.05), rgba(255, 255, 255, 0));
}
.squad-row.side-b {
    background: linear-gradient(135deg, rgba(220, 38, 38, 0.05), rgba(255, 255, 255, 0));
}

.squad-rank {
    display: flex;
    align-items: center;
    justify-content: center;
}

.squad-name .squad-label {
    font-size: 1.1rem;
    font-weight: 800;
    color: var(--text-primary, #0f172a);
    letter-spacing: 0.01em;
    line-height: 1;
    margin-bottom: 0.35rem;
}

.squad-row.side-a .squad-label { color: #0d9488; }
.squad-row.side-b .squad-label { color: #dc2626; }

.squad-members {
    display: flex;
    flex-wrap: wrap;
    gap: 0.35rem;
}

.member-chip {
    display: inline-flex;
    align-items: center;
    padding: 0.2rem 0.55rem;
    border-radius: 999px;
    background: rgba(148, 163, 184, 0.15);
    color: var(--text-primary, #0f172a);
    font-size: 0.72rem;
    font-weight: 600;
    letter-spacing: 0.01em;
    white-space: nowrap;
}

.squad-row.side-a .member-chip {
    background: rgba(13, 148, 136, 0.12);
    color: #0f766e;
}

.squad-row.side-b .member-chip {
    background: rgba(220, 38, 38, 0.1);
    color: #b91c1c;
}

.member-chip.muted {
    font-style: italic;
    color: var(--text-secondary, #94a3b8);
}

.squad-metrics {
    display: grid;
    grid-auto-flow: column;
    gap: 0.75rem;
    padding: 0 0.5rem;
    border-left: 1px solid var(--border-color, rgba(0, 0, 0, 0.06));
    border-right: 1px solid var(--border-color, rgba(0, 0, 0, 0.06));
}

.squad-metrics .metric {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-width: 48px;
}

.squad-metrics .metric-value {
    font-variant-numeric: tabular-nums;
    font-size: 1rem;
    font-weight: 700;
    color: var(--text-primary, #0f172a);
    line-height: 1;
}

.squad-metrics .metric-label {
    font-size: 0.65rem;
    font-weight: 600;
    color: var(--text-secondary, #94a3b8);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-top: 0.25rem;
}

.squad-points .points-badge {
    display: inline-flex;
    align-items: baseline;
    gap: 0.3rem;
    padding: 0.5rem 0.9rem;
    border-radius: 12px;
    background: linear-gradient(135deg, rgba(13, 148, 136, 0.15), rgba(16, 185, 129, 0.1));
    border: 1px solid rgba(13, 148, 136, 0.25);
    color: #0d9488;
    font-variant-numeric: tabular-nums;
    min-width: 80px;
    justify-content: center;
}

.squad-points .points-value {
    font-size: 1.6rem;
    font-weight: 800;
    line-height: 1;
}

.squad-points .points-unit {
    font-size: 0.7rem;
    font-weight: 700;
    letter-spacing: 0.05em;
    text-transform: uppercase;
    opacity: 0.75;
}

.squad-row.side-b .points-badge {
    background: linear-gradient(135deg, rgba(220, 38, 38, 0.15), rgba(249, 115, 22, 0.1));
    border-color: rgba(220, 38, 38, 0.25);
    color: #dc2626;
}

/* Leader highlight — winning team */
.squad-row.is-leader {
    border-color: #f59e0b;
    box-shadow: 0 4px 14px rgba(245, 158, 11, 0.15);
}

.squad-row.is-leader .points-badge {
    background: linear-gradient(135deg, #fbbf24, #f59e0b);
    border-color: #f59e0b;
    color: #7c2d12;
    box-shadow: 0 2px 6px rgba(245, 158, 11, 0.3);
}

.squad-row.is-leader .squad-label::after {
    content: ' \f091';          /* fa-trophy */
    font-family: 'Font Awesome 6 Free', 'Font Awesome 5 Free', 'FontAwesome';
    font-weight: 900;
    color: #f59e0b;
    margin-left: 0.35rem;
    font-size: 0.9rem;
}

.bracket-standings .rank-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 30px;
    height: 30px;
    border-radius: 50%;
    background: var(--bg-tertiary, #f1f5f9);
    font-weight: 800;
    font-size: 0.85rem;
    color: var(--text-secondary, #64748b);
}

.bracket-standings .rank-badge.top1 { background: #fde68a; color: #854d0e; }
.bracket-standings .rank-badge.top2 { background: #e5e7eb; color: #374151; }
.bracket-standings .rank-badge.top3 { background: #fed7aa; color: #9a3412; }

/* ---------- Empty / loading ---------- */
.bracket-empty,
.bracket-loading {
    padding: 3rem 1.5rem;
    text-align: center;
    color: var(--text-secondary, #64748b);
    background: var(--bg-primary, #ffffff);
    border-radius: 12px;
    border: 1px dashed var(--border-color, rgba(0, 0, 0, 0.08));
}

.bracket-empty i,
.bracket-loading i {
    display: block;
    font-size: 2.5rem;
    color: #0d9488;
    margin-bottom: 0.75rem;
}

.bracket-loading .spinner {
    width: 36px;
    height: 36px;
    border: 3px solid rgba(13, 148, 136, 0.2);
    border-top-color: #0d9488;
    border-radius: 50%;
    margin: 0 auto 0.75rem;
    animation: bracket-spin 0.8s linear infinite;
}

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

/* ---------- Mobile ---------- */
@media (max-width: 768px) {
    .timeline-entry {
        grid-template-columns: 55px 1fr;
        gap: 0.5rem;
    }

    .timeline-track { padding-left: 32px; }
    .timeline-track::before { left: 13px; }
    .timeline-entry::before {
        left: -26px;
        width: 12px;
        height: 12px;
        border-width: 2px;
    }

    .timeline-time .time-value {
        font-size: 0.88rem;
    }

    .timeline-card {
        padding: 0.55rem 0.6rem;
        grid-template-columns: 1fr;
        gap: 0.5rem;
        min-height: auto;
    }

    .timeline-card .team.team-right { text-align: left; }

    .timeline-card .center-block {
        flex-direction: row;
        border-left: 0;
        border-right: 0;
        border-top: 1px solid var(--border-color, rgba(0, 0, 0, 0.05));
        border-bottom: 1px solid var(--border-color, rgba(0, 0, 0, 0.05));
        padding: 0.4rem 0;
        gap: 0.5rem;
        justify-content: space-between;
    }

    .timeline-card .team-name {
        font-size: 0.85rem;
    }

    .bracket-summary .summary-pill {
        padding: 0.55rem 0.75rem;
    }

    .bracket-summary .pill-value {
        font-size: 1rem;
    }

    .bracket-standings .squad-row {
        grid-template-columns: auto 1fr auto;
        grid-template-areas:
            "rank name points"
            "metrics metrics metrics";
        gap: 0.6rem;
        padding: 0.75rem;
    }

    .bracket-standings .squad-rank { grid-area: rank; }
    .bracket-standings .squad-name { grid-area: name; }
    .bracket-standings .squad-points { grid-area: points; }
    .bracket-standings .squad-metrics {
        grid-area: metrics;
        border: 0;
        padding: 0.5rem 0 0;
        border-top: 1px solid var(--border-color, rgba(0, 0, 0, 0.06));
        justify-content: space-between;
        width: 100%;
    }

    .bracket-standings .squad-metrics .metric {
        min-width: 0;
        flex: 1;
    }

    .bracket-standings .squad-name .squad-label {
        font-size: 1rem;
    }

    .bracket-standings .squad-points .points-value {
        font-size: 1.25rem;
    }

    .bracket-standings .squad-points .points-badge {
        min-width: 0;
        padding: 0.4rem 0.65rem;
    }

    .bracket-standings .member-chip {
        font-size: 0.68rem;
    }
}

/* ---------- Dark mode ---------- */
@media (prefers-color-scheme: dark) {
    .timeline-card {
        background: rgba(255, 255, 255, 0.04);
        border-color: rgba(255, 255, 255, 0.07);
    }
    .bracket-filter-chips .chip {
        background: rgba(255, 255, 255, 0.04);
        border-color: rgba(255, 255, 255, 0.07);
    }
    .bracket-filter-chips .chip .chip-count {
        background: rgba(255, 255, 255, 0.1);
    }
}
