/* Basic layout */
* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; font-family: system-ui, -apple-system, Segoe UI, Roboto, Helvetica, Arial, "Apple Color Emoji", "Segoe UI Emoji"; }

header { padding: 12px 16px; border-bottom: 1px solid #e5e7eb; }
header h1 { margin: 0; font-size: 18px; }

main { display: flex; height: 100%; }

.sidebar { width: 340px; border-right: 1px solid #e5e7eb; padding: 12px; overflow-y: auto; }
.rightbar { width: 360px; border-left: 1px solid #e5e7eb; padding: 12px; overflow-y: auto; }

#map { flex: 1; height: 100%; }
.panel { margin-bottom: 16px; }
.panel h2 { font-size: 16px; margin: 0 0 8px; margin-top: 24px;}
.label { display: block; font-size: 12px; color: #374151; }
input, select { width: 100%; padding: 8px; margin: 6px 0 12px; border: 1px solid #d1d5db; border-radius: 6px; }
.actions { display: flex; gap: 8px; }
button { padding: 8px 12px; border-radius: 6px; border: 1px solid #d1d5db; background: #fff; cursor: pointer; }
button.primary { background: #2563eb; color: #fff; border-color: #1d4ed8; }
button:disabled { opacity: 0.6; cursor: not-allowed; }
.note { font-size: 12px; color: #6b7280; }

#map { flex: 1; height: 100%; }

/* Results */
#summary { margin-bottom: 8px; font-size: 14px; color: #111827; }
#orderList { margin: 0; padding-left: 0; list-style: none; }
/* Google Maps-like timeline for results */
.gm-summary-card { display: flex; align-items: center; gap: 8px; padding: 10px 12px; border: 1px solid #e5e7eb; border-radius: 10px; background: #ffffff; box-shadow: 0 1px 2px rgba(0,0,0,0.04); }
.gm-summary-title { font-weight: 700; color: #111827; }
.gm-summary-duration { font-weight: 700; color: #111827; }
.gm-summary-mode { color: #6b7280; }
.gm-timeline { margin: 0; padding-left: 0; }
.gm-step { display: grid; grid-template-columns: 24px 1fr; gap: 8px; align-items: start; padding: 8px 0; }
.gm-rail { position: relative; width: 24px; display: flex; justify-content: center; }
.gm-rail::after { content: ""; position: absolute; top: 0; bottom: 0; left: 50%; width: 2px; transform: translateX(-50%); background: #e5e7eb; }
.gm-dot { width: 10px; height: 10px; border-radius: 50%; background: #22c55e; border: 2px solid #dcfce7; position: relative; z-index: 1; margin-top: 6px; }
.gm-card { padding: 10px 12px; border: 1px solid #e5e7eb; border-radius: 10px; background: #ffffff; box-shadow: 0 1px 2px rgba(0,0,0,0.04); }
.gm-title { font-size: 14px; font-weight: 700; color: #111827; margin-bottom: 4px; }
.gm-meta { font-size: 12px; color: #6b7280; display: flex; gap: 8px; }
.gm-step:hover .gm-card { border-color: #22c55e; box-shadow: 0 2px 6px rgba(34,197,94,0.1); }
.gm-step:hover .gm-dot { background: #16a34a; }
#orderList li { margin-bottom: 6px; }
#hotspotList { display: flex; flex-direction: column; gap: 8px; }
.gm-simple { margin: 0; padding-left: 0; }
.gm-row { display: grid; grid-template-columns: 1fr; gap: 4px; padding: 8px 0; border-bottom: 1px dashed #e5e7eb; }
.gm-line { font-size: 14px; color: #111827; }
.gm-arrowline { font-size: 12px; color: #374151; }
.gm-duration { font-weight: 700; color: #2563eb; }
.hotspot-item { display: flex; }
.hotspot-card { flex: 1; padding: 8px 10px; border: 1px solid #e5e7eb; border-radius: 8px; background: #ffffff; color: #111827; cursor: pointer; user-select: none; box-shadow: 0 1px 2px rgba(0,0,0,0.04); transition: background-color 0.15s ease, border-color 0.15s ease, box-shadow 0.15s ease, color 0.15s ease; }
.hotspot-card:hover { background: #f9fafb; }
.hotspot-card.selected { border-color: #22c55e; background: #dcfce7; color: #166534; box-shadow: 0 2px 4px rgba(34,197,94,0.15); }
.hotspot-card:focus { outline: 2px solid #93c5fd; outline-offset: 2px; }
.hotspot-item input[type="checkbox"] { margin: 2px 0 0; }
.hotspot-item label { flex: 1; white-space: normal; word-break: break-word; overflow: visible; text-overflow: clip; color: #111827; }
/* Segment tooltip styles */
.seg-tooltip { font-size: 12px; font-weight: 700; font-variant-numeric: tabular-nums; color: #111827; }
.seg-tooltip .leaflet-tooltip-content { padding: 4px 8px; border-radius: 6px; background: rgba(255, 255, 255, 0.95); box-shadow: 0 2px 6px rgba(0,0,0,0.2); border: 1px solid rgba(17,24,39,0.15); line-height: 1; color: #111827; }
.seg-tooltip.alt .leaflet-tooltip-content { opacity: 0.95; background: rgba(255, 255, 255, 0.9); border-color: rgba(17,24,39,0.12); color: #111827; }
/* Ensure container bubble itself is green-themed (override Leaflet defaults) */
.leaflet-tooltip.seg-tooltip { color: #111827; background: rgba(255, 255, 255, 0.95); border: 1px solid rgba(17,24,39,0.15); box-shadow: 0 2px 6px rgba(0,0,0,0.2); }
.leaflet-tooltip.seg-tooltip.alt { color: #111827; background: rgba(255, 255, 255, 0.95); border: 1px solid rgba(17,24,39,0.15); box-shadow: 0 2px 6px rgba(0,0,0,0.2); }
/* Match tooltip arrow color with green background */
.leaflet-tooltip-top.seg-tooltip::before,
.leaflet-tooltip-top.seg-tooltip.alt::before { border-top-color: rgba(255, 255, 255, 0.95) !important; }
/* Ensure tooltips don't block hover events over markers or lines */
.seg-tooltip { pointer-events: none; }
.gm-arrow { display: inline-block; color: #16a34a; font-weight: 700; animation: gm-arrow-down 2s ease-in-out infinite; margin-right: 6px; }
@keyframes gm-arrow-down { 0% { transform: translateY(-2px); opacity: 0.8; } 50% { transform: translateY(2px); opacity: 1; } 100% { transform: translateY(-2px); opacity: 0.8; } }

/* Smooth transitions for alt lines on hover highlight */
.gm-altline { transition: stroke 0.15s ease, stroke-width 0.15s ease, opacity 0.15s ease; }
/* Pop effect: subtle drop shadow when highlighted */
.gm-altline-pop {
  filter: drop-shadow(0 0 2px rgba(34,197,94,0.65)) drop-shadow(0 1px 0 rgba(0,0,0,0.2));
}
/* Highlighted alt tooltip content style */
.seg-tooltip.alt.highlight .leaflet-tooltip-content {
  color: #166534; /* deep green text */
  background: rgba(220, 252, 231, 0.95); /* green-tint background */
  border-color: #22c55e;
  border-width: 2px;
  box-shadow: 0 2px 8px rgba(34,197,94,0.25), 0 0 0 2px rgba(34,197,94,0.25);
}
/* Container-level highlight (ensures bubble itself turns green and bold) */
.leaflet-tooltip.seg-tooltip.highlight {
  color: #166534 !important;
  background: rgba(220, 252, 231, 0.95) !important;
  border-color: #22c55e !important;
  border-width: 2px !important;
  box-shadow: 0 2px 8px rgba(34,197,94,0.25), 0 0 0 2px rgba(34,197,94,0.25) !important;
}
.leaflet-tooltip-top.seg-tooltip.highlight::before { border-top-color: rgba(220, 252, 231, 0.95) !important; }
/* Highlighted tooltip content style (applies to main route too) */
.seg-tooltip.highlight .leaflet-tooltip-content {
  color: #166534;
  background: rgba(220, 252, 231, 0.95);
  border-color: #22c55e;
  border-width: 2px;
  box-shadow: 0 2px 8px rgba(34,197,94,0.25), 0 0 0 2px rgba(34,197,94,0.25);
}
/* Fallback: when content element itself has highlight */
.leaflet-tooltip-content.highlight {
  color: #166534;
  background: rgba(220, 252, 231, 0.95);
  border: 2px solid #22c55e;
  box-shadow: 0 2px 8px rgba(34,197,94,0.25), 0 0 0 2px rgba(34,197,94,0.25);
}
/* Results timeline (Option A - Google Maps-like) */
.gm-simple {
  list-style: none;
  margin: 0;
  padding: 0 0 0 28px; /* space for timeline */
  position: relative;
}
.gm-simple::before {
  content: "";
  position: absolute;
  top: 0;
  bottom: 0;
  left: 12px;
  width: 2px;
  background: rgba(26, 115, 232, 0.15); /* light blue guideline */
}

.gm-row {
  margin: 0 0 10px 0;
}

.gm-line {
  position: relative;
  padding-left: 4px;
  font-weight: 600;
  color: #202124; /* near-black text */
}
.gm-line::before {
  content: "";
  position: absolute;
  left: -16px; /* align with guideline */
  top: 50%;
  transform: translateY(-50%);
  width: 10px;
  height: 10px;
  background: #fff; /* inner dot */
  border: 2px solid #1a73e8; /* primary blue ring */
  border-radius: 50%;
  box-shadow: 0 0 0 4px rgba(26, 115, 232, 0.12); /* soft outer ring for double-border feel */
}

.gm-arrowline {
  position: relative;
  padding-left: 4px;
  color: #5f6368; /* secondary text */
  margin: 4px 0 8px;
}
.gm-arrowline::before {
  content: "";
  position: absolute;
  left: 12px; /* align to guideline */
  top: -4px; /* extend above to look longer */
  width: 2px;
  height: 28px; /* longer connector */
  background: rgba(26, 115, 232, 0.35); /* stronger blue for connectors */
  border-radius: 2px;
}
/* Minimalist segment line (no arrows, no blue shapes) */
.gm-segline { font-size: 12px; color: #6b7280; margin: 2px 0 4px; }
.gm-duration {
  display: inline-block;
  margin-left: 0;
  padding: 2px 8px;
  border-radius: 999px;
  background: #f3f4f6; /* neutral grey */
  border: 1px solid #e5e7eb;
  color: #111827;
  font-weight: 600;
}
/* Remove old arrow styles if any remain */
.gm-arrowline { display: none; }
/* Remove timeline dots and blue guideline */
.gm-simple::before { display: none !important; }
.gm-line::before { display: none !important; }
.gm-duration { font-weight: 700; color: #2563eb; }
.hotspot-item { display: flex; }
.hotspot-card { flex: 1; padding: 8px 10px; border: 1px solid #e5e7eb; border-radius: 8px; background: #ffffff; color: #111827; cursor: pointer; user-select: none; box-shadow: 0 1px 2px rgba(0,0,0,0.04); transition: background-color 0.15s ease, border-color 0.15s ease, box-shadow 0.15s ease, color 0.15s ease; }
.hotspot-card:hover { background: #f9fafb; }
.hotspot-card.selected { border-color: #22c55e; background: #dcfce7; color: #166534; box-shadow: 0 2px 4px rgba(34,197,94,0.15); }
.hotspot-card:focus { outline: 2px solid #93c5fd; outline-offset: 2px; }
.hotspot-item input[type="checkbox"] { margin: 2px 0 0; }
.hotspot-item label { flex: 1; white-space: normal; word-break: break-word; overflow: visible; text-overflow: clip; color: #111827; }
/* Segment tooltip styles */
.seg-tooltip { font-size: 12px; font-weight: 700; font-variant-numeric: tabular-nums; color: #111827; }
.seg-tooltip .leaflet-tooltip-content { padding: 4px 8px; border-radius: 6px; background: rgba(255, 255, 255, 0.95); box-shadow: 0 2px 6px rgba(0,0,0,0.2); border: 1px solid rgba(17,24,39,0.15); line-height: 1; color: #111827; }
.seg-tooltip.alt .leaflet-tooltip-content { opacity: 0.95; background: rgba(255, 255, 255, 0.9); border-color: rgba(17,24,39,0.12); color: #111827; }
/* Ensure container bubble itself is green-themed (override Leaflet defaults) */
.leaflet-tooltip.seg-tooltip { color: #111827; background: rgba(255, 255, 255, 0.95); border: 1px solid rgba(17,24,39,0.15); box-shadow: 0 2px 6px rgba(0,0,0,0.2); }
.leaflet-tooltip.seg-tooltip.alt { color: #111827; background: rgba(255, 255, 255, 0.95); border: 1px solid rgba(17,24,39,0.15); box-shadow: 0 2px 6px rgba(0,0,0,0.2); }
/* Match tooltip arrow color with green background */
.leaflet-tooltip-top.seg-tooltip::before,
.leaflet-tooltip-top.seg-tooltip.alt::before { border-top-color: rgba(255, 255, 255, 0.95) !important; }
/* Ensure tooltips don't block hover events over markers or lines */
.seg-tooltip { pointer-events: none; }
.gm-arrow { display: inline-block; color: #16a34a; font-weight: 700; animation: gm-arrow-down 2s ease-in-out infinite; margin-right: 6px; }
@keyframes gm-arrow-down { 0% { transform: translateY(-2px); opacity: 0.8; } 50% { transform: translateY(2px); opacity: 1; } 100% { transform: translateY(-2px); opacity: 0.8; } }
.hidden { display: none !important; }
/* Floating bottom-right controls */
.floating-controls {
  position: fixed;
  right: 20px;
  bottom: 32px;
  z-index: 1000;
  display: grid;
  gap: 10px;
  padding: 10px 12px;
  border: 1px solid #e5e7eb;
  border-radius: 12px;
  background: #ffffff;
  box-shadow: 0 6px 24px rgba(0,0,0,0.12);
}
.toggle-item { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.toggle-label { font-size: 12px; color: #111827; }
/* Switch UI */
.switch { position: relative; display: inline-block; width: 44px; height: 24px; }
.switch input { opacity: 0; width: 0; height: 0; }
.slider { position: absolute; cursor: pointer; top: 0; left: 0; right: 0; bottom: 0; background: #e5e7eb; transition: 0.2s; border-radius: 999px; }
.slider::before { content: ""; position: absolute; height: 18px; width: 18px; left: 3px; top: 3px; background: #ffffff; border: 1px solid #d1d5db; border-radius: 999px; box-shadow: 0 1px 2px rgba(0,0,0,0.08); transition: 0.2s; }
.switch input:checked + .slider { background: #22c55e; }
.switch input:checked + .slider::before { transform: translateX(20px); border-color: #22c55e; }
/* Minor spacing for Start/End */
#hotspotsPanel .label { margin-top: 8px; display: block; font-size: 12px; color: #6b7280; }
#hotspotsPanel select { width: 100%; margin-bottom: 8px; }
#endSelect { margin-bottom: 12px; }
.gm-simple { padding-left: 0; }
.gm-simple::before { display: none; }
.gm-line::before { display: none; }
.gm-line { font-weight: 600; color: #202124; padding: 6px 0; }
.gm-row { border-bottom: 1px dashed #e5e7eb; padding: 6px 0; }

/* Cleaner arrow line using CSS only */
.gm-arrowline { position: relative; color: #5f6368; padding-left: 0; margin: 2px 0 6px; }
.gm-arrowline::before {
  content: "";
  position: relative;
  display: inline-block;
  width: 10px;
  height: 10px;
  margin-right: 6px;
  border-left: 2px solid #9aa0a6; /* neutral grey connector */
  border-bottom: 2px solid #9aa0a6; /* arrow head */
  transform: rotate(-45deg) translateY(1px);
}
.gm-duration {
  display: inline-block;
  margin-left: 0;
  padding: 2px 8px;
  border-radius: 999px;
  background: #f3f4f6; /* neutral grey */
  border: 1px solid #e5e7eb;
  color: #111827;
  font-weight: 600;
}

/* Summary card subtler look inside floating card */
.gm-summary-card {
  margin-top: 8px;
  padding: 8px 10px;
  border-radius: 10px;
  border: 1px solid #e5e7eb;
  background: #f9fafb;
  color: #111827;
  box-shadow: none;
}
.gm-summary-mode { color: #6b7280; }
/* Topbar for mobile */
.topbar { position: sticky; top: 0; z-index: 1001; display: none; align-items: center; gap: 8px; padding: 10px 12px; border-bottom: 1px solid #e5e7eb; background: #ffffff; }
.topbar .spacer { flex: 1; }
.icon-btn { padding: 8px 12px; border-radius: 8px; border: 1px solid #d1d5db; background: #fff; cursor: pointer; }
.icon-btn:focus { outline: 2px solid #93c5fd; outline-offset: 2px; }

/* Mobile header Compute button: light green theme */
#headerCompute {
  background: #dcfce7; /* light green tint */
  border-color: #86efac; /* soft green border */
  color: #166534; /* deep green text */
}
#headerCompute:hover {
  background: #bbf7d0; /* slightly stronger green on hover */
  border-color: #22c55e;
}

/* Mobile drawer & bottom sheet */
@media (max-width: 768px) {
  .topbar { display: flex; }
  main { position: relative; }
  .sidebar { position: fixed; left: 0; top: 52px; bottom: 0; width: 86vw; max-width: 360px; transform: translateX(-100%); transition: transform 0.25s ease; background: #fff; box-shadow: 0 8px 24px rgba(0,0,0,0.12); z-index: 1000; }
  .sidebar.open { transform: translateX(0); }
  .rightbar { position: fixed; right: 0; top: 52px; bottom: 0; width: 86vw; max-width: 360px; transform: translateX(100%); transition: transform 0.25s ease; padding: 12px; border-left: 1px solid #e5e7eb; border-right: none; border-top: none; background: #fff; z-index: 1000; }
  .rightbar.open { transform: translateX(0); }
  #map { height: calc(100% - 52px); }
}

/* Overlay to close panels */
.overlay { position: fixed; inset: 0; background: rgba(0,0,0,0.25); z-index: 900; display: none; }
.overlay.show { display: block; }

/* Mobile-only compute button on map */
.map-fab { position: fixed; right: 16px; bottom: 92px; z-index: 1001; display: none; padding: 10px 14px; border-radius: 999px; border: 1px solid #15803d; background: #22c55e; color: #ffffff; box-shadow: 0 8px 24px rgba(0,0,0,0.25); }
.map-fab:active { transform: translateY(1px); }
@media (max-width: 768px) {
  .map-fab { display: inline-flex; align-items: center; gap: 8px; }
}