/* Full-viewport map page — UI aligned with map.bcsp-cnr.eu (dark controls, coords panel) */
html.map-page-root {
  height: 100%;
  height: 100dvh;
  max-height: 100dvh;
  margin: 0;
  padding: 0;
  overflow: hidden;
  background: #171717;
  overscroll-behavior: none;
}

html.map-page-root body.map-page-body {
  margin: 0;
  padding: 0;
  overflow: hidden;
  height: 100%;
  height: 100dvh;
  max-height: 100dvh;
  min-height: 0;
  display: flex;
  flex-direction: column;
  background: #171717;
  overscroll-behavior: none;
}

.map-page-app {
  flex: 1 1 auto;
  min-height: 0;
  display: flex;
  flex-direction: column;
  background: #171717;
}

.map-page-hero {
  flex: 0 0 auto;
}

.map-page-header .nav {
  margin-bottom: 0;
}

/* Hamburger uses .nav-toggle in app.css; on dark hero bars read better in light gray. */
.map-page-header .nav-toggle span {
  background-color: rgba(245, 245, 245, 0.92);
}

.map-page-header .nav-toggle:hover {
  background-color: rgba(255, 255, 255, 0.08);
}

.map-page-header .nav-toggle.is-active span {
  background-color: #f5f5f5;
}

.map-page-error {
  flex: 0 0 auto;
  padding: 0.5rem 1rem;
  background: #ff3860;
  color: #fff;
  font-size: 0.9rem;
  text-align: center;
}

.map-page-main {
  flex: 1 1 auto;
  min-height: 0;
  position: relative;
  background: #171717;
}

.map-page-canvas,
#lscnr-map,
#lscnr-map.leaflet-container {
  position: absolute;
  left: 0;
  top: 0;
  right: 0;
  bottom: 0;
  width: 100%;
  height: 100%;
  min-height: 0;
  z-index: 1;
  font-family: var(--font-geist-sans, "Inter", system-ui, sans-serif);
}

/* —— Coordinates (bottom-left, bcsp-style) —— */
.map-page-coords {
  position: absolute;
  left: max(0.5rem, env(safe-area-inset-left, 0px));
  bottom: max(0.5rem, env(safe-area-inset-bottom, 0px));
  z-index: 401;
  pointer-events: none;
  margin: 0;
  padding: 0.375rem 0.625rem;
  border-radius: 0.375rem;
  border: 1px solid rgba(255, 255, 255, 0.12);
  background: rgba(23, 23, 23, 0.9);
  box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.35), 0 2px 4px -2px rgba(0, 0, 0, 0.25);
  font-family: "Geist Mono", ui-monospace, "Cascadia Mono", "Segoe UI Mono", monospace;
  font-size: 0.75rem;
  font-weight: 400;
  line-height: 1.25rem;
  letter-spacing: -0.01em;
  color: #f5f5f5;
  white-space: nowrap;
}

.map-page-coords:empty {
  display: none;
}

/* —— Top-right controls (zoom + layers, bcsp-style) —— */
#lscnr-map .leaflet-top.leaflet-right {
  top: 0.5rem;
  right: 0.5rem;
  z-index: 401;
}

#lscnr-map .leaflet-top.leaflet-left,
#lscnr-map .leaflet-bottom.leaflet-left {
  display: none;
}

#lscnr-map .leaflet-control {
  margin: 0;
  border: none;
  box-shadow: none;
  background: transparent;
}

#lscnr-map .leaflet-bar {
  border: none;
  box-shadow: none;
}

#lscnr-map .leaflet-control-zoom {
  margin: 0;
}

#lscnr-map .leaflet-control-zoom a {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 3rem;
  height: 2rem;
  padding: 0.25rem;
  border: 1px solid rgba(255, 255, 255, 0.12);
  background: rgba(23, 23, 23, 0.9);
  color: #f5f5f5;
  font-size: 1.125rem;
  font-weight: 500;
  line-height: 1;
  text-indent: 0;
  text-decoration: none;
  box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.35), 0 2px 4px -2px rgba(0, 0, 0, 0.25);
  transition: color 0.15s ease, background-color 0.15s ease;
}

#lscnr-map .leaflet-control-zoom a:hover,
#lscnr-map .leaflet-control-zoom a:focus {
  background: rgba(38, 38, 38, 0.95);
  color: #fafafa;
}

#lscnr-map .leaflet-control-zoom-in {
  border-radius: 0.375rem 0.375rem 0 0;
  border-bottom: none;
}

#lscnr-map .leaflet-control-zoom-out {
  border-radius: 0 0 0.375rem 0.375rem;
  border-top: 1px solid rgba(255, 255, 255, 0.08);
}

#lscnr-map .leaflet-control-zoom-disabled a {
  opacity: 0.45;
  cursor: default;
}

/* Layer picker (bcsp-style) — icon when collapsed, panel when expanded */
#lscnr-map .leaflet-control-layers {
  margin-top: 0.5rem;
  border-radius: 0.375rem;
  border: 1px solid rgba(255, 255, 255, 0.12);
  background: rgba(23, 23, 23, 0.9);
  box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.35), 0 2px 4px -2px rgba(0, 0, 0, 0.25);
}

#lscnr-map .leaflet-control-layers-toggle {
  display: block;
  width: 3rem;
  height: 2rem;
  padding: 0.25rem;
  border-radius: 0.375rem;
  background: rgba(23, 23, 23, 0.9)
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%23f5f5f5' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M12 2L2 7l10 5 10-5-10-5z'/%3E%3Cpath d='M2 17l10 5 10-5'/%3E%3Cpath d='M2 12l10 5 10-5'/%3E%3C/svg%3E")
    no-repeat center / 1rem 1rem;
}

#lscnr-map .leaflet-control-layers-expanded .leaflet-control-layers-toggle {
  flex-shrink: 0;
  border-radius: 0.375rem 0.375rem 0 0;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  margin-bottom: 0;
}

#lscnr-map .leaflet-control-layers-toggle:hover,
#lscnr-map .leaflet-control-layers-toggle:focus {
  background-color: rgba(38, 38, 38, 0.95);
}

#lscnr-map .leaflet-control-layers-collapsed .leaflet-control-layers-list {
  display: none;
}

#lscnr-map .leaflet-control-layers-expanded {
  /* Flex: scroll list fills under the toggle; bottom padding lives on the list so the scrollbar runs to the panel edge. */
  display: flex;
  flex-direction: column;
  align-items: stretch;
  padding: 0.5rem 0 0 0.625rem;
  border-radius: 0.375rem;
  color: #f5f5f5;
  font-size: 0.8125rem;
  /* Dark rail / muted thumb — same family as panel bg (see .leaflet-control-layers). */
  --lscnr-layers-scrollbar-rail: rgba(12, 12, 12, 0.95);
  --lscnr-layers-scrollbar-rail-edge: rgba(255, 255, 255, 0.05);
  --lscnr-layers-scrollbar-thumb: rgba(255, 255, 255, 0.2);
  --lscnr-layers-scrollbar-thumb-hover: rgba(255, 255, 255, 0.32);
}

#lscnr-map .leaflet-control-layers-expanded .leaflet-control-layers-list {
  display: block;
  flex: 1 1 auto;
  min-height: 0;
  width: 15rem;
  max-width: 100%;
  max-height: min(60vh, calc(100dvh - 10rem));
  box-sizing: border-box;
  /* Reserve space so labels never sit under the scrollbar (incl. overlay scrollbars). */
  padding: 0 0.625rem 0.5rem 0;
  overflow-y: auto;
  overscroll-behavior: contain;
  position: relative;
  scrollbar-width: thin;
  scrollbar-color: var(--lscnr-layers-scrollbar-thumb) var(--lscnr-layers-scrollbar-rail);
  border-bottom-right-radius: 0.375rem;
}

#lscnr-map
  .leaflet-control-layers-expanded
  .leaflet-control-layers-list::-webkit-scrollbar {
  width: 7px;
}

#lscnr-map
  .leaflet-control-layers-expanded
  .leaflet-control-layers-list::-webkit-scrollbar-button {
  display: none;
  width: 0;
  height: 0;
}

#lscnr-map
  .leaflet-control-layers-expanded
  .leaflet-control-layers-list::-webkit-scrollbar-corner {
  background: transparent;
}

#lscnr-map
  .leaflet-control-layers-expanded
  .leaflet-control-layers-list::-webkit-scrollbar-track {
  margin: 0;
  border-radius: 3px;
  background: var(--lscnr-layers-scrollbar-rail);
  box-shadow: inset 0 0 0 1px var(--lscnr-layers-scrollbar-rail-edge);
}

#lscnr-map
  .leaflet-control-layers-expanded
  .leaflet-control-layers-list::-webkit-scrollbar-thumb {
  border-radius: 3px;
  border: 1px solid rgba(255, 255, 255, 0.06);
  background-color: var(--lscnr-layers-scrollbar-thumb);
  background-clip: padding-box;
}

#lscnr-map
  .leaflet-control-layers-expanded
  .leaflet-control-layers-list::-webkit-scrollbar-thumb:hover {
  background-color: var(--lscnr-layers-scrollbar-thumb-hover);
  border-color: rgba(255, 255, 255, 0.1);
}

#lscnr-map
  .leaflet-control-layers-expanded
  .leaflet-control-layers-list::-webkit-scrollbar-thumb:active {
  background-color: var(--lscnr-layers-scrollbar-thumb-hover);
}

.lscnr-map-marker,
.lscnr-map-blip,
#lscnr-map .leaflet-marker-icon.lscnr-map-blip,
#lscnr-map .leaflet-marker-icon.lscnr-blip-marker {
  background: transparent !important;
  border: none !important;
}

#lscnr-map .leaflet-marker-icon.lscnr-map-blip {
  width: 18px !important;
  height: 18px !important;
  margin-left: -18px !important;
  margin-top: -18px !important;
}

#lscnr-map .leaflet-marker-icon.lscnr-blip-marker {
  width: 18px !important;
  height: 18px !important;
  margin-left: -18px !important;
  margin-top: -18px !important;
}

#lscnr-map .lscnr-blip-marker .lscnr-blip-img {
  display: block;
  width: 18px;
  height: 18px;
  pointer-events: none;
}

#lscnr-map .leaflet-control-attribution {
  display: none;
}

#lscnr-map .lscnr-map-tiles {
  image-rendering: auto;
}

#lscnr-map.leaflet-fade-anim .leaflet-tile {
  transition: opacity 0.12s linear;
}

#lscnr-map .leaflet-zoom-anim .leaflet-zoom-animated {
  transition: transform 0.2s cubic-bezier(0, 0, 0.25, 1);
}

.map-legend-status {
  margin: 0;
  font-size: 0.75rem;
  line-height: 1.4;
  color: #d4d4d4;
}

.map-legend-status--error {
  color: #fca5a5;
}

#lscnr-map .map-legend-title {
  margin: 0 0 0.5rem;
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: #a3a3a3;
}

#lscnr-map .map-legend-layer {
  margin-bottom: 0.625rem;
  padding-bottom: 0.625rem;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

#lscnr-map .map-legend-layer:last-child {
  margin-bottom: 0;
  padding-bottom: 0;
  border-bottom: none;
}

#lscnr-map .map-legend-layer.is-off {
  opacity: 0.55;
}

#lscnr-map .map-legend-toggle {
  display: flex;
  align-items: center;
  gap: 0.375rem;
  cursor: pointer;
  user-select: none;
}

#lscnr-map .map-legend-toggle input {
  accent-color: #f5f5f5;
  flex-shrink: 0;
}

#lscnr-map .map-legend-label {
  flex: 1 1 auto;
  color: #f5f5f5;
  font-weight: 500;
}

#lscnr-map .map-legend-count {
  flex-shrink: 0;
  font-size: 0.6875rem;
  color: #a3a3a3;
  font-variant-numeric: tabular-nums;
}

#lscnr-map .map-legend-price {
  margin-top: 0.375rem;
  padding-left: 1.25rem;
}

#lscnr-map .map-legend-price-readout {
  margin: 0 0 0.25rem;
  font-size: 0.6875rem;
  color: #d4d4d4;
  font-variant-numeric: tabular-nums;
}

/* Dual-thumb price range (one track, min + max handles) */
#lscnr-map .map-legend-dual-range {
  position: relative;
  height: 1.75rem;
  margin: 0.375rem 0 0.125rem;
}

#lscnr-map .map-legend-dual-range-track {
  position: absolute;
  left: 0;
  right: 0;
  top: 50%;
  height: 0.25rem;
  margin-top: -0.125rem;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.15);
  pointer-events: none;
}

#lscnr-map .map-legend-dual-range-fill {
  position: absolute;
  top: 0;
  bottom: 0;
  left: 0;
  width: 100%;
  border-radius: 999px;
  background: #e5e5e5;
}

#lscnr-map .map-legend-dual-range-input {
  position: absolute;
  left: 0;
  width: 100%;
  height: 1.75rem;
  margin: 0;
  padding: 0;
  background: transparent;
  pointer-events: none;
  -webkit-appearance: none;
  appearance: none;
}

#lscnr-map .map-legend-dual-range-input--max {
  z-index: 2;
}

#lscnr-map .map-legend-dual-range-input--min {
  z-index: 3;
}

#lscnr-map .map-legend-dual-range-input::-webkit-slider-runnable-track {
  height: 0.25rem;
  background: transparent;
  border: none;
}

#lscnr-map .map-legend-dual-range-input::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  pointer-events: auto;
  width: 0.875rem;
  height: 0.875rem;
  margin-top: -0.3125rem;
  border-radius: 50%;
  border: 2px solid #171717;
  background: #f5f5f5;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.45);
  cursor: grab;
}

#lscnr-map .map-legend-dual-range-input::-moz-range-track {
  height: 0.25rem;
  background: transparent;
  border: none;
}

#lscnr-map .map-legend-dual-range-input::-moz-range-thumb {
  pointer-events: auto;
  width: 0.875rem;
  height: 0.875rem;
  border-radius: 50%;
  border: 2px solid #171717;
  background: #f5f5f5;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.45);
  cursor: grab;
}

#lscnr-map .leaflet-popup-content {
  margin: 0.5rem 0.75rem;
  font-size: 0.8125rem;
  line-height: 1.4;
  color: #171717;
}

#lscnr-map .leaflet-popup-content p {
  margin: 0.25rem 0;
}

#lscnr-map .leaflet-popup-content strong {
  display: block;
  margin-bottom: 0.35rem;
}

#lscnr-map .map-popup-copy-wrap {
  margin: 0.35rem 0 0.15rem;
}

#lscnr-map .map-popup-copy-coords {
  display: inline-block;
  margin: 0;
  padding: 0.2rem 0.55rem;
  font-size: 0.75rem;
  font-weight: 500;
  line-height: 1.2;
  color: #fafafa;
  background: #262626;
  border: 1px solid rgba(0, 0, 0, 0.2);
  border-radius: 0.25rem;
  cursor: pointer;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.12);
}

#lscnr-map .map-popup-copy-coords:hover {
  background: #404040;
}

#lscnr-map .map-popup-copy-coords:active {
  transform: translateY(1px);
}

#lscnr-map .map-drug-table {
  width: 100%;
  margin: 0.15rem 0 0.35rem;
  border-collapse: collapse;
  font-size: 0.75rem;
  line-height: 1.35;
}

#lscnr-map .map-drug-table th,
#lscnr-map .map-drug-table td {
  padding: 0.2rem 0.4rem;
  border-bottom: 1px solid rgba(23, 23, 23, 0.12);
  vertical-align: top;
}

#lscnr-map .map-drug-table th {
  font-weight: 600;
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  color: rgba(23, 23, 23, 0.65);
}

#lscnr-map .map-drug-table td:last-child {
  text-align: right;
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}

#lscnr-map .map-drug-table tbody tr:last-child td {
  border-bottom: none;
}

#lscnr-map .map-popup-coords {
  margin-top: 0.35rem !important;
  margin-bottom: 0 !important;
}
