/* base.css — shared across all pages: theme, nav, layout, and reusable
   components (cards, panels, pills, map, diagnostics). Page-specific styles
   live in their own file (dashboard.css, clients.css, location.css). */

:root {
  --green: #4ade80;
  --green-dark: #22c55e;
  --green-glow: rgba(74, 222, 128, 0.18);
  --violet: #8b7cf6;

  --bg: #0b0f1a;
  --bg-2: #0e1424;
  --surface: #141b2e;
  --surface-2: #1a2438;
  --text: #e8eef6;
  --muted: #8592a8;
  --border: #232f47;
  --red: #f87171;

  --shadow: 0 1px 2px rgba(0, 0, 0, 0.4), 0 14px 40px rgba(0, 0, 0, 0.4);
  --radius: 14px;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }

body {
  margin: 0;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  background:
    radial-gradient(1100px 500px at 85% -10%, rgba(139, 124, 246, 0.12), transparent 60%),
    radial-gradient(900px 500px at 0% 0%, rgba(74, 222, 128, 0.07), transparent 55%),
    var(--bg);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
}

/* Top nav */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 24px;
  background: rgba(14, 20, 36, 0.72);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
  position: sticky; top: 0; z-index: 10;
}
.nav { display: flex; align-items: center; gap: 6px; }
.nav-item {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 14px;
  border-radius: 10px;
  font-size: 14px;
  font-weight: 600;
  color: var(--muted);
  text-decoration: none;
  transition: background 0.15s ease, color 0.15s ease;
}
.nav-item:hover { color: var(--text); background: var(--surface-2); }
.nav-item.is-active { color: var(--green); background: rgba(74, 222, 128, 0.1); }
.nav-ic { display: inline-flex; }

.topbar-right { display: flex; align-items: center; gap: 12px; }
.conn-dot { width: 10px; height: 10px; border-radius: 50%; background: var(--muted); }
.conn-dot[data-state="connecting"] { background: #fbbf24; animation: pulse 1.2s ease-in-out infinite; }
.conn-dot[data-state="online"] { background: var(--green); box-shadow: 0 0 0 4px var(--green-glow); }
.conn-dot[data-state="offline"] { background: var(--red); }
@keyframes pulse { 50% { opacity: 0.35; } }

/* Layout */
.container { max-width: 1080px; margin: 0 auto; padding: 30px 24px 56px; }
.container--wide { max-width: 1160px; }
.page-head {
  display: flex; align-items: flex-start; justify-content: space-between;
  gap: 16px; margin-bottom: 24px; flex-wrap: wrap;
}
.page-title { margin: 0 0 6px; font-size: 26px; font-weight: 800; letter-spacing: -0.01em; }
.subtitle { margin: 0; color: var(--muted); font-size: 14px; }
.foot { text-align: center; color: var(--muted); font-size: 12px; margin-top: 30px; }

/* Live badge (used by clients/location headers) */
.live-badge {
  display: inline-flex; align-items: center; gap: 7px;
  font-size: 12px; font-weight: 700; color: var(--green);
  background: rgba(74, 222, 128, 0.1);
  border: 1px solid rgba(74, 222, 128, 0.22);
  padding: 4px 11px; border-radius: 999px;
}
.live-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--green); animation: pulse 1.4s ease-in-out infinite; }
.live-badge.is-off { color: var(--muted); background: rgba(133,146,168,0.12); border-color: var(--border); }
.live-badge.is-off .live-dot { background: var(--muted); animation: none; }

/* Pills (shared) */
.pill {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 4px 11px; border-radius: 999px;
  font-size: 12px; font-weight: 700;
}
.pill::before { content: ""; width: 8px; height: 8px; border-radius: 50%; }
.pill--active { background: rgba(74, 222, 128, 0.14); color: var(--green); }
.pill--active::before { background: var(--green); box-shadow: 0 0 0 3px rgba(74,222,128,0.22); }

/* Reusable panel + diagnostics list (used by location page + sidebars) */
.cam-panel {
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 16px;
}
.cam-panel-title { margin: 0 0 12px; font-size: 12px; text-transform: uppercase; letter-spacing: 0.7px; color: var(--muted); }
.cam-diag { margin: 0; display: grid; gap: 10px; }
.diag-row { display: flex; align-items: center; justify-content: space-between; gap: 10px; font-size: 13px; }
.diag-row dt { color: var(--muted); }
.diag-row dd { margin: 0; font-weight: 700; color: var(--green); }

/* Reusable button (used by sidebar consent block + location) */
.cam-btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  background: var(--bg-2);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 11px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s ease, border-color 0.15s ease, color 0.15s ease;
}
.cam-btn:hover { background: var(--surface-2); border-color: var(--green); color: var(--green); }

/* Device chip + head-right (location header) */
.cam-head-right { display: flex; align-items: center; gap: 12px; }
.device-chip {
  display: inline-flex; align-items: center; gap: 7px;
  font-size: 13px; font-weight: 600;
  color: var(--muted);
  background: var(--surface-2);
  border: 1px solid var(--border);
  padding: 7px 14px; border-radius: 999px;
}
.device-chip.is-online { color: var(--text); }
.device-chip.is-online::before {
  content: ""; width: 8px; height: 8px; border-radius: 50%;
  background: var(--green); box-shadow: 0 0 0 3px var(--green-glow);
}

/* Map + location detail/history (used by location page + configure sidebar) */
.loc-status {
  font-size: 12px; font-weight: 700; color: var(--green);
  background: rgba(74,222,128,0.1); border: 1px solid rgba(74,222,128,0.25);
  padding: 4px 10px; border-radius: 999px;
}
.loc-status.is-off { color: var(--muted); background: rgba(133,146,168,0.12); border-color: var(--border); }

.map-wrap {
  position: relative; aspect-ratio: 16 / 11;
  background: #05070c; border: 1px solid var(--border);
  border-radius: 12px; overflow: hidden; margin-bottom: 16px;
}
.map-wrap iframe { width: 100%; height: 100%; border: 0; display: block; }
.map-placeholder {
  position: absolute; inset: 0;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 8px; color: var(--muted); font-size: 14px; text-align: center; padding: 20px;
}
.map-placeholder small { font-size: 12px; opacity: 0.8; max-width: 280px; }
.map-ic { font-size: 34px; opacity: 0.5; }

.loc-history { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.history-item {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  padding: 10px 12px; border-radius: 9px;
  background: var(--bg-2); border: 1px solid var(--border); font-size: 13px;
}
.history-time { color: var(--muted); }
.history-coords { font-size: 12px; }
.history-coords.mono, .mono { font-family: ui-monospace, "SFMono-Regular", Menlo, Consolas, monospace; }
.history-empty { color: var(--muted); font-size: 13px; padding: 12px; text-align: center; }

@media (max-width: 640px) {
  .nav-item span:not(.nav-ic) { display: none; }
  .container { padding: 24px 14px 40px; }
}
