/*
 * Birdie Fleet — brand and layout foundation.
 *
 * Dark by default: this is a wall-display product. Operators keep it open for
 * a whole shift next to live camera feeds, and a white page beside night-time
 * dashcam footage is fatiguing and washes out the video.
 *
 * The palette is the app's, so the two products read as one family.
 */

:root {
  /* Birdie blue, from the product logo. */
  --blue: #4a91ca;
  --blue-bright: #5ea3d8;
  --blue-deep: #2f6fa3;

  --live: #35c08a;
  --warn: #e8a33d;
  --alert: #e2574c;
  --offline: #6b7785;

  --bg: #0e1520;
  --panel: #151e2b;
  --panel-2: #1b2635;
  --line: #26344a;

  --ink: #e8eef6;
  --ink-dim: #93a3b8;
  --ink-faint: #64748b;

  --radius: 10px;
  --header: 56px;
  --shadow: 0 8px 24px rgb(0 0 0 / 35%);

  color-scheme: dark;
}

* { box-sizing: border-box; }

html, body {
  height: 100%;
  margin: 0;
}

body {
  background: var(--bg);
  color: var(--ink);
  font: 14px/1.5 "Segoe UI", Tahoma, system-ui, sans-serif;
  overflow: hidden;
}

/* Arabic UI, Latin data. Device ids, coordinates and speeds stay LTR inside an
   RTL page — `dir` on the element, not a text-align guess. */
[dir="rtl"] { direction: rtl; }
.ltr {
  direction: ltr;
  unicode-bidi: isolate;
  font-variant-numeric: tabular-nums;
}

button { font: inherit; color: inherit; cursor: pointer; }

::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb {
  background: var(--line);
  border-radius: 5px;
  border: 2px solid var(--bg);
}
::-webkit-scrollbar-thumb:hover { background: #35476a; }

/* ------------------------------------------------------------------ header */

.top {
  height: var(--header);
  display: flex;
  align-items: center;
  gap: 20px;
  padding: 0 16px;
  background: linear-gradient(90deg, var(--blue-deep), var(--blue));
  box-shadow: var(--shadow);
  position: relative;
  z-index: 40;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 190px;
}

.brand svg { width: 30px; height: 30px; flex: none; }

.brand .name {
  font-size: 19px;
  font-weight: 700;
  letter-spacing: -0.3px;
  line-height: 1;
}

.brand .sub {
  font-size: 10px;
  opacity: 0.8;
  letter-spacing: 0.4px;
}

.nav { display: flex; gap: 4px; margin-inline-start: auto; }

.nav button {
  background: none;
  border: 0;
  padding: 8px 16px;
  border-radius: 7px;
  opacity: 0.82;
  font-size: 14px;
  transition: background 0.15s, opacity 0.15s;
}

.nav button:hover { background: rgb(255 255 255 / 12%); opacity: 1; }

.nav button[aria-current="page"] {
  background: rgb(255 255 255 / 20%);
  opacity: 1;
  font-weight: 600;
}

.who {
  display: flex;
  align-items: center;
  gap: 8px;
  padding-inline-start: 16px;
  border-inline-start: 1px solid rgb(255 255 255 / 22%);
  font-size: 13px;
}

.who .avatar {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: rgb(255 255 255 / 22%);
  display: grid;
  place-items: center;
  font-weight: 700;
  font-size: 12px;
}

/* ------------------------------------------------------------------ shell */

.shell {
  height: calc(100vh - var(--header));
  display: grid;
  grid-template-columns: 290px 1fr 400px;
  gap: 1px;
  background: var(--line);
}

.pane {
  background: var(--panel);
  display: flex;
  flex-direction: column;
  min-height: 0;
  min-width: 0;
}

.pane-head {
  height: 42px;
  flex: none;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 0 12px;
  border-bottom: 1px solid var(--line);
  font-size: 13px;
  font-weight: 600;
  color: var(--ink-dim);
}

.pane-body { flex: 1; overflow: auto; min-height: 0; }

/* ------------------------------------------------------------------ chips */

.chips { display: flex; gap: 6px; padding: 10px 12px; flex-wrap: wrap; }

.chip {
  background: var(--panel-2);
  border: 1px solid var(--line);
  border-radius: 20px;
  padding: 5px 12px;
  font-size: 12px;
  color: var(--ink-dim);
  transition: all 0.15s;
}

.chip:hover { border-color: var(--blue); color: var(--ink); }

.chip[aria-pressed="true"] {
  background: var(--blue);
  border-color: var(--blue);
  color: #fff;
  font-weight: 600;
}

.chip .n { opacity: 0.75; font-size: 11px; margin-inline-start: 3px; }

/* ------------------------------------------------------------------ search */

.search {
  margin: 10px 12px 4px;
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--panel-2);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 8px 10px;
}

.search input {
  background: none;
  border: 0;
  outline: 0;
  color: var(--ink);
  width: 100%;
  font: inherit;
}

.search input::placeholder { color: var(--ink-faint); }
.search:focus-within { border-color: var(--blue); }

/* ------------------------------------------------------------------ list */

.device {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 9px 12px;
  border-bottom: 1px solid rgb(38 52 74 / 45%);
  cursor: pointer;
  transition: background 0.12s;
}

.device:hover { background: var(--panel-2); }

.device[aria-selected="true"] {
  background: color-mix(in srgb, var(--blue) 22%, transparent);
  box-shadow: inset 3px 0 0 var(--blue);
}

[dir="rtl"] .device[aria-selected="true"] { box-shadow: inset -3px 0 0 var(--blue); }

.dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex: none;
  background: var(--offline);
}

.dot.on { background: var(--live); box-shadow: 0 0 0 3px rgb(53 192 138 / 18%); }
.dot.alarm { background: var(--alert); box-shadow: 0 0 0 3px rgb(226 87 76 / 18%); }

.device .id { flex: 1; font-size: 13px; }
.device .name { display: block; font-size: 11px; color: var(--ink-faint); }
.device .speed { font-size: 12px; color: var(--ink-dim); }

.cams { display: flex; gap: 3px; }

.cam-pip {
  width: 15px;
  height: 11px;
  border-radius: 2px;
  border: 1px solid var(--line);
  background: var(--panel-2);
  font-size: 7px;
  display: grid;
  place-items: center;
  color: var(--ink-faint);
}

.cam-pip.on { border-color: var(--live); color: var(--live); }

/* ------------------------------------------------------------------ map */

#map { flex: 1; background: #0b1119; min-height: 0; }

.leaflet-container { background: #0b1119 !important; }

/* Tiles are grey-shifted so the blue device markers stay the brightest thing
   on screen — the operator's eye should go to vehicles, not to streets. */
.leaflet-tile { filter: grayscale(1) invert(0.92) contrast(0.82) brightness(0.92); }

.map-fallback {
  flex: 1;
  display: grid;
  place-items: center;
  text-align: center;
  color: var(--ink-faint);
  padding: 40px;
  font-size: 13px;
}

.marker {
  background: var(--blue);
  color: #fff;
  border-radius: 6px;
  padding: 2px 7px;
  font-size: 11px;
  font-weight: 600;
  white-space: nowrap;
  box-shadow: 0 2px 8px rgb(0 0 0 / 55%);
  border: 1px solid rgb(255 255 255 / 28%);
}

.marker.sel { background: var(--live); }
.marker.alarm { background: var(--alert); }

/* ------------------------------------------------------------------ video */

.video-grid {
  flex: 1;
  display: grid;
  grid-template-columns: 1fr 1fr;
  grid-template-rows: 1fr 1fr;
  gap: 1px;
  background: var(--line);
  min-height: 0;
}

.cell {
  background: #05090f;
  position: relative;
  overflow: hidden;
  display: grid;
  place-items: center;
}

.cell .placeholder {
  text-align: center;
  color: #2c3a4d;
  font-size: 12px;
}

.cell .scene { position: absolute; inset: 0; }

/* The burnt-in overlay real JT/T 1078 streams carry: time, plate, speed,
   coordinates. Reproduced so the layout is judged against what the hardware
   actually sends, not an idealised frame. */
.osd {
  position: absolute;
  inset: 0;
  padding: 6px 8px;
  font-size: 10px;
  font-family: Consolas, monospace;
  color: #fff;
  text-shadow: 0 1px 3px #000;
  pointer-events: none;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  direction: ltr;
}

.osd .row { display: flex; justify-content: space-between; gap: 8px; }

.cell .tag {
  position: absolute;
  inset-inline-start: 0;
  bottom: 0;
  background: var(--blue-deep);
  color: #fff;
  font-size: 10px;
  padding: 2px 8px;
  font-family: Consolas, monospace;
  direction: ltr;
}

/* ------------------------------------------------------------------ table */

.bottom {
  height: 210px;
  flex: none;
  border-top: 1px solid var(--line);
  background: var(--panel);
  display: flex;
  flex-direction: column;
}

.tabs { display: flex; gap: 2px; padding: 0 8px; border-bottom: 1px solid var(--line); }

.tabs button {
  background: none;
  border: 0;
  padding: 9px 14px;
  font-size: 12.5px;
  color: var(--ink-dim);
  border-bottom: 2px solid transparent;
}

.tabs button:hover { color: var(--ink); }

.tabs button[aria-selected="true"] {
  color: var(--blue-bright);
  border-bottom-color: var(--blue-bright);
  font-weight: 600;
}

.tabs .badge {
  background: var(--alert);
  color: #fff;
  border-radius: 9px;
  padding: 0 5px;
  font-size: 10px;
  margin-inline-start: 5px;
}

table { width: 100%; border-collapse: collapse; font-size: 12.5px; }

thead th {
  position: sticky;
  top: 0;
  background: var(--panel-2);
  text-align: start;
  padding: 7px 12px;
  font-weight: 600;
  color: var(--ink-dim);
  border-bottom: 1px solid var(--line);
  white-space: nowrap;
}

tbody td {
  padding: 7px 12px;
  border-bottom: 1px solid rgb(38 52 74 / 40%);
  white-space: nowrap;
}

tbody tr:hover { background: var(--panel-2); }

.pill {
  display: inline-block;
  border-radius: 4px;
  padding: 1px 7px;
  font-size: 11px;
  font-weight: 600;
}

.pill.on { background: rgb(53 192 138 / 16%); color: var(--live); }
.pill.off { background: rgb(107 119 133 / 18%); color: var(--offline); }
.pill.warn { background: rgb(232 163 61 / 16%); color: var(--warn); }
.pill.alert { background: rgb(226 87 76 / 16%); color: var(--alert); }

.addr {
  max-width: 340px;
  overflow: hidden;
  text-overflow: ellipsis;
  color: var(--ink-dim);
}

/* ------------------------------------------------------------------ stats */

.stats { display: flex; gap: 1px; background: var(--line); flex: none; }

.stat {
  background: var(--panel-2);
  padding: 9px 14px;
  flex: 1;
  min-width: 0;
}

.stat .v { font-size: 19px; font-weight: 700; line-height: 1.1; }
.stat .k { font-size: 11px; color: var(--ink-faint); }
.stat .v.on { color: var(--live); }
.stat .v.off { color: var(--offline); }
.stat .v.alert { color: var(--alert); }
.stat .v.warn { color: var(--warn); }

/* ------------------------------------------------------------------ misc */

.toolbar { display: flex; gap: 4px; margin-inline-start: auto; }

.tool {
  background: var(--panel-2);
  border: 1px solid var(--line);
  border-radius: 6px;
  width: 28px;
  height: 24px;
  display: grid;
  place-items: center;
  font-size: 11px;
  color: var(--ink-dim);
}

.tool:hover { border-color: var(--blue); color: var(--ink); }

.note {
  margin: 10px 12px;
  padding: 9px 11px;
  background: color-mix(in srgb, var(--warn) 10%, transparent);
  border: 1px solid color-mix(in srgb, var(--warn) 34%, transparent);
  border-radius: 8px;
  font-size: 11.5px;
  color: var(--warn);
  line-height: 1.6;
}

@media (max-width: 1400px) {
  .shell { grid-template-columns: 250px 1fr 320px; }
}
