/* ------------------------------------------------------------------ */
/* Reset & base                                                         */
/* ------------------------------------------------------------------ */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html, body {
  height: 100%;
  font-family: system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  font-size: 14px;
}

/* ------------------------------------------------------------------ */
/* Full-screen map                                                      */
/* ------------------------------------------------------------------ */
#map {
  position: absolute;
  inset: 0;
}

/* ------------------------------------------------------------------ */
/* Floating UI panel                                                    */
/* ------------------------------------------------------------------ */
#ui-panel {
  position: absolute;
  top: 12px;
  left: 12px;
  z-index: 10;
  width: 265px;
  background: rgba(255, 255, 255, 0.97);
  border-radius: 10px;
  padding: 16px;
  box-shadow: 0 3px 14px rgba(0, 0, 0, 0.18);
  max-height: calc(100vh - 24px);
  overflow-y: auto;
}

#ui-panel::-webkit-scrollbar { width: 5px; }
#ui-panel::-webkit-scrollbar-thumb { background: #ccc; border-radius: 3px; }

#ui-panel h2 {
  font-size: 1rem;
  font-weight: 700;
  color: #111;
  margin-bottom: 12px;
}

#ui-panel h3 {
  font-size: 0.72rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: #666;
  margin-top: 14px;
  margin-bottom: 7px;
}

/* ------------------------------------------------------------------ */
/* Search                                                               */
/* ------------------------------------------------------------------ */
#search-container {
  position: relative;
}

#search-row {
  display: flex;
  gap: 6px;
}

#search-input {
  flex: 1;
  padding: 7px 10px;
  border: 1.5px solid #ccc;
  border-radius: 6px;
  font-size: 0.85rem;
  outline: none;
  transition: border-color 0.15s;
}

#search-input:focus {
  border-color: #3b82f6;
}

#search-btn {
  padding: 7px 10px;
  background: #3b82f6;
  color: #fff;
  border: none;
  border-radius: 6px;
  cursor: pointer;
  font-size: 0.9rem;
  line-height: 1;
  transition: background 0.15s;
}

#search-btn:hover {
  background: #2563eb;
}

/* Results dropdown */
#search-results {
  list-style: none;
  position: absolute;
  top: calc(100% + 3px);
  left: 0;
  right: 0;
  background: #fff;
  border: 1px solid #ddd;
  border-radius: 6px;
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.1);
  max-height: 200px;
  overflow-y: auto;
  z-index: 20;
}

#search-results:empty {
  display: none;
}

#search-results li {
  padding: 9px 12px;
  cursor: pointer;
  font-size: 0.82rem;
  color: #222;
  border-bottom: 1px solid #f2f2f2;
  line-height: 1.3;
}

#search-results li:last-child {
  border-bottom: none;
}

#search-results li:hover {
  background: #eff6ff;
}

#search-results li.status-msg {
  color: #888;
  cursor: default;
  pointer-events: none;
}

/* ------------------------------------------------------------------ */
/* Checkboxes and labels                                                */
/* ------------------------------------------------------------------ */
#road-mode-section,
#layer-controls-section {
  border-top: 1px solid #eee;
  padding-top: 4px;
}

#road-mode-section label,
#layer-controls-section label {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 4px 2px;
  cursor: pointer;
  color: #333;
  border-radius: 4px;
  transition: color 0.12s;
  user-select: none;
}

#road-mode-section label:hover,
#layer-controls-section label:hover {
  color: #000;
}

/* ------------------------------------------------------------------ */
/* Map style switcher (Streets / Satellite)                             */
/* ------------------------------------------------------------------ */
#style-switcher {
  display: flex;
  margin-bottom: 12px;
  border: 1.5px solid #ddd;
  border-radius: 7px;
  overflow: hidden;
}

.style-btn {
  flex: 1;
  padding: 7px 0;
  font-size: 0.82rem;
  font-weight: 500;
  background: #fff;
  border: none;
  cursor: pointer;
  color: #555;
  transition: background 0.15s, color 0.15s;
}

.style-btn:not(:last-child) {
  border-right: 1.5px solid #ddd;
}

.style-btn.active {
  background: #3b82f6;
  color: #fff;
}

.style-btn:hover:not(.active) {
  background: #f0f4ff;
}

/* ------------------------------------------------------------------ */
/* Panel toggle button (hamburger — hidden on desktop)                  */
/* ------------------------------------------------------------------ */
#panel-toggle {
  display: none; /* shown in mobile media query below */
  position: absolute;
  top: 12px;
  left: 12px;
  z-index: 11; /* above the panel so it's always tappable */
  width: 44px;
  height: 44px;
  background: rgba(255, 255, 255, 0.97);
  border: none;
  border-radius: 8px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
  font-size: 1.25rem;
  cursor: pointer;
  align-items: center;
  justify-content: center;
}

/* ------------------------------------------------------------------ */
/* Mobile layout — panel slides in from the left                        */
/* ------------------------------------------------------------------ */
@media (max-width: 599px) {
  /* Show the hamburger toggle */
  #panel-toggle {
    display: flex;
    /* Respect notch / status bar on iOS */
    top: max(12px, env(safe-area-inset-top));
    left: max(12px, env(safe-area-inset-left));
  }

  /* Panel: full-height drawer, hidden off-screen by default */
  #ui-panel {
    top: 0;
    left: 0;
    bottom: 0;
    width: min(300px, 90vw);
    max-height: 100%;
    border-radius: 0 12px 12px 0;
    transform: translateX(calc(-100% - 20px)); /* slide fully off-screen */
    transition: transform 0.25s ease;
    /* Respect notch insets */
    padding-top: max(16px, env(safe-area-inset-top));
    padding-bottom: max(16px, env(safe-area-inset-bottom));
    padding-left: max(16px, env(safe-area-inset-left));
  }

  /* Panel open state — toggled by JS */
  #ui-panel.open {
    transform: translateX(0);
  }

  /* Larger touch targets on mobile (Apple HIG recommends 44 × 44 pt minimum) */
  #road-mode-section label,
  #layer-controls-section label {
    min-height: 44px;
    padding-top: 8px;
    padding-bottom: 8px;
  }

  /* Zoom controls: avoid notch / home indicator */
  .mapboxgl-ctrl-bottom-right {
    bottom: max(12px, env(safe-area-inset-bottom));
    right: max(12px, env(safe-area-inset-right));
  }
}
