/* ── Tokens ─────────────────────────────────────────────────────────── */
:root {
  --bg:       #0d1117;
  --surface:  #161b22;
  --surface2: #1c2128;
  --border:   #30363d;
  --text:     #e6edf3;
  --muted:    #8b949e;
  --accent:   #58a6ff;
  --green:    #3fb950;
  --amber:    #d29922;
  --red:      #f85149;
  --radius:   8px;
  --font: -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
}

/* ── Reset ──────────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 15px; }
body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  min-height: 100vh;
}
a { color: var(--accent); text-decoration: none; }

/* ── Nav ────────────────────────────────────────────────────────────── */
.navbar {
  position: sticky;
  top: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  gap: 24px;
  padding: 0 24px;
  height: 52px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}

.nav-logo {
  width: 28px;
  height: 28px;
  border-radius: 5px;
  flex-shrink: 0;
}

.nav-brand {
  display: flex;
  align-items: baseline;
  gap: 6px;
  white-space: nowrap;
}
.brand-main {
  font-size: 1rem;
  font-weight: 700;
  letter-spacing: 0.5px;
  color: var(--text);
}
.brand-sub {
  font-size: 0.75rem;
  color: var(--muted);
}

.nav-tabs {
  display: flex;
  gap: 2px;
}
.nav-tab {
  background: none;
  border: none;
  color: var(--muted);
  font: inherit;
  font-size: 0.85rem;
  padding: 6px 14px;
  border-radius: var(--radius);
  cursor: pointer;
  transition: color 0.15s, background 0.15s;
}
.nav-tab:hover  { color: var(--text); background: var(--surface2); }
.nav-tab.active { color: var(--text); background: var(--surface2); }

.nav-meta {
  margin-left: auto;
  font-size: 0.78rem;
  color: var(--muted);
  white-space: nowrap;
}

/* ── Layout ─────────────────────────────────────────────────────────── */
.main { max-width: 1280px; margin: 0 auto; padding: 24px; }
.tab  { display: none; }
.tab.active { display: block; }

/* ── Inputs ─────────────────────────────────────────────────────────── */
.input, .select {
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  font: inherit;
  font-size: 0.85rem;
  padding: 7px 12px;
  outline: none;
  transition: border-color 0.15s;
}
.input:focus, .select:focus { border-color: var(--accent); }
.input::placeholder { color: var(--muted); }
.select option { background: var(--surface2); }
.input-lg { font-size: 0.95rem; padding: 10px 14px; width: 100%; max-width: 480px; }

.btn {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font: inherit;
  font-size: 0.82rem;
  padding: 7px 14px;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s;
}
.btn-ghost { background: none; color: var(--muted); }
.btn-ghost:hover { background: var(--surface2); color: var(--text); border-color: var(--muted); }


/* ── Players tab ────────────────────────────────────────────────────── */
.filter-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-bottom: 20px;
}
.filter-bar .input { flex: 1; min-width: 180px; }

.player-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(230px, 1fr));
  gap: 12px;
}

.player-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  cursor: pointer;
  transition: border-color 0.15s, transform 0.1s;
}
.player-card:hover {
  border-color: var(--accent);
  transform: translateY(-1px);
}
.card-top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 10px;
}
.card-top-right {
  display: flex;
  align-items: center;
  gap: 6px;
}
.card-rank-dot {
  width: 16px;
  height: 16px;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 0.58rem;
  font-weight: 700;
  color: #0d1117;
  flex-shrink: 0;
}
.card-number { font-size: 0.75rem; color: var(--muted); }
.card-gp {
  font-size: 0.72rem;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 2px 7px;
  color: var(--muted);
}
.card-name {
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 3px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.card-team {
  font-size: 0.78rem;
  color: var(--muted);
  margin-bottom: 12px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.card-stats {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 4px;
  border-top: 1px solid var(--border);
  padding-top: 10px;
}
.card-stat { text-align: center; }
.card-stat-val {
  font-size: 0.88rem;
  font-weight: 600;
  color: var(--text);
}
.card-stat-lbl {
  font-size: 0.65rem;
  color: var(--muted);
  margin-top: 1px;
}

.empty-state {
  padding: 60px 0;
  text-align: center;
  color: var(--muted);
  font-size: 0.9rem;
}

/* ── Autocomplete ───────────────────────────────────────────────────── */
.autocomplete-root { position: relative; }
.autocomplete-list {
  display: none;
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  right: 0;
  max-width: 480px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  z-index: 50;
  box-shadow: 0 8px 24px rgba(0,0,0,0.4);
}
.autocomplete-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 14px;
  cursor: pointer;
  transition: background 0.1s;
}
.autocomplete-item:hover { background: var(--surface2); }
.sug-name { flex: 1; font-size: 0.88rem; color: var(--text); }
.sug-team { font-size: 0.78rem; color: var(--muted); }
.sug-gp   { font-size: 0.75rem; color: var(--muted); min-width: 36px; text-align: right; }

/* ── Dashboard tab ──────────────────────────────────────────────────── */
.search-wrap { margin-bottom: 24px; }

.dashboard-content {}

.player-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 20px;
  padding-bottom: 20px;
  border-bottom: 1px solid var(--border);
}
.player-info { display: flex; align-items: center; gap: 16px; }
.player-number-badge {
  width: 48px; height: 48px;
  display: flex; align-items: center; justify-content: center;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--muted);
}
.player-name  { font-size: 1.4rem; font-weight: 700; color: var(--text); }
.player-team  { font-size: 0.85rem; color: var(--muted); margin-top: 2px; }
.player-gp-badge {
  font-size: 0.82rem;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 4px 12px;
  color: var(--muted);
}

.stat-summary {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-bottom: 28px;
}
.stat-chip {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 10px 16px;
  min-width: 80px;
  text-align: center;
}
.stat-chip-val {
  font-size: 1.15rem;
  font-weight: 700;
  color: var(--text);
}
.stat-chip-lbl {
  font-size: 0.68rem;
  color: var(--muted);
  margin-top: 2px;
}

.pct-warning {
  font-size: 0.8rem;
  color: var(--amber);
  margin-bottom: 16px;
  padding: 8px 12px;
  background: rgba(210, 153, 34, 0.08);
  border: 1px solid rgba(210, 153, 34, 0.2);
  border-radius: var(--radius);
}

.pct-sections { display: flex; flex-direction: column; gap: 24px; }

.pct-category-title {
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.8px;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 10px;
}

.pct-row {
  display: grid;
  grid-template-columns: 180px 52px 1fr 44px;
  align-items: center;
  gap: 12px;
  margin-bottom: 7px;
}
.pct-label { font-size: 0.82rem; color: var(--text); }
.pct-raw   { font-size: 0.78rem; color: var(--muted); text-align: right; }
.pct-bar-bg {
  height: 5px;
  background: var(--border);
  border-radius: 3px;
  overflow: hidden;
}
.pct-bar {
  height: 100%;
  border-radius: 3px;
  transition: width 0.4s ease;
}
.pct-rank {
  font-size: 0.75rem;
  font-weight: 600;
  text-align: right;
}
.pct-rank sup { font-size: 0.6em; }

/* ── Compare tab ────────────────────────────────────────────────────── */
.compare-header {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: 12px;
  margin-bottom: 24px;
}
.compare-selectors {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  flex: 1;
}
.compare-slot {
  position: relative;
  display: flex;
  align-items: center;
  gap: 6px;
}
.compare-slot .autocomplete-list { min-width: 280px; }
.compare-remove {
  background: none;
  border: none;
  color: var(--muted);
  font-size: 1rem;
  cursor: pointer;
  padding: 4px;
  line-height: 1;
  transition: color 0.15s;
}
.compare-remove:hover { color: var(--red); }

#compare-chart { min-height: 400px; }

/* ── Scatter tab ────────────────────────────────────────────────────── */
.scatter-controls {
  display: flex;
  flex-wrap: wrap;
  gap: 16px;
  align-items: flex-end;
  margin-bottom: 16px;
  padding: 16px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}
.ctrl-group { display: flex; flex-direction: column; gap: 5px; }
.ctrl-group .select, .ctrl-group .input { min-width: 160px; }
.ctrl-narrow .input { min-width: 70px; max-width: 70px; }
.ctrl-label {
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.5px;
  text-transform: uppercase;
  color: var(--muted);
}
.scatter-plot { min-height: 580px; }

/* ── Loading overlay ────────────────────────────────────────────────── */
.loading-overlay {
  position: fixed;
  inset: 0;
  background: var(--bg);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 16px;
  z-index: 999;
  transition: opacity 0.3s;
}
.loading-overlay.hidden { opacity: 0; pointer-events: none; }
.loading-spinner {
  width: 32px; height: 32px;
  border: 3px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}
.loading-text { font-size: 0.85rem; color: var(--muted); }
@keyframes spin { to { transform: rotate(360deg); } }

/* ── Compare custom chart ────────────────────────────────────────────── */
.cmp-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 14px;
  margin-bottom: 20px;
  padding: 10px 14px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}
.cmp-legend-item {
  display: flex;
  align-items: center;
  gap: 7px;
  font-size: 0.82rem;
  color: var(--text);
}
.cmp-legend-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  flex-shrink: 0;
}
.cmp-sections { display: flex; flex-direction: column; gap: 24px; }
.cmp-cat-title {
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.8px;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 10px;
  padding-bottom: 6px;
  border-bottom: 1px solid var(--border);
}
.cmp-metric {
  display: grid;
  grid-template-columns: 160px 1fr;
  align-items: center;
  gap: 12px;
  margin-bottom: 7px;
}
.cmp-metric-label { font-size: 0.82rem; color: var(--text); }
.cmp-bars { display: flex; flex-direction: column; gap: 5px; }
.cmp-bar-row {
  display: grid;
  grid-template-columns: 96px 1fr 38px;
  align-items: center;
  gap: 8px;
  padding: 2px 4px;
  border-radius: 4px;
  transition: background 0.12s;
}
.cmp-bar-row:hover { background: rgba(255,255,255,0.03); }
.cmp-pname {
  font-size: 0.72rem;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.cmp-bar-bg {
  height: 6px;
  background: var(--border);
  border-radius: 3px;
  overflow: hidden;
}
.cmp-bar {
  height: 100%;
  border-radius: 3px;
  transform-origin: left;
  animation: growBar 0.55s cubic-bezier(0.22, 1, 0.36, 1) both;
}
.cmp-pct {
  font-size: 0.68rem;
  font-weight: 600;
  text-align: right;
  white-space: nowrap;
}
@keyframes growBar {
  from { transform: scaleX(0); }
  to   { transform: scaleX(1); }
}

/* ── Scatter ─────────────────────────────────────────────────────────── */
#scatter-plot .plotly-notifier { display: none !important; }
#scatter-plot .modebar { display: none !important; }

/* ── Footer ──────────────────────────────────────────────────────────── */
.site-footer {
  margin-top: 48px;
  padding: 24px 16px;
  border-top: 1px solid var(--border);
  text-align: center;
  color: var(--muted);
  font-size: 0.82rem;
  line-height: 1.7;
}
.site-footer a {
  color: var(--muted);
  transition: color 0.15s;
}
.site-footer a:hover { color: var(--accent); }
.footer-sep { margin: 0 6px; opacity: 0.5; }

/* ── Responsive ─────────────────────────────────────────────────────── */
@media (max-width: 640px) {
  .navbar { gap: 12px; padding: 0 14px; }
  .main   { padding: 14px; }
  .pct-row { grid-template-columns: 130px 44px 1fr 36px; gap: 8px; }
  .cmp-metric { grid-template-columns: 1fr; gap: 4px; }
  .brand-sub { display: none; }
  .nav-meta  { display: none; }
}
