/**
 * Series Ranking Specific Styles
 *
 * Extends /assets/css/style.css with tabs, matrix table, and ranking-specific styles.
 * Color scheme: Red (#C71F3C) to match Swiss Squash branding.
 */

/* ========== SERIES HEADER ========== */
.series-header {
    justify-content: center;
}

.series-header .logos-left,
.series-header .logos-right {
    flex: 0 0 auto;
    min-width: 150px;
    align-self: flex-start;
}

.series-header .logos-right {
    visibility: hidden;
}

.header-title {
    text-align: center;
    flex: 1;
}

.header-title h1 {
    margin-bottom: 0;
}

.header-title .subtitle {
    color: #666;
    font-size: 0.9em;
    margin: 2px 0 0 0;
}

/* ========== META SECTION ========== */
.meta {
    background: #f8f9fa;
    padding: 10px 15px;
    border-radius: 5px;
    margin-bottom: 15px;
}

.meta p {
    margin: 3px 0;
    font-size: 0.9em;
}

.meta-inline {
    display: flex;
    flex-wrap: wrap;
    gap: 20px;
    justify-content: center;
}

.meta-inline span {
    font-size: 0.9em;
}

/* ========== RULES SECTION (Foldable) ========== */
.rules-section {
    margin-top: -15px;
    margin-bottom: 8px;
}

.rules-section summary {
    display: flex;
    align-items: center;
    cursor: pointer;
    user-select: none;
    list-style: none;
    color: #888;
    font-size: 0.85em;
}

.rules-section summary::-webkit-details-marker {
    display: none;
}

.rules-section summary::before,
.rules-section summary::after {
    content: "";
    flex: 1;
    height: 1px;
    background: #ddd;
}

.rules-section summary::before {
    margin-right: 12px;
}

.rules-section summary::after {
    margin-left: 12px;
}

.rules-section summary .summary-text::before {
    content: "▶ ";
    font-size: 0.7em;
    transition: transform 0.2s ease;
    display: inline-block;
}

.rules-section[open] summary .summary-text::before {
    content: "▼ ";
}

.rules-section summary:hover {
    color: #666;
}

.rules-list {
    padding: 10px 15px 15px 35px;
    margin: 0;
    background: #f8f9fa;
    border-radius: 5px;
    margin-top: 10px;
}

.rules-list li {
    margin-bottom: 5px;
    font-size: 0.8em;
    color: #666;
}

.rules-list li:last-child {
    margin-bottom: 0;
}

.rules-list .prize-eligibility-note {
    font-style: italic;
    opacity: 0.8;
}

.rules-list .points-table {
    margin-top: 5px;
    padding: 8px 12px;
    background: #fff;
    border: 1px solid #e0e0e0;
    border-radius: 4px;
    font-family: monospace;
    font-size: 0.85em;
    color: #666;
    white-space: nowrap;
    overflow-x: auto;
}

/* ========== TABS SYSTEM ========== */
.tabs-container {
    margin-bottom: 30px;
}

.tabs {
    display: flex;
    flex-wrap: wrap;
    gap: 5px;
    margin-bottom: 20px;
    border-bottom: 2px solid #e0e0e0;
}

.tab-btn {
    padding: 6px 16px;
    cursor: pointer;
    background: #f0f0f0;
    border: 1px solid #ddd;
    border-bottom: none;
    border-radius: 5px 5px 0 0;
    transition: all 0.3s ease;
    font-weight: 600;
    color: #666;
    font-size: 13px;
}

.tab-btn:hover {
    background: #e0e0e0;
}

.tab-btn.active {
    background: #C71F3C;
    color: white;
    border-color: #C71F3C;
}

.tab-content {
    display: none;
    animation: fadeIn 0.3s ease-in-out;
}

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

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

.tab-content h2 {
    color: #C71F3C;
    font-size: 1.8em;
    margin-bottom: 5px;
    padding-bottom: 10px;
    border-bottom: 2px solid #e0e0e0;
}

.category-info {
    color: #666;
    font-size: 0.9em;
    margin-bottom: 20px;
}

/* ========== MATRIX TABLE ========== */
.table-wrapper {
    overflow-x: auto;
    margin-bottom: 30px;
}

.matrix-table {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
    font-size: 0.9em;
}

.matrix-table thead {
    background: #C71F3C;
    color: white;
}

.matrix-table th {
    padding: 8px 6px;
    text-align: center;
    font-weight: 600;
    border-right: 1px solid rgba(255,255,255,0.2);
    white-space: nowrap;
}

.tournament-col .tournament-name {
    display: block;
}

.tournament-col .tournament-date {
    display: block;
    font-size: 0.75em;
    font-weight: 400;
    opacity: 0.85;
}

.matrix-table th:last-child {
    border-right: none;
}

/* Sticky columns (rank + player name) */
.sticky-col {
    position: sticky;
    background: white;
    z-index: 10;
}

.rank-col {
    left: 0;
    width: 50px;
    text-align: center;
}

.player-col {
    left: 50px;
    min-width: 150px;
    text-align: left;
}

.matrix-table thead .sticky-col {
    background: #C71F3C;
    z-index: 20;
}

.tournament-col {
    width: 70px;
    min-width: 70px;
    text-align: center;
}

.total-col {
    width: 70px;
    text-align: center;
    font-weight: 600;
    background: #f8f9fa;
}

.matrix-table tbody tr {
    border-bottom: 1px solid #e0e0e0;
}

.matrix-table tbody tr:nth-child(odd) {
    background: #fafafa;
}

.matrix-table tbody tr:nth-child(odd) .sticky-col {
    background: #fafafa;
}

.matrix-table tbody tr:hover {
    background: #fce8eb;
}

.matrix-table tbody tr:hover .sticky-col {
    background: #fce8eb;
}

.matrix-table td {
    padding: 8px;
    border-right: 1px solid #e0e0e0;
}

.matrix-table td:last-child {
    border-right: none;
}

.center {
    text-align: center;
}

/* ========== RANK STYLES ========== */
.rank {
    font-weight: bold;
    font-size: 1.1em;
    color: #C71F3C;
}

.rank-1 { color: #FFD700; } /* Gold */
.rank-2 { color: #C0C0C0; } /* Silver */
.rank-3 { color: #CD7F32; } /* Bronze */

.player-name {
    font-weight: 600;
    padding-left: 12px !important;
}

/* ========== POINTS BADGES ========== */
.points-badge {
    display: inline-block;
    padding: 4px 8px;
    background: #fce8eb;
    border-radius: 3px;
    color: #C71F3C;
    font-weight: 600;
    min-width: 30px;
}

.no-participation {
    color: #ccc;
    font-size: 1.2em;
}

/* Ineligible for prize (insufficient participations) */
.matrix-table tbody tr.ineligible-for-prize {
    opacity: 0.35;
}

.matrix-table tbody tr.ineligible-for-prize:hover {
    opacity: 0.6;
}

.participation-count {
    color: #666;
    font-weight: 600;
}

.total-points {
    color: #C71F3C;
    font-size: 1.1em;
}

/* ========== FOOTER ========== */
.ranking-footer {
    text-align: center;
    margin-top: 40px;
    padding-top: 20px;
    border-top: 2px solid #e0e0e0;
    color: #666;
    font-size: 0.9em;
}

/* ========== RESPONSIVE ========== */
@media (max-width: 768px) {
    .tab-btn {
        padding: 8px 12px;
        font-size: 0.9em;
    }

    .matrix-table {
        font-size: 0.8em;
    }

    .player-col {
        min-width: 120px;
    }

    .meta {
        padding: 10px;
        font-size: 0.85em;
    }
}

@media print {
    .tabs {
        display: none;
    }

    .tab-content {
        display: block !important;
        page-break-before: always;
    }

    .tab-content:first-of-type {
        page-break-before: avoid;
    }

    .matrix-table {
        page-break-inside: avoid;
    }

    .ranking-footer {
        page-break-before: avoid;
    }
}
