: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;
  user-select: none;
  -webkit-user-select: none;
}

/* header desktop */

.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;
}

/* profielknoppen */

.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);
}

/* bovenste panel */

#top-panel {
  background: var(--bg-panel);
  border-bottom: 1px solid var(--border-subtle);
  padding: 10px 12px 8px;
  display: flex;
  justify-content: center;
}

#top-inner {
  width: 100%;
  max-width: 640px; /* smaller op groot scherm */
  display: flex;
  flex-direction: column;
  gap: 8px;
}

#inputs-row {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.field-group {
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.field-group label {
  font-size: 11px;
  font-weight: 500;
  color: #4b5563;
}

/* input met locatie-icoon */

.input-with-icon {
  position: relative;
}

.input-with-icon input {
  width: 100%;
  padding-right: 40px; /* ruimte voor icoon */
}

.icon-button {
  position: absolute;
  top: 50%;
  right: 6px;
  transform: translateY(-50%);
  width: 26px;
  height: 26px;
  border-radius: 999px;
  border: 1px solid var(--border-strong);
  background: #e5e7eb;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  padding: 0;
}

.icon-button svg {
  width: 16px;
  height: 16px;
  fill: #1f2937;
}

.icon-button:hover {
  background: #d1d5db;
}

/* reset oude stijl op id (zodat hij niet blauw wordt) */
#btn-use-location {
  border: none;
  background: transparent;
}

/* inputs algemeen */

.field-group input {
  font-size: 12px;
  padding: 5px 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);
}

/* samenvatting */

#summary-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-top: 2px;
  flex-wrap: wrap;
}

#summary-line {
  font-size: 12px;
  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;
}

/* route details knop beter zichtbaar */

#details-toggle-label {
  font-size: 11px;
  padding: 4px 12px;
  border-radius: 999px;
  border: 1px solid var(--accent-soft);
  background: #ffffff;
  color: var(--accent-strong);
  cursor: pointer;
  user-select: none;
  -webkit-user-select: none;
  font-weight: 500;
}

#details-toggle-label:hover {
  background: var(--accent-soft);
  color: #0f172a;
}

/* details panel */

#details-panel {
  background: #fefefe;
  border-bottom: 1px solid var(--border-subtle);
  padding: 10px 12px 12px;
  display: none;
}

/* centreren en max breedte, compacter */

#details-panel-inner {
  /* als dit element niet bestaat, valt de styling gewoon weg,
     daarom hieronder ook styling direct op #details-panel */
}

/* fallback: direct op panel zelf */
#details-panel {
  background: var(--bg-panel);          /* volledige band in dezelfde lichte kleur */
  display: none;
  gap: 24px;
  padding: 10px 12px 12px;              /* binnenmarge boven/onder */
  border-bottom: 1px solid var(--border-subtle);
}

/* details zichtbaar als toggle aan staat */
#details-toggle:checked ~ #details-panel {
  display: flex;
}



#details-toggle:checked ~ #details-panel {
  display: flex;
}

.details-column {
  flex: 1;
  min-width: 200px;
  font-size: 12px;
}

/* kolomverhouding: ondergrond smaller, reistijd groter, legenda smal */
#details-panel .details-column:nth-child(1) {
  flex: 0.9;
}
#details-panel .details-column:nth-child(2) {
  flex: 1.3;
}
#details-panel .details-column:nth-child(3) {
  flex: 0.9;
}

.details-heading {
  margin: 0 0 4px;
  font-size: 11px;
  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: 11px;
}

#route-summary {
  font-size: 12px;
  color: #374151;
}

#legend {
  font-size: 11px;
  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;
}

/* 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;
  user-select: none;
  -webkit-user-select: none;
}

#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;
}

/* grotere touch zone markers */

.leaflet-touch .leaflet-marker-icon {
  padding: 10px;
  margin: -10px;
  background-clip: padding-box;
  z-index: 1100 !important;
}

/* download GPX knop */

#btn-download-gpx {
  border-radius: 999px;
  border: 1px solid rgba(251, 191, 36, 0.9);
  background: #111827;
  color: #fde68a;
  padding: 4px 10px;
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
  white-space: nowrap;
  box-shadow: 0 0 0 1px rgba(15, 23, 42, 0.7);
  transition: background 0.12s ease, color 0.12s ease, transform 0.12s ease;
}

#btn-download-gpx:hover {
  background: #facc15;
  color: #111827;
  transform: translateY(-1px);
}

#btn-download-gpx:active {
  transform: translateY(0);
}

/* responsive header lay-out voor mobiel */

@media (max-width: 700px) {
  .app-header {
    grid-template-columns: minmax(0, 1fr) auto;
    grid-template-areas:
      "title gpx"
      "profiles profiles";
    row-gap: 6px;
  }

  .header-left {
    grid-area: title;
  }

  .header-center {
    grid-area: profiles;
    justify-content: flex-start;
  }

  .header-right {
    grid-area: gpx;
    justify-content: flex-end;
  }

  #top-panel {
    padding-inline: 8px;
  }

  #top-inner {
    max-width: 100%;
  }

  #details-panel {
    flex-direction: column;
    max-width: 100%;
  }

  #details-panel .details-column {
    min-width: 0;
  }
}
/* centreer inhoud bij brede schermen, met volledige achtergrond */
@media (min-width: 960px) {
  #details-panel {
    padding-left: max(12px, (100vw - 960px) / 2);
    padding-right: max(12px, (100vw - 960px) / 2);
  }
}
