/* Z-Rating Website Styles */
@import url('https://fonts.googleapis.com/css2?family=Merriweather:wght@400;700&display=swap');

:root {
    --primary-color: #991b1b;
    --secondary-color: #b91c1c;
    --accent-color: #dc2626;
    --bg-color: #fef2f2;
    --card-bg: #ffffff;
    --text-color: #1a202c;
    --text-muted: #4a5568;
    --border-color: #e8d2d2;
    --hover-bg: #fef2f2;
    --class-4a: #991b1b;
    --class-3a: #2f855a;
    --class-2a: #b7791f;
    --class-1a: #1e4976;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Merriweather', Georgia, serif;
    background-color: var(--bg-color);
    color: var(--text-color);
    line-height: 1.6;
}

.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 20px;
}

/* Header */
header {
    background: var(--bg-color);
    padding: 20px 0;
    text-align: center;
    border-bottom: 3px solid var(--primary-color);
}

.header-content {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
}

header .logo {
    max-width: 400px;
    height: auto;
}

/* Sport Toggle */
.sport-toggle {
    display: flex;
    align-items: center;
    gap: 12px;
    font-size: 1rem;
}

.sport-link {
    color: var(--text-muted);
    text-decoration: none;
    font-weight: 500;
    padding: 4px 12px;
    border-radius: 4px;
    transition: all 0.2s;
}

.sport-link:hover {
    color: var(--primary-color);
    background: var(--hover-bg);
}

.sport-link.active {
    color: white;
    background: var(--primary-color);
}

.sport-divider {
    color: var(--border-color);
}

header h1 {
    font-size: 2.5rem;
    font-weight: 700;
    letter-spacing: -0.5px;
}

header .subtitle {
    font-size: 1.1rem;
    opacity: 0.9;
    margin-top: 5px;
}

/* Info Bar */
.info-bar {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 40px;
    padding: 20px;
    background: var(--card-bg);
    border-radius: 8px;
    margin: 20px 0;
    box-shadow: 0 1px 3px rgba(0,0,0,0.1);
    flex-wrap: wrap;
}

.stat {
    text-align: center;
}

.stat-value {
    display: block;
    font-size: 1.2rem;
    font-weight: 700;
    color: var(--primary-color);
    font-family: 'Courier New', Courier, monospace;
}

.stat-label {
    font-size: 0.7rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.season-selector select {
    font-size: 0.9rem;
    font-weight: 700;
    color: var(--primary-color);
    background: var(--card-bg);
    border: 2px solid var(--primary-color);
    border-radius: 4px;
    padding: 5px 15px;
    cursor: pointer;
    text-align: center;
}

.season-selector select:focus {
    outline: none;
    box-shadow: 0 0 0 2px rgba(185, 28, 28, 0.3);
}

/* Filters */
.filters-section {
    margin-bottom: 20px;
}

.filters-header {
    display: flex;
    align-items: center;
    gap: 15px;
    margin-bottom: 10px;
}

.btn-toggle-filters {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 16px;
    background: var(--card-bg);
    border: 1px solid var(--border-color);
    border-radius: 4px;
    font-size: 0.9rem;
    font-weight: 500;
    color: var(--text-color);
    cursor: pointer;
    transition: all 0.2s;
}

.btn-toggle-filters:hover {
    background: var(--hover-bg);
    border-color: var(--secondary-color);
}

.btn-toggle-filters #filter-toggle-icon {
    font-size: 0.7rem;
    transition: transform 0.2s;
}

.btn-toggle-filters.active #filter-toggle-icon {
    transform: rotate(180deg);
}

.filters {
    display: flex;
    flex-wrap: wrap;
    gap: 15px;
    padding: 20px;
    background: var(--card-bg);
    border-radius: 8px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.1);
    align-items: flex-end;
}

.filter-group {
    display: flex;
    flex-direction: column;
    gap: 5px;
}

.filter-group label {
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.filter-group select,
.filter-group input {
    padding: 8px 12px;
    border: 1px solid var(--border-color);
    border-radius: 4px;
    font-size: 0.95rem;
    min-width: 150px;
}

.filter-group select:focus,
.filter-group input:focus {
    outline: none;
    border-color: var(--secondary-color);
    box-shadow: 0 0 0 2px rgba(185, 28, 28, 0.2);
}

.btn-reset {
    padding: 8px 16px;
    background: var(--hover-bg);
    border: 1px solid var(--border-color);
    border-radius: 4px;
    cursor: pointer;
    font-size: 0.9rem;
    transition: background 0.2s;
}

.btn-reset:hover {
    background: var(--border-color);
}

/* Rankings Table */
.rankings {
    background: var(--card-bg);
    border-radius: 8px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.1);
    overflow: hidden;
}

#rankings-table {
    width: 100%;
    border-collapse: collapse;
}

#rankings-table th {
    background: var(--primary-color);
    color: white;
    padding: 12px 15px;
    text-align: left;
    font-weight: 600;
    font-size: 0.85rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

#rankings-table td {
    padding: 12px 15px;
    border-bottom: 1px solid var(--border-color);
}

#rankings-table tbody tr:hover {
    background: var(--hover-bg);
}

#rankings-table tbody tr:last-child td {
    border-bottom: none;
}

.col-filter-rank {
    width: 90px;
    text-align: center;
    white-space: nowrap;
}

.col-rank {
    width: 60px;
    text-align: center;
    white-space: nowrap;
}

.col-team {
    min-width: 180px;
}

.col-class {
    width: 55px;
    text-align: center;
    white-space: nowrap;
}

.col-record {
    width: 65px;
    text-align: center;
    white-space: nowrap;
}

.col-rating {
    width: 75px;
    text-align: center;
    white-space: nowrap;
}

.col-sos {
    width: 75px;
    text-align: center;
    white-space: nowrap;
}

.col-vs-top {
    width: 85px;
    text-align: center;
    white-space: nowrap;
}

.col-rpi {
    width: 70px;
    text-align: center;
    white-space: nowrap;
}

.checkbox-label {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.95rem;
    cursor: pointer;
    padding: 8px 0;
}

.checkbox-label input[type="checkbox"] {
    width: 18px;
    height: 18px;
    cursor: pointer;
}

/* Team Link */
.team-link {
    color: var(--secondary-color);
    text-decoration: none;
    font-weight: 500;
}

.team-link:hover {
    text-decoration: underline;
}

/* Abbreviated team name (hidden by default, shown on small screens) */
.team-abbr { display: none; }

/* Class Badges */
.class-badge {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 4px;
    font-size: 0.8rem;
    font-weight: 600;
    color: white;
}

.class-4A { background: var(--class-4a); }
.class-3A { background: var(--class-3a); }
.class-2A { background: var(--class-2a); }
.class-1A { background: var(--class-1a); }

/* Postseason Title Badges */
.title-badge {
    display: inline-block;
    padding: 2px 6px;
    border-radius: 4px;
    font-size: 0.65rem;
    font-weight: 600;
    margin-left: 6px;
    vertical-align: middle;
}

.title-badge.badge-sectional {
    background: #e0f2fe;
    border: 1px solid #7dd3fc;
    color: #0369a1;
}

.title-badge.badge-regional {
    background: #fcd6b5;
    border: 1px solid #cd7f32;
    color: #92400e;
}

.title-badge.badge-semistate {
    background: #e5e7eb;
    border: 1px solid #9ca3af;
    color: #374151;
}

.title-badge.badge-state {
    background: #fef3c7;
    border: 1px solid #fbbf24;
    color: #92400e;
}

/* Postseason Champs Key */
.postseason-key {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 15px;
    background: var(--hover-bg);
    border-radius: 6px;
    border: 1px solid var(--border-color);
    flex-wrap: wrap;
    justify-content: center;
    flex-basis: 100%;
}

.postseason-key .key-label {
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--text-muted);
}

.postseason-key .key-item {
    padding: 3px 8px;
    border-radius: 4px;
    font-size: 0.7rem;
    font-weight: 600;
}

.postseason-key .key-sectional {
    background: #e0f2fe;
    border: 1px solid #7dd3fc;
    color: #0369a1;
}

.postseason-key .key-regional {
    background: #fcd6b5;
    border: 1px solid #cd7f32;
    color: #92400e;
}

.postseason-key .key-semistate {
    background: #e5e7eb;
    border: 1px solid #9ca3af;
    color: #374151;
}

.postseason-key .key-state {
    background: #fef3c7;
    border: 1px solid #fbbf24;
    color: #92400e;
}

/* Rating Cell */
.rating-value {
    font-weight: 700;
    color: var(--primary-color);
}

/* Loading */
.loading {
    text-align: center;
    padding: 40px;
    color: var(--text-muted);
}

/* Legend */
.legend {
    margin-top: 30px;
    padding: 20px;
    background: var(--card-bg);
    border-radius: 8px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.1);
}

.legend h3 {
    margin-bottom: 10px;
    color: var(--primary-color);
}

.legend ul {
    margin: 10px 0 10px 20px;
}

.legend li {
    margin: 5px 0;
    color: var(--text-muted);
}

/* Footer */
footer {
    margin-top: 40px;
    padding: 20px 0;
    background: var(--primary-color);
    color: white;
    text-align: center;
    font-size: 0.9rem;
}

/* Team Page Styles */
.team-header {
    background: linear-gradient(135deg, #7f1d1d, var(--secondary-color));
    color: white;
    padding: 30px 0;
}

.team-header-top {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 10px;
}

.team-season-selector {
    display: flex;
    align-items: center;
    gap: 8px;
}

.team-season-selector label {
    font-size: 0.9rem;
    opacity: 0.9;
}

.team-season-selector select {
    padding: 6px 12px;
    border: 1px solid rgba(255,255,255,0.3);
    border-radius: 4px;
    background: rgba(255,255,255,0.15);
    color: white;
    font-size: 0.9rem;
    cursor: pointer;
}

.team-season-selector select:focus {
    outline: none;
    border-color: rgba(255,255,255,0.6);
    background: rgba(255,255,255,0.25);
}

.team-season-selector select option {
    background: var(--primary-color);
    color: white;
}

.team-name-row {
    display: flex;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
}

.team-name {
    font-size: 2.2rem;
    font-weight: 700;
}

/* Team Page Title Badge (larger version) */
.title-badge-lg {
    display: inline-block;
    padding: 4px 10px;
    border-radius: 5px;
    font-size: 0.85rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.title-badge-lg.badge-sectional {
    background: #e0f2fe;
    border: 1px solid #7dd3fc;
    color: #0369a1;
}

.title-badge-lg.badge-regional {
    background: #fcd6b5;
    border: 1px solid #cd7f32;
    color: #92400e;
}

.title-badge-lg.badge-semistate {
    background: #e5e7eb;
    border: 1px solid #9ca3af;
    color: #374151;
}

.title-badge-lg.badge-state {
    background: #fef3c7;
    border: 1px solid #fbbf24;
    color: #92400e;
}

.team-meta {
    display: flex;
    gap: 20px;
    margin-top: 10px;
    font-size: 1rem;
    opacity: 0.9;
}

/* Team Stats Container - Side by Side Layout */
.team-stats-container {
    display: flex;
    gap: 12px;
    margin: 14px 0;
    align-items: stretch;
}

.team-stats {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(80px, 1fr));
    gap: 6px;
    padding: 12px 14px;
    background: var(--card-bg);
    border-radius: 8px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.1);
    align-content: center;
}

.team-stats-primary {
    flex: 2;
}

.team-stats-secondary {
    flex: 1;
    grid-template-columns: repeat(2, 1fr);
    align-content: center;
}

.team-stat {
    text-align: center;
}

.team-stat-value {
    display: block;
    font-size: 1.05rem;
    font-weight: 700;
    color: var(--primary-color);
}

.team-stat-label {
    font-size: 0.68rem;
    color: var(--text-muted);
    text-transform: uppercase;
}

/* Secondary Stats (Sectional/Regional Rankings) */
.team-stat-group {
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    white-space: nowrap;
    padding: 0 8px;
}

.team-stat-group:not(:first-child) {
    border-left: 1px solid #ddd;
    padding-left: 12px;
}

.team-stat-category {
    font-size: 0.68rem;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.team-stat-category-num {
    font-size: 0.85rem;
    font-weight: 700;
    color: var(--secondary-color);
    margin-bottom: 2px;
}

.team-stat-value-sm {
    display: block;
    font-size: 1.05rem;
    font-weight: 700;
    color: var(--primary-color);
}

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

.schedule-table th {
    background: var(--hover-bg);
    padding: 10px 15px;
    text-align: left;
    font-weight: 600;
    font-size: 0.85rem;
    border-bottom: 2px solid var(--border-color);
}

.schedule-table td {
    padding: 10px 15px;
    border-bottom: 1px solid var(--border-color);
}

.schedule-table .col-opp-rank {
    text-align: right;
    padding-right: 20px;
}

.schedule-subheader {
    background: var(--primary-color);
    color: white;
    font-weight: 600;
    text-transform: uppercase;
    font-size: 0.85rem;
    letter-spacing: 0.5px;
}

.schedule-subheader td {
    padding: 8px 15px !important;
}

.result-W {
    color: #2f855a;
    font-weight: 600;
}

.result-L {
    color: #c53030;
    font-weight: 600;
}

.back-link {
    display: inline-block;
    margin-bottom: 20px;
    color: rgba(255,255,255,0.8);
    text-decoration: none;
}

.back-link:hover {
    color: white;
    text-decoration: underline;
}

/* ── Responsive ───────────────────────────────────────────────────────────── */

/* ≤950px — hide vs Top 10 / vs Top 25 columns */
@media (max-width: 950px) {
    .col-vs-top { display: none; }
}

/* ≤768px — hide SOS; show abbreviated team names; general layout fixes */
@media (max-width: 768px) {
    header .logo {
        max-width: 280px;
    }
    .info-bar {
        gap: 15px;
        justify-content: center;
    }

    .postseason-key {
        width: 100%;
    }

    /* Team stats stack vertically on mobile */
    .team-stats-container {
        flex-direction: column;
    }

    .team-stats-primary,
    .team-stats-secondary {
        flex: none;
        width: 100%;
    }

    .team-stats-secondary {
        grid-template-columns: repeat(2, 1fr);
    }

    .filters-header {
        flex-wrap: wrap;
    }

    .filters {
        flex-direction: column;
        align-items: flex-start;
    }

    .filter-group {
        width: 100%;
    }

    .filter-group select,
    .filter-group input {
        width: 100%;
    }

    #rankings-table {
        font-size: 0.9rem;
    }

    #rankings-table th,
    #rankings-table td {
        padding: 8px 10px;
    }

    .col-sos {
        display: none;
    }

    .team-full { display: none; }
    .team-abbr { display: inline; }

    .team-header-top {
        flex-direction: column;
        align-items: flex-start;
        gap: 10px;
    }

    .team-season-selector {
        width: 100%;
    }

    .team-season-selector select {
        flex: 1;
    }
}

/* ≤550px — hide Record */
@media (max-width: 550px) {
    .col-record { display: none; }
}

@media (max-width: 480px) {
    .team-stats-secondary .team-stat-group { padding: 0 5px; }
    .team-stats-secondary .team-stat-group:not(:first-child) { padding-left: 8px; }

    .team-stat-value {
        font-size: 0.95rem;
    }

    .team-stat-value-sm {
        font-size: 0.9rem;
    }
}

/* ── Page Tab Bar (Rankings / Results tabs) ─────────────────────── */
.page-tab-bar {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-end;
    gap: 3px;
    padding: 0 20px;
    background: var(--bg-color);
    border-bottom: 2.5px solid var(--primary-color);
}

@media (max-width: 500px) {
    .page-tab-bar {
        padding: 0 12px;
        gap: 2px;
    }
    .page-tab-bar a {
        padding: 7px 14px 6px;
        font-size: 0.82rem;
    }
    .page-tab-bar a.active {
        padding-bottom: 8px;
    }
}

.page-tab-bar a {
    display: inline-block;
    padding: 9px 26px 8px;
    font-size: 0.88rem;
    font-weight: 600;
    text-decoration: none;
    color: var(--text-muted);
    background: #f3d9d9;
    border: 1.5px solid #d8a8a8;
    border-bottom: none;
    border-radius: 7px 7px 0 0;
    position: relative;
    bottom: -2.5px;
    letter-spacing: 0.01em;
    transition: background 0.15s, color 0.15s, border-color 0.15s;
}

.page-tab-bar a:hover {
    background: #fce8e8;
    color: var(--primary-color);
    border-color: #c07070;
}

.page-tab-bar a.active {
    background: var(--card-bg);
    color: var(--primary-color);
    border-color: var(--primary-color);
    border-bottom: 2.5px solid var(--card-bg);
    font-weight: 700;
    padding-bottom: 10px;
}

/* ── Results page ───────────────────────────────────────────────── */
.results-nav {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    margin: 24px 0 18px;
    flex-wrap: wrap;
}

.date-btn {
    background: var(--card-bg);
    border: 1.5px solid var(--border-color);
    border-radius: 6px;
    padding: 8px 18px;
    font-size: 1rem;
    font-family: inherit;
    color: var(--primary-color);
    cursor: pointer;
    font-weight: 600;
    transition: background 0.15s, border-color 0.15s;
}
.date-btn:hover:not(:disabled) {
    background: var(--hover-bg);
    border-color: var(--secondary-color);
}
.date-btn:disabled {
    opacity: 0.35;
    cursor: default;
}

.date-display {
    font-size: 1.2rem;
    font-weight: 700;
    color: var(--primary-color);
    min-width: 200px;
    text-align: center;
}

.date-input-wrap input[type="date"] {
    padding: 8px 12px;
    border: 1.5px solid var(--border-color);
    border-radius: 6px;
    font-size: 0.9rem;
    font-family: inherit;
    color: var(--text-color);
    background: var(--card-bg);
    cursor: pointer;
}
.date-input-wrap input[type="date"]:focus {
    outline: none;
    border-color: var(--secondary-color);
    box-shadow: 0 0 0 2px rgba(153,27,27,0.2);
}

.results-count {
    text-align: center;
    font-size: 0.9rem;
    color: var(--text-muted);
    margin-bottom: 18px;
}

.matches-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 14px;
    margin-bottom: 32px;
}

.match-card {
    background: var(--card-bg);
    border-radius: 8px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.1);
    padding: 16px 20px;
    border-left: 4px solid var(--accent-color);
    transition: box-shadow 0.15s;
}
.match-card:hover {
    box-shadow: 0 3px 10px rgba(0,0,0,0.13);
}

.match-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    padding: 5px 0;
}
.match-row:first-child {
    border-bottom: 1px solid var(--border-color);
    padding-bottom: 10px;
    margin-bottom: 4px;
}

.match-team-name {
    flex: 1;
    font-size: 0.95rem;
    font-weight: 600;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.match-team-name a {
    color: inherit;
    text-decoration: none;
}
.match-team-name a:hover {
    color: var(--secondary-color);
    text-decoration: underline;
}
.winner-row .match-team-name { color: var(--primary-color); }
.loser-row .match-team-name  { color: var(--text-muted); font-weight: 400; }

.sets-badge {
    display: inline-block;
    min-width: 36px;
    text-align: center;
    font-size: 1.05rem;
    font-weight: 700;
    border-radius: 4px;
    padding: 2px 8px;
    flex-shrink: 0;
}
.winner-row .sets-badge { background: var(--primary-color); color: #fff; }
.loser-row .sets-badge  { background: var(--hover-bg); color: var(--text-muted); }

.result-label {
    font-size: 0.75rem;
    font-weight: 700;
    color: var(--text-muted);
    min-width: 36px;
    text-align: right;
    flex-shrink: 0;
}

.no-results {
    text-align: center;
    padding: 60px 20px;
    color: var(--text-muted);
    font-size: 1rem;
    background: var(--card-bg);
    border-radius: 8px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.08);
}

.btn-latest {
    background: var(--primary-color);
    color: #fff;
    border: none;
    border-radius: 6px;
    padding: 8px 16px;
    font-size: 0.85rem;
    font-family: inherit;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.15s;
}
.btn-latest:hover { background: var(--secondary-color); }

@media (max-width: 600px) {
    .matches-grid { grid-template-columns: 1fr; }
    .date-display { font-size: 1rem; min-width: 160px; }
}
