/* Reset & Base Styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: 'Outfit', sans-serif;
}

body {
    background-color: #0d1117;
    color: #e6edf3;
    overflow-x: hidden;
    scrollbar-width: thin;
    scrollbar-color: #30363d #0d1117;
}

/* Custom Scrollbar */
::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

::-webkit-scrollbar-track {
    background: #0d1117;
}

::-webkit-scrollbar-thumb {
    background: #30363d;
    border-radius: 10px;
}

::-webkit-scrollbar-thumb:hover {
    background: #484f58;
}

/* Layout */
/* Icons */
.lucide {
    width: 20px;
    height: 20px;
    vertical-align: middle;
    margin-right: 8px;
    stroke-width: 2px;
}
.metric-icon .lucide {
    width: 32px;
    height: 32px;
    margin-right: 0;
    color: #58a6ff;
}
.tab-btn .lucide {
    width: 16px;
    height: 16px;
    margin-right: 6px;
    opacity: 0.7;
}
.tab-btn.active .lucide {
    opacity: 1;
}

.app-container {
    display: flex;
    min-height: 100vh;
    background: radial-gradient(circle at top right, #1a202c, #0d1117);
}

.mobile-header {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    height: 60px;
    background: rgba(22, 27, 34, 0.8);
    backdrop-filter: blur(12px);
    border-bottom: 1px solid #30363d;
    z-index: 1000;
    align-items: center;
    padding: 0 20px;
    justify-content: space-between;
}

#sidebar-toggle {
    background: none;
    border: none;
    color: #e6edf3;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 8px;
    border-radius: 8px;
    transition: background 0.2s;
}

#sidebar-toggle:hover {
    background: rgba(255, 255, 255, 0.1);
}

.mobile-logo {
    font-weight: 700;
    color: #f85149;
    font-size: 1.2rem;
}

.sidebar {
    width: 300px;
    background-color: #161b22;
    border-right: 1px solid #30363d;
    padding: 20px;
    display: flex;
    flex-direction: column;
    position: fixed;
    height: 100vh;
    overflow-y: auto;
    z-index: 1100;
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.sidebar-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 25px;
}

.logo-container {
    display: flex;
    align-items: center;
    gap: 12px;
}

.tournament-logo {
    height: 42px;
    width: auto;
    filter: drop-shadow(0 0 8px rgba(248, 81, 73, 0.4));
    transition: transform 0.3s ease;
}

.tournament-logo:hover {
    transform: scale(1.05) rotate(5deg);
}

.sidebar-header h1 {
    margin-bottom: 0;
    font-size: 1.1rem;
    line-height: 1.2;
    letter-spacing: -0.5px;
}

#sidebar-close {
    background: none;
    border: none;
    color: #8b949e;
    cursor: pointer;
    padding: 8px;
}

.main-content {
    flex: 1;
    margin-left: 300px;
    padding: 40px;
    max-width: 1600px;
    margin-right: auto;
}

.mobile-only {
    display: none;
}

/* Typography & Elements */
h1 {
    color: #f85149;
    font-weight: 700;
    letter-spacing: -1px;
    font-size: 1.8rem;
    margin-bottom: 30px;
}

h2 {
    color: #f0f6fc;
    font-size: 2rem;
    margin-bottom: 20px;
}

h3 {
    color: #f0f6fc;
    border-bottom: 2px solid #30363d;
    padding-bottom: 10px;
    margin-top: 30px;
    margin-bottom: 20px;
}

h4 {
    color: #c9d1d9;
    margin-bottom: 15px;
    text-align: center;
}

#welcome-message {
    background: linear-gradient(135deg, rgba(63, 185, 80, 0.15), rgba(88, 166, 255, 0.1));
    border: 1px solid rgba(63, 185, 80, 0.3);
    border-radius: 12px;
    padding: 20px;
    margin-bottom: 25px;
    display: flex;
    align-items: center;
    gap: 15px;
    animation: slideDown 0.5s ease-out;
}

@keyframes slideDown {
    from { transform: translateY(-20px); opacity: 0; }
    to { transform: translateY(0); opacity: 1; }
}

.welcome-icon { 
    display: flex;
    align-items: center;
    justify-content: center;
}
.welcome-icon i {
    width: 36px;
    height: 36px;
    color: #3fb950;
    filter: drop-shadow(0 0 5px rgba(63, 185, 80, 0.4));
}
.welcome-text h3 { margin: 0; border: none; padding: 0; color: #3fb950; }
.welcome-text p { margin: 5px 0 0; color: #8b949e; font-size: 0.9rem; }

/* Sidebar Controls */
.filter-group {
    margin-bottom: 20px;
}

.filter-group label {
    display: flex;
    align-items: center;
    gap: 8px;
    color: #f0f6fc;
    font-weight: 600;
    margin-bottom: 10px;
    font-size: 0.85rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.filter-group label i {
    width: 16px;
    height: 16px;
    color: #f85149;
}

select {
    width: 100%;
    padding: 10px;
    background-color: #0d1117;
    color: #e6edf3;
    border: 1px solid #30363d;
    border-radius: 6px;
    outline: none;
    cursor: pointer;
}

select:focus {
    border-color: #f85149;
}

.checkbox-group {
    max-height: 150px;
    overflow-y: auto;
    background-color: #0d1117;
    border: 1px solid #30363d;
    border-radius: 6px;
    padding: 10px;
}

.checkbox-group label {
    display: flex;
    align-items: center;
    font-weight: 400;
    font-size: 0.85rem;
    color: #c9d1d9;
    cursor: pointer;
    margin-bottom: 5px;
}

.checkbox-group input {
    margin-right: 8px;
    accent-color: #f85149;
}

.sidebar-footer p {
    margin-bottom: 8px;
}

.contact-link {
    color: inherit;
    text-decoration: none;
    transition: color 0.2s;
    display: inline-flex;
    align-items: center;
    gap: 5px;
}

.contact-link:hover {
    color: #f85149;
}

.sidebar-footer {
    margin-top: auto;
    font-size: 0.8rem;
    color: #8b949e;
    padding: 20px 0;
    border-top: 1px solid #30363d;
}

/* Loading Overlay */
#loading-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: #0d1117;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    z-index: 2000;
    transition: opacity 0.5s, visibility 0.5s;
}

.loader {
    width: 48px;
    height: 48px;
    border: 5px solid #f85149;
    border-bottom-color: transparent;
    border-radius: 50%;
    display: inline-block;
    box-sizing: border-box;
    animation: rotation 1s linear infinite;
}

@keyframes rotation {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

.loading-text {
    margin-top: 20px;
    font-weight: 600;
    color: #f0f6fc;
    letter-spacing: 2px;
}

/* Main Content: Metrics */
.metrics-container {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 16px;
    margin-bottom: 25px;
    max-width: 1200px;
}

/* On very small screens, 3 columns might be tight, but let's follow the user's "2 lines" request */
@media (max-width: 768px) {
    .metrics-container {
        grid-template-columns: repeat(2, 1fr); /* Back to 2 columns if too tight, but user asked for 2 lines */
    }
}

.metric-card {
    background: rgba(22, 27, 34, 0.6);
    backdrop-filter: blur(8px);
    border: 1px solid #30363d;
    border-radius: 16px;
    padding: 24px;
    box-shadow: 0 8px 32px rgba(0,0,0,0.4);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    position: relative;
    overflow: hidden;
}

.metric-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 4px;
    background: linear-gradient(90deg, #f85149, #d23a33);
    opacity: 0.8;
}

.metric-card:hover {
    transform: translateY(-5px);
    box-shadow: 0 12px 40px rgba(248, 81, 73, 0.15);
    border-color: #f85149;
}

.metric-label {
    font-size: 0.9rem;
    color: #8b949e;
    text-transform: uppercase;
    font-weight: 600;
    margin-bottom: 5px;
}

.metric-value {
    font-size: 2.2rem;
    font-weight: 700;
    color: #f85149;
}

/* Tabs */
.tab-list {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    gap: 8px;
    background-color: #161b22;
    padding: 8px;
    border-radius: 12px;
    margin-bottom: 25px;
    border: 1px solid #30363d;
    max-width: 1200px;
}

@media (max-width: 1024px) {
    .tab-list {
        grid-template-columns: repeat(3, 1fr); /* 3 rows for 9 items */
    }
}

@media (max-width: 600px) {
    .tab-list {
        grid-template-columns: repeat(2, 1fr);
    }
}
.tab-list::-webkit-scrollbar { display: none; }

.tab-btn {
    white-space: nowrap;
    height: 44px;
    color: #8b949e;
    background-color: transparent;
    border: none;
    font-weight: 600;
    font-size: 0.72rem;
    letter-spacing: 0.3px;
    cursor: pointer;
    border-radius: 10px;
    transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0 4px;
    text-transform: uppercase;
}

/* Make the last tab (9th) span 2 columns if needed, or keep it balanced */
.tab-btn:last-child {
    grid-column: span 2;
}

.tab-btn:hover {
    color: #ffffff;
    background-color: rgba(255, 255, 255, 0.08);
}

.tab-btn.active {
    color: #ffffff;
    background: linear-gradient(135deg, #f85149 0%, #d23a33 100%);
    box-shadow: 0 4px 15px rgba(248, 81, 73, 0.4);
    border: 1px solid rgba(255, 255, 255, 0.2);
    transform: translateY(-1px);
}

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

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

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(5px); }
    to { opacity: 1; transform: translateY(0); }
}

/* Charts Grid */
.charts-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
    max-width: 1200px;
}

.chart-box {
    background: rgba(22, 27, 34, 0.5);
    backdrop-filter: blur(10px);
    border: 1px solid #30363d;
    border-radius: 16px;
    padding: 24px;
    box-shadow: 0 10px 30px rgba(0,0,0,0.3);
    transition: border-color 0.3s;
    min-height: 350px;
    display: flex;
    flex-direction: column;
}

.chart-box:hover {
    border-color: #484f58;
}

.row-filter {
    display: flex;
    align-items: center;
    gap: 15px;
    margin-bottom: 20px;
}

.row-filter label {
    margin-bottom: 0;
    white-space: nowrap;
}

.row-filter select {
    width: 200px;
}

/* Pitch Containers */
.pitch-container {
    width: 100%;
    max-width: 600px;
    margin: 0 auto;
    aspect-ratio: 80 / 120; /* Vertical Pitch ratio */
    background-color: #161b22;
    border: 2px solid #30363d;
    position: relative;
    border-radius: 5px;
}

.pitch-container.horizontal {
    max-width: 100%;
    width: 100%;
    aspect-ratio: 120 / 80;
    border: 1px solid #21262d;
    border-radius: 6px;
    overflow: hidden;
    background: #0d1f14;
}


/* Network — subtitle & sublabel only (cards/bars defined below) */
.network-subtitle {
    color: #8b949e;
    text-align: center;
    margin-bottom: 20px;
    font-size: 0.9rem;
}

.net-label {
    display: block;
    color: #8b949e;
    font-size: 0.8rem;
    text-transform: uppercase;
    margin-bottom: 8px;
}

.net-value {
    display: block;
    color: #f85149;
    font-weight: 700;
    font-size: 1.2rem;
}

.net-sublabel {
    display: block;
    color: #8b949e;
    font-size: 0.75rem;
    margin-top: 4px;
}

/* Simple Responsive */
@media (max-width: 1200px) {
    .sidebar { width: 280px; }
    .main-content { margin-left: 280px; padding: 30px; }
}

@media (max-width: 1024px) {
    .charts-grid { grid-template-columns: 1fr; }
    .network-stats { flex-direction: column; }
    /* We already set metrics and tabs to 2 columns globally, so we keep them here */
}

@media (max-width: 850px) {
    .mobile-header { display: flex; }
    .sidebar {
        transform: translateX(-100%);
        box-shadow: 20px 0 50px rgba(0,0,0,0.8);
    }
    .sidebar.active {
        transform: translateX(0);
    }
    .main-content {
        margin-left: 0;
        padding: 80px 20px 40px;
    }
    .mobile-only {
        display: flex;
    }
}

@media (max-width: 600px) {
    .metric-value { font-size: 1.8rem; }
    .metric-card { padding: 16px; }
    .h2 { font-size: 1.5rem; }
    .tab-btn { font-size: 0.6rem; padding: 0 4px; }
}

/* Metric card icons */
.metric-icon { font-size: 1.4rem; margin-bottom: 4px; }

/* Chart descriptions */
.chart-desc {
    color: #8b949e;
    font-size: 0.8rem;
    text-align: center;
    margin-bottom: 12px;
    line-height: 1.4;
}
.section-desc {
    color: #8b949e;
    font-size: 0.85rem;
    text-align: center;
    margin-bottom: 20px;
    max-width: 800px;
    margin-left: auto;
    margin-right: auto;
}

/* Network sublabel */
.net-sublabel {
    display: block;
    color: #8b949e;
    font-size: 0.75rem;
    margin-top: 4px;
}

/* Results KPIs row */
.results-kpis {
    display: flex;
    justify-content: center;
    gap: 16px;
    flex-wrap: wrap;
    margin-bottom: 10px;
}
.res-kpi {
    background: #161b22;
    border: 1px solid #30363d;
    border-radius: 10px;
    padding: 16px 24px;
    text-align: center;
    min-width: 100px;
}
.res-kpi-val {
    display: block;
    font-size: 2rem;
    font-weight: 700;
    color: #f0f6fc;
    line-height: 1;
}
.res-kpi-label {
    display: block;
    color: #8b949e;
    font-size: 0.78rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-top: 6px;
}

/* Results table */
.results-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.9rem;
}
.results-table th {
    background: #21262d;
    color: #8b949e;
    padding: 10px 14px;
    text-align: left;
    font-weight: 600;
    font-size: 0.8rem;
    text-transform: uppercase;
    border-bottom: 1px solid #30363d;
}
.results-table td {
    padding: 10px 14px;
    border-bottom: 1px solid #21262d;
    color: #c9d1d9;
}
.results-table tr:hover td { background: #161b22; }
.results-table tr.top3-row td { background: rgba(248,81,73,0.06); }

/* Table Containers for scroll */
#leaderboard-table, #match-results-table, #net-connections-table, #connections-table-container {
    width: 100%;
    overflow-x: auto;
    background: #161b22;
    border-radius: 12px;
    border: 1px solid #30363d;
    margin-top: 20px;
}
#leaderboard-table .results-table, 
#match-results-table .results-table, 
#net-connections-table .results-table {
    border: none;
}

.result-badge {
    display: inline-block;
    padding: 3px 10px;
    border-radius: 20px;
    font-weight: 700;
    font-size: 0.85rem;
    color: #fff;
}

/* Sidebar summary */
.sidebar-summary {
    background: #21262d;
    border: 1px solid #30363d;
    border-radius: 8px;
    padding: 14px;
    margin-bottom: 16px;
}
.summary-title {
    font-weight: 700;
    color: #f85149;
    font-size: 0.85rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 10px;
}
.summary-stats { display: flex; flex-direction: column; gap: 6px; }
.sum-stat { font-size: 0.85rem; color: #c9d1d9; }

/* Player KPI Cards */
.player-kpis {
    display: flex;
    justify-content: center;
    gap: 16px;
    flex-wrap: wrap;
    margin-bottom: 25px;
}
.p-kpi {
    background: #161b22;
    border: 1px solid #30363d;
    border-radius: 10px;
    padding: 18px 20px;
    text-align: center;
    min-width: 140px;
    flex: 1;
}
.p-kpi-val {
    display: block;
    font-size: 1.8rem;
    font-weight: 700;
    color: #f0f6fc;
    line-height: 1.1;
}
.p-kpi-label {
    display: block;
    color: #8b949e;
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-top: 8px;
}

/* ── Network Enrichments ─────────────────────────────── */

/* Third KPI card */
.network-stats {
    display: flex;
    justify-content: center;
    gap: 16px;
    flex-wrap: wrap;
    margin-bottom: 20px;
}
.net-stat-card {
    background: #161b22;
    border: 1px solid #30363d;
    border-radius: 10px;
    padding: 16px 20px;
    text-align: center;
    min-width: 180px;
    flex: 1;
    max-width: 260px;
}

/* Direction & Side stats */
.net-direction-row {
    display: flex;
    gap: 20px;
    flex-wrap: wrap;
    margin-bottom: 6px;
}
.net-dir-block {
    flex: 1;
    min-width: 240px;
    background: #161b22;
    border: 1px solid #30363d;
    border-radius: 8px;
    padding: 14px 16px;
}
.net-dir-title {
    display: block;
    font-weight: 700;
    font-size: 0.85rem;
    color: #8b949e;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 12px;
}

/* Stat bar rows */
.stat-bar-row {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 9px;
}
.stat-bar-label {
    font-size: 0.82rem;
    color: #c9d1d9;
    min-width: 90px;
}
.stat-bar-track {
    flex: 1;
    height: 7px;
    background: #21262d;
    border-radius: 20px;
    overflow: hidden;
}
.stat-bar-fill {
    height: 100%;
    border-radius: 20px;
    transition: width 0.4s ease;
}
.stat-bar-pct {
    font-weight: 700;
    font-size: 0.85rem;
    min-width: 36px;
    text-align: right;
}
.stat-bar-count {
    font-size: 0.78rem;
    color: #8b949e;
    min-width: 36px;
}

/* Network legend */
.net-legend {
    display: flex;
    align-items: center;
    gap: 18px;
    flex-wrap: wrap;
    margin: 12px 0 10px;
    padding: 10px 16px;
    background: #161b22;
    border: 1px solid #30363d;
    border-radius: 8px;
    font-size: 0.82rem;
    color: #c9d1d9;
}
.net-legend-item {
    display: flex;
    align-items: center;
    gap: 6px;
}
.dot {
    display: inline-block;
    border-radius: 50%;
}
.dot.big  { width: 14px; height: 14px; }
.dot.small { width: 8px; height: 8px; }
.link-thick {
    display: inline-block;
    width: 30px;
    height: 4px;
    background: #f8d03a;
    border-radius: 2px;
}
.link-thin {
    display: inline-block;
    width: 30px;
    height: 1.5px;
    background: #58a6ff;
    border-radius: 2px;
}

/* Responsive */
@media (max-width: 1200px) {
    .sidebar {
        width: 260px;
    }
    .main-content {
        margin-left: 260px;
    }
}

@media (max-width: 992px) {
    .charts-grid {
        grid-template-columns: 1fr;
    }
    .metrics-container {
        grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    }
}

@media (max-width: 768px) {
    .app-container {
        flex-direction: column;
    }
    .sidebar {
        position: relative;
        width: 100%;
        height: auto;
        border-right: none;
        border-bottom: 1px solid #30363d;
    }
    .main-content {
        margin-left: 0;
        padding: 20px;
    }
    .tab-list {
        padding: 4px;
    }
    .tab-btn {
        font-size: 0.65rem;
        padding: 0 5px;
    }
}


