/* css/ui-refresh.css — additive UI refresh for MapTheTrip v43
   Loaded AFTER style.css. Overrides only the chrome (toolbar, buttons,
   dialogs, status chip, version footer). Does NOT touch JS-toggled
   `display` of dialogs (managers set inline display:block/none, which
   wins over stylesheet rules). */

:root {
  --mtt-blue: #1a73e8;
  --mtt-blue-dark: #1558b0;
  --mtt-blue-soft: #e8f0fe;
  --mtt-green: #1e8e3e;
  --mtt-green-soft: #e6f4ea;
  --mtt-amber: #b26500;
  --mtt-amber-soft: #fef7e0;
  --mtt-ink: #202124;
  --mtt-muted: #5f6368;
  --mtt-line: #dadce0;
  --mtt-bg: #ffffff;
  --mtt-shadow: 0 1px 3px rgba(60,64,67,.18), 0 2px 8px rgba(60,64,67,.10);
  --mtt-radius: 10px;
}

/* ---------- Version badge -> discreet footer ---------- */
#mtt-version.app-version {
  position: fixed;
  bottom: 6px;
  right: 10px;
  z-index: 20;
  font: 11px/1 system-ui, -apple-system, Segoe UI, Roboto, Arial, sans-serif;
  color: rgba(0,0,0,.45);
  background: transparent;
  padding: 0;
  pointer-events: none;
}

/* ---------- Top toolbar ---------- */
.toolbar {
  top: 8px !important;
  left: 8px !important;
  right: auto;
  max-width: calc(100vw - 16px) !important;
  padding: 6px 8px !important;
  gap: 6px !important;
  border-radius: var(--mtt-radius) !important;
  box-shadow: var(--mtt-shadow) !important;
  border: 1px solid var(--mtt-line);
  font-family: system-ui, -apple-system, Segoe UI, Roboto, Arial, sans-serif;
  background: rgba(255,255,255,.98) !important;
  align-items: center;
}

/* Group sections visually with subtle dividers */
.toolbar .toolbar-section {
  gap: 4px;
  align-items: center;
  padding: 0 6px;
  position: relative;
}
.toolbar .toolbar-section + .toolbar-section::before {
  content: "";
  position: absolute;
  left: -3px;
  top: 50%;
  transform: translateY(-50%);
  width: 1px;
  height: 22px;
  background: var(--mtt-line);
}
.toolbar .autocomplete-section { padding-left: 2px; }
.toolbar .autocomplete-section::before { display: none; }

/* Search */
.toolbar .autocomplete-container { width: 230px; }
.toolbar #searchInput {
  padding: 7px 10px !important;
  font-size: 13px !important;
  border: 1px solid var(--mtt-line) !important;
  border-radius: 8px !important;
  height: 34px;
  box-sizing: border-box;
}
.toolbar #searchInput:focus {
  outline: none;
  border-color: var(--mtt-blue) !important;
  box-shadow: 0 0 0 3px rgba(26,115,232,.16) !important;
}
.toolbar .google-attribution { font-size: 9px; margin-top: 1px; }

/* ---------- Buttons: unified modern style ---------- */
.toolbar button,
.toolbar select {
  height: 34px;
  box-sizing: border-box;
  padding: 0 12px !important;
  font-size: 12.5px !important;
  font-weight: 600;
  font-family: inherit;
  border-radius: 8px !important;
  border: 1px solid transparent !important;
  cursor: pointer;
  transition: background .12s ease, box-shadow .12s ease, transform .05s ease;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
  white-space: nowrap;
  line-height: 1;
}
.toolbar button:active { transform: translateY(1px); }
.toolbar button:focus-visible,
.toolbar select:focus-visible {
  outline: 2px solid var(--mtt-blue);
  outline-offset: 1px;
}

/* Route buttons — clean blue */
.toolbar-section.route-controls button {
  background: var(--mtt-blue) !important;
  color: #fff !important;
}
.toolbar-section.route-controls button:hover {
  background: var(--mtt-blue-dark) !important;
}
/* Primary "Draw Route" — emphasized */
.toolbar button#startRouteBtn.primary-route-btn {
  background: var(--mtt-blue) !important;
  box-shadow: 0 1px 2px rgba(26,115,232,.4), 0 0 0 1px rgba(26,115,232,.2);
  min-width: 104px;
}
.toolbar button#startRouteBtn.primary-route-btn:hover {
  background: var(--mtt-blue-dark) !important;
}
/* Active (drawing) state — inverted */
.toolbar button#startRouteBtn.active {
  background: #fff !important;
  color: var(--mtt-blue) !important;
  border-color: var(--mtt-blue) !important;
  box-shadow: 0 0 0 2px rgba(26,115,232,.25) inset;
}

/* Secondary route actions (Save/Clear/Follow Roads/Trip Summary) */
.toolbar-section.route-controls button#saveRouteBtn,
.toolbar-section.route-controls button#clearRouteBtn,
.toolbar-section.route-controls button#roadRouteBtn,
.toolbar-section.route-controls button#showMilesBtn {
  background: var(--mtt-blue-soft) !important;
  color: var(--mtt-blue-dark) !important;
}
.toolbar-section.route-controls button#saveRouteBtn:hover,
.toolbar-section.route-controls button#clearRouteBtn:hover,
.toolbar-section.route-controls button#roadRouteBtn:hover,
.toolbar-section.route-controls button#showMilesBtn:hover {
  background: #d6e4fd !important;
}
.toolbar-section.route-controls button#clearRouteBtn {
  background: #fbe9e9 !important;
  color: #b3261e !important;
}
.toolbar-section.route-controls button#clearRouteBtn:hover {
  background: #f6d4d2 !important;
}

/* My Routes — outlined */
.toolbar-section.route-controls button#showRoutesBtn {
  background: #fff !important;
  color: var(--mtt-blue-dark) !important;
  border-color: var(--mtt-line) !important;
}
.toolbar-section.route-controls button#showRoutesBtn:hover {
  background: #f5f7fa !important;
}

/* Places — green */
.toolbar-section.places-controls button {
  background: var(--mtt-green) !important;
  color: #fff !important;
}
.toolbar-section.places-controls button:hover { background: #176b30 !important; }

/* Photos — amber (was harsh yellow; softer now) */
.toolbar-section.photos-controls button {
  background: var(--mtt-amber) !important;
  color: #fff !important;
}
.toolbar-section.photos-controls button:hover { background: #8a4f00 !important; }

/* Basemap + Street view group */
.toolbar .basemap-label {
  font-weight: 600;
  font-size: 12px;
  color: var(--mtt-muted);
  margin-right: 2px;
}
.toolbar #basemapSelect {
  background: #fff !important;
  color: var(--mtt-ink) !important;
  border-color: var(--mtt-line) !important;
  padding: 0 8px !important;
  cursor: pointer;
}
.toolbar #basemapSelect:hover { background: #f5f7fa !important; }
.toolbar .streetview-button {
  background: #fff !important;
  border: 1px solid var(--mtt-line) !important;
  border-radius: 8px !important;
  padding: 0 10px !important;
  height: 34px;
  margin-left: 0 !important;
}
.toolbar .streetview-button svg { width: 18px; height: 18px; fill: var(--mtt-muted); }
.toolbar .streetview-button:hover { background: #f5f7fa !important; }
.toolbar .streetview-button:hover svg { fill: var(--mtt-blue); }
.toolbar .streetview-label { font-size: 12px; color: var(--mtt-ink); font-weight: 600; }

/* ---------- Route status chip (always visible) ---------- */
.route-status {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin-left: 4px;
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 11.5px;
  font-weight: 600;
  background: #f1f3f4;
  color: var(--mtt-muted);
  white-space: nowrap;
  border: 1px solid transparent;
}
.route-status::before {
  content: "";
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: currentColor;
  display: inline-block;
}
.route-status.status-drawing {
  background: var(--mtt-blue-soft);
  color: var(--mtt-blue-dark);
}
.route-status.status-loaded {
  background: var(--mtt-green-soft);
  color: #176b30;
}
.route-status.status-roaded {
  background: var(--mtt-amber-soft);
  color: var(--mtt-amber);
}
.route-status.status-multi {
  background: #f3e8fd;
  color: #7c3aed;
}

/* ---------- Route tip (draw-mode hint) ---------- */
.route-tip {
  font-size: 11.5px;
  color: var(--mtt-muted);
  font-style: italic;
  background: #fff7e6;
  border: 1px solid #f0d879;
  padding: 4px 10px;
  border-radius: 8px;
  margin-left: 2px;
  white-space: normal;
  max-width: 300px;
  line-height: 1.35;
}

/* ---------- Auth button (top-right) ---------- */
.auth-section-upper-right { top: 8px; right: 8px; }
.auth-button {
  background: var(--mtt-ink) !important;
  color: #fff !important;
  border-radius: 8px !important;
  padding: 0 14px !important;
  height: 34px;
  font-size: 12.5px !important;
  font-weight: 600;
  box-shadow: var(--mtt-shadow);
  border: 1px solid transparent !important;
}
.auth-button:hover { background: #3c4043 !important; }

/* ---------- Floating dialogs -> clean panels ---------- */
.floating-dialog {
  border-radius: 14px !important;
  border: 1px solid var(--mtt-line) !important;
  box-shadow: 0 12px 40px rgba(60,64,67,.22) !important;
  padding: 14px !important;
  font-family: system-ui, -apple-system, Segoe UI, Roboto, Arial, sans-serif;
  background: #fff;
}
.floating-dialog h3 {
  font-size: 15px !important;
  font-weight: 700;
  color: var(--mtt-ink);
  margin: 0 0 10px !important;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--mtt-line);
}
.floating-dialog button {
  border-radius: 8px;
  border: 1px solid var(--mtt-line);
  background: #fff;
  color: var(--mtt-ink);
  padding: 6px 12px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  transition: background .12s ease;
}
.floating-dialog button:hover { background: #f1f3f4; }

/* Dock the saved-routes/places/photos panels at top-left, clean width */
#savedRoutesDialog,
#savedPlacesDialog,
#savedPhotosDialog {
  top: 56px !important;
  left: 8px !important;
  max-height: calc(100vh - 72px) !important;
}

/* Miles table card */
.miles-display {
  border-radius: 12px !important;
  border: 1px solid var(--mtt-line) !important;
  box-shadow: var(--mtt-shadow) !important;
  padding: 8px 10px !important;
  bottom: 8px;
  left: 8px;
  background: rgba(255,255,255,.97) !important;
  font-family: system-ui, -apple-system, Segoe UI, Roboto, Arial, sans-serif;
}

/* ---------- Touch: bigger stop markers + long-press armed state ---------- */
@media (pointer: coarse) {
  .mapboxgl-marker.marker {
    min-width: 40px;
    min-height: 40px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
  }
}
.mapboxgl-marker.marker.armed {
  transform: scale(1.18);
  box-shadow: 0 0 0 4px rgba(26,115,232,.35);
  z-index: 5;
  transition: transform .1s ease, box-shadow .1s ease;
}

/* ---------- Floating Undo / Redo bar (thumb-reachable) ---------- */
.mtt-undo-bar {
  position: fixed;
  bottom: 14px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 10001;
  display: flex;
  gap: 6px;
  padding: 6px;
  border-radius: 999px;
  background: rgba(255,255,255,.96);
  box-shadow: var(--mtt-shadow);
  border: 1px solid var(--mtt-line);
  font-family: system-ui, -apple-system, Segoe UI, Roboto, Arial, sans-serif;
}
.mtt-undo-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 40px;
  padding: 0 16px;
  border: none;
  border-radius: 999px;
  background: var(--mtt-blue);
  color: #fff;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: background .12s ease, opacity .12s ease;
}
.mtt-undo-btn svg { flex: none; }
.mtt-undo-btn:hover:not(:disabled) { background: var(--mtt-blue-dark); }
.mtt-undo-btn:disabled {
  background: #e8eaed;
  color: #bdc1c6;
  cursor: default;
}
@media (max-width: 820px) {
  .mtt-undo-bar { bottom: 80px; }
  .mtt-undo-btn { height: 44px; padding: 0 18px; }
}

/* ---------- Responsive ---------- */
@media (max-width: 820px) {
  .toolbar {
    flex-wrap: wrap;
    max-width: calc(100vw - 16px) !important;
  }
  .toolbar .autocomplete-container { width: 100%; }
  .toolbar .toolbar-section { padding: 0 4px; flex-wrap: wrap; }
  .toolbar .toolbar-section + .toolbar-section::before { display: none; }
  .toolbar button,
  .toolbar select { height: 36px; }
  .route-status { order: 99; width: 100%; justify-content: flex-start; margin-left: 0; }
  .route-tip { order: 98; width: 100%; margin-left: 0; }
  #mtt-version.app-version { font-size: 10px; }
  /* Panels fill more on small screens */
  #savedRoutesDialog,
  #savedPlacesDialog,
  #savedPhotosDialog {
    left: 6px !important;
    right: 6px !important;
    width: auto !important;
    max-width: calc(100vw - 12px) !important;
  }
}

/* Touch: bigger tap targets */
@media (pointer: coarse) {
  .toolbar button,
  .toolbar select { height: 40px; min-width: 44px; }
  .toolbar #searchInput { height: 40px; }
}
