/* DriftNet Dashboard */

:root {
  --bg: #0a0a0f;
  --surface: #12121a;
  --surface2: #1a1a25;
  --border: #2a2a3a;
  --text: #e0e0e8;
  --text-dim: #888;
  --accent: #00ff88;
  --accent2: #00ccff;
  --danger: #ff4444;
  --warning: #ffaa00;
  --speed-slow: #00ff88;
  --speed-medium: #ffaa00;
  --speed-fast: #ff4444;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
}

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

/* ── Auth Gate ─────────────────────────────────────────────────── */

.gate {
  display: none;
  position: fixed; inset: 0;
  background: var(--bg);
  z-index: 1000;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  gap: 1rem;
}

.gate.open { display: flex; }

.gate h1 { font-size: 2rem; color: var(--accent); }
.gate p { color: var(--text-dim); }
.gate input {
  padding: 0.75rem 1rem;
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: 8px;
  font-size: 1rem;
  width: 300px;
}
.gate button {
  padding: 0.75rem 2rem;
  background: var(--accent);
  color: var(--bg);
  border: none;
  border-radius: 8px;
  font-weight: 600;
  cursor: pointer;
  font-size: 1rem;
}

/* ── Nav ───────────────────────────────────────────────────────── */

nav {
  display: flex;
  align-items: center;
  gap: 1.5rem;
  padding: 1rem 2rem;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  flex-wrap: wrap;
}

nav .logo {
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--accent);
  margin-right: 1rem;
}

nav a {
  color: var(--text-dim);
  font-weight: 500;
  padding: 0.25rem 0;
  border-bottom: 2px solid transparent;
  transition: all 0.2s;
}

nav a:hover, nav a.active {
  color: var(--accent);
  text-decoration: none;
  border-bottom-color: var(--accent);
}

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

.container { padding: 2rem; max-width: 1400px; margin: 0 auto; }

.grid {
  display: grid;
  gap: 1.5rem;
}

.grid-2 { grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); }
.grid-3 { grid-template-columns: repeat(auto-fit, minmax(250px, 1fr)); }
.grid-4 { grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); }

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

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 1.5rem;
}

.card h2 {
  font-size: 1rem;
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 1rem;
}

.card .big-number {
  font-size: 3rem;
  font-weight: 700;
  line-height: 1;
}

.card .label {
  font-size: 0.85rem;
  color: var(--text-dim);
  margin-top: 0.25rem;
}

/* ── Speed Gun ─────────────────────────────────────────────────── */

.speed-gun {
  text-align: center;
  padding: 3rem 2rem;
}

.speed-gun .speed-value {
  font-size: 8rem;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
  line-height: 1;
  transition: color 0.3s;
}

.speed-gun .speed-unit {
  font-size: 2rem;
  color: var(--text-dim);
  margin-top: 0.5rem;
}

.speed-gun .speed-meta {
  display: flex;
  justify-content: center;
  gap: 2rem;
  margin-top: 1rem;
  font-size: 1.1rem;
}

.speed-gun .speed-meta .direction {
  font-weight: 600;
}

.speed-slow { color: var(--speed-slow); }
.speed-medium { color: var(--speed-medium); }
.speed-fast { color: var(--speed-fast); }

/* ── Live Feed ─────────────────────────────────────────────────── */

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

.feed-item {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 0.75rem 0;
  border-bottom: 1px solid var(--border);
}

.feed-item:last-child { border-bottom: none; }

.feed-item .speed {
  font-size: 1.5rem;
  font-weight: 700;
  min-width: 80px;
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.feed-item .meta {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
}

.feed-item .direction-badge {
  padding: 0.15rem 0.5rem;
  border-radius: 4px;
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
}

.badge-inbound { background: rgba(0,204,255,0.15); color: var(--accent2); }
.badge-outbound { background: rgba(0,255,136,0.15); color: var(--accent); }

.feed-item .type-icon {
  font-size: 1.5rem;
  min-width: 2rem;
  text-align: center;
}

.feed-item .time {
  color: var(--text-dim);
  font-size: 0.85rem;
  min-width: 60px;
  text-align: right;
}

/* ── Node Array Visualization ──────────────────────────────────── */

.node-array {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  justify-content: center;
  padding: 2rem 0;
}

.node-dot {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 0.85rem;
  cursor: pointer;
  transition: transform 0.2s;
}

.node-dot:hover { transform: scale(1.2); }

.node-dot.online { background: var(--accent); color: var(--bg); }
.node-dot.degraded { background: var(--warning); color: var(--bg); }
.node-dot.offline { background: var(--danger); color: white; }

.node-wire {
  width: 40px;
  height: 2px;
  background: var(--border);
}

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

table {
  width: 100%;
  border-collapse: collapse;
}

th {
  text-align: left;
  padding: 0.75rem;
  color: var(--text-dim);
  font-weight: 500;
  font-size: 0.85rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  border-bottom: 1px solid var(--border);
}

td {
  padding: 0.75rem;
  border-bottom: 1px solid var(--border);
}

tr:hover td { background: rgba(255,255,255,0.02); }

/* ── Buttons ───────────────────────────────────────────────────── */

.btn {
  padding: 0.5rem 1rem;
  border: 1px solid var(--border);
  background: var(--surface2);
  color: var(--text);
  border-radius: 6px;
  cursor: pointer;
  font-size: 0.85rem;
  transition: all 0.2s;
}

.btn:hover { border-color: var(--accent); }
.btn-primary { background: var(--accent); color: var(--bg); border-color: var(--accent); font-weight: 600; }

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

.chart-container {
  position: relative;
  height: 300px;
}

/* ── Gallery ───────────────────────────────────────────────────── */

.gallery-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 1rem;
}

.gallery-item {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  overflow: hidden;
}

.gallery-item img {
  width: 100%;
  aspect-ratio: 16/9;
  object-fit: cover;
}

.gallery-item .caption {
  padding: 0.75rem;
  font-size: 0.85rem;
}

/* ── Heatmap ───────────────────────────────────────────────────── */

.heatmap {
  display: grid;
  grid-template-columns: 60px repeat(24, 1fr);
  gap: 2px;
}

.heatmap-cell {
  aspect-ratio: 1;
  border-radius: 3px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.65rem;
  color: transparent;
  transition: all 0.2s;
}

.heatmap-cell:hover {
  color: white;
  transform: scale(1.3);
  z-index: 1;
}

.heatmap-label {
  display: flex;
  align-items: center;
  font-size: 0.75rem;
  color: var(--text-dim);
}

.heatmap-hour {
  font-size: 0.65rem;
  color: var(--text-dim);
  text-align: center;
}

/* ── Leaderboard ───────────────────────────────────────────────── */

.leaderboard-item {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 1rem 0;
  border-bottom: 1px solid var(--border);
}

.leaderboard-rank {
  font-size: 1.5rem;
  font-weight: 800;
  color: var(--text-dim);
  min-width: 2rem;
}

.leaderboard-rank.gold { color: #ffd700; }
.leaderboard-rank.silver { color: #c0c0c0; }
.leaderboard-rank.bronze { color: #cd7f32; }

/* ── Status Dot ────────────────────────────────────────────────── */

.status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  display: inline-block;
  margin-right: 0.5rem;
}

.status-dot.green { background: var(--accent); }
.status-dot.yellow { background: var(--warning); }
.status-dot.red { background: var(--danger); }

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

@media (max-width: 768px) {
  .container { padding: 1rem; }
  .speed-gun .speed-value { font-size: 5rem; }
  nav { gap: 0.75rem; padding: 0.75rem 1rem; }
  .grid-4 { grid-template-columns: repeat(2, 1fr); }
}

/* ── WebSocket indicator ───────────────────────────────────────── */

.ws-status {
  position: fixed;
  bottom: 1rem;
  right: 1rem;
  padding: 0.5rem 1rem;
  border-radius: 20px;
  font-size: 0.75rem;
  font-weight: 600;
}

.ws-connected { background: rgba(0,255,136,0.15); color: var(--accent); }
.ws-disconnected { background: rgba(255,68,68,0.15); color: var(--danger); }
