/* =====================================================================
   Wheelpin — GPS control-panel MOCKUP styles
   School project. Design is the deliverable; nothing here is functional.
   Palette centers on one accent (electric blue). Follows system dark/light.
   ===================================================================== */

:root {
  color-scheme: light dark;

  /* accent */
  --accent: #2f6bff;
  --accent-strong: #1552e0;
  --accent-soft: rgba(47, 107, 255, 0.12);
  --green: #29c26b;
  --amber: #ff9f0a;
  --red: #ff453a;

  /* light theme surfaces */
  --bg: #eef1f5;
  --bg-2: #f7f9fc;
  --card: #ffffff;
  --card-2: #f2f4f8;
  --text: #0b1220;
  --text-2: #5b6572;
  --text-3: #97a0ad;
  --hairline: rgba(10, 18, 32, 0.08);
  --shadow: 0 8px 30px rgba(10, 18, 32, 0.10);
  --shadow-soft: 0 2px 10px rgba(10, 18, 32, 0.06);
  --sheet-bg: rgba(255, 255, 255, 0.86);
  --blur: saturate(180%) blur(20px);

  /* type */
  --font: -apple-system, BlinkMacSystemFont, "SF Pro Text", "SF Pro Display",
          "Segoe UI", Roboto, Helvetica, Arial, sans-serif;

  --radius: 20px;
  --radius-sm: 14px;

  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

@media (prefers-color-scheme: dark) {
  :root {
    --accent: #4d86ff;
    --accent-strong: #2f6bff;
    --accent-soft: rgba(77, 134, 255, 0.16);
    --bg: #0b1220;
    --bg-2: #0e1524;
    --card: #161c2b;
    --card-2: #1d2536;
    --text: #f4f6fb;
    --text-2: #9aa5b6;
    --text-3: #6b7688;
    --hairline: rgba(255, 255, 255, 0.09);
    --shadow: 0 10px 34px rgba(0, 0, 0, 0.45);
    --shadow-soft: 0 2px 12px rgba(0, 0, 0, 0.35);
    --sheet-bg: rgba(18, 24, 38, 0.82);
  }
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
[hidden] { display: none !important; }
img { max-width: 100%; }

html, body {
  margin: 0;
  height: 100%;
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

body { overflow: hidden; }

.tabnum {
  font-variant-numeric: tabular-nums;
  font-feature-settings: "tnum" 1;
  letter-spacing: -0.01em;
}

/* ===================== LOGIN ===================== */
.login-view {
  min-height: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: calc(24px + var(--safe-top)) 22px calc(24px + var(--safe-bottom));
  gap: 26px;
  background:
    radial-gradient(120% 80% at 50% -10%, var(--accent-soft), transparent 60%),
    var(--bg);
}

.login-card {
  width: 100%;
  max-width: 380px;
  background: var(--card);
  border: 1px solid var(--hairline);
  border-radius: 28px;
  box-shadow: var(--shadow);
  padding: 34px 26px 28px;
  text-align: center;
  animation: rise 0.5s cubic-bezier(0.2, 0.8, 0.2, 1) both;
}

.brand { display: flex; flex-direction: column; align-items: center; gap: 6px; margin-bottom: 26px; }
.brand-mark { border-radius: 20px; box-shadow: var(--shadow-soft); }
.brand-name { margin: 8px 0 0; font-size: 27px; font-weight: 700; letter-spacing: -0.02em; }
.brand-tag { margin: 0; color: var(--text-2); font-size: 15px; max-width: 22ch; }

.google-btn {
  width: 100%;
  height: 52px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  border: 1px solid var(--hairline);
  border-radius: 14px;
  background: var(--card);
  color: var(--text);
  font-size: 16px;
  font-weight: 600;
  font-family: var(--font);
  cursor: pointer;
  box-shadow: var(--shadow-soft);
  transition: transform 0.12s ease, box-shadow 0.2s ease, background 0.2s ease;
}
.google-btn:active { transform: scale(0.975); }
.g-logo { width: 20px; height: 20px; }

.login-fine { margin: 20px 0 0; color: var(--text-2); font-size: 12.5px; line-height: 1.5; }
.mock-pill {
  display: inline-block; margin-top: 8px; padding: 4px 10px;
  background: var(--accent-soft); color: var(--accent);
  border-radius: 999px; font-weight: 600; font-size: 11.5px;
}
.footer-note { color: var(--text-2); font-size: 12px; text-align: center; max-width: 30ch; margin: 0; opacity: 0.8; }

/* ===================== APP SHELL ===================== */
.app-view {
  height: 100%;
  display: flex;
  flex-direction: column;
  background: var(--bg);
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: calc(10px + var(--safe-top)) 16px 10px;
  background: var(--sheet-bg);
  -webkit-backdrop-filter: var(--blur);
  backdrop-filter: var(--blur);
  border-bottom: 1px solid var(--hairline);
  z-index: 20;
}
.topbar-title { display: flex; align-items: center; gap: 8px; font-weight: 700; font-size: 18px; letter-spacing: -0.02em; }
.topbar-title img { border-radius: 7px; }

.icon-btn {
  display: inline-flex; align-items: center; justify-content: center;
  width: 38px; height: 38px; border: none; border-radius: 12px;
  background: var(--card-2); color: var(--text); cursor: pointer; font-size: 16px;
  transition: transform 0.12s ease, background 0.2s ease;
}
.icon-btn:active { transform: scale(0.9); }

/* ===================== MAP ===================== */
.map-wrap { position: relative; flex: 1 1 auto; min-height: 0; }
/* z-index:0 gives the map its own stacking context so Leaflet's internal panes
   (tiles, markers, controls) stay BELOW the overlay UI (status bar, recenter). */
#map { position: absolute; inset: 0; background: var(--bg-2); z-index: 0; }

/* Leaflet chrome tuned to match the theme */
.leaflet-container { font-family: var(--font); background: var(--bg-2); }

/* Dark map: filter the light OSM tiles into a dark basemap (no API key needed).
   Only the tile pane is filtered, so the car/route/pins keep their real colors. */
@media (prefers-color-scheme: dark) {
  .leaflet-tile-pane { filter: invert(1) hue-rotate(180deg) brightness(0.92) contrast(0.9); }
}
.leaflet-control-attribution {
  background: var(--sheet-bg) !important;
  color: var(--text-2) !important;
  backdrop-filter: var(--blur);
  border-radius: 8px 0 0 0;
  font-size: 10px;
}
.leaflet-control-attribution a { color: var(--accent) !important; }
.leaflet-bar a { background: var(--card) !important; color: var(--text) !important; border-color: var(--hairline) !important; }

/* Car marker */
.car-marker { will-change: transform; }
.car-marker svg { display: block; filter: drop-shadow(0 3px 5px rgba(0,0,0,0.35)); }
.car-rot { transition: transform 0.18s linear; transform-origin: 50% 50%; }
.dest-pin svg { filter: drop-shadow(0 4px 6px rgba(0,0,0,0.3)); }

.map-fab {
  position: absolute; right: 14px; bottom: 16px; z-index: 15;
  width: 46px; height: 46px; border-radius: 50%;
  border: 1px solid var(--hairline);
  background: var(--sheet-bg); color: var(--accent);
  -webkit-backdrop-filter: var(--blur); backdrop-filter: var(--blur);
  box-shadow: var(--shadow); cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  transition: transform 0.12s ease, color 0.2s ease;
}
.map-fab:active { transform: scale(0.9); }
.map-fab.following { color: var(--accent); }
.map-fab.unfollowed { color: var(--text-2); animation: nudge 1.6s ease-in-out infinite; }
@keyframes nudge { 0%,100%{transform:translateY(0);} 50%{transform:translateY(-3px);} }

/* ===================== STATUS BAR (running) ===================== */
.status-bar {
  position: absolute; left: 12px; right: 12px; top: 12px; z-index: 16;
  background: var(--sheet-bg);
  -webkit-backdrop-filter: var(--blur); backdrop-filter: var(--blur);
  border: 1px solid var(--hairline);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 14px 16px;
  animation: dropIn 0.4s cubic-bezier(0.2, 0.8, 0.2, 1) both;
}
.status-hero { display: flex; flex-direction: column; align-items: flex-start; }
.hero-num { display: flex; align-items: baseline; gap: 6px; }
.hero-num .tabnum { font-size: 46px; font-weight: 700; line-height: 1; letter-spacing: -0.03em; }
.hero-unit { font-size: 16px; font-weight: 600; color: var(--text-2); }
.hero-label { font-size: 12px; color: var(--text-2); margin-top: 2px; }

.status-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin: 12px 0 10px; }
.stat {
  background: var(--card-2); border-radius: var(--radius-sm);
  padding: 8px 6px; text-align: center;
}
.stat .tabnum { display: block; font-size: 18px; font-weight: 700; }
.stat label { font-size: 10.5px; color: var(--text-2); text-transform: uppercase; letter-spacing: 0.04em; }

.status-chips { display: flex; flex-wrap: wrap; gap: 8px; }
.live-chip {
  display: inline-flex; align-items: center; gap: 6px;
  background: var(--card-2); border-radius: 999px;
  padding: 5px 10px; font-size: 12px; font-weight: 600; color: var(--text-2);
}
.dot { width: 8px; height: 8px; border-radius: 50%; display: inline-block; }
.dot-green { background: var(--green); box-shadow: 0 0 0 0 rgba(41,194,107,0.5); }
.pulse { animation: pulse 1.6s ease-out infinite; }
@keyframes pulse {
  0% { box-shadow: 0 0 0 0 rgba(41,194,107,0.55); }
  70% { box-shadow: 0 0 0 7px rgba(41,194,107,0); }
  100% { box-shadow: 0 0 0 0 rgba(41,194,107,0); }
}

/* ===================== CONTROL SHEET ===================== */
.sheet {
  position: relative; z-index: 18;
  background: var(--sheet-bg);
  -webkit-backdrop-filter: var(--blur); backdrop-filter: var(--blur);
  border-top: 1px solid var(--hairline);
  border-radius: 26px 26px 0 0;
  box-shadow: 0 -10px 30px rgba(10, 18, 32, 0.10);
  padding: 8px 16px calc(14px + var(--safe-bottom));
  max-height: 62%;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}
.sheet-grip { width: 38px; height: 5px; border-radius: 3px; background: var(--hairline); margin: 4px auto 12px; }

.field-label { display: block; font-size: 13px; font-weight: 600; color: var(--text-2); margin: 2px 2px 7px; }
.row-between { display: flex; align-items: center; justify-content: space-between; margin-top: 16px; }
.note { font-size: 11.5px; color: var(--text-2); }

/* address field */
.addr-field { position: relative; }
/* icon + clear are anchored to the 48px input height, not the whole field
   (the field also contains the dropdown, which makes it much taller). */
.addr-icon { position: absolute; left: 13px; top: 24px; transform: translateY(-50%); color: var(--accent); pointer-events: none; }
.addr-input {
  width: 100%; height: 48px;
  padding: 0 40px 0 40px;
  border: 1px solid var(--hairline); border-radius: 14px;
  background: var(--card); color: var(--text);
  font-size: 16px; font-family: var(--font);
  outline: none; transition: border-color 0.2s ease, box-shadow 0.2s ease;
}
.addr-input:focus { border-color: var(--accent); box-shadow: 0 0 0 4px var(--accent-soft); }
.addr-clear {
  position: absolute; right: 10px; top: 24px; transform: translateY(-50%);
  width: 26px; height: 26px; border: none; border-radius: 50%;
  background: var(--card-2); color: var(--text-2); cursor: pointer; font-size: 12px;
}

.suggestions {
  list-style: none; margin: 8px 0 0; padding: 6px;
  background: var(--card); border: 1px solid var(--hairline);
  border-radius: var(--radius-sm); box-shadow: var(--shadow);
  overflow: hidden;
}
.suggestions li {
  display: flex; align-items: center; gap: 10px;
  padding: 11px 10px; border-radius: 10px; cursor: pointer;
  animation: slideIn 0.28s cubic-bezier(0.2,0.8,0.2,1) both;
}
.suggestions li:active { background: var(--accent-soft); }
.sug-ic { width: 30px; height: 30px; flex: none; border-radius: 8px; background: var(--accent-soft); color: var(--accent);
  display: flex; align-items: center; justify-content: center; }
.sug-text { min-width: 0; }
.sug-title { font-size: 14.5px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sug-sub { font-size: 12px; color: var(--text-2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.suggestions .sug-head { padding: 8px 10px 4px; font-size: 11px; font-weight: 700; letter-spacing: 0.05em; text-transform: uppercase; color: var(--text-2); cursor: default; }
.suggestions .sug-msg { padding: 12px 12px; font-size: 13.5px; color: var(--text-2); cursor: default; }
.suggestions .sug-head:active, .suggestions .sug-msg:active { background: transparent; }

/* chips */
.chips { display: flex; gap: 8px; margin: 12px 0 2px; overflow-x: auto; padding-bottom: 4px; scrollbar-width: none; }
.chips::-webkit-scrollbar { display: none; }
.chip {
  flex: none; height: 38px; padding: 0 15px;
  border: 1px solid var(--hairline); border-radius: 999px;
  background: var(--card); color: var(--text);
  font-size: 14px; font-weight: 600; font-family: var(--font); cursor: pointer;
  transition: transform 0.12s ease, background 0.2s ease, border-color 0.2s ease;
  animation: chipIn 0.3s cubic-bezier(0.2,0.8,0.2,1) both;
}
.chip:active { transform: scale(0.94); background: var(--accent-soft); }
.chip-add { width: 38px; padding: 0; color: var(--accent); font-size: 20px; font-weight: 400; }

/* segmented control */
.segmented {
  position: relative; display: grid; grid-template-columns: 1fr 1fr;
  background: var(--card-2); border-radius: 12px; padding: 3px; margin-top: 8px;
}
.seg-btn {
  position: relative; z-index: 2; height: 38px; border: none; background: transparent;
  color: var(--text-2); font-size: 14px; font-weight: 600; font-family: var(--font);
  cursor: pointer; transition: color 0.2s ease;
}
.seg-btn.active { color: var(--text); }
.seg-thumb {
  position: absolute; z-index: 1; top: 3px; left: 3px;
  width: calc(50% - 3px); height: calc(100% - 6px);
  background: var(--card); border-radius: 9px; box-shadow: var(--shadow-soft);
  transition: transform 0.28s cubic-bezier(0.2, 0.8, 0.2, 1);
}
.seg-thumb.right { transform: translateX(100%); }

/* stepper */
.stepper-wrap {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  margin-top: 12px; background: var(--card-2); border-radius: var(--radius-sm); padding: 8px 10px;
  animation: rise 0.3s ease both;
}
.step-btn {
  width: 46px; height: 46px; border: none; border-radius: 12px;
  background: var(--card); color: var(--accent); font-size: 26px; font-weight: 500;
  cursor: pointer; box-shadow: var(--shadow-soft);
  transition: transform 0.1s ease;
}
.step-btn:active { transform: scale(0.9); }
.step-value { display: flex; align-items: baseline; gap: 5px; }
.step-value .tabnum { font-size: 30px; font-weight: 700; }
.step-value small { color: var(--text-2); font-size: 14px; font-weight: 600; }

/* GO button */
.go-btn {
  position: relative; width: 100%; height: 60px; margin-top: 16px;
  border: none; border-radius: 18px;
  background: linear-gradient(180deg, var(--accent), var(--accent-strong));
  color: #fff; font-size: 21px; font-weight: 800; letter-spacing: 0.04em;
  font-family: var(--font); cursor: pointer;
  box-shadow: 0 10px 24px rgba(47, 107, 255, 0.42);
  transition: transform 0.12s ease, box-shadow 0.2s ease, filter 0.2s ease;
  display: flex; align-items: center; justify-content: center; gap: 10px;
}
.go-btn:active { transform: scale(0.97); box-shadow: 0 6px 16px rgba(47, 107, 255, 0.4); }
.go-btn.loading { filter: saturate(0.9) brightness(0.98); pointer-events: none; }
.go-btn.loading .go-label { opacity: 0.6; }

/* run controls */
.run-controls { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 16px; animation: rise 0.3s ease both; }
.ctrl-btn {
  height: 56px; border: none; border-radius: 16px;
  font-size: 17px; font-weight: 700; font-family: var(--font); cursor: pointer; color: #fff;
  transition: transform 0.12s ease, filter 0.2s ease;
}
.ctrl-btn:active { transform: scale(0.96); }
.ctrl-amber { background: linear-gradient(180deg, #ffb340, var(--amber)); color: #3a2600; }
.ctrl-red { background: linear-gradient(180deg, #ff6b60, var(--red)); }

/* clear / panic */
.clear-btn {
  width: 100%; height: 50px; margin-top: 12px;
  border: 1.5px solid var(--red); border-radius: 15px;
  background: transparent; color: var(--red);
  font-size: 15px; font-weight: 700; font-family: var(--font); cursor: pointer;
  transition: transform 0.12s ease, background 0.2s ease;
}
.clear-btn:active { transform: scale(0.98); background: rgba(255, 69, 58, 0.10); }

/* ===================== MODALS ===================== */
.overlay {
  position: fixed; inset: 0; z-index: 60;
  background: rgba(6, 10, 20, 0.5);
  -webkit-backdrop-filter: blur(6px); backdrop-filter: blur(6px);
  display: flex; align-items: flex-end; justify-content: center;
  animation: fade 0.2s ease both;
}
.modal {
  width: 100%; max-width: 440px; background: var(--card);
  border: 1px solid var(--hairline);
  box-shadow: var(--shadow);
}
.modal-sheet {
  border-radius: 24px 24px 0 0;
  padding: 10px 18px calc(20px + var(--safe-bottom));
  animation: sheetUp 0.32s cubic-bezier(0.2, 0.8, 0.2, 1) both;
}
.modal-prompt {
  margin: auto 16px; border-radius: 22px; padding: 22px 20px;
  animation: rise 0.28s cubic-bezier(0.2, 0.8, 0.2, 1) both;
  align-self: center;
}
.modal-head { display: flex; align-items: center; justify-content: space-between; margin: 4px 0 10px; }
.modal-head h2 { margin: 0; font-size: 20px; font-weight: 700; }
.modal h2 { letter-spacing: -0.02em; }
.prompt-sub { margin: 0 0 14px; color: var(--text-2); font-size: 14px; }
.prompt-actions { display: flex; gap: 10px; margin-top: 14px; }
.prompt-actions .ghost-btn, .prompt-actions .solid-btn { flex: 1; }

.settings-group {
  background: var(--card-2); border-radius: var(--radius-sm);
  padding: 6px 14px; margin-bottom: 14px;
}
.settings-row { display: flex; align-items: center; justify-content: space-between; padding: 12px 0; font-size: 16px; }
.group-title { font-size: 13px; color: var(--text-2); font-weight: 600; margin: 12px 2px 8px; }
.settings-group .text-input { margin-bottom: 10px; }
.settings-muted { color: var(--text-2); font-size: 15px; }

.text-input {
  width: 100%; height: 46px; padding: 0 14px;
  border: 1px solid var(--hairline); border-radius: 12px;
  background: var(--card); color: var(--text); font-size: 16px; font-family: var(--font);
  outline: none; transition: border-color 0.2s ease, box-shadow 0.2s ease;
}
.text-input:focus { border-color: var(--accent); box-shadow: 0 0 0 4px var(--accent-soft); }

.ghost-btn {
  height: 46px; padding: 0 16px; border: 1px solid var(--hairline);
  border-radius: 12px; background: var(--card); color: var(--text);
  font-size: 15px; font-weight: 600; font-family: var(--font); cursor: pointer;
  transition: transform 0.12s ease;
}
.ghost-btn:active { transform: scale(0.97); }
.solid-btn {
  height: 46px; padding: 0 16px; border: none; border-radius: 12px;
  background: linear-gradient(180deg, var(--accent), var(--accent-strong)); color: #fff;
  font-size: 15px; font-weight: 700; font-family: var(--font); cursor: pointer;
  transition: transform 0.12s ease;
}
.solid-btn:active { transform: scale(0.97); }

/* toggle switch */
.switch {
  width: 51px; height: 31px; border-radius: 999px; border: none;
  background: var(--card-2); position: relative; cursor: pointer;
  transition: background 0.24s ease;
}
.switch[aria-checked="true"] { background: var(--green); }
.switch .knob {
  position: absolute; top: 2px; left: 2px; width: 27px; height: 27px;
  background: #fff; border-radius: 50%; box-shadow: 0 2px 4px rgba(0,0,0,0.25);
  transition: transform 0.24s cubic-bezier(0.2, 0.8, 0.2, 1);
}
.switch[aria-checked="true"] .knob { transform: translateX(20px); }

/* button spinner */
.btn-spinner {
  width: 18px; height: 18px; border-radius: 50%;
  border: 2.5px solid var(--hairline); border-top-color: var(--accent);
  display: inline-block; animation: spin 0.7s linear infinite;
}
.btn-spinner.light { border-color: rgba(255,255,255,0.4); border-top-color: #fff; }

/* toast */
.toast {
  position: fixed; left: 50%; bottom: calc(28px + var(--safe-bottom));
  transform: translateX(-50%) translateY(20px);
  background: var(--text); color: var(--bg);
  padding: 12px 18px; border-radius: 14px; font-size: 14px; font-weight: 600;
  box-shadow: var(--shadow); z-index: 80; opacity: 0; pointer-events: none;
  transition: opacity 0.25s ease, transform 0.25s ease; max-width: 88vw; text-align: center;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* ===================== ANIMATIONS ===================== */
@keyframes spin { to { transform: rotate(360deg); } }
@keyframes rise { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: translateY(0); } }
@keyframes dropIn { from { opacity: 0; transform: translateY(-14px); } to { opacity: 1; transform: translateY(0); } }
@keyframes sheetUp { from { transform: translateY(100%); } to { transform: translateY(0); } }
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }
@keyframes slideIn { from { opacity: 0; transform: translateX(-8px); } to { opacity: 1; transform: translateX(0); } }
@keyframes chipIn { from { opacity: 0; transform: scale(0.8); } to { opacity: 1; transform: scale(1); } }

@media (prefers-reduced-motion: reduce) {
  * { animation-duration: 0.001ms !important; transition-duration: 0.001ms !important; }
}

/* number transition helper (applied by JS on value change) */
.bump { animation: bump 0.3s ease; }
@keyframes bump { 0% { transform: scale(1); } 40% { transform: scale(1.12); } 100% { transform: scale(1); } }

/* ===================== RESPONSIVE ===================== */
@media (min-width: 620px) {
  .app-view { max-width: 480px; margin: 0 auto; box-shadow: var(--shadow); }
  body { background: var(--bg-2); }
}
@media (max-height: 680px) {
  .hero-num .tabnum { font-size: 38px; }
  .sheet { max-height: 58%; }
}
@media (max-width: 340px) {
  .brand-name { font-size: 24px; }
  .go-btn { height: 54px; font-size: 19px; }
  .stat .tabnum { font-size: 16px; }
}
