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

html, body {
  height: 100%;
  font-family: system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  font-size: 14px;
  color: #212121;
  overflow: hidden;
}

/* ── Map ──────────────────────────────────────────────────────────────────── */
#map {
  position: fixed;
  inset: 0;
  z-index: 0;
}

/* ── Sidebar ──────────────────────────────────────────────────────────────── */
#sidebar {
  position: fixed;
  top: 0;
  left: 0;
  height: 100%;
  width: 285px;
  background: #fff;
  box-shadow: 2px 0 20px rgba(0, 0, 0, 0.18);
  z-index: 1000;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  transition: transform 0.3s ease;
}

/* Sidebar header */
#sidebar-header {
  padding: 18px 16px 14px;
  background: linear-gradient(135deg, #1a237e 0%, #283593 100%);
  color: #fff;
  flex-shrink: 0;
}

#sidebar-header h1 {
  font-size: 17px;
  font-weight: 700;
  letter-spacing: -0.3px;
}

.subtitle {
  font-size: 11px;
  opacity: 0.75;
  margin-top: 3px;
  line-height: 1.4;
}

/* Select All / Hide All buttons */
#sidebar-controls {
  display: flex;
  gap: 8px;
  padding: 10px 12px;
  background: #f5f5f5;
  border-bottom: 1px solid #e0e0e0;
  flex-shrink: 0;
}

#sidebar-controls button {
  flex: 1;
  padding: 7px 0;
  font-size: 12px;
  font-weight: 500;
  border: 1px solid #bdbdbd;
  background: #fff;
  border-radius: 6px;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s;
  color: #212121;
}

#sidebar-controls button:hover {
  background: #e8eaf6;
  border-color: #1a237e;
  color: #1a237e;
}

/* Category list */
#category-list {
  list-style: none;
  overflow-y: auto;
  flex: 1;
  padding: 6px 0;
  scrollbar-width: thin;
  scrollbar-color: #e0e0e0 transparent;
}

#category-list::-webkit-scrollbar {
  width: 4px;
}

#category-list::-webkit-scrollbar-thumb {
  background: #e0e0e0;
  border-radius: 2px;
}

.category-item {
  border-bottom: 1px solid #f5f5f5;
  transition: background 0.1s;
}

.category-item:hover {
  background: #fafafa;
}

.category-item--off .category-name {
  opacity: 0.4;
}

.category-item--off .category-dot {
  opacity: 0.3;
}

.category-item--scam .category-name {
  font-weight: 600;
}

.category-label {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 10px 14px;
  cursor: pointer;
  user-select: none;
}

.category-dot {
  width: 11px;
  height: 11px;
  border-radius: 50%;
  flex-shrink: 0;
  box-shadow: 0 1px 3px rgba(0,0,0,0.2);
}

.category-icon {
  font-size: 17px;
  flex-shrink: 0;
  line-height: 1;
  width: 22px;
  text-align: center;
}

.category-name {
  flex: 1;
  font-size: 13px;
  line-height: 1.3;
  transition: opacity 0.2s;
}

/* Toggle switch — checkbox is visually hidden, track+thumb mimic the switch */
.category-toggle {
  position: absolute;
  opacity: 0;
  width: 0;
  height: 0;
  pointer-events: none;
}

.toggle-track {
  position: relative;
  display: inline-block;
  width: 38px;
  height: 21px;
  background: #bdbdbd;
  border-radius: 11px;
  transition: background 0.2s;
  flex-shrink: 0;
  cursor: pointer;
}

.toggle-thumb {
  position: absolute;
  top: 2.5px;
  left: 2.5px;
  width: 16px;
  height: 16px;
  background: #fff;
  border-radius: 50%;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.3);
  transition: transform 0.2s;
}

.category-toggle:checked + .toggle-track {
  background: #43a047;
}

.category-toggle:checked + .toggle-track .toggle-thumb {
  transform: translateX(17px);
}

/* Sidebar footer */
#sidebar-footer {
  padding: 10px 14px;
  font-size: 11px;
  color: #9e9e9e;
  border-top: 1px solid #eeeeee;
  flex-shrink: 0;
  line-height: 1.8;
}

#sidebar-footer a {
  color: #1a237e;
  text-decoration: none;
}

#sidebar-footer a:hover {
  text-decoration: underline;
}

/* ── Sidebar toggle button ────────────────────────────────────────────────── */
#sidebar-toggle {
  position: fixed;
  top: 14px;
  z-index: 1001;
  background: #1a237e;
  color: #fff;
  border: none;
  padding: 9px 13px;
  font-size: 17px;
  cursor: pointer;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.25);
  line-height: 1;
  transition: background 0.2s;
}

#sidebar-toggle:hover {
  background: #283593;
}

/* ── Backdrop (mobile only, shown when bottom sheet is open) ─────────────── */
#sidebar-backdrop {
  display: none;
}

/* Desktop: button sits at right edge of sidebar */
@media (min-width: 641px) {
  #sidebar-toggle {
    left: 299px; /* sidebar width + 14 gap */
    border-radius: 0 6px 6px 0;
    transition: left 0.3s ease, background 0.2s;
  }

  body.sidebar-hidden #sidebar {
    transform: translateX(-100%);
  }

  body.sidebar-hidden #sidebar-toggle {
    left: 14px;
    border-radius: 6px;
  }
}

/* ── Mobile layout ────────────────────────────────────────────────────────── */
@media (max-width: 640px) {
  /* Toggle button: larger tap target, top-left above map */
  #sidebar-toggle {
    left: 12px;
    top: 12px;
    border-radius: 8px;
    padding: 11px 15px;
    font-size: 19px;
    min-width: 44px;
    min-height: 44px;
  }

  /* Bottom sheet */
  #sidebar {
    width: 100%;
    height: auto;
    max-height: 70vh;
    top: auto;
    bottom: 0;
    /* Account for iPhone home bar */
    padding-bottom: env(safe-area-inset-bottom, 0px);
    transform: translateY(100%);
    border-radius: 18px 18px 0 0;
    box-shadow: 0 -6px 32px rgba(0, 0, 0, 0.28);
  }

  #sidebar.sidebar--open {
    transform: translateY(0);
  }

  /* Drag handle indicator */
  #sidebar::before {
    content: '';
    display: block;
    width: 40px;
    height: 4px;
    background: #d0d0d0;
    border-radius: 2px;
    margin: 10px auto 0;
    flex-shrink: 0;
  }

  /* Make header slightly more compact on small screens */
  #sidebar-header {
    padding: 12px 16px 10px;
  }

  #sidebar-header h1 {
    font-size: 16px;
  }

  /* Bigger tap targets for category rows */
  .category-label {
    padding: 13px 14px;
    min-height: 48px;
  }

  /* Wider toggle track for fat fingers */
  .toggle-track {
    width: 44px;
    height: 24px;
    border-radius: 12px;
  }

  .toggle-thumb {
    width: 18px;
    height: 18px;
  }

  .category-toggle:checked + .toggle-track .toggle-thumb {
    transform: translateX(20px);
  }

  /* Backdrop: semi-transparent overlay behind the sheet */
  #sidebar-backdrop {
    display: block;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0);
    z-index: 999;
    pointer-events: none;
    transition: background 0.3s ease;
  }

  #sidebar-backdrop.active {
    background: rgba(0, 0, 0, 0.45);
    pointer-events: auto;
  }

  /* Popups: fit narrow screens */
  .popup-content {
    min-width: 0;
    max-width: calc(100vw - 40px);
  }

  /* Error toast: sit above the home bar */
  #error-toast {
    bottom: calc(12px + env(safe-area-inset-bottom, 0px));
    flex-wrap: wrap;
    gap: 8px;
  }

  /* Leaflet zoom control: move down slightly so it's under the hamburger */
  .leaflet-top.leaflet-left .leaflet-control-zoom {
    margin-top: 66px;
    margin-left: 12px;
  }
}

/* ── Locate button ────────────────────────────────────────────────────────── */
.locate-btn {
  background: #fff !important;
  border: none !important;
  font-size: 19px;
  cursor: pointer;
  padding: 6px 9px !important;
  line-height: 1;
  box-shadow: 0 1px 5px rgba(0,0,0,0.3) !important;
}

.locate-btn:hover {
  background: #f5f5f5 !important;
}

/* ── Markers ──────────────────────────────────────────────────────────────── */
.marker-dot {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 15px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.35);
  border: 2.5px solid rgba(255, 255, 255, 0.92);
  line-height: 1;
}

.marker-icon {
  display: block;
  line-height: 1;
}

/* Custom cluster bubbles */
.cluster-dot {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-size: 12px;
  font-weight: 700;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.35);
  border: 2.5px solid rgba(255, 255, 255, 0.9);
}

/* User location dot */
.location-dot {
  width: 16px;
  height: 16px;
  background: #2196f3;
  border: 3px solid #fff;
  border-radius: 50%;
  box-shadow: 0 0 10px rgba(33, 150, 243, 0.7);
}

/* ── Popup styles ─────────────────────────────────────────────────────────── */
.prague-popup .leaflet-popup-content-wrapper {
  border-radius: 10px;
  padding: 0;
  overflow: hidden;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.18);
}

.prague-popup .leaflet-popup-content {
  margin: 0;
  width: auto !important;
}

.popup-content {
  font-family: system-ui, -apple-system, 'Segoe UI', sans-serif;
  font-size: 13px;
  min-width: 210px;
  max-width: 280px;
}

.popup-header {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  padding: 11px 13px 10px;
  border-left: 4px solid #ccc;
  background: #fafafa;
  border-bottom: 1px solid #f0f0f0;
}

.popup-icon {
  font-size: 19px;
  flex-shrink: 0;
  line-height: 1.2;
  margin-top: 1px;
}

.popup-name {
  font-size: 14px;
  font-weight: 600;
  word-break: break-word;
  line-height: 1.3;
  color: #1a1a1a;
}

.popup-warning {
  background: #fff8e1;
  border-left: 3px solid #ffc107;
  padding: 9px 13px;
  font-size: 12px;
  color: #4e342e;
  line-height: 1.5;
  border-bottom: 1px solid #ffe082;
}

.popup-warning-list {
  padding: 6px 0 2px;
}

.popup-warning-item {
  padding: 4px 13px;
  line-height: 1.5;
  font-size: 12.5px;
  color: #333;
  border-bottom: 1px solid #f9f9f9;
}

.popup-warning-item:last-child {
  border-bottom: none;
}

.popup-row {
  padding: 5px 13px;
  line-height: 1.5;
  word-break: break-word;
  border-bottom: 1px solid #f7f7f7;
}

.popup-row:last-child {
  border-bottom: none;
}

.popup-row a {
  color: #1a237e;
  text-decoration: none;
}

.popup-row a:hover {
  text-decoration: underline;
}

.popup-hours {
  font-size: 12px;
  color: #555;
}

.popup-muted {
  color: #9e9e9e;
  font-style: italic;
  font-size: 12px;
  padding-bottom: 8px;
}

/* ── Loading overlay ──────────────────────────────────────────────────────── */
#loading-overlay {
  position: fixed;
  inset: 0;
  background: rgba(21, 28, 85, 0.88);
  z-index: 9999;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 14px;
  color: #fff;
  font-size: 16px;
  font-weight: 500;
}

#loading-overlay.hidden {
  display: none;
}

.loading-sub {
  font-size: 12px;
  opacity: 0.65;
  font-weight: 400;
}

.spinner {
  width: 50px;
  height: 50px;
  border: 4px solid rgba(255, 255, 255, 0.25);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

/* ── Error toast ──────────────────────────────────────────────────────────── */
#error-toast {
  position: fixed;
  bottom: 22px;
  left: 50%;
  transform: translateX(-50%);
  background: #b71c1c;
  color: #fff;
  padding: 12px 16px;
  border-radius: 8px;
  z-index: 9998;
  display: flex;
  align-items: center;
  gap: 10px;
  box-shadow: 0 4px 18px rgba(0, 0, 0, 0.3);
  max-width: 440px;
  width: calc(100% - 32px);
  font-size: 13px;
}

#error-toast.hidden {
  display: none;
}

#error-message {
  flex: 1;
  line-height: 1.4;
}

#retry-btn,
#dismiss-btn {
  padding: 5px 12px;
  border: 1px solid rgba(255, 255, 255, 0.45);
  background: transparent;
  color: #fff;
  border-radius: 5px;
  cursor: pointer;
  font-size: 12px;
  font-weight: 500;
  white-space: nowrap;
  flex-shrink: 0;
  transition: background 0.15s;
}

#retry-btn:hover,
#dismiss-btn:hover {
  background: rgba(255, 255, 255, 0.18);
}

/* ── Route panel ──────────────────────────────────────────────────────────── */
#route-panel {
  position: fixed;
  z-index: 1000;
  background: #fff;
  border-radius: 14px;
  box-shadow: 0 4px 28px rgba(0, 0, 0, 0.22);
  overflow: hidden;
  /* Desktop default: bottom-right corner of map */
  bottom: 36px;
  right: 20px;
  width: 300px;
}

#route-panel.hidden {
  display: none;
}

#route-panel-header {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 11px 12px 10px;
  background: linear-gradient(135deg, #1565C0, #1976D2);
  color: #fff;
}

#route-header-info {
  flex: 1;
  min-width: 0;
}

#route-label {
  display: block;
  font-size: 10px;
  opacity: 0.8;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 1px;
}

#route-dest-name {
  display: block;
  font-size: 14px;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

#route-close-btn {
  background: rgba(255, 255, 255, 0.2);
  border: none;
  color: #fff;
  width: 28px;
  height: 28px;
  min-width: 28px;
  border-radius: 50%;
  cursor: pointer;
  font-size: 13px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s;
  padding: 0;
}

#route-close-btn:hover {
  background: rgba(255, 255, 255, 0.35);
}

/* Transport mode buttons */
#route-modes {
  display: flex;
  padding: 8px;
  gap: 6px;
  border-bottom: 1px solid #f0f0f0;
  background: #fafafa;
}

.mode-btn {
  flex: 1;
  padding: 7px 4px;
  font-size: 12px;
  font-weight: 500;
  border: 1px solid #e0e0e0;
  background: #fff;
  border-radius: 8px;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s, color 0.15s;
  color: #555;
  white-space: nowrap;
}

.mode-btn:hover {
  background: #e3f2fd;
  border-color: #1565C0;
  color: #1565C0;
}

.mode-btn--active {
  background: #1565C0 !important;
  border-color: #1565C0 !important;
  color: #fff !important;
}

/* Route summary / loading / error rows */
#route-body {
  padding: 0;
}

#route-summary-loading,
#route-summary-data,
#route-summary-error {
  padding: 10px 14px;
  font-size: 13px;
  display: flex;
  align-items: center;
  gap: 8px;
  border-bottom: 1px solid #f5f5f5;
}

#route-summary-loading.hidden,
#route-summary-data.hidden,
#route-summary-error.hidden {
  display: none;
}

#route-summary-data {
  font-size: 16px;
  font-weight: 700;
  color: #212121;
}

.route-sep {
  color: #bdbdbd;
  font-weight: 400;
  font-size: 14px;
}

#route-summary-error {
  color: #c62828;
  font-size: 12px;
  line-height: 1.4;
}

/* Drag-to-start hint */
#route-hint {
  padding: 6px 14px 6px;
  font-size: 11.5px;
  color: #e65100;
  font-style: italic;
  border-bottom: 1px solid #f5f5f5;
}

#route-hint.hidden {
  display: none;
}

/* External navigation links */
#route-external-links {
  padding: 9px 10px;
}

#route-external-links a {
  display: block;
  text-align: center;
  padding: 11px 8px;
  font-size: 13px;
  font-weight: 600;
  color: #fff;
  border: none;
  border-radius: 8px;
  text-decoration: none;
  background: #1565C0;
  transition: background 0.15s;
  white-space: nowrap;
}

#route-external-links a:hover {
  background: #0d47a1;
}

/* Spinning loader inside the route panel */
.route-spinner {
  display: inline-block;
  width: 14px;
  height: 14px;
  border: 2px solid #e0e0e0;
  border-top-color: #1565C0;
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
  flex-shrink: 0;
}

/* Draggable start pin (A marker) */
.start-pin {
  width: 28px;
  height: 28px;
  background: #1565C0;
  border: 2.5px solid #fff;
  border-radius: 50%;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.35);
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-weight: 700;
  font-size: 12px;
  font-family: system-ui, sans-serif;
  cursor: grab;
}

.start-pin:active {
  cursor: grabbing;
}

/* "Get Directions" button at the bottom of every POI popup */
.popup-directions-btn {
  display: block;
  width: 100%;
  padding: 10px 14px;
  background: #1565C0;
  color: #fff;
  border: none;
  cursor: pointer;
  font-size: 13px;
  font-weight: 600;
  text-align: center;
  transition: background 0.15s;
  letter-spacing: 0.2px;
}

.popup-directions-btn:hover {
  background: #1976D2;
}

/* Mobile adjustments for route panel */
@media (max-width: 640px) {
  #route-panel {
    bottom: calc(12px + env(safe-area-inset-bottom, 0px));
    left: 12px;
    right: 12px;
    width: auto;
    border-radius: 14px;
  }

  .mode-btn {
    font-size: 11px;
    padding: 8px 2px;
    min-height: 38px;
  }

  #route-summary-data {
    font-size: 17px;
  }
}



