/*=============================================
  1. GLOBAL STYLES & CSS VARIABLES
=============================================*/
:root {
    --bg-color: #121212;
    --surface-color: #1e1e1e;
    --surface-color-hover: #2a2a2a;
    --primary-color: #00e676; /* A vibrant default green */
    --text-color: #e0e0e0;
    --text-color-secondary: #a0a0a0;
    --border-color: #333;
    --font-family: 'Inter', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
}

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

body {
    font-family: var(--font-family);
    background-color: var(--bg-color);
    color: var(--text-color);
    line-height: 1.5;
}

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

/*=============================================
  2. HEADER & NAVIGATION
=============================================*/
.site-header {
    background-color: var(--surface-color);
    border-bottom: 1px solid var(--border-color);
    padding: 15px 0;
    position: sticky;
    top: 0;
    z-index: 1000;
}

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

.site-brand {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--text-color);
    text-decoration: none;
}

.main-nav ul {
    list-style: none;
    display: flex;
    gap: 25px;
}

.main-nav a {
    color: var(--text-color-secondary);
    text-decoration: none;
    font-weight: 500;
    transition: color 0.2s ease;
}

.main-nav a:hover,
.main-nav a.active {
    color: var(--primary-color);
}

.mobile-nav-toggle {
    display: none;
    background: none;
    border: none;
    cursor: pointer;
    z-index: 1001;
}

.hamburger {
    display: block;
    width: 24px;
    height: 2px;
    background-color: var(--text-color);
    position: relative;
    transition: background-color 0.2s ease;
}

.hamburger::before,
.hamburger::after {
    content: '';
    position: absolute;
    width: 24px;
    height: 2px;
    background-color: var(--text-color);
    transition: transform 0.3s ease;
}

.hamburger::before { top: -8px; }
.hamburger::after { top: 8px; }


/*=============================================
  3. LEAGUE TABLE & DYNAMIC CONTENT
=============================================*/
/* This variable will be set by JS */
#league-container {
    --league-color: var(--primary-color);
}

/* Main content layout with sidebar */
.main-content-wrapper {
    display: grid;
    grid-template-columns: 1fr 300px;
    gap: 30px;
    max-width: 1200px;
    margin: 30px auto;
    padding: 0 20px;
}

@media (max-width: 1024px) {
    .main-content-wrapper {
        grid-template-columns: 1fr;
        gap: 20px;
    }
}

.enhanced-league-container {
    background: var(--surface-color);
    border-radius: 12px;
    overflow: hidden;
    border: 1px solid var(--border-color);
}

.enhanced-league-header {
    background: linear-gradient(135deg, var(--league-color) 0%, #111 150%);
    color: white;
    padding: 30px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 20px;
}
.enhanced-league-header h1 {
    font-size: 2.2rem;
    font-weight: 700;
    margin: 0;
}

.selector-wrapper {
    display: flex;
    gap: 15px;
}
.styled-select {
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 8px;
    padding: 10px 15px;
    font-size: 0.9rem;
    font-weight: 600;
    color: white;
    cursor: pointer;
    -webkit-appearance: none;
    appearance: none;
    background-image: url("data:image/svg+xml;charset=UTF-8,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='white' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3e%3cpolyline points='6 9 12 15 18 9'%3e%3c/polyline%3e%3c/svg%3e");
    background-repeat: no-repeat;
    background-position: right 12px center;
    background-size: 1em;
    padding-right: 2.5em;
}

.styled-select option {
    background-color: var(--surface-color);
    color: var(--text-color);
    padding: 10px;
    border: none;
}

.enhanced-tabs {
    display: flex;
    background: var(--bg-color);
    border-bottom: 1px solid var(--border-color);
    overflow-x: auto;
}
.enhanced-tab {
    padding: 15px 25px;
    cursor: pointer;
    border: none;
    background: none;
    font-size: 1rem;
    font-weight: 500;
    color: var(--text-color-secondary);
    white-space: nowrap;
    border-bottom: 3px solid transparent;
    transition: all 0.2s ease;
}
.enhanced-tab:hover { color: var(--text-color); }
.enhanced-tab.active {
    color: var(--league-color);
    border-bottom-color: var(--league-color);
}

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

.enhanced-table-wrapper {
    overflow-x: auto;
    padding: 10px 20px 20px;
}
.enhanced-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.95rem;
}
.enhanced-table th, .enhanced-table td {
    padding: 15px 10px;
    text-align: center;
    border-bottom: 1px solid var(--border-color);
}
.enhanced-table th {
    font-weight: 600;
    color: var(--text-color-secondary);
    text-align: center;
}
.enhanced-table tr:hover {
    background-color: var(--surface-color-hover);
}
.enhanced-table td:nth-child(2) {
    text-align: left;
}
.enhanced-team-cell {
    display: flex;
    align-items: center;
    gap: 12px;
}
.enhanced-team-logo {
    width: 24px;
    height: 24px;
    object-fit: contain;
    transition: opacity 0.2s ease;
}

.enhanced-team-logo[loading] {
    opacity: 0.5;
}
.enhanced-position-badge {
    width: 24px; height: 24px; border-radius: 50%; display: flex;
    align-items: center; justify-content: center; font-weight: bold;
    font-size: 0.8rem; color: white; margin: 0 auto;
}
/* Qualification Colors */
.enhanced-cl { background: #0066cc; }
.enhanced-el { background: #ff6600; }
.enhanced-ecl { background: #009900; }
.enhanced-playoff { background: #ffa500; }
.enhanced-rel { background: #cc0000; }
.enhanced-safe { background: #555; }


/*=============================================
  4. SKELETON LOADER
=============================================*/
.skeleton-loader {
    display: grid;
    grid-template-columns: 1fr 300px;
    gap: 30px;
    max-width: 1200px;
    margin: 30px auto;
    padding: 0 20px;
}

@media (max-width: 1024px) {
    .skeleton-loader {
        grid-template-columns: 1fr;
        gap: 20px;
    }
}
@keyframes pulse {
    0% { background-color: #2a2a2a; }
    50% { background-color: #3a3a3a; }
    100% { background-color: #2a2a2a; }
}
.skeleton-header {
    height: 120px;
    width: 100%;
    background-color: #2a2a2a;
    border-radius: 12px;
    animation: pulse 1.5s infinite ease-in-out;
}
.skeleton-tabs { display: flex; gap: 10px; margin-top: 10px; }
.skeleton-tab {
    height: 50px;
    width: 100px;
    background-color: #2a2a2a;
    border-radius: 8px;
    animation: pulse 1.5s infinite ease-in-out;
}
.skeleton-table { margin-top: 10px; }
.skeleton-row {
    height: 50px;
    width: 100%;
    background-color: #2a2a2a;
    border-radius: 8px;
    margin-bottom: 8px;
    animation: pulse 1.5s infinite ease-in-out;
}

.skeleton-sidebar-section {
    height: 200px;
    width: 100%;
    background-color: #2a2a2a;
    border-radius: 12px;
    animation: pulse 1.5s infinite ease-in-out;
}

.skeleton-sidebar-section:first-child {
    height: 300px;
}


/*=============================================
  5. FOOTER
=============================================*/
.site-footer-bottom {
    text-align: center;
    padding: 20px;
    margin-top: 40px;
    color: var(--text-color-secondary);
    font-size: 0.9rem;
    border-top: 1px solid var(--border-color);
}

.footer-links {
    margin-top: 10px;
    display: flex;
    justify-content: center;
    gap: 20px;
}

.footer-links a {
    color: var(--text-color-secondary);
    text-decoration: none;
    transition: color 0.2s ease;
    font-size: 0.85rem;
}

.footer-links a:hover {
    color: var(--primary-color);
    text-decoration: underline;
}

@media (max-width: 480px) {
    .footer-links {
        flex-direction: column;
        gap: 10px;
    }
}


/*=============================================
  6. SIDEBAR STYLES
=============================================*/
.league-sidebar {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.sidebar-section {
    background: var(--surface-color);
    border-radius: 12px;
    border: 1px solid var(--border-color);
    overflow: hidden;
}

.sidebar-title {
    background: linear-gradient(135deg, var(--league-color, var(--primary-color)) 0%, #111 150%);
    color: white;
    padding: 15px 20px;
    margin: 0;
    font-size: 1.1rem;
    font-weight: 600;
}

.top-scorers-list {
    padding: 0;
}

.scorer-item {
    display: flex;
    align-items: center;
    padding: 12px 20px;
    border-bottom: 1px solid var(--border-color);
    transition: background-color 0.2s ease;
}

.scorer-item:last-child {
    border-bottom: none;
}

.scorer-item:hover {
    background-color: var(--surface-color-hover);
}

.scorer-rank {
    width: 24px;
    height: 24px;
    border-radius: 50%;
    background: var(--league-color, var(--primary-color));
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: bold;
    font-size: 0.8rem;
    flex-shrink: 0;
}

.scorer-photo {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    overflow: hidden;
    margin-left: 12px;
    flex-shrink: 0;
}

.scorer-photo img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.scorer-info {
    flex-grow: 1;
    margin-left: 12px;
    min-width: 0;
}

.scorer-name {
    font-weight: 600;
    color: var(--text-color);
    font-size: 0.9rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.scorer-team {
    font-size: 0.8rem;
    color: var(--text-color-secondary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.scorer-goals {
    font-weight: bold;
    color: var(--league-color, var(--primary-color));
    font-size: 1.1rem;
    flex-shrink: 0;
}

.league-info {
    padding: 20px;
}

.info-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px 0;
    border-bottom: 1px solid var(--border-color);
}

.info-item:last-child {
    border-bottom: none;
}

.info-label {
    font-weight: 500;
    color: var(--text-color-secondary);
    font-size: 0.9rem;
}

.info-value {
    font-weight: 600;
    color: var(--text-color);
    font-size: 0.9rem;
}

/*=============================================
  7. TEAM PROFILE STYLES
=============================================*/
.team-link {
    color: var(--text-color);
    text-decoration: none;
    transition: color 0.2s ease;
}

.team-link:hover {
    color: var(--league-color, var(--primary-color));
}

.team-profile-container {
    background: var(--surface-color);
    border-radius: 12px;
    border: 1px solid var(--border-color);
    overflow: hidden;
}

.team-header {
    background: linear-gradient(135deg, var(--league-color, var(--primary-color)) 0%, #111 150%);
    color: white;
    padding: 30px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 20px;
}

.team-info {
    display: flex;
    align-items: center;
    gap: 20px;
}

.team-logo-large {
    width: 80px;
    height: 80px;
    object-fit: contain;
}

.team-header h1 {
    font-size: 2.2rem;
    font-weight: 700;
    margin: 0 0 8px 0;
}

.team-details {
    font-size: 1rem;
    opacity: 0.9;
    margin: 0;
}

.back-button {
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 8px;
    padding: 12px 20px;
    color: white;
    text-decoration: none;
    font-weight: 600;
    transition: background-color 0.2s ease;
}

.back-button:hover {
    background: rgba(255, 255, 255, 0.2);
}

.team-tabs {
    display: flex;
    background: var(--bg-color);
    border-bottom: 1px solid var(--border-color);
    overflow-x: auto;
}

.team-tab {
    padding: 15px 25px;
    cursor: pointer;
    border: none;
    background: none;
    font-size: 1rem;
    font-weight: 500;
    color: var(--text-color-secondary);
    white-space: nowrap;
    border-bottom: 3px solid transparent;
    transition: all 0.2s ease;
}

.team-tab:hover {
    color: var(--text-color);
}

.team-tab.active {
    color: var(--league-color, var(--primary-color));
    border-bottom-color: var(--league-color, var(--primary-color));
}

.team-tab-content {
    display: none;
    padding: 30px;
}

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

.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 20px;
}

.stat-card {
    background: var(--bg-color);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 20px;
}

.stat-card h3 {
    color: var(--league-color, var(--primary-color));
    margin: 0 0 15px 0;
    font-size: 1.1rem;
    font-weight: 600;
}

.stat-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px 0;
    border-bottom: 1px solid var(--border-color);
}

.stat-row:last-child {
    border-bottom: none;
}

.fixtures-section h3 {
    color: var(--text-color);
    margin: 0 0 20px 0;
    font-size: 1.3rem;
}

.fixtures-list {
    margin-bottom: 30px;
}

.fixture-item {
    display: grid;
    grid-template-columns: 1fr auto auto;
    align-items: center;
    gap: 20px;
    padding: 15px 20px;
    background: var(--bg-color);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    margin-bottom: 10px;
}

.fixture-teams {
    display: flex;
    align-items: center;
    gap: 10px;
    min-width: 0;
}

.home-team, .away-team {
    font-weight: 500;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.vs {
    color: var(--text-color-secondary);
    font-size: 0.9rem;
}

.fixture-score {
    font-weight: bold;
    color: var(--league-color, var(--primary-color));
    white-space: nowrap;
}

.fixture-date {
    color: var(--text-color-secondary);
    font-size: 0.9rem;
    white-space: nowrap;
}

.fixture-league {
    background: var(--league-color, var(--primary-color));
    color: white;
    font-size: 0.75rem;
    font-weight: 600;
    padding: 4px 8px;
    border-radius: 4px;
    text-transform: uppercase;
    white-space: nowrap;
    justify-self: center;
}

.squad-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
    gap: 15px;
}

.player-card {
    background: var(--bg-color);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 15px;
    transition: background-color 0.2s ease;
}

.player-card:hover {
    background-color: var(--surface-color-hover);
}

.player-name {
    font-weight: 600;
    color: var(--text-color);
    margin-bottom: 5px;
}

.player-details {
    color: var(--text-color-secondary);
    font-size: 0.9rem;
}

/*=============================================
  8. LEGAL PAGES STYLES
=============================================*/
.legal-content {
    max-width: 800px;
    margin: 30px auto;
    padding: 0 20px;
    line-height: 1.7;
}

.legal-content h1 {
    color: var(--primary-color);
    font-size: 2.5rem;
    font-weight: 700;
    margin-bottom: 10px;
}

.legal-content .last-updated {
    color: var(--text-color-secondary);
    font-style: italic;
    margin-bottom: 40px;
    padding-bottom: 20px;
    border-bottom: 1px solid var(--border-color);
}

.legal-content section {
    margin-bottom: 40px;
}

.legal-content h2 {
    color: var(--primary-color);
    font-size: 1.5rem;
    font-weight: 600;
    margin-bottom: 15px;
    margin-top: 30px;
}

.legal-content h3 {
    color: var(--text-color);
    font-size: 1.2rem;
    font-weight: 600;
    margin-bottom: 10px;
    margin-top: 20px;
}

.legal-content p {
    margin-bottom: 15px;
    color: var(--text-color);
}

.legal-content ul {
    margin-bottom: 15px;
    padding-left: 25px;
}

.legal-content li {
    margin-bottom: 8px;
    color: var(--text-color);
}

.legal-content a {
    color: var(--primary-color);
    text-decoration: underline;
    transition: color 0.2s ease;
}

.legal-content a:hover {
    color: var(--text-color);
}

.legal-content strong {
    color: var(--primary-color);
    font-weight: 600;
}

/*=============================================
  9. RESPONSIVE & MOBILE STYLES
=============================================*/
@media (max-width: 768px) {
    .main-nav {
        display: none;
        position: fixed;
        top: 0;
        right: 0;
        width: 100%;
        height: 100vh;
        background-color: rgba(0, 0, 0, 0.9);
        flex-direction: column;
        justify-content: center;
        align-items: center;
    }

    body.nav-open .main-nav {
        display: flex;
    }

    .main-nav ul {
        flex-direction: column;
        text-align: center;
        gap: 20px;
    }
    
    .main-nav a { font-size: 1.5rem; }

    .mobile-nav-toggle { display: block; }
    
    body.nav-open .hamburger { background-color: transparent; }
    body.nav-open .hamburger::before { transform: rotate(45deg); top: 0; }
    body.nav-open .hamburger::after { transform: rotate(-45deg); top: 0; }
    
    .enhanced-league-header {
        flex-direction: column;
        align-items: flex-start;
        padding: 20px;
    }
    .enhanced-league-header h1 { font-size: 1.8rem; }
    .selector-wrapper { width: 100%; }
    .styled-select { flex-grow: 1; }

    /* Sidebar mobile adjustments */
    .league-sidebar {
        margin-top: 20px; /* Add space between main content and sidebar */
    }

    .main-content-wrapper {
        padding: 0 10px;
    }

    .scorer-name, .scorer-team {
        font-size: 0.8rem;
    }

    .scorer-goals {
        font-size: 1rem;
    }

    /* Team profile mobile adjustments */
    .team-header {
        flex-direction: column;
        align-items: flex-start;
        text-align: left;
    }

    .team-info {
        width: 100%;
    }

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

    .team-logo-large {
        width: 60px;
        height: 60px;
    }

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

    .fixture-item {
        display: flex;
        flex-direction: column;
        gap: 8px;
        text-align: center;
        padding: 12px 15px;
    }

    .fixture-teams {
        justify-content: center;
    }

    .fixture-league {
        order: -1; /* Show league name first on mobile */
        font-size: 0.8rem;
        margin-bottom: 5px;
    }

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