/* Frosty Fleet Vehicle Rentals — component styles (mobile-first, dark).
 * Consumes tokens from tokens.css; no raw color / spacing / type values here.
 */

/* ── Base ───────────────────────────────────────────────────────── */
* { box-sizing: border-box; }
[hidden] { display: none !important; }  /* `hidden` must beat any `display:` rule (login overlay, drawers, panels) */
html, body { margin: 0; height: 100%; }
body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  display: flex;
  flex-direction: column;
  height: 100dvh;
}

/* ── Top bar ────────────────────────────────────────────────────── */
.topbar {
  display: flex; align-items: baseline; justify-content: space-between;
  padding: var(--s3) var(--s4);
  background: var(--panel); border-bottom: 1px solid var(--line);
}
.topbar h1 { display: flex; align-items: center; gap: var(--s2); font-size: var(--fs-2xl); margin: 0; }
.topbar h1 .brand { color: var(--brand); }
.flame { width: 1.1em; height: 1.1em; color: var(--accent); flex: none; }
.topbar .muted { color: var(--text-dim); font-size: var(--fs-sm); }

/* ── Map ────────────────────────────────────────────────────────── */
#map { flex: 1 1 55vh; min-height: 280px; background: var(--map-bg); }

/* MapLibre GL popup + controls (dark theme) */
.maplibregl-popup-content {
  background: var(--panel); color: var(--text);
  border: 1px solid var(--line); border-radius: var(--radius);
  padding: var(--s2) var(--s3); font-family: var(--font);
  box-shadow: 0 4px 16px rgba(0, 0, 0, .4);
}
.maplibregl-popup-tip { border-top-color: var(--panel); border-bottom-color: var(--panel); }
.maplibregl-popup-close-button { color: var(--text-dim); }
.maplibregl-ctrl-attrib { background: var(--panel); color: var(--text-dim); font-size: var(--fs-xs); }
.maplibregl-ctrl-attrib a { color: var(--text-dim); }
.maplibregl-ctrl-group button { background: var(--panel); border: 0; }
.maplibregl-ctrl-group button:hover { background: var(--raised); }
.maplibregl-ctrl-group button .maplibregl-ctrl-icon { filter: invert(1); }

/* ── List ───────────────────────────────────────────────────────── */
.list { overflow-y: auto; padding: var(--s3); }
.card {
  display: flex; align-items: center; gap: var(--s3);
  background: var(--panel); border: 1px solid var(--line);
  border-radius: var(--radius); padding: var(--s3) var(--s4); margin-bottom: var(--s2);
}
.card:active { background: var(--raised); }
.dot { width: 10px; height: 10px; border-radius: 50%; flex: none; }
.dot.online { background: var(--ok); }
.dot.asleep { background: var(--warn); }
.dot.offline, .dot.unknown { background: var(--muted); }
.card .meta { flex: 1; min-width: 0; }
.card .name { font-weight: 600; }
.card .sub { color: var(--text-dim); font-size: var(--fs-sm); }
.badge { font-size: var(--fs-xs); padding: var(--s1) var(--s2); border-radius: 999px; flex: none; }
.badge.rental { background: var(--rental-bg); color: var(--rental); }
.battery { font-size: var(--fs-sm); color: var(--text-dim); flex: none; }

/* ── Popup ──────────────────────────────────────────────────────── */
.popup-name { font-weight: 600; }
.popup-sub { color: var(--text-dim); font-size: var(--fs-sm); }

/* ── Detail drawer ──────────────────────────────────────────────── */
.drawer {
  position: fixed; left: 0; right: 0; bottom: 0;
  background: var(--panel); border-top: 1px solid var(--line);
  border-radius: 16px 16px 0 0; padding: 0;
  max-height: 72vh; overflow-y: auto; z-index: 1100;
}
.drawer-head {
  position: sticky; top: 0; z-index: 2;
  display: flex; align-items: center; justify-content: space-between;
  background: var(--raised);
  border-bottom: 1px solid var(--line);
  padding: var(--s3) var(--s4);
}
.drawer-body {
  padding: var(--s4);
}
.drawer-head h2 {
  margin: 0; font-size: var(--fs-xl); font-weight: 700;
  text-transform: uppercase; letter-spacing: .04em; color: var(--text);
}
.drawer-title { display: flex; align-items: center; gap: var(--s3); min-width: 0; }
.drawer-title-text { min-width: 0; }
.drawer-sub { color: var(--text-dim); font-size: var(--fs-sm); margin-top: 2px; }
.vehicle-img {
  width: 56px; height: 56px; object-fit: cover; border-radius: var(--radius);
  border: 1px solid var(--line); flex: none;
}
.ghost { background: none; border: 0; color: var(--text-dim); font-size: var(--fs-3xl); cursor: pointer; }
.row { display: flex; justify-content: space-between; padding: var(--s2) 0; border-bottom: 1px solid var(--line); font-size: var(--fs-md); }
.row .k { color: var(--text-dim); }
.btn {
  width: 100%; margin-top: var(--s4); padding: var(--s3);
  background: var(--accent); color: var(--on-accent); border: 0; border-radius: var(--radius);
  font-size: var(--fs-lg); font-weight: 600;
}
.btn:disabled { background: var(--raised); color: var(--muted); }
.btn:hover:not(:disabled) { background: var(--accent-strong); }
.btn.secondary { background: transparent; border: 1px solid var(--line); color: var(--text); margin-top: var(--s2); }
.btn.secondary:hover:not(:disabled) { background: var(--raised); }

/* ── Toast ──────────────────────────────────────────────────────── */
.toast {
  position: fixed; left: 50%; bottom: var(--s5); transform: translateX(-50%);
  background: var(--raised); border: 1px solid var(--line);
  padding: var(--s3) var(--s4); border-radius: var(--radius);
  font-size: var(--fs-md); z-index: 1200; max-width: 90vw;
}
.toast.error { border-color: var(--danger); color: var(--danger); }

/* ── Commands ───────────────────────────────────────────────────── */
.commands { margin-top: var(--s4); border-top: 1px solid var(--line); padding-top: var(--s3); }
.commands h3 {
  margin: 0 0 var(--s2); font-size: var(--fs-sm); color: var(--text-dim);
  text-transform: uppercase; letter-spacing: .05em;
}
.cmd-note { margin: 0 0 var(--s2); color: var(--warn); font-size: var(--fs-sm); }
.cmd-group { margin-bottom: var(--s2); }
.cmd-group-head {
  width: 100%; text-align: left; background: var(--raised); border: 0;
  color: var(--text); padding: var(--s2) var(--s3); border-radius: var(--radius);
  font-size: var(--fs-md); font-weight: 600;
  display: flex; justify-content: space-between; align-items: center; cursor: pointer;
}
.cmd-group-head::after { content: "▾"; color: var(--text-dim); font-size: var(--fs-sm); }
.cmd-group-body { padding: var(--s2) 0 0 var(--s2); }
.cmd-row { margin-bottom: var(--s2); }
.btn.cmd-trigger {
  margin-top: 0; display: flex; align-items: center; justify-content: space-between; gap: var(--s2);
  background: var(--raised); border: 1px solid var(--line); color: var(--text);
  text-align: left; padding: var(--s3); border-radius: var(--radius);
  font-size: var(--fs-md); font-weight: 600;
}
.btn.cmd-trigger:hover:not(:disabled) { border-color: var(--accent); background: var(--panel); }
.btn.cmd-trigger.sending { opacity: .6; cursor: progress; }
.btn.secondary:disabled, .cmd-trigger:disabled {
  background: var(--panel); color: var(--muted); border-color: var(--line); opacity: .6; cursor: not-allowed;
}
.chev { color: var(--text-dim); }
.badge.owner { background: var(--raised); color: var(--text-dim); border: 1px solid var(--line); }
.cmd-hint { color: var(--text-dim); font-size: var(--fs-xs); margin-top: var(--s1); }
.cmd-error { color: var(--danger); font-size: var(--fs-xs); margin-top: var(--s1); font-weight: 600; }
.cmd-params {
  margin-top: var(--s2); padding: var(--s3); background: var(--panel);
  border: 1px solid var(--line); border-radius: var(--radius);
}
.field {
  display: flex; align-items: center; justify-content: space-between; gap: var(--s3);
  padding: var(--s2) 0; border-bottom: 1px solid var(--line);
}
.field:last-child { border-bottom: 0; }
.field-label { color: var(--text); font-size: var(--fs-md); flex: 1; min-width: 0; }
.field-label .hint { display: block; color: var(--text-dim); font-style: normal; font-size: var(--fs-xs); }
.field-input {
  background: var(--raised); border: 1px solid var(--line); color: var(--text);
  border-radius: var(--radius); padding: var(--s2) var(--s3); font-size: var(--fs-md);
  flex: 0 1 55%; min-width: 0;
}
.field-input:focus { outline: none; border-color: var(--accent); }
input[type="checkbox"].field-input { flex: none; width: 18px; height: 18px; padding: 0; }
.cmd-params .btn.send { margin-top: var(--s3); }

/* ── Auth / topbar ──────────────────────────────────────────────── */
.topbar-right { display: flex; align-items: center; gap: var(--s3); }
.topbar .ghost {
  color: var(--text-dim); font-size: var(--fs-sm); cursor: pointer;
  padding: var(--s1) var(--s2); border-radius: var(--radius); border: 0; background: none;
}
.topbar .ghost:hover { background: var(--raised); color: var(--text); }
a.btn { display: block; text-align: center; text-decoration: none; box-sizing: border-box; }

/* ── Login ──────────────────────────────────────────────────────── */
.login {
  position: fixed; inset: 0; background: var(--bg); z-index: 2000;
  display: flex; align-items: center; justify-content: center; padding: var(--s4);
  overflow: hidden;
}
.login-bg {
  position: absolute; inset: -24px; pointer-events: none;
  background-size: cover; background-position: center;
  filter: blur(10px) brightness(.32) saturate(.9);
  transform: scale(1.12);
  transition: transform .25s ease-out;
}
.login-card {
  position: relative;
  width: 100%; max-width: 360px; background: var(--panel); border: 1px solid var(--line);
  border-radius: var(--radius); padding: var(--s5); text-align: center;
}
.login-brand { display: flex; align-items: center; justify-content: center; gap: var(--s2); font-size: var(--fs-2xl); font-weight: 700; }
.login-brand .brand { color: var(--brand); }
.login-app { margin-top: var(--s2); font-size: var(--fs-md); font-weight: 600; color: var(--text-dim); text-transform: uppercase; letter-spacing: .14em; }
.dev-login { margin-top: var(--s4); border-top: 1px solid var(--line); padding-top: var(--s3); text-align: left; }
.dev-login h3 { font-size: var(--fs-sm); color: var(--text-dim); text-transform: uppercase; letter-spacing: .05em; }
.dev-user { margin-top: var(--s2); }

/* ── In-UI modal (replaces browser confirm) ─────────────────────── */
.modal-backdrop {
  position: fixed; inset: 0; z-index: 4000;
  display: flex; align-items: center; justify-content: center;
  background: rgba(0, 0, 0, .55); padding: var(--s4);
}
.modal {
  width: 100%; max-width: 340px; background: var(--panel);
  border: 1px solid var(--line); border-radius: var(--radius);
  padding: var(--s4); box-shadow: 0 8px 32px rgba(0, 0, 0, .5);
}
.modal-text { margin: 0 0 var(--s4); font-size: var(--fs-md); line-height: 1.45; }
.modal-actions { display: flex; gap: var(--s2); }
.modal-actions .btn { margin-top: 0; flex: 1; }

/* ── Notifications ──────────────────────────────────────────────── */
.notifications {
  position: fixed; top: var(--s4); right: var(--s4); z-index: 3000;
  display: flex; flex-direction: column; gap: var(--s2); max-width: 90vw;
}
.notification {
  background: var(--raised); border: 1px solid var(--line); color: var(--text);
  padding: var(--s3) var(--s4); border-radius: var(--radius); font-size: var(--fs-md);
  box-shadow: 0 4px 16px rgba(0, 0, 0, .4);
}
.notification--success { border-color: var(--ok); }
.notification--error { border-color: var(--danger); color: var(--danger); }
.notification--pending { border-color: var(--warn); color: var(--warn); }
.notification--info { border-color: var(--accent); }

/* ── Settings ───────────────────────────────────────────────────── */
.settings-section { margin-top: var(--s4); border-top: 1px solid var(--line); padding-top: var(--s3); }
.settings-section h3 {
  margin: 0 0 var(--s2); font-size: var(--fs-sm); color: var(--text-dim);
  text-transform: uppercase; letter-spacing: .05em;
}
.users-list { margin-bottom: var(--s3); }
.user-row {
  display: flex; align-items: center; gap: var(--s2);
  padding: var(--s2) 0; border-bottom: 1px solid var(--line);
}
.user-meta { flex: 1; min-width: 0; }
.user-name { font-weight: 600; display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.user-email { color: var(--text-dim); font-size: var(--fs-xs); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; display: block; }
.user-row .field-input { flex: none; width: auto; padding: var(--s1) var(--s2); }
.user-row .btn.secondary { width: auto; margin-top: 0; padding: var(--s1) var(--s3); font-size: var(--fs-sm); }
.user-add { display: flex; flex-direction: column; gap: var(--s2); margin-top: var(--s2); }

/* ── Activity feed ──────────────────────────────────────────────── */
.activity-row { padding: var(--s3) 0; border-bottom: 1px solid var(--line); }
.activity-top { display: flex; justify-content: space-between; gap: var(--s3); }
.activity-cmd { font-weight: 600; }
.activity-result { font-size: var(--fs-sm); }
.activity-result.success { color: var(--ok); }
.activity-result.failed, .activity-result.error, .activity-result.refused { color: var(--danger); }
.activity-sub { color: var(--text-dim); font-size: var(--fs-xs); margin-top: var(--s1); }
.activity-reason { color: var(--text-dim); font-size: var(--fs-sm); margin-top: var(--s1); }

/* ── Circular vehicle images (map marker + list/trip thumbnails) ──── */
.car-marker, .car-thumb, .trip-thumb {
  border-radius: 50%; overflow: hidden; flex: none; background: var(--panel);
}
.car-marker img, .car-thumb img, .trip-thumb img {
  width: 100%; height: 100%; object-fit: cover; display: block;
}
.car-marker { width: 34px; height: 34px; border: 3px solid var(--muted); }
.car-thumb { width: 40px; height: 40px; border: 3px solid var(--muted); }
.trip-thumb { width: 36px; height: 36px; }
.car-marker.online, .car-thumb.online { border-color: var(--ok); }
.car-marker.asleep, .car-thumb.asleep { border-color: var(--warn); }
.car-marker.offline, .car-marker.unknown,
.car-thumb.offline, .car-thumb.unknown { border-color: var(--muted); }
.car-marker.stale, .car-thumb.stale { opacity: .4; }

/* ── Trips ───────────────────────────────────────────────────────── */
.trip-section { margin-top: var(--s4); border-top: 1px solid var(--line); padding-top: var(--s3); }
.trip-section h3 {
  margin: 0 0 var(--s2); font-size: var(--fs-sm); color: var(--text-dim);
  text-transform: uppercase; letter-spacing: .05em;
}
.trip-row { display: flex; align-items: center; gap: var(--s3); padding: var(--s2) 0; border-bottom: 1px solid var(--line); }
.trip-meta { flex: 1; min-width: 0; }
.trip-name { font-weight: 600; }
.trip-when { color: var(--text-dim); font-size: var(--fs-xs); }
.trip-badge {
  font-size: var(--fs-xs); padding: var(--s1) var(--s2); border-radius: 999px; flex: none;
  background: var(--raised); color: var(--text-dim); text-transform: uppercase; letter-spacing: .04em;
}
.trip-empty { color: var(--text-dim); font-size: var(--fs-sm); }
