/* ───── General Layout ───── */
html,
body {
  margin: 0;
  padding: 0;
  height: 100%;
  font-family: sans-serif;
}

#map {
  width: 100%;
  height: 100%;
}

/* ────────────── Legend Style ────────────── */

.legend-heading {
  font-size: 24px;
  font-weight: bold;
}

.legend-subtext {
  font-size: 12px;
  color: #555;
}

.legend {
  position: absolute;
  top: 60px;
  right: 10px;
  width: 320px;
  max-width: 100%;
  max-height: calc(100dvh - 160px);
  /* 60 top + 80 bottom */
  /* background: rgb(254, 253, 255); */
  background: white;
  padding: 10px;
  font-size: 12px;
  border-radius: 5px;
  box-shadow: 0 0 5px rgba(0, 0, 0, 0.2);
  /* overflow-y: auto; */
  overflow-y: scroll;
  scrollbar-gutter: stable;
}


.legend .legend-title .info-icon {
  font-size: 14px;
  cursor: help;
  color: #555;
}

.legend-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 4px 0 6px;
  cursor: pointer;
}

.legend-header label {
  font-size: 12px;
}


.legend-section-divider {
  border-top: 1px solid #ccc;
  margin: 12px 0 6px;
}

.legend-subsection-divider {
  border-top: 1px solid #ddd;
  margin: 2px 0;
  margin-left: 16px;
  /* Einrückung nach rechts */
  width: calc(100% - 16px);
  /* Optional: macht's proportional */
}

/* Items and layout */
.legend-items {
  margin-left: 8px;
}

.legend-items.collapsed {
  display: none;
}


.legend-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 6px;
  margin-bottom: 4px;
}

.label-wrapper {
  display: flex;
  align-items: center;
  gap: 6px;
  flex: 1;
  /* ← This is the key part */
  min-width: 0;
  /* prevents overflow on long labels */
}


/* .legend-section {
    margin-top: 10px;
} */



.legend-section-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-weight: bold;
  font-size: 14px;
  margin-bottom: 6px;
  color: #333;
  cursor: pointer;
  gap: 6px;
}

.legend-section-title label {
  display: flex;
  align-items: center;
  gap: 6px;
}



.legend.collapsed>.legend-section,
.legend.collapsed>.scenario-legend-section,
.legend.collapsed>.legend-subsection-divider {
  display: none;
}


/* ─── Cluster Legend Layout ─── */



.legend-section-allcontent {
  display: flex;
  gap: 20px;
  margin-top: 14px; 

}


/* ─── Linke Spalte: Cluster Entries ─── */

.cluster-legend-entry {
  display: grid;
  grid-template-columns: 35px 1fr;
  align-items: center;
  column-gap: 6px;
  margin-bottom: 6px;
  padding-left: 8px;
}

.cluster-dot {
  justify-self: center;
  background-color: #999;
  border-radius: 50%;
  border: 0.5px solid #e6e6e6;
  box-sizing: border-box;
}

.cluster-label {
  text-align: center;
  white-space: nowrap;
}


/* ─── Rechte Spalte: Verletztenanteile ─── */

#cluster-legend-color {
  margin-left: 10px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.cluster-color-item {
  display: flex;
  align-items: center;
  gap: 8px;
}

.cluster-color-item svg {
  width: 30px;
  height: 30px;
  display: block;
  /* wichtig! */
  min-width: 30px;
  /* stellt konsistente Breite sicher */
}



/* ─────  ───── */
.color-box {
  width: 14px;
  height: 14px;
  display: inline-block;
  border-radius: 2px;
}



/* ───── Count Badges ───── */

.count-badge {
  font-size: 10px;
  padding: 0 4px;
  background: #eee;
  border-radius: 10px;
  min-width: 24px;
  text-align: center;
  white-space: nowrap;
  color: #333;
  display: inline-block;
  flex-shrink: 0;
}

/* ───── Toggle Arrows ───── */

/* Basis-Pfeil-Logik */
.toggle-arrow {
  display: inline-block;
  transform: rotate(135deg);
  transition: transform 0.2s ease;
}

/* Offener Zustand */
.toggle-arrow.open {
  transform: rotate(45deg);
}

/* Großer Root-Pfeil (nur bei legend-root) */
[data-arrow="legend-root"] {
  width: 14px !important;
  height: 14px !important;
  border-right: 5px solid #000 !important;
  border-bottom: 5px solid #000 !important;
  margin-left: auto;
}

/* Mittlere Section-Pfeile */
.section-arrow {
  width: 10px;
  height: 10px;
  border-right: 4px solid #000;
  border-bottom: 4px solid #000;
  margin-left: 8px;
}

/* Kleine Pfeile bei legend-header */
.legend-header .toggle-arrow {
  width: 6px;
  height: 6px;
  border-right: 3px solid #000;
  border-bottom: 3px solid #000;
  margin-left: 6px;
}



/* Einklappbare Sektionen */
.legend-section.collapsed .legend-section-content {
  display: none;
}

.legend-section.collapsed .legend-section-allcontent {
  display: none;
}




/* ───── Hidden Section Defaults ───── */
#mapillary-legend,
#movebis-legend,
#hvs-legend,
#maxspeed-legend,
#obs-legend,
#schools-legend {
  display: none;
}




/* ────────────── Feature Count ────────────── */

#feature-count {
  display: flex;
  flex-direction: column;
  justify-content: center;
  line-height: 1.3;
}

#feature-count-wrapper {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  margin-top: 10px;
}


/* ────────────── zoomlock ────────────── */
.zoom-lock {
  font-size: 0.8em;
  vertical-align: middle;
  opacity: 0.8;
}

/* ────────────── Photon Geocoder (Stil: vizsim/hilo_profiler) ────────────── */
.geocoder {
  position: absolute;
  top: 8px;
  left: 8px;
  z-index: 7;
  width: 320px;
  max-width: calc(100vw - 24px);
  font-family: sans-serif;
}

.geocoder-input-wrapper {
  position: relative;
  display: flex;
  align-items: center;
  background: rgba(255, 255, 255, 0.98);
  border: 1px solid #d9e2ec;
  border-radius: 12px;
  box-shadow: 0 10px 28px rgba(15, 23, 42, 0.18);
  backdrop-filter: blur(8px);
}
.geocoder-input-wrapper:focus-within {
  border-color: #2563eb;
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.14), 0 10px 28px rgba(15, 23, 42, 0.18);
}

#search {
  width: 100%;
  padding: 11px 38px 11px 40px;
  font-size: 14px;
  border: none;
  outline: none;
  background: transparent;
  color: #111827;
  box-sizing: border-box;
}
#search::placeholder { color: #64748b; }

.geocoder-icon {
  position: absolute;
  left: 12px;
  color: #64748b;
  pointer-events: none;
}

.geocoder-clear,
.geocoder-loading {
  position: absolute;
  right: 8px;
  width: 24px;
  height: 24px;
  min-height: 24px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: transparent;
  border: none;
  color: #64748b;
  padding: 0;
  box-shadow: none;
  cursor: pointer;
  border-radius: 8px;
}
.geocoder-clear:hover { background: #eef2f7; }
.geocoder-loading {
  pointer-events: none;
  animation: spin 1s linear infinite;
}
@keyframes spin {
  from { transform: rotate(0deg); }
  to { transform: rotate(360deg); }
}

.geocoder-results {
  margin-top: 4px;
  max-height: 300px;
  overflow-y: auto;
  background: rgba(255, 255, 255, 0.98);
  border: 1px solid #d9e2ec;
  border-radius: 12px;
  box-shadow: 0 10px 28px rgba(15, 23, 42, 0.18);
  display: none;
}
.geocoder-result-item {
  padding: 10px 12px;
  cursor: pointer;
  border-bottom: 1px solid #d9e2ec;
}
.geocoder-result-item:last-child { border-bottom: none; }
.geocoder-result-item:hover,
.geocoder-result-item.selected { background: #eef2f7; }
.geocoder-result-primary {
  font-size: 14px;
  color: #111827;
  font-weight: 600;
}
.geocoder-result-secondary,
.geocoder-no-results {
  font-size: 12px;
  color: #64748b;
}
.geocoder-no-results { padding: 10px 12px; }

/* ───── Container Bottom Left ───── */
#bottom-left-ui-container {
  position: absolute;
  bottom: 64px;            /* angehoben: Platz für den Karten-Panel-Button darunter */
  left: 10px;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 8px;
  z-index: 2;
  font-family: sans-serif;
}

/* Nav (Zoom/Kompass) als 44px-Kacheln, passend zum Karten-Panel-Button (wie hilo_profiler) */
#custom-nav-control .maplibregl-ctrl-group {
  display: flex;
  flex-direction: column;
  gap: 8px;
  width: 44px;
  background: transparent;
  border: none;
  box-shadow: none;
}
#custom-nav-control .maplibregl-ctrl-group button {
  width: 44px;
  height: 44px;
  border-radius: 12px;
  background: #fff;
  border: 1px solid #e3e5e9;
  box-shadow: 0 6px 16px rgba(0, 0, 0, .12);
}

/* ───── Basemap Thumbnails ───── */

#basemap-thumbnails {
  display: flex;
  gap: 8px;
  align-items: flex-end;
}

.basemap-thumb {
  width: 60px;
  height: 60px;
  background-size: cover;
  background-position: center;
  border: 2px solid #ccc;
  border-radius: 6px;
  cursor: pointer;
  box-shadow: 0 0 4px rgba(0, 0, 0, 0.2);
  transition: border 0.2s;
  margin-bottom: -2px;
}

.basemap-thumb.selected {
  border-color: #0077ff;
}

/* ───── Terrain Controls ───── */
#terrain-controls {
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  height: 63px;
  /* Match thumbs */
  padding: 4px 6px;
  font-size: 12px;
  border: 2px solid #ccc;
  border-radius: 6px;
  background: white;
  box-shadow: 0 0 4px rgba(0, 0, 0, 0.2);
  transition: border 0.2s;
  box-sizing: border-box;
  margin-bottom: -1px;
  margin-left: -4px;
}

#terrain-controls label {
  display: flex;
  align-items: center;
  height: 50%;
}



/* ─── ─── */

.spacer {
  /* width: 160px; */
  display: none;
  /* Erzwingt Breite für rechte Spalte */
}


/* Toggle-Labels in Szenarien + Kontext: hängender Einzug, damit umgebrochene Zeilen
   unter dem Text (nicht links unter der Checkbox) weiterlaufen. Ausgenommen:
   Sektions-Header (liegen außerhalb .legend-section-content), Slider-Labels (for=…)
   und Flex-Labels (Mapillary-Filter mit Icon). */
.scenario-legend-section .legend-section-content label:not([for]):not([style*="flex"]),
.legend-section[data-section="kontext"] .legend-section-content label:not([for]):not([style*="flex"]) {
  display: block;
  padding-left: 1.45em;
  text-indent: -1.45em;
}

/* slider */
#scenario1-slider,
#scenario8-slider,
#scenario2-slider {
  --progress: 0%;
  appearance: none;
  height: 6px;
  border-radius: 3px;
  background: linear-gradient(to right, #ccc var(--progress), orange var(--progress));
  outline: none;
}

#scenario1-slider::-webkit-slider-thumb,
#scenario8-slider::-webkit-slider-thumb,
#scenario2-slider::-webkit-slider-thumb {
  appearance: none;
  height: 16px;
  width: 16px;
  border-radius: 50%;
  background: #fff;
  border: 2px solid orange;
  cursor: pointer;
  /* margin-top: -1px; */
  /* zentrieren */
}

#scenario1-slider::-moz-range-thumb,
#scenario8-slider::-moz-range-thumb,
#scenario2-slider::-moz-range-thumb {
  height: 12px;
  width: 12px;
  border-radius: 50%;
  background: #fff;
  border: 2px solid orange;
  cursor: pointer;
}

#scenario-legend-section {
  display: block !important;
  visibility: visible !important;
  opacity: 1 !important;
}


.legend-section-subtitle {
  font-weight: 600;
  font-size: 12px;
  margin: 12px 10px 4px 10px;
  color: #333;
}

/* ===== Radinfrastruktur-Legende (rechtes Kontext-Panel, Stil aus mapillary_coverage_analysis) ===== */
#bikelanes-legend .bl-row {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 4px;
}
#bikelanes-legend .bl-line {
  width: 22px;
  height: 3px;
  border-radius: 2px;
  flex-shrink: 0;
}
#bikelanes-legend .bl-line.solid {
  background: var(--line-color, #174ed9);
}
#bikelanes-legend .bl-line.dashed {
  background: repeating-linear-gradient(to right,
      var(--line-color, #174ed9) 0 6px, transparent 6px 8px);
}
/* Zoom-Hinweis "Daten ab Zoomstufe X+" (Radinfra + Tempolimit), nur unter dataMinZoom. */
.zoom-hint {
  padding: 6px 10px;
  margin-bottom: 8px;
  background: rgba(255, 193, 7, 0.1);
  border: 1px solid rgba(255, 193, 7, 0.3);
  border-radius: 4px;
  font-size: 11px;
}
#bikelanes-legend .bl-source {
  margin-top: 6px;
  opacity: 0.8;
}
#bikelanes-legend .bl-source a {
  color: inherit;
}

/* ===== Karten-Panel (unten links) — aus frontend-Makeover ===== */
/* Karten-Panel unten links — an style.css anhängen. Aus vizsim/gradients2osm. */

.map-settings-toggle {
  position: absolute; left: 10px; bottom: 10px; z-index: 6;
  width: 44px; height: 44px; border-radius: 12px;
  background: #fff; border: 1px solid #e3e5e9;
  box-shadow: 0 6px 16px rgba(0,0,0,.12);
  display: inline-flex; align-items: center; justify-content: center;
  color: #4b5563; padding: 0; cursor: pointer;
}
.map-settings-toggle:hover { background: #f3f4f6; }

.map-settings-panel {
  position: absolute; left: 10px; bottom: 64px; width: 300px;
  max-width: calc(100vw - 32px);
  background: #fff; border-radius: 16px; border: 1px solid #e3e5e9;
  box-shadow: 0 14px 40px rgba(0,0,0,.18); z-index: 5; padding: 14px;
  display: flex; flex-direction: column; gap: 12px;
}
.map-settings-panel.is-collapsed { display: none; }
.map-settings-panel-content { display: flex; flex-direction: column; gap: 10px; }

.basemap-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.basemap-btn {
  display: flex; flex-direction: column; align-items: center; gap: 6px;
  padding: 6px; border: 1px solid transparent; border-radius: 10px;
  background: #f9fafb; cursor: pointer;
}
.basemap-btn:hover { background: #f3f4f6; }
.basemap-btn.selected { border-color: #1d4ed8; background: #eef2ff; }
.basemap-preview {
  width: 100%; aspect-ratio: 1 / 1; border-radius: 8px;
  background-size: cover; background-position: center; background-color: #e5e7eb;
}
/* Thumbnails 1:1 aus vizsim/gradients2osm (viz/assets/basemaps) übernommen. */
.basemap-preview-positron  { background-color: #eef3f7; background-image: url('./thumbs/thumb-standard.png'); }
.basemap-preview-osm       { background-color: #f5f1df; background-image: url('./thumbs/thumb-osm.png'); }
.basemap-preview-satellite { background-color: #516146; background-image: url('./thumbs/thumb-satellite.png'); }
.basemap-label { font-size: 11px; color: #4b5563; }

.terrain-row { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.terrain-row strong { font-size: 13px; }
.terrain-row p { margin: 2px 0 0; font-size: 11px; color: #6b7280; }

.switch { position: relative; display: inline-block; width: 40px; height: 22px; flex: none; }
.switch input { opacity: 0; width: 0; height: 0; }
.switch-slider {
  position: absolute; inset: 0; cursor: pointer; background: #cbd5e1;
  border-radius: 22px; transition: .2s;
}
.switch-slider::before {
  content: ""; position: absolute; height: 16px; width: 16px; left: 3px; bottom: 3px;
  background: #fff; border-radius: 50%; transition: .2s;
}
.switch input:checked + .switch-slider { background: #1d4ed8; }
.switch input:checked + .switch-slider::before { transform: translateX(18px); }
