/* ─────────────────────────────────────────────────────────────────────────────
   maps/_shared/fms-map.css — styles for the map modules (M00-core, M17 …).
   Injected by <!--MAP_SHARED--> as a <link>. Colours come from the app's theme
   tokens in v2-map-first.html (:root / html[data-theme="dark"]) so dark mode
   follows automatically. Every class is prefixed fms- to stay out of the app's way.
   ───────────────────────────────────────────────────────────────────────────── */

/* ── Vehicle marker: legacy sprite (L2) ────────────────────────────────────── */
.fms-marker { background: transparent !important; border: 0 !important; }
.fms-veh {
  position: relative;
  width: 32px; height: 32px;
  cursor: pointer;
}
/* Layering inside a marker: halo (0) < sprite (1) < overlay ring (2) < badges / label (3). */
.fms-veh__img {
  position: relative; z-index: 1;
  display: block;
  width: 32px; height: 32px;
  -webkit-user-drag: none; user-select: none;
  filter: drop-shadow(0 1px 1.5px rgba(15,23,42,.35));
  transition: transform .15s ease;
}
.fms-veh:hover .fms-veh__img { transform: scale(1.12); }
/* Selected: a brand halo behind the sprite. */
.fms-veh.is-sel::before {
  content: '';
  position: absolute; inset: -6px; z-index: 0;
  border-radius: 50%;
  background: rgba(37,99,235,.16);
  border: 2px solid var(--brand, #2563EB);
  box-shadow: 0 0 0 4px rgba(37,99,235,.12);
}
/* Lost GPS / SMS: an OVERLAY on the normal colour sprite (never sGray/sGreen). */
.fms-veh.is-lost::after,
.fms-veh.is-sms::after {
  content: '';
  position: absolute; inset: -3px; z-index: 2;
  border-radius: 50%;
  border: 2px dashed #64748B;
  pointer-events: none;
}
.fms-veh.is-sms::after { border-style: dotted; border-color: #334155; }
.fms-veh.is-lost .fms-veh__img,
.fms-veh.is-sms .fms-veh__img { opacity: .78; }
.fms-veh__badge {
  position: absolute; top: -7px; right: -12px; z-index: 3;
  padding: 0 3px;
  border-radius: 4px;
  background: #64748B; color: #FFFFFF;
  font: 700 8px/12px 'Be Vietnam Pro', system-ui, sans-serif;
  letter-spacing: .02em;
  white-space: nowrap;
  box-shadow: 0 1px 2px rgba(15,23,42,.3);
  pointer-events: none;
}
.fms-veh__badge--gps { text-decoration: line-through; }
.fms-veh__badge--sms { background: #334155; }
.fms-veh__alert {
  position: absolute; top: -8px; left: -8px; z-index: 3;
  width: 16px; height: 16px;
  border-radius: 50%;
  background: #DC2626; color: #FFFFFF;
  font: 700 10px/16px system-ui, sans-serif;
  text-align: center;
  box-shadow: 0 1px 3px rgba(15,23,42,.35);
  pointer-events: none;
}

/* ── Plate / mã tài label (L3) — the legacy yellow label (MapV2.aspx .marker-car-label) ── */
.fms-veh__label {
  position: absolute; top: 34px; left: 50%; z-index: 3;
  transform: translateX(-50%);
  min-width: 56px;
  padding: 0 4px;
  background: #FFFF00;
  color: #FF0000;
  border: 1px solid #000000;
  font: 700 8pt/1.35 'Be Vietnam Pro', system-ui, sans-serif;
  text-align: center;
  white-space: nowrap;
  pointer-events: none;
}
.fms-veh.is-sel .fms-veh__label { top: 38px; }

/* ── Legend control (L11), Leaflet control 'bottomleft' ────────────────────── */
.fms-legend {
  background: var(--surface-solid, #FFFFFF);
  color: var(--text, #0F172A);
  border: 1px solid var(--border, rgba(15,23,42,.08));
  border-radius: 12px;
  box-shadow: 0 8px 24px rgba(15,23,42,.18);
  font: 12px/1.35 'Be Vietnam Pro', system-ui, sans-serif;
  min-width: 150px;
  overflow: hidden;
  transition: margin-left .15s ease;
}
.fms-legend__head {
  display: flex; align-items: center; gap: 6px;
  width: 100%;
  padding: 7px 10px;
  border: 0; background: var(--surface-soft, rgba(15,23,42,.03));
  color: var(--text, #0F172A);
  font: 700 12px/1.2 'Be Vietnam Pro', system-ui, sans-serif;
  cursor: pointer; text-align: left;
}
.fms-legend__head .fms-legend__chev { margin-left: auto; color: var(--text-3, #94A3B8); font-size: 10px; }
.fms-legend.is-collapsed .fms-legend__body { display: none; }
.fms-legend__body { padding: 4px 10px 8px; }
.fms-legend__row { display: flex; align-items: center; gap: 8px; padding: 2px 0; white-space: nowrap; }
.fms-legend__row .fms-veh { width: 20px; height: 20px; cursor: default; }
.fms-legend__row .fms-veh__img { width: 20px; height: 20px; }
.fms-legend__row .fms-veh.is-lost::after,
.fms-legend__row .fms-veh.is-sms::after { inset: -2px; border-width: 1.5px; }
.fms-legend__sep { height: 1px; margin: 4px 0; background: var(--border, rgba(15,23,42,.08)); }

/* ── Vehicle info popup (L5) — host binds it with className 'fms-veh-popup' ── */
.fms-veh-popup .leaflet-popup-content-wrapper,
.fms-veh-popup .leaflet-popup-tip {
  background: var(--surface-solid, #FFFFFF);
  color: var(--text, #0F172A);
}
.fms-veh-popup .leaflet-popup-content { margin: 0 !important; }
.fms-pop {
  padding: 10px 12px 12px;
  max-width: 320px;
  font: 11.5px/1.55 'Be Vietnam Pro', system-ui, sans-serif;
  color: var(--text, #0F172A);
}
.fms-pop b { font-weight: 700; }
.fms-pop__v { color: var(--brand, #2563EB); }
.fms-pop__plate { color: var(--brand, #2563EB); font-weight: 800; font-family: 'JetBrains Mono', ui-monospace, monospace; }
.fms-pop__time { color: var(--text-2, #475569); }
.fms-pop__red { color: #DC2626; }
.fms-pop__muted { color: var(--text-3, #94A3B8); }
.fms-pop hr { border: 0; border-top: 1px solid var(--border, rgba(15,23,42,.08)); margin: 6px 0; }

/* ── Matai chip in vehicle lists (L3 listRenderer) ─────────────────────────── */
.fms-matai-chip {
  display: inline-block;
  max-width: 110px;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  padding: 0 5px;
  border-radius: 4px;
  background: #FFFF00; color: #B91C1C;
  border: 1px solid rgba(0,0,0,.55);
  font: 700 10px/15px 'JetBrains Mono', ui-monospace, monospace;
  vertical-align: middle;
}

/* ── User position marker (E9) ─────────────────────────────────────────────── */
.fms-userpos { background: transparent !important; border: 0 !important; }
.fms-userpos img {
  display: block; width: 30px; height: 30px;
  border-radius: 50%;
  border: 2px solid #FFFFFF;
  box-shadow: 0 2px 6px rgba(15,23,42,.35);
}

/* ── Fleet summary panel (L12) ─────────────────────────────────────────────── */
.fms-sum { padding: 12px 14px 14px; font: 12.5px/1.4 'Be Vietnam Pro', system-ui, sans-serif; color: var(--text, #0F172A); }
.fms-sum__title { font-weight: 800; font-size: 13.5px; margin-bottom: 8px; }
.fms-sum__status {
  display: flex; align-items: center; gap: 8px;
  padding: 7px 10px; margin-bottom: 10px;
  border-radius: 10px;
  background: var(--surface-soft, rgba(15,23,42,.03));
  border: 1px solid var(--border, rgba(15,23,42,.08));
}
.fms-sum__dot { width: 10px; height: 10px; border-radius: 50%; flex-shrink: 0; border: 1px solid rgba(15,23,42,.35); }
.fms-sum__grid { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 6px; margin-bottom: 12px; }
.fms-sum__grid.is-compact { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.fms-sum__tile {
  padding: 7px 6px;
  border-radius: 10px;
  background: var(--surface-soft, rgba(15,23,42,.03));
  border: 1px solid var(--border, rgba(15,23,42,.08));
  text-align: center;
}
.fms-sum__num { font: 800 17px/1.1 'JetBrains Mono', ui-monospace, monospace; font-variant-numeric: tabular-nums; }
.fms-sum__lbl { font-size: 10.5px; color: var(--text-2, #475569); margin-top: 2px; }
.fms-sum__h { font-weight: 700; font-size: 11px; color: var(--text-3, #94A3B8); text-transform: uppercase; letter-spacing: .04em; margin: 4px 0 6px; }
.fms-sum__bar-row { display: grid; grid-template-columns: 118px 1fr 78px; align-items: center; gap: 8px; padding: 3px 0; }
.fms-sum__bar { height: 8px; border-radius: 4px; background: var(--surface-soft, rgba(15,23,42,.05)); overflow: hidden; }
.fms-sum__bar > span { display: block; height: 100%; border-radius: 4px; }
.fms-sum__val { text-align: right; font-family: 'JetBrains Mono', ui-monospace, monospace; font-variant-numeric: tabular-nums; font-size: 11.5px; }
.fms-sum table { width: 100%; border-collapse: collapse; font-size: 12px; }
.fms-sum th, .fms-sum td { padding: 4px 6px; border-bottom: 1px solid var(--border, rgba(15,23,42,.08)); text-align: left; }
.fms-sum th { color: var(--text-2, #475569); font-weight: 700; font-size: 11px; }
.fms-sum td.num, .fms-sum th.num { text-align: right; font-family: 'JetBrains Mono', ui-monospace, monospace; font-variant-numeric: tabular-nums; }
.fms-sum__foot { display: flex; align-items: center; gap: 8px; margin-top: 12px; font-size: 11px; color: var(--text-2, #475569); flex-wrap: wrap; }
.fms-btn {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 5px 10px;
  border-radius: 8px;
  border: 1px solid var(--border-strong, rgba(15,23,42,.14));
  background: var(--surface-solid, #FFFFFF);
  color: var(--text, #0F172A);
  font: 600 11.5px/1.2 'Be Vietnam Pro', system-ui, sans-serif;
  cursor: pointer;
}
.fms-btn:hover { border-color: var(--brand, #2563EB); }
.fms-btn.is-on { background: var(--brand, #2563EB); border-color: var(--brand, #2563EB); color: #FFFFFF; }
.fms-btn:disabled { opacity: .5; cursor: default; }

/* ── Tile-server diagnostics panel (M17) ───────────────────────────────────── */
.fms-tiles { padding: 12px 14px 14px; font: 12px/1.4 'Be Vietnam Pro', system-ui, sans-serif; color: var(--text, #0F172A); }
.fms-tiles__meta { display: grid; grid-template-columns: auto 1fr; gap: 2px 10px; margin-bottom: 10px; font-size: 11.5px; }
.fms-tiles__meta dt { color: var(--text-2, #475569); }
.fms-tiles__meta dd { margin: 0; font-family: 'JetBrains Mono', ui-monospace, monospace; word-break: break-all; }
.fms-tiles__list { display: flex; flex-direction: column; gap: 6px; }
.fms-tiles__item {
  padding: 8px 10px;
  border-radius: 10px;
  border: 1px solid var(--border, rgba(15,23,42,.08));
  background: var(--surface-soft, rgba(15,23,42,.03));
}
.fms-tiles__item.is-current { border-color: var(--brand, #2563EB); box-shadow: 0 0 0 1px var(--brand, #2563EB) inset; }
.fms-tiles__item.is-hidden { opacity: .6; }
.fms-tiles__row { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.fms-tiles__host { font-family: 'JetBrains Mono', ui-monospace, monospace; font-size: 11px; color: var(--text-2, #475569); word-break: break-all; }
.fms-tag {
  display: inline-block; padding: 0 6px; border-radius: 999px;
  font: 700 10px/16px 'Be Vietnam Pro', system-ui, sans-serif;
  background: var(--slate-soft, rgba(100,116,139,.14)); color: var(--text-2, #475569);
}
.fms-tag--warn { background: var(--amber-soft, rgba(180,83,9,.12)); color: var(--amber, #B45309); }
.fms-tag--ok { background: var(--emerald-soft, rgba(5,150,105,.12)); color: var(--emerald, #059669); }
.fms-tag--bad { background: var(--red-soft, rgba(220,38,38,.10)); color: var(--red, #DC2626); }
.fms-tag--brand { background: var(--brand-soft, rgba(37,99,235,.10)); color: var(--brand, #2563EB); }
