/* ════════════════════════════════════════════════════════════
   City Address Map – Nairobi | Custom Styles
   Companion to Tailwind CSS (loaded via CDN)
   ════════════════════════════════════════════════════════════ */

/* ── Base ─────────────────────────────────────────────────── */
* {
  box-sizing: border-box;
}

/* ── Suppress Leaflet's default focus ring on clicked polygons ──
   Only the explicit "highlighted" style (applied by highlightFeature)
   should indicate selection. */
.leaflet-container .leaflet-interactive:focus,
.leaflet-container .leaflet-interactive:focus-visible,
.leaflet-container svg path:focus,
.leaflet-container svg path:focus-visible {
  outline: none !important;
}

/* ── Light-mode: legend (Land Use + Roads & Signage) text in black ── */
html.light #mapLegend,
html.light #mapLegend summary,
html.light #mapLegend .text-gray-100,
html.light #mapLegend .text-gray-300,
html.light #mapLegend .text-gray-400 {
  color: #000 !important;
}

/* ── Light-mode: panels with near-white background must not show white text ──
   Targets headings/labels rendered inside aside/details panels that are
   templated with "text-white" (only safe to flip when bg is the panel itself,
   not when text-white sits on a dark coloured button). */
html.light #detailsContent h3.text-white,
html.light #detailsContent h4.text-white,
html.light #detailsContent .text-gray-100,
html.light #bsContent h3.text-white,
html.light #bsContent h4.text-white,
html.light #bsContent .text-gray-100,
html.light #bsStickyTitle.text-white,
html.light #bsStickySubtitle,
html.light #amenitiesPropertyLabel.text-white,
html.light #amenitiesRadiusLabel,
html.light #routingPanel h4.text-white,
html.light #commentsPanel h4.text-white,
html.light #photoUploadPanel h4.text-white {
  color: #0f172a !important;
}

/* ── Make the on-map Report Issue button stand out (amber) ── */
.report-map-btn,
.report-map-btn a,
html.dark .report-map-btn a,
html.light .report-map-btn a {
  background: #f59e0b !important;
  border-color: #b45309 !important;
}
.report-map-btn {
  border: 1px solid #b45309 !important;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.35);
}
.report-map-btn a,
.report-map-btn a svg {
  color: #1f2937 !important;
  stroke: #1f2937 !important;
  fill: none !important;
}
.report-map-btn a:hover,
html.dark .report-map-btn a:hover,
html.light .report-map-btn a:hover {
  background: #fbbf24 !important;
  color: #1f2937 !important;
}

/* ── Responsive safety net for floating panels on small screens ── */
@media (max-width: 480px) {
  #notifPanel,
  #fieldEditPanel,
  #qrShareModal .qr-card {
    width: calc(100vw - 16px) !important;
    max-width: 360px !important;
    right: 8px !important;
  }
  #fieldEditPanel {
    left: 8px !important;
    right: 8px !important;
    max-height: 80vh;
    overflow-y: auto;
  }
  /* Keep tools panel from clipping off-screen */
  #toolsPanel {
    max-height: 70vh;
    overflow-y: auto;
  }
}

/* ── Zone label tooltips ─────────────────────────────────── */
.zone-label-tooltip {
  background: transparent !important;
  border: none !important;
  box-shadow: none !important;
  color: rgba(0, 0, 0, 0.7);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  text-shadow: 0 1px 3px rgba(255, 255, 255, 0.5);
  pointer-events: none;
}
.dark .zone-label-tooltip {
  color: rgba(255, 255, 255, 0.7);
  text-shadow: 0 1px 3px rgba(0, 0, 0, 0.7);
}
.zone-label-tooltip::before {
  display: none !important;
}

body {
  margin: 0;
  padding: 0;
}
::-webkit-scrollbar {
  width: 6px;
}
::-webkit-scrollbar-track {
  background: #1e293b;
}
::-webkit-scrollbar-thumb {
  background: #475569;
  border-radius: 3px;
}
::-webkit-scrollbar-thumb:hover {
  background: #64748b;
}

/* ── Sidebar ──────────────────────────────────────────────── */
.sidebar-tab {
  color: #94a3b8;
  border-bottom: 2px solid transparent;
  transition: all 0.2s;
}
.sidebar-tab:hover {
  color: #e2e8f0;
  background: rgba(30, 41, 59, 0.5);
}
.sidebar-tab.active {
  color: #00843d;
  border-bottom-color: #00843d;
}

/* ── Layer opacity sliders ────────────────────────────────── */
.layer-opacity-slider {
  -webkit-appearance: none;
  appearance: none;
  height: 4px;
  border-radius: 2px;
  background: #334155;
  outline: none;
  cursor: pointer;
}
.layer-opacity-slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: #00843d;
  border: 2px solid #0f172a;
  cursor: pointer;
  transition: background 0.15s;
}
.layer-opacity-slider::-webkit-slider-thumb:hover {
  background: #22c55e;
}
.layer-opacity-slider::-moz-range-thumb {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: #00843d;
  border: 2px solid #0f172a;
  cursor: pointer;
}
html.light .layer-opacity-slider {
  background: #cbd5e1;
}
html.light .layer-opacity-slider::-webkit-slider-thumb {
  border-color: #fff;
}
html.light .layer-opacity-slider::-moz-range-thumb {
  border-color: #fff;
}

/* ── Recent search chips ──────────────────────────────────── */
.recent-chip {
  transition: all 0.15s ease;
}
.recent-chip:hover {
  box-shadow: 0 0 0 1px #00843d;
}
html.light #recentSearches {
  background: #fff;
  border-color: #e2e8f0;
}
html.light .recent-chip {
  background: #f1f5f9;
  color: #334155;
}
html.light .recent-chip:hover {
  background: #00843d;
  color: #fff;
}

/* ── Filter popup (map overlay) ────────────────────────────── */
.filter-popup {
  position: fixed;
  top: 7.5rem;
  left: 3.5rem;
  z-index: 999;
  width: 15rem;
  background: rgba(15, 23, 42, 0.97);
  backdrop-filter: blur(12px);
  border: 1px solid #334155;
  border-radius: 0.75rem;
  padding: 0.75rem;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.4);
}
html.light .filter-popup {
  background: rgba(255, 255, 255, 0.97);
  border-color: #e2e8f0;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.12);
}
html.light .filter-popup select {
  background: #f8fafc;
  border-color: #e2e8f0;
  color: #1e293b;
}
html.light .filter-popup .text-gray-400 {
  color: #64748b;
}
/* Filter map button (inherits map-tool-btn base, kept for specificity) */
.filter-map-btn.filter-active a {
  background: #00843d !important;
  color: #ffd100 !important;
}
.filter-map-btn.filter-active a svg {
  color: #ffd100;
}
/* Position filter popup relative to sidebar on desktop */
@media (min-width: 768px) {
  .filter-popup {
    left: 22rem;
  }
}

/* ── Tool buttons ─────────────────────────────────────────── */
.tool-btn.tool-active {
  background: #00843d !important;
  border-color: #00843d !important;
}
.tool-btn.tool-active svg {
  color: #0f172a !important;
}

/* ── Map tool controls (all top-left buttons: filter, geocoder, choropleth, report, timeline) ── */
.leaflet-top.leaflet-left .leaflet-control {
  clear: both;
  float: left;
  margin-left: 10px !important;
}
/* Match zoom control width/border-radius to other tools for visual consistency */
.leaflet-top.leaflet-left .leaflet-control-zoom a {
  width: 36px !important;
  height: 36px !important;
  line-height: 36px !important;
  border-radius: 6px !important;
  font-size: 18px !important;
}
.leaflet-top.leaflet-left .leaflet-control-zoom {
  border-radius: 6px !important;
  overflow: hidden;
  margin-top: 8px !important;
}
.leaflet-top.leaflet-left .map-tool-btn,
.leaflet-top.leaflet-left .leaflet-bar.map-tool-btn {
  margin-top: 8px !important;
  margin-bottom: 0 !important;
  border-radius: 6px !important;
  overflow: hidden;
}
.leaflet-top.leaflet-left .map-tool-btn + .map-tool-btn {
  margin-top: 8px !important;
}
.map-tool-btn {
  width: 36px;
  height: 36px;
}
.map-tool-btn a {
  display: flex !important;
  align-items: center;
  justify-content: center;
  width: 36px !important;
  height: 36px !important;
  cursor: pointer;
  border-radius: 6px;
  transition:
    background 0.15s,
    color 0.15s;
}
html.dark .map-tool-btn a,
.map-tool-btn a {
  background: #1e293b;
  border-color: #334155;
  color: #e2e8f0;
}
html.dark .map-tool-btn a:hover,
.map-tool-btn a:hover {
  background: #334155;
  color: #00843d;
}
html.light .map-tool-btn a {
  background: #fff;
  border-color: #e2e8f0;
  color: #475569;
}
html.light .map-tool-btn a:hover {
  background: #f1f5f9;
  color: #00843d;
}
.map-tool-btn.filter-active a {
  background: #00843d !important;
  color: #ffd100 !important;
}
.map-tool-btn.filter-active a svg {
  color: #ffd100;
}

/* ── Left panels (geocoder, choropleth, timeline) ────────── */
.map-left-panel {
  transition:
    opacity 0.15s,
    transform 0.15s;
}
@media (min-width: 768px) {
  .map-left-panel {
    left: 22rem !important;
  }
}
html.light .map-left-panel {
  background: rgba(255, 255, 255, 0.97) !important;
  border-color: #e2e8f0 !important;
  color: #1e293b;
}
html.light .map-left-panel input,
html.light .map-left-panel select {
  background: #f8fafc;
  border-color: #e2e8f0;
  color: #1e293b;
}
/* Tailwind utility overrides so dark-theme classes don't bleed into light panels */
html.light .map-left-panel .text-gray-200,
html.light .map-left-panel .text-gray-300,
html.light .map-left-panel .text-gray-400 {
  color: #475569 !important; /* slate-600 — passes AA on white */
}
html.light .map-left-panel .text-gray-500 {
  color: #64748b !important; /* slate-500 — passes AA on white at >= 14px bold/16px */
}
html.light .map-left-panel .text-white {
  color: #0f172a !important;
}
html.light .map-left-panel .bg-navy-700,
html.light .map-left-panel .bg-navy-900,
html.light .map-left-panel .bg-gray-700 {
  background-color: #f1f5f9 !important;
  color: #1e293b !important;
}
html.light .map-left-panel .hover\:bg-navy-700:hover,
html.light .map-left-panel .hover\:bg-navy-600:hover,
html.light .map-left-panel .hover\:bg-gray-600:hover {
  background-color: #e2e8f0 !important;
}
html.light .map-left-panel .border-gray-600 {
  border-color: #cbd5e1 !important;
}
html.light .map-left-panel button.hover\:text-white:hover {
  color: #0f172a !important;
}

/* Same overrides for the filter popup */
html.light .filter-popup .text-gray-500 {
  color: #64748b !important;
}
html.light .filter-popup .text-gray-300,
html.light .filter-popup .text-gray-200 {
  color: #475569 !important;
}
html.light .filter-popup .bg-navy-700,
html.light .filter-popup .bg-navy-900,
html.light .filter-popup .bg-gray-700 {
  background-color: #f1f5f9 !important;
  color: #1e293b !important;
}
html.light .filter-popup .border-gray-600 {
  border-color: #cbd5e1 !important;
}
html.light .filter-popup .text-white {
  color: #0f172a !important;
}

/* Focus ring helper for icon-only buttons */
.icon-btn:focus-visible,
button:focus-visible,
.leaflet-bar a:focus-visible,
.map-tool-btn a:focus-visible {
  outline: 2px solid #00843d;
  outline-offset: 2px;
  border-radius: 4px;
}

/* ── Admin-only controls (hidden by default) ─────────────── */
.admin-only-control {
  display: none !important;
}
.admin-only-control.admin-visible {
  display: block !important;
}

/* Choropleth tooltip */
.choropleth-tooltip {
  background: rgba(15, 23, 42, 0.92) !important;
  border-color: #334155 !important;
  color: #e2e8f0 !important;
  font-size: 11px !important;
  padding: 4px 8px !important;
  border-radius: 6px !important;
}

/* ── Driver.js tour overrides ─────────────────────────────── */
.citymap-tour-popover {
  background: #1e293b !important;
  color: #e2e8f0 !important;
  border: 1px solid #334155 !important;
  border-radius: 12px !important;
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.5) !important;
}
.citymap-tour-popover .driver-popover-title {
  color: #00843d !important;
  font-size: 15px !important;
  font-weight: 600 !important;
}
.citymap-tour-popover .driver-popover-description {
  color: #cbd5e1 !important;
  font-size: 13px !important;
  line-height: 1.5 !important;
}
.citymap-tour-popover .driver-popover-description kbd {
  display: inline-block;
  background: #334155;
  border: 1px solid #475569;
  border-radius: 4px;
  padding: 1px 5px;
  font-size: 11px;
  font-family: ui-monospace, monospace;
  color: #4ade80;
}
.citymap-tour-popover .driver-popover-progress-text {
  color: #64748b !important;
}
.citymap-tour-popover .driver-popover-navigation-btns button {
  border-radius: 8px !important;
  font-size: 12px !important;
  padding: 6px 14px !important;
  text-shadow: none !important;
}
.citymap-tour-popover .driver-popover-next-btn {
  background: #00843d !important;
  color: #fff !important;
}
.citymap-tour-popover .driver-popover-prev-btn {
  background: #334155 !important;
  color: #e2e8f0 !important;
}
html.light .citymap-tour-popover {
  background: #fff !important;
  border-color: #e2e8f0 !important;
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.15) !important;
}
html.light .citymap-tour-popover .driver-popover-description {
  color: #475569 !important;
}
html.light .citymap-tour-popover .driver-popover-description kbd {
  background: #f1f5f9;
  border-color: #e2e8f0;
  color: #059669;
}

/* ── Map ──────────────────────────────────────────────────── */
#map {
  background: #0f172a;
}

/* Geolocate spinner keyframe (button base styling comes from .map-tool-btn) */
@keyframes spin {
  from {
    transform: rotate(0deg);
  }
  to {
    transform: rotate(360deg);
  }
}

/* Geolocate marker (pulsing blue dot) */
.geolocate-marker {
  background: transparent !important;
  border: none !important;
}
.geo-dot {
  width: 14px;
  height: 14px;
  background: #00843d;
  border: 2.5px solid #fff;
  border-radius: 50%;
  position: absolute;
  top: 3px;
  left: 3px;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.3);
}
.geo-pulse {
  width: 20px;
  height: 20px;
  background: rgba(0, 132, 61, 0.25);
  border-radius: 50%;
  position: absolute;
  top: 0;
  left: 0;
  animation: geo-pulse-ring 1.5s ease-out infinite;
}
@keyframes geo-pulse-ring {
  0% {
    transform: scale(1);
    opacity: 0.6;
  }
  100% {
    transform: scale(2.5);
    opacity: 0;
  }
}

/* Leaflet control overrides for dark theme */
.dark .leaflet-control-zoom a {
  background: #1e293b !important;
  color: #e2e8f0 !important;
  border-color: #334155 !important;
}
.dark .leaflet-control-zoom a:hover {
  background: #334155 !important;
}
.dark .leaflet-control-scale-line {
  background: rgba(30, 41, 59, 0.9) !important;
  color: #94a3b8 !important;
  border-color: #475569 !important;
}
.dark .leaflet-control-attribution {
  background: rgba(15, 23, 42, 0.85) !important;
  color: #64748b !important;
}
.dark .leaflet-control-attribution a {
  color: #00843d !important;
}

/* Leaflet MiniMap overrides */
.leaflet-control-minimap {
  border: 2px solid rgba(100, 116, 139, 0.5) !important;
  border-radius: 6px !important;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3) !important;
}
.dark .leaflet-control-minimap {
  border-color: #334155 !important;
}
html.light .leaflet-control-minimap {
  border-color: #cbd5e1 !important;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.12) !important;
}

/* ── Modern Mapbox-style popups (theme-aware) ─────────────── */
.leaflet-popup-content-wrapper {
  background: rgba(15, 23, 42, 0.97) !important;
  color: #e2e8f0 !important;
  border-radius: 10px !important;
  border: 1px solid rgba(51, 65, 85, 0.7) !important;
  box-shadow:
    0 6px 24px -6px rgba(0, 0, 0, 0.55),
    0 2px 8px rgba(0, 0, 0, 0.35) !important;
  padding: 2px 0 !important;
}
.leaflet-popup-content {
  margin: 12px 14px !important;
  font:
    13px/1.5 'Inter',
    system-ui,
    sans-serif !important;
  color: #e2e8f0 !important;
}
.leaflet-popup-content b,
.leaflet-popup-content strong {
  color: #f1f5f9 !important;
}
.leaflet-popup-content a {
  color: #34d399 !important;
}
.leaflet-popup-tip {
  background: rgba(15, 23, 42, 0.97) !important;
  border: 1px solid rgba(51, 65, 85, 0.7) !important;
  box-shadow: none !important;
}
.leaflet-popup-close-button {
  color: #94a3b8 !important;
  font-size: 18px !important;
  padding: 6px 8px 0 0 !important;
  width: 24px !important;
  height: 24px !important;
  transition: color 0.15s;
}
.leaflet-popup-close-button:hover {
  color: #f1f5f9 !important;
  background: transparent !important;
}
html.light .leaflet-popup-content-wrapper {
  background: #ffffff !important;
  color: #1e293b !important;
  border-color: rgba(226, 232, 240, 0.9) !important;
  box-shadow:
    0 6px 24px -6px rgba(0, 0, 0, 0.18),
    0 2px 8px rgba(0, 0, 0, 0.08) !important;
}
html.light .leaflet-popup-content {
  color: #1e293b !important;
}
html.light .leaflet-popup-content b,
html.light .leaflet-popup-content strong {
  color: #0f172a !important;
}
html.light .leaflet-popup-content a {
  color: #047857 !important;
}
html.light .leaflet-popup-tip {
  background: #ffffff !important;
  border-color: rgba(226, 232, 240, 0.9) !important;
}
html.light .leaflet-popup-close-button {
  color: #64748b !important;
}
html.light .leaflet-popup-close-button:hover {
  color: #0f172a !important;
}

/* ── Mapbox-style signage pin ─────────────────────────────── */
.signage-marker {
  background: transparent !important;
  border: 0 !important;
}
.sign-pin {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: #fbbf24;
  border: 2px solid #ffffff;
  box-shadow:
    0 2px 6px rgba(0, 0, 0, 0.35),
    0 0 0 1px rgba(180, 83, 9, 0.7);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.15s ease;
}
.sign-pin:hover {
  transform: scale(1.25);
}
.sign-pin .sign-pin-dot {
  width: 4px;
  height: 4px;
  border-radius: 50%;
  background: #b45309;
}
html.light .sign-pin {
  box-shadow:
    0 2px 6px rgba(0, 0, 0, 0.18),
    0 0 0 1px rgba(180, 83, 9, 0.6);
}

/* ── Tooltips ─────────────────────────────────────────────── */
.property-tooltip {
  background: rgba(15, 23, 42, 0.95) !important;
  color: #e2e8f0 !important;
  border: 1px solid #334155 !important;
  border-radius: 6px !important;
  padding: 4px 8px !important;
  font-size: 11px !important;
  font-weight: 500 !important;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.4) !important;
}
.property-tooltip::before {
  border-bottom-color: #334155 !important;
}

.road-tooltip {
  background: rgba(15, 23, 42, 0.92) !important;
  color: #fbbf24 !important;
  border: 1px solid rgba(245, 158, 11, 0.5) !important;
  border-radius: 999px !important;
  padding: 3px 10px !important;
  font-size: 11px !important;
  font-weight: 600 !important;
  letter-spacing: 0.01em;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.35) !important;
}
html.light .road-tooltip {
  background: rgba(255, 255, 255, 0.96) !important;
  color: #b45309 !important;
  border-color: rgba(245, 158, 11, 0.55) !important;
}

.sign-tooltip {
  background: rgba(15, 23, 42, 0.92) !important;
  color: #fde68a !important;
  border: 1px solid rgba(251, 191, 36, 0.5) !important;
  border-radius: 999px !important;
  padding: 2px 8px !important;
  font-size: 10px !important;
  font-weight: 500 !important;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.35) !important;
}
html.light .sign-tooltip {
  background: rgba(255, 255, 255, 0.96) !important;
  color: #92400e !important;
  border-color: rgba(251, 191, 36, 0.55) !important;
}

.measure-tooltip {
  background: rgba(239, 68, 68, 0.95) !important;
  color: #fff !important;
  border: none !important;
  border-radius: 4px !important;
  padding: 3px 8px !important;
  font-size: 11px !important;
  font-weight: 600 !important;
}

/* Rich property tooltip (hover) – Mapbox-style card */
.property-tooltip-rich {
  background: rgba(15, 23, 42, 0.97) !important;
  color: #e2e8f0 !important;
  border: 1px solid rgba(51, 65, 85, 0.7) !important;
  border-radius: 10px !important;
  padding: 8px 12px !important;
  font-size: 12px !important;
  line-height: 1.5 !important;
  box-shadow:
    0 6px 20px -4px rgba(0, 0, 0, 0.55),
    0 2px 6px rgba(0, 0, 0, 0.3) !important;
  max-width: 240px !important;
}
.property-tooltip-rich::before {
  border-top-color: rgba(51, 65, 85, 0.7) !important;
}
html.light .property-tooltip-rich {
  background: rgba(255, 255, 255, 0.98) !important;
  color: #1e293b !important;
  border-color: rgba(226, 232, 240, 0.95) !important;
  box-shadow:
    0 6px 20px -4px rgba(0, 0, 0, 0.18),
    0 2px 6px rgba(0, 0, 0, 0.08) !important;
}
html.light .property-tooltip-rich::before {
  border-top-color: rgba(226, 232, 240, 0.95) !important;
}

/* Marker cluster custom styles */
.marker-cluster-custom {
  background: transparent !important;
}
.cluster-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  font-weight: 700;
  font-size: 12px;
  color: #0f172a;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
  border: 2px solid rgba(255, 255, 255, 0.7);
}
.cluster-icon span {
  line-height: 1;
}
.cluster-small {
  width: 30px;
  height: 30px;
  background: rgba(251, 191, 36, 0.85);
}
.cluster-medium {
  width: 36px;
  height: 36px;
  background: rgba(245, 158, 11, 0.85);
  font-size: 13px;
}
.cluster-large {
  width: 42px;
  height: 42px;
  background: rgba(234, 88, 12, 0.85);
  font-size: 14px;
  color: #fff;
}

/* ── Address labels ───────────────────────────────────────── */
.address-label {
  transform: translate(-50%, -50%);
}
.address-label span {
  display: inline-block;
  background: transparent;
  color: #e2e8f0;
  font-size: 9px;
  font-weight: 500;
  line-height: 1.15;
  padding: 0;
  border: none;
  border-radius: 0;
  /* Allow the number/street to wrap to a second line */
  white-space: normal;
  overflow: hidden;
  text-overflow: ellipsis;
  text-align: center;
  pointer-events: none;
  /* Subtle halo for legibility over any basemap, theme-aware below */
  text-shadow:
    0 0 2px rgba(0, 0, 0, 0.85),
    0 0 3px rgba(0, 0, 0, 0.6);
}
.address-label span b {
  font-weight: 700;
  font-size: 10px;
}

/* ── Search marks ─────────────────────────────────────────── */
mark {
  background: rgba(0, 132, 61, 0.25);
  color: inherit;
  border-radius: 2px;
  padding: 0 1px;
}

/* ── Loading animation ────────────────────────────────────── */
@keyframes spinner-rotate {
  0% {
    transform: rotate(0deg);
  }
  100% {
    transform: rotate(360deg);
  }
}
.loading-spinner {
  animation: spinner-rotate 1s linear infinite;
}

@keyframes pulse-glow {
  0%,
  100% {
    box-shadow: 0 0 0 0 rgba(0, 132, 61, 0.4);
  }
  50% {
    box-shadow: 0 0 0 10px rgba(0, 132, 61, 0);
  }
}
.search-result-marker div {
  animation: pulse-glow 1.5s ease-in-out infinite;
}

/* ── Light mode overrides ─────────────────────────────────── */
.light body,
html.light body {
  background: #f1f5f9;
  color: #1e293b;
}

html.light nav,
html.light #sidebar,
html.light .tool-btn,
html.light #coordDisplay,
html.light #bufferPopup,
html.light #whatsHerePopup,
html.light #openSidebar {
  background: rgba(255, 255, 255, 0.97) !important;
  border-color: #e2e8f0 !important;
  color: #1e293b !important;
}
html.light #openSidebar svg,
html.light #closeSidebar {
  color: #475569 !important;
}
html.light #openSidebar:hover {
  background: #f1f5f9 !important;
}
html.light #closeSidebar:hover {
  color: #1e293b !important;
  background: rgba(241, 245, 249, 0.7) !important;
}

html.light .sidebar-tab {
  color: #64748b;
}
html.light .sidebar-tab.active {
  color: #006b3f;
  border-bottom-color: #006b3f;
}
html.light .sidebar-tab:hover {
  color: #1e293b;
  background: rgba(241, 245, 249, 0.7);
}

html.light .bg-navy-900\/50,
html.light .bg-navy-900 {
  background: #f8fafc !important;
}

html.light .tool-btn svg {
  color: #64748b !important;
}
html.light .tool-btn:hover svg {
  color: #006b3f !important;
}

/* ── Routing panel ────────────────────────────────────────── */
html.light #routingPanel {
  background: rgba(255, 255, 255, 0.97) !important;
  border-color: #e2e8f0 !important;
  color: #1e293b !important;
}
html.light #routingPanel input {
  background: #f8fafc !important;
  border-color: #e2e8f0 !important;
  color: #1e293b !important;
}
html.light #routingPanel label,
html.light #routingPanel .text-gray-400 {
  color: #64748b !important;
}
html.light #routingPanel button.text-gray-400 {
  color: #64748b !important;
}
html.light #routingPanel button.text-gray-400:hover {
  color: #1e293b !important;
}
html.light #routingPanel #routePickOrigin,
html.light #routingPanel #routePickDest {
  background: #f1f5f9 !important;
  border-color: #e2e8f0 !important;
}
html.light #routingPanel #routePickOrigin svg,
html.light #routingPanel #routePickDest svg {
  color: #64748b !important;
}
html.light #routingPanel #routeClearBtn {
  background: #e2e8f0 !important;
  color: #1e293b !important;
}
html.light #routingPanel #routeClearBtn:hover {
  background: #cbd5e1 !important;
}
html.light #routingPanel #routeCloseBtn {
  color: #94a3b8 !important;
}
html.light #routingPanel #routeCloseBtn:hover {
  color: #1e293b !important;
}
html.light #routingPanel .route-directions {
  border-color: #e2e8f0 !important;
}
html.light #routeOriginDropdown,
html.light #routeDestDropdown {
  background: #fff !important;
  border-color: #e2e8f0 !important;
  color: #1e293b !important;
}
.route-directions::-webkit-scrollbar {
  width: 4px;
}
.route-directions::-webkit-scrollbar-track {
  background: transparent;
}
.route-directions::-webkit-scrollbar-thumb {
  background: #475569;
  border-radius: 2px;
}
.route-marker-icon {
  background: transparent !important;
  border: none !important;
}

html.light #searchDropdown {
  background: #fff !important;
  border-color: #e2e8f0 !important;
}

html.light .property-tooltip {
  background: rgba(255, 255, 255, 0.97) !important;
  color: #1e293b !important;
  border-color: #e2e8f0 !important;
}

html.light .address-label span {
  background: transparent;
  color: #0f172a;
  border: none;
  text-shadow:
    0 0 2px rgba(255, 255, 255, 0.95),
    0 0 3px rgba(255, 255, 255, 0.7);
}

html.light input,
html.light select {
  background: #f8fafc !important;
  border-color: #e2e8f0 !important;
  color: #1e293b !important;
}

/* ── Leaflet Draw overrides for dark theme ────────────────── */
.dark .leaflet-draw-toolbar a {
  background-color: #1e293b !important;
  border-color: #334155 !important;
}

/* ── Responsive ───────────────────────────────────────────── */

/* Touch-friendly tap targets on mobile */
@media (pointer: coarse) {
  .tool-btn {
    min-width: 40px;
    min-height: 40px;
  }
  .sidebar-tab {
    min-height: 44px;
  }
}

/* Tablets & small screens */
@media (max-width: 768px) {
  #sidebar {
    width: 100%;
    max-width: 100%;
  }
  #toolsPanel {
    top: 60px;
    right: 6px;
  }
  .tool-btn {
    padding: 8px;
  }
  .tool-btn svg {
    width: 18px;
    height: 18px;
  }
  #coordDisplay {
    font-size: 10px;
    padding: 2px 6px;
  }
  /* Popups: full-width on mobile with margin */
  #bufferPopup,
  #routingPanel {
    max-width: calc(100vw - 3.5rem);
  }
  /* What's Here popup: center on mobile */
  #whatsHerePopup {
    max-width: calc(100vw - 1rem);
  }
  /* Stack: sidebar button → zoom → geolocate with clean spacing
     The other top-left controls use margin-top: 8px (see line ~279), so we
     position the leaflet container such that the first 8px-margin child sits
     8px below the hamburger button. Hamburger sits at top:4rem (64px) with a
     touch-friendly height of 40px → bottom 104px → desired zoom top 112px →
     container top (relative to #map at top:56px) = 112 − 56 − 8 = 48px. */
  #openSidebar {
    top: 4rem;
    left: 6px;
  }
  .leaflet-top.leaflet-left {
    top: 46px !important;
    left: 0 !important;
  }
  .leaflet-control-zoom {
    margin-top: 0 !important;
    margin-left: 6px !important;
  }
  .geolocate-btn {
    margin-top: 8px !important;
    margin-left: 6px !important;
  }
  .leaflet-top.leaflet-left .leaflet-control {
    margin-left: 6px !important;
  }
  .map-tool-btn,
  .leaflet-top.leaflet-left .map-tool-btn {
    margin-top: 8px !important;
    margin-left: 6px !important;
  }
  .basemap-toggle-btn {
    margin-top: 8px !important;
    margin-right: 6px !important;
  }
  /* Hide back-to-previous-view on mobile */
  #backViewBtn {
    display: none !important;
  }
  /* Login modal: tighter on mobile */
  #loginModal > div {
    margin-left: 0.75rem;
    margin-right: 0.75rem;
  }
}

/* ── Accessibility: visually-hidden but readable by screen readers ── */
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

/* ── Live-update status dot (admin navbar indicator) ─────────── */
.live-status-dot {
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
  transition: background-color 0.4s ease;
}
.live-status-dot.connected    { background: #22c55e; box-shadow: 0 0 4px #22c55e88; }
.live-status-dot.reconnecting { background: #f59e0b; animation: pulse-dot 1.2s ease-in-out infinite; }
.live-status-dot.offline      { background: #6b7280; }

@keyframes pulse-dot {
  0%, 100% { opacity: 1; }
  50%       { opacity: 0.35; }
}

/* ── Search "Show more" button ───────────────────────────────── */
.show-more-btn {
  display: block;
  border-top: 1px solid rgba(255,255,255,0.06);
  font-size: 0.7rem;
  letter-spacing: 0.03em;
}
.show-more-btn:hover {
  background: rgba(0, 132, 61, 0.08);
}

/* Small phones */
@media (max-width: 480px) {
  nav {
    padding-left: 6px;
    padding-right: 6px;
    gap: 4px;
  }
  #globalSearch {
    font-size: 13px;
    padding-top: 6px;
    padding-bottom: 6px;
  }
  #searchDropdown {
    max-height: 60vh;
  }
  #toolsPanel {
    top: 58px;
    right: 4px;
    gap: 2px;
  }
  .tool-btn {
    padding: 6px;
    border-radius: 6px;
  }
  .tool-btn svg {
    width: 16px;
    height: 16px;
  }
  /* Popups stack vertically fullwidth, centred vertically in the map view
     so the mobile FAB (#fabContainer at bottom-20) doesn't overshadow them. */
  #bufferPopup,
  #routingPanel {
    left: 0.5rem !important;
    right: 0.5rem !important;
    max-width: none;
    top: 50% !important;
    bottom: auto !important;
    transform: translateY(-50%) !important;
    max-height: calc(100vh - 8rem);
    overflow-y: auto;
  }
  #whatsHerePopup {
    left: 0.5rem !important;
    right: 0.5rem !important;
    max-width: none;
    top: 50% !important;
    bottom: auto !important;
    transform: translateY(-50%) !important;
    max-height: calc(100vh - 8rem);
    overflow-y: auto;
  }
  /* Route info directions: shorter on phone */
  .route-directions {
    max-height: 30vh !important;
  }
  /* Sidebar tabs: smaller text */
  .sidebar-tab {
    font-size: 11px;
    padding-top: 0.5rem;
    padding-bottom: 0.5rem;
  }
  /* Coord display: minimal */
  #coordDisplay {
    font-size: 9px;
    padding: 1px 4px;
    bottom: 2px;
  }
}

/* Very small screens (iPhone SE, etc.) */
@media (max-width: 360px) {
  nav {
    height: 3rem;
  }
  /* Adjust top offset for shorter nav */
  #sidebar,
  #map,
  #toolsPanel,
  #openSidebar {
    top: 3rem;
  }
  #openSidebar {
    left: 4px;
  }
  .leaflet-top.leaflet-left {
    top: 40px !important;
  }
  .leaflet-control-zoom {
    margin-left: 4px !important;
  }
  .map-tool-btn {
    margin-top: 3px !important;
    margin-left: 4px !important;
  }
  .map-tool-btn a {
    width: 30px;
    height: 30px;
  }
  .map-tool-btn a svg {
    width: 15px;
    height: 15px;
  }
  .tool-btn {
    padding: 5px;
  }
  .tool-btn svg {
    width: 14px;
    height: 14px;
  }
}

/* Landscape phones: limit sidebar height */
@media (max-height: 500px) and (max-width: 768px) {
  #sidebar {
    max-height: calc(100vh - 3.5rem);
    overflow-y: auto;
  }
  .sidebar-panel {
    padding-bottom: 1rem;
  }
  #routingPanel,
  #bufferPopup {
    max-height: calc(100vh - 5rem);
    overflow-y: auto;
  }
}

/* ── Print styles ─────────────────────────────────────────── */
@media print {
  nav,
  #sidebar,
  #toolsPanel,
  #coordDisplay,
  #openSidebar,
  #bufferPopup,
  #whatsHerePopup,
  #loginModal,
  #loadingOverlay,
  #fabContainer,
  #fabScrim,
  #bottomSheet,
  #filterPopup {
    display: none !important;
  }
  #map {
    position: static !important;
    top: 0 !important;
    left: 0 !important;
    right: 0 !important;
    bottom: 0 !important;
    width: 100% !important;
    height: 100vh !important;
  }
}

/* ── Mobile Bottom Sheet ──────────────────────────────────── */
#bottomSheet.bs-visible {
  transform: translateY(0);
  pointer-events: auto;
}
#bottomSheet.bs-peek {
  transform: translateY(calc(100% - 9rem));
  pointer-events: auto;
}
#bottomSheet.bs-peek #bsContent {
  display: none;
}
#bottomSheet.bs-peek #bsPeekActions {
  display: flex;
}
#bottomSheet.bs-visible #bsPeekActions {
  display: none;
}
html.light #bottomSheet > div {
  background: rgba(255, 255, 255, 0.98) !important;
  border-color: #e2e8f0 !important;
  color: #1e293b !important;
}
html.light #bottomSheet .bg-navy-900\/50 {
  background: #f8fafc !important;
}
html.light #bottomSheet .border-gray-600 {
  border-color: #cbd5e1 !important;
}
html.light #bottomSheet .text-gray-500 {
  color: #64748b !important;
}

/* Favorite star active */
#bsFavoriteBtn.favorited svg {
  fill: #ffd100;
  stroke: #ffd100;
  color: #ffd100;
}

/* ── Full-screen search modal ─────────────────────────────── */
#searchModal {
  transition: transform 0.25s cubic-bezier(0.32, 0.72, 0, 1);
  flex-direction: column;
}
#searchModal.modal-visible {
  display: flex !important;
  animation: slideUp 0.25s cubic-bezier(0.32, 0.72, 0, 1) forwards;
}
#searchModal > .search-modal-body {
  overflow-y: auto;
  display: flex;
  flex-direction: column;
}
#modalSearchResults {
  max-height: 25rem;
  overflow-y: auto;
}
#searchModal > .search-modal-header {
  flex-shrink: 0;
  border-top: 1px solid rgba(51, 65, 85, 0.6);
  padding-bottom: calc(env(safe-area-inset-bottom, 0px) + 20px);
}
@keyframes slideUp {
  from {
    transform: translateY(100%);
  }
  to {
    transform: translateY(0);
  }
}
html.light #searchModal {
  background: #fff !important;
  color: #1e293b !important;
}
html.light #searchModal input {
  background: #f8fafc !important;
  border-color: #e2e8f0 !important;
  color: #1e293b !important;
}
html.light #searchModal .text-gray-400 {
  color: #64748b !important;
}

/* ── Top-left tool buttons: only state-specific overrides
       (base styling now comes from .map-tool-btn) ───────────── */
.geolocate-btn a.geolocating svg {
  animation: spin 1s linear infinite;
  color: #00843d;
}
.basemap-toggle-btn a:hover svg,
.view3d-btn a:hover svg {
  color: #00843d;
}

/* Favorite chips */
.fav-chip {
  display: flex;
  align-items: center;
  gap: 4px;
  transition: all 0.15s ease;
}
.fav-chip svg {
  flex-shrink: 0;
}

/* Light mode: details panel image placeholder + nearby list */
html.light .bg-navy-900\/60 {
  background: #f1f5f9 !important;
}
html.light .bg-navy-700 {
  background: #e2e8f0 !important;
  color: #1e293b !important;
}

/* ── Mobile FAB ── */
.fab-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px 8px 10px;
  border-radius: 999px;
  background: rgba(30, 41, 59, 0.97);
  border: 1px solid #475569;
  color: #e2e8f0;
  font-size: 12px;
  font-weight: 500;
  white-space: nowrap;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
  transition: all 0.15s ease;
}
.fab-item:active {
  transform: scale(0.95);
  background: #00843d;
  border-color: #00843d;
  color: #0f172a;
}
.fab-item-danger {
  border-color: rgba(185, 28, 28, 0.5) !important;
  color: #fca5a5 !important;
}
.fab-item-danger:active {
  background: #991b1b !important;
  border-color: #991b1b !important;
  color: #fff !important;
}
.fab-label {
  pointer-events: none;
}
html.light .fab-item {
  background: rgba(255, 255, 255, 0.97);
  border-color: #e2e8f0;
  color: #1e293b;
}
html.light .fab-item:active {
  background: #00843d;
  color: #fff;
}
html.light .fab-item-danger {
  color: #dc2626 !important;
}
#fabMenu.fab-open {
  opacity: 1;
  pointer-events: auto;
}

/* On mobile, hide the desktop tools panel and minimap */
@media (max-width: 767px) {
  #toolsPanel {
    display: none !important;
  }
  .leaflet-control-minimap {
    display: none !important;
  }
}

/* ── Compass control (mobile only, below basemap toggle) ── */
.compass-control {
  display: none !important;
}
@media (max-width: 767px) {
  .compass-control {
    display: block !important;
    margin-top: 6px !important;
    margin-right: 6px !important;
  }
}
.compass-control a {
  display: flex !important;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  cursor: pointer;
  background: #fff;
  border-radius: 4px;
}
html.dark .compass-control a {
  background: #1e293b;
  border-color: #334155;
}
html.light .compass-control a {
  background: #fff;
  border-color: #e2e8f0;
}

/* ── Comparison panel ────────────────────────────────────── */
html.light #comparePanel {
  background: rgba(255, 255, 255, 0.97) !important;
  border-color: #e2e8f0 !important;
  color: #1e293b !important;
}
html.light #comparePanel th,
html.light #comparePanel td {
  color: #1e293b !important;
}
html.light #comparePanel th {
  background: #fff !important;
}
html.light #comparePanel .bg-navy-900\/30 td {
  background: #f8fafc !important;
}

/* ── Report panel ────────────────────────────────────────── */
html.light #reportPanel {
  background: rgba(255, 255, 255, 0.97) !important;
  border-color: #e2e8f0 !important;
  color: #1e293b !important;
}
html.light #reportPanel input,
html.light #reportPanel textarea,
html.light #reportPanel select {
  background: #f8fafc !important;
  border-color: #e2e8f0 !important;
  color: #1e293b !important;
}
html.light #reportPanel label,
html.light #reportPanel .text-gray-400 {
  color: #64748b !important;
}

/* ── Amenities panel ─────────────────────────────────────── */
html.light #amenitiesPanel {
  background: rgba(255, 255, 255, 0.97) !important;
  border-color: #e2e8f0 !important;
  color: #1e293b !important;
}
html.light #amenitiesPanel .bg-navy-900\/50 {
  background: #f1f5f9 !important;
}
html.light #amenitiesPanel .text-gray-400,
html.light #amenitiesPanel label {
  color: #64748b !important;
}
html.light .amenity-filter-btn {
  background: #e2e8f0 !important;
  color: #475569 !important;
}
html.light .amenity-filter-btn.active {
  background: rgba(0, 132, 61, 0.15) !important;
  color: #00843d !important;
}

/* ════════════════════════════════════════════════════════════
   RESPONSIVE: panels, popups, modals, dropdowns
   ════════════════════════════════════════════════════════════ */

/* Tablets and below: keep floating panels inside the viewport */
@media (max-width: 768px) {
  #reportPanel,
  #comparePanel,
  #amenitiesPanel,
  #routingPanel,
  #timelinePanel,
  #choroplethPanel,
  #geocoderPanel,
  #bufferPopup,
  #notifPanel,
  #fieldEditPanel,
  #photoUploadPanel,
  #commentsPanel {
    left: 8px !important;
    right: 8px !important;
    max-width: none !important;
    width: auto !important;
    /* Cap height so the panel never reaches the mobile FAB (bottom-20 ≈ 5rem
       + ~3.5rem button + safe gap). Nav is 3.5rem, leaving usable area. */
    max-height: calc(100vh - 12rem);
    overflow-y: auto;
  }
  /* Modal dialogs (login, QR share, photo modal) */
  #loginModal > div,
  #qrShareModal .qr-card,
  .modal-card {
    width: calc(100vw - 24px) !important;
    max-width: 420px !important;
    margin-left: auto !important;
    margin-right: auto !important;
    max-height: 90vh;
    overflow-y: auto;
  }
  /* Search / generic dropdowns: never overflow viewport */
  #searchDropdown,
  #routeOriginDropdown,
  #routeDestDropdown,
  .dropdown-menu {
    max-width: calc(100vw - 16px) !important;
  }
  /* Toast / undo notification: bottom-center, full-width minus margin */
  #undoToast,
  .toast-notification {
    left: 8px !important;
    right: 8px !important;
    max-width: none !important;
    bottom: 12px !important;
  }
  /* Tables inside panels scroll horizontally */
  #comparePanel table,
  #amenitiesPanel table {
    display: block;
    overflow-x: auto;
    white-space: nowrap;
  }
}

/* Phones */
@media (max-width: 480px) {
  #reportPanel,
  #comparePanel,
  #amenitiesPanel,
  #routingPanel,
  #timelinePanel,
  #choroplethPanel,
  #geocoderPanel,
  #notifPanel,
  #fieldEditPanel,
  #photoUploadPanel,
  #commentsPanel {
    left: 4px !important;
    right: 4px !important;
    top: auto !important;
    bottom: 12px !important;
    max-height: 65vh;
  }
  /* Filter popup is anchored to the filter button — keep on screen */
  #filterPopup {
    left: 4px !important;
    right: 4px !important;
    width: auto !important;
    max-width: none !important;
  }
  /* Headings inside panels: smaller */
  #reportPanel h2,
  #comparePanel h2,
  #amenitiesPanel h2,
  #routingPanel h2,
  #notifPanel h3,
  #fieldEditPanel h3 {
    font-size: 0.95rem !important;
  }
  /* Buttons inside panels: full width on small screens */
  #reportPanel .panel-actions button,
  #fieldEditPanel .panel-actions button {
    width: 100% !important;
    margin: 4px 0 !important;
  }
  /* Legend inside layers tab: tighter rows */
  #mapLegend .grid {
    grid-template-columns: 1fr 1fr !important;
    gap: 4px !important;
  }
  /* Leaflet popup max-width */
  .leaflet-popup-content-wrapper {
    max-width: calc(100vw - 24px) !important;
  }
  .leaflet-popup-content {
    width: auto !important;
    max-width: calc(100vw - 48px) !important;
  }
}

/* Wide desktops: cap floating panels so they don't sprawl */
@media (min-width: 1280px) {
  #notifPanel,
  #fieldEditPanel,
  #qrShareModal .qr-card {
    max-width: 380px;
  }
}

/* -- Draggable panels: mobile positioning + drag handle ------- */
/* Sizing: cap height so panel never exceeds viewport, but DO NOT
   force min-height — panel hugs its content. */
#geocoderPanel,
#choroplethPanel,
#reportPanel,
#timelinePanel {
  max-height: calc(100vh - 5rem);
  overflow-y: auto;
  overscroll-behavior: contain;
}

/* Desktop: keep panels anchored just to the right of the in-map
   toolbar (the leaflet-top-left controls sit ~10–46px in). The map
   container starts after the 320px sidebar; place panels at 380px so
   they sit immediately beside the toolbar buttons. */
@media (min-width: 768px) {
  #geocoderPanel,
  #choroplethPanel,
  #timelinePanel {
    left: 380px !important;
    top: 5rem !important;
    right: auto !important;
  }
  /* Allow user-dragged coords to override */
  #geocoderPanel[data-dragged='1'],
  #choroplethPanel[data-dragged='1'],
  #timelinePanel[data-dragged='1'],
  #reportPanel[data-dragged='1'] {
    top: auto;
  }
}

/* Drag handle on the panel header (the h4's parent flex row) */
#geocoderPanel > .flex.items-center.justify-between:first-child,
#choroplethPanel > .flex.items-center.justify-between:first-child,
#reportPanel > .flex.items-center.justify-between:first-child,
#timelinePanel > .flex.items-center.justify-between:first-child {
  cursor: grab;
  user-select: none;
  touch-action: none;
}
.panel-dragging {
  cursor: grabbing !important;
  opacity: 0.92;
  transition: none !important;
}
.panel-dragging > .flex.items-center.justify-between:first-child {
  cursor: grabbing !important;
}

/* Small screens: anchor panels near the top with safe gutters,
   sized to content (no forced max-height that creates empty scroll). */
@media (max-width: 767px) {
  #geocoderPanel,
  #choroplethPanel,
  #timelinePanel,
  #reportPanel {
    left: 8px !important;
    right: 8px !important;
    top: 4.25rem !important;
    bottom: auto !important;
    width: auto !important;
    max-width: calc(100vw - 16px) !important;
    max-height: min(80vh, calc(100vh - 5.5rem));
    height: auto !important;
  }
  /* User-dragged: free vertical position */
  #geocoderPanel[data-dragged='1'],
  #choroplethPanel[data-dragged='1'],
  #reportPanel[data-dragged='1'],
  #timelinePanel[data-dragged='1'] {
    right: auto !important;
    bottom: auto !important;
    max-width: calc(100vw - 16px) !important;
  }
}

/* -- Right-click map context menu --------------------------- */
.map-ctx-menu {
  position: fixed;
  z-index: 9999;
  min-width: 240px;
  max-width: 320px;
  background: #0f172a;
  color: #e5e7eb;
  border: 1px solid rgba(148,163,184,0.18);
  border-radius: 12px;
  box-shadow: 0 24px 48px -12px rgba(0,0,0,0.55), 0 0 0 1px rgba(0,0,0,0.4);
  padding: 12px;
  font-family: 'Segoe UI', system-ui, sans-serif;
  font-size: 12px;
  backdrop-filter: saturate(140%) blur(8px);
  animation: ctxIn .12s ease-out;
}
.map-ctx-menu.hidden { display: none; }
@keyframes ctxIn {
  from { opacity: 0; transform: translateY(-4px) scale(.98); }
  to   { opacity: 1; transform: translateY(0)    scale(1);   }
}
.map-ctx-menu .ctx-head {
  border-bottom: 1px solid rgba(148,163,184,0.15);
  padding-bottom: 8px;
  margin-bottom: 8px;
}
.map-ctx-menu .ctx-badge {
  display: inline-block;
  font-size: 9px;
  letter-spacing: 0.12em;
  font-weight: 700;
  color: #0f172a;
  background: #00C853;
  padding: 2px 8px;
  border-radius: 999px;
  margin-bottom: 6px;
}
.map-ctx-menu .ctx-badge--muted { background: #94a3b8; color: #0f172a; }
.map-ctx-menu .ctx-title {
  font-weight: 600; font-size: 13px; color: #f1f5f9;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.map-ctx-menu .ctx-coords {
  font-size: 11px; color: #94a3b8; margin-top: 2px;
  user-select: all;
}
.map-ctx-menu .ctx-meta {
  display: grid; grid-template-columns: 1fr; gap: 4px 8px;
  margin: 0 0 10px;
  font-size: 11px;
}
.map-ctx-menu .ctx-meta > div { display: flex; justify-content: space-between; gap: 8px; }
.map-ctx-menu .ctx-meta dt { color: #94a3b8; }
.map-ctx-menu .ctx-meta dd { color: #e2e8f0; font-weight: 500; text-align: right; }
.map-ctx-menu .ctx-actions {
  display: grid; grid-template-columns: 1fr 1fr; gap: 6px;
}
.map-ctx-menu .ctx-btn {
  display: inline-flex; align-items: center; gap: 6px; justify-content: flex-start;
  padding: 7px 9px; border-radius: 8px;
  background: rgba(148,163,184,0.08);
  border: 1px solid rgba(148,163,184,0.15);
  color: #e5e7eb;
  font-size: 11.5px; font-weight: 500;
  cursor: pointer;
  transition: background .12s, border-color .12s, color .12s, transform .08s;
}
.map-ctx-menu .ctx-btn:hover {
  background: rgba(0,200,83,0.12);
  border-color: rgba(0,200,83,0.4);
  color: #fff;
}
.map-ctx-menu .ctx-btn:active { transform: translateY(1px); }
.map-ctx-menu .ctx-btn--primary {
  background: linear-gradient(135deg,#00843D,#00A651);
  border-color: rgba(0,200,83,0.5);
  color: #fff;
  grid-column: span 2;
  justify-content: center;
  font-weight: 600;
}
.map-ctx-menu .ctx-btn--primary:hover { filter: brightness(1.08); }
.map-ctx-menu .ctx-btn svg { flex-shrink: 0; }

/* ==========================================================================
   Role-based UI gating (anon / public / staff / senior_staff / admin)
   Driven by classes set on <body> from assets/js/auth.js -> updateUI().
   ========================================================================== */

/* --- ANON: blur every map overlay so features are not legible until login --- */
body.role-anon .leaflet-overlay-pane,
body.role-anon .leaflet-marker-pane,
body.role-anon .leaflet-shadow-pane,
body.role-anon .leaflet-tooltip-pane,
body.role-anon .leaflet-popup-pane {
    filter: blur(8px) saturate(0.7);
    -webkit-filter: blur(8px) saturate(0.7);
    pointer-events: none;
    user-select: none;
}
body.role-anon .leaflet-container {
    cursor: not-allowed;
}
/* Hide every map tool & side panel for anon  keep only the top nav + login modal */
body.role-anon #sidebar,
body.role-anon .tool-btn,
body.role-anon #searchContainer,
body.role-anon .map-ctx-menu {
    display: none !important;
}
/* The login modal stays visible & non-dismissable for anonymous users */
body.role-anon #loginModal {
    display: flex !important;
}
body.role-anon #loginModal .modal-close,
body.role-anon #loginModalBackdrop {
    pointer-events: none;
}

/* --- PUBLIC: search-only access. Hide right toolbar, side panels, etc. ---- */
body.role-public .tool-btn,
body.role-public #sidebar,
body.role-public #toggleSidebar,
body.role-public #adminLink,
body.role-public #dashboardLink,
body.role-public .admin-only-control,
body.role-public .restricted-only,
body.role-public [data-restricted] {
    display: none !important;
}

/* --- STAFF: full attribute view, but admin/dashboard links stay hidden ---- */
body.role-staff #adminLink,
body.role-staff #dashboardLink {
    display: none !important;
}
