/* Lenny's Baseball Draft Pool — shared styles */

:root {
  --bg: #f4f6f8;
  --surface: #ffffff;
  --surface-2: #eef1f4;
  --surface-3: #e3e8ee;
  --text: #172029;
  --text-muted: #5a6673;
  --border: #d7dee6;
  --accent: #1c6fd6;
  --accent-strong: #14498c;
  --accent-soft: #e4effb;
  --good: #1a8a4a;
  --bad: #c53030;
  --warn: #b7791f;
  --live: #c53030;
  --shadow: 0 1px 3px rgba(20, 40, 70, 0.08), 0 4px 14px rgba(20, 40, 70, 0.06);
  --radius: 10px;
  --radius-sm: 6px;
  --maxw: 1240px;
  --heat-0: #eef2f7;
  --heat-max: #1c6fd6;
}

html[data-theme='dark'] {
  --bg: #0e141b;
  --surface: #161e28;
  --surface-2: #1d2732;
  --surface-3: #26323f;
  --text: #e6edf4;
  --text-muted: #9aa8b6;
  --border: #2a3744;
  --accent: #4d9bff;
  --accent-strong: #7db4ff;
  --accent-soft: #16304c;
  --good: #4ec17f;
  --bad: #f27272;
  --warn: #e0b04a;
  --live: #f27272;
  --shadow: 0 1px 3px rgba(0, 0, 0, 0.4), 0 6px 18px rgba(0, 0, 0, 0.3);
  --heat-0: #1a232e;
  --heat-max: #4d9bff;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.45;
  -webkit-text-size-adjust: 100%;
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ---------- Header / nav ---------- */
.site-header {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 50;
  box-shadow: var(--shadow);
}
.header-inner {
  max-width: var(--maxw);
  margin: 0 auto;
  padding: 0 16px;
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: 58px;
  flex-wrap: wrap;
}
.brand {
  display: flex;
  align-items: center;
  gap: 9px;
  font-weight: 800;
  font-size: 1.05rem;
  color: var(--text);
  white-space: nowrap;
}
.brand:hover { text-decoration: none; }
.brand .ball {
  width: 26px; height: 26px; border-radius: 50%;
  background: radial-gradient(circle at 35% 30%, #fff 55%, #f0f0f0 100%);
  border: 1px solid #d0d0d0;
  position: relative; flex: none;
  box-shadow: inset 0 0 0 2px transparent;
}
.brand .ball::before, .brand .ball::after {
  content: ""; position: absolute; top: 4px; bottom: 4px; width: 6px;
  border: 1.4px solid #d0453b; border-radius: 50%;
}
.brand .ball::before { left: 2px; border-right: none; }
.brand .ball::after { right: 2px; border-left: none; }

.main-nav {
  display: flex;
  gap: 2px;
  flex: 1;
  flex-wrap: wrap;
}
.main-nav a {
  color: var(--text-muted);
  padding: 8px 12px;
  border-radius: var(--radius-sm);
  font-size: 0.92rem;
  font-weight: 600;
  white-space: nowrap;
}
.main-nav a:hover { background: var(--surface-2); color: var(--text); text-decoration: none; }
.main-nav a.active { color: var(--accent); background: var(--accent-soft); }

.theme-toggle {
  background: var(--surface-2);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: var(--radius-sm);
  width: 38px; height: 34px;
  cursor: pointer;
  font-size: 1.05rem;
  display: inline-flex; align-items: center; justify-content: center;
  flex: none;
}
.theme-toggle:hover { background: var(--surface-3); }

.nav-toggle {
  display: none;
  background: var(--surface-2);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: var(--radius-sm);
  width: 38px; height: 34px;
  cursor: pointer; font-size: 1.1rem;
}

/* ---------- Layout ---------- */
.container {
  max-width: var(--maxw);
  margin: 0 auto;
  padding: 20px 16px 60px;
}
.page-title {
  font-size: 1.55rem;
  margin: 4px 0 2px;
  font-weight: 800;
}
.page-sub { color: var(--text-muted); margin: 0 0 18px; font-size: 0.95rem; }

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 16px 18px;
  margin-bottom: 20px;
}
.card h2 { margin: 0 0 12px; font-size: 1.12rem; }
.card h3 { margin: 18px 0 8px; font-size: 1rem; }
.card-head {
  display: flex; align-items: center; justify-content: space-between;
  gap: 12px; flex-wrap: wrap; margin-bottom: 12px;
}
.card-head h2 { margin: 0; }

.muted { color: var(--text-muted); }
.small { font-size: 0.85rem; }
.nowrap { white-space: nowrap; }
.right { text-align: right; }
.center { text-align: center; }

/* ---------- Segmented control ---------- */
.segmented {
  display: inline-flex;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 3px;
  gap: 2px;
  flex-wrap: wrap;
}
.segmented button {
  border: none; background: transparent; color: var(--text-muted);
  padding: 6px 14px; border-radius: 999px; cursor: pointer;
  font-size: 0.88rem; font-weight: 600;
}
.segmented button.active { background: var(--accent); color: #fff; }
.segmented button:hover:not(.active) { color: var(--text); }

/* ---------- Buttons ---------- */
.btn {
  border: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--text);
  border-radius: var(--radius-sm);
  padding: 8px 14px;
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
}
.btn:hover { background: var(--surface-3); }
.btn-primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn-primary:hover { background: var(--accent-strong); }
.btn-sm { padding: 5px 10px; font-size: 0.82rem; }
.btn:disabled { opacity: 0.55; cursor: default; }

/* ---------- Tables ---------- */
.table-wrap { overflow-x: auto; }
table.data {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.92rem;
}
table.data th, table.data td {
  padding: 9px 10px;
  text-align: left;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}
table.data th {
  color: var(--text-muted);
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  font-weight: 700;
  position: sticky; top: 0;
  background: var(--surface);
  cursor: default;
}
table.data th.sortable { cursor: pointer; }
table.data th.sortable:hover { color: var(--text); }
table.data th.sorted::after { content: " ▾"; color: var(--accent); }
table.data th.sorted.asc::after { content: " ▴"; }
table.data tbody tr:hover { background: var(--surface-2); }
table.data td.num, table.data th.num { text-align: right; font-variant-numeric: tabular-nums; }
table.data tr.rowlink { cursor: pointer; }
.rank { font-weight: 700; color: var(--text-muted); width: 2em; }

.expand-row td { background: var(--surface-2); padding: 0; }
.expand-inner { padding: 12px 14px; }
.team-mini-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 8px;
}
.team-chip {
  display: flex; justify-content: space-between; align-items: center;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius-sm); padding: 6px 10px; font-size: 0.86rem;
}
.team-chip .rec { color: var(--text-muted); font-variant-numeric: tabular-nums; }

.badge {
  display: inline-block; padding: 2px 8px; border-radius: 999px;
  font-size: 0.72rem; font-weight: 700; letter-spacing: 0.02em;
}
.badge-good { background: color-mix(in srgb, var(--good) 18%, transparent); color: var(--good); }
.badge-bad { background: color-mix(in srgb, var(--bad) 18%, transparent); color: var(--bad); }
.badge-warn { background: color-mix(in srgb, var(--warn) 20%, transparent); color: var(--warn); }
.badge-accent { background: var(--accent-soft); color: var(--accent); }
.badge-live { background: var(--live); color: #fff; }
.badge-muted { background: var(--surface-3); color: var(--text-muted); }

/* ---------- Scoreboard ---------- */
.scoreboard-cols {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 16px;
}
.sb-col h3 {
  margin: 0 0 8px; font-size: 0.82rem; text-transform: uppercase;
  letter-spacing: 0.05em; color: var(--text-muted);
}
.game-card {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 8px 12px;
  margin-bottom: 8px;
}
.game-row {
  display: flex; justify-content: space-between; align-items: center;
  padding: 2px 0; font-size: 0.92rem;
}
.game-row.winner { font-weight: 700; }
.game-row .team { display: flex; align-items: center; gap: 6px; }
.game-row .score { font-variant-numeric: tabular-nums; }
.game-status { font-size: 0.75rem; color: var(--text-muted); margin-top: 4px; }
.game-status.live { color: var(--live); font-weight: 700; }

/* ---------- Charts ---------- */
.chart-box { position: relative; width: 100%; height: 380px; }
.chart-hint { font-size: 0.8rem; color: var(--text-muted); margin-top: 6px; }

/* ---------- States ---------- */
.empty-state {
  text-align: center; padding: 40px 20px; color: var(--text-muted);
}
.empty-state .icon { font-size: 2.2rem; margin-bottom: 8px; opacity: 0.6; }
.loading { color: var(--text-muted); padding: 20px; text-align: center; }
.error-banner {
  background: color-mix(in srgb, var(--bad) 14%, transparent);
  border: 1px solid var(--bad); color: var(--bad);
  padding: 10px 14px; border-radius: var(--radius-sm); margin-bottom: 16px;
  font-size: 0.9rem;
}
.notice {
  background: var(--accent-soft); border: 1px solid var(--accent);
  color: var(--accent-strong); padding: 10px 14px; border-radius: var(--radius-sm);
  margin-bottom: 16px; font-size: 0.9rem;
}

/* ---------- Stat pills ---------- */
.stat-row { display: flex; flex-wrap: wrap; gap: 14px; }
.stat {
  background: var(--surface-2); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 12px 16px; min-width: 120px; flex: 1;
}
.stat .label { font-size: 0.75rem; text-transform: uppercase; letter-spacing: 0.04em; color: var(--text-muted); }
.stat .value { font-size: 1.5rem; font-weight: 800; margin-top: 2px; }

/* ---------- Common picks heatmap ---------- */
.heat-wrap { overflow-x: auto; }
table.heat { border-collapse: collapse; font-size: 0.72rem; }
table.heat th, table.heat td {
  border: 1px solid var(--border); text-align: center;
  width: 30px; height: 30px; padding: 0;
}
table.heat th.corner { background: var(--surface); }
table.heat th.rowhead, table.heat th.colhead {
  background: var(--surface); color: var(--text-muted);
  font-weight: 600; padding: 2px 6px; white-space: nowrap;
}
table.heat th.colhead { height: auto; }
table.heat td { color: #fff; font-weight: 600; font-variant-numeric: tabular-nums; }
table.heat td.diag { background: var(--surface-3); color: var(--text-muted); }

/* ---------- Best possible ---------- */
.box-optimal {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 10px;
}
.opt-box {
  background: var(--surface-2); border: 1px solid var(--border);
  border-radius: var(--radius-sm); padding: 10px 12px;
}
.opt-box .bn { font-size: 0.72rem; color: var(--text-muted); text-transform: uppercase; }
.opt-box .best { font-weight: 800; font-size: 1.05rem; margin-top: 2px; }
.opt-box .bw { color: var(--good); font-weight: 700; }
.lost { color: var(--bad); }
.kept { color: var(--good); }

/* ---------- Payouts ---------- */
.prize-card {
  border: 1px solid var(--border); border-radius: var(--radius);
  background: var(--surface-2); padding: 14px 16px; margin-bottom: 12px;
}
.prize-head { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; flex-wrap: wrap; }
.prize-head .amt { font-size: 1.25rem; font-weight: 800; color: var(--good); }
.prize-winners { margin-top: 8px; display: flex; flex-wrap: wrap; gap: 8px; }
.winner-chip {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 999px; padding: 4px 12px; font-size: 0.86rem;
}
.winner-chip .share { color: var(--good); font-weight: 700; }

/* ---------- Admin ---------- */
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--border); margin-bottom: 18px; flex-wrap: wrap; }
.tabs button {
  border: none; background: transparent; color: var(--text-muted);
  padding: 10px 14px; cursor: pointer; font-weight: 600; font-size: 0.92rem;
  border-bottom: 2px solid transparent;
}
.tabs button.active { color: var(--accent); border-bottom-color: var(--accent); }
.tabs button:hover:not(.active) { color: var(--text); }
.tab-panel { display: none; }
.tab-panel.active { display: block; }

.form-grid { display: grid; gap: 12px; max-width: 460px; }
.field { display: flex; flex-direction: column; gap: 4px; }
.field label { font-size: 0.82rem; font-weight: 600; color: var(--text-muted); }
input[type=text], input[type=password], input[type=number], input[type=date], textarea, select {
  background: var(--surface); border: 1px solid var(--border); color: var(--text);
  border-radius: var(--radius-sm); padding: 8px 10px; font-size: 0.9rem; font-family: inherit;
  width: 100%;
}
input:focus, textarea:focus, select:focus { outline: 2px solid var(--accent); outline-offset: -1px; }
textarea { resize: vertical; min-height: 60px; }
label.check { display: inline-flex; align-items: center; gap: 6px; font-size: 0.9rem; }
label.check input { width: auto; }

.admin-row {
  display: grid; grid-template-columns: 1fr; gap: 10px;
  border: 1px solid var(--border); border-radius: var(--radius);
  background: var(--surface-2); padding: 12px 14px; margin-bottom: 10px;
}
.toast {
  position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%);
  background: var(--text); color: var(--bg); padding: 10px 18px;
  border-radius: 999px; font-size: 0.9rem; box-shadow: var(--shadow);
  z-index: 100; opacity: 0; transition: opacity 0.2s; pointer-events: none;
}
.toast.show { opacity: 1; }
.toast.err { background: var(--bad); color: #fff; }

.pill-list { display: flex; flex-wrap: wrap; gap: 6px; }
.pill { background: var(--surface-3); border-radius: 999px; padding: 3px 10px; font-size: 0.8rem; }

.sync-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 12px; }
.sync-item { border: 1px solid var(--border); border-radius: var(--radius); padding: 12px; background: var(--surface-2); }
.sync-item .last { font-size: 0.78rem; color: var(--text-muted); margin: 6px 0 10px; }

/* ---------- Responsive ---------- */
@media (max-width: 760px) {
  .nav-toggle { display: inline-flex; align-items: center; justify-content: center; order: 3; }
  .main-nav {
    order: 10; flex-basis: 100%; flex-direction: column;
    display: none; gap: 0; padding-top: 6px;
  }
  .main-nav.open { display: flex; }
  .main-nav a { padding: 10px 8px; border-radius: var(--radius-sm); }
  .brand { flex: 1; }

  /* Collapse tables to cards */
  table.data.responsive thead { display: none; }
  table.data.responsive, table.data.responsive tbody,
  table.data.responsive tr, table.data.responsive td { display: block; width: 100%; }
  table.data.responsive tr {
    border: 1px solid var(--border); border-radius: var(--radius-sm);
    margin-bottom: 10px; padding: 6px 4px; background: var(--surface);
  }
  table.data.responsive tbody tr:hover { background: var(--surface); }
  table.data.responsive td {
    display: flex; justify-content: space-between; gap: 12px;
    border: none; padding: 5px 12px; white-space: normal; text-align: right;
  }
  table.data.responsive td::before {
    content: attr(data-label);
    font-weight: 700; color: var(--text-muted); text-align: left;
    font-size: 0.78rem; text-transform: uppercase; letter-spacing: 0.03em;
  }
  table.data.responsive td.no-label::before { content: ""; }
  table.data.responsive tr.expand-row td { display: block; }
  table.data.responsive tr.expand-row td::before { content: ""; }
  .chart-box { height: 300px; }
}
