/* LumeRide Driver — app-specific layout (design system lives in design.css) */

/* --- Map dimming while offline ---
   The dim is a filter on #map only: it can dull the tiles, never hide
   them, and it never touches the loading/error overlays. --- */
#mapWrap { position: fixed; inset: 0; z-index: 0; }
#mapWrap #map { transition: filter .35s ease; }
#mapWrap.is-offline #map { filter: saturate(.6) brightness(.8); }

/* --- Map loading / error overlays (inside #mapWrap, above #map,
       below the top bar and bottom sheet) --- */
.map-overlay {
  position: absolute; inset: 0; z-index: 5;
  display: flex; align-items: center; justify-content: center;
  pointer-events: none;
}
.map-overlay[hidden] { display: none !important; }
.map-loading {
  /* Translucent scrim: the live map stays visible underneath while
     the branded loading state floats over it. */
  background: linear-gradient(rgba(11, 14, 17, .18), rgba(11, 14, 17, .42));
  transition: opacity .35s ease;
}
.map-loading-inner {
  display: flex; flex-direction: column; align-items: center; gap: 12px;
  padding: 22px 26px;
  background: rgba(11, 14, 17, .82);
  border: 1px solid rgba(229, 200, 148, .35);
  border-radius: 20px;
  box-shadow: var(--shadow-card);
  backdrop-filter: blur(8px);
}
.map-loading-badge { width: 44px; height: 44px; flex-basis: 44px; font-size: 16px; }
.map-loading-text { font-weight: 700; font-size: 15px; letter-spacing: .02em; }
.map-loading-shimmer {
  display: block; width: 120px; height: 6px; border-radius: 999px;
  background: linear-gradient(90deg, var(--panel-2) 25%, #3a4350 50%, var(--panel-2) 75%);
  background-size: 240px 100%;
  animation: map-shimmer 1.3s infinite linear;
}
@keyframes map-shimmer {
  0% { background-position: -120px 0; }
  100% { background-position: 120px 0; }
}
.map-error { background: rgba(11, 14, 17, .55); pointer-events: auto; }
.map-error-card {
  display: flex; flex-direction: column; align-items: center; gap: 10px;
  max-width: 300px; margin: 0 20px; padding: 24px 22px; text-align: center;
  background: var(--panel); border: 1px solid rgba(229, 83, 75, .5);
  border-radius: 20px; box-shadow: var(--shadow-card);
}
.map-error-title { font-size: 18px; font-weight: 800; }
.map-error-text { font-size: 14px; color: var(--muted); line-height: 1.45; }
.map-error-card .btn { width: 100%; margin-top: 4px; }

/* --- Online control in the top bar (design.css styles .topbar/.switch) --- */
/* Right cluster: notification bell + online control. The map
   carries no brand overlay, so the cluster hugs the right edge. */
.topbar-right { display: flex; align-items: center; gap: 10px; margin-left: auto; }
.online-control {
  display: flex; align-items: center; gap: 12px;
  background: rgba(11, 14, 17, .88); color: var(--text);
  border: 1px solid rgba(229, 200, 148, .35); border-radius: 999px;
  padding: 8px 8px 8px 18px; backdrop-filter: blur(8px);
  box-shadow: var(--shadow-card);
  transition: border-color .2s ease, background .2s ease;
}
.online-label { font-weight: 700; font-size: 16px; letter-spacing: .02em; white-space: nowrap; }
/* Unmissable when online: gold ring + gold label + larger switch. */
.online-control.is-online {
  border-color: rgba(229, 200, 148, .8);
  background: rgba(229, 200, 148, .16);
}
.online-control.is-online .online-label { color: var(--gold); }
.online-control .switch { width: 88px; height: 52px; flex-basis: 88px; }
.online-control .switch .switch-track::after { width: 42px; height: 42px; top: 4px; left: 4px; }
.online-control .switch input:checked + .switch-track::after { transform: translateX(38px); }
.switch input:disabled + .switch-track { opacity: .45; }

/* --- Bottom stack: FAB + request card + sheet flow together so the
       request card always sits directly above the sheet --- */
.bottom-ui {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 40;
  display: flex; flex-direction: column; gap: 10px;
  padding: 0 12px calc(10px + env(safe-area-inset-bottom, 0px));
  pointer-events: none;
}
.bottom-ui > * { pointer-events: auto; }
.bottom-ui .sheet {
  position: relative; left: auto; right: auto; bottom: auto;
  transform: none; width: 100%; max-width: 560px; margin: 0 auto;
  border: 1px solid var(--line);
  border-radius: var(--sheet-radius);
  max-height: 62vh; min-height: 0;
}
.fab-row { display: flex; justify-content: flex-end; padding-right: 2px; pointer-events: none; }
.fab-row .fab { pointer-events: auto; }

/* --- Stat internals (design.css styles .stat/.stat-grid shells) --- */
.stat > span { display: block; font-size: 12px; color: var(--muted); letter-spacing: .03em; }
.stat > strong { display: block; margin-top: 2px; font-size: 20px; font-weight: 800; }

/* --- Request card --- */
.request-card {
  width: 100%; max-width: 560px; margin: 0 auto;
  padding: 16px;
  background: var(--panel); color: var(--text);
  border: 1px solid rgba(229, 200, 148, .45); border-radius: var(--radius);
  box-shadow: var(--shadow-card);
  animation: req-in .28s ease;
}
@keyframes req-in { from { transform: translateY(16px); opacity: 0; } to { transform: translateY(0); opacity: 1; } }
.request-progress { margin-bottom: 12px; }
.request-progress .progress-fill { transition: width .1s linear; }
.request-head { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; margin-bottom: 10px; }
.request-tier { font-weight: 800; font-size: 17px; }
.request-countdown { font-variant-numeric: tabular-nums; font-weight: 700; color: var(--gold); }
.request-places { display: grid; gap: 10px; margin-bottom: 12px; }
.place-row { display: flex; gap: 10px; align-items: flex-start; }
.place-row > div { display: flex; flex-direction: column; min-width: 0; }
.place-label { font-size: 11px; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); }
.place-dot { width: 11px; height: 11px; border-radius: 50%; margin-top: 4px; flex: none; }
.place-dot-pickup { background: #69ccad; box-shadow: 0 0 0 3px rgba(105, 204, 173, .25); }
.place-dot-dropoff { background: var(--gold); border-radius: 3px; box-shadow: 0 0 0 3px rgba(229, 200, 148, .22); }
.request-loading .skeleton-line { margin-bottom: 8px; }
.request-meta { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 14px; font-weight: 600; }
.request-fares { display: flex; flex-direction: column; align-items: flex-end; gap: 2px; }
.request-earn { color: var(--gold); font-size: 17px; }
.request-actions { display: grid; grid-template-columns: 1fr 1.4fr; gap: 10px; }
.request-actions .btn { width: 100%; }

/* --- Sheet content --- */
.sheet-view { padding-top: 10px; }
.sheet-hint, .microcopy { font-size: 13px; color: var(--muted); margin: 10px 0 2px; }
.mini-stats { margin-top: 4px; }

/* --- Trip panel (design.css styles .trip-phase type) --- */
.trip-phase { margin: 2px 0 10px; }
.trip-place { margin-bottom: 12px; }
.trip-place strong { font-size: 17px; }
.trip-meta { font-size: 13px; color: var(--muted); margin-top: 2px; }
.trip-nav { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-bottom: 10px; }
.trip-nav .btn { text-decoration: none; }
.trip-action { width: 100%; }

/* --- Summary --- */
.sum-route { font-weight: 600; margin: 0 0 10px; }
.sum-earn { display: flex; align-items: baseline; gap: 8px; margin: 12px 0; }
.sum-earn strong { color: var(--gold); font-size: 26px; }
.sum-estimate { font-size: 12px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); }

/* --- Earnings --- */
.recent-trips { margin: 6px 0 14px; }
/* Metrics card (Earnings): stacked stat grids from js/app.js. */
.metrics-card .stat-grid + .stat-grid { margin-top: 10px; }
.metrics-card .microcopy { margin-top: 12px; }
.recent-empty { font-size: 13px; color: var(--muted); margin: 6px 0 14px; }
.payout-card {
  padding: 16px; margin-top: 6px;
  background: var(--panel-2); border: 1px solid var(--line); border-radius: var(--radius);
}
.payout-card h2 { margin: 0 0 6px; font-size: 17px; }
.payout-card > p { font-size: 13.5px; line-height: 1.45; color: var(--muted); }
.payout-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 12px; }
.payout-actions .btn { width: 100%; }
.payout-card .status-line { margin-top: 10px; word-break: break-word; }

/* --- Recenter FAB: larger target so it is easy to hit while driving --- */
.fab-row .fab { width: 56px; height: 56px; }

/* --- Build badge: subtle footer line at the bottom of the sheet --- */
.build-badge {
  margin: 18px 0 2px;
  text-align: center;
  font-size: 12px;
  letter-spacing: .04em;
  color: var(--muted);
  opacity: .85;
}

/* --- Toast visibility helper (design.css styles .toast look) --- */
.toast[hidden] { display: none !important; }

/* ── Auth gate ───────────────────────────────────────────────
   Full-screen branded sign-in / sign-up gate. Shown first when
   there is no Supabase session; #appRoot stays hidden until
   sign-in succeeds (js/app.js boot flow). */
#appRoot[hidden] { display: none; }
.auth-gate {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px 20px calc(24px + env(safe-area-inset-bottom, 0px));
  overflow-y: auto;
  background:
    radial-gradient(120% 90% at 50% 0%, rgba(229, 200, 148, .13), transparent 55%),
    var(--coal);
}
.auth-gate[hidden] { display: none; }
.auth-card { width: 100%; max-width: 380px; text-align: center; }
.auth-mark {
  width: 54px; height: 54px;
  font-size: 20px;
  border-radius: 16px;
  margin-bottom: 16px;
}
.auth-sub { color: var(--muted); font-size: var(--text-caption); margin: 8px 0 28px; }
.auth-form { text-align: left; }
.auth-seg { margin-bottom: 20px; }
.auth-state .spinner { margin-bottom: 14px; }
.auth-note { color: var(--muted); font-size: 14px; }
.auth-state-title { font-size: var(--text-title); font-weight: 700; margin-bottom: 8px; }
.auth-form .auth-note { margin-bottom: 18px; }
.auth-link {
  display: inline-block;
  margin: 2px 0 14px;
  padding: 4px 2px;
  background: none;
  border: 0;
  color: var(--gold);
  font: inherit;
  font-size: 14px;
  cursor: pointer;
}

/* ── Account card (Earnings view) ── */
.account-email { font-weight: 600; color: var(--text); word-break: break-all; }

/* ── Vehicle card (Earnings view) ──
   Reuses .payout-card / .field / .switch from the design system.
   The status pill is computed live in js/app.js (renderVehicle):
   neutral while there is nothing to judge, green (--ok) when the
   vehicle is eligible (2016+ or the passed-inspection exception),
   red (--danger) when a pre-2016 vehicle still needs an inspection. */
.vehicle-status {
  padding: 11px 13px;
  margin: 2px 0 12px;
  border: 1px solid var(--line);
  border-radius: 12px;
  font-size: 13.5px;
  line-height: 1.45;
  color: var(--muted);
}
.vehicle-status.is-ok {
  color: var(--text);
  background: rgba(63, 182, 139, .1);
  border-color: rgba(63, 182, 139, .45);
}
.vehicle-status.is-bad {
  color: var(--text);
  background: rgba(229, 83, 75, .1);
  border-color: rgba(229, 83, 75, .4);
}
.vehicle-check {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 2px 0 4px;
}
.vehicle-check-label { font-size: 14px; font-weight: 600; line-height: 1.4; cursor: pointer; }
.vehicle-policy { font-size: 13px; color: var(--muted); line-height: 1.45; margin: 4px 0 10px; }
.vehicle-save { margin-top: 2px; }

/* ── Account theme row (Earnings → Account card) ── */
.account-theme-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-top: 12px;
}
.account-theme-row > span { font-size: 13.5px; font-weight: 600; }

/* ── Light theme (Build 7) ─────────────────────────────────────
   Token flips live in design.css; these are the driver surfaces
   with hard-coded dark values (map overlays, online pill). */
[data-theme="light"] .map-loading {
  background: linear-gradient(rgba(250, 248, 244, .22), rgba(250, 248, 244, .5));
}
[data-theme="light"] .map-loading-inner {
  background: rgba(255, 255, 255, .88);
  border-color: var(--gold-line);
}
[data-theme="light"] .map-loading-shimmer {
  background: linear-gradient(90deg, var(--panel-2) 25%, #e0d8c4 50%, var(--panel-2) 75%);
  background-size: 240px 100%;
}
[data-theme="light"] .map-error { background: rgba(250, 248, 244, .55); }
[data-theme="light"] .online-control {
  background: rgba(255, 255, 255, .9);
}
[data-theme="light"] .online-control.is-online { background: rgba(168, 127, 36, .14); }
/* The offline dim must not wash out the light basemap. */
[data-theme="light"] #mapWrap.is-offline #map { filter: saturate(.65) brightness(.97); }
