/* Reset and Base Styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    --primary-color: #2c3e50;
    --secondary-color: #3498db;
    --success-color: #27ae60;
    --danger-color: #e74c3c;
    --warning-color: #f39c12;
    --neutral-color: #95a5a6;
    --background-color: #ecf0f1;
    --card-background: #ffffff;
    --text-color: #2c3e50;
    --border-color: #bdc3c7;
    --home-color: #3498db;
    --away-color: #9b59b6;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    line-height: 1.6;
    color: var(--text-color);
    background-color: var(--background-color);
}

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

/* Header */
header {
    background-color: var(--primary-color);
    color: white;
    padding: 1rem 0;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

header nav {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.logo {
    font-size: 1.5rem;
    font-weight: bold;
    color: white;
    text-decoration: none;
}

.nav-links a {
    color: white;
    text-decoration: none;
    margin-left: 2rem;
    transition: color 0.3s;
}

.nav-links a:hover {
    color: var(--secondary-color);
}

/* Main Content */
main {
    padding: 1rem 0;
    min-height: calc(100vh - 200px);
}

/* Team Header */
.team-header {
    text-align: center;
    margin-bottom: 0.75rem;
}

.team-header h1 {
    font-size: 1.8rem;
    color: var(--primary-color);
    margin-bottom: 0.3rem;
}

.team-header h2 {
    font-size: 1rem;
    color: var(--neutral-color);
    font-weight: normal;
}

/* Season Selector */
.season-selector {
    margin-top: 1rem;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.75rem;
}

.season-selector label {
    font-size: 1rem;
    color: var(--primary-color);
    font-weight: 600;
}

.season-selector select {
    padding: 0.5rem 1rem;
    font-size: 1rem;
    border: 2px solid var(--border-color);
    border-radius: 6px;
    background-color: var(--card-background);
    color: var(--text-color);
    cursor: pointer;
    transition: border-color 0.3s, box-shadow 0.3s;
    min-width: 250px;
}

.season-selector select:hover {
    border-color: var(--secondary-color);
}

.season-selector select:focus {
    outline: none;
    border-color: var(--secondary-color);
    box-shadow: 0 0 0 3px rgba(52, 152, 219, 0.1);
}

/* Sidebar Selector */
.sidebar-selector {
    margin-bottom: 0.5rem;
}

.sidebar-selector label {
    font-size: 0.7rem;
    color: var(--primary-color);
    font-weight: 600;
    display: block;
    margin-bottom: 0.3rem;
}

.sidebar-selector select {
    width: 100%;
    padding: 0.35rem 0.5rem;
    font-size: 0.75rem;
    border: 1px solid var(--border-color);
    border-radius: 4px;
    background-color: var(--card-background);
    color: var(--text-color);
    cursor: pointer;
    transition: border-color 0.3s;
}

.sidebar-selector select:hover {
    border-color: var(--secondary-color);
}

.sidebar-selector select:focus {
    outline: none;
    border-color: var(--secondary-color);
}

/* Content Layout with Sidebar */
.content-layout {
    display: flex;
    gap: 0.75rem;
    align-items: flex-start;
}

.sidebar {
    flex-shrink: 0;
    width: 180px;
    background: var(--card-background);
    border-radius: 8px;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
    position: sticky;
    top: 20px;
}

.sidebar-section {
    padding: 0.75rem;
    border-bottom: 1px solid var(--border-color);
}

.sidebar-section:last-child {
    border-bottom: none;
}

.sidebar-section h3 {
    font-size: 0.8rem;
    color: var(--primary-color);
    margin-bottom: 0.5rem;
    font-weight: 600;
}

.stat-item {
    margin-bottom: 0.5rem;
    padding-bottom: 0.5rem;
    border-bottom: 1px solid #f0f0f0;
}

.stat-item:last-child {
    margin-bottom: 0;
    padding-bottom: 0;
    border-bottom: none;
}

.stat-item .stat-label {
    font-size: 0.7rem;
    color: var(--neutral-color);
    margin-bottom: 0.15rem;
}

.stat-item .stat-value {
    font-size: 1.2rem;
    font-weight: bold;
    color: var(--primary-color);
}

.stat-item .stat-value-large {
    font-size: 1.6rem;
    font-weight: bold;
    color: var(--primary-color);
}

.stat-item.positive .stat-value,
.stat-item.positive .stat-value-large {
    color: var(--success-color);
}

.stat-item.negative .stat-value,
.stat-item.negative .stat-value-large {
    color: var(--danger-color);
}

.team-replacements {
    font-size: 0.65rem;
}

.replacement {
    display: flex;
    align-items: center;
    gap: 0.3rem;
    margin-bottom: 0.3rem;
    padding: 0.3rem;
    background: #f8f9fa;
    border-radius: 3px;
}

.old-team {
    color: var(--danger-color);
    font-weight: 500;
}

.arrow {
    color: var(--neutral-color);
}

.new-team {
    color: var(--success-color);
    font-weight: 500;
}

.main-content {
    flex: 1;
    min-width: 0;
}

/* Summary Stats */
.summary-stats {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 1rem;
    margin-bottom: 2rem;
}

.stat-card {
    background: var(--card-background);
    padding: 1.5rem;
    border-radius: 8px;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
    text-align: center;
}

.stat-label {
    font-size: 0.9rem;
    color: var(--neutral-color);
    margin-bottom: 0.5rem;
}

.stat-value {
    font-size: 2rem;
    font-weight: bold;
    color: var(--primary-color);
}

.stat-card.positive .stat-value {
    color: var(--success-color);
}

.stat-card.negative .stat-value {
    color: var(--danger-color);
}

/* Team Mapping Notice */
.team-mapping-notice {
    background: #fff3cd;
    border: 1px solid #ffc107;
    border-radius: 8px;
    padding: 1rem;
    margin-bottom: 2rem;
}

.mapping {
    display: inline-block;
    margin-left: 1rem;
    padding: 0.25rem 0.5rem;
    background: white;
    border-radius: 4px;
    font-size: 0.9rem;
}

/* Comparison Table */
.comparison-table {
    background: var(--card-background);
    border-radius: 8px;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
    overflow: hidden;
}

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

thead {
    background-color: var(--primary-color);
    color: white;
}

th {
    padding: 0.4rem 0.5rem;
    text-align: center;
    font-weight: 600;
    font-size: 0.75rem;
}

.season-header {
    background-color: var(--primary-color);
    border-left: 2px solid rgba(255, 255, 255, 0.3);
}

.venue-header {
    background-color: #34495e;
    font-size: 0.7rem;
    padding: 0.3rem 0.4rem;
}

th.opponent-col {
    text-align: left;
}

th.diff-col {
    text-align: center;
}

tbody tr {
    border-bottom: 1px solid var(--border-color);
    transition: background-color 0.2s;
}

tbody tr:hover {
    background-color: #f8f9fa;
}

tfoot {
    background-color: #f8f9fa;
    border-top: 2px solid var(--primary-color);
}

tfoot .totals-row {
    font-weight: bold;
}

tfoot .totals-row:hover {
    background-color: #f8f9fa;
}

td {
    padding: 0.35rem 0.5rem;
    font-size: 0.8rem;
}

.opponent-col {
    font-weight: 600;
    min-width: 120px;
    text-align: left;
}

.replaced {
    font-size: 0.65rem;
    color: var(--neutral-color);
    font-weight: normal;
    display: block;
    margin-top: 0.1rem;
}

.fixture-cell {
    text-align: center;
    padding: 0.3rem 0.4rem;
    min-width: 70px;
}

.score {
    font-weight: bold;
    font-size: 0.85rem;
    padding: 0.15rem 0.3rem;
    border-radius: 3px;
    display: inline-block;
}

.score.win {
    background-color: #d4edda;
    color: #155724;
}

.score.draw {
    background-color: #fff3cd;
    color: #856404;
}

.score.loss {
    background-color: #f8d7da;
    color: #721c24;
}

.score.pending {
    background-color: #e9ecef;
    color: var(--neutral-color);
}

.xg {
    font-size: 0.7rem;
    color: var(--neutral-color);
    display: block;
    margin-top: 0.15rem;
}

.diff-col {
    width: 60px;
    text-align: center;
}

.points-diff {
    display: inline-block;
    padding: 0.2rem 0.4rem;
    border-radius: 3px;
    font-weight: bold;
    font-size: 0.8rem;
}

.points-diff.positive {
    background-color: var(--success-color);
    color: white;
}

.points-diff.negative {
    background-color: var(--danger-color);
    color: white;
}

.points-diff.neutral {
    background-color: var(--neutral-color);
    color: white;
}

/* Index Page */
.hero {
    text-align: center;
    margin-bottom: 2rem;
    padding: 2rem 0 1rem;
}

.hero h1 {
    font-size: 3rem;
    color: var(--primary-color);
    margin-bottom: 1rem;
}

.hero p {
    font-size: 1.2rem;
    color: var(--neutral-color);
}

/* Summary Section */
.summary-section {
    background: var(--card-background);
    border-radius: 8px;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
    padding: 1.5rem;
    margin-bottom: 2rem;
}

.summary-section h2 {
    color: var(--primary-color);
    margin-bottom: 1rem;
    text-align: center;
    font-size: 1.5rem;
}

.summary-table-container {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

.summary-table {
    width: 100%;
    border-collapse: collapse;
    margin-bottom: 1rem;
}

.summary-table thead {
    background-color: var(--primary-color);
    color: white;
}

.summary-table th {
    padding: 0.75rem 0.5rem;
    text-align: center;
    font-weight: 600;
    font-size: 0.85rem;
}

.summary-table th.team-col {
    text-align: left;
}

.summary-table tbody tr {
    border-bottom: 1px solid var(--border-color);
    transition: background-color 0.2s;
}

.summary-table tbody tr:hover {
    background-color: #f8f9fa;
}

.summary-table td {
    padding: 0.6rem 0.5rem;
    font-size: 0.85rem;
    text-align: center;
}

.summary-table td.team-col {
    text-align: left;
    font-weight: 600;
}

.summary-table td.team-col a {
    color: var(--primary-color);
    text-decoration: none;
    transition: color 0.2s;
}

.summary-table td.team-col a:hover {
    color: var(--secondary-color);
    text-decoration: underline;
}

.comparison-note {
    display: inline;
    margin-left: 0.3rem;
    font-size: 0.7rem;
    color: var(--neutral-color);
    font-weight: normal;
}

.summary-table .rank-col {
    width: 40px;
    color: var(--neutral-color);
    font-weight: 600;
}

.summary-table .pts-col {
    width: 80px;
}

.summary-table .diff-col {
    width: 90px;
}

.summary-table .record-col {
    width: 110px;
    font-size: 0.8rem;
    color: #666;
}

.summary-note {
    font-size: 0.85rem;
    color: var(--neutral-color);
    text-align: center;
    font-style: italic;
    margin-top: 0.5rem;
}

.teams-section {
    margin-bottom: 2rem;
}

.teams-section h2 {
    color: var(--primary-color);
    margin-bottom: 1rem;
    text-align: center;
    font-size: 1.3rem;
}

.teams-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
    gap: 1.5rem;
    margin-bottom: 3rem;
}

.team-card {
    background: var(--card-background);
    padding: 1.5rem;
    border-radius: 8px;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
    text-decoration: none;
    color: inherit;
    transition: transform 0.2s, box-shadow 0.2s;
}

.team-card:hover {
    transform: translateY(-4px);
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.15);
}

.team-card h3 {
    color: var(--primary-color);
    margin-bottom: 0.5rem;
}

.comparison-info {
    color: var(--neutral-color);
    font-size: 0.9rem;
}

.info-section {
    background: var(--card-background);
    padding: 2rem;
    border-radius: 8px;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.info-section h2 {
    color: var(--primary-color);
    margin-bottom: 1rem;
}

.info-section ul {
    margin-left: 2rem;
    margin-top: 1rem;
}

.info-section li {
    margin-bottom: 0.5rem;
}

/* Footer */
footer {
    background-color: var(--primary-color);
    color: white;
    text-align: center;
    padding: 2rem 0;
    margin-top: 3rem;
}

footer a {
    color: var(--secondary-color);
    text-decoration: none;
}

footer a:hover {
    text-decoration: underline;
}

/* Additional Statistics Section */
.stats-section {
    margin-top: 2rem;
    padding-top: 2rem;
    border-top: 2px solid var(--border-color);
}

.stats-section h2 {
    font-size: 1.3rem;
    color: var(--primary-color);
    margin-bottom: 1rem;
    text-align: center;
}

.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 1rem;
    margin-top: 1rem;
}

.stat-card-large {
    background: var(--card-background);
    border-radius: 6px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
    padding: 1rem;
}

.stat-card-large h3 {
    font-size: 0.9rem;
    color: var(--primary-color);
    margin-bottom: 0.75rem;
    font-weight: 600;
    text-align: center;
}

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

.stats-table thead {
    background-color: #f8f9fa;
}

.stats-table th {
    padding: 0.5rem;
    text-align: left;
    font-weight: 600;
    font-size: 0.75rem;
    color: var(--primary-color);
    border-bottom: 2px solid var(--border-color);
}

.stats-table td {
    padding: 0.4rem 0.5rem;
    font-size: 0.75rem;
    border-bottom: 1px solid #f0f0f0;
}

.stats-table tbody tr:hover {
    background-color: #f8f9fa;
}

.stats-table td.positive {
    color: var(--success-color);
    font-weight: 600;
}

.stats-table td.negative {
    color: var(--danger-color);
    font-weight: 600;
}

/* Results Breakdown */
.breakdown-stats {
    display: flex;
    justify-content: space-around;
    gap: 1rem;
    padding: 1rem;
}

.breakdown-item {
    text-align: center;
    flex: 1;
    padding: 1rem;
    border-radius: 6px;
}

.breakdown-item.positive {
    background-color: #d4edda;
}

.breakdown-item.neutral {
    background-color: #fff3cd;
}

.breakdown-item.negative {
    background-color: #f8d7da;
}

.breakdown-number {
    font-size: 2rem;
    font-weight: bold;
    margin-bottom: 0.25rem;
}

.breakdown-item.positive .breakdown-number {
    color: var(--success-color);
}

.breakdown-item.neutral .breakdown-number {
    color: var(--warning-color);
}

.breakdown-item.negative .breakdown-number {
    color: var(--danger-color);
}

.breakdown-label {
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: #666;
}

/* Responsive Design */

/* Tablet and smaller laptops */
@media (max-width: 1024px) {
    .stats-grid {
        grid-template-columns: 1fr;
    }

    .sidebar {
        width: 160px;
    }

    .sidebar-section h3 {
        font-size: 0.75rem;
    }

    .stat-item .stat-value {
        font-size: 1rem;
    }

    .stat-item .stat-value-large {
        font-size: 1.4rem;
    }
}

/* Mobile devices */
@media (max-width: 768px) {
    .hero h1 {
        font-size: 2rem;
    }

    .hero p {
        font-size: 1rem;
    }

    .summary-section {
        padding: 1rem;
    }

    .summary-section h2 {
        font-size: 1.2rem;
    }

    .summary-table {
        min-width: 600px;
    }

    .summary-table th,
    .summary-table td {
        font-size: 0.75rem;
        padding: 0.5rem 0.4rem;
    }

    .summary-note {
        font-size: 0.75rem;
    }

    .teams-section h2 {
        font-size: 1.1rem;
    }

    .team-header h1 {
        font-size: 1.5rem;
    }

    .team-header h2 {
        font-size: 0.9rem;
    }

    /* Stack sidebar on top of content */
    .content-layout {
        flex-direction: column;
        gap: 1rem;
    }

    .sidebar {
        width: 100%;
        position: relative;
        top: 0;
    }

    .sidebar-section {
        padding: 0.5rem;
    }

    /* Horizontal layout for summary stats on mobile */
    .sidebar-section:first-child {
        display: grid;
        grid-template-columns: repeat(2, 1fr);
        gap: 0.5rem;
    }

    .sidebar-selector {
        grid-column: 1 / -1;
    }

    .stat-item {
        text-align: center;
        border-bottom: none;
        background: #f8f9fa;
        padding: 0.5rem;
        border-radius: 4px;
    }

    .stat-item .stat-label {
        font-size: 0.65rem;
    }

    .stat-item .stat-value {
        font-size: 1.1rem;
    }

    .stat-item .stat-value-large {
        font-size: 1.3rem;
    }

    /* Make table horizontally scrollable */
    .comparison-table {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }

    table {
        min-width: 600px;
    }

    th, td {
        padding: 0.3rem 0.4rem;
        font-size: 0.7rem;
    }

    .opponent-col {
        min-width: 100px;
        font-size: 0.75rem;
    }

    .score {
        font-size: 0.75rem;
        padding: 0.1rem 0.25rem;
    }

    .fixture-cell {
        min-width: 60px;
        padding: 0.2rem 0.3rem;
    }

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

    .teams-grid {
        grid-template-columns: 1fr;
    }

    .stats-grid {
        grid-template-columns: 1fr;
    }

    .stats-section h2 {
        font-size: 1.1rem;
    }

    .stat-card-large h3 {
        font-size: 0.85rem;
    }

    .stats-table th {
        font-size: 0.7rem;
        padding: 0.4rem;
    }

    .stats-table td {
        font-size: 0.7rem;
        padding: 0.35rem 0.4rem;
    }

    .breakdown-stats {
        flex-direction: column;
    }

    .breakdown-number {
        font-size: 1.5rem;
    }

    .breakdown-label {
        font-size: 0.7rem;
    }
}

/* Small mobile devices */
@media (max-width: 480px) {
    .container {
        padding: 0 10px;
    }

    .team-header h1 {
        font-size: 1.3rem;
    }

    .logo {
        font-size: 1.2rem;
    }

    .nav-links a {
        margin-left: 1rem;
        font-size: 0.9rem;
    }

    table {
        min-width: 500px;
    }

    .stats-grid {
        gap: 0.75rem;
    }

    .stat-card-large {
        padding: 0.75rem;
    }
}
