/* =========================================================================
   GPS Tracker Pro — Design System
   Concept: instrument / control-room panel. Dark navy chassis, teal signal
   accent, monospace readouts for coordinates & speed (like a real GNSS unit).
   ========================================================================= */

@import url('https://fonts.googleapis.com/css2?family=Space+Grotesk:wght@500;600;700&family=Inter:wght@400;500;600;700&family=JetBrains+Mono:wght@400;500;600&display=swap');

:root {
  --bg: #0a0f1c;
  --panel: #111a2e;
  --panel-2: #16213b;
  --border: #223052;
  --text: #e7ecf5;
  --text-dim: #8c97b3;
  --accent: #00d9c0;
  --accent-dim: #0a9c8c;
  --accent-soft: rgba(0, 217, 192, 0.14);
  --warn: #ffb020;
  --danger: #ff5d6c;
  --danger-soft: rgba(255, 93, 108, 0.14);
  --radius-sm: 8px;
  --radius: 14px;
  --radius-lg: 20px;
  --shadow: 0 10px 30px rgba(0, 0, 0, 0.35);
  --font-display: 'Space Grotesk', system-ui, sans-serif;
  --font-body: 'Inter', system-ui, sans-serif;
  --font-mono: 'JetBrains Mono', ui-monospace, monospace;
  --sidebar-w: 240px;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  background: radial-gradient(ellipse at top left, #0d1526 0%, var(--bg) 55%);
  color: var(--text);
  font-family: var(--font-body);
  -webkit-font-smoothing: antialiased;
}
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3, .display { font-family: var(--font-display); letter-spacing: -0.01em; }
.mono { font-family: var(--font-mono); }
::selection { background: var(--accent-soft); color: var(--text); }

/* signature element: oscilloscope "signal strip" divider */
.signal-strip {
  height: 6px;
  width: 64px;
  background-image: repeating-linear-gradient(
    90deg, var(--accent) 0 3px, transparent 3px 8px
  );
  border-radius: 3px;
  margin: 6px 0 18px;
  opacity: .9;
}

/* =========================== App shell / nav =========================== */
.app-shell { display: flex; min-height: 100vh; }
.sidebar {
  width: var(--sidebar-w);
  flex-shrink: 0;
  background: linear-gradient(180deg, var(--panel) 0%, #0d1424 100%);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  padding: 20px 14px;
  position: sticky;
  top: 0;
  height: 100vh;
}
.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 4px 8px 18px;
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 17px;
}
.brand-dot {
  width: 12px; height: 12px; border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 0 0 rgba(0,217,192,.6);
  animation: pulse-dot 2.2s infinite;
}
@keyframes pulse-dot {
  0%   { box-shadow: 0 0 0 0 rgba(0,217,192,.55); }
  70%  { box-shadow: 0 0 0 9px rgba(0,217,192,0); }
  100% { box-shadow: 0 0 0 0 rgba(0,217,192,0); }
}
.nav-group { display: flex; flex-direction: column; gap: 2px; margin-top: 6px; }
.nav-link {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 12px; border-radius: var(--radius-sm);
  color: var(--text-dim); font-weight: 500; font-size: 14px;
}
.nav-link svg { width: 18px; height: 18px; flex-shrink: 0; }
.nav-link:hover { background: var(--panel-2); color: var(--text); text-decoration: none; }
.nav-link.active { background: var(--accent-soft); color: var(--accent); }
.nav-spacer { flex: 1; }
.nav-user {
  border-top: 1px solid var(--border);
  padding-top: 14px; margin-top: 8px;
  display: flex; align-items: center; gap: 10px; font-size: 13px;
}
.avatar {
  width: 30px; height: 30px; border-radius: 50%;
  background: var(--accent-soft); color: var(--accent);
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-family: var(--font-display); font-size: 13px;
}

.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.topbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 16px 24px; border-bottom: 1px solid var(--border);
  background: rgba(17, 26, 46, 0.6); backdrop-filter: blur(8px);
  position: sticky; top: 0; z-index: 20;
}
.topbar h1 { font-size: 18px; margin: 0; }
.content { padding: 24px; flex: 1; }

.hamburger { display: none; background: none; border: 1px solid var(--border); color: var(--text); border-radius: var(--radius-sm); padding: 8px 10px; cursor: pointer; }

/* =============================== Cards ================================== */
.card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  box-shadow: var(--shadow);
}
.card-glass {
  background: rgba(17, 26, 46, 0.72);
  backdrop-filter: blur(10px);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}
.card-title { font-family: var(--font-display); font-size: 15px; font-weight: 600; margin: 0 0 4px; }
.card-sub { color: var(--text-dim); font-size: 13px; margin: 0 0 14px; }

.grid { display: grid; gap: 16px; }
.grid-2 { grid-template-columns: repeat(2, 1fr); }
.grid-3 { grid-template-columns: repeat(3, 1fr); }
.grid-4 { grid-template-columns: repeat(4, 1fr); }

.stat { padding: 16px; }
.stat .label { color: var(--text-dim); font-size: 12px; text-transform: uppercase; letter-spacing: .06em; }
.stat .value { font-family: var(--font-mono); font-size: 22px; font-weight: 600; margin-top: 6px; }
.stat .value .unit { font-size: 12px; color: var(--text-dim); margin-left: 4px; }

/* =============================== Forms =================================== */
label { display: block; font-size: 13px; color: var(--text-dim); margin-bottom: 6px; font-weight: 500; }
input[type=text], input[type=password], input[type=email], input[type=date], input[type=number] {
  width: 100%; padding: 11px 13px; border-radius: var(--radius-sm);
  border: 1px solid var(--border); background: #0c1424; color: var(--text);
  font-family: var(--font-body); font-size: 14px; outline: none;
  transition: border-color .15s ease, box-shadow .15s ease;
}
input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.form-group { margin-bottom: 16px; }
.help-block { color: var(--danger); font-size: 12.5px; margin-top: 6px; display: block; }
.field-hint { color: var(--text-dim); font-size: 12px; margin-top: 6px; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 11px 18px; border-radius: var(--radius-sm); border: 1px solid transparent;
  font-weight: 600; font-size: 14px; cursor: pointer; font-family: var(--font-body);
  transition: transform .06s ease, filter .15s ease, background .15s ease;
}
.btn:active { transform: translateY(1px); }
.btn-primary { background: var(--accent); color: #04211d; }
.btn-primary:hover { filter: brightness(1.08); text-decoration: none; }
.btn-ghost { background: transparent; border-color: var(--border); color: var(--text); }
.btn-ghost:hover { background: var(--panel-2); text-decoration: none; }
.btn-danger { background: var(--danger-soft); color: var(--danger); border-color: rgba(255,93,108,.35); }
.btn-danger:hover { background: rgba(255,93,108,.22); text-decoration: none; }
.btn-block { width: 100%; }
.btn-sm { padding: 7px 12px; font-size: 13px; }

.alert { padding: 12px 14px; border-radius: var(--radius-sm); font-size: 13.5px; margin-bottom: 16px; border: 1px solid transparent; }
.alert-error { background: var(--danger-soft); color: #ffb3ba; border-color: rgba(255,93,108,.3); }
.alert-success { background: var(--accent-soft); color: var(--accent); border-color: rgba(0,217,192,.3); }

.badge { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; font-weight: 600; padding: 4px 10px; border-radius: 999px; }
.badge-live { background: var(--accent-soft); color: var(--accent); }
.badge-live .dot { width: 7px; height: 7px; border-radius: 50%; background: var(--accent); animation: pulse-dot 2s infinite; }

/* ================================ Table =================================== */
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th, td { text-align: left; padding: 12px 14px; border-bottom: 1px solid var(--border); }
th { color: var(--text-dim); font-weight: 600; font-size: 12.5px; text-transform: uppercase; letter-spacing: .04em; }
tr:hover td { background: rgba(255,255,255,0.02); }

/* ============================= Device list =============================== */
.device-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 10px; }
.device-row {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 16px; background: var(--panel-2); border: 1px solid var(--border); border-radius: var(--radius);
}
.device-name { display: flex; align-items: center; gap: 10px; font-weight: 600; }
.color-chip { width: 10px; height: 10px; border-radius: 50%; }

/* =============================== Auth pages ================================ */
.auth-wrap {
  min-height: 100vh; display: flex; align-items: center; justify-content: center;
  padding: 24px; position: relative; overflow: hidden;
}
.radar-bg {
  position: absolute; inset: 0; z-index: 0; opacity: .5;
  background:
    repeating-radial-gradient(circle at 50% 50%, transparent 0, transparent 70px, rgba(0,217,192,.06) 71px, transparent 72px);
  animation: radar-spin 18s linear infinite;
}
@keyframes radar-spin { from { transform: rotate(0deg); } to { transform: rotate(360deg); } }
.auth-card { position: relative; z-index: 1; width: 100%; max-width: 400px; padding: 32px; }
.auth-logo { display: flex; align-items: center; gap: 10px; margin-bottom: 6px; font-family: var(--font-display); font-weight: 700; font-size: 20px; }
.auth-foot { text-align: center; margin-top: 18px; font-size: 13.5px; color: var(--text-dim); }

/* =============================== Map page ================================== */
#map { width: 100%; height: 100%; background: #0c1424; }
.map-wrap { position: relative; flex: 1; min-height: 480px; border-radius: var(--radius); overflow: hidden; border: 1px solid var(--border); }
.map-floating { position: absolute; z-index: 500; }
.map-floating.top-left { top: 16px; left: 16px; max-width: 320px; }
.map-floating.top-right { top: 16px; right: 16px; max-width: 260px; }
.leaflet-popup-content-wrapper { background: var(--panel); color: var(--text); border-radius: var(--radius-sm); }
.leaflet-popup-tip { background: var(--panel); }
.popup-mono { font-family: var(--font-mono); font-size: 12.5px; line-height: 1.6; }

/* =============================== Utilities =================================== */
.flex { display: flex; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.gap-8 { gap: 8px; } .gap-12 { gap: 12px; } .gap-16 { gap: 16px; }
.mt-8{margin-top:8px;} .mt-16{margin-top:16px;} .mt-24{margin-top:24px;}
.text-dim { color: var(--text-dim); }
.text-sm { font-size: 13px; }
.empty-state { text-align: center; padding: 48px 20px; color: var(--text-dim); }
.empty-state svg { opacity: .5; margin-bottom: 12px; }

/* ============================== Responsive =================================== */
@media (max-width: 900px) {
  .sidebar {
    position: fixed; left: 0; top: 0; height: 100vh; z-index: 100;
    transform: translateX(-100%); transition: transform .2s ease;
  }
  .sidebar.open { transform: translateX(0); }
  .hamburger { display: inline-flex; }
  .grid-4 { grid-template-columns: repeat(2, 1fr); }
  .grid-3 { grid-template-columns: repeat(2, 1fr); }
  .grid-2 { grid-template-columns: 1fr; }
  .content { padding: 16px; }
  .topbar { padding: 12px 16px; }
}
@media (max-width: 560px) {
  .grid-4, .grid-3 { grid-template-columns: 1fr 1fr; }
  .auth-card { padding: 24px; }
}
@media (prefers-reduced-motion: reduce) {
  * { animation-duration: 0.001ms !important; animation-iteration-count: 1 !important; transition-duration: 0.001ms !important; }
}
