/* Area map — shared by frontend/map.html and admin #/map. Keep
   frontend/map-core.css and admin/map-core.css byte-identical
   (tests/map-core-copies.test.ts checks).

   One look for every control (19 Oct 2026, "make the buttons and interface look better"):
   white cards with soft shadows and 12px corners, 44px touch rows, MYSA green for "on". */
.leaflet-container {
  --m-ink: #1A1A17; --m-muted: #6B6B66; --m-line: #ebebe5; --m-card: #fff; --m-hover: #f4f4f0;
  --m-green: #1F7A3A; --m-green-soft: #e8f4ed; --m-red: #b91c1c;
  --m-radius: 12px; --m-shadow: 0 2px 6px rgba(20,20,15,.14), 0 8px 24px rgba(20,20,15,.10);
  font-family: var(--font-sans, -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif);
  background: #e8e6df;
}
.mysa-pin { background: none; border: 0; }
.mysa-pin svg { display: block; filter: drop-shadow(0 1px 2px rgba(0,0,0,.35)); }
.mysa-drawing, .mysa-drawing .leaflet-interactive { cursor: crosshair !important; }

/* ---- Controls ---- */
.leaflet-left .leaflet-control, .leaflet-right .leaflet-control { margin-left: 10px; margin-right: 10px; }
.leaflet-top .leaflet-control { margin-top: 10px; }
/* The search bar runs across the top: the left column always moves down, the right one only on narrow maps. */
.mysa-has-searchbar .leaflet-top.leaflet-left { top: 54px; }
.mysa-has-searchbar.mysa-narrow .leaflet-top.leaflet-right { top: 54px; }

/* While a card is open on a narrow map, the side controls step aside (they always draw above cards). */
.leaflet-top.leaflet-left, .leaflet-top.leaflet-right { transition: opacity .15s; }
.mysa-narrow.mysa-card-open .leaflet-top.leaflet-left,
.mysa-narrow.mysa-card-open .leaflet-top.leaflet-right { opacity: 0; pointer-events: none; }
.mysa-narrow.mysa-card-open .leaflet-top.leaflet-left * , .mysa-narrow.mysa-card-open .leaflet-top.leaflet-right * { pointer-events: none !important; }

/* Zoom and GPS: the same white cards. */
.leaflet-bar { border: 0 !important; border-radius: var(--m-radius) !important; box-shadow: var(--m-shadow) !important; overflow: hidden; background: var(--m-card); }
.leaflet-bar a, .leaflet-touch .leaflet-bar a {
  width: 44px !important; height: 44px !important; line-height: 44px !important; font-size: 22px; color: var(--m-ink);
  border-bottom: 1px solid var(--m-line) !important; background: var(--m-card); display: flex; align-items: center; justify-content: center;
  border-radius: 0 !important;
}
.leaflet-bar a:last-child { border-bottom: 0 !important; }
.leaflet-bar a:hover { background: var(--m-hover); color: var(--m-ink); }
.leaflet-bar a.leaflet-disabled { color: #c4c4bc; background: var(--m-card); }
.mysa-locate a[aria-pressed="true"] { color: #2563eb; background: #eef4ff; }
.mysa-locate-note {
  position: absolute; left: 50%; bottom: 76px; transform: translateX(-50%); z-index: 1000;
  max-width: min(340px, calc(100% - 32px)); padding: 10px 14px; border-radius: var(--m-radius);
  background: rgba(26,26,23,.92); color: #fff; font-size: 0.8125rem; line-height: 1.4; text-align: center; box-shadow: var(--m-shadow);
}

/* The control card, top right: Map | Satellite, Layers, Full screen. */
.mysa-toolbar { width: 156px; background: var(--m-card); border-radius: var(--m-radius); box-shadow: var(--m-shadow); overflow: hidden; }
.mysa-tb-slot:empty { display: none; }
.mysa-tb-slot + .mysa-tb-slot:not(:empty) { border-top: 1px solid var(--m-line); }
.mysa-basemap { display: flex; padding: 4px; gap: 4px; background: var(--m-card); }
.mysa-basemap-btn {
  flex: 1; border: 0; background: transparent; color: var(--m-muted); font: inherit; font-size: 0.8125rem; font-weight: 600;
  min-height: 34px; border-radius: 8px; cursor: pointer; transition: background .15s, color .15s;
}
.mysa-basemap-btn:hover { background: var(--m-hover); color: var(--m-ink); }
.mysa-basemap-btn[aria-pressed="true"] { background: var(--m-green); color: #fff; box-shadow: 0 1px 2px rgba(0,0,0,.15); }
.mysa-tb-row {
  display: flex; align-items: center; gap: 10px; width: 100%; min-height: 44px; padding: 0 14px; border: 0; background: var(--m-card);
  color: var(--m-ink); font: inherit; font-size: 0.875rem; font-weight: 600; text-align: left; cursor: pointer; transition: background .15s;
}
.mysa-tb-row + .mysa-tb-row { border-top: 1px solid var(--m-line); }
.mysa-tb-row:hover { background: var(--m-hover); }
.mysa-tb-row svg { flex: none; color: var(--m-muted); }
.mysa-tb-row[aria-pressed="true"], .mysa-tb-row[aria-expanded="true"] { background: var(--m-green-soft); color: var(--m-green); }
.mysa-tb-row[aria-pressed="true"] svg, .mysa-tb-row[aria-expanded="true"] svg { color: var(--m-green); }

/* ---- Search bar ---- */
.mysa-search {
  position: absolute; top: 10px; left: 10px; right: 10px; z-index: 1150; max-width: 440px;
  background: var(--m-card); color: var(--m-ink); border-radius: 22px; box-shadow: var(--m-shadow); overflow: hidden;
}
.mysa-has-searchbar:not(.mysa-narrow) .mysa-search { right: auto; width: min(440px, calc(100% - 196px)); }
.mysa-search-row { display: flex; align-items: center; gap: 8px; height: 44px; padding: 0 6px 0 14px; }
.mysa-search-icon { display: flex; color: var(--m-muted); flex: none; }
.mysa-search-input { flex: 1; min-width: 0; border: 0; outline: none; font: inherit; font-size: 16px; padding: 0; background: none; color: inherit; }
.mysa-search-input::placeholder { color: #8d8d86; }
.mysa-search-input::-webkit-search-cancel-button { display: none; }
.mysa-search-clear { flex: none; width: 32px; height: 32px; border: 0; border-radius: 50%; background: var(--m-hover); color: var(--m-muted); font-size: 20px; line-height: 1; cursor: pointer; }
.mysa-search-clear[hidden] { display: none; }
.mysa-search:focus-within { box-shadow: var(--m-shadow), 0 0 0 3px rgba(31,122,58,.22); }
.mysa-search-results { max-height: min(50vh, 340px); overflow-y: auto; border-top: 1px solid var(--m-line); }
.mysa-search-results[hidden] { display: none; }
.mysa-search-hit { display: flex; flex-direction: column; align-items: flex-start; width: 100%; text-align: left; border: 0; background: none; padding: 10px 16px; cursor: pointer; font: inherit; color: inherit; border-top: 1px solid var(--m-line); }
.mysa-search-hit:first-child { border-top: 0; }
.mysa-search-hit:hover, .mysa-search-hit:focus, .mysa-search-hit.is-first { background: var(--m-green-soft); outline: none; }
.mysa-search-name { font-weight: 600; font-size: 0.9375rem; }
.mysa-search-type { font-size: 0.75rem; color: var(--m-muted); margin-top: 1px; }
.mysa-search-msg { padding: 12px 16px; font-size: 0.8125rem; color: var(--m-muted); }

/* ---- Cards (popups) ---- */
/* flow-root: with padding 0 the content's margins collapsed out of the card, leaving the buttons
   flush against its bottom edge (Nabil, 19 Oct 2026: "no margin ... below buttons"). */
.leaflet-popup-content-wrapper { display: flow-root; border-radius: 16px; box-shadow: 0 6px 16px rgba(20,20,15,.16), 0 18px 40px rgba(20,20,15,.14); padding: 0; }
.leaflet-popup-content { margin: 16px 18px 14px; }
.leaflet-popup-tip { box-shadow: none; }
.leaflet-container a.leaflet-popup-close-button {
  top: 8px; right: 8px; width: 30px; height: 30px; border-radius: 50%; font: 400 20px/30px system-ui, sans-serif;
  color: var(--m-muted); background: var(--m-hover); text-align: center;
}
.leaflet-container a.leaflet-popup-close-button:hover { color: var(--m-ink); background: var(--m-line); }
.mysa-popup { min-width: 180px; max-width: min(250px, 62vw); font-family: inherit; color: var(--m-ink); }
.mysa-popup-kind {
  display: inline-flex; align-items: center; gap: 6px; margin-right: 26px; padding: 3px 9px 3px 5px; border-radius: 999px;
  background: var(--m-hover); font-size: 0.6875rem; font-weight: 700; letter-spacing: 0.04em; text-transform: uppercase; color: var(--m-muted);
}
.mysa-popup-kind.mysa-popup-kind-danger { background: #fee2e2; color: #b91c1c; }
.mysa-popup-kind svg { width: 16px !important; height: 16px !important; display: block; flex: none; }
.mysa-popup-kind-sw { width: 12px; height: 12px; border-radius: 3px; flex: none; box-sizing: border-box; }
.mysa-popup-name { font-size: 1.0625rem; font-weight: 700; line-height: 1.25; margin-top: 8px; overflow-wrap: anywhere; }
.mysa-popup-alt { font-size: 0.9375rem; color: #44403c; margin-top: 2px; }
.mysa-popup-aka { margin-top: 2px; font-size: 12px; color: var(--m-muted); }
.mysa-popup-note { margin: 8px 0 0; font-size: 0.875rem; line-height: 1.45; white-space: pre-wrap; overflow-wrap: anywhere; }
.mysa-popup-meta { margin-top: 8px; font-size: 0.75rem; color: var(--m-muted); }
.mysa-popup-actions { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 12px; }

/* Coordinates, Copy, Open in Maps, Report. */
.mysa-coords { margin-top: 12px; padding: 10px 12px; border-radius: 10px; background: var(--m-hover); }
.mysa-coords-val { font: 600 0.8125rem/1.3 ui-monospace, SFMono-Regular, Menlo, monospace; color: var(--m-ink); user-select: all; -webkit-user-select: all; }
.mysa-coords-acts { display: flex; gap: 6px; margin-top: 8px; }
.mysa-coords-btn {
  flex: 1; display: inline-flex; align-items: center; justify-content: center; min-height: 34px; padding: 0 10px; border-radius: 999px;
  border: 1px solid #d4d4cc; background: #fff; color: var(--m-ink) !important; font: inherit; font-size: 0.8125rem; font-weight: 600;
  text-decoration: none; cursor: pointer; white-space: nowrap;
}
.mysa-coords-btn:hover { background: #fafaf7; }
a.mysa-coords-btn { background: var(--m-green); border-color: var(--m-green); color: #fff !important; }
a.mysa-coords-btn:hover { background: #196530; }
.mysa-coords-report { width: 100%; margin-top: 8px; border-color: #f1c4c4; background: #fff5f5; color: var(--m-red) !important; }
.mysa-coords-report:hover { background: #ffecec; }

/* ---- Layers screen ---- */
.mysa-layers {
  position: absolute; top: 10px; right: 10px; bottom: 10px; z-index: 1200; width: min(340px, calc(100% - 20px));
  display: flex; flex-direction: column; background: var(--m-card); color: var(--m-ink); border-radius: 16px;
  box-shadow: 0 12px 40px rgba(20,20,15,.28); font-size: 0.875rem; overflow: hidden;
}
.mysa-layers[hidden] { display: none; }
.mysa-layers-head { display: flex; align-items: center; justify-content: space-between; padding: 14px 14px 12px 18px; border-bottom: 1px solid var(--m-line); }
.mysa-layers-title { font-weight: 700; font-size: 1.0625rem; }
.mysa-layers-close { width: 32px; height: 32px; border: 0; border-radius: 50%; background: var(--m-hover); font-size: 20px; line-height: 1; cursor: pointer; color: var(--m-muted); }
.mysa-layers-close:hover { color: var(--m-ink); background: var(--m-line); }
.mysa-layers-body { overflow-y: auto; -webkit-overflow-scrolling: touch; padding: 4px 18px 18px; }
.mysa-layers-sec-title { margin: 18px 0 4px; font-size: 0.6875rem; font-weight: 700; letter-spacing: .07em; text-transform: uppercase; color: var(--m-muted); }
.mysa-layers-row { display: flex; align-items: flex-start; gap: 12px; padding: 9px 0; cursor: pointer; border-bottom: 1px solid var(--m-line); }
.mysa-layers-sec .mysa-layers-row:last-child { border-bottom: 0; }
/* On/off switch, at the end of the row. */
.mysa-layers-row input {
  order: 3; margin: 1px 0 0 auto; flex: none; appearance: none; -webkit-appearance: none; width: 40px; height: 24px; border-radius: 999px;
  background: #d6d6cf; position: relative; cursor: pointer; transition: background .18s;
}
.mysa-layers-row input::before {
  content: ''; position: absolute; top: 3px; left: 3px; width: 18px; height: 18px; border-radius: 50%; background: #fff;
  box-shadow: 0 1px 2px rgba(0,0,0,.25); transition: transform .18s;
}
.mysa-layers-row input:checked { background: var(--m-green); }
.mysa-layers-row input:checked::before { transform: translateX(16px); }
.mysa-layers-row input:focus-visible { outline: 3px solid rgba(31,122,58,.35); outline-offset: 2px; }
.mysa-layers-swatch { width: 20px; height: 16px; margin-top: 2px; flex: none; border-radius: 4px; box-sizing: border-box; }
.mysa-layers-text { display: flex; flex-direction: column; min-width: 0; flex: 1; }
.mysa-layers-name { font-weight: 600; }
.mysa-layers-meta { font-size: 0.75rem; color: var(--m-muted); margin-top: 1px; }
.mysa-layers-note { font-size: 0.75rem; color: #57534e; margin-top: 3px; line-height: 1.4; }
.mysa-layers-msg { margin-top: 14px; font-size: 0.75rem; color: var(--m-muted); line-height: 1.4; }
.mysa-layers-err { color: var(--m-red) !important; }
.mysa-layers-swatch.mysa-swatch-icon { border: 0 !important; background: none !important; height: 20px !important; width: 20px !important; margin-top: 0; }
.mysa-layers-swatch.mysa-swatch-icon svg { width: 20px; height: 20px; display: block; }

/* ---- Key (legend) ---- */
.mysa-legend { background: var(--m-card); color: var(--m-ink); border-radius: var(--m-radius); box-shadow: var(--m-shadow); font-size: 11.5px; line-height: 1.3; max-width: 200px; overflow: hidden; }
.mysa-legend-toggle { display: flex; align-items: center; gap: 6px; width: 100%; min-height: 36px; text-align: left; border: 0; background: none; font: inherit; font-weight: 700; font-size: 13px; padding: 0 12px; cursor: pointer; color: inherit; }
.mysa-legend-list { padding: 2px 12px 10px; max-height: 40vh; overflow-y: auto; border-top: 1px solid var(--m-line); }
.mysa-legend-list[hidden] { display: none; }
.mysa-legend-item { display: flex; align-items: center; gap: 8px; padding: 3px 0; }
.mysa-legend-item .mysa-layers-swatch { width: 15px; height: 11px; margin-top: 0; }
.mysa-legend-item .mysa-swatch-icon, .mysa-legend-item .mysa-swatch-icon svg { width: 16px !important; height: 16px !important; }
.mysa-legend-empty { color: var(--m-muted); padding-top: 6px; }

/* ---- Map markers and labels ---- */
.leaflet-tooltip.mysa-ref-label { display: none; background: rgba(17,17,17,.72); color: #fff; border: 0; box-shadow: none; padding: 1px 6px; font-size: 11px; font-weight: 500; border-radius: 4px; }
.leaflet-tooltip.mysa-ref-label::before { display: none; }
.leaflet-tooltip.mysa-ref-label.t0,
.mysa-z12 .leaflet-tooltip.mysa-ref-label.t1,
.mysa-z14 .leaflet-tooltip.mysa-ref-label.t2 { display: block; }
.mysa-ref-pin { background: none; border: 0; }
.mysa-ref-pin svg { display: block; filter: drop-shadow(0 1px 1.5px rgba(0,0,0,.4)); }
.mysa-count { display: flex; align-items: center; justify-content: center; border-radius: 50%; color: #fff; font: 700 11px/1 var(--font-sans, system-ui, sans-serif);
  border: 2px solid #fff; box-shadow: 0 1px 3px rgba(0,0,0,.45); opacity: .92; box-sizing: border-box; }
/* While placing something, outside areas must not swallow the taps. */
.mysa-drawing .leaflet-mysaRef-pane *, .mysa-drawing .leaflet-mysaRefPts-pane * { pointer-events: none !important; }
.leaflet-control-attribution { border-radius: 8px 0 0 0; font-size: 10px; }

/* ---- Full screen: the wrapper is pinned over the whole window (works on iPhone too). ---- */
html.mysa-noscroll, html.mysa-noscroll body { overflow: hidden !important; }
.mysa-fullscreen {
  position: fixed !important; top: 0; left: 0; right: 0; bottom: 0; z-index: 5000;
  width: 100% !important; max-width: none !important; height: 100vh !important; height: 100dvh !important;
  margin: 0 !important; padding: 0 !important; background: #111; border-radius: 0 !important;
}
.mysa-fullscreen .leaflet-container, .leaflet-container.mysa-fullscreen {
  height: 100% !important; max-height: none !important; min-height: 0 !important; border: 0 !important; border-radius: 0 !important;
}
.mysa-fullscreen .leaflet-top, .mysa-fullscreen .mysa-search { margin-top: env(safe-area-inset-top); }
.mysa-fullscreen .leaflet-bottom { padding-bottom: env(safe-area-inset-bottom); }

/* Old filter chips (no longer used by the pages; kept for any cached page). */
.mysa-chips { display: flex; flex-wrap: wrap; gap: 6px; }
