/* Live karta & larm (admin/taxi/taxi-map.html), round 47 (panel redesign R3).
   The map fills the page, and the lists float over it as two panes, the alarms first. Colours come only from tokens.css,
   admin-v2.css and page.css: the accent classes green, amber, rose and gray (page.css) carry their own light and dark
   values, so both themes follow the sun/moon button. The floating glass (the @supports gate and its reduced-transparency
   fallback) stays in the page's own <style>, after this file. */
* { box-sizing: border-box; margin: 0; padding: 0; }

/* the page's small line icons (24x24, stroke currentColor) */
.ic { width: 18px; height: 18px; flex-shrink: 0; vertical-align: -3px; }

/* ---- The frame: the header strip, then the map with its two panes ---- */
.map-wrap {
  display: flex;
  flex-direction: column;
  height: calc(100vh - 72px);
  height: calc(100dvh - 72px);
  width: 100%;
  position: relative;
  overflow: hidden;
  background: var(--bg);
  color: var(--pg-text);
}

/* the header: the page pattern (page.css) on the glass strip over the map, the figures in one row of tiles */
.map-header {
  display: flex;
  flex-direction: column;
  gap: 14px;
  padding: 18px 28px 16px;
  background: var(--pg-surface-flat);
  border-block-end: 1px solid var(--pg-line);
  z-index: 10;
  flex-shrink: 0;
}
.map-header .pg-title { font-size: 24px; }
.map-header .pg-sub { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; font-size: 15px; }
.map-header .pg-sub b { font-variant-numeric: tabular-nums; color: var(--pg-text); }
.map-header .pg-field, .map-header .pg-btn { min-height: 42px; font-size: 15px; }
.map-header .pg-field { border-radius: var(--radius-full); padding-inline: 16px; }
.map-header .pg-btn.alarm { font-weight: 700; padding-inline: 18px; }

/* the figures, six in a row: big numbers over small labels; «Larm» first, red while any is open */
.map-header .pg-kpis.compact { grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 12px; }
.map-header .pg-kpis.compact .pg-kpi { padding: 12px 14px; gap: 4px; }
.map-header .pg-kpis.compact .pg-kpi-label { font-size: 14px; }   /* the panel's 14 px floor */
.map-header .pg-kpis.compact .pg-kpi-value { font-size: 32px; line-height: 1.05; }
.map-header .pg-kpi[data-part="alarm-kpi"].rose { border-color: var(--a-line); }

.pulse-dot {
  display: inline-block;
  width: 8px;
  height: 8px;
  background: var(--kr-green);
  border-radius: 50%;
  box-shadow: 0 0 8px var(--kr-green);
  animation: pulseBeacon 1.5s infinite;
}
@keyframes pulseBeacon {
  0%, 100% { transform: scale(1); opacity: 1; }
  50% { transform: scale(1.3); opacity: 0.5; }
}
/* the last read failed, or the page is not this person's: the pulse stops */
.pulse-dot.is-stale { animation: none; background: var(--pg-muted); box-shadow: none; }

/* why the page is not up to date, or the map cannot be drawn: a row of its own under the header, never under a pane */
.map-note {
  flex-shrink: 0;
  padding: 12px 28px;
  background: var(--pg-surface-flat);
  border-block-end: 1px solid var(--orange);
  font-size: 15px;
  font-weight: 700;
  color: var(--pg-text);
}

/* the map's full width, with the two panes floating over it, each folding to a strip */
.map-body {
  display: block;
  flex: 1;
  position: relative;
  overflow: hidden;
  width: 100%;
  height: 100%;
}
.left-pane, .right-pane {
  position: absolute;
  top: 16px;
  bottom: 16px;
  width: 336px;
  background: var(--pg-surface-flat);
  border: 1px solid var(--pg-line);
  border-radius: 20px;
  box-shadow: var(--shadow-luxe);
  overflow-y: auto;
  z-index: 10;
  display: flex;
  flex-direction: column;
  transition: transform 0.2s var(--ease-spring), opacity 0.2s ease;
  /* a pane scrolled to its end keeps the wheel: the page (and its header) stays where it is */
  overscroll-behavior: contain;
}
.left-pane { left: 16px; }
.right-pane { right: 16px; }
.left-pane.is-collapsed { transform: translateX(calc(-100% + 46px)); }
.right-pane.is-collapsed { transform: translateX(calc(100% - 46px)); }
/* folded: only the toggle shows on the strip, never half a card */
.is-collapsed > .pane-section { visibility: hidden; }
.is-collapsed .overlay-toggle .w { display: none; }
.left-pane.is-collapsed .overlay-toggle { margin-right: 3px; }
.right-pane .overlay-toggle { align-self: flex-start; }
.right-pane.is-collapsed .overlay-toggle { margin-left: 3px; }
.overlay-toggle {
  align-self: flex-end;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin: 10px 12px 0;
  padding: 8px 10px;
  font: inherit;
  font-size: 15px;
  font-weight: 700;
  line-height: 1.1;
  border-radius: var(--radius-full);
  border: 1px solid var(--pg-line-hi);
  background: var(--btn-glass-bg);
  color: var(--btn-glass-text);
  cursor: pointer;
}
.overlay-toggle .w { padding-inline-end: 4px; }
.overlay-toggle:hover { background: var(--btn-glass-hover); border-color: var(--glass-border-hi); }

/* ---- A pane's sections: a heading with its icon and its count, then the list ---- */
.pane-section {
  padding: 18px;
  border-block-end: 1px solid var(--pg-line);
}
.pane-section h3 {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-block-end: 12px;
  font-size: 16px;
  font-weight: 800;
  letter-spacing: -0.01em;
  color: var(--pg-text);
  font-variant-numeric: tabular-nums;
}
html[dir="rtl"] .pane-section h3 { letter-spacing: 0; }
.pane-section h3 .ic { width: 20px; height: 20px; color: var(--pg-muted); }
.pane-section-grow { flex: 1; }
.pane-count-muted { color: var(--muted); }
.pane-count-bold { color: var(--muted); font-weight: 700; }
.pane-empty { color: var(--pg-muted); font-size: 15px; line-height: 1.45; padding: 6px 2px; }

/* the alarms: the left pane's first section, a red card (page.css .rose) with its count large */
.alarm-section {
  margin: 8px 10px 6px;
  border: 1px solid var(--a-line);
  background: var(--a-bg);
  border-radius: 18px;
}
.alarm-section h3, .alarm-section h3 .ic { color: var(--a); }
.alarm-section h3 [data-bind="incident_count"] { font-size: 18px; }
.alarm-item {
  padding: 14px 16px;
  border-radius: 14px;
  background: var(--card);
  border: 1px solid var(--a-line);
  margin-block-end: 10px;
}
.alarm-item .t { font-weight: 800; font-size: 16px; color: var(--a); }
.alarm-item .s { font-size: 15px; color: var(--pg-muted); margin-block-start: 4px; line-height: 1.45; }
.alarm-item textarea {
  width: 100%;
  margin-block-start: 10px;
  min-height: 64px;
  padding: 10px 12px;
  border-radius: 12px;
  border: 1px solid var(--pg-line-hi);
  background: var(--pg-field);
  color: var(--pg-text);
  font: inherit;
  font-size: 16px;
  line-height: 1.45;
  resize: vertical;
}
.alarm-item .row { display: flex; gap: 8px; margin-block-start: 10px; flex-wrap: wrap; }
.alarm-item button {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 38px;
  padding: 7px 16px;
  border-radius: var(--radius-full);
  border: 1px solid var(--pg-line-hi);
  background: var(--btn-glass-bg);
  color: var(--pg-text);
  font: inherit;
  font-weight: 700;
  font-size: 15px;
  cursor: pointer;
}
.alarm-item button:hover { background: var(--btn-glass-hover); }
/* «Markera hanterad»: page.css .green */
.alarm-item button.done { background: var(--a-bg); border-color: var(--a-line); color: var(--a); }
.alarm-item button:disabled { opacity: .55; cursor: not-allowed; }

/* the primary button of a card: «Tilldela föraren», «Öppna» */
.btn-go {
  width: 100%;
  min-height: 44px;
  padding: 11px 16px;
  border-radius: var(--radius-full);
  border: none;
  cursor: pointer;
  background: linear-gradient(135deg, var(--primary-hi) 0%, var(--primary-hover) 100%);
  color: var(--paper);
  font: inherit;
  font-weight: 700;
  font-size: 15px;
  text-decoration: none;
  transition: transform 0.2s var(--ease-spring), box-shadow 0.2s ease, filter 0.2s ease;
  box-shadow: 0 4px 14px var(--primary-glow);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}
.btn-go:hover {
  transform: translateY(-1px);
  filter: brightness(1.06);
}
.btn-go:disabled { opacity: .55; cursor: not-allowed; transform: none; }

/* ---- Rides: the cards of «Söker förare», «Förbokade» and «Pågående» ---- */
.ride-card {
  padding: 14px 16px;
  border-radius: 14px;
  border: 1px solid var(--pg-line);
  background: var(--pg-inner);
  margin-block-end: 10px;
  font-size: 15px;
  font-variant-numeric: tabular-nums;
}
.ride-card .route { font-weight: 700; font-size: 16px; color: var(--pg-text); line-height: 1.35; }
.ride-card .meta { color: var(--pg-muted); font-size: 15px; line-height: 1.45; margin-block: 4px 10px; }
.ride-card select {
  width: 100%;
  min-height: 44px;
  padding: 9px 12px;
  border-radius: 12px;
  border: 1px solid var(--pg-line-hi);
  background: var(--pg-field);
  color: var(--pg-text);
  font: inherit;
  font-size: 16px;
  margin-block-end: 8px;
}
.ride-card .btn-go { padding: 10px 14px; }
/* «Öppna» and «Avboka» under a card, and the cancel form */
.ride-card .row { display: flex; gap: 8px; margin-block-start: 8px; flex-wrap: wrap; }
.ride-card .row a, .ride-card .row button {
  display: inline-flex;
  align-items: center;
  min-height: 38px;
  padding: 7px 16px;
  border-radius: var(--radius-full);
  border: 1px solid var(--pg-line-hi);
  background: var(--pg-surface-flat);
  color: var(--pg-text);
  font-weight: 700;
  font-size: 15px;
  cursor: pointer;
  text-decoration: none;
  font-family: inherit;
}
[data-theme="dark"] .ride-card .row a, [data-theme="dark"] .ride-card .row button { background: var(--card-hi); }
.ride-card .row a:hover, .ride-card .row button:hover { border-color: var(--glass-border-hi); }
/* «Avboka resan»: page.css .rose */
.ride-card .row button.danger { background: var(--a-bg); border-color: var(--a-line); color: var(--a); }
.ride-card .row button:disabled { opacity: .55; cursor: not-allowed; }
.cancel-form { margin-block-start: 10px; padding-block-start: 10px; border-block-start: 1px solid var(--pg-line); }
.cancel-form input {
  width: 100%;
  min-height: 44px;
  padding: 9px 12px;
  border-radius: 12px;
  border: 1px solid var(--pg-line-hi);
  background: var(--pg-field);
  color: var(--pg-text);
  font: inherit;
  font-size: 16px;
}
.cancel-form .err { color: var(--a); font-size: 15px; margin-block-start: 6px; }
.cancel-form .err:empty { display: none; }
/* the team's test rides: page.css .amber */
.tag-test {
  display: inline-block;
  margin-inline-start: 6px;
  padding: 1px 9px;
  border-radius: var(--radius-full);
  background: var(--a-bg);
  border: 1px solid var(--a-line);
  color: var(--a);
  font-size: 14px;
  font-weight: 800;
  letter-spacing: .02em;
  vertical-align: 1px;
}

/* ---- Drivers online: one row each, the status dot, the name, the rating and the phone ---- */
.driver-list-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 14px;
  border-radius: 14px;
  border: 1px solid var(--pg-line);
  background: var(--pg-inner);
  margin-block-end: 8px;
  cursor: pointer;
  transition: border-color 0.18s ease, background 0.18s ease, transform 0.18s var(--ease-spring);
}
.driver-list-item:hover {
  border-color: var(--glass-border-hi);
  background: var(--hover);
  transform: translateX(-2px);
}
.driver-list-item:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; }
.driver-list-item .status-indicator {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  flex-shrink: 0;
}
.status-indicator.available { background: var(--kr-green); box-shadow: 0 0 6px var(--kr-green); }
.status-indicator.busy { background: var(--orange); box-shadow: 0 0 6px var(--orange); }
.status-indicator.offline { background: var(--pg-muted); }
.status-indicator.on_break { background: var(--red); }
.driver-list-item .info { flex: 1; min-width: 0; }
.driver-list-item .nm { font-weight: 800; font-size: 16px; color: var(--pg-text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.driver-list-item .meta { color: var(--pg-muted); font-size: 15px; line-height: 1.4; margin-block-start: 2px; font-variant-numeric: tabular-nums; }
/* the rating: page.css .amber */
.driver-list-item .rating { display: inline-flex; align-items: center; gap: 3px; color: var(--a); font-weight: 800; font-size: 15px; font-variant-numeric: tabular-nums; white-space: nowrap; }
.driver-list-item .rating .ic { width: 15px; height: 15px; vertical-align: 0; }
.driver-list-item .call {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  color: var(--blue);
  text-decoration: none;
  font-size: 15px;
  padding: 6px 8px;
  background: none;
  border: 0;
  border-radius: var(--radius-full);
  cursor: pointer;
  font-family: inherit;
  white-space: nowrap;
}
.driver-list-item button.call { min-width: 40px; min-height: 40px; background: var(--btn-glass-bg); }
.driver-list-item button.call:hover { background: var(--btn-glass-hover); }
.driver-list-item button.call:disabled { opacity: .55; cursor: not-allowed; }
.driver-list-item a.call { font-weight: 700; font-variant-numeric: tabular-nums; }

/* ---- The map, its buttons, its markers and its credit ---- */
.map-center { position: relative; width: 100%; height: 100%; min-height: 0; isolation: isolate; }
#map {
  width: 100%;
  height: 100%;
  background: var(--bg);
  z-index: 1;
}
.map-controls-pod {
  position: absolute;
  top: 16px;
  right: 16px;
  z-index: 1000;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.map-control-btn {
  background: var(--pg-surface-flat);
  border: 1px solid var(--pg-line-hi);
  color: var(--pg-text);
  min-height: 42px;
  padding: 9px 16px;
  border-radius: var(--radius-full);
  cursor: pointer;
  font: inherit;
  font-size: 15px;
  font-weight: 700;
  transition: background 0.2s ease, border-color 0.2s ease, transform 0.2s var(--ease-spring);
  display: flex;
  align-items: center;
  gap: 8px;
  box-shadow: var(--pg-lift);
}
.map-control-btn:hover {
  border-color: var(--glass-border-hi);
  background: var(--btn-glass-hover);
}
.map-control-btn.active {
  background: linear-gradient(135deg, var(--primary-hi) 0%, var(--primary-hover) 100%);
  color: var(--paper);
  border-color: transparent;
  box-shadow: 0 4px 16px var(--primary-glow);
}
/* the map's credit (OpenStreetMap, CARTO), under the zoom */
.map-credit { padding: 4px 12px; border-radius: var(--radius-full); background: var(--pg-surface-flat); border: 1px solid var(--pg-line); color: var(--pg-muted); font-size: 14px; }
.map-credit a { color: inherit; }

/* a car: its ring says free (green) or on a ride (orange); MapLibre moves it, so no transition on its transform */
.driver-marker-box {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: var(--card);
  color: var(--pg-text);
  border: 2px solid var(--blue);
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.35);
  transition: border-color 0.3s ease, box-shadow 0.3s ease, opacity 0.2s ease;
  cursor: pointer;
}
.driver-marker-box .ic { width: 18px; height: 18px; vertical-align: 0; }
.driver-marker-box.available { border-color: var(--kr-green); box-shadow: 0 0 12px rgba(16, 185, 129, 0.55); }
.driver-marker-box.busy { border-color: var(--orange); box-shadow: 0 0 12px rgba(245, 158, 11, 0.55); }
.driver-marker-box.offline { border-color: var(--pg-muted); }
.driver-marker-box.on_break { border-color: var(--red); }
/* an alarm: a pulsing red dot where it was raised */
.alarm-marker { width: 28px; height: 28px; border-radius: 50%; background: var(--red); border: 3px solid var(--paper); box-shadow: 0 0 0 0 rgba(239, 68, 68, 0.7); animation: alarm-pulse 1.4s infinite; cursor: pointer; }
@keyframes alarm-pulse { 0% { box-shadow: 0 0 0 0 rgba(239, 68, 68, 0.7); } 70% { box-shadow: 0 0 0 16px rgba(239, 68, 68, 0); } 100% { box-shadow: 0 0 0 0 rgba(239, 68, 68, 0); } }
/* a pickup waiting for a driver */
.req-marker { width: 22px; height: 22px; border-radius: 50% 50% 50% 0; transform: rotate(-45deg); background: var(--primary); border: 2px solid var(--paper); box-shadow: 0 0 14px var(--primary-glow); }

@media (prefers-reduced-motion: reduce) {
  .pulse-dot, .alarm-marker { animation: none; }
  .left-pane, .right-pane, .btn-go, .map-control-btn, .driver-list-item, .driver-marker-box { transition: none; }
  .btn-go:hover, .driver-list-item:hover { transform: none; }
}
@media (min-width: 801px) {
  /* the map's own buttons, the zoom and the credit beside the drivers' pane, never under it; on its strip when it is folded */
  .map-controls-pod { right: 366px; }
  .map-center .maplibregl-ctrl-bottom-right { right: 352px; }
  .map-body[data-right-folded] .map-controls-pod { right: 74px; }
  .map-body[data-right-folded] .map-center .maplibregl-ctrl-bottom-right { right: 62px; }
}
@media (max-width: 800px) {
  .map-wrap { height: auto; overflow: visible; }
  .map-body { display: flex; flex-direction: column; overflow: visible; }
  .map-center { height: 55vh; order: 0; }
  .left-pane, .right-pane { display: flex; border: none; order: 1; overflow: visible; position: static; width: auto; inset: auto; transform: none; border-radius: 0; box-shadow: none; }
  /* a pane folded on a wider screen is open here: there is no toggle on a phone */
  .left-pane.is-collapsed, .right-pane.is-collapsed { transform: none; }
  .is-collapsed > .pane-section { visibility: visible; }
  /* the alarms come first, above the map; the other lists after it */
  .left-pane { display: contents; }
  .left-pane > .pane-section { order: 1; background: var(--pg-surface-flat); }
  .left-pane > .alarm-section { order: -1; margin: 12px 16px; background: var(--a-bg); }
  .right-pane { order: 2; }
  .overlay-toggle { display: none; }
  .map-header { padding: 14px 16px; }
  .map-header .pg-kpis.compact { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; }
  .map-header .pg-kpis.compact .pg-kpi-value { font-size: 28px; }
  .map-note { padding: 12px 16px; }
  .pane-section { padding: 18px 16px; }
}
.map-main { padding: 0; max-width: none; flex: 1; }
/* the shell's hooks (the access card, the footer) find #pageContent here too; the map keeps its full width (VERIFY-full O80) */
#pageContent.map-page { padding: 0 !important; max-width: none; }
