/* NBA Kalshi Bot — Mobile-First Web Dashboard */

:root {
  --bg-base: #0d0f12;
  --bg-card: #15181e;
  --bg-card-hover: #1a1e26;
  --border: #252a33;
  --text: #e6e9ef;
  --text-muted: #8b92a0;
  --accent: #f59e0b;
  --accent-dim: #b45309;
  --positive: #22c55e;
  --negative: #ef4444;
  --radius: 10px;
  --font-sans: 'Outfit', system-ui, sans-serif;
  --font-mono: 'JetBrains Mono', monospace;
}

*, *::before, *::after { box-sizing: border-box; }

body {
  margin: 0;
  font-family: var(--font-sans);
  background: var(--bg-base);
  color: var(--text);
  line-height: 1.5;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}

/* ── App Layout ─────────────────────────────────────────────────── */

.app {
  display: flex;
  min-height: 100vh;
}

/* ── Sidebar (desktop) ──────────────────────────────────────────── */

.sidebar {
  width: 220px;
  background: var(--bg-card);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  padding: 1.25rem 0;
  flex-shrink: 0;
}

.logo {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0 1rem 1.25rem;
  border-bottom: 1px solid var(--border);
  margin-bottom: 0.75rem;
}
.logo-icon { font-size: 1.3rem; }
.logo-text { font-weight: 600; font-size: 0.95rem; letter-spacing: -0.02em; }

.nav {
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
  padding: 0 0.5rem;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  padding: 0.5rem 0.65rem;
  color: var(--text-muted);
  text-decoration: none;
  border-radius: var(--radius);
  font-size: 0.85rem;
  font-weight: 500;
  transition: color 0.15s, background 0.15s;
}
.nav-item:hover { color: var(--text); background: var(--bg-card-hover); }
.nav-item.active { color: var(--accent); background: rgba(245,158,11,0.08); }
.nav-icon { font-size: 0.75rem; opacity: 0.9; }

.sidebar-footer {
  margin-top: auto;
  padding: 0.75rem 1rem;
  border-top: 1px solid var(--border);
}

.status-pill {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  font-size: 0.75rem;
  color: var(--text-muted);
  font-family: var(--font-mono);
}

.status-dot {
  width: 6px; height: 6px;
  border-radius: 50%;
  background: var(--accent);
  animation: pulse 2s ease-in-out infinite;
}

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

/* ── Main Content ───────────────────────────────────────────────── */

.main {
  flex: 1;
  padding: 1.5rem;
  overflow-x: hidden;
  min-width: 0;
}

.header { margin-bottom: 1.5rem; }
.header h1 {
  margin: 0 0 0.15rem;
  font-size: 1.5rem;
  font-weight: 600;
  letter-spacing: -0.03em;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}
.subtitle { margin: 0; color: var(--text-muted); font-size: 0.85rem; }

/* ── Stats Grid ─────────────────────────────────────────────────── */

.stats-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 0.75rem;
  margin-bottom: 1.25rem;
}

.stats-sm { grid-template-columns: repeat(3, 1fr); }

.stat-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem;
  transition: border-color 0.15s;
}
.stat-card:hover { border-color: rgba(245,158,11,0.2); }
.stat-label { font-size: 0.7rem; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.05em; margin-bottom: 0.2rem; }
.stat-value { font-size: 1.25rem; font-weight: 600; font-family: var(--font-mono); letter-spacing: -0.02em; }
.stat-value.positive, .positive { color: var(--positive); }
.stat-value.negative, .negative { color: var(--negative); }
.stat-meta { font-size: 0.7rem; color: var(--text-muted); margin-top: 0.2rem; }

/* ── Panels ─────────────────────────────────────────────────────── */

.panel {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.25rem;
  margin-bottom: 1rem;
}
.panel-title { margin: 0 0 0.2rem; font-size: 1rem; font-weight: 600; }
.panel-desc { margin: 0 0 0.75rem; font-size: 0.8rem; color: var(--text-muted); }

/* ── Tables ─────────────────────────────────────────────────────── */

.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }

.data-table { width: 100%; border-collapse: collapse; font-size: 0.8rem; }
.data-table th, .data-table td { padding: 0.6rem 0.5rem; text-align: left; border-bottom: 1px solid var(--border); white-space: nowrap; }
.data-table th { color: var(--text-muted); font-weight: 500; font-size: 0.7rem; text-transform: uppercase; letter-spacing: 0.04em; }
.data-table tbody tr:hover { background: var(--bg-card-hover); }
.empty-state { color: var(--text-muted); font-style: italic; text-align: center; padding: 1.5rem !important; }
.game-cell { font-weight: 500; }
.odds-cell { font-family: var(--font-mono); font-size: 0.8rem; }
.pnl-cell { font-family: var(--font-mono); font-weight: 500; }
.pnl-cell.positive { color: var(--positive); }
.pnl-cell.negative { color: var(--negative); }
.text-muted { color: var(--text-muted); font-size: 0.75rem; }

/* ── Badges ─────────────────────────────────────────────────────── */

.badge {
  display: inline-block;
  font-size: 0.65rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  padding: 0.15rem 0.4rem;
  border-radius: 4px;
  color: #fff;
}
.badge-green { background: var(--positive); }
.badge-red { background: var(--negative); }
.badge-yellow { background: var(--accent); color: #000; }
.badge-blue { background: #3b82f6; }
.badge-live { background: var(--positive); }
.badge-dry { background: var(--accent); color: #000; }

.mode-badge {
  display: inline-block;
  font-size: 0.65rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  padding: 0.2rem 0.5rem;
  border-radius: 4px;
  color: #fff;
}
.mode-badge.badge-live { background: var(--positive); }
.mode-badge.badge-dry { background: var(--accent); color: #000; }

/* ── Agent Grid ─────────────────────────────────────────────────── */

.agent-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 0.75rem;
  margin-bottom: 1.25rem;
}

.agent-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.75rem;
}
.agent-card.agent-healthy { border-left: 3px solid var(--positive); }
.agent-card.agent-stale { border-left: 3px solid var(--accent); }
.agent-card.agent-dead { border-left: 3px solid var(--negative); }

.agent-header {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  margin-bottom: 0.3rem;
}
.agent-icon { font-size: 1rem; }
.agent-name { font-weight: 600; font-size: 0.75rem; letter-spacing: 0.03em; }
.agent-meta { font-size: 0.7rem; color: var(--text-muted); }
.agent-activity { font-size: 0.65rem; color: var(--text-muted); margin-top: 0.2rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.dot {
  display: inline-block;
  width: 8px; height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
}

/* ── Event Feed ─────────────────────────────────────────────────── */

.event-feed { max-height: 400px; overflow-y: auto; }

.event-row {
  display: flex;
  gap: 0.5rem;
  padding: 0.3rem 0;
  border-bottom: 1px solid var(--border);
  font-size: 0.75rem;
  font-family: var(--font-mono);
}
.event-agent { font-weight: 600; min-width: 70px; }

/* ── Strategy Toggles ───────────────────────────────────────────── */

.strategy-row {
  padding: 0.75rem 0;
  border-bottom: 1px solid var(--border);
}
.strategy-row:last-child { border-bottom: none; }

.toggle-label {
  display: flex;
  align-items: flex-start;
  gap: 0.75rem;
  cursor: pointer;
}

.toggle-input { display: none; }

.toggle-slider {
  width: 44px;
  height: 24px;
  background: #374151;
  border-radius: 12px;
  position: relative;
  flex-shrink: 0;
  transition: background 0.2s;
  margin-top: 2px;
}
.toggle-slider::after {
  content: '';
  position: absolute;
  top: 2px; left: 2px;
  width: 20px; height: 20px;
  background: #fff;
  border-radius: 50%;
  transition: transform 0.2s;
}
.toggle-input:checked + .toggle-slider { background: var(--positive); }
.toggle-input:checked + .toggle-slider::after { transform: translateX(20px); }

.toggle-text { display: flex; flex-direction: column; }
.toggle-text strong { font-size: 0.9rem; }
.toggle-text small { font-size: 0.75rem; color: var(--text-muted); }

/* ── Games Grid ─────────────────────────────────────────────────── */

.games-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 0.5rem;
}

.game-card {
  background: var(--bg-card-hover);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.6rem;
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
}
.game-matchup { font-weight: 600; font-size: 0.85rem; }
.game-status { font-size: 0.7rem; color: var(--text-muted); }

/* ── Hypothesis Cards ───────────────────────────────────────────── */

.hyp-card {
  padding: 0.6rem 0;
  border-bottom: 1px solid var(--border);
}
.hyp-card:last-child { border-bottom: none; }
.hyp-header { display: flex; align-items: center; gap: 0.4rem; font-size: 0.85rem; }
.hyp-meta { font-size: 0.7rem; color: var(--text-muted); margin-top: 0.15rem; }

/* ── Changelog ──────────────────────────────────────────────────── */

.log-entry {
  padding: 0.6rem 0;
  border-bottom: 1px solid var(--border);
}
.log-entry:last-child { border-bottom: none; }
.log-header { display: flex; align-items: center; gap: 0.4rem; margin-bottom: 0.2rem; }
.log-body { font-size: 0.8rem; }

/* ── Alerts ─────────────────────────────────────────────────────── */

.alert-row {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.5rem 0;
  border-bottom: 1px solid var(--border);
  font-size: 0.8rem;
}
.alert-row:last-child { border-bottom: none; }

/* ── Graveyard ──────────────────────────────────────────────────── */

.grave-card {
  padding: 0.6rem 0;
  border-bottom: 1px solid var(--border);
}
.grave-card:last-child { border-bottom: none; }
.grave-meta { font-size: 0.75rem; color: var(--text-muted); }
.grave-reason { font-size: 0.75rem; color: var(--negative); margin-top: 0.15rem; }

/* ── Settings ───────────────────────────────────────────────────── */

.settings-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.6rem 0;
  border-bottom: 1px solid var(--border);
  font-size: 0.85rem;
}
.settings-row:last-child { border-bottom: none; }

.quick-links {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.link-btn {
  display: inline-block;
  padding: 0.5rem 1rem;
  background: var(--bg-card-hover);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--accent);
  text-decoration: none;
  font-size: 0.8rem;
  font-weight: 500;
}
.link-btn:hover { background: rgba(245,158,11,0.1); }

/* ── Loading / Error ────────────────────────────────────────────── */

.loading-state, .error-state {
  text-align: center;
  padding: 3rem 1rem;
  color: var(--text-muted);
  font-size: 0.9rem;
}
.error-state { color: var(--negative); }

/* ── Canvas Charts ──────────────────────────────────────────────── */

canvas {
  width: 100%;
  height: 200px;
  border-radius: var(--radius);
}

/* ── Bottom Nav (mobile) ────────────────────────────────────────── */

.bottom-nav {
  display: none;
  position: fixed;
  bottom: 0; left: 0; right: 0;
  background: var(--bg-card);
  border-top: 1px solid var(--border);
  justify-content: space-around;
  padding: 0.4rem 0;
  padding-bottom: max(0.4rem, env(safe-area-inset-bottom));
  z-index: 100;
}

.bottom-nav-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.15rem;
  text-decoration: none;
  color: var(--text-muted);
  font-size: 0.65rem;
  padding: 0.3rem 0.5rem;
  min-width: 52px;
  transition: color 0.15s;
}
.bottom-nav-item.active { color: var(--accent); }
.bnav-icon { font-size: 1.1rem; }
.bnav-label { font-weight: 500; }

/* ── Responsive ─────────────────────────────────────────────────── */

@media (max-width: 768px) {
  .sidebar { display: none; }
  .bottom-nav { display: flex; }
  .main { padding: 1rem 0.75rem 5rem; }
  .header h1 { font-size: 1.25rem; }
  .stats-grid { gap: 0.5rem; }
  .stat-card { padding: 0.75rem; }
  .stat-value { font-size: 1.1rem; }
  .agent-grid { grid-template-columns: repeat(2, 1fr); }
  .games-grid { grid-template-columns: 1fr; }
}

@media (min-width: 769px) {
  .sidebar { display: flex; }
  .bottom-nav { display: none; }
  .main { padding: 2rem 2.5rem; }
  .stats-grid { grid-template-columns: repeat(4, 1fr); }
  .agent-grid { grid-template-columns: repeat(4, 1fr); }
}

@media (min-width: 1200px) {
  .agent-grid { grid-template-columns: repeat(7, 1fr); }
}
