:root {
    --bg-dark: #0a0b10;
    --bg-panel: #13151c;
    --text-primary: #e2e8f0;
    --text-secondary: #94a3b8;
    --accent: #3b82f6;
    --accent-glow: rgba(59, 130, 246, 0.5);
    
    --elite-color: #f59e0b;
    --elite-glow: rgba(245, 158, 11, 0.4);
    
    --hc-color: #10b981;
    --hc-glow: rgba(16, 185, 129, 0.4);

    --border: rgba(255, 255, 255, 0.08);
    --glass-bg: rgba(19, 21, 28, 0.7);
    --row-hover: rgba(255, 255, 255, 0.03);

    --font-heading: 'Outfit', sans-serif;
    --font-body: 'Inter', sans-serif;
}

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

body {
    background-color: var(--bg-dark);
    color: var(--text-primary);
    font-family: var(--font-body);
    -webkit-font-smoothing: antialiased;
    min-height: 100vh;
    overflow-x: hidden;
}

/* Scrollbar styling */
::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}
::-webkit-scrollbar-track {
    background: var(--bg-dark); 
}
::-webkit-scrollbar-thumb {
    background: #334155; 
    border-radius: 4px;
}
::-webkit-scrollbar-thumb:hover {
    background: #475569; 
}

/* Layout */
.app-container {
    display: flex;
    flex-direction: column;
    height: 100vh;
}

/* Header */
.glass-header {
    background: var(--glass-bg);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border-bottom: 1px solid var(--border);
    padding: 1.5rem 2rem;
    position: sticky;
    top: 0;
    z-index: 100;
}

.header-content {
    display: flex;
    justify-content: space-between;
    align-items: center;
    max-width: 1800px;
    margin: 0 auto;
}

.logo-area h1 {
    font-family: var(--font-heading);
    font-size: 1.8rem;
    font-weight: 700;
    letter-spacing: -0.02em;
    color: #fff;
}

.logo-area h1 span {
    color: var(--accent);
}

.subtitle {
    font-size: 0.9rem;
    color: var(--text-secondary);
    margin-top: 0.2rem;
    font-weight: 500;
}

/* Toggle Switch and Language Selectors */
.controls-area {
    display: flex;
    align-items: center;
    gap: 1.5rem;
}

.lang-selector {
    display: flex;
    background: rgba(0, 0, 0, 0.2);
    border-radius: 8px;
    border: 1px solid var(--border);
    overflow: hidden;
}

.lang-btn {
    background: transparent;
    border: none;
    color: var(--text-secondary);
    padding: 0.5rem 1rem;
    font-size: 0.85rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    font-family: inherit;
}

.lang-btn:hover {
    color: #fff;
    background: rgba(255, 255, 255, 0.05);
}

.lang-btn.active {
    background: rgba(59, 130, 246, 0.2);
    color: var(--accent);
    box-shadow: inset 0 -2px 0 var(--accent);
}

.toggle-container {
    display: flex;
    align-items: center;
    gap: 0.8rem;
    background: rgba(0, 0, 0, 0.2);
    padding: 0.5rem 1rem;
    border-radius: 50px;
    border: 1px solid var(--border);
}

.toggle-label {
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--text-secondary);
    transition: color 0.3s;
}

.toggle-label.active {
    color: #fff;
}

.switch {
    position: relative;
    display: inline-block;
    width: 46px;
    height: 24px;
}

.switch input { 
    opacity: 0;
    width: 0;
    height: 0;
}

.slider {
    position: absolute;
    cursor: pointer;
    top: 0; left: 0; right: 0; bottom: 0;
    background-color: #334155;
    transition: .4s;
}

.slider:before {
    position: absolute;
    content: "";
    height: 18px;
    width: 18px;
    left: 3px;
    bottom: 3px;
    background-color: white;
    transition: .4s;
    box-shadow: 0 2px 4px rgba(0,0,0,0.3);
}

input:checked + .slider {
    background-color: var(--accent);
    box-shadow: 0 0 10px var(--accent-glow);
}

input:checked + .slider:before {
    transform: translateX(22px);
}

.slider.round {
    border-radius: 24px;
}

.slider.round:before {
    border-radius: 50%;
}

/* Main Content & Table */
.table-container {
    flex: 1;
    padding: 2rem;
    overflow: hidden; /* we handle scroll in wrapper */
    display: flex;
    justify-content: center;
}

.table-wrapper {
    width: 100%;
    max-width: 1800px;
    background: var(--bg-panel);
    border-radius: 12px;
    border: 1px solid var(--border);
    overflow: auto;
    box-shadow: 0 10px 30px rgba(0,0,0,0.5);
}

table {
    width: 100%;
    border-collapse: collapse;
    text-align: left;
    white-space: nowrap;
}

th, td {
    padding: 0.6rem 0.8rem;
    border-bottom: 1px solid var(--border);
}

th {
    background: rgba(255, 255, 255, 0.02);
    font-family: var(--font-heading);
    font-weight: 600;
    font-size: 0.85rem;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    position: sticky;
    top: 0;
    z-index: 10;
    backdrop-filter: blur(10px);
    white-space: nowrap;
}

/* Base Truncated Style */
td {
    font-size: 0.95rem;
    color: var(--text-primary);
    vertical-align: middle;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 250px;
}

/* Make Rank, Ticker, and Name slightly sticky to the left so they are always visible */
/* Also optimizing widths for efficiency */
th:nth-child(1), td:nth-child(1) { width: 50px; max-width: 60px; min-width: 50px; text-align: center; position: sticky; left: 0; z-index: 20; background: var(--bg-panel); }
th:nth-child(2), td:nth-child(2) { width: 90px; max-width: 100px; min-width: 90px; position: sticky; left: 50px; z-index: 20; background: var(--bg-panel); }
th:nth-child(3), td:nth-child(3) { width: 140px; max-width: 160px; min-width: 140px; position: sticky; left: 140px; z-index: 20; background: var(--bg-panel); border-right: 1px solid var(--border); }

/* Fix header z-index for sticky cols */
th:nth-child(1), th:nth-child(2), th:nth-child(3) {
    z-index: 30;
    background: #1a1d26;
}

/* Expansion logic */
tbody tr {
    cursor: pointer;
    transition: background-color 0.2s;
}

tbody tr:hover td {
    background-color: var(--row-hover);
}

tr.row-expanded td {
    white-space: pre-wrap;
    overflow: visible;
    text-overflow: clip;
    max-width: none;
    vertical-align: top;
    background-color: rgba(255, 255, 255, 0.02); /* slight highlight when expanded */
}

/* Ensure sticky columns maintain their background in expanded/hover states */
/* But also get the hover/expanded background mix */
tbody tr:hover td:nth-child(1), tbody tr:hover td:nth-child(2), tbody tr:hover td:nth-child(3) {
    background-color: #1a1d26;
}
tr.row-expanded td:nth-child(1), tr.row-expanded td:nth-child(2), tr.row-expanded td:nth-child(3) {
    background-color: #1a1d26;
}


.badge {
    display: inline-block;
    padding: 0.25rem 0.6rem;
    border-radius: 6px;
    font-size: 0.75rem;
    font-weight: 600;
    letter-spacing: 0.03em;
}

.badge.elite {
    background: rgba(245, 158, 11, 0.15);
    color: var(--elite-color);
    border: 1px solid rgba(245, 158, 11, 0.3);
    box-shadow: 0 0 10px var(--elite-glow);
}

.badge.score-glow {
    background: rgba(0, 255, 128, 0.2);
    color: #00ff80;
    border: 1px solid #00ff80;
    box-shadow: 0 0 20px 6px rgba(0, 255, 128, 0.6);
    text-shadow: 0 0 5px rgba(0, 255, 128, 0.8);
}

.badge.hc {
    background: rgba(16, 185, 129, 0.15);
    color: var(--hc-color);
    border: 1px solid rgba(16, 185, 129, 0.3);
}

.badge.standard {
    background: rgba(148, 163, 184, 0.15);
    color: var(--text-secondary);
    border: 1px solid var(--border);
}

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

tbody tr {
    animation: fadeIn 0.4s ease forwards;
    opacity: 0;
}

/* Dynamic column hiding */
.col-advanced {
    display: none;
}

body.show-advanced .col-advanced {
    display: table-cell;
}
