/* FragMath Dark Theme — based on docs/requirements/ui-style.md */

/* ── Reset & Base ───────────────────────────────────────────── */
*, *::before, *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html {
    font-size: 14px;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

body {
    font-family: 'JetBrains Mono', 'Fira Code', 'SF Mono', monospace;
    font-weight: 400;
    background: #0c0d10;
    color: #e0e0e4;
    line-height: 1.5;
    min-height: 100vh;
}

/* ── Typography ─────────────────────────────────────────────── */
h1, h2, h3, h4, h5, h6 {
    font-family: 'Space Grotesk', sans-serif;
    font-weight: 700;
    letter-spacing: -0.5px;
    color: #fff;
}

h1 { font-size: 1.5rem; }
h2 { font-size: 1.25rem; }
h3 { font-size: 1.1rem; }

a {
    color: #5b8def;
    text-decoration: none;
    transition: color 0.12s;
}

a:hover {
    color: #7da5f3;
}

/* ── Layout ─────────────────────────────────────────────────── */
.page-container {
    max-width: 1000px;
    margin: 0 auto;
    padding: 0 16px;
}

.content-area {
    padding: 20px 0;
}

/* ── Navigation ─────────────────────────────────────────────── */
.nav-bar {
    background: #13141a;
    border-bottom: 1px solid #1e1f28;
    padding: 0 16px;
    position: sticky;
    top: 0;
    z-index: 100;
}

.nav-inner {
    max-width: 1000px;
    margin: 0 auto;
    display: flex;
    align-items: center;
    gap: 24px;
    height: 48px;
}

.nav-logo {
    height: 28px;
    opacity: 0.9;
}

.nav-links {
    display: flex;
    gap: 16px;
    flex: 1;
}

.nav-links a {
    color: #888;
    font-size: 11px;
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    padding: 4px 0;
    transition: color 0.12s;
}

.nav-links a:hover,
.nav-links a.active {
    color: #e0e0e4;
}

.nav-right {
    display: flex;
    align-items: center;
    gap: 12px;
}

.nav-admin-label {
    font-size: 9px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: #ef5b5b;
    padding: 2px 6px;
    border: 1px solid rgba(239, 91, 91, 0.3);
    border-radius: 3px;
}

/* ── Footer ─────────────────────────────────────────────────── */
.site-footer {
    border-top: 1px solid #1e1f28;
    padding: 16px;
    margin-top: 40px;
}

.footer-inner {
    max-width: 1000px;
    margin: 0 auto;
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 10px;
    color: #555;
}

.tz-selector {
    display: flex;
    align-items: center;
    gap: 6px;
}

.tz-select {
    font-family: 'JetBrains Mono', monospace;
    font-size: 10px;
    background: #13141a;
    color: #888;
    border: 1px solid #1e1f28;
    padding: 2px 4px;
    border-radius: 3px;
    max-width: 280px;
}

.tz-select:focus {
    outline: none;
    border-color: #333;
    color: #e0e0e4;
}

/* ── Buttons ────────────────────────────────────────────────── */
.btn {
    font-family: 'JetBrains Mono', monospace;
    font-size: 11px;
    font-weight: 500;
    padding: 6px 14px;
    border: 1px solid #1e1f28;
    border-radius: 4px;
    background: #1a1b22;
    color: #e0e0e4;
    cursor: pointer;
    transition: background 0.12s, color 0.12s;
}

.btn:hover {
    background: #2a2c35;
    color: #fff;
}

.btn-primary {
    background: #5b8def;
    border-color: #5b8def;
    color: #fff;
}

.btn-primary:hover {
    background: #4a7ce0;
}

/* ── Toggle Buttons ─────────────────────────────────────────── */
.toggle-group {
    display: inline-flex;
    background: #1a1b20;
    border-radius: 6px;
    padding: 2px;
    width: fit-content;
}

.toggle-btn {
    font-family: 'JetBrains Mono', monospace;
    font-size: 11px;
    padding: 6px 14px;
    border: none;
    border-radius: 4px;
    background: transparent;
    color: #666;
    font-weight: 400;
    cursor: pointer;
    transition: background 0.12s, color 0.12s;
}

.toggle-btn.active {
    background: #2a2c35;
    color: #fff;
    font-weight: 600;
}

/* ── Data Tables ────────────────────────────────────────────── */
.data-table {
    width: 100%;
    border-collapse: separate;
    border-spacing: 2px;
    font-variant-numeric: tabular-nums;
}

.data-table th {
    font-size: 10px;
    font-weight: 500;
    color: #777;
    letter-spacing: 0.5px;
    text-transform: uppercase;
    text-align: left;
    padding: 6px 4px;
    white-space: nowrap;
}

.data-table td {
    padding: 7px 4px;
    font-size: 11px;
    font-weight: 500;
    border-radius: 3px;
    white-space: nowrap;
}

.data-table tbody tr {
    transition: outline 0.12s;
}

.data-table tbody tr:hover td {
    outline: 2px solid rgba(255, 255, 255, 0.4);
    outline-offset: -2px;
}

.data-table .highlight-row td {
    background: rgba(91, 141, 239, 0.12);
    font-weight: 700;
}

.data-table .text-right {
    text-align: right;
}

.data-table .text-center {
    text-align: center;
}

/* ── Team Colors ────────────────────────────────────────────── */
.team-red { color: #ef5b5b; }
.team-blue { color: #5b8def; }
.data-table th.team-red { color: #ef5b5b; }
.data-table th.team-blue { color: #5b8def; }

.team-dot {
    display: inline-block;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    opacity: 0.8;
}

.team-dot-red { background: #ef5b5b; }
.team-dot-blue { background: #5b8def; }

/* ── Semantic Colors ────────────────────────────────────────── */
.best-in-team { text-decoration: underline; text-underline-offset: 2px; color: #f0c040; font-weight: 600; }
.positive-strong { color: #22c55e; }
.positive { color: #4ade80; }
.positive-muted { color: #86efac; }
.neutral { color: #a0a0a8; }
.negative { color: #fca5a5; }
.negative-strong { color: #ef4444; }
.warning { color: #f87171; }
.accent { color: #5b8def; }
.muted { color: #888; }
.dim { color: #666; }

.text-strong { color: #fff; font-weight: 600; }
.text-secondary { color: #c0c0c4; }

/* ── Stat Labels ────────────────────────────────────────────── */
.stat-label {
    font-size: 9px;
    color: #555;
    letter-spacing: 0.5px;
    text-transform: uppercase;
}

.stat-value {
    font-size: 16px;
    font-weight: 700;
}

/* ── Detail Panels ──────────────────────────────────────────── */
.panel {
    background: #13141a;
    border-radius: 8px;
    border: 1px solid #1e1f28;
    padding: 16px;
}

.panel-raised {
    background: #1a1b22;
}

/* ── Status Badges ──────────────────────────────────────────── */
.status-badge {
    font-size: 9px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    padding: 2px 8px;
    border-radius: 3px;
}

.status-ended {
    color: #4ade80;
    background: rgba(74, 222, 128, 0.1);
}

.status-imported {
    color: #888;
    background: rgba(136, 136, 136, 0.1);
}

.status-killed {
    color: #ef4444;
    background: rgba(239, 68, 68, 0.1);
}

.status-active {
    color: #5b8def;
    background: rgba(91, 141, 239, 0.1);
}

/* ── Tier Badge ─────────────────────────────────────────────── */
.tier-badge {
    font-size: 10px;
    font-weight: 600;
    padding: 1px 6px;
    border-radius: 3px;
    display: inline-block;
}

.tier-0 { color: #888; background: rgba(136, 136, 136, 0.15); }
.tier-1 { color: #86efac; background: rgba(134, 239, 172, 0.1); }
.tier-2 { color: #4ade80; background: rgba(74, 222, 128, 0.1); }
.tier-3 { color: #22c55e; background: rgba(34, 197, 94, 0.1); }
.tier-4 { color: #5b8def; background: rgba(91, 141, 239, 0.1); }
.tier-5 { color: #a78bfa; background: rgba(167, 139, 250, 0.1); }
.tier-6 { color: #f59e0b; background: rgba(245, 158, 11, 0.1); }
.tier-7 { color: #ef5b5b; background: rgba(239, 91, 91, 0.1); }
.tier-8 { color: #ef4444; background: rgba(239, 68, 68, 0.15); }
.tier-9 { color: #fff; background: rgba(255, 255, 255, 0.12); }

/* ── Filters ────────────────────────────────────────────────── */
.filter-bar {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-bottom: 16px;
    align-items: center;
}

.filter-select,
.filter-input {
    font-family: 'JetBrains Mono', monospace;
    font-size: 11px;
    padding: 6px 10px;
    background: #1a1b22;
    color: #e0e0e4;
    border: 1px solid #1e1f28;
    border-radius: 4px;
    outline: none;
    transition: border-color 0.12s;
}

.filter-select:focus,
.filter-input:focus {
    border-color: #5b8def;
}

.filter-select option {
    background: #1a1b22;
    color: #e0e0e4;
}

/* ── Forms ──────────────────────────────────────────────────── */
.form-group {
    margin-bottom: 16px;
}

.form-label {
    display: block;
    font-size: 9px;
    color: #555;
    letter-spacing: 0.5px;
    text-transform: uppercase;
    margin-bottom: 4px;
}

.form-input {
    font-family: 'JetBrains Mono', monospace;
    font-size: 12px;
    padding: 8px 12px;
    background: #1a1b22;
    color: #e0e0e4;
    border: 1px solid #1e1f28;
    border-radius: 4px;
    outline: none;
    width: 100%;
    transition: border-color 0.12s;
}

.form-input:focus {
    border-color: #5b8def;
}

.form-input:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* ── Z-Score Divider Column ─────────────────────────────────── */
th.zscore-divider-col,
td.zscore-divider-col {
    width: 1px;
    padding: 0 4px;
    background: transparent;
    position: relative;
}

th.zscore-divider-col::after,
td.zscore-divider-col::after {
    content: '';
    position: absolute;
    top: 2px;
    bottom: 2px;
    left: 50%;
    width: 1px;
    background: #1e1f28;
}

/* ── Match Team Tables ─────────────────────────────────────── */
.match-team-table {
    table-layout: fixed;
}

/* ── Heatmap Colors ─────────────────────────────────────────── */
.heatmap-cell {
    text-align: right;
    font-size: 11px;
    font-weight: 500;
    padding: 4px 6px;
    border-radius: 3px;
}

/* ── Match Header ───────────────────────────────────────────── */
.match-header {
    display: flex;
    flex-wrap: wrap;
    gap: 24px;
    align-items: baseline;
    margin-bottom: 20px;
}

.match-score {
    font-family: 'Space Grotesk', sans-serif;
    font-size: 2rem;
    font-weight: 700;
    letter-spacing: -1px;
}

.match-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 16px;
    font-size: 11px;
    color: #888;
}

/* ── Section Spacing ────────────────────────────────────────── */
.section {
    margin-bottom: 24px;
}

.section-title {
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: #888;
    margin-bottom: 10px;
    padding-bottom: 6px;
    border-bottom: 1px solid #1e1f28;
}

/* ── Player Link ────────────────────────────────────────────── */
.player-link {
    color: #e0e0e4;
    transition: color 0.12s;
}

.player-link:hover {
    color: #fff;
}

/* ── Chart Container ────────────────────────────────────────── */
.chart-container {
    position: relative;
    height: 300px;
    background: #13141a;
    border: 1px solid #1e1f28;
    border-radius: 8px;
    padding: 12px;
}

/* ── Kill Matrix ────────────────────────────────────────────── */
.kill-matrix {
    font-size: 10px;
}

.kill-matrix th,
.kill-matrix td {
    padding: 3px 6px;
    text-align: center;
}

.kill-matrix td.self {
    background: rgba(255, 255, 255, 0.03);
}

/* ── Insight Tags ───────────────────────────────────────────── */
.insight-tag {
    display: inline-block;
    font-size: 9px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    padding: 2px 8px;
    border-radius: 3px;
    margin: 2px;
}

.insight-carry { color: #22c55e; background: rgba(34, 197, 94, 0.12); }
.insight-upset { color: #f59e0b; background: rgba(245, 158, 11, 0.12); }
.insight-godlike { color: #ef4444; background: rgba(239, 68, 68, 0.15); }
.insight-hot { color: #ef5b5b; background: rgba(239, 91, 91, 0.1); }
.insight-cold { color: #5b8def; background: rgba(91, 141, 239, 0.1); }

/* ── Loading / Empty ────────────────────────────────────────── */
.empty-state {
    text-align: center;
    padding: 40px 20px;
    color: #555;
    font-size: 12px;
}

.error-state {
    text-align: center;
    padding: 20px;
    color: #ef4444;
    font-size: 12px;
}

/* ── Clickable Rows ─────────────────────────────────────────── */
tr.clickable {
    cursor: pointer;
}

tr.clickable:hover td {
    background: #1a1b22;
}

/* ── Responsive ─────────────────────────────────────────────── */
@media (max-width: 768px) {
    .nav-inner {
        gap: 12px;
    }

    .filter-bar {
        flex-direction: column;
        align-items: stretch;
    }

    .match-header {
        flex-direction: column;
        gap: 8px;
    }

    .data-table {
        font-size: 10px;
    }
}

/* ── Auth Button ────────────────────────────────────────────── */
.login-btn {
    font-family: 'JetBrains Mono', monospace;
    font-size: 10px;
    font-weight: 500;
    padding: 4px 12px;
    background: #5b65f6;
    color: #fff;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    text-decoration: none;
    transition: background 0.12s;
}

.login-btn:hover {
    background: #4a54e5;
    color: #fff;
}

/* ── Win/Loss Indicator ─────────────────────────────────────── */
.win-indicator { color: #4ade80; }
.loss-indicator { color: #fca5a5; }

/* ── Coming Soon ────────────────────────────────────────────── */
.coming-soon {
    font-size: 10px;
    color: #555;
    font-style: italic;
}

/* ── Preference Grid ────────────────────────────────────────── */
.pref-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 8px;
}

.pref-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 6px 10px;
    background: #1a1b22;
    border-radius: 4px;
    font-size: 11px;
}
