/* CSS Variables - Premium Dark Theme */
:root {
    --bg-primary: #0a0d14;
    --bg-secondary: rgba(18, 24, 38, 0.85);
    --bg-card: rgba(22, 30, 49, 0.75);
    --bg-hover: rgba(30, 41, 67, 0.9);
    --border-color: rgba(255, 255, 255, 0.07);
    --border-glow: rgba(16, 185, 129, 0.2);
    
    --text-main: #f8fafc;
    --text-sub: #cbd5e1;
    --text-muted: #64748b;
    
    --primary: #10b981; /* Emerald Field Green */
    --primary-hover: #059669;
    --primary-glow: rgba(16, 185, 129, 0.15);
    
    --gold: #fbbf24;
    --silver: #cbd5e1;
    --bronze: #f59e0b;
    --danger: #ef4444;
    --blue: #3b82f6;
    
    --glass-shadow: 0 8px 32px 0 rgba(0, 0, 0, 0.4);
    --transition-fast: all 0.15s ease;
    --transition-smooth: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

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

body {
    background-color: var(--bg-primary);
    color: var(--text-main);
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    min-height: 100vh;
    overflow-x: hidden;
    background-image: 
        radial-gradient(circle at 10% 20%, rgba(16, 185, 129, 0.03) 0%, transparent 40%),
        radial-gradient(circle at 90% 80%, rgba(59, 130, 246, 0.03) 0%, transparent 45%);
    background-attachment: fixed;
}

/* App Container Layout */
.app-container {
    display: flex;
    flex-direction: column;
    min-height: 100vh;
    max-width: 1600px;
    margin: 0 auto;
    padding: 0 20px;
}

/* App Header styling */
.app-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px 0;
    border-bottom: 1px solid var(--border-color);
    margin-bottom: 30px;
}

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

.logo-icon {
    font-size: 24px;
    color: var(--primary);
    background: var(--primary-glow);
    width: 48px;
    height: 48px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 12px;
    border: 1px solid rgba(16, 185, 129, 0.25);
    box-shadow: 0 0 15px var(--primary-glow);
}

.logo-text h1 {
    font-family: 'Outfit', sans-serif;
    font-weight: 800;
    font-size: 20px;
    letter-spacing: 1.5px;
    color: var(--text-main);
    line-height: 1.2;
}

.logo-text span {
    font-size: 11px;
    color: var(--text-muted);
    font-weight: 600;
    letter-spacing: 0.5px;
}

/* Tab Navigation Buttons */
.tab-navigation {
    display: flex;
    background: var(--bg-secondary);
    padding: 4px;
    border-radius: 12px;
    border: 1px solid var(--border-color);
    gap: 4px;
}

.nav-btn {
    border: none;
    background: transparent;
    color: var(--text-muted);
    padding: 10px 18px;
    font-size: 13px;
    font-weight: 600;
    border-radius: 8px;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 8px;
    transition: var(--transition-fast);
}

.nav-btn:hover {
    color: var(--text-main);
}

.nav-btn.active {
    background: var(--primary);
    color: #ffffff;
    box-shadow: 0 4px 12px rgba(16, 185, 129, 0.3);
}

/* Sync block */
.sync-section {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 6px;
}

.btn {
    border: none;
    padding: 10px 20px;
    font-size: 13px;
    font-weight: 700;
    border-radius: 10px;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 8px;
    transition: var(--transition-fast);
}

.btn-primary {
    background: var(--bg-secondary);
    color: var(--text-main);
    border: 1px solid var(--border-color);
}

.btn-primary:hover {
    background: var(--primary);
    color: white;
    border-color: var(--primary);
    box-shadow: 0 0 15px rgba(16, 185, 129, 0.25);
}

.last-update {
    font-size: 10px;
    color: var(--text-muted);
    font-weight: 500;
}

.last-update span {
    color: var(--text-sub);
    font-weight: 600;
}

/* Stats Widgets Row */
.stats-row {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 20px;
    margin-bottom: 30px;
}

.stat-card {
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    padding: 20px;
    border-radius: 16px;
    display: flex;
    align-items: center;
    gap: 16px;
    transition: var(--transition-smooth);
}

.stat-card:hover {
    transform: translateY(-4px);
    border-color: rgba(16, 185, 129, 0.3);
    box-shadow: 0 10px 20px rgba(0, 0, 0, 0.2), 0 0 10px rgba(16, 185, 129, 0.05);
}

.stat-icon {
    font-size: 20px;
    color: var(--primary);
    background: var(--primary-glow);
    width: 44px;
    height: 44px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.stat-info h3 {
    font-size: 11px;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.8px;
    margin-bottom: 2px;
}

.stat-info p {
    font-family: 'Outfit', sans-serif;
    font-size: 24px;
    font-weight: 700;
    color: var(--text-main);
}

/* Tab Content Visibility */
.tab-content {
    display: none;
    animation: fadeIn 0.35s ease-out;
}

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

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

/* Premium Standings Layout Grid */
.standings-layout {
    display: grid;
    grid-template-columns: 2.3fr 1fr;
    gap: 24px;
    align-items: start;
}

/* Card General Style */
.card {
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: 20px;
    padding: 24px;
    box-shadow: var(--glass-shadow);
    backdrop-filter: blur(10px);
}

.card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    gap: 16px;
    flex-wrap: wrap;
}

.card-header h2 {
    font-family: 'Outfit', sans-serif;
    font-weight: 700;
    font-size: 18px;
    letter-spacing: 0.5px;
    display: flex;
    align-items: center;
    gap: 10px;
}

/* Search bar styling */
.search-box {
    display: flex;
    align-items: center;
    background: var(--bg-primary);
    border: 1px solid var(--border-color);
    border-radius: 10px;
    padding: 8px 14px;
    gap: 10px;
    width: 280px;
    transition: var(--transition-fast);
}

.search-box:focus-within {
    border-color: var(--primary);
    box-shadow: 0 0 8px rgba(16, 185, 129, 0.2);
}

.search-box i {
    color: var(--text-muted);
    font-size: 12px;
}

.search-box input {
    background: transparent;
    border: none;
    color: var(--text-main);
    outline: none;
    font-size: 12px;
    width: 100%;
}

.search-box input::placeholder {
    color: var(--text-muted);
}

/* Leaderboard Table Styling */
.table-container {
    overflow-x: auto;
    border-radius: 12px;
}

table {
    width: 100%;
    border-collapse: collapse;
    text-align: left;
    font-size: 13px;
}

th {
    background: rgba(22, 30, 49, 0.4);
    color: var(--text-muted);
    font-weight: 600;
    padding: 14px 16px;
    text-transform: uppercase;
    font-size: 10px;
    letter-spacing: 0.8px;
    border-bottom: 1px solid var(--border-color);
}

td {
    padding: 14px 16px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.03);
    color: var(--text-sub);
    vertical-align: middle;
}

tbody tr {
    cursor: pointer;
    transition: var(--transition-fast);
}

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

/* Table columns customization */
.col-rank {
    width: 60px;
    text-align: center;
    font-weight: 700;
}

.col-name {
    font-weight: 600;
    color: var(--text-main);
    font-size: 13px;
}

.col-sector {
    color: var(--text-muted);
}

.col-pts {
    font-weight: 700;
    color: var(--primary);
    font-size: 14px;
    text-align: center;
}

.col-stat {
    text-align: center;
    color: var(--text-sub);
}

.col-auto {
    text-align: center;
    color: var(--text-muted);
}

/* Ranks Styles (Medals) */
.rank-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 24px;
    height: 24px;
    border-radius: 50%;
    font-weight: 700;
    font-size: 12px;
}

tr:nth-child(1) .rank-badge {
    background: rgba(251, 191, 36, 0.15);
    color: var(--gold);
    border: 1px solid rgba(251, 191, 36, 0.35);
}

tr:nth-child(2) .rank-badge {
    background: rgba(203, 213, 225, 0.15);
    color: var(--silver);
    border: 1px solid rgba(203, 213, 225, 0.35);
}

tr:nth-child(3) .rank-badge {
    background: rgba(245, 158, 11, 0.15);
    color: var(--bronze);
    border: 1px solid rgba(245, 158, 11, 0.35);
}

/* Highlight Top rows */
tr:nth-child(1) { background: rgba(251, 191, 36, 0.015); }
tr:nth-child(2) { background: rgba(203, 213, 225, 0.01); }
tr:nth-child(3) { background: rgba(245, 158, 11, 0.008); }

/* Loading and empty placeholders */
.loading-cell {
    text-align: center;
    padding: 40px;
    font-size: 14px;
    color: var(--text-muted);
}

.loading-cell i {
    margin-right: 8px;
}

/* Sector List styling */
.sector-description {
    font-size: 11px;
    color: var(--text-muted);
    line-height: 1.4;
    margin-bottom: 20px;
}

.sector-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.sector-row {
    background: rgba(22, 30, 49, 0.4);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    padding: 14px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    transition: var(--transition-fast);
}

.sector-row:hover {
    border-color: rgba(255, 255, 255, 0.15);
}

.sector-row.leader {
    border-color: rgba(251, 191, 36, 0.25);
    background: rgba(251, 191, 36, 0.02);
}

.sector-info {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.sector-name {
    font-size: 12px;
    font-weight: 600;
    color: var(--text-main);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.sector-count {
    font-size: 10px;
    color: var(--text-muted);
}

.sector-points {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 2px;
}

.sector-avg {
    font-family: 'Outfit', sans-serif;
    font-size: 16px;
    font-weight: 700;
    color: var(--primary);
}

.sector-row.leader .sector-avg {
    color: var(--gold);
}

.sector-rank-label {
    font-size: 9px;
    color: var(--text-muted);
    font-weight: 600;
    text-transform: uppercase;
}

.sector-row.ineligible {
    opacity: 0.5;
}

.sector-row.ineligible .sector-avg {
    color: var(--text-muted);
}

/* Matches Grid tab styling */
.filter-group {
    display: flex;
    background: var(--bg-primary);
    padding: 3px;
    border-radius: 8px;
    border: 1px solid var(--border-color);
    gap: 2px;
}

.filter-btn {
    border: none;
    background: transparent;
    color: var(--text-muted);
    padding: 6px 14px;
    font-size: 11px;
    font-weight: 600;
    border-radius: 6px;
    cursor: pointer;
    transition: var(--transition-fast);
}

.filter-btn:hover {
    color: var(--text-main);
}

.filter-btn.active {
    background: var(--primary);
    color: white;
}

.matches-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
    gap: 16px;
    margin-top: 10px;
}

.match-card {
    background: rgba(22, 30, 49, 0.4);
    border: 1px solid var(--border-color);
    border-radius: 16px;
    padding: 16px;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    min-height: 140px;
    transition: var(--transition-smooth);
}

.match-card:hover {
    border-color: rgba(255, 255, 255, 0.15);
    transform: translateY(-2px);
}

.match-card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 10px;
    color: var(--text-muted);
    font-weight: 600;
    border-bottom: 1px solid rgba(255, 255, 255, 0.03);
    padding-bottom: 8px;
    margin-bottom: 12px;
}

.match-card-header .m-group {
    background: rgba(255, 255, 255, 0.05);
    padding: 2px 6px;
    border-radius: 4px;
    color: var(--text-sub);
}

.match-card-body {
    display: flex;
    flex-direction: column;
    gap: 10px;
    flex-grow: 1;
    justify-content: center;
}

.team-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

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

.flag-emoji {
    font-size: 16px;
    width: 24px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.team-name-label {
    font-size: 13px;
    font-weight: 500;
    color: var(--text-sub);
}

.match-card.finished .team-name-label {
    color: var(--text-main);
}

.score-box-label {
    font-family: 'Outfit', sans-serif;
    font-size: 15px;
    font-weight: 700;
    width: 24px;
    text-align: center;
}

.score-box-label.empty {
    color: var(--text-muted);
    font-weight: 400;
}

.match-card-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 12px;
    padding-top: 8px;
    border-top: 1px solid rgba(255, 255, 255, 0.03);
    font-size: 10px;
    color: var(--text-muted);
}

.m-status-badge {
    background: rgba(255, 255, 255, 0.05);
    padding: 2px 6px;
    border-radius: 4px;
    font-weight: 600;
}

.m-status-badge.live {
    background: rgba(239, 68, 68, 0.15);
    color: var(--danger);
    border: 1px solid rgba(239, 68, 68, 0.25);
    animation: pulse 1.5s infinite;
}

@keyframes pulse {
    0% { opacity: 0.6; }
    50% { opacity: 1; }
    100% { opacity: 0.6; }
}

.m-status-badge.finished {
    background: rgba(16, 185, 129, 0.1);
    color: var(--primary);
    border: 1px solid rgba(16, 185, 129, 0.25);
}

/* Rules Tab styling */
.rules-container {
    max-width: 900px;
    margin: 0 auto;
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.rules-section {
    margin-top: 24px;
    padding-bottom: 24px;
    border-bottom: 1px solid var(--border-color);
}

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

.rules-section h3 {
    font-family: 'Outfit', sans-serif;
    font-size: 15px;
    font-weight: 600;
    color: var(--text-main);
    margin-bottom: 12px;
    display: flex;
    align-items: center;
    gap: 10px;
}

.rules-section h3 i {
    color: var(--primary);
}

.rules-section p {
    font-size: 13px;
    color: var(--text-sub);
    line-height: 1.6;
    margin-bottom: 12px;
}

.rules-section ul, .rules-section ol {
    margin-left: 20px;
    font-size: 13px;
    color: var(--text-sub);
    line-height: 1.6;
    margin-bottom: 16px;
}

.rules-section li {
    margin-bottom: 6px;
}

.pts-table {
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin-top: 12px;
}

.pts-row {
    display: flex;
    align-items: center;
    font-size: 12px;
    color: var(--text-sub);
}

.pts-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 10px;
    width: 50px;
    padding: 3px 0;
    border-radius: 4px;
    margin-right: 12px;
}

.pts-3 { background: rgba(16, 185, 129, 0.15); color: var(--primary); border: 1px solid rgba(16, 185, 129, 0.25); }
.pts-2 { background: rgba(59, 130, 246, 0.15); color: var(--blue); border: 1px solid rgba(59, 130, 246, 0.25); }
.pts-1 { background: rgba(251, 191, 36, 0.15); color: var(--gold); border: 1px solid rgba(251, 191, 36, 0.25); }
.pts-0 { background: rgba(239, 68, 68, 0.15); color: var(--danger); border: 1px solid rgba(239, 68, 68, 0.25); }

/* Overlays (Sync and Modal) */
.overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(5, 7, 12, 0.85);
    backdrop-filter: blur(8px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease;
}

.overlay.active {
    opacity: 1;
    pointer-events: auto;
}

.overlay-content {
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    padding: 40px;
    border-radius: 20px;
    text-align: center;
    max-width: 480px;
    box-shadow: var(--glass-shadow);
}

.spinner {
    font-size: 40px;
    color: var(--primary);
    margin-bottom: 24px;
}

.overlay-content h2 {
    font-family: 'Outfit', sans-serif;
    font-size: 20px;
    margin-bottom: 12px;
}

.overlay-content p {
    font-size: 13px;
    color: var(--text-muted);
    line-height: 1.5;
}

/* Modal Box styling */
.modal-box {
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: 24px;
    width: 90%;
    max-width: 750px;
    max-height: 85vh;
    box-shadow: var(--glass-shadow);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    transform: scale(0.95);
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.overlay.active .modal-box {
    transform: scale(1);
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 24px;
    border-bottom: 1px solid var(--border-color);
    background: rgba(22, 30, 49, 0.2);
}

.modal-header h2 {
    font-family: 'Outfit', sans-serif;
    font-size: 18px;
    color: var(--text-main);
    margin-bottom: 2px;
}

.modal-header span {
    font-size: 11px;
    color: var(--text-muted);
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.close-btn {
    border: none;
    background: transparent;
    color: var(--text-muted);
    font-size: 20px;
    cursor: pointer;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    transition: var(--transition-fast);
}

.close-btn:hover {
    background: var(--bg-hover);
    color: var(--text-main);
}

/* Modal summary stats cards grid */
.modal-summary-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 12px;
    padding: 20px 24px;
    background: rgba(10, 13, 20, 0.3);
}

.m-summary-card {
    background: rgba(22, 30, 49, 0.3);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    padding: 12px;
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    gap: 4px;
}

.m-summary-card.Highlight {
    border-color: rgba(16, 185, 129, 0.3);
    background: rgba(16, 185, 129, 0.03);
}

.m-summary-label {
    font-size: 9px;
    color: var(--text-muted);
    text-transform: uppercase;
    font-weight: 600;
    letter-spacing: 0.5px;
}

.m-summary-val {
    font-family: 'Outfit', sans-serif;
    font-size: 18px;
    font-weight: 700;
}

.m-summary-card.Highlight .m-summary-val {
    color: var(--primary);
}

/* Modal Tabs Navigation */
.modal-tabs {
    display: flex;
    border-bottom: 1px solid var(--border-color);
    padding: 0 24px;
    gap: 16px;
    background: rgba(22, 30, 49, 0.1);
}

.modal-tab-btn {
    border: none;
    background: transparent;
    color: var(--text-muted);
    font-size: 12px;
    font-weight: 600;
    padding: 14px 0;
    cursor: pointer;
    position: relative;
    transition: var(--transition-fast);
}

.modal-tab-btn:hover {
    color: var(--text-main);
}

.modal-tab-btn.active {
    color: var(--primary);
}

.modal-tab-btn.active::after {
    content: '';
    position: absolute;
    bottom: -1px;
    left: 0;
    width: 100%;
    height: 2px;
    background: var(--primary);
    box-shadow: 0 0 8px var(--primary);
}

/* Modal tab contents */
.modal-tab-content {
    display: none;
    flex-grow: 1;
    overflow-y: auto;
    padding: 20px 24px;
}

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

.modal-table-container {
    max-height: 400px;
    overflow-y: auto;
}

.modal-table-container table {
    width: 100%;
}

.modal-table-container th {
    position: sticky;
    top: 0;
    background: var(--bg-secondary);
    z-index: 10;
}

.modal-table-container td {
    padding: 10px 12px;
}

/* Points label pill */
.pts-badge-pill {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 10px;
    min-width: 22px;
    height: 22px;
    border-radius: 50%;
}

.pts-badge-pill.exact { background: rgba(16, 185, 129, 0.15); color: var(--primary); }
.pts-badge-pill.saldo { background: rgba(59, 130, 246, 0.15); color: var(--blue); }
.pts-badge-pill.winner { background: rgba(251, 191, 36, 0.15); color: var(--gold); }
.pts-badge-pill.zero { background: rgba(239, 68, 68, 0.08); color: var(--text-muted); }

/* Responsive adjustments */
@media (max-width: 1024px) {
    .standings-layout {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 768px) {
    .app-header {
        flex-direction: column;
        gap: 16px;
        align-items: stretch;
    }
    
    .tab-navigation {
        justify-content: center;
    }
    
    .sync-section {
        align-items: center;
    }
    
    .logo-area {
        justify-content: center;
    }
    
    .card-header {
        flex-direction: column;
        align-items: stretch;
    }
    
    .search-box {
        width: 100%;
    }
}
