/**
 * ambulance/assets/css/mapcn-theme.css
 *
 * mapcn-style map theme (same as the admin portal): rounded Leaflet
 * controls, ring pins, pin cards and a dark-mode variant. Loaded after
 * map.css, so the pin rules below replace the older teardrop pin.
 */

/* The picker / route stages also hold their own overlays (centre pin 400,
   buttons 410) next to the map; contain them so none can draw over the
   sticky top bar (z-index 40) while scrolling. */
.amb-map-picker__stage,
.amb-route-card__map,
[data-route-map],
.amb-trip-route-map {
  position: relative;
  z-index: 0;
  isolation: isolate;
}

/* Keep Leaflet's internal z-indexes (panes 400-700, controls 800-1000)
   inside the map so pins and controls never draw over the sticky top bar. */
.leaflet-container {
  z-index: 0;
  isolation: isolate;
}

/* Do NOT force position on .leaflet-container: the picker canvas is
   absolutely positioned (inset: 0) and a later `position: relative` here
   collapsed it to 0px height, so the map never showed. */
.amb-map-picker__canvas.leaflet-container {
  position: absolute;
  inset: 0;
}

.leaflet-container {
  background: #eef3f8;
  color: #0f172a;
  font-family: Inter, "DM Sans", system-ui, -apple-system, "Segoe UI", sans-serif;
}

/* Voyager is already balanced: no colour filter on the basemap. */

.leaflet-control-attribution {
  margin: 8px !important;
  padding: 3px 10px !important;
  border: 1px solid rgba(15, 23, 42, 0.06);
  border-radius: 999px !important;
  background: rgba(255, 255, 255, 0.88) !important;
  color: #64748b !important;
  font-size: 10px !important;
  line-height: 1.5 !important;
  backdrop-filter: blur(10px);
}
.leaflet-control-attribution a {
  color: #2563eb !important;
  text-decoration: none;
}

.leaflet-control-zoom {
  overflow: hidden;
  border: 0 !important;
  border-radius: 14px !important;
  box-shadow: 0 12px 30px rgba(15, 23, 42, 0.14) !important;
}
.leaflet-control-zoom a {
  width: 36px !important;
  height: 36px !important;
  border-bottom: 1px solid rgba(15, 23, 42, 0.07) !important;
  background: rgba(255, 255, 255, 0.95) !important;
  color: #1e293b !important;
  font-size: 17px !important;
  font-weight: 700 !important;
  line-height: 36px !important;
}
.leaflet-control-zoom a:last-child {
  border-bottom: 0 !important;
}
.leaflet-control-zoom a:hover {
  background: #eff6ff !important;
  color: #2563eb !important;
}

.amb-map-pin-wrap {
  border: 0 !important;
  background: transparent !important;
}
.amb-map-pin {
  position: relative;
  transform: none;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  border: 3px solid var(--pin-color, #2563eb);
  border-radius: 50%;
  background: #fff;
  color: var(--pin-color, #2563eb);
  box-shadow:
    0 10px 24px rgba(37, 99, 235, 0.24),
    0 2px 6px rgba(15, 23, 42, 0.16);
  font-size: 12px;
  font-weight: 800;
  line-height: 1;
}
.amb-map-pin::after {
  content: "";
  position: absolute;
  left: 50%;
  bottom: -7px;
  width: 12px;
  height: 12px;
  border-right: 3px solid var(--pin-color, #2563eb);
  border-bottom: 3px solid var(--pin-color, #2563eb);
  border-radius: 0 0 4px 0;
  background: #fff;
  transform: translateX(-50%) rotate(45deg);
}
.amb-map-pin > * { transform: none; }
.amb-map-pin__dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--pin-color, #2563eb);
  box-shadow: 0 0 0 4px color-mix(in srgb, var(--pin-color, #2563eb) 16%, transparent);
}
.amb-map-pin__label {
  color: inherit;
  position: relative;
  z-index: 1;
}

.leaflet-tooltip.amb-pin-tip,
.leaflet-tooltip.amb-rm-tip {
  padding: 5px 10px !important;
  border: 0 !important;
  border-radius: 10px !important;
  background: rgba(15, 23, 42, 0.92) !important;
  color: #fff !important;
  box-shadow: 0 8px 20px rgba(15, 23, 42, 0.22) !important;
  font-size: 11px !important;
  font-weight: 600 !important;
}
.leaflet-tooltip.amb-pin-tip::before,
.leaflet-tooltip.amb-rm-tip::before {
  display: none !important;
}

/* Pin card: bold title + one short address line, beside every pinned place. */
.leaflet-tooltip.amb-pin-card {
  display: flex;
  flex-direction: column;
  gap: 1px;
  max-width: 190px;
  padding: 6px 11px 7px !important;
  border: 0 !important;
  border-left: 3px solid var(--card-accent, #2563eb) !important;
  border-radius: 12px !important;
  background: #ffffff !important;
  color: #0f172a !important;
  box-shadow: 0 10px 26px rgba(15, 23, 42, 0.18), 0 1px 3px rgba(15, 23, 42, 0.1) !important;
  white-space: normal !important;
  pointer-events: none;
}
.leaflet-tooltip.amb-pin-card::before { display: none !important; }
.leaflet-tooltip.amb-pin-card--pickup, .leaflet-tooltip.amb-pin-card--start { --card-accent: #16a34a; }
.leaflet-tooltip.amb-pin-card--drop, .leaflet-tooltip.amb-pin-card--end { --card-accent: #ef4444; }
.leaflet-tooltip.amb-pin-card--stop { --card-accent: #f59e0b; }
.amb-pin-card__title {
  font-size: 12px;
  font-weight: 700;
  line-height: 1.25;
  letter-spacing: 0.01em;
  color: #0f172a;
}
.amb-pin-card__addr {
  overflow: hidden;
  font-size: 11px;
  font-weight: 500;
  line-height: 1.3;
  color: #64748b;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.leaflet-popup-content-wrapper {
  border-radius: 16px !important;
  box-shadow: 0 18px 44px rgba(15, 23, 42, 0.2) !important;
}
.leaflet-popup-content {
  margin: 12px 14px !important;
  font-size: 13px !important;
}
.leaflet-popup-tip {
  box-shadow: 0 8px 20px rgba(15, 23, 42, 0.14) !important;
}
/* Vector basemap sits below Leaflet's own markers and lets clicks reach the map. */
.leaflet-gl-layer,
.leaflet-gl-layer canvas,
.leaflet-gl-layer.leaflet-image-layer {
  pointer-events: none !important;
}
.leaflet-gl-layer { z-index: 0; }

/* Dark mode: Dark Matter basemap, so the map chrome and pin cards go dark too. */
[data-theme="dark"] .leaflet-container { background: #0e1116; color: #e5e7eb; }
[data-theme="dark"] .leaflet-control-attribution {
  border-color: rgba(255, 255, 255, 0.08);
  background: rgba(15, 23, 42, 0.82) !important;
  color: #94a3b8 !important;
}
[data-theme="dark"] .leaflet-control-attribution a { color: #93c5fd !important; }
[data-theme="dark"] .leaflet-tooltip.amb-pin-card {
  background: #1e293b !important;
  color: #f1f5f9 !important;
  box-shadow: 0 10px 26px rgba(0, 0, 0, 0.5), 0 1px 3px rgba(0, 0, 0, 0.4) !important;
}
[data-theme="dark"] .amb-pin-card__title { color: #f8fafc; }
[data-theme="dark"] .amb-pin-card__addr { color: #94a3b8; }
[data-theme="dark"] .leaflet-popup-content-wrapper,
[data-theme="dark"] .leaflet-popup-tip { background: #1e293b; color: #f1f5f9; }
