/* ============================================================
   ROUTE AI — MAP CONTAINER & OVERLAY STYLES
   ============================================================ */

/* --- Map Container --- */
.map-container {
  flex: 1;
  height: 100vh;
  position: relative;
  background: var(--bg-base);
}

.map-container canvas {
  outline: none;
}

/* --- Custom Marker Styles --- */
.custom-marker {
  cursor: pointer;
  animation: markerBounce 0.5s var(--ease-bounce) both;
}

.marker-body {
  width: 36px;
  height: 36px;
  border-radius: 50% 50% 50% 0;
  transform: rotate(-45deg);
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.5);
  position: relative;
}

.marker-body::after {
  content: '';
  position: absolute;
  inset: 4px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.2);
}

.marker-body svg {
  transform: rotate(45deg);
  position: relative;
  z-index: 1;
}

.marker-body.origin {
  background: var(--success);
}

.marker-body.destination {
  background: var(--danger);
}

.marker-pulse {
  position: absolute;
  bottom: -3px;
  left: 50%;
  transform: translateX(-50%);
  width: 12px;
  height: 12px;
  border-radius: 50%;
  animation: ringExpand 2s ease-out infinite;
  pointer-events: none;
}

.marker-pulse.origin-pulse {
  background: rgba(16, 185, 129, 0.15);
}

.marker-pulse.dest-pulse {
  background: rgba(239, 68, 68, 0.3);
}

/* --- Google Maps control polish --- */
.gm-style .gm-style-iw-c {
  background: var(--bg-surface) !important;
  color: var(--text-1) !important;
  border: 1px solid var(--border) !important;
  border-radius: var(--r-lg) !important;
  box-shadow: var(--shadow-lg) !important;
  font-family: 'Inter', sans-serif !important;
}

.gm-style .gm-style-iw-d {
  max-height: min(42dvh, 340px) !important;
  color: var(--text-1) !important;
  overflow-x: hidden !important;
  overflow-y: auto !important;
  overscroll-behavior: contain;
  scrollbar-color: var(--text-3) transparent;
  scrollbar-width: thin;
  touch-action: pan-y;
  -webkit-overflow-scrolling: touch;
}

.gm-style .gm-style-iw-d::-webkit-scrollbar {
  width: 6px;
}

.gm-style .gm-style-iw-d::-webkit-scrollbar-track {
  background: transparent;
}

.gm-style .gm-style-iw-d::-webkit-scrollbar-thumb {
  background: var(--text-3);
  border-radius: var(--r-full);
}

.gm-style .gm-style-iw-tc::after {
  background: var(--bg-surface) !important;
}

.gm-style .gm-ui-hover-effect {
  opacity: 0.8 !important;
}

.gm-style .gm-ui-hover-effect > span {
  background-color: var(--text-2) !important;
}

.gm-style .gm-style-iw-d [style*="color:#475569"],
.gm-style .gm-style-iw-d [style*="color: #475569"],
.gm-style .gm-style-iw-d [style*="color:#64748b"],
.gm-style .gm-style-iw-d [style*="color: #64748b"] {
  color: var(--text-2) !important;
}

.gm-style .gm-control-active {
  border-radius: var(--r-md) !important;
}

/* --- Map Overlay Controls --- */
.map-overlay-controls {
  position: absolute;
  bottom: 5rem;
  right: 1rem;
  z-index: 100;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.map-ctrl-btn {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.5rem 0.875rem;
  background: var(--bg-raised);
  border: 1px solid var(--border-light);
  border-radius: var(--r-md);
  color: var(--text-2);
  font-size: 0.75rem;
  font-weight: 600;
  box-shadow: var(--shadow-md);
  transition: all var(--dur-base) var(--ease);
  white-space: nowrap;
}

.map-ctrl-btn:hover {
  background: var(--glass-strong);
  color: var(--text-1);
  transform: translateX(-2px);
}

.map-ctrl-btn.active,
.map-ctrl-btn[data-active="true"],
.map-ctrl-btn[aria-pressed="true"] {
  background: #2563eb;
  border-color: #3b82f6;
  color: #ffffff;
  box-shadow: 0 4px 14px rgba(37, 99, 235, 0.34);
}

.map-ctrl-btn.active:hover,
.map-ctrl-btn[data-active="true"]:hover,
.map-ctrl-btn[aria-pressed="true"]:hover,
.map-ctrl-btn:active {
  background: #1d4ed8;
  border-color: #60a5fa;
  color: #ffffff;
}

/* --- Route Info Chip --- */
.route-chip {
  position: absolute;
  bottom: 1.5rem;
  left: 50%;
  transform: translateX(-50%);
  z-index: 200;
  display: flex;
  align-items: center;
  gap: 0;
  background: #1e293b;
  border: 1px solid var(--border-light);
  border-radius: var(--r-full);
  box-shadow: var(--shadow-lg);
  overflow: hidden;
  animation: chipSlideUp 0.35s var(--ease-bounce) both;
}

.chip-stat {
  display: flex;
  align-items: center;
  gap: 0.375rem;
  padding: 0.5rem 1rem;
  font-size: 0.8125rem;
  font-weight: 600;
  color: var(--text-1);
}

.chip-emoji {
  font-size: 0.875rem;
}

.chip-divider {
  width: 1px;
  height: 24px;
  background: var(--border);
}

#chip-traffic-wrap {
  color: var(--success);
}

#chip-traffic-wrap.delayed {
  color: var(--warning);
}

#chip-traffic-wrap.heavy {
  color: var(--danger);
}

.route-traffic-marker {
  width: 31px;
  height: 31px;
  border-radius: 50%;
  border: 2px solid #fff;
  background: #f59e0b;
  color: #111827;
  font-size: 1rem;
  font-weight: 900;
  box-shadow: 0 3px 12px rgba(0, 0, 0, 0.48);
  cursor: pointer;
}
.route-traffic-marker.jam { background: #ef4444; color: #fff; }
.route-traffic-marker:focus-visible { outline: 3px solid #60a5fa; outline-offset: 2px; }
.route-traffic-info { color: #172033; font: 13px/1.4 system-ui, sans-serif; }
.route-traffic-info strong { display: block; font-size: 14px; }
.route-traffic-info p { margin: 5px 0; }
.route-traffic-info small { color: #64748b; }

.route-issues-popup {
  position: absolute;
  top: 5.5rem;
  left: calc(var(--map-left) + 1rem);
  z-index: 500;
  width: min(340px, calc(100vw - var(--map-left) - 2rem));
  max-height: min(420px, calc(100dvh - 7rem));
  display: flex;
  flex-direction: column;
  overflow: hidden;
  background: #111827;
  color: #f8fafc;
  border: 1px solid rgba(148, 163, 184, 0.3);
  border-radius: 15px;
  box-shadow: 0 12px 35px rgba(0, 0, 0, 0.5);
}
.route-issues-popup.hidden { display: none; }
.route-issues-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 12px 14px;
  border-bottom: 1px solid rgba(148, 163, 184, 0.16);
}
.route-issues-header strong { font-size: 0.88rem; }
#route-issues-close {
  flex: none;
  width: 32px;
  height: 32px;
  border: 0;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.1);
  color: #fff;
  font-size: 1.2rem;
  cursor: pointer;
}
.route-issues-list { overflow-y: auto; padding: 8px; }
.route-issues-empty { margin: 8px; color: #cbd5e1; font-size: 0.78rem; line-height: 1.4; }
.route-issue-row {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 8px;
  background: transparent;
  color: inherit;
  border: 0;
  border-radius: 8px;
  text-align: left;
  cursor: pointer;
}
.route-issue-row:hover, .route-issue-row:focus-visible { background: rgba(59, 130, 246, 0.22); }
.route-issue-icon { flex: none; font-size: 1.15rem; }
.route-issue-copy { display: flex; flex-direction: column; min-width: 0; }
.route-issue-copy strong { font-size: 0.78rem; }
.route-issue-copy small { color: #94a3b8; font-size: 0.66rem; line-height: 1.35; }
.route-issues-source {
  margin: 0;
  padding: 9px 14px 12px;
  border-top: 1px solid rgba(148, 163, 184, 0.16);
  color: #94a3b8;
  font-size: 0.64rem;
  line-height: 1.35;
}
@media (max-width: 1023px) {
  .route-issues-popup {
    top: 8rem;
    left: 12px;
    width: min(320px, calc(100vw - 90px));
    max-height: calc(100dvh - 10rem);
  }
}
.app-container.is-navigating .route-issues-popup { top: 9rem; }

/* --- Traffic Legend --- */
.traffic-legend {
  position: absolute;
  top: 1rem;
  right: 1rem;
  z-index: 100;
  background: var(--bg-overlay);
  border: 1px solid var(--border-light);
  border-radius: var(--r-lg);
  padding: 0.75rem 1rem;
  box-shadow: var(--shadow-md);
}

.traffic-legend-title {
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-3);
  margin-bottom: 0.5rem;
}

.legend-items {
  display: flex;
  flex-direction: column;
  gap: 0.375rem;
}

.legend-item {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.75rem;
  color: var(--text-2);
}

.legend-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  flex-shrink: 0;
}

.dot-free {
  background: #10b981;
}

.dot-slow {
  background: #f59e0b;
}

.dot-queuing {
  background: #f97316;
}

.dot-static {
  background: #ef4444;
}

/* --- Map Attribution Override --- */
.gm-style-cc {
  background: rgba(10, 15, 29, 0.7) !important;
  color: var(--text-4) !important;
  font-size: 0.65rem !important;
  border-radius: var(--r-sm) !important;
}

.gm-style-cc a {
  color: var(--primary-light) !important;
}

/* --- Cursor states --- */
.map-container.pick-mode {
  cursor: crosshair !important;
}

.map-container.dragging {
  cursor: grabbing !important;
}

/* ── User Location Dot (GPS) ──────────────────────────────── */
.user-location-dot {
  position: relative;
  width: 22px;
  height: 22px;
  cursor: default;
  pointer-events: none;
}

.udot-pulse {
  position: absolute;
  top: 50%;
  left: 50%;
  width: 46px;
  height: 46px;
  transform: translate(-50%, -50%);
  border-radius: 50%;
  background: rgba(37, 99, 235, 0.12);
  border: 1.5px solid rgba(37, 99, 235, 0.3);
  animation: gpsPulse 2.2s ease-out infinite;
  pointer-events: none;
}

.udot-core {
  position: absolute;
  top: 50%;
  left: 50%;
  width: 18px;
  height: 18px;
  transform: translate(-50%, -50%);
  border-radius: 50%;
  background: #2563eb;
  border: 3px solid #ffffff;
  box-shadow:
    0 2px 8px rgba(0, 0, 0, 0.3),
    0 0 0 1px rgba(0, 0, 0, 0.15);
  z-index: 2;
}

@keyframes gpsPulse {
  0% {
    transform: translate(-50%, -50%) scale(0.55);
    opacity: 1;
  }

  70% {
    transform: translate(-50%, -50%) scale(1.65);
    opacity: 0.18;
  }

  100% {
    transform: translate(-50%, -50%) scale(1.65);
    opacity: 0;
  }
}

/* ── Locate / Follow Me button states ────────────────────── */
#locate-btn.follow-active {
  background: #2563eb;
  border-color: #3b82f6;
  color: #ffffff;
  box-shadow: 0 4px 14px rgba(37, 99, 235, 0.34);
  animation: locatePulse 2.5s ease-in-out infinite;
}

@keyframes locatePulse {

  0%,
  100% {
    box-shadow: var(--shadow-md);
  }

  50% {
    box-shadow: var(--shadow-md);
  }
}

/* GPS button next to origin input */
#origin-gps-btn {
  flex-shrink: 0;
}

/* ──────────────────────────────────────────────────────────
   NAVIGATION HUD — styles moved to css/waze-hud.css
   ──────────────────────────────────────────────────────── */

/* Driving avatar — direction indicator */
.user-location-dot .udot-core {
  transition: transform 0.3s ease-out;
}

/* Nav mode — show directional triangle inside the dot */
.user-location-dot.nav-active .udot-core {
  border-radius: 2px;
  clip-path: polygon(50% 0%, 100% 100%, 50% 80%, 0% 100%);
  background: #2563eb;
  width: 26px;
  height: 26px;
  border: none;
  box-shadow: none; /* clip-path hides box-shadow anyway */
}

/* Hide sidebar during nav */
.sidebar {
  transition: margin-left 0.35s cubic-bezier(0.4, 0, 0.2, 1), 
              transform 0.35s cubic-bezier(0.4, 0, 0.2, 1),
              max-height 0.35s cubic-bezier(0.4, 0, 0.2, 1),
              opacity 0.35s cubic-bezier(0.4, 0, 0.2, 1);
}

.sidebar.nav-hidden {
  margin-left: calc(var(--sidebar-w) * -1);
}

/* Responsive navigation visibility is owned by layout.css. */

/* ──────────────────────────────────────────────────────────
   REROUTE OVERLAY (shows during auto-rerouting)
   ──────────────────────────────────────────────────────── */
.nav-reroute-overlay {
  pointer-events: none;
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%) scale(0.9);
  z-index: 650;
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.75rem 1.5rem;
  background: #111827;
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 1.5px solid rgba(255, 255, 255, 0.08);
  border-radius: var(--r-full);
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.5);
  opacity: 0;
  transition: opacity 0.3s ease, transform 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.nav-reroute-overlay.visible {
  opacity: 1;
  transform: translate(-50%, -50%) scale(1);
  animation: reroutePulse 2s ease-in-out infinite;
}

@keyframes reroutePulse {

  0%,
  100% {
    border-color: rgba(255, 255, 255, 0.08);
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.5);
  }

  50% {
    border-color: rgba(255, 255, 255, 0.08);
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.5);
  }
}

.reroute-spinner {
  width: 20px;
  height: 20px;
  border: 2.5px solid rgba(255, 255, 255, 0.08);
  border-top-color: #2563eb;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  flex-shrink: 0;
}

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

.reroute-text {
  font-size: 0.8125rem;
  font-weight: 700;
  color: var(--text-1);
  letter-spacing: 0.01em;
  white-space: nowrap;
}

/* ──────────────────────────────────────────────────────────
   SIDEBAR TOGGLE BUTTON
   ──────────────────────────────────────────────────────── */
.sidebar-toggle-btn {
  position: absolute;
  top: 6rem;
  left: 1rem;
  z-index: 750;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: var(--bg-raised);
  border: 1px solid var(--border-light);
  color: var(--primary-light);
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: var(--shadow-lg);
  cursor: pointer;
  transition: all 0.25s var(--ease);
}

.sidebar-toggle-btn:hover {
  background: var(--glass-strong);
  transform: scale(1.05);
  color: #fff;
  border-color: var(--primary);
}

.sidebar-toggle-btn.nav-expanded {
  /* Arrow points left when sidebar is expanded */
  transform: rotate(180deg);
}

.sidebar-toggle-btn.nav-expanded:hover {
  transform: rotate(180deg) scale(1.05);
}

/* ──────────────────────────────────────────────────────────
   RAIN RADAR CONTROL BAR (RainViewer)
   ──────────────────────────────────────────────────────── */

.radar-control-bar {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 300;
  transform: translateY(100%);
  opacity: 0;
  transition: transform 0.4s cubic-bezier(0.34, 1.56, 0.64, 1),
    opacity 0.3s ease;
  pointer-events: none;
}

.radar-control-bar.visible {
  transform: translateY(0);
  opacity: 1;
  pointer-events: all;
}

.radar-bar-inner {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.625rem 1rem;
  background: var(--bg-surface);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border-top: 1px solid var(--border);
  box-shadow: 0 -4px 28px rgba(0, 0, 0, 0.5);
}

.radar-bar-label {
  display: flex;
  align-items: center;
  gap: 0.375rem;
  flex-shrink: 0;
}

.radar-bar-icon {
  font-size: 1rem;
  animation: radarPulse 3s linear infinite;
}

@keyframes radarPulse {
  0% {
    opacity: 0.6;
  }

  50% {
    opacity: 1;
  }

  100% {
    opacity: 0.6;
  }
}

.radar-bar-title {
  font-size: 0.7rem;
  font-weight: 700;
  color: var(--text-2);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  white-space: nowrap;
}

/* Playback buttons */
.radar-bar-controls {
  display: flex;
  align-items: center;
  gap: 0.25rem;
  flex-shrink: 0;
}

.radar-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 30px;
  height: 30px;
  border-radius: 50%;
  border: 1px solid rgba(255, 255, 255, 0.1);
  background: rgba(255, 255, 255, 0.05);
  color: #94a3b8;
  cursor: pointer;
  transition: all 0.2s ease;
}

.radar-btn:hover {
  background: var(--glass-hover);
  border-color: var(--border);
  color: var(--text-1);
  transform: scale(1.08);
}

.radar-btn.radar-play-btn {
  width: 34px;
  height: 34px;
  background: var(--bg-raised);
  border-color: rgba(37, 99, 235, 0.5);
  color: var(--primary);
}

.radar-btn.radar-play-btn:hover {
  background: var(--glass-hover);
  border-color: rgba(37, 99, 235, 0.5);
  color: var(--text-1);
  transform: scale(1.12);
}

/* ── Timeline area ────────────────────────────────────────── */
.radar-bar-timeline {
  flex: 1;
  display: flex;
  align-items: center;
  gap: 0.4rem;
  min-width: 0;
}

/* Start / End time labels beside the slider */
.radar-time-label {
  font-family: 'Inter', monospace;
  font-size: 0.65rem;
  font-weight: 500;
  color: #64748b;
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
  flex-shrink: 0;
  user-select: none;
}

/* ── Slider wrapper (for positioning the tooltip) ─────────── */
.radar-slider-wrap {
  flex: 1;
  position: relative;
  display: flex;
  align-items: center;
  min-width: 0;
  /* Expand touch target area vertically */
  padding: 8px 0;
  margin: -8px 0;
}

.radar-slider {
  width: 100%;
  -webkit-appearance: none;
  appearance: none;
  height: 5px;
  border-radius: 3px;
  background: #374151;
  outline: none;
  cursor: pointer;
  transition: height 0.15s ease;
}

/* Grow track when hovered or scrubbing */
.radar-slider:hover,
.radar-control-bar.scrubbing .radar-slider {
  height: 7px;
}

.radar-slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: #2563eb;
  border: 2.5px solid rgba(255, 255, 255, 0.6);
  box-shadow: none;
  cursor: grab;
  transition: transform 0.12s ease, box-shadow 0.12s ease;
}

.radar-slider::-webkit-slider-thumb:hover {
  transform: scale(1.25);
  box-shadow: none;
}

.radar-slider:active::-webkit-slider-thumb {
  cursor: grabbing;
  transform: scale(1.35);
  box-shadow: none;
}

.radar-slider::-moz-range-thumb {
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: #2563eb;
  border: 2.5px solid rgba(255, 255, 255, 0.6);
  box-shadow: none;
  cursor: grab;
}

.radar-slider:active::-moz-range-thumb {
  cursor: grabbing;
  transform: scale(1.35);
}

/* ── Scrub tooltip — floats above the thumb while dragging ── */
.radar-scrub-tooltip {
  position: absolute;
  bottom: calc(100% + 6px);
  left: 50%;
  transform: translateX(-50%) translateY(8px);
  padding: 5px 10px;
  background: var(--bg-raised);
  border: 1px solid var(--border);
  border-radius: 8px;
  font-family: 'Inter', monospace;
  font-size: 0.72rem;
  font-weight: 600;
  color: var(--text-1);
  text-align: center;
  line-height: 1.4;
  white-space: nowrap;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.18s ease, transform 0.18s ease;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.5);
  z-index: 10;
}

.radar-scrub-tooltip::after {
  content: '';
  position: absolute;
  top: 100%;
  left: 50%;
  transform: translateX(-50%);
  border-width: 5px;
  border-style: solid;
  border-color: var(--bg-raised) transparent transparent transparent;
}

/* Show tooltip when scrubbing */
.radar-control-bar.scrubbing .radar-scrub-tooltip {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

/* Also show on slider hover for quick peek */
.radar-slider-wrap:hover .radar-scrub-tooltip {
  opacity: 0.85;
  transform: translateX(-50%) translateY(0);
}

/* ── Timestamp box (prominent current time display) ────────── */
.radar-bar-timestamp {
  display: flex;
  align-items: center;
  gap: 0.375rem;
  flex-shrink: 0;
  padding: 0.25rem 0.625rem;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 6px;
}

.radar-ts-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #10b981;
  box-shadow: none;
  flex-shrink: 0;
  transition: background 0.3s ease, box-shadow 0.3s ease;
}

.radar-bar-timestamp #radar-timestamp {
  font-family: 'Inter', monospace;
  font-size: 0.75rem;
  font-weight: 700;
  color: var(--text-1);
  white-space: nowrap;
  letter-spacing: 0.02em;
  font-variant-numeric: tabular-nums;
}

/* Source badge */
.radar-bar-source {
  flex-shrink: 0;
  font-size: 0.6rem;
  color: var(--text-3);
  white-space: nowrap;
}

/* ── Scrubbing state: glow the bar border ─────────────────── */
.radar-control-bar.scrubbing .radar-bar-inner {
  border-top-color: var(--border);
  box-shadow: 0 -4px 28px rgba(0, 0, 0, 0.5);
}

/* ── Radar bar responsiveness ─────────────────────────────── */
@media (max-width: 640px) {
  .radar-bar-inner {
    flex-wrap: wrap;
    gap: 0.5rem;
    padding: 0.5rem 0.75rem;
  }

  .radar-bar-label {
    order: 1;
    flex-basis: auto;
  }

  .radar-bar-timestamp {
    order: 2;
    margin-left: auto;
  }

  .radar-bar-source {
    display: none;
  }

  .radar-bar-controls {
    order: 3;
  }

  .radar-bar-timeline {
    order: 4;
    flex-basis: 100%;
  }
}
