:root {
  --bg-page: #020617;
  --bg-header: #020617;
  --bg-panel: #f9fafb;
  --bg-panel-soft: #f3f4f6;
  --border-subtle: #e5e7eb;
  --border-strong: #d1d5db;
  --accent: #2563eb;
  --accent-soft: #dbeafe;
  --accent-strong: #1d4ed8;
  --text-main: #111827;
  --text-soft: #6b7280;
  --text-invert: #f9fafb;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
  height: 100%;
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: var(--bg-page);
  color: var(--text-main);
}

body {
  display: flex;
  flex-direction: column;
}

#app {
  display: flex;
  flex-direction: column;
  flex: 1 1 auto;
  min-height: 0;
  /* NIEUWE REGELS OM ALLE TEKSTSELECTIE BINNEN DE APP TE BLOKKEREN */
  user-select: none;
  -webkit-user-select: none;
}



/* header */

.app-header {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr);
  align-items: center;
  gap: 12px;
  padding: 8px 12px;
  background: linear-gradient(90deg, #020617, #111827);
  color: var(--text-invert);
  border-bottom: 1px solid rgba(148, 163, 184, 0.8);
  z-index: 10;
}

.header-left {
  display: flex;
  align-items: center;
}

.app-title {
  font-weight: 600;
  font-size: 15px;
  letter-spacing: 0.02em;
  white-space: nowrap;
}

.header-center {
  display: flex;
  justify-content: center;
}

.header-right {
  display: flex;
  justify-content: flex-end;
}

.profile-buttons {
  display: inline-flex;
  gap: 4px;
  padding: 3px;
  border-radius: 999px;
  background: rgba(15, 23, 42, 0.8);
  border: 1px solid rgba(55, 65, 81, 0.9);
}

.profile-buttons button {
  border: none;
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 12px;
  cursor: pointer;
  background: transparent;
  color: #e5e7eb;
  transition: background 0.15s ease, color 0.15s ease;
  white-space: nowrap;
}

.profile-buttons button:hover {
  background: #1f2937;
}

.profile-buttons button.active {
  background: var(--accent);
  color: var(--text-invert);
}

.ghost-button {
  border-radius: 999px;
  border: 1px solid rgba(148, 163, 184, 0.8);
  background: transparent;
  color: #e5e7eb;
  padding: 5px 12px;
  font-size: 12px;
  cursor: pointer;
}

.ghost-button:hover {
  background: rgba(15, 23, 42, 0.8);
}

/* top panel */

#top-panel {
  background: var(--bg-panel);
  border-bottom: 1px solid var(--border-subtle);
  padding: 10px 12px 8px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

#inputs-row {
  display: grid;
  grid-template-columns: minmax(0, 1.5fr) minmax(0, 1.5fr);
  gap: 12px;
}

.field-group {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.field-group label {
  font-size: 12px;
  font-weight: 500;
  color: #4b5563;
}

.field-with-button {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 6px;
}

.field-group input {
  font-size: 13px;
  padding: 6px 8px;
  border-radius: 8px;
  border: 1px solid var(--border-strong);
  outline: none;
  min-width: 0;
}

.field-group input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 1px var(--accent-soft);
}

#btn-use-location {
  font-size: 12px;
  padding: 6px 10px;
  border-radius: 999px;
  border: 1px solid var(--accent-soft);
  background: var(--accent-strong);
  color: var(--text-invert);
  cursor: pointer;
  white-space: nowrap;
}

#btn-use-location:hover {
  background: #1e40af;
}

#summary-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-top: 2px;
  flex-wrap: wrap;
}

#summary-line {
  font-size: 13px;
  color: #111827;
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  align-items: center;
}

.summary-separator {
  color: #9ca3af;
}

#details-toggle-wrapper {
  display: flex;
  align-items: center;
  justify-content: flex-end;
}

#details-toggle-label {
  font-size: 12px;
  padding: 4px 10px;
  border-radius: 999px;
  border: 1px solid var(--border-subtle);
  background: var(--bg-panel-soft);
  color: #374151;
  cursor: pointer;
  
  /* Zorgt ervoor dat de tekst niet geselecteerd kan worden */
  user-select: none;
  -webkit-user-select: none; 
}

#details-toggle-label:hover {
  border-color: var(--accent-soft);
}

/* details panel */

#details-panel {
  background: #fefefe;
  border-bottom: 1px solid var(--border-subtle);
  padding: 8px 12px 10px;
  display: none;
  gap: 16px;
}

.details-column {
  flex: 1;
  min-width: 180px;
  font-size: 13px;
}

.details-heading {
  margin: 0 0 4px;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-soft);
}

#surface-panel strong {
  display: inline-block;
  margin-bottom: 2px;
}

#surface-panel .line {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  color: #4b5563;
  font-size: 12px;
}

#surface-panel .line span:first-child {
  font-variant-numeric: tabular-nums;
}

#route-summary {
  font-size: 13px;
  color: #374151;
}

#legend {
  font-size: 12px;
  color: #4b5563;
}

#legend-title {
  font-weight: 600;
  margin-bottom: 2px;
}

#legend-items {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
}

.legend-item {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 11px;
  padding: 2px 6px;
  border-radius: 999px;
  background: var(--bg-panel-soft);
  border: 1px solid var(--border-subtle);
}

.legend-swatch {
  width: 16px;
  height: 4px;
  border-radius: 999px;
}

/* toggle details */

#details-toggle:checked ~ #details-panel {
  display: flex;
}

/* kaart */

#map-container {
  position: relative;
  flex: 1 1 auto;
  min-height: 0;
}

#map {
  width: 100%;
  height: 100%;
  min-height: 320px;
  touch-action: manipulation;
}

/* contextmenu */

#map-context-menu {
  position: absolute;
  z-index: 1000;
  background: #ffffff;
  border: 1px solid rgba(148, 163, 184, 0.7);
  border-radius: 8px;
  box-shadow: 0 18px 40px rgba(15, 23, 42, 0.35);
  font-size: 13px;
  display: none;
  min-width: 170px;
  overflow: hidden;
  /* DEZE REGELS OPLOSSEN HET POP-UP CONFLICT OP MOBIEL */
  user-select: none;
  -webkit-user-select: none; /* Voor oudere iOS/Safari */
}

/* 2. Stijlen voor de Leaflet controls (NIEUW BLOK) */
.leaflet-control-zoom,
.leaflet-control-attribution {
  user-select: none;
  -webkit-user-select: none; /* Zorgt dat de +- knoppen niet geselecteerd worden */
  touch-action: manipulation; 
}



#map-context-menu button {
  display: block;
  width: 100%;
  padding: 7px 10px;
  border: none;
  background: transparent;
  text-align: left;
  cursor: pointer;
  color: #111827;
  font-size: 13px;
}

#map-context-menu button + button {
  border-top: 1px solid #e5e7eb;
}

#map-context-menu button:hover {
  background: #eff6ff;
}

/* debug */

#debug-container {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  max-height: 30%;
  background: rgba(15, 23, 42, 0.96);
  color: #a7f3d0;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
  font-size: 11px;
  padding: 8px;
  overflow: auto;
  display: none;
  z-index: 1200;
  border-top: 1px solid rgba(75, 85, 99, 0.8);
}

#debug-container pre {
  margin: 0;
  white-space: pre-wrap;
  word-break: break-all;
}

@media (max-width: 900px) {
  .app-header {
    grid-template-columns: minmax(0, 1fr);
    row-gap: 6px;
  }

  .header-center,
  .header-right {
    justify-content: flex-start;
  }

  #inputs-row {
    grid-template-columns: minmax(0, 1fr);
  }

  #summary-row {
    flex-direction: column;
    align-items: flex-start;
  }
}
/* Vergroot het touch-gebied voor alle Leaflet markers op mobiel */
.leaflet-touch .leaflet-marker-icon {
    /* Vergroot de transparante rand (padding) rond het icoon */
    padding: 10px; 
    /* Zorgt ervoor dat de schaal correct blijft */
    margin: -10px;
    /* Zorgt dat de marker nog steeds de juiste positie op de kaart aanwijst */
    background-clip: padding-box;
    /* Belangrijk: Geef de marker een hogere z-index bij touch om over routes te blijven */
    z-index: 1100 !important;
}