﻿/* ==========================================
   EV Map - Mobile-First Stylesheet
   Pattern: Full-screen map + Bottom Sheet
   ========================================== */

@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&display=swap');

/* ==========================================
   CSS Variables
   ========================================== */
:root {
  --accent:        #00d4aa;
  --accent-2:      #0891b2;
  --accent-glow:   rgba(0, 212, 170, 0.2);
  --accent-dim:    rgba(0, 212, 170, 0.12);

  --bg-dark:       #0a0f1e;
  --bg-card:       #111827;
  --bg-glass:      rgba(10, 15, 30, 0.88);
  --bg-sheet:      #0f172a;
  --bg-input:      rgba(255,255,255,0.06);

  --border:        rgba(255,255,255,0.09);
  --border-focus:  rgba(0, 212, 170, 0.5);

  --txt-1:         #f1f5f9;
  --txt-2:         #94a3b8;
  --txt-3:         #4b5563;

  --danger:        #ef4444;
  --warning:       #f59e0b;
  --success:       #22c55e;
  --info:          #3b82f6;

  --sheet-peek:    120px;    /* chiều cao bottom sheet thu nhỏ */
  --sheet-mid:     55vh;     /* mở vừa */
  --sheet-full:    92vh;     /* mở tối đa */
  --top-bar-h:     56px;
  --radius:        16px;
  --radius-sm:     10px;
  --transition:    all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  --shadow:        0 -4px 32px rgba(0,0,0,0.5);
}

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

html { height: 100%; font-size: 16px; }

body {
  height: 100%;
  font-family: 'Inter', system-ui, -apple-system, sans-serif;
  background: var(--bg-dark);
  color: var(--txt-1);
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
  /* Prevent text selection on long press */
  -webkit-user-select: none;
  user-select: none;
  touch-action: manipulation;
}

/* Allow text selection in inputs */
input, textarea { -webkit-user-select: auto; user-select: auto; }

/* ==========================================
   App Root
   ========================================== */
#app {
  position: fixed;
  inset: 0;
  display: flex;
  flex-direction: column;
}

/* ==========================================
   Map Canvas (full screen base)
   ========================================== */
#map-canvas {
  position: fixed;
  top: 0; left: 0;
  width: 100vw;
  height: 100vh;
  height: 100dvh; /* dynamic viewport height (Android Chrome) */
  z-index: 0;
}

/* ==========================================
   Top Bar (floating)
   ========================================== */
#top-bar {
  position: fixed;
  top: 0; left: 0; right: 0;
  height: var(--top-bar-h);
  background: var(--bg-glass);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 0 16px;
  z-index: 300;
}

.top-logo {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

.logo-bolt {
  width: 34px; height: 34px;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  border-radius: 8px;
  display: flex; align-items: center; justify-content: center;
  font-size: 17px;
  box-shadow: 0 0 12px var(--accent-glow);
}

.logo-name {
  font-size: 16px; font-weight: 700;
  background: linear-gradient(135deg, var(--accent), #60a5fa);
  -webkit-background-clip: text; -webkit-text-fill-color: transparent;
  background-clip: text;
}

.top-spacer { flex: 1; }

/* Location badge in top bar */
#gps-status {
  display: flex; align-items: center; gap: 6px;
  padding: 6px 10px;
  background: var(--accent-dim);
  border: 1px solid rgba(0,212,170,0.2);
  border-radius: 20px;
  font-size: 11px; color: var(--accent);
  max-width: 160px; overflow: hidden;
  transition: var(--transition);
}

#gps-status .dot {
  width: 7px; height: 7px;
  background: var(--accent);
  border-radius: 50%; flex-shrink: 0;
  animation: pulse 2s infinite;
}

#gps-status span {
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}

@keyframes pulse {
  0%, 100% { opacity: 1; transform: scale(1); }
  50%       { opacity: 0.4; transform: scale(0.75); }
}

/* ==========================================
   FAB Buttons (right side, above sheet)
   ========================================== */
#fab-group {
  position: fixed;
  right: 14px;
  bottom: calc(var(--sheet-peek) + 16px);
  display: flex;
  flex-direction: column;
  gap: 10px;
  z-index: 200;
  transition: bottom 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.fab {
  width: 46px; height: 46px;
  border-radius: 50%;
  background: var(--bg-glass);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 1px solid var(--border);
  color: var(--txt-1);
  font-size: 20px;
  display: flex; align-items: center; justify-content: center;
  cursor: pointer;
  box-shadow: 0 4px 16px rgba(0,0,0,0.4);
  transition: var(--transition);
  -webkit-tap-highlight-color: transparent;
}

.fab:active { transform: scale(0.92); }
.fab.active { border-color: var(--accent); color: var(--accent); background: var(--accent-dim); }

/* ==========================================
   Bottom Sheet
   ========================================== */
#bottom-sheet {
  position: fixed;
  left: 0; right: 0;
  background: var(--bg-sheet);
  border-radius: var(--radius) var(--radius) 0 0;
  box-shadow: var(--shadow);
  z-index: 250;
  display: flex;
  flex-direction: column;
  transition: transform 0.35s cubic-bezier(0.4, 0, 0.2, 1), bottom 0.15s ease;
  will-change: transform;
  border-top: 1px solid var(--border);

  bottom: 0;
  height: calc(100vh - 120px);
  height: calc(100dvh - 120px);
  transform: translateY(calc(100% - var(--sheet-peek)));
}
#bottom-sheet.mid { transform: translateY(45%); }
#bottom-sheet.full { transform: translateY(0); }

/* Drag Handle */
.sheet-handle-wrap {
  padding: 10px 0 4px;
  display: flex; justify-content: center; align-items: center;
  flex-shrink: 0;
  cursor: grab;
}

.sheet-handle {
  width: 38px; height: 4px;
  background: var(--border);
  border-radius: 2px;
}

/* Sheet Header */
.sheet-header {
  padding: 0 16px 12px;
  flex-shrink: 0;
}

.sheet-title {
  font-size: 13px; font-weight: 600;
  color: var(--txt-2);
  text-transform: uppercase; letter-spacing: 0.07em;
}

/* Sheet Scrollable Content */
.sheet-body {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  -webkit-overflow-scrolling: touch;
  padding: 0 16px 40px;
  scrollbar-width: none;
}

.sheet-body::-webkit-scrollbar { display: none; }

/* ==========================================
   Route Form (inside sheet)
   ========================================== */
.route-form-card {
  background: rgba(255,255,255,0.03);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px;
  margin-bottom: 12px;
}

.route-inputs {
  display: flex;
  flex-direction: column;
  gap: 0;
  position: relative;
}

/* Vertical connector line between inputs */
.route-inputs::before {
  content: '';
  position: absolute;
  left: 19px;
  top: 44px;
  bottom: 44px;
  width: 2px;
  background: linear-gradient(var(--accent), #60a5fa);
  border-radius: 1px;
  z-index: 0;
}

.route-input-row {
  display: flex;
  align-items: center;
  gap: 10px;
  position: relative;
  z-index: 1;
}

.route-input-row + .route-input-row { margin-top: 8px; }

.ri-icon {
  width: 38px; height: 38px;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 16px; flex-shrink: 0;
  background: var(--bg-card);
  border: 2px solid var(--border);
}

.ri-icon.origin { border-color: var(--accent); color: var(--accent); background: var(--accent-dim); }
.ri-icon.dest   { border-color: #60a5fa; color: #60a5fa; background: rgba(96,165,250,0.1); }

.ri-input {
  flex: 1;
  padding: 11px 14px;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--txt-1);
  font-size: 14px;
  font-family: inherit;
  outline: none;
  transition: var(--transition);
  min-width: 0;
}

.ri-input::placeholder { color: var(--txt-3); }
.ri-input:focus { border-color: var(--border-focus); background: rgba(0,212,170,0.04); }

/* Battery range row */
.battery-row {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px solid var(--border);
}

.battery-label {
  display: flex; align-items: center; gap: 6px;
  font-size: 13px; color: var(--txt-2);
  white-space: nowrap;
}

.battery-input-wrap {
  display: flex; align-items: center; gap: 0; flex: 1;
}

.battery-input {
  flex: 1;
  padding: 9px 12px;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm) 0 0 var(--radius-sm);
  color: var(--txt-1);
  font-size: 14px;
  font-family: inherit;
  outline: none;
  transition: var(--transition);
  -webkit-appearance: none;
}

.battery-input:focus { border-color: var(--border-focus); }

.battery-unit {
  padding: 9px 11px;
  background: rgba(255,255,255,0.04);
  border: 1px solid var(--border);
  border-left: none;
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
  font-size: 13px; color: var(--txt-2);
}

/* Submit button */
.btn-route {
  width: 100%;
  margin-top: 12px;
  padding: 14px;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  color: #000;
  border: none;
  border-radius: var(--radius-sm);
  font-size: 15px; font-weight: 700;
  font-family: inherit;
  cursor: pointer;
  display: flex; align-items: center; justify-content: center; gap: 8px;
  box-shadow: 0 4px 20px var(--accent-glow);
  transition: var(--transition);
  -webkit-tap-highlight-color: transparent;
}

.btn-route:active { transform: scale(0.97); }
.btn-route:disabled { opacity: 0.5; }

/* ==========================================
   Route Result Card
   ========================================== */
#result-card {
  background: rgba(255,255,255,0.03);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  margin-bottom: 12px;
  display: none;
}

#result-card.visible { display: block; }

.result-stats {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1px;
  background: var(--border);
}

.stat-cell {
  padding: 16px;
  background: var(--bg-sheet);
  text-align: center;
}

.stat-val {
  font-size: 22px; font-weight: 700;
  color: var(--accent);
  line-height: 1;
  margin-bottom: 4px;
}

.stat-lbl {
  font-size: 11px; color: var(--txt-3);
  text-transform: uppercase; letter-spacing: 0.05em;
}

/* Charging station strip */
#cs-strip {
  display: none;
  align-items: center;
  gap: 12px;
  padding: 14px 16px;
  background: rgba(0,212,170,0.07);
  border-top: 1px solid rgba(0,212,170,0.15);
}

#cs-strip.visible { display: flex; }

.cs-bolt { font-size: 24px; flex-shrink: 0; }

.cs-info .cs-name  { font-size: 14px; font-weight: 600; color: var(--accent); }
.cs-info .cs-addr  { font-size: 12px; color: var(--txt-2); margin-top: 2px; }

/* Clear route */
.btn-clear {
  width: 100%;
  padding: 12px;
  background: transparent;
  border: 1px solid var(--border);
  border-top: none;
  color: var(--txt-2);
  font-size: 13px; font-family: inherit;
  cursor: pointer;
  transition: var(--transition);
  -webkit-tap-highlight-color: transparent;
}

.btn-clear:active { background: rgba(255,255,255,0.04); }

/* ==========================================
   Alert Legend Card
   ========================================== */
.alert-legend-card {
  background: rgba(255,255,255,0.02);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px;
  margin-bottom: 12px;
}

.legend-title {
  font-size: 12px; font-weight: 600; color: var(--txt-2);
  text-transform: uppercase; letter-spacing: 0.07em;
  margin-bottom: 10px;
  display: flex; align-items: center; gap: 6px;
}

.legend-grid {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 8px;
  text-align: center;
}

.legend-item {
  display: flex; flex-direction: column; align-items: center; gap: 5px;
}

.legend-emoji { font-size: 22px; }

.legend-lbl { font-size: 10px; color: var(--txt-3); line-height: 1.2; }

.alert-hint {
  margin-top: 10px; padding-top: 10px;
  border-top: 1px solid var(--border);
  font-size: 12px; color: var(--txt-3);
  display: flex; align-items: center; gap: 6px;
}

#alerts-count { font-size: 12px; color: var(--txt-2); margin-top: 8px; }

/* ==========================================
   Alert Context Menu (mobile: bottom sheet style)
   ========================================== */
#alert-menu-backdrop {
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.5);
  backdrop-filter: blur(4px);
  z-index: 800;
  opacity: 0; visibility: hidden;
  transition: var(--transition);
}

#alert-menu-backdrop.visible { opacity: 1; visibility: visible; }

#alert-menu {
  position: fixed;
  left: 0; right: 0; bottom: 0;
  background: var(--bg-sheet);
  border-radius: var(--radius) var(--radius) 0 0;
  border-top: 1px solid var(--border);
  z-index: 900;
  padding: 0 0 env(safe-area-inset-bottom, 20px);
  transform: translateY(100%);
  transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

#alert-menu.visible { transform: translateY(0); }

.am-handle {
  display: flex; justify-content: center; padding: 10px 0 4px;
}

.am-handle-bar {
  width: 38px; height: 4px;
  background: var(--border); border-radius: 2px;
}

.am-title {
  font-size: 13px; font-weight: 600; color: var(--txt-2);
  text-transform: uppercase; letter-spacing: 0.07em;
  padding: 4px 16px 12px;
  border-bottom: 1px solid var(--border);
}

.am-options {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  padding: 16px;
  gap: 8px;
}

.am-opt {
  display: flex; flex-direction: column; align-items: center; gap: 6px;
  padding: 12px 4px;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: var(--transition);
  -webkit-tap-highlight-color: transparent;
}

.am-opt:active { transform: scale(0.93); background: var(--accent-dim); border-color: var(--accent); }

.am-icon { font-size: 24px; }
.am-lbl  { font-size: 10px; color: var(--txt-2); text-align: center; line-height: 1.2; }

.am-cancel {
  width: calc(100% - 32px);
  margin: 0 16px 12px;
  padding: 14px;
  background: transparent;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--txt-2);
  font-size: 14px; font-family: inherit;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

/* ==========================================
   Toast Notifications
   ========================================== */
#toast-container {
  position: fixed;
  top: calc(var(--top-bar-h) + 8px);
  left: 12px; right: 12px;
  z-index: 999;
  display: flex;
  flex-direction: column;
  gap: 8px;
  pointer-events: none;
}

.toast {
  display: flex; align-items: flex-start; gap: 10px;
  padding: 12px 14px;
  border-radius: var(--radius-sm);
  background: var(--bg-card);
  border: 1px solid var(--border);
  box-shadow: 0 8px 24px rgba(0,0,0,0.5);
  animation: toastIn 0.3s ease;
  pointer-events: auto;
  cursor: pointer;
}

.toast.removing { animation: toastOut 0.25s ease forwards; }

@keyframes toastIn  { from { opacity:0; transform:translateY(-10px) scale(0.95); } to { opacity:1; transform:none; } }
@keyframes toastOut { from { opacity:1; transform:none; } to { opacity:0; transform:translateY(-8px) scale(0.95); } }

.toast-icon { font-size: 18px; flex-shrink: 0; margin-top: 1px; }
.toast-body .toast-title { font-size: 13px; font-weight: 600; }
.toast-body .toast-msg   { font-size: 12px; color: var(--txt-2); margin-top: 2px; line-height: 1.4; }

.toast.success { border-left: 3px solid var(--success); }
.toast.error   { border-left: 3px solid var(--danger); }
.toast.warning { border-left: 3px solid var(--warning); }
.toast.info    { border-left: 3px solid var(--info); }

/* ==========================================
   Loading Overlay
   ========================================== */
#loading-overlay {
  position: fixed; inset: 0;
  background: rgba(10,15,30,0.7);
  backdrop-filter: blur(6px);
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  gap: 16px; z-index: 600;
  opacity: 0; visibility: hidden;
  transition: var(--transition);
}

#loading-overlay.visible { opacity: 1; visibility: visible; }

.loader {
  width: 44px; height: 44px;
  border: 3px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.75s linear infinite;
}

.loader-txt { font-size: 14px; color: var(--txt-2); font-weight: 500; }

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

/* ==========================================
   Safe area for notched phones
   ========================================== */
.sheet-body {
  padding-bottom: max(40px, env(safe-area-inset-bottom, 40px));
}

/* ==========================================
   Autocomplete suggestions dropdown
   ========================================== */
.pac-container {
  background: var(--bg-card) !important;
  border: 1px solid var(--border) !important;
  border-radius: var(--radius-sm) !important;
  box-shadow: 0 8px 32px rgba(0,0,0,0.5) !important;
  margin-top: 4px;
  font-family: 'Inter', sans-serif !important;
}

.pac-item {
  padding: 10px 14px !important;
  color: var(--txt-1) !important;
  border-top: 1px solid var(--border) !important;
  font-size: 13px !important;
  cursor: pointer;
}

.pac-item:first-child { border-top: none !important; }
.pac-item:hover, .pac-item-selected { background: rgba(0,212,170,0.08) !important; }
.pac-item-query { color: var(--txt-1) !important; font-weight: 500; }
.pac-matched { color: var(--accent) !important; }
.pac-icon { display: none !important; }

/* ==========================================
   Autocomplete Dropdown
   ========================================== */
.autocomplete-wrap {
  position: relative;
  flex: 1;
  min-width: 0;
}

.autocomplete-wrap .ri-input {
  width: 100%;
}

.autocomplete-list {
  display: none;
  position: absolute;
  top: calc(100% + 4px);
  left: 0; right: 0;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  max-height: 220px;
  overflow-y: auto;
  z-index: 1000;
  list-style: none;
  box-shadow: 0 8px 32px rgba(0,0,0,0.5);
  scrollbar-width: none;
}

.autocomplete-list.show { display: block; }
.autocomplete-list::-webkit-scrollbar { display: none; }

.autocomplete-item {
  padding: 11px 14px;
  font-size: 13px;
  color: var(--txt-1);
  cursor: pointer;
  border-bottom: 1px solid rgba(255,255,255,0.05);
  line-height: 1.4;
  transition: background 0.15s;
}

.autocomplete-item:last-child { border-bottom: none; }
.autocomplete-item:active,
.autocomplete-item:hover { background: var(--accent-dim); color: var(--accent); }

/* ==========================================
   Leaflet Overrides (dark theme)
   ========================================== */
.leaflet-container {
  background: #0a0f1e;
  font-family: 'Inter', sans-serif;
}

/* Zoom buttons */
.leaflet-control-zoom a {
  background: var(--bg-glass) !important;
  backdrop-filter: blur(12px) !important;
  color: var(--txt-1) !important;
  border: 1px solid var(--border) !important;
  width: 36px !important;
  height: 36px !important;
  line-height: 36px !important;
  font-size: 18px !important;
}

.leaflet-control-zoom a:hover {
  background: var(--accent-dim) !important;
  color: var(--accent) !important;
}

.leaflet-control-zoom {
  border: none !important;
  box-shadow: 0 4px 16px rgba(0,0,0,0.4) !important;
  margin-right: 14px !important;
  margin-bottom: calc(var(--sheet-peek) + 90px) !important;
}

/* Attribution */
.leaflet-control-attribution {
  background: rgba(10,15,30,0.7) !important;
  color: var(--txt-3) !important;
  font-size: 10px !important;
  backdrop-filter: blur(4px);
  border-radius: 4px 4px 0 0 !important;
}

.leaflet-control-attribution a { color: var(--txt-2) !important; }

/* Popup */
.leaflet-popup-content-wrapper {
  background: var(--bg-card) !important;
  color: var(--txt-1) !important;
  border: 1px solid var(--border) !important;
  border-radius: var(--radius-sm) !important;
  box-shadow: 0 8px 24px rgba(0,0,0,0.5) !important;
  font-family: 'Inter', sans-serif !important;
  font-size: 13px !important;
}

.leaflet-popup-tip { background: var(--bg-card) !important; }
.leaflet-popup-close-button { color: var(--txt-2) !important; }
/* ==========================================
   Pick on Map Button (nút 🎯 bên cạnh input)
   ========================================== */
.btn-pick {
  width: 40px; height: 40px;
  flex-shrink: 0;
  background: var(--accent-dim);
  border: 1px solid rgba(0,212,170,0.3);
  border-radius: var(--radius-sm);
  color: var(--accent);
  font-size: 18px;
  display: flex; align-items: center; justify-content: center;
  cursor: pointer;
  transition: var(--transition);
  -webkit-tap-highlight-color: transparent;
}
.btn-pick:active { transform: scale(0.9); background: rgba(0,212,170,0.2); }

/* Route input row với pick button */
.route-input-row {
  display: flex; align-items: center; gap: 8px;
}

/* ==========================================
   Pick Mode Banner
   ========================================== */
#pick-banner {
  position: fixed;
  top: calc(var(--top-bar-h) + 8px);
  left: 12px; right: 12px;
  background: var(--bg-card);
  border: 1px solid var(--accent);
  border-radius: var(--radius-sm);
  padding: 12px 14px;
  display: none;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  z-index: 400;
  box-shadow: 0 4px 20px rgba(0,212,170,0.2);
  animation: toastIn 0.25s ease;
  font-size: 13px; color: var(--accent); font-weight: 500;
}
#pick-banner.visible { display: flex; }
#pick-banner button {
  background: transparent; border: 1px solid var(--border);
  border-radius: 6px; padding: 4px 10px;
  color: var(--txt-2); font-size: 12px; cursor: pointer; font-family: inherit;
}

/* ==========================================
   Autocomplete item 2-line style
   ========================================== */
.autocomplete-item { display: flex; flex-direction: column; gap: 2px; }
.ac-main { font-size: 13px; color: var(--txt-1); font-weight: 500; }
.ac-sub  { font-size: 11px; color: var(--txt-3); }

/* ==========================================
   FAB Primary (nút mở navigation)
   ========================================== */
.fab-primary {
  background: linear-gradient(135deg, var(--accent), var(--accent-2)) !important;
  border-color: transparent !important;
  color: #000 !important;
  font-size: 22px !important;
  box-shadow: 0 4px 16px var(--accent-glow) !important;
}

/* ==========================================
   Result card fix (display:none → hidden via class)
   ========================================== */
#result-card {
  display: none;
  background: rgba(255,255,255,0.03);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  margin-bottom: 12px;
}
#result-card.visible { display: block; }
/* ==========================================
   Map Markers (custom styled)
   ========================================== */
.map-marker {
  width: 32px; height: 36px;
  border-radius: 50% 50% 50% 0;
  transform: rotate(-45deg);
  display: flex; align-items: center; justify-content: center;
  font-size: 13px; font-weight: 700;
  color: #fff;
  box-shadow: 0 3px 10px rgba(0,0,0,0.5);
}
.map-marker span { transform: rotate(45deg); }
.map-marker.marker-start { background: linear-gradient(135deg, #00d4aa, #0891b2); }
.map-marker.marker-end   { background: linear-gradient(135deg, #ef4444, #dc2626); }
.map-marker.marker-cs    { background: linear-gradient(135deg, #f59e0b, #d97706); transform:rotate(0); border-radius:50%; height:32px; }

/* ==========================================
   Input with clear button + spinner
   ========================================== */
.input-with-clear {
  position: relative; width: 100%;
}
.input-with-clear .ri-input { padding-right: 56px; width: 100%; }
.input-clear-btn {
  position: absolute; right: 28px; top: 50%; transform: translateY(-50%);
  background: none; border: none; color: var(--txt-3); font-size: 14px;
  cursor: pointer; padding: 4px; display: none; -webkit-tap-highlight-color:transparent;
}
.input-with-clear:has(input:not(:placeholder-shown)) .input-clear-btn { display: block; }
.input-spinner {
  position: absolute; right: 8px; top: 50%; transform: translateY(-50%);
  width: 14px; height: 14px;
  border: 2px solid var(--border); border-top-color: var(--accent);
  border-radius: 50%; animation: spin 0.7s linear infinite;
  display: none;
}
.input-spinner.show { display: block; }

/* ==========================================
   Route Connector (đường nối dọc A-B)
   ========================================== */
.route-connector {
  display: flex; justify-content: center;
  padding: 0 0 0 19px; margin: 4px 0;
}
.connector-line {
  width: 2px; height: 16px;
  background: linear-gradient(var(--accent), #60a5fa);
  border-radius: 1px; display: block;
}

/* ==========================================
   Battery Range Slider
   ========================================== */
.battery-slider-wrap { flex: 1; display: flex; flex-direction: column; gap: 6px; }
.battery-slider {
  width: 100%;
  -webkit-appearance: none; appearance: none;
  height: 4px; border-radius: 2px;
  background: linear-gradient(to right, var(--accent) 0%, var(--accent) var(--val,41.7%), var(--border) 41.7%);
  outline: none;
}
.battery-slider::-webkit-slider-thumb {
  -webkit-appearance: none; width: 18px; height: 18px;
  border-radius: 50%; background: var(--accent);
  border: 2px solid #fff; cursor: pointer;
  box-shadow: 0 2px 6px rgba(0,0,0,0.3);
}
.battery-val-wrap { display: flex; align-items: center; gap: 0; }

/* ==========================================
   Result Card - 3 stat cells
   ========================================== */
.result-stats { grid-template-columns: 1fr 1fr 1fr; }

/* ==========================================
   Navigate Button
   ========================================== */
.btn-navigate {
  width: calc(100% - 2px);
  margin: 0;
  padding: 14px;
  background: linear-gradient(135deg, #3b82f6, #1d4ed8);
  color: #fff; border: none;
  font-size: 15px; font-weight: 700; font-family: inherit;
  cursor: pointer;
  display: flex; align-items: center; justify-content: center; gap: 8px;
  box-shadow: 0 4px 16px rgba(59,130,246,0.3);
  transition: var(--transition);
  -webkit-tap-highlight-color: transparent;
}
.btn-navigate:active { transform: scale(0.97); }

/* ==========================================
   Steps Section
   ========================================== */
#steps-section {
  background: rgba(255,255,255,0.02);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  margin-bottom: 12px;
}
.steps-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 12px 14px;
  font-size: 13px; font-weight: 600; color: var(--txt-2);
  cursor: pointer;
  user-select: none;
}
.steps-header:active { background: rgba(255,255,255,0.03); }
.steps-list { max-height: 300px; overflow-y: auto; scrollbar-width: none; }
.steps-list::-webkit-scrollbar { display: none; }

.step-item {
  display: flex; align-items: center; gap: 12px;
  padding: 10px 14px;
  border-top: 1px solid rgba(255,255,255,0.04);
}
.step-icon {
  width: 28px; height: 28px; flex-shrink: 0;
  background: var(--bg-card); border: 1px solid var(--border);
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 14px; font-weight: 700; color: var(--accent);
}
.step-body { flex: 1; min-width: 0; }
.step-name { font-size: 13px; color: var(--txt-1); font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.step-dist { font-size: 11px; color: var(--txt-3); margin-top: 2px; }

/* ==========================================
   Tracking FAB active state
   ========================================== */
#fab-track.tracking { border-color: #3b82f6; color: #3b82f6; background: rgba(59,130,246,0.12); }

/* ==========================================
   Route line animation
   ========================================== */
.route-line { stroke-dasharray: 10; animation: dashRoute 0.5s linear; }
@keyframes dashRoute { from { stroke-dashoffset: 1000; } to { stroke-dashoffset: 0; } }

/* ==========================================
   ri-icon - Letter style (A / B)
   ========================================== */
.ri-icon {
  font-size: 13px !important;
  font-weight: 700 !important;
}
/* Alert marker với opacity mờ dần khi gần hết hạn */
.alert-marker {
  font-size: 22px;
  width: 36px; height: 36px;
  display: flex; align-items: center; justify-content: center;
  filter: drop-shadow(0 2px 4px rgba(0,0,0,0.7));
  transition: opacity 1s ease;
}
/* ==========================================
   MOBILE-FIRST UI OVERHAUL & PWA INSTALL
   ========================================== */

/* Nút cài đặt PWA */
.btn-install {
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  color: #000;
  border: none;
  border-radius: 20px;
  padding: 6px 12px;
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
  box-shadow: 0 2px 8px var(--accent-glow);
  display: flex; align-items: center; gap: 4px;
  -webkit-tap-highlight-color: transparent;
}
.btn-install:active { transform: scale(0.95); }

/* Đổi Top Bar thành dạng Floating Pill (như Google Maps) */
#top-bar {
  top: env(safe-area-inset-top, 12px);
  left: 12px; right: 12px;
  height: 50px;
  border-radius: 25px;
  background: var(--bg-glass);
  box-shadow: 0 4px 20px rgba(0,0,0,0.6);
  border: 1px solid rgba(255,255,255,0.08);
}

/* Nâng cấp Bottom Sheet (Tràn viền, bo góc to hơn, blur) */
#bottom-sheet {
  border-radius: 24px 24px 0 0;
  background: rgba(15, 23, 42, 0.95);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border-top: 1px solid rgba(255,255,255,0.1);
}

/* Drag Handle to và dễ bấm hơn */
.sheet-handle-wrap {
  padding: 12px 0 8px;
}
.sheet-handle {
  width: 48px; height: 5px;
  background: rgba(255,255,255,0.2);
  border-radius: 3px;
}

/* Route Inputs Style native hơn */
.route-input-row .ri-icon {
  width: 32px; height: 32px; font-size: 14px;
}
.ri-input {
  border-radius: 12px;
  padding: 12px 14px;
  font-size: 15px; /* Ngăn iOS tự zoom */
  background: rgba(255,255,255,0.08);
  border: none;
}
.ri-input:focus { background: rgba(255,255,255,0.12); box-shadow: inset 0 0 0 1px var(--accent); }

.route-connector::before {
  left: 16px; top: 38px; bottom: 38px;
}

/* Buttons to hơn */
.btn-route, .btn-navigate {
  border-radius: 14px;
  padding: 16px;
  font-size: 16px;
}

/* FAB shadows và margin */
#fab-group { right: 16px; }
.fab {
  width: 50px; height: 50px; font-size: 22px;
  border-radius: 16px; /* Squircle style */
}

/* Căn chỉnh Alert Menu Bottom Sheet */
#alert-menu {
  border-radius: 24px 24px 0 0;
  background: rgba(15, 23, 42, 0.95);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
}
.am-cancel {
  border-radius: 14px;
  background: rgba(255,255,255,0.08);
  border: none;
}
/* Cố định lại logic Bottom Sheet để không bị đẩy quá cao khi bật bàn phím */
#bottom-sheet {
  bottom: 0; /* KHÔNG dùng var(--kb-h) để tránh bị đẩy kép */
   /* Luôn cách top bar một khoảng, dvh tự động trừ đi bàn phím */
  
}

#bottom-sheet.mid {
  
}

#bottom-sheet.full {
   /* Khi mở full, sẽ chiếm toàn bộ phần màn hình còn lại (calc 100dvh - 70px) */
}

.sheet-body {
  height: 100%;
  padding-bottom: 20px !important;
}

/* Ẩn bớt autocomplete list nếu màn hình quá ngắn (bàn phím che) */
.autocomplete-list {
  max-height: 35dvh !important;
}
/* Xoá !important và thêm fallback vh cho các trình duyệt cũ */
#bottom-sheet {
  bottom: 0;
  height: calc(100vh - 80px); /* Fallback */
  height: calc(100dvh - 80px); /* Cố ý trừ 80px để cách top bar xa hơn một chút */
  transform: translateY(calc(100% - var(--sheet-peek)));
}
#bottom-sheet.mid { transform: translateY(45%); }
#bottom-sheet.full { transform: translateY(0); }

/* Đảm bảo nút pick không bao giờ bị bóp méo hoặc đẩy ra ngoài */
.btn-pick {
  width: 40px !important;
  height: 40px !important;
  min-width: 40px !important;
  flex-shrink: 0 !important;
}

.route-input-row {
  flex-wrap: nowrap !important;
}

/* Đảm bảo autocomplete không tràn ra ngoài */
.autocomplete-wrap {
  min-width: 100px;
}