/* Tab Navigation */
.tab-btn {
    padding: 0.75rem 1.5rem;
    color: #6b7280;
    border-bottom: 2px solid transparent;
    font-weight: 500;
    transition: all 0.2s;
}

.tab-btn:hover {
    color: #374151;
}

.tab-btn.active {
    color: #111827;
    border-bottom-color: var(--team-primary);
}

/* Tab Content */
.tab-content {
    display: none;
}

.tab-content.active {
    display: block;
}

/* Game Selection Buttons */
.game-btn {
    padding: 0.5rem 0.75rem;
    background-color: #ffffff;
    color: #374151;
    border-radius: 0.375rem;
    cursor: pointer;
    transition: all 0.2s;
    border: 1px solid #d1d5db;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.125rem;
    min-width: 80px;
}

.game-btn:hover {
    background-color: #f3f4f6;
    border-color: #9ca3af;
}

.game-btn.selected {
    background-color: #ffffff;
    border-color: var(--team-primary);
    border-width: 3px;
}

.game-btn-opponent {
    font-size: 0.75rem;
    font-weight: 600;
    text-align: center;
}

.game-btn-result {
    font-size: 1rem;
    font-weight: 700;
    text-align: center;
}

.game-btn-result.W { color: #22c55e; }
.game-btn-result.L { color: #ef4444; }
.game-btn-result.T { color: #f59e0b; }

.game-btn.selected .game-btn-result.W { color: #22c55e !important; }
.game-btn.selected .game-btn-result.L { color: #ef4444 !important; }
.game-btn.selected .game-btn-result.T { color: #f59e0b !important; }

.game-btn-date {
    font-size: 0.75rem;
    text-align: center;
    opacity: 0.8;
}

/* Filter Buttons */
.filter-btn {
    padding: 0.375rem 0.75rem;
    background-color: #f3f4f6;
    color: #374151;
    border-radius: 0.375rem;
    cursor: pointer;
    transition: all 0.2s;
    border: 1px solid #d1d5db;
    font-size: 0.875rem;
    font-weight: 500;
}

.filter-btn:hover {
    background-color: #e5e7eb;
    border-color: #9ca3af;
}

.filter-btn.active {
    background-color: var(--team-primary);
    border-color: var(--team-primary);
    color: white;
}

/* Game Search */
#game-search {
    font-size: 0.875rem;
}

#game-search:focus {
    outline: none;
    border-color: var(--team-primary);
    box-shadow: 0 0 0 2px rgba(220, 38, 38, 0.1);
}

/* W/L/T Indicators on game buttons */
.game-btn .wl-indicator {
    display: inline-block;
    margin-left: 0.25rem;
    font-size: 0.75rem;
    font-weight: bold;
}

.game-btn .wl-indicator.W { color: #22c55e; }
.game-btn .wl-indicator.L { color: #ef4444; }
.game-btn .wl-indicator.T { color: #f59e0b; }

/* Login Button */
.login-btn {
    background-color: var(--team-primary);
    color: white;
}

.login-btn:hover {
    background-color: var(--team-secondary);
}

/* View Mode Toggle */
.toggle-switch {
    position: relative;
    width: 48px;
    height: 24px;
    background-color: #d1d5db;
    border-radius: 12px;
    cursor: pointer;
    transition: background-color 0.2s;
}

.toggle-switch.active {
    background-color: var(--team-primary);
}

.toggle-slider {
    position: absolute;
    top: 2px;
    left: 2px;
    width: 20px;
    height: 20px;
    background-color: white;
    border-radius: 50%;
    transition: transform 0.2s;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.2);
}

.toggle-switch.active .toggle-slider {
    transform: translateX(24px);
}

/* Login Error */
#login-error {
    color: var(--team-primary);
}

/* Stats Table */
.stats-table {
    border-collapse: collapse;
    background-color: #ffffff;
    border-radius: 0.5rem;
    overflow: hidden;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

.stats-table th {
    font-weight: 600;
    font-size: 0.75rem;
    padding: 0.75rem 0.5rem;
    text-align: center;
    border-bottom: 1px solid #e5e7eb;
}

.stats-table th.player-col {
    text-align: left;
    width: 100px;
    min-width: 100px;
    max-width: 100px;
    font-size: 0.875rem;
}

.stats-table th.umbrella:not(.player-col) {
    min-width: 40px;
}

.stats-table th.sub-header {
    width: 45px;
    min-width: 45px;
    max-width: 45px;
}

:root {
    --stats-font-size: 0.95rem;
}

.stats-table td {
    padding: 0.75rem 0.5rem;
    font-size: var(--stats-font-size);
    color: #111827;
    border-bottom: 1px solid #f3f4f6;
    text-align: center;
    width: 45px;
    min-width: 45px;
    max-width: 45px;
}

.stats-table th.umbrella {
    background-color: var(--team-primary);
    color: white;
    font-weight: 700;
    font-size: 0.7rem;
    text-transform: uppercase;
    letter-spacing: 0.025em;
}

.stats-table th.sub-header {
    background-color: color-mix(in srgb, var(--team-primary) 15%, white);
    color: #374151;
    font-weight: 500;
    width: 45px;
    min-width: 45px;
    max-width: 45px;
}

.stats-table th.sortable {
    cursor: pointer;
    user-select: none;
}

.stats-table th.sortable:hover {
    background-color: #e5e7eb;
    color: #374151;
}

.stats-table th.sorted {
    color: #111827;
    font-weight: 600;
}

.stats-table td {
    padding: 0.75rem 0.5rem;
    color: #111827;
    border-bottom: 1px solid #f3f4f6;
    text-align: center;
    width: 45px;
    min-width: 45px;
    max-width: 45px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.stats-table td.player-col {
    text-align: left;
    font-weight: 500;
    font-size: 0.875rem;
    width: 100px;
    min-width: 100px;
    max-width: 100px;
    max-width: 140px;
}

/* Alternating row colors */
.stats-table tbody tr:nth-child(odd) {
    background-color: #ffffff;
}

.stats-table tbody tr:nth-child(even) {
    background-color: #f9fafb;
}

/* Hover effect - darker than alternating */
.stats-table tbody tr:hover {
    background-color: #e5e7eb;
}

.stats-table tbody tr:last-child td {
    border-bottom: none;
}

/* Rate columns (percentage/rating) */
.stats-table td.rate-col {
    color: #6b7280;
    font-style: italic;
}

/* Group separators - vertical bars between umbrella groups */
.stats-table th.group-end,
.stats-table td.group-end {
    border-right: 2px solid #d1d5db;
}

.stats-table th.group-end {
    border-right: 2px solid #9ca3af;
}

/* Best value highlighting */
.stats-table td.best-value {
    font-weight: bold;
    color: var(--team-primary);
}

/* Column hover highlight */
.stats-table td.col-hover {
    background-color: #e5e7eb;
}

/* Pinned row (double-click) */
.stats-table tbody tr.player-row.row-pinned {
    background-color: #fef9c3 !important;
    outline: 2px solid #eab308;
    outline-offset: -2px;
}

/* Expandable rows */
.stats-table td.expandable {
    cursor: pointer;
}

.stats-table td.expandable:hover {
    color: var(--team-primary);
}

/* Chart Containers */
#attack-chart,
#attack-efficiency-chart,
#reception-chart {
    width: 100%;
    min-height: 500px;
}

/* Set Selection Buttons */
.set-btn {
    padding: 0.375rem 0.75rem;
    background-color: #ffffff;
    color: #374151;
    border-radius: 0.375rem;
    cursor: pointer;
    transition: all 0.2s;
    border: 1px solid #d1d5db;
    font-size: 0.875rem;
    font-weight: 500;
}

.set-btn:hover {
    background-color: #f3f4f6;
    border-color: #9ca3af;
}

.set-btn.selected {
    background-color: var(--team-primary);
    border-color: var(--team-primary);
    color: white;
}

/* Expand Arrow */
.expand-arrow {
    display: inline-block;
    margin-right: 0.5rem;
    font-size: 0.75rem;
    color: #9ca3af;
    transition: transform 0.2s;
}

/* Player Row */
.player-row td.expandable {
    cursor: pointer;
}

.player-row td.expandable:hover {
    color: var(--team-primary);
}

/* Set Row */
.set-row {
    background-color: #f9fafb;
    font-size: 0.875rem;
}

.set-row td {
    padding: 0.5rem;
}

.set-row td.set-data {
    color: #6b7280;
}

/* Override gray color for best-value in set rows */
.set-row td.best-value {
    color: var(--team-primary);
}

.set-row td.player-col {
    padding-left: 2.5rem;
    color: #6b7280;
    font-weight: 400;
}

/* Chart Card Expand */
.chart-card {
    position: relative;
}

.chart-card.minimized > .flex + *,
.chart-card.minimized > .overflow-x-auto,
.chart-card.minimized > div:not(.flex) {
    display: none;
}

.chart-card.minimized .minimize-icon {
    transform: rotate(90deg);
}

.expand-chart-btn {
    background: none;
    border: none;
    cursor: pointer;
    padding: 0.25rem;
    border-radius: 0.25rem;
    transition: all 0.2s;
}

.section-toggle {
    font-size: 0.75rem;
    margin-left: 0.5rem;
    transition: transform 0.2s ease;
    display: inline-block;
}

[data-section].minimized .section-toggle {
    transform: rotate(-90deg);
}

.expand-chart-btn:hover {
    background-color: #f3f4f6;
}

.expand-icon {
    transition: transform 0.3s ease;
}

/* Per-Set Chart Container */
.chart-sets-container {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 1rem;
}

.per-set-chart {
    background-color: #f9fafb;
    border-radius: 0.5rem;
    padding: 1rem;
}

.per-set-chart-container {
    width: 100%;
    min-height: 400px;
}

/* Team Logo */
.team-logo {
    position: absolute;
    top: 0;
    right: 0;
    width: 100px;
    height: 100px;
    object-fit: contain;
}

/* Team Total rows */
tr.team-total-row {
    border-top: 3px solid #374151;
    font-weight: 700;
    background-color: #f3f4f6;
}

tr.team-total-row td {
    color: #111827;
}

tr.team-total-row td.player-col {
    font-weight: 700;
}

.stats-table tr.team-total-row:hover {
    background-color: #e5e7eb;
}

/* Rally Stats Table */
.rally-stats-card {
    display: block;
}

.rally-stats-table {
    border-collapse: collapse;
    width: 100%;
}

.rally-stats-table th,
.rally-stats-table td {
    padding-left: 1rem;
    padding-right: 1rem;
    min-width: 80px;
}

.rally-stats-table th {
    font-size: 1rem;
}

.rally-stats-table td:first-child {
    min-width: 60px;
}

/* Rally Legend & Toggle Row (same line) */
.rally-legend-toggle-row {
    display: flex;
    flex-wrap: wrap;
    gap: 1rem;
}

.rally-legend-row {
    display: flex;
    gap: 1rem;
    flex-wrap: wrap;
}

/* Rally Timeline Legend */
.rally-legend-item {
    display: flex;
    align-items: center;
    gap: 0.375rem;
}

.rally-legend-item .color-box {
    width: 16px;
    height: 16px;
    border-radius: 3px;
    flex-shrink: 0;
}

.rally-legend-item .color-box.green { background-color: #22c55e; }
.rally-legend-item .color-box.blue { background-color: #3b82f6; }
.rally-legend-item .color-box.orange { background-color: #f97316; }
.rally-legend-item .color-box.red { background-color: #ef4444; }

/* Rally Timeline Toggle Buttons */
.rally-toggle-btns {
    display: flex;
    gap: 0.25rem;
}

.rally-toggle-btn {
    padding: 0.25rem 0.5rem;
    font-size: 0.75rem;
    border: 1px solid #d1d5db;
    background-color: #fff;
    border-radius: 0.25rem;
    cursor: pointer;
    transition: all 0.15s;
}

.rally-toggle-btn:hover {
    background-color: #f3f4f6;
}

.rally-toggle-btn.active {
    background-color: #374151;
    color: #fff;
    border-color: #374151;
}

/* Player Toggle Buttons */
.player-toggle-btn {
    display: inline-flex;
    align-items: center;
    gap: 0.375rem;
    padding: 0.375rem 0.75rem;
    border: 1px solid #d1d5db;
    border-radius: 9999px;
    font-size: 0.8125rem;
    background-color: #fff;
    color: #6b7280;
    cursor: pointer;
    transition: all 0.15s ease;
    line-height: 1.25rem;
    white-space: nowrap;
}

.player-toggle-btn:hover {
    background-color: #f9fafb;
    border-color: #9ca3af;
}

.player-toggle-btn.active {
    background-color: #f3f4f6;
    border-color: #374151;
    color: #374151;
    font-weight: 500;
}

.color-dot {
    display: inline-block;
    width: 0.625rem;
    height: 0.625rem;
    border-radius: 9999px;
    flex-shrink: 0;
}

.player-toggle-btn.active .color-dot {
    box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.8);
}

/* Set Header */
.set-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.5rem 0.75rem;
}

/* Average Line Labels */
.rally-avg-label {
    background-color: rgba(255, 255, 255, 0.9);
    border: 1px solid #d1d5db;
    border-radius: 0.25rem;
    padding: 0.125rem 0.375rem;
    font-size: 0.75rem;
}
