/* ==========================================================================
   Map Common Styles — shared between Public/Map and GIS Map Editor
   ========================================================================== */

/* Top Bar */
.map-top-bar {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  z-index: 1001;
  background: linear-gradient(
    to bottom,
    rgba(255, 255, 255, 0.95) 0%,
    rgba(255, 255, 255, 0.85) 100%
  );
  backdrop-filter: blur(8px);
  padding: 12px 16px;
  display: flex;
  align-items: center;
  gap: 12px;
  border-bottom: 1px solid rgba(0, 0, 0, 0.1);
}

.back-btn {
  width: 40px;
  height: 40px;
  background: white;
  border: 1px solid #e5e7eb;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #374151;
  cursor: pointer;
  transition: all 0.2s;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

.back-btn:hover {
  background: #f3f4f6;
  color: #111827;
}

.page-title {
  font-weight: 600;
  color: #111827;
  font-size: 1rem; /* rem so font-resize toolbar scales it */
  margin: 0;
}

.page-subtitle {
  font-size: 0.6875rem;
  color: #6b7280;
}

/* Search Box */
.search-container {
  flex: 1;
  max-width: 400px;
  margin-left: auto;
}

.search-box {
  position: relative;
}

.search-input {
  width: 100%;
  padding: 10px 40px 10px 36px;
  border: 1px solid #e5e7eb;
  border-radius: 10px;
  font-size: 14px;
  background: white;
  transition: all 0.2s;
}

.search-input:focus {
  outline: none;
  border-color: #3b82f6;
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
}

.search-icon {
  position: absolute;
  left: 12px;
  top: 50%;
  transform: translateY(-50%);
  color: #9ca3af;
}

.clear-btn {
  position: absolute;
  right: 10px;
  top: 50%;
  transform: translateY(-50%);
  color: #9ca3af;
  cursor: pointer;
  padding: 4px;
}

.clear-btn:hover {
  color: #6b7280;
}

/* Bottom Controls */
.bottom-controls {
  position: absolute;
  bottom: 24px;
  left: 16px;
  right: 16px;
  z-index: 1001;
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  pointer-events: none;
}

.bottom-controls > * {
  pointer-events: auto;
}

/* Action Buttons */
.action-buttons {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.action-btn {
  width: 48px;
  height: 48px;
  background: white;
  border: none;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #374151;
  cursor: pointer;
  transition: all 0.2s;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
  font-size: 18px;
}

.action-btn:hover {
  background: #f3f4f6;
  transform: scale(1.05);
}

.action-btn.location-btn {
  color: #22c55e;
}

.action-btn.location-btn:hover {
  background: #dcfce7;
}

.action-btn.home-btn {
  color: #3b82f6;
}

.action-btn.home-btn:hover {
  background: #dbeafe;
}

/* Popup Styles */
.leaflet-popup-content-wrapper {
  border-radius: 12px !important;
}

/* Hover Tooltip */
.map-tooltip {
  position: absolute;
  z-index: 1001;
  background: rgba(0, 0, 0, 0.85);
  color: white;
  padding: 6px 10px;
  border-radius: 6px;
  font-size: 12px;
  font-weight: 500;
  pointer-events: none;
  white-space: nowrap;
  max-width: 250px;
  overflow: hidden;
  text-overflow: ellipsis;
  transform: translate(-50%, -100%);
  margin-top: -12px;
  opacity: 0;
  transition: opacity 0.15s ease;
}

.map-tooltip.visible {
  opacity: 1;
}

.map-tooltip::after {
  content: "";
  position: absolute;
  top: 100%;
  left: 50%;
  transform: translateX(-50%);
  border: 6px solid transparent;
  border-top-color: rgba(0, 0, 0, 0.85);
}

.map-tooltip .tooltip-type {
  font-size: 0.625rem;
  opacity: 0.7;
  margin-right: 6px;
}

/* Loading Overlay */
.loading-overlay {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(255, 255, 255, 0.9);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  z-index: 1002;
}

.loading-overlay.hidden {
  display: none;
}

.loading-spinner {
  width: 48px;
  height: 48px;
  border: 4px solid #e5e7eb;
  border-top-color: #3b82f6;
  border-radius: 50%;
  animation: spin 1s linear infinite;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

.loading-text {
  margin-top: 16px;
  color: #6b7280;
  font-size: 14px;
}

/* Mobile Responsive */
@media (max-width: 640px) {
  .map-top-bar {
    padding: 10px 12px;
  }

  .page-title {
    font-size: 0.875rem;
  }

  .search-container {
    display: none;
  }

  .bottom-controls {
    bottom: 16px;
    left: 12px;
    right: 12px;
  }

  .action-btn {
    width: 44px;
    height: 44px;
  }
}

/* ==========================================================================
   Focus visible (WCAG 2.4.7) — scoped to map surfaces
   ========================================================================== */
.gis-widget *:focus-visible,
.map-top-bar *:focus-visible,
.bottom-controls *:focus-visible,
.filter-chips *:focus-visible {
  outline: 2px solid #2563eb;
  outline-offset: 2px;
  border-radius: 4px;
}

/* ==========================================================================
   GIS Widget — Leaflet host + toolbar (TOR 5.4.3.16 (8)(9)(10)(11))
   ========================================================================== */
.gis-widget {
  position: relative;
  width: 100%;
  height: 100%;
  flex: 1 1 auto;
  display: flex;
  flex-direction: column;
}

.gis-map-host {
  width: 100%;
  height: 100%;
  flex: 1 1 auto;
  background: #e5e7eb;
}

/* Map application keyboard-focus ring (role="application") */
.gis-map-host:focus-visible {
  outline: 3px solid #2563eb;
  outline-offset: -3px;
}

/* GIS toolbar — top-right (basemap + share) */
.gis-toolbar {
  position: absolute;
  z-index: 1050;
  display: flex;
  align-items: center;
  gap: 6px;
  background: rgba(255, 255, 255, 0.95);
  padding: 6px 8px;
  border-radius: 10px;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.15);
}

.gis-toolbar--top {
  /* Sit BELOW the a11y-mini-toolbar (top: 12px height ~52px). */
  top: 72px;
  right: 12px;
}

/* Embed parity (UAT 2026-06-12): /Map renders basemap+share in the page
   header, so the widget's floating .gis-toolbar--top is empty there. On
   /Map/Embed there is no page header, so that floating toolbar IS the basemap
   + share control — its bottom (~126px) overlapped the sidebar top (120px) by
   ~6px on every >768 width (iPad-landscape / small-laptop / desktop), crowding
   the "ชั้นข้อมูล" panel header. Drop the embed sidebar to clear the toolbar
   (leave the toolbar where it is — it already sits clear of the lang button).
   The ≤768 drawer media (below) overrides this top for the bottom-sheet. */
/* ── Embed off-canvas rail + compact floating card (2026-06-15) ──────────
   Problem: at iframe sizes the persistent full-height right rail (.gis-sidebar
   = position:absolute; top:134px; bottom:16px) covered ~21% width × ~79% height
   of a 1300×700 embed and only the ≤768-WIDTH bottom-sheet rescued it — wide-
   but-short embeds never got relief. Fix (>768 width, embed only):

     • Collapsed by default → parked OFF-CANVAS right (translateX) → full-bleed map.
       Launched from the toolbar layer-group button (data-gis-sidebar-toggle).
     • Open → a COMPACT floating card: ~256px wide, TOP-ANCHORED + auto-height
       capped at min(560px, 78vh) with internal scroll, strong shadow → reads as
       a panel pulled OVER the map covering far LESS area, NOT a full-height rail.

   The ≤768 media block (later in source order) re-overrides transform to the
   translateY bottom-sheet, so narrow widths keep the proven mobile drawer. */
.embed-frame .gis-sidebar {
  top: 134px;
  /* auto-height card: drop the full-height stretch (bottom:16px from base) so
     the card is only as tall as its content, capped below. 68vh (not 78) keeps
     a clear strip of map visible above + below at short embed heights so it
     reads as a floating card, not a near-full-height rail. */
  bottom: auto;
  max-height: min(520px, 68vh);
  /* parked off-canvas right; +20px clears the box-shadow so no edge peeks in. */
  transform: translateX(calc(100% + 20px));
  transition: transform 0.22s ease;
  /* float as a card over the map: a touch stronger shadow than the base rail. */
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.18);
  /* GPU-compose the slide; will-change kept narrow to the animated prop. */
  will-change: transform;
}

.embed-frame .gis-sidebar[data-gis-sidebar-open="true"] {
  transform: translateX(0);
}

/* Embed control scale-down (UAT 2026-06-14): in the iframe the sidebar /
   basemap selector / lang button / toolbar sat at full /Map size and dwarfed
   the smaller embedded map. Scale the whole control cluster ~13% in embed
   context only (the logo badge already has a good ratio).
   COHERENT scale — text, the iOS toggle switch (knob + travel), marker dot,
   count pill and spacing all step down TOGETHER so nothing is left
   out-of-ratio (an un-shrunk 44×28 toggle next to 10px text looked broken +
   would trip a Lighthouse audit). Interactive targets stay ≥24px (Lighthouse
   tap-target floor): the switch lands at 38×24, the lang/toolbar buttons at
   ≥30px. Positions untouched → mobile drawer + toolbar stacking still work.
   /Map (full page) is unaffected — everything here is .embed-frame-scoped. */
/* Compact card width — 256px (was 272) so the floating panel occludes less of
   a small embed; the layer list + chips still wrap cleanly at this width. */
.embed-frame .gis-sidebar { width: 256px; }
.embed-frame .gis-sidebar-body { padding: 10px 12px 12px; }

/* Embed row density: the toggle switch is already at the 38×24 tap-target floor
   (≥24px, can't shrink without failing the Lighthouse/WCAG 2.5.8 audit), so the
   "chunky" feel comes from the row height — tighten vertical padding + the count
   line so each layer row is compact without touching the switch hit-area. */
.embed-frame .gis-layer-item { padding: 5px 4px; gap: 7px; }
.embed-frame .gis-layer-item .gis-layer-name { line-height: 1.2; }
.embed-frame .gis-layer-item .gis-layer-count,
.embed-frame .gis-layer-summary { font-size: 0.6875rem; }
.embed-frame .gis-layer-list { max-height: clamp(110px, 26vh, 230px); }

/* ── Embed launcher (toolbar layer-group button) ─────────────────────────
   A normal .gis-toolbar-btn that also carries an inline label. Hidden on /Map
   full page (not .embed-frame) — there the rail is always open. Hidden when the
   rail is open so a leftover pill never floats under the card (the user's
   "ลอยจนน่าเกลียด" worry). It sits inside .gis-share-group / .gis-toolbar--top,
   a SIBLING of <aside>, so it never slides off-canvas with the parked rail. */
/* ⚠️ The "modern theme" .gis-toolbar-btn (line ~1200) is `display:inline-flex`
   + a 40×40 CIRCLE, and sits LATER in source order at the SAME specificity
   (0,1,0) as a bare `.gis-sidebar-toggle--embed`. So both the hide-default AND
   the pill geometry must be written at 0,2,0 (`.gis-toolbar-btn.gis-…`) to win.
   Hidden by default → only shown inside .embed-frame. */
.gis-toolbar-btn.gis-sidebar-toggle--embed { display: none; }
.embed-frame .gis-toolbar-btn.gis-sidebar-toggle--embed {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  /* Undo the circular 40×40 so the "ชั้นข้อมูล" label fits — a rounded pill. */
  width: auto;
  height: auto;
  min-height: 32px;
  border-radius: 8px;
  padding: 5px 10px;
}
.gis-sidebar-toggle-label {
  font-size: 0.78125rem;
  font-weight: 600;
  white-space: nowrap;
}
/* Once the card is open, retire the launcher (the card's own × dismisses it).
   .gis-toolbar--top precedes .gis-sidebar in source, so a sibling combinator off
   the rail isn't possible — JS mirrors the open flag onto the widget root. */
.embed-frame .gis-widget[data-gis-sidebar-state="open"] .gis-toolbar-btn.gis-sidebar-toggle--embed {
  display: none;
}

/* ── Embed close (×) inside the floating card ────────────────────────────
   Top-right of the card, only in embed. On /Map full page + ≤768 mobile the
   rail/drawer has no × (mobile uses its own handle), so keep it embed-only. */
.gis-sidebar-close { display: none; }
.embed-frame .gis-sidebar-close {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  position: absolute;
  top: 8px;
  right: 8px;
  z-index: 2;
  width: 30px;
  height: 30px;
  padding: 0;
  background: rgba(255, 255, 255, 0.92);
  border: 1px solid #e5e7eb;
  border-radius: 8px;
  color: #6b7280;
  cursor: pointer;
  transition: background-color 0.15s, color 0.15s;
}
.embed-frame .gis-sidebar-close:hover {
  background: #f3f4f6;
  color: #111827;
}
.embed-frame .gis-sidebar-close i { font-size: 0.875rem; }
/* Reserve room so the × close (floating top-right of the card) never overlaps
   the first panel's title — apply the clearance to the HEADER ROW only, not the
   whole panel (padding the whole panel pushed every layer row ~34px narrow and
   left a white gutter on the right of the layer list — only on ชั้นข้อมูล). */
.embed-frame .gis-sidebar-body { padding-top: 12px; }
.embed-frame .gis-sidebar-body > :first-child .gis-panel-header { padding-right: 34px; }

/* — headers / section titles — */
.embed-frame .gis-panel-title { font-size: 0.8125rem; }
.embed-frame .gis-layer-summary,
.embed-frame .gis-filter-label { font-size: 0.6875rem; }

/* — layer rows: name + count + dot scaled to match the toggle below — */
.embed-frame .gis-layer-name { font-size: 0.78125rem; }
.embed-frame .gis-layer-count,
.embed-frame .gis-layer-zoom-indicator { font-size: 0.6875rem; }
.embed-frame .gis-layer-item { padding-top: 5px; padding-bottom: 5px; }
.embed-frame .gis-layer-marker-dot { width: 9px; height: 9px; }

/* — the iOS toggle: 44×28 → 38×24 (≥24px tap target), knob + travel in ratio — */
.embed-frame .gis-layer-switch { min-width: 38px; width: 38px; height: 24px; }
.embed-frame .gis-layer-switch::after { width: 16px; height: 16px; margin-top: -8px; left: 3px; }
.embed-frame .gis-layer-switch[aria-checked="true"]::after { transform: translateX(13px); }

/* — filter chips, tags, search — */
.embed-frame .gis-filter-chip,
.embed-frame .gis-filter-tag { font-size: 0.71875rem; padding: 3px 9px; }
.embed-frame .gis-filter-chip-count { font-size: 0.625rem; }
.embed-frame .gis-search-input { font-size: 0.78125rem; min-height: 34px; }
.embed-frame .gis-search-item-name { font-size: 0.78125rem; }
.embed-frame .gis-search-item-layer,
.embed-frame .gis-search-hint { font-size: 0.6875rem; }

/* — basemap selector — */
.embed-frame .gis-basemap-select {
  min-height: 32px;
  padding: 4px 9px;
  font-size: 0.78125rem;
  max-width: 158px;
}

/* — top toolbar (copy/embed/share buttons) — */
.embed-frame .gis-toolbar { padding: 5px 7px; gap: 4px; }
.embed-frame .gis-toolbar-btn { min-width: 32px; min-height: 32px; padding: 5px 8px; font-size: 0.8125rem; }

/* — lang button: mounted with inline sizing by gis-language-switcher.js → !important — */
.embed-frame .gis-lang-toggle {
  min-width: 36px !important;
  min-height: 36px !important;
  font-size: 0.78125rem !important;
  padding: 5px 9px !important;
}

/* — mobile bottom-drawer handle — */
.embed-frame .gis-sidebar-toggle--mobile { min-height: 38px; }

/* — icons step down with everything else (the detail that was missing: the
     toggle + box + text shrank but the fa-icons stayed full size). Chevrons,
     sliders, search, clear-X, toolbar glyphs all ~13% smaller. — */
.embed-frame .gis-toolbar-btn i { font-size: 0.75rem; }
.embed-frame .gis-panel-collapse i,
.embed-frame .gis-panel-toggle i { font-size: 0.8125rem; }
.embed-frame .gis-search-icon,
.embed-frame .gis-search > i,
.embed-frame .gis-search-input + i { font-size: 0.75rem; }
.embed-frame .gis-search-clear i,
.embed-frame .gis-filter-clear i { font-size: 0.6875rem; }
.embed-frame .gis-sidebar-toggle--mobile i { font-size: 0.875rem; }

.gis-toolbar-btn {
  min-width: 36px;
  min-height: 36px;
  padding: 6px 10px;
  background: transparent;
  border: 1px solid transparent;
  border-radius: 6px;
  color: #1f2937;
  cursor: pointer;
  transition: background-color 0.15s, border-color 0.15s;
  font-size: 0.875rem;
}

.gis-toolbar-btn:hover {
  background: #f3f4f6;
  border-color: #d1d5db;
}

.gis-basemap-select {
  min-height: 36px;
  padding: 4px 10px;
  border: 1px solid #d1d5db;
  border-radius: 6px;
  background: #fff;
  color: #1f2937;
  font-family: inherit;
  font-size: 0.8125rem;
  max-width: 180px;
}

.gis-share-group {
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

/* GIS sidebar — desktop persistent right rail, mobile drawer */
.gis-sidebar {
  position: absolute;
  top: 120px;
  bottom: 16px;
  right: 9px;
  z-index: 1040;
  width: 320px;
  max-width: calc(100vw - 24px);
  display: flex;
  flex-direction: column;
  background: #ffffff;
  border: 1px solid #e5e7eb;
  border-radius: 12px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.12);
  overflow: hidden;
}

.gis-sidebar-body {
  flex: 1 1 auto;
  overflow-y: auto;
  padding: 12px 14px 14px;
}

.gis-sidebar-toggle--mobile {
  display: none;
}

.gis-panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 8px;
}

.gis-panel-title {
  font-size: 0.875rem;
  font-weight: 600;
  color: #111827;
  margin: 0;
}

.gis-panel-collapse {
  min-width: 32px;
  min-height: 32px;
  background: transparent;
  border: 1px solid transparent;
  border-radius: 6px;
  color: #6b7280;
  cursor: pointer;
}

.gis-panel-collapse:hover {
  background: #f3f4f6;
  border-color: #d1d5db;
}

/* ── Layer panel ─────────────────────────────────────────────────────── */
.gis-layer-panel {
  margin-bottom: 16px;
}

.gis-layer-list {
  list-style: none;
  margin: 0;
  padding: 0;
  /* Cap the layer list so a long map (12+ layers) scrolls INTERNALLY instead of
     shoving the filter panel far down the sidebar. Keeps filters reachable
     without scrolling past the whole layer list. */
  max-height: clamp(160px, 32vh, 340px);
  overflow-y: auto;
  /* room for the scrollbar so it doesn't overlap the toggle switches */
  padding-right: 2px;
  scrollbar-width: thin;
}

/* Layer-panel header: keep the title + live count together on the left, the
   collapse chevron on the right. Center-align (not baseline): the title is an
   inline-flex with an 18px ::before accent bar, whose flex baseline is the box
   bottom — baseline-aligning the smaller count to that made "N ชั้น" visually
   drop below the title. Center keeps the count vertically aligned with it. */
.gis-panel-titlebar {
  display: flex;
  align-items: center;
  gap: 6px;
  min-width: 0;
}

.gis-layer-summary {
  font-size: 0.75rem;
  font-weight: 500;
  color: #6b7280;
  white-space: nowrap;
}

.gis-layer-list .gis-layer-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 4px;
  border-bottom: 1px solid #f3f4f6;
}

.gis-layer-list .gis-layer-item:last-child {
  border-bottom: 0;
}

.gis-layer-switch {
  /* Round-9 fix — was width:44px + height:24px but min-height:28px → final
       28px tall; thumb top:2px sat off-center. Unify height = min-height. */
  min-width: 44px;
  width: 44px;
  height: 28px;
  position: relative;
  background: #d1d5db;
  border: 1px solid #9ca3af;
  border-radius: 999px;
  cursor: pointer;
  padding: 0;
  flex-shrink: 0;
  transition: background-color 0.15s, border-color 0.15s;
}

.gis-layer-switch::after {
  content: "";
  position: absolute;
  top: 50%;
  left: 3px;
  width: 18px;
  height: 18px;
  margin-top: -9px;
  background: #fff;
  border-radius: 50%;
  transition: transform 0.15s;
}

.gis-layer-switch[aria-checked="true"] {
  background: #2563eb;
  border-color: #1d4ed8;
}

.gis-layer-switch[aria-checked="true"]::after {
  transform: translateX(20px);
}

.gis-layer-meta {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
  flex: 1;
}

.gis-layer-name {
  font-size: 0.8125rem;
  color: #1f2937;
  font-weight: 500;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.gis-layer-count {
  font-size: 0.6875rem;
  color: #6b7280;
}

.gis-layer-zoom-indicator {
  font-size: 0.6875rem;
  color: #6b7280;
  background: #f3f4f6;
  padding: 2px 6px;
  border-radius: 999px;
  flex-shrink: 0;
}

.gis-layer-marker-dot {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  border: 1px solid #9ca3af; /* 3.4:1 — WCAG 1.4.11 non-text contrast */
  flex-shrink: 0;
}

.gis-layer-empty {
  padding: 12px 4px;
  color: #6b7280;
  font-size: 0.8125rem;
  text-align: center;
}

/* ── Filter panel ────────────────────────────────────────────────────── */
.gis-filter-panel {
  margin-bottom: 8px;
}

.gis-filter-fieldset {
  border: 0;
  padding: 0;
  margin: 0;
}

.gis-filter-row {
  display: flex;
  flex-direction: column;
  gap: 4px;
  margin-bottom: 10px;
}

/* Browser default `[hidden] { display: none }` loses the specificity battle
   against `.gis-filter-row { display: flex }`, leaving JS-toggled
   empty Sub-category / Tag rows visible with only their label.
   Restore hide. */
.gis-filter-row[hidden] {
  display: none !important;
}

.gis-filter-label {
  font-size: 0.75rem;
  color: #374151;
  font-weight: 500;
}

.gis-filter-select,
.gis-filter-input {
  min-height: 36px;
  padding: 6px 10px;
  border: 1px solid #9ca3af; /* 3.4:1 */
  border-radius: 6px;
  background: #fff;
  color: #1f2937;
  font-family: inherit;
  font-size: 0.8125rem;
  width: 100%;
}

.gis-filter-select--short {
  max-width: 140px;
}

.gis-filter-select:focus-visible,
.gis-filter-input:focus-visible {
  outline: 2px solid #2563eb;
  outline-offset: 1px;
  border-color: #2563eb;
}

.gis-filter-inline {
  display: flex;
  gap: 6px;
  align-items: stretch;
}

.gis-filter-inline .gis-filter-input {
  flex: 1;
}

.gis-filter-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.gis-filter-tag {
  min-height: 32px;
  padding: 4px 10px;
  background: #fff;
  border: 1px solid #9ca3af;
  border-radius: 999px;
  font-size: 0.75rem;
  color: #1f2937;
  cursor: pointer;
}

.gis-filter-tag[aria-checked="true"] {
  background: #1f2937;
  border-color: #1f2937;
  color: #fff;
}

.gis-filter-actions {
  display: flex;
  gap: 8px;
  margin-top: 12px;
}

.gis-filter-apply,
.gis-filter-clear {
  min-height: 36px;
  padding: 6px 14px;
  border-radius: 6px;
  font-family: inherit;
  font-size: 0.8125rem;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.gis-filter-apply {
  background: #2563eb;
  border: 1px solid #1d4ed8;
  color: #fff;
}

.gis-filter-apply:hover {
  background: #1d4ed8;
}

.gis-filter-clear {
  background: #fff;
  border: 1px solid #9ca3af;
  color: #374151;
}

.gis-filter-clear:hover {
  background: #f3f4f6;
}

/* ============================================================================
   TOR 5.4.3.16 C10 — multi-chip category filter (public viewer)
   ============================================================================ */

.gis-filter-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 4px;
}

/* Panda-final P0-B fix — WCAG 2.5.5 + BMA mobile-first floor = 44×44 touch.
   Citizen-facing map chips are thumb-driven. Was 32px desktop / 36px mobile.
   Viper-final M4 — `white-space: nowrap` + label `text-overflow: ellipsis`
   prevent long Thai labels wrapping to two lines (which would defeat the
   44px touch floor by shrinking effective tap area). */
.gis-filter-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 44px;
  padding: 8px 14px;
  white-space: nowrap;
  background: #fff;
  border: 1px solid #9ca3af;
  border-radius: 999px;
  font-family: inherit;
  font-size: 0.75rem;
  color: #1f2937;
  cursor: pointer;
  transition: background-color 120ms, border-color 120ms, color 120ms,
    transform 80ms;
}

.gis-filter-chip:hover {
  background: #f0fdf4;
  border-color: #007744;
}

.gis-filter-chip:focus-visible {
  outline: 2px solid #007744;
  outline-offset: 2px;
}

.gis-filter-chip--selected {
  background: #007744;
  border-color: #005c33;
  color: #fff;
}

.gis-filter-chip--selected:hover {
  background: #005c33;
}

.gis-filter-chip--null {
  border-style: dashed;
  color: #475569;
  font-style: italic;
}
.gis-filter-chip--null.gis-filter-chip--selected {
  background: #475569;
  border-color: #334155;
  color: #fff;
  font-style: normal;
}

.gis-filter-chip-swatch {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 18px;
  height: 18px;
  border-radius: 999px;
  background: #6c757d;
  color: #fff;
  font-size: 10px;
  flex: 0 0 18px;
}

.gis-filter-chip-label {
  line-height: 1.2;
  max-width: 160px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* Panda-final P2 #6 — opacity 0.85 on selected chip = white text on green
   bg ≈ 5.5:1 (passes AA but tight on color-blocked retina). Bumped to 1.0
   so count badge keeps full contrast inside selected state. */
.gis-filter-chip-count {
  font-size: 0.6875rem;
  opacity: 1;
  color: inherit;
}

@media (max-width: 768px) {
  .gis-filter-chips {
    /* Mobile: scroll horizontally if chip list overflows; bottom-drawer
           layout still wraps via existing parent flex constraints. */
    flex-wrap: wrap;
    max-height: 50vh;
    overflow-y: auto;
  }
  .gis-filter-chip,
  .gis-filter-tag {
    min-height: 44px;
    padding: 10px 14px;
  }
}

/* ── Identify popup (Leaflet) ────────────────────────────────────────── */
.gis-feature-detail {
  max-width: 320px;
  min-width: 220px;
  padding: 4px;
}

.gis-feature-head {
  margin-bottom: 6px;
}

.gis-feature-name {
  font-size: 0.875rem;
  font-weight: 600;
  color: #111827;
  margin: 0 0 4px;
  line-height: 1.3;
}

.gis-feature-cat {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 999px;
  background: #ddd6fe;
  color: #5b21b6;
  font-size: 0.6875rem;
  font-weight: 500;
}

.gis-feature-attrs {
  margin: 0 0 6px;
  padding: 6px 0;
  border-top: 1px solid #f3f4f6;
  border-bottom: 1px solid #f3f4f6;
  font-size: 0.8125rem;
  color: #374151;
  line-height: 1.5;
  display: grid;
  grid-template-columns: minmax(0, auto) minmax(0, 1fr);
  column-gap: 8px;
  row-gap: 2px;
}

.gis-feature-attrs dt {
  color: #6b7280;
  font-weight: 500;
}

.gis-feature-attrs dd {
  margin: 0;
  color: #111827;
  overflow-wrap: anywhere;
}

.gis-feature-foot {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 6px;
}

.gis-feature-share,
.gis-feature-link {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 6px 10px;
  min-height: 32px;
  background: #f3f4f6;
  color: #1f2937;
  border: 1px solid #d1d5db;
  border-radius: 6px;
  font-size: 0.75rem;
  text-decoration: none;
  cursor: pointer;
}

.gis-feature-share:hover,
.gis-feature-link:hover {
  background: #e5e7eb;
}

/* ── Mobile ──────────────────────────────────────────────────────────── */
@media (max-width: 768px) {
  /* ⚠️ Specificity gotcha: the embed off-canvas card above uses
     `.embed-frame .gis-sidebar` (0,2,0), declared OUTSIDE any media query, so
     it out-specifies a bare `.gis-sidebar` (0,1,0) here REGARDLESS of source
     order. At ≤768 we want the proven translateY bottom-sheet, so every rule
     that must beat the embed card is written at `.embed-frame .gis-sidebar`
     too (equal specificity → later source order wins). /Map (non-embed) keeps
     using the plain `.gis-sidebar` rules. */
  .gis-sidebar,
  .embed-frame .gis-sidebar {
    top: auto;
    /* True bottom-sheet: flush to the page bottom + full width (no floating
       gap). Only the top corners are rounded since the sheet meets the page
       edge. The peek/open transform rides this bottom:0 anchor. */
    bottom: 0;
    right: 0;
    left: 0;
    width: auto;
    /* Override the base .gis-sidebar max-width:calc(100vw-24px) so the sheet is
       truly full-width (it was leaving a ~24px gap on the right). */
    max-width: none;
    max-height: 60vh;
    border-radius: 16px 16px 0 0;
    transform: translateY(calc(100% - 56px));
    transition: transform 0.2s;
    /* Drop the embed card's floating-panel shadow back to the drawer's. */
    box-shadow: 0 -4px 16px rgba(0, 0, 0, 0.15);
  }

  .gis-sidebar[data-gis-sidebar-open="true"],
  .embed-frame .gis-sidebar[data-gis-sidebar-open="true"] {
    transform: translateY(0);
  }

  /* Bottom-sheet uses the green handle, not the toolbar launcher or the ×.
     Match the 0,2,0 show-rule specificity so this later-source hide wins. */
  .embed-frame .gis-toolbar-btn.gis-sidebar-toggle--embed,
  .embed-frame .gis-sidebar-close {
    display: none;
  }

  .gis-sidebar-toggle--mobile {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    min-height: 44px;
    background: #007744;
    color: #fff;
    border: 0;
    cursor: pointer;
  }
  .gis-sidebar-toggle--mobile:hover {
    background: #005c33;
  }

  .gis-sidebar-body {
    padding: 10px 12px 12px;
  }

  .gis-toolbar--top {
    top: 64px;
    right: 8px;
  }

  .gis-basemap-select {
    max-width: 120px;
  }
}

/* ==========================================================================
   GIS Widget — Modern theme (2026-05 polish pass)
   Overrides + extends the earlier base styles for a contemporary look.
   Design tokens: indigo primary, soft shadows, larger radius, glassmorphism.
   ========================================================================== */

:root {
  /* GOV.BKK brand palette (mirror govbkk.css CI green) */
  --gis-primary: #007744;
  --gis-primary-strong: #005c33;
  --gis-primary-mint: #6faa8a;
  --gis-primary-soft: #dcfce7;
  --gis-primary-softer: #f0fdf4;
  /* Lighter siblings used in linear gradients (replace legacy indigo) */
  --gis-primary-light: #2d9b6a;
  --gis-primary-shadow-rgb: 0, 92, 51;
  --gis-accent: #e8a447;
  --gis-accent-soft: #fff3d9;
  --gis-surface: #ffffff;
  --gis-surface-2: #f9fafb;
  --gis-border: #e5e7eb;
  --gis-text: #111827;
  --gis-text-muted: #6b7280;
  --gis-radius-lg: 16px;
  --gis-radius-md: 12px;
  --gis-radius-sm: 8px;
  --gis-shadow-soft: 0 10px 25px -10px rgba(0, 92, 51, 0.22),
    0 4px 8px -4px rgba(15, 23, 42, 0.08);
  --gis-shadow-pop: 0 20px 40px -12px rgba(0, 92, 51, 0.3),
    0 6px 12px -6px rgba(15, 23, 42, 0.12);
}

/* Map host — soft cream fallback (matches CI peach) instead of dead gray */
.gis-map-host {
  background: linear-gradient(180deg, #fff3d9 0%, #f0fdf4 100%);
}

/* Floating topbar — pill with backdrop blur */
.map-topbar-floating {
  background: rgba(255, 255, 255, 0.85);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border: 1px solid rgba(255, 255, 255, 0.6);
  border-radius: 999px;
  padding: 6px 16px 6px 6px;
  box-shadow: var(--gis-shadow-soft);
}

.map-topbar-floating .back-btn {
  width: 36px;
  height: 36px;
  background: var(--gis-primary);
  color: #fff;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  text-decoration: none;
  transition: background-color 0.15s, transform 0.15s;
}

.map-topbar-floating .back-btn:hover {
  background: var(--gis-primary-strong);
  transform: scale(1.05);
}

/* Toolbar — glassmorphism pill */
.gis-toolbar {
  background: rgba(255, 255, 255, 0.92);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border: 1px solid rgba(255, 255, 255, 0.6);
  border-radius: 999px;
  padding: 6px 8px;
  box-shadow: var(--gis-shadow-soft);
  gap: 4px;
}

.gis-toolbar-btn {
  width: 40px;
  height: 40px;
  padding: 0;
  border-radius: 50%;
  color: var(--gis-text-muted);
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.gis-toolbar-btn:hover {
  background: var(--gis-primary-soft);
  border-color: transparent;
  color: var(--gis-primary);
}

.gis-share-group {
  gap: 2px;
  padding-left: 6px;
  border-left: 1px solid var(--gis-border);
  margin-left: 4px;
}

.gis-basemap-select {
  min-height: 40px;
  padding: 6px 28px 6px 14px;
  border: 1px solid transparent;
  border-radius: 999px;
  background: var(--gis-primary-soft)
    url("data:image/svg+xml;charset=UTF-8,%3csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12' fill='none'%3e%3cpath d='M3 4.5L6 7.5L9 4.5' stroke='%234f46e5' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'/%3e%3c/svg%3e")
    no-repeat right 10px center;
  color: var(--gis-primary-strong);
  font-weight: 500;
  font-size: 0.8125rem;
  appearance: none;
  -webkit-appearance: none;
  max-width: 220px;
  cursor: pointer;
}

.gis-basemap-select:hover {
  background-color: #e0e7ff;
}
.gis-basemap-select:focus-visible {
  outline: 2px solid var(--gis-primary);
  outline-offset: 2px;
  border-color: var(--gis-primary);
}

/* Sidebar — frosted card */
.gis-sidebar {
  width: 340px;
  background: rgba(255, 255, 255, 0.96);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 1px solid rgba(255, 255, 255, 0.7);
  border-radius: var(--gis-radius-lg);
  box-shadow: var(--gis-shadow-soft);
}

.gis-sidebar-body {
  padding: 18px 18px 20px;
}

/* Panel header — colored title chip */
.gis-panel-header {
  margin-bottom: 12px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--gis-border);
}

.gis-panel-title {
  font-size: 0.9375rem;
  font-weight: 700;
  color: var(--gis-text);
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.gis-layer-panel .gis-panel-title::before {
  content: "";
  width: 4px;
  height: 18px;
  background: linear-gradient(
    180deg,
    var(--gis-primary),
    var(--gis-primary-light)
  );
  border-radius: 999px;
  display: inline-block;
}

.gis-filter-panel .gis-panel-title::before {
  content: "";
  width: 4px;
  height: 18px;
  background: linear-gradient(180deg, #f59e0b, #fbbf24);
  border-radius: 999px;
  display: inline-block;
}

.gis-panel-collapse {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  color: var(--gis-text-muted);
}

.gis-panel-collapse:hover {
  background: var(--gis-primary-soft);
  color: var(--gis-primary);
  border-color: transparent;
}

/* Layer panel — card per layer */
.gis-layer-panel {
  margin-bottom: 20px;
}

.gis-layer-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.gis-layer-list .gis-layer-item {
  background: var(--gis-surface-2);
  border: 1px solid transparent;
  border-radius: var(--gis-radius-sm);
  padding: 10px 12px;
  gap: 10px;
  transition: background-color 0.15s, border-color 0.15s, transform 0.15s;
}

.gis-layer-list .gis-layer-item:hover {
  background: #fff;
  border-color: var(--gis-border);
  transform: translateY(-1px);
}

.gis-layer-list .gis-layer-item:last-child {
  border-bottom: 1px solid transparent;
}

.gis-layer-marker-dot {
  width: 16px;
  height: 16px;
  border: 2px solid #fff;
  box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.15), 0 2px 4px rgba(0, 0, 0, 0.12);
}

.gis-layer-name {
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--gis-text);
}

.gis-layer-count {
  font-size: 0.75rem;
  color: var(--gis-text-muted);
  font-weight: 500;
}

.gis-layer-zoom-indicator {
  background: var(--gis-primary-soft);
  color: var(--gis-primary-strong);
  font-weight: 500;
}

.gis-layer-switch {
  background: #cbd5e1;
  border-color: transparent;
  box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.1);
}

.gis-layer-switch[aria-checked="true"] {
  background: linear-gradient(
    135deg,
    var(--gis-primary),
    var(--gis-primary-light)
  );
  border-color: transparent;
}

.gis-layer-switch::after {
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.18);
}

.gis-layer-empty {
  background: var(--gis-surface-2);
  border: 1px dashed var(--gis-border);
  border-radius: var(--gis-radius-md);
  padding: 24px 12px;
  color: var(--gis-text-muted);
}

.gis-layer-empty::before {
  content: "🗺️";
  display: block;
  font-size: 2rem;
  margin-bottom: 4px;
  opacity: 0.6;
}

/* Filter panel */
.gis-filter-row {
  gap: 6px;
  margin-bottom: 14px;
}

.gis-filter-label {
  /* Thai script doesn't have casing — uppercase + wide letter-spacing
       (panda P1) was a Latin-only nicety that broke Thai legibility. */
  font-size: 0.8125rem;
  font-weight: 600;
  color: var(--gis-text);
}

.gis-filter-select,
.gis-filter-input {
  min-height: 40px;
  padding: 8px 12px;
  border: 1px solid var(--gis-border);
  border-radius: var(--gis-radius-sm);
  background: var(--gis-surface);
  color: var(--gis-text);
  font-size: 0.875rem;
  transition: border-color 0.15s, box-shadow 0.15s;
}

.gis-filter-select {
  padding-right: 32px;
  background-image: url("data:image/svg+xml;charset=UTF-8,%3csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12' fill='none'%3e%3cpath d='M3 4.5L6 7.5L9 4.5' stroke='%236b7280' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'/%3e%3c/svg%3e");
  background-repeat: no-repeat;
  background-position: right 10px center;
  appearance: none;
  -webkit-appearance: none;
}

.gis-filter-select:focus-visible,
.gis-filter-input:focus-visible {
  outline: none;
  border-color: var(--gis-primary);
  box-shadow: 0 0 0 3px rgba(0, 119, 68, 0.18);
}

.gis-filter-tag {
  background: var(--gis-primary-soft);
  border-color: transparent;
  color: var(--gis-primary-strong);
  font-weight: 500;
  padding: 6px 12px;
  transition: background-color 0.15s, color 0.15s;
}

/* On-brand green hover (was indigo #e0e7ff — brand-drift on the green widget). */
.gis-filter-tag:hover {
  background: rgba(0, 119, 68, 0.16);
}

.gis-filter-tag:focus-visible {
  outline: none;
  box-shadow: 0 0 0 3px rgba(0, 119, 68, 0.35);
}

.gis-filter-tag[aria-checked="true"] {
  background: linear-gradient(
    135deg,
    var(--gis-primary),
    var(--gis-primary-light)
  );
  border-color: transparent;
  color: #fff;
  box-shadow: 0 2px 6px rgba(0, 119, 68, 0.35);
}

.gis-filter-actions {
  gap: 10px;
  padding-top: 4px;
  border-top: 1px dashed var(--gis-border);
  margin-top: 14px;
}

.gis-filter-apply {
  min-height: 40px;
  flex: 1;
  background: linear-gradient(
    135deg,
    var(--gis-primary),
    var(--gis-primary-light)
  );
  border: 0;
  color: #fff;
  font-weight: 600;
  padding: 8px 16px;
  box-shadow: 0 4px 10px rgba(0, 119, 68, 0.35);
  transition: transform 0.1s, box-shadow 0.15s;
}

.gis-filter-apply:hover {
  background: linear-gradient(
    135deg,
    var(--gis-primary-strong),
    var(--gis-primary-strong)
  );
  transform: translateY(-1px);
  box-shadow: 0 6px 14px rgba(0, 119, 68, 0.45);
}

.gis-filter-clear {
  min-height: 40px;
  background: transparent;
  border: 1px solid var(--gis-border);
  color: var(--gis-text-muted);
  padding: 8px 16px;
  font-weight: 500;
}

.gis-filter-clear:hover {
  background: var(--gis-surface-2);
  color: var(--gis-text);
}

/* Identify popup — modern card with colored head */
.leaflet-popup-content-wrapper {
  border-radius: var(--gis-radius-md) !important;
  box-shadow: var(--gis-shadow-pop) !important;
  padding: 0 !important;
  overflow: hidden;
}

.leaflet-popup-content {
  margin: 0 !important;
  width: auto !important;
  min-width: 280px;
  max-width: min(420px, 92vw);
}

.leaflet-popup-tip {
  box-shadow: var(--gis-shadow-pop);
}

.gis-feature-detail {
  max-width: 420px;
  min-width: 280px;
  padding: 0;
  font-family: inherit;
}

.gis-feature-head {
  padding: 14px 16px 12px;
  background: linear-gradient(
    135deg,
    var(--gis-primary),
    var(--gis-primary-light)
  );
  color: #fff;
  margin: 0;
  position: relative;
}

.gis-feature-head::after {
  content: "";
  position: absolute;
  inset: 0;
  background: radial-gradient(
    circle at top right,
    rgba(255, 255, 255, 0.25),
    transparent 60%
  );
  pointer-events: none;
}

.gis-feature-name {
  font-size: 1rem;
  font-weight: 700;
  color: #fff;
  margin: 0 0 4px;
  line-height: 1.3;
  position: relative;
}

.gis-feature-cat {
  /* Solid darker fill = readable white text on green-gradient header
       (WCAG 1.4.3 — translucent 25% white over green failed 4.5:1). */
  background: rgba(0, 0, 0, 0.28);
  color: #ffffff;
  font-weight: 600;
  position: relative;
}

/* Force hide when no categoryName resolved — base .gis-feature-cat carries
   display:inline-block which overrode the hidden attribute, leaving a thin
   translucent bar under the name. */
.gis-feature-cat[hidden] {
  display: none !important;
}

.gis-feature-attrs {
  padding: 12px 16px;
  margin: 0;
  border: 0;
  background: var(--gis-surface);
  font-size: 0.875rem;
  grid-template-columns: minmax(0, 110px) minmax(0, 1fr);
  column-gap: 12px;
  row-gap: 6px;
}

.gis-feature-attrs:empty {
  display: none;
}

.gis-feature-attrs dt {
  color: var(--gis-text-muted);
  font-weight: 600;
  font-size: 0.8125rem;
  padding-top: 2px;
}

.gis-feature-attrs dd {
  color: var(--gis-text);
  font-weight: 500;
}

/* Boolean chip in popup */
.gis-feature-bool {
  display: inline-block;
  padding: 2px 10px;
  border-radius: 999px;
  font-size: 0.75rem;
  font-weight: 600;
  background: #fee2e2;
  color: #b91c1c;
}

.gis-feature-bool--on {
  background: #dcfce7;
  color: #15803d;
}

/* Fallback states */
.gis-feature-attrs--desc,
.gis-feature-attrs--empty {
  display: block !important;
}

.gis-feature-desc {
  margin: 0;
  color: var(--gis-text);
  font-size: 0.875rem;
  line-height: 1.5;
}

.gis-feature-empty {
  margin: 0;
  color: var(--gis-text-muted);
  font-size: 0.8125rem;
  font-style: italic;
  text-align: center;
  padding: 4px 0;
}

.gis-feature-foot {
  padding: 10px 14px 12px;
  background: var(--gis-surface-2);
  border-top: 1px solid var(--gis-border);
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 0;
}

/* Round 9.1 — popup footer 3 buttons overflowed at ≤320px popup width.
   Use `min-width: max-content` so buttons keep their full label width
   (no clipping). flex-wrap:wrap on parent lets row break to 2 rows when
   needed. align-items:center keeps icons centered with text. */
.gis-feature-foot > .gis-feature-share,
.gis-feature-foot > .gis-feature-link {
  flex: 1 1 max-content;
  min-width: max-content;
  justify-content: center;
  align-items: center;
  white-space: nowrap;
}

.gis-feature-share {
  background: var(--gis-primary);
  color: #fff;
  border-color: transparent;
  font-weight: 600;
  padding: 8px 12px;
  box-shadow: 0 2px 6px rgba(0, 119, 68, 0.3);
  transition: background-color 0.15s, transform 0.1s;
}

.gis-feature-share:hover {
  background: var(--gis-primary-strong);
  transform: translateY(-1px);
}

.gis-feature-link {
  background: var(--gis-surface);
  border-color: var(--gis-border);
  color: var(--gis-text);
  font-weight: 500;
  padding: 8px 10px;
  transition: background-color 0.15s, border-color 0.15s;
}

.gis-feature-link:hover {
  background: var(--gis-primary-soft);
  border-color: var(--gis-primary);
  color: var(--gis-primary-strong);
}

/* Loading overlay — center spinner with backdrop */
.loading-overlay {
  position: absolute;
  inset: 0;
  z-index: 1100;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  gap: 14px;
  background: rgba(255, 255, 255, 0.7);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
}

.loading-overlay.hidden {
  display: none;
}

.loading-spinner {
  width: 44px;
  height: 44px;
  border: 4px solid var(--gis-primary-soft);
  border-top-color: var(--gis-primary);
  border-radius: 50%;
  animation: gis-spin 0.8s linear infinite;
}

.loading-text {
  font-weight: 600;
  color: var(--gis-text);
  font-size: 0.9375rem;
}

@keyframes gis-spin {
  to {
    transform: rotate(360deg);
  }
}

/* Mobile drawer — friendlier handle */
@media (max-width: 768px) {
  .gis-sidebar {
    border-radius: var(--gis-radius-lg) var(--gis-radius-lg) 0 0;
    transform: translateY(calc(100% - 64px));
  }
  .gis-sidebar-toggle--mobile {
    background: linear-gradient(
      135deg,
      var(--gis-primary),
      var(--gis-primary-light)
    );
    font-weight: 600;
    border-radius: var(--gis-radius-lg) var(--gis-radius-lg) 0 0;
    position: relative;
  }
  .gis-sidebar-toggle--mobile::before {
    content: "";
    position: absolute;
    top: 8px;
    left: 50%;
    width: 36px;
    height: 4px;
    background: rgba(255, 255, 255, 0.5);
    border-radius: 999px;
    transform: translateX(-50%);
  }
}

/* ========================================================================
   TOR 5.4.3.16 FI8 — deep-link feature highlight pulse (3s)
   Applied via gis-map-widget.js when ?feature=<id> URL param resolves a
   marker. Visual cue helps citizens spot the focused marker on busy maps.
   ======================================================================== */
.gis-feature-deeplink-highlight {
  animation: gis-feature-pulse 1s ease-in-out infinite;
  filter: drop-shadow(0 0 6px #ffc107) drop-shadow(0 0 12px #ffc107);
  z-index: 1500 !important;
}

@keyframes gis-feature-pulse {
  0%,
  100% {
    transform: scale(1);
  }
  50% {
    transform: scale(1.18);
  }
}

/* ── Smart search input (TOR 5.4.3.16 (11) — replaces attribute filter row).
   Suggestion dropdown lists matched features across all layers; click pans + opens identify. */
.gis-search-row .gis-filter-label {
  margin-bottom: 6px;
}
.gis-search {
  position: relative;
  display: flex;
  align-items: center;
}
.gis-search-icon {
  position: absolute;
  left: 12px;
  color: #94a3b8;
  pointer-events: none;
  font-size: 0.875rem;
}
.gis-search-input {
  width: 100%;
  padding: 10px 38px 10px 36px;
  border: 1.5px solid #cbd5e1;
  border-radius: 12px;
  background: #fff;
  font-size: 0.9375rem;
  color: #1e293b;
  transition: border-color 0.15s, box-shadow 0.15s;
}
.gis-search-input::-webkit-search-cancel-button {
  display: none;
}
.gis-search-input:focus {
  outline: none;
  border-color: var(--gis-primary, #007744);
  box-shadow: 0 0 0 3px rgba(0, 119, 68, 0.16);
}
.gis-search-clear {
  position: absolute;
  right: 8px;
  width: 24px;
  height: 24px;
  border: 0;
  border-radius: 50%;
  background: #f1f5f9;
  color: #475569;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 0.75rem;
}
.gis-search-clear:hover {
  background: #e2e8f0;
  color: #1e293b;
}
.gis-search-clear:focus-visible {
  outline: 2px solid var(--gis-primary, #007744);
  outline-offset: 2px;
}
.gis-search-suggestions {
  position: absolute;
  top: calc(100% + 6px);
  left: 0;
  right: 0;
  z-index: 1200;
  max-height: 320px;
  overflow-y: auto;
  margin: 0;
  padding: 4px;
  background: #fff;
  border: 1px solid #cbd5e1;
  border-radius: 12px;
  box-shadow: 0 16px 36px rgba(15, 23, 42, 0.14);
  list-style: none;
}
.gis-search-suggestions[hidden] {
  display: none;
}
.gis-search-item {
  padding: 10px 12px;
  border-radius: 8px;
  cursor: pointer;
  font-size: 0.9375rem;
  color: #1e293b;
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.gis-search-item:hover,
.gis-search-item.active {
  background: #f0fdf4;
  color: #064e3b;
}
.gis-search-item-name {
  font-weight: 600;
}
.gis-search-item-layer {
  font-size: 0.75rem;
  color: #64748b;
}
.gis-search-empty,
.gis-search-loading {
  padding: 10px 12px;
  font-size: 0.875rem;
  color: #94a3b8;
  font-style: italic;
}
.gis-search-hint {
  padding: 8px 12px;
  font-size: 0.8125rem;
  color: #475569;
  line-height: 1.45;
  background: #f8fafc;
  border-bottom: 1px solid #f1f5f9;
}
.gis-search-hint:last-child { border-bottom: 0; }

/* Temporary highlight pin dropped at a search result's centroid so the
   user has a visual anchor even when the feature's parent layer is
   toggled off. Removed on popupclose. */
.gis-search-pin {
  background: transparent;
  border: 0;
}
.gis-search-pin i {
  color: #dc2626;
  font-size: 32px;
  text-shadow: 0 2px 4px rgba(0, 0, 0, 0.35);
  display: block;
  line-height: 1;
}
.gis-search-hint--muted {
  color: #64748b;
  font-size: 0.75rem;
  font-style: italic;
  background: transparent;
}

/* Smart-search a11y + mobile drawer polish (Panda review). */
.gis-search-item:focus-visible {
  outline: 2px solid var(--gis-primary, #007744);
  outline-offset: 2px;
}
@media (max-width: 768px) {
  /* Inside a bottom-sheet drawer, the suggestion list can clip if the parent
       has overflow:hidden — escape via position:fixed-style flow so the list
       can scroll independently. */
  .gis-search-suggestions {
    max-height: 60vh;
  }
  .gis-search-input {
    font-size: 1rem; /* avoid iOS 16+ auto-zoom */
  }
}
