/* ==========================================================================
   Tables & Fixtures Pages - Enhanced Styling
   ========================================================================== */

/* --- Reduced Section Spacing --- */
#tables-section,
#fixtures-section {
    padding-top: 30px;
    padding-bottom: 40px;
}

#tables-section > .container > .section-title,
#fixtures-section > .container > .section-title {
    padding-bottom: 16px;
}

/* --- Tab Bar with Season Picker --- */
.tabs-header {
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    gap: 1rem;
    margin-bottom: 0;
}

.tabs-header .nav-tabs {
    flex: 1;
    min-width: 0;
}

/* --- Season Picker (inline) --- */
.season-picker-inline {
    flex-shrink: 0;
    margin-bottom: -2px;
}

.season-picker-inline select {
    appearance: none;
    -webkit-appearance: none;
    background-color: #fff;
    border: 2px solid #dee2e6;
    border-bottom-color: transparent;
    border-radius: 0.5rem 0.5rem 0 0;
    padding: 0.5rem 2rem 0.5rem 0.75rem;
    font-size: 0.9rem;
    font-weight: 600;
    color: #495057;
    cursor: pointer;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%236c757d' d='M6 8L1 3h10z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 0.6rem center;
    background-size: 10px;
    transition: border-color 0.2s, color 0.2s;
    line-height: 1.4;
}

.season-picker-inline select:hover {
    border-color: #7cc576;
    color: #212529;
}

.season-picker-inline select:focus {
    outline: none;
    border-color: #7cc576;
    box-shadow: 0 -2px 4px rgba(124, 197, 118, 0.15);
}

/* --- Tab Navigation --- */
.tables-tabs .nav-tabs {
    border-bottom: 2px solid #dee2e6;
    gap: 0.25rem;
}

.tables-tabs .nav-tabs .nav-link {
    color: #495057;
    font-weight: 600;
    border: none;
    border-bottom: 3px solid transparent;
    padding: 0.75rem 1.5rem;
    transition: all 0.2s ease;
    font-size: 0.95rem;
}

.tables-tabs .nav-tabs .nav-link:hover {
    color: #7cc576;
    border-bottom-color: rgba(124, 197, 118, 0.4);
}

.tables-tabs .nav-tabs .nav-link.active {
    color: #7cc576;
    border-bottom-color: #7cc576;
    background: transparent;
}

/* --- Leader Row --- */
.table-leader td {
    font-weight: 700;
    background-color: rgba(124, 197, 118, 0.12) !important;
}

/* --- Win/Loss Colours --- */
.font-win {
    color: #198754;
    font-weight: 600;
}

.font-lose {
    color: #dc3545;
    font-weight: 600;
}

.ld-positive {
    color: #198754;
    font-weight: 600;
}

.ld-negative {
    color: #dc3545;
    font-weight: 600;
}

/* --- Form Dots (Last 5 Results) --- */
.form-dots {
    display: inline-flex;
    gap: 4px;
    align-items: center;
}

.form-dot {
    width: 9px;
    height: 9px;
    border-radius: 50%;
    display: inline-block;
}

.form-dot.form-win {
    background-color: #198754;
}

.form-dot.form-lose {
    background-color: #dc3545;
}

.form-dot.form-draw {
    background-color: #6c757d;
}

/* --- Position Change Arrows --- */
.pos-up {
    color: #198754;
    font-size: 0.75rem;
    margin-left: 4px;
}

.pos-down {
    color: #dc3545;
    font-size: 0.75rem;
    margin-left: 4px;
}

.pos-same {
    color: #6c757d;
    font-size: 0.7rem;
    margin-left: 4px;
}

/* --- League Table Column Widths (percentage-based) --- */
#league-table th:nth-child(1)  { width: 6%; }    /* # */
#league-table th:nth-child(2)  { width: 18%; }   /* Team */
#league-table th:nth-child(3),
#league-table th:nth-child(4),
#league-table th:nth-child(5),
#league-table th:nth-child(6),
#league-table th:nth-child(7),
#league-table th:nth-child(8),
#league-table th:nth-child(9),
#league-table th:nth-child(12) { width: 6%; }    /* P, W, L, W/L, LF, LA, LD, Pts */
#league-table th:nth-child(10) { width: 12%; }   /* Win% */
#league-table th:nth-child(11) { width: 10%; }   /* Form */
#league-table td { text-align: center; }
#league-table td:nth-child(2) { text-align: left; }

/* --- Win Percentage Progress Bar --- */
.win-pct-bar {
    width: 40px;
    height: 8px;
    background-color: #e9ecef;
    border-radius: 4px;
    overflow: hidden;
    display: inline-block;
    vertical-align: middle;
}

.win-pct-fill {
    display: block;
    height: 100%;
    background-color: #7cc576;
    border-radius: 4px;
    transition: width 0.3s ease;
}

.win-pct-text {
    font-size: 0.75rem;
    margin-left: 4px;
    color: #495057;
}

/* --- Rank Badge --- */
.rank-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    border-radius: 50%;
    font-weight: 700;
    font-size: 0.85rem;
    background-color: #f8f9fa;
    color: #212529;
}

.rank-badge.rank-1 {
    background-color: #ffd700;
    color: #212529;
}

.rank-badge.rank-2 {
    background-color: #c0c0c0;
    color: #212529;
}

.rank-badge.rank-3 {
    background-color: #cd7f32;
    color: #fff;
}

/* --- Mobile Card Layout --- */
.table-card {
    background: #fff;
    border: 1px solid #dee2e6;
    border-radius: 0.75rem;
    padding: 1rem 1.25rem;
    margin-bottom: 0.75rem;
    transition: box-shadow 0.2s;
}

.table-card:hover {
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
}

.table-card .card-rank {
    font-size: 1.5rem;
    font-weight: 700;
    color: #7cc576;
    min-width: 40px;
}

.table-card .card-name {
    font-size: 1.1rem;
    font-weight: 600;
    color: #212529;
}

.table-card .card-team {
    font-size: 0.85rem;
    color: #6c757d;
}

.table-card .card-stats {
    display: flex;
    gap: 1rem;
    flex-wrap: wrap;
    margin-top: 0.5rem;
}

.table-card .card-stat {
    text-align: center;
}

.table-card .card-stat-value {
    font-weight: 700;
    font-size: 1rem;
}

.table-card .card-stat-label {
    font-size: 0.7rem;
    text-transform: uppercase;
    color: #6c757d;
}

.table-card .card-footer-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-top: 0.75rem;
    padding-top: 0.5rem;
    border-top: 1px solid #e9ecef;
}

/* --- Chart Container --- */
.chart-container {
    position: relative;
    margin-top: 2rem;
    padding: 1rem;
    background: #fff;
    border-radius: 0.75rem;
    border: 1px solid #dee2e6;
}

.chart-container canvas {
    max-height: 350px;
}

/* --- Enhanced DataTable Styling --- */
table.dataTable.enhanced thead th {
    background-color: #2d2d2d;
    color: #fff;
    font-weight: 600;
    font-size: 0.85rem;
    text-transform: uppercase;
    letter-spacing: 0.03em;
    padding: 0.75rem 0.5rem;
}

table.dataTable.enhanced tbody td {
    padding: 0.6rem 0.5rem;
    vertical-align: middle;
}

/* =========================================================================
   Dark Mode
   ========================================================================= */

/* --- Season Picker Dark --- */
.dark .season-picker-inline select {
    background-color: #1f2937;
    border-color: #374151;
    border-bottom-color: transparent;
    color: #d1d5db;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%239ca3af' d='M6 8L1 3h10z'/%3E%3C/svg%3E");
}

.dark .season-picker-inline select:hover {
    border-color: #7cc576;
    border-bottom-color: transparent;
    color: #f3f4f6;
}

.dark .season-picker-inline select:focus {
    border-color: #7cc576;
    border-bottom-color: transparent;
    box-shadow: 0 -2px 4px rgba(124, 197, 118, 0.1);
}

.dark .tables-tabs .nav-tabs {
    border-bottom-color: #374151;
}

.dark .tables-tabs .nav-tabs .nav-link {
    color: #9ca3af;
}

.dark .tables-tabs .nav-tabs .nav-link:hover {
    color: #7cc576;
}

.dark .tables-tabs .nav-tabs .nav-link.active {
    color: #7cc576;
}

.dark .table-leader td {
    background-color: rgba(124, 197, 118, 0.08) !important;
}

.dark .win-pct-bar {
    background-color: #374151;
}

.dark .win-pct-text {
    color: #9ca3af;
}

.dark .rank-badge {
    background-color: #374151;
    color: #d1d5db;
}

.dark .rank-badge.rank-1 {
    background-color: #ffd700;
    color: #212529;
}

.dark .rank-badge.rank-2 {
    background-color: #c0c0c0;
    color: #212529;
}

.dark .rank-badge.rank-3 {
    background-color: #cd7f32;
    color: #fff;
}

.dark .table-card {
    background: #1f2937;
    border-color: #374151;
}

.dark .table-card:hover {
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
}

.dark .table-card .card-name {
    color: #f3f4f6;
}

.dark .table-card .card-team {
    color: #9ca3af;
}

.dark .table-card .card-stat-label {
    color: #9ca3af;
}

.dark .table-card .card-footer-row {
    border-top-color: #374151;
}

.dark .chart-container {
    background: #1f2937;
    border-color: #374151;
}

.dark table.dataTable.enhanced thead th {
    background-color: #111827;
}

/* ==========================================================================
   Fixtures Page - Cards & Results
   ========================================================================== */

/* --- Fixture Card --- */
.fixture-card {
    background: #fff;
    border: 1px solid #dee2e6;
    border-radius: 0.75rem;
    margin-bottom: 0.75rem;
    overflow: hidden;
    transition: box-shadow 0.2s ease;
}

.fixture-card:hover {
    box-shadow: 0 2px 12px rgba(0, 0, 0, 0.08);
}

/* --- Fixture Header (clickable row) --- */
.fixture-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.875rem 1.25rem;
    cursor: pointer;
    gap: 1rem;
    transition: background-color 0.15s ease;
}

.fixture-header:hover {
    background-color: rgba(124, 197, 118, 0.06);
}

.fixture-header.no-results {
    cursor: default;
}

.fixture-header.no-results:hover {
    background-color: transparent;
}

/* --- Badge Group --- */
.fixture-badges {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    flex-shrink: 0;
}

/* --- Date Badge --- */
.fixture-date-badge {
    background-color: #f0f0f0;
    color: #495057;
    font-size: 0.8rem;
    font-weight: 600;
    padding: 0.3rem 0.75rem;
    border-radius: 2rem;
    white-space: nowrap;
}

/* --- Type Badge --- */
.fixture-type-badge {
    background-color: #e8f0fe;
    color: #1a56db;
    font-size: 0.75rem;
    font-weight: 600;
    padding: 0.25rem 0.6rem;
    border-radius: 2rem;
    white-space: nowrap;
}

/* --- Teams --- */
.fixture-teams {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    flex: 1;
    justify-content: center;
    min-width: 0;
    text-align: center;
}

.fixture-team-name {
    font-weight: 600;
    font-size: 1rem;
    color: #212529;
}

.fixture-vs {
    color: #6c757d;
    font-size: 0.85rem;
    font-weight: 400;
}

/* --- Score Badge --- */
.fixture-score-badge-wrapper {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    flex-shrink: 0;
}

.fixture-score-badge {
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
    background-color: #2d2d2d;
    color: #fff;
    padding: 0.35rem 0.75rem;
    border-radius: 0.5rem;
    font-weight: 700;
    font-size: 1rem;
}

.fixture-score-badge .font-win {
    color: #7cc576;
}

.fixture-score-badge .font-lose {
    color: #ff6b6b;
}

.fixture-score-separator {
    color: #aaa;
    margin: 0 0.15rem;
}

.fixture-chevron {
    font-size: 0.85rem;
    color: #6c757d;
    transition: transform 0.2s ease;
}

.fixture-header[aria-expanded="true"] .fixture-chevron {
    transform: rotate(180deg);
}

.fixture-pending-badge {
    background-color: #e9ecef;
    color: #6c757d;
    font-size: 0.8rem;
    font-weight: 600;
    padding: 0.3rem 0.75rem;
    border-radius: 2rem;
}

/* --- Fixture Detail (expanded content) --- */
.fixture-detail {
    padding: 1.25rem;
    border-top: 1px solid #e9ecef;
    background-color: #fafbfc;
}

/* --- Scoreboard --- */
.scoreboard {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 1.5rem;
    padding: 1.25rem;
    margin-bottom: 1.5rem;
    background: #fff;
    border-radius: 0.75rem;
    border: 1px solid #dee2e6;
}

.scoreboard-team {
    font-size: 1.1rem;
    font-weight: 600;
    color: #495057;
    flex: 1;
    text-align: center;
}

.scoreboard-team:first-child {
    text-align: right;
}

.scoreboard-team:last-child {
    text-align: left;
}

.scoreboard-winner {
    color: #198754;
    font-weight: 700;
}

.scoreboard-scores {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    flex-shrink: 0;
}

.scoreboard-score {
    font-size: 2rem;
    font-weight: 800;
    color: #495057;
    min-width: 2.5rem;
    text-align: center;
}

.scoreboard-score-win {
    color: #198754;
}

.scoreboard-divider {
    font-size: 1.5rem;
    color: #adb5bd;
    font-weight: 300;
}

/* --- Result Section (Pairs / Singles) --- */
.result-section {
    margin-bottom: 1.25rem;
}

.result-section:last-child {
    margin-bottom: 0;
}

.result-section-title {
    font-size: 0.9rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: #6c757d;
    margin-bottom: 0.5rem;
    padding-bottom: 0.25rem;
    border-bottom: 2px solid #e9ecef;
}

/* --- Result Table --- */
.result-table-wrapper {
    overflow-x: auto;
}

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

.result-table thead th {
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: #6c757d;
    padding: 0.5rem 0.75rem;
    border-bottom: 1px solid #dee2e6;
}

.result-th-player {
    width: 40%;
}

.result-th-score {
    width: 10%;
    text-align: center;
}

.result-table tbody td {
    padding: 0.6rem 0.75rem;
    border-bottom: 1px solid #f0f0f0;
    font-size: 0.95rem;
}

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

.result-score-cell {
    text-align: center;
    width: 10%;
}

/* --- Score Pills --- */
.score-pill {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 1.75rem;
    height: 1.75rem;
    padding: 0 0.4rem;
    border-radius: 2rem;
    font-weight: 700;
    font-size: 0.85rem;
    color: #fff;
}

.score-pill-win {
    background-color: #198754;
}

.score-pill-lose {
    background-color: #dc3545;
}

/* --- Download Button --- */
.btn-fixtures-download {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 1.25rem;
    border: 2px solid #198754;
    border-radius: 0.5rem;
    color: #198754;
    font-weight: 600;
    font-size: 0.95rem;
    text-decoration: none;
    transition: all 0.2s ease;
}

.btn-fixtures-download:hover {
    background-color: #198754;
    color: #fff;
}

/* --- Mobile Responsive --- */
@media (max-width: 768px) {
    .tabs-header {
        flex-direction: column;
        align-items: stretch;
    }

    .season-picker-inline {
        margin-bottom: 0.5rem;
    }

    .season-picker-inline select {
        width: 100%;
        border-radius: 0.5rem;
        border-bottom-color: #dee2e6;
    }

    .dark .season-picker-inline select {
        border-bottom-color: #374151;
    }

    .fixture-header {
        flex-wrap: wrap;
        padding: 0.75rem 1rem;
        gap: 0.5rem;
    }

    .fixture-date-badge {
        order: 1;
        font-size: 0.75rem;
    }

    .fixture-score-badge-wrapper {
        order: 2;
    }

    .fixture-teams {
        order: 3;
        width: 100%;
        flex-basis: 100%;
        justify-content: center;
    }

    .fixture-team-name {
        font-size: 0.9rem;
    }

    .scoreboard {
        flex-direction: column;
        gap: 0.5rem;
        padding: 1rem;
    }

    .scoreboard-team {
        font-size: 0.95rem;
        text-align: center !important;
    }

    .scoreboard-score {
        font-size: 1.5rem;
    }

    .result-table tbody td,
    .result-table thead th {
        padding: 0.4rem 0.5rem;
        font-size: 0.85rem;
    }
}

/* ==========================================================================
   Fixtures - Dark Mode
   ========================================================================= */
.dark .fixture-card {
    background: #1f2937;
    border-color: #374151;
}

.dark .fixture-card:hover {
    box-shadow: 0 2px 12px rgba(0, 0, 0, 0.3);
}

.dark .fixture-header:hover {
    background-color: rgba(124, 197, 118, 0.08);
}

.dark .fixture-date-badge {
    background-color: #374151;
    color: #d1d5db;
}

.dark .fixture-type-badge {
    background-color: #1e3a5f;
    color: #93bbfc;
}

.dark .fixture-team-name {
    color: #f3f4f6;
}

.dark .fixture-vs {
    color: #9ca3af;
}

.dark .fixture-score-badge {
    background-color: #111827;
}

.dark .fixture-chevron {
    color: #9ca3af;
}

.dark .fixture-pending-badge {
    background-color: #374151;
    color: #9ca3af;
}

.dark .fixture-detail {
    border-top-color: #374151;
    background-color: #111827;
}

.dark .scoreboard {
    background: #1f2937;
    border-color: #374151;
}

.dark .scoreboard-team {
    color: #d1d5db;
}

.dark .scoreboard-score {
    color: #d1d5db;
}

.dark .scoreboard-divider {
    color: #6b7280;
}

.dark .result-section-title {
    color: #9ca3af;
    border-bottom-color: #374151;
}

.dark .result-table thead th {
    color: #9ca3af;
    border-bottom-color: #374151;
}

.dark .result-table tbody td {
    border-bottom-color: #1f2937;
    color: #d1d5db;
}

.dark .btn-fixtures-download {
    border-color: #7cc576;
    color: #7cc576;
}

.dark .btn-fixtures-download:hover {
    background-color: #7cc576;
    color: #111827;
}
