/* ═══════════════════════════════════════════════════════════
   Taxi RL Dashboard — Premium Dark-Mode Stylesheet
   ═══════════════════════════════════════════════════════════ */

/* ─── CSS Custom Properties ──────────────────────────────── */
:root {
  /* Backgrounds */
  --bg-base:      #080c14;
  --bg-surface:   #0d1117;
  --bg-elevated:  #161b22;
  --bg-card:      #1a2030;
  --bg-overlay:   rgba(22, 27, 34, 0.85);

  /* Brand accent palette */
  --accent-blue:  #58a6ff;
  --accent-green: #3fb950;
  --accent-red:   #f78166;
  --accent-purple:#d2a8ff;
  --accent-amber: #ffa657;
  --accent-cyan:  #39d0d8;

  /* Text */
  --text-primary:   #e6edf3;
  --text-secondary: #8b949e;
  --text-muted:     #484f58;

  /* Borders */
  --border-subtle: rgba(255,255,255,0.06);
  --border-default:rgba(255,255,255,0.12);

  /* Shadows */
  --shadow-sm: 0 1px 3px rgba(0,0,0,0.4);
  --shadow-md: 0 4px 16px rgba(0,0,0,0.5);
  --shadow-lg: 0 8px 40px rgba(0,0,0,0.6);
  --glow-blue: 0 0 20px rgba(88,166,255,0.25);
  --glow-green:0 0 20px rgba(63,185,80,0.25);

  /* Typography */
  --font-sans: 'Inter', system-ui, sans-serif;
  --font-mono: 'JetBrains Mono', 'Fira Code', monospace;

  /* Layout */
  --max-width: 1280px;
  --header-h:  64px;
  --radius-sm: 8px;
  --radius-md: 14px;
  --radius-lg: 20px;

  /* Transitions */
  --ease: cubic-bezier(0.16, 1, 0.3, 1);
  --dur: 0.25s;
}

/* ─── Reset ──────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { scroll-behavior: smooth; font-size: 16px; }
body {
  font-family: var(--font-sans);
  background: var(--bg-base);
  color: var(--text-primary);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}
a { color: var(--accent-blue); text-decoration: none; }
img { max-width: 100%; display: block; }
button { cursor: pointer; font-family: inherit; }
input, select { font-family: inherit; }

/* ─── Scrollbar ──────────────────────────────────────────── */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: var(--bg-surface); }
::-webkit-scrollbar-thumb { background: var(--bg-elevated); border-radius: 3px; }

/* ─── Container ──────────────────────────────────────────── */
.container { max-width: var(--max-width); margin: 0 auto; padding: 0 24px; }

/* ═══════════════════════════════════════════ HEADER ════════ */
.header {
  position: fixed;
  top: 0; left: 0; right: 0;
  height: var(--header-h);
  background: var(--bg-overlay);
  backdrop-filter: blur(20px) saturate(180%);
  border-bottom: 1px solid var(--border-subtle);
  z-index: 100;
  transition: background var(--dur) var(--ease);
}
.header-inner {
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 0 24px;
  height: 100%;
  display: flex;
  align-items: center;
  gap: 32px;
}
.logo { display: flex; align-items: center; gap: 10px; }
.logo-icon { font-size: 1.6rem; }
.logo-text { display: flex; flex-direction: column; line-height: 1.2; }
.logo-title { font-size: 1rem; font-weight: 700; color: var(--text-primary); }
.logo-subtitle { font-size: 0.7rem; font-weight: 400; color: var(--text-secondary); }

.nav {
  display: flex;
  gap: 4px;
  margin-left: auto;
}
.nav-link {
  padding: 6px 14px;
  border-radius: var(--radius-sm);
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--text-secondary);
  transition: all var(--dur) var(--ease);
}
.nav-link:hover, .nav-link.active {
  color: var(--text-primary);
  background: var(--bg-elevated);
}

.header-badge {
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 5px 12px;
  background: rgba(63,185,80,0.1);
  border: 1px solid rgba(63,185,80,0.25);
  border-radius: 999px;
  font-size: 0.75rem;
  font-weight: 500;
  color: var(--accent-green);
}
.badge-dot {
  width: 7px; height: 7px;
  border-radius: 50%;
  background: var(--accent-green);
  animation: pulse 2s ease-in-out infinite;
}
@keyframes pulse {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.5; transform: scale(0.8); }
}

/* ═══════════════════════════════════════════ HERO ══════════ */
.hero {
  position: relative;
  padding: calc(var(--header-h) + 72px) 0 80px;
  overflow: hidden;
}
.hero-bg {
  position: absolute;
  inset: 0;
  background:
    radial-gradient(ellipse 70% 60% at 50% 0%, rgba(88,166,255,0.1) 0%, transparent 70%),
    radial-gradient(ellipse 40% 40% at 80% 60%, rgba(63,185,80,0.07) 0%, transparent 60%);
  pointer-events: none;
}
.hero-title {
  font-size: clamp(2rem, 4vw, 3.2rem);
  font-weight: 700;
  line-height: 1.2;
  margin-bottom: 16px;
  letter-spacing: -0.02em;
}
.gradient-text {
  background: linear-gradient(135deg, var(--accent-blue) 0%, var(--accent-cyan) 50%, var(--accent-green) 100%);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
}
.hero-subtitle {
  font-size: 1.1rem;
  color: var(--text-secondary);
  max-width: 620px;
  margin-bottom: 48px;
  line-height: 1.7;
}

/* ─── Metric Cards ───────────────────────────────────────── */
.metric-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
  gap: 16px;
}
.metric-card {
  background: var(--bg-elevated);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 24px 20px;
  text-align: center;
  transition: all var(--dur) var(--ease);
  position: relative;
  overflow: hidden;
}
.metric-card::before {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(135deg, rgba(255,255,255,0.03) 0%, transparent 100%);
  pointer-events: none;
}
.metric-card:hover {
  border-color: var(--border-default);
  transform: translateY(-3px);
  box-shadow: var(--shadow-md);
}
.metric-icon { font-size: 1.5rem; margin-bottom: 8px; }
.metric-value {
  font-size: 1.8rem;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  color: var(--accent-blue);
  line-height: 1;
  margin-bottom: 6px;
}
.metric-label {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text-primary);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}
.metric-sub {
  font-size: 0.72rem;
  color: var(--text-muted);
  margin-top: 2px;
}

/* ═══════════════════════════════════════════ SECTIONS ══════ */
.section {
  padding: 80px 0;
  border-top: 1px solid var(--border-subtle);
}
.section-title {
  font-size: 1.75rem;
  font-weight: 700;
  margin-bottom: 12px;
  letter-spacing: -0.01em;
}
.section-sub {
  color: var(--text-secondary);
  margin-bottom: 36px;
  font-size: 1rem;
}

/* ─── Algorithm Cards ────────────────────────────────────── */
.algo-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 20px;
  margin-top: 32px;
}
.algo-card {
  background: var(--bg-elevated);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 28px 24px;
  transition: all var(--dur) var(--ease);
}
.algo-card:hover {
  border-color: rgba(88,166,255,0.3);
  box-shadow: var(--glow-blue);
  transform: translateY(-2px);
}
.algo-num {
  font-size: 0.72rem;
  font-weight: 700;
  color: var(--accent-blue);
  letter-spacing: 0.1em;
  margin-bottom: 10px;
}
.algo-card h3 {
  font-size: 1rem;
  font-weight: 600;
  margin-bottom: 8px;
}
.algo-card p {
  font-size: 0.875rem;
  color: var(--text-secondary);
  line-height: 1.6;
  margin-bottom: 14px;
}
.algo-code {
  display: block;
  font-family: var(--font-mono);
  font-size: 0.78rem;
  color: var(--accent-cyan);
  background: rgba(57, 208, 216, 0.07);
  border: 1px solid rgba(57, 208, 216, 0.15);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  word-break: break-all;
}

/* ─── Hyperparameter Grid ────────────────────────────────── */
.hp-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 16px;
  margin-top: 24px;
}
.hp-card {
  background: var(--bg-elevated);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 20px;
}
.hp-key {
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  margin-bottom: 6px;
}
.hp-val {
  font-size: 1.4rem;
  font-weight: 700;
  font-family: var(--font-mono);
  color: var(--accent-amber);
}
.hp-desc {
  font-size: 0.78rem;
  color: var(--text-muted);
  margin-top: 4px;
}
.hp-skeleton {
  height: 96px;
  background: linear-gradient(90deg, var(--bg-elevated) 25%, var(--bg-card) 50%, var(--bg-elevated) 75%);
  background-size: 200% 100%;
  animation: shimmer 1.5s infinite;
  border-radius: var(--radius-md);
}
@keyframes shimmer {
  0%   { background-position: -200% 0; }
  100% { background-position:  200% 0; }
}

/* ─── Chart Cards ────────────────────────────────────────── */
.charts-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
  margin-top: 32px;
}
@media (max-width: 900px) { .charts-grid { grid-template-columns: 1fr; } }
.chart-card {
  background: var(--bg-elevated);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 24px;
  grid-column: span 2;
}
.chart-card.half { grid-column: span 1; }
@media (max-width: 900px) { .chart-card.half { grid-column: span 1; } }
.chart-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 20px;
  flex-wrap: wrap;
  gap: 12px;
}
.chart-header h3 {
  font-size: 1rem;
  font-weight: 600;
}
.chart-controls {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 0.8rem;
  color: var(--text-secondary);
}
.chart-controls input[type="range"] {
  accent-color: var(--accent-blue);
  width: 120px;
}
.chart-wrapper {
  position: relative;
  height: 280px;
}
.chart-card.half .chart-wrapper { height: 220px; }

/* ─── Evaluation Table ───────────────────────────────────── */
.eval-grid {
  display: grid;
  grid-template-columns: 1fr 300px;
  gap: 24px;
  margin-top: 32px;
  align-items: start;
}
@media (max-width: 800px) { .eval-grid { grid-template-columns: 1fr; } }
.eval-table-wrap {
  overflow-x: auto;
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  max-height: 440px;
  overflow-y: auto;
}
.eval-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.875rem;
}
.eval-table thead {
  position: sticky;
  top: 0;
  background: var(--bg-card);
  z-index: 2;
}
.eval-table th {
  padding: 12px 16px;
  text-align: left;
  font-weight: 600;
  color: var(--text-secondary);
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  border-bottom: 1px solid var(--border-subtle);
}
.eval-table td {
  padding: 10px 16px;
  border-bottom: 1px solid var(--border-subtle);
  font-variant-numeric: tabular-nums;
}
.eval-table tbody tr:hover { background: rgba(255,255,255,0.03); }
.eval-table .success-yes { color: var(--accent-green); font-weight: 600; }
.eval-table .success-no  { color: var(--accent-red); }
.loading-cell { text-align: center; padding: 40px; color: var(--text-muted); }

.eval-stats {
  background: var(--bg-elevated);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 24px;
}
.stat-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 0;
  border-bottom: 1px solid var(--border-subtle);
}
.stat-row:last-child { border-bottom: none; }
.stat-key { font-size: 0.82rem; color: var(--text-secondary); }
.stat-val { font-family: var(--font-mono); font-size: 0.95rem; font-weight: 600; color: var(--text-primary); }

/* ─── Q-Table Explorer ───────────────────────────────────── */
.explorer-grid {
  display: grid;
  grid-template-columns: 260px 1fr 260px;
  gap: 24px;
  margin-top: 32px;
  align-items: start;
}
@media (max-width: 1000px) { .explorer-grid { grid-template-columns: 1fr; } }

.input-group { margin-bottom: 20px; }
.input-group label {
  display: block;
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin-bottom: 8px;
}
.input-row { display: flex; gap: 8px; margin-bottom: 8px; }
input[type="number"], select {
  background: var(--bg-card);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  padding: 8px 12px;
  font-size: 0.9rem;
  width: 100%;
  outline: none;
  transition: border-color var(--dur) var(--ease);
}
input[type="number"]:focus, select:focus { border-color: var(--accent-blue); }
input[type="range"] {
  width: 100%;
  accent-color: var(--accent-blue);
}

.decoded-state {
  background: var(--bg-elevated);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  overflow: hidden;
}
.decode-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 16px;
  border-bottom: 1px solid var(--border-subtle);
}
.decode-row:last-child { border-bottom: none; }
.decode-row.highlight { background: rgba(88,166,255,0.08); }
.decode-key { font-size: 0.8rem; color: var(--text-secondary); }
.decode-val { font-family: var(--font-mono); font-size: 0.9rem; font-weight: 600; color: var(--text-primary); }
.decode-row.highlight .decode-val { color: var(--accent-blue); }

.q-bars-wrap {
  background: var(--bg-elevated);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 20px;
}
.q-bars { display: flex; flex-direction: column; gap: 12px; }
.q-bar-item { }
.q-bar-header {
  display: flex;
  justify-content: space-between;
  margin-bottom: 4px;
  font-size: 0.8rem;
}
.q-bar-name { color: var(--text-secondary); }
.q-bar-val  { font-family: var(--font-mono); font-weight: 600; }
.q-bar-track {
  height: 8px;
  background: var(--bg-card);
  border-radius: 4px;
  overflow: hidden;
}
.q-bar-fill {
  height: 100%;
  border-radius: 4px;
  transition: width 0.4s var(--ease), background 0.3s;
}

/* ─── Taxi Grid ──────────────────────────────────────────── */
.taxi-grid-wrap {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
}
.taxi-grid {
  display: grid;
  grid-template-columns: repeat(5, 48px);
  grid-template-rows:    repeat(5, 48px);
  gap: 4px;
  padding: 12px;
  background: var(--bg-elevated);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
}
.taxi-grid.large {
  grid-template-columns: repeat(5, 60px);
  grid-template-rows:    repeat(5, 60px);
}
.taxi-cell {
  border-radius: 8px;
  background: var(--bg-card);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.2rem;
  border: 1px solid var(--border-subtle);
  transition: all 0.2s var(--ease);
  position: relative;
}
.taxi-cell.has-taxi   { background: rgba(88,166,255,0.15); border-color: var(--accent-blue); }
.taxi-cell.has-pass   { background: rgba(63,185,80,0.15);  border-color: var(--accent-green); }
.taxi-cell.has-dest   { background: rgba(247,129,102,0.15); border-color: var(--accent-red); }
.taxi-cell.special    { border-color: rgba(255,255,255,0.15); }
.taxi-cell .cell-label {
  position: absolute;
  bottom: 2px; right: 4px;
  font-size: 0.55rem;
  font-weight: 700;
  color: var(--text-muted);
  font-family: var(--font-mono);
}
.taxi-legend {
  display: flex;
  gap: 16px;
  font-size: 0.78rem;
  color: var(--text-secondary);
}
.legend-item { display: flex; align-items: center; gap: 6px; }
.legend-dot {
  width: 10px; height: 10px;
  border-radius: 50%;
}
.legend-dot.taxi        { background: var(--accent-blue); }
.legend-dot.passenger   { background: var(--accent-green); }
.legend-dot.destination { background: var(--accent-red); }

/* ─── Replay ─────────────────────────────────────────────── */
.replay-grid {
  display: grid;
  grid-template-columns: 240px 1fr 260px;
  gap: 24px;
  margin-top: 32px;
  align-items: start;
}
@media (max-width: 1000px) { .replay-grid { grid-template-columns: 1fr; } }
.ep-select {
  width: 100%;
  margin-bottom: 12px;
  padding: 9px 12px;
}
.replay-buttons {
  display: flex;
  gap: 8px;
  margin-bottom: 16px;
}
.replay-progress {
  background: var(--bg-elevated);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  padding: 14px;
  font-size: 0.85rem;
  line-height: 1.8;
}
.replay-progress div { color: var(--text-secondary); }
.replay-progress div strong { color: var(--text-primary); }
.replay-main {
  display: flex;
  justify-content: center;
  align-items: flex-start;
}
.replay-log {
  background: var(--bg-elevated);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  overflow: hidden;
  max-height: 420px;
  display: flex;
  flex-direction: column;
}
.log-header {
  padding: 12px 16px;
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  border-bottom: 1px solid var(--border-subtle);
  background: var(--bg-card);
}
.log-body {
  overflow-y: auto;
  flex: 1;
  padding: 8px 0;
}
.log-entry {
  padding: 6px 14px;
  font-size: 0.78rem;
  font-family: var(--font-mono);
  color: var(--text-secondary);
  border-bottom: 1px solid var(--border-subtle);
  transition: background 0.2s;
}
.log-entry.current { background: rgba(88,166,255,0.1); color: var(--accent-blue); }
.log-entry:last-child { border-bottom: none; }

/* ─── Buttons ────────────────────────────────────────────── */
.btn {
  padding: 8px 16px;
  border-radius: var(--radius-sm);
  font-size: 0.875rem;
  font-weight: 600;
  border: none;
  transition: all var(--dur) var(--ease);
  display: inline-flex;
  align-items: center;
  gap: 6px;
  white-space: nowrap;
}
.btn:disabled { opacity: 0.4; cursor: not-allowed; }
.btn-primary {
  background: var(--accent-blue);
  color: #000;
}
.btn-primary:hover:not(:disabled) {
  background: #79b8ff;
  box-shadow: var(--glow-blue);
}
.btn-secondary {
  background: var(--bg-card);
  color: var(--text-primary);
  border: 1px solid var(--border-default);
}
.btn-secondary:hover:not(:disabled) {
  background: var(--bg-elevated);
  border-color: var(--border-default);
}

/* ─── Footer ─────────────────────────────────────────────── */
.footer {
  border-top: 1px solid var(--border-subtle);
  padding: 40px 0;
  text-align: center;
  color: var(--text-muted);
  font-size: 0.875rem;
}
.footer strong { color: var(--text-secondary); }
.footer code {
  font-family: var(--font-mono);
  font-size: 0.82rem;
  background: var(--bg-elevated);
  padding: 2px 7px;
  border-radius: 4px;
  color: var(--accent-cyan);
}
.footer-sub { margin-top: 6px; font-size: 0.8rem; }

/* ─── Animations ─────────────────────────────────────────── */
@keyframes fadeInUp {
  from { opacity: 0; transform: translateY(20px); }
  to   { opacity: 1; transform: translateY(0); }
}
.metric-card { animation: fadeInUp 0.5s var(--ease) both; }
.metric-card:nth-child(1) { animation-delay: 0.05s; }
.metric-card:nth-child(2) { animation-delay: 0.10s; }
.metric-card:nth-child(3) { animation-delay: 0.15s; }
.metric-card:nth-child(4) { animation-delay: 0.20s; }
.metric-card:nth-child(5) { animation-delay: 0.25s; }
.metric-card:nth-child(6) { animation-delay: 0.30s; }
