/* GarageX — CSS custom properties for theming, same convention as EchoX */
:root {
  --bg: #f5f6fa;
  --card-bg: #ffffff;
  --text: #1a1a2e;
  --text2: #4a4a68;
  --muted: #7a7a94;
  --border: #e0e0ec;
  --accent: #2e7d5b;
  --accent-text: #ffffff;
  --error: #c0392b;
  --nav-h: 56px;
}

html[data-theme="dark"] {
  --bg: #111120;
  --card-bg: #1a1a2e;
  --text: #f0f0f8;
  --text2: #c4c4e0;
  --muted: #9090b8;
  --border: #2e2e50;
  --accent: #3fae7f;
  --accent-text: #0b1210;
  --error: #e57368;
}

* { box-sizing: border-box; }

/* Class-based display rules below (e.g. .modal-overlay{display:flex}) tie in
   CSS specificity with the UA stylesheet's [hidden]{display:none} and lose on
   source order — this makes [hidden] always win instead. Toggle visibility
   via the hidden attribute/property everywhere, never inline style.display. */
[hidden] { display: none !important; }

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
}

/* ── Auth screen ─────────────────────────────────────────────── */
.auth-card {
  width: 100%;
  max-width: 360px;
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 28px 24px;
}

.auth-logo {
  margin: 0 0 20px;
  text-align: center;
  font-size: 24px;
  font-weight: 700;
  color: var(--accent);
}

.auth-form h2 {
  margin: 0 0 16px;
  font-size: 18px;
}

/* Applies to every form in the app (auth screens + all modals), not just
   .auth-form — found via a real bug: the Document modal's plain text label
   had no .form-row wrapper and no native-widget fallback (unlike a date
   input), so it rendered fully unstyled when these rules were auth-only. */
label {
  display: block;
  margin-bottom: 14px;
  font-size: 13px;
  color: var(--text2);
}

input:not([type="checkbox"]):not([type="radio"]) {
  display: block;
  width: 100%;
  margin-top: 6px;
  padding: 10px 12px;
  font-size: 15px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--bg);
  color: var(--text);
}

input:focus {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
}

.btn-primary {
  width: 100%;
  padding: 12px;
  font-size: 15px;
  font-weight: 600;
  border: none;
  border-radius: 8px;
  background: var(--accent);
  color: var(--accent-text);
  cursor: pointer;
}

.btn-primary:disabled { opacity: 0.6; cursor: default; }

.btn-link {
  background: none;
  border: none;
  color: var(--accent);
  font-size: 14px;
  cursor: pointer;
}

.auth-links {
  margin: 16px 0 0;
  text-align: center;
  font-size: 13px;
}

.auth-links a {
  color: var(--accent);
  text-decoration: none;
}

.field-note { font-size: 12px; color: var(--muted); margin: -8px 0 14px; }
.field-error {
  font-size: 13px;
  color: var(--error);
  background: color-mix(in srgb, var(--error) 12%, transparent);
  border-radius: 8px;
  padding: 8px 10px;
  margin: 0 0 14px;
}

/* ── Authenticated shell ─────────────────────────────────────── */
#top-bar {
  height: var(--nav-h);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 16px;
  /* index.html's viewport-fit=cover lets the page draw under the
     notch/Dynamic Island/status bar (needed for a full-bleed edge-to-edge
     look) — which means WE now have to keep top content clear of it
     ourselves. env() resolves to 0 on non-notched screens, so this is a
     no-op there; on iOS Safari and the native shell alike, it pushes the
     bar down below the unsafe area instead of rendering underneath it. */
  padding-top: env(safe-area-inset-top);
  border-bottom: 1px solid var(--border);
  background: var(--card-bg);
}

.app-title { font-weight: 700; color: var(--accent); }
.topbar-account { flex: 1; margin-left: 14px; font-size: 13px; color: var(--muted); }

.tier-badge {
  border: none;
  border-radius: 999px;
  padding: 3px 10px;
  margin-right: 14px;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.02em;
  cursor: pointer;
  background: color-mix(in srgb, var(--muted) 18%, transparent);
  color: var(--muted);
}
.tier-badge.is-pro {
  background: color-mix(in srgb, var(--accent) 18%, transparent);
  color: var(--accent);
  cursor: default;
}

.toast-banner {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 14px;
  flex-wrap: wrap;
  padding: 10px 16px;
  /* Same safe-area reasoning as #top-bar — this is position:fixed at top:0,
     the most exposed case of all (found via the same iOS device screenshot
     that caught #top-bar/.landing-nav). */
  padding-top: max(10px, env(safe-area-inset-top));
  background: var(--accent);
  color: var(--accent-text);
  font-size: 13px;
  text-align: center;
}
.toast-banner .btn-link { color: var(--accent-text); font-weight: 700; text-decoration: underline; }

.ad-banner {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  padding: 10px 16px;
  background: var(--card-bg);
  border-top: 1px solid var(--border);
  font-size: 13px;
  color: var(--muted);
}
.ad-banner-message {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  width: 100%;
}
.ad-slot { display: flex; justify-content: center; max-width: 100%; overflow: hidden; }

.upgrade-feature-list {
  margin: 0 0 16px;
  padding-left: 20px;
  font-size: 14px;
  color: var(--text2);
}
.upgrade-feature-list li { margin-bottom: 6px; }

.upgrade-note-link {
  background: none;
  border: none;
  padding: 0;
  font: inherit;
  color: var(--accent);
  text-decoration: underline;
  cursor: pointer;
}

#main-nav {
  display: flex;
  gap: 4px;
  padding: 8px 16px 0;
  background: var(--card-bg);
  border-bottom: 1px solid var(--border);
}

.nav-tab {
  border: none;
  background: none;
  padding: 8px 14px;
  font-size: 14px;
  font-weight: 600;
  color: var(--muted);
  cursor: pointer;
  border-bottom: 2px solid transparent;
}
.nav-tab.active { color: var(--accent); border-bottom-color: var(--accent); }

#app-content { padding: 20px 16px; max-width: 640px; margin: 0 auto; }

#dashboard-charts h3 { margin: 20px 0 10px; font-size: 15px; }
#dashboard-charts h3:first-child { margin-top: 0; }
#dashboard-vehicle-select {
  width: auto;
  margin-top: 0;
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--card-bg);
  color: var(--text);
  font-size: 14px;
}

/* ── Garage ──────────────────────────────────────────────────── */
.section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
}
.section-header h2 { margin: 0; font-size: 20px; }

.btn-small { width: auto; padding: 8px 14px; font-size: 13px; }

.btn-secondary {
  padding: 10px 16px;
  font-size: 14px;
  font-weight: 600;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--card-bg);
  color: var(--text);
  cursor: pointer;
}

.btn-danger {
  padding: 10px 16px;
  font-size: 14px;
  font-weight: 600;
  border: 1px solid var(--error);
  border-radius: 8px;
  background: none;
  color: var(--error);
  cursor: pointer;
}

.vehicle-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 14px;
}

.vehicle-card {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px;
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: 12px;
  cursor: pointer;
  text-align: left;
}

.vehicle-avatar {
  flex: none;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  color: var(--accent-text);
  background: var(--accent);
  overflow: hidden;
}
.vehicle-avatar img { width: 100%; height: 100%; object-fit: cover; }

.vehicle-detail-photo {
  width: 100%;
  max-height: 200px;
  object-fit: cover;
  border-radius: 10px;
  margin-bottom: 14px;
}

.record-row-link { color: var(--accent); text-decoration: none; font-size: 12px; }

/* ── Landing page ────────────────────────────────────────────────── */
#view-landing { background: var(--bg); min-height: 100dvh; }

.landing-nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px 24px;
  /* Same safe-area reasoning as #top-bar above — max() keeps the normal
     18px on non-notched screens instead of collapsing it to 0. */
  padding-top: max(18px, env(safe-area-inset-top));
  max-width: 1140px;
  margin: 0 auto;
}
.landing-logo { font-weight: 700; font-size: 20px; color: var(--accent); }
.landing-nav nav { display: flex; align-items: center; gap: 16px; }

.landing-hero-band {
  background:
    radial-gradient(ellipse 900px 500px at 15% -10%, color-mix(in srgb, var(--accent) 16%, transparent), transparent),
    var(--bg);
}

.landing-hero {
  max-width: 1140px;
  margin: 0 auto;
  padding: 20px 24px 56px;
  display: flex;
  flex-direction: column;
  gap: 32px;
}
.landing-hero h1 { font-size: 32px; line-height: 1.15; margin: 0 0 16px; letter-spacing: -0.01em; }
.landing-subhead { font-size: 16px; color: var(--text2); margin: 0 0 22px; max-width: 46ch; }
.landing-cta { width: auto; padding: 14px 28px; font-size: 16px; display: inline-block; }
.landing-demo-link { margin-left: 16px; font-size: 15px; }
/* .field-note's -8px top margin is tuned for sitting directly under a form
   input (auth forms) — reused here for the CTA caption, where it instead
   pulls the text up into the button above it. Reset to normal spacing. */
.landing-hero-copy .field-note { margin-top: 14px; }

/* ── Demo mode ───────────────────────────────────────────────────── */
.demo-banner {
  display: none;
  align-items: center;
  justify-content: center;
  gap: 12px;
  padding: 10px 16px;
  background: color-mix(in srgb, var(--accent) 15%, transparent);
  color: var(--accent);
  font-size: 13px;
  text-align: center;
}
body.is-demo-mode .demo-banner { display: flex; }
body.is-demo-mode .demo-hide { display: none !important; }

.landing-hero-visual {
  display: flex;
  flex-direction: column;
  gap: 14px;
  perspective: 1200px;
}
.mock-vehicle-card {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 16px;
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: 12px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.08);
  transition: transform 0.25s ease;
}
.mock-vehicle-card .status-pill { margin-left: auto; }

.landing-features, .landing-pricing {
  max-width: 1140px;
  margin: 0 auto;
  padding: 64px 24px;
}
.landing-pricing { background: color-mix(in srgb, var(--accent) 4%, transparent); border-radius: 32px; }
.landing-features h2, .landing-pricing h2 {
  text-align: center;
  font-size: 28px;
  margin: 0 0 40px;
}

.feature-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 20px;
}
.feature-card {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 26px 22px;
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}
.feature-icon {
  font-size: 26px;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 52px;
  height: 52px;
  border-radius: 12px;
  background: color-mix(in srgb, var(--accent) 12%, transparent);
  margin-bottom: 16px;
}
.feature-card h3 { margin: 0 0 8px; font-size: 16px; }
.feature-card p { margin: 0; font-size: 14px; color: var(--text2); }

.pricing-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 24px;
  max-width: 640px;
  margin: 0 auto;
}
.pricing-card {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 28px 24px;
  text-align: center;
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}
.pricing-card-featured { border-color: var(--accent); border-width: 2px; position: relative; }
.pricing-card-featured::before {
  content: "MOST POPULAR";
  position: absolute;
  top: -12px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--accent);
  color: var(--accent-text);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.05em;
  padding: 4px 12px;
  border-radius: 999px;
}
.pricing-card h3 { margin: 0 0 6px; font-size: 15px; color: var(--muted); text-transform: uppercase; letter-spacing: 0.04em; }
.pricing-price { font-size: 34px; font-weight: 700; margin: 0 0 18px; }
.pricing-price span { font-size: 15px; font-weight: 400; color: var(--muted); }
.pricing-features { list-style: none; padding: 0; margin: 0 0 22px; text-align: left; }
.pricing-features li {
  padding: 8px 0 8px 24px;
  position: relative;
  font-size: 14px;
  color: var(--text2);
  border-bottom: 1px solid var(--border);
}
.pricing-features li:last-child { border-bottom: none; }
.pricing-features li::before { content: "✓"; position: absolute; left: 0; color: var(--accent); font-weight: 700; }
.pricing-cta { width: 100%; }

.landing-footer {
  max-width: 1140px;
  margin: 0 auto;
  padding: 24px 24px 48px;
  display: flex;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 10px;
  font-size: 13px;
  color: var(--muted);
}
.landing-footer a { color: var(--muted); }

/* Hover depth reads as "designed for a mouse" — harmless no-op on touch. */
@media (hover: hover) {
  .feature-card:hover, .pricing-card:hover {
    transform: translateY(-4px);
    box-shadow: 0 12px 28px rgba(0, 0, 0, 0.08);
  }
  .landing-hero-visual:hover .mock-vehicle-card:first-child { transform: rotate(0deg) translateY(-2px); }
}

@media (min-width: 760px) {
  .landing-hero { flex-direction: row; align-items: center; padding-top: 48px; gap: 56px; }
  .landing-hero-copy { flex: 1; }
  .landing-hero-visual { flex: 1; }
  .landing-hero h1 { font-size: 42px; }
  .mock-vehicle-card:first-child { transform: rotate(-1.5deg); }
  .mock-vehicle-card:last-child { transform: rotate(1deg) translateX(24px); }
}

@media (min-width: 1080px) {
  .landing-hero { padding-top: 76px; padding-bottom: 76px; }
  .landing-hero h1 { font-size: 52px; }
  .landing-subhead { font-size: 18px; }
  .landing-features, .landing-pricing { padding-top: 84px; padding-bottom: 84px; }
}

/* ── Auth modal (landing page's Log in / Sign up) ───────────────────── */
.auth-card { position: relative; }
.auth-modal-close {
  position: absolute;
  top: 12px;
  right: 14px;
  background: none;
  border: none;
  font-size: 22px;
  line-height: 1;
  color: var(--muted);
  cursor: pointer;
  padding: 4px;
}

.vehicle-card-title { font-weight: 600; }
.vehicle-card-sub { font-size: 13px; color: var(--muted); margin-top: 2px; }

.vehicle-detail-card {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 20px;
  margin: 16px 0;
}
.vehicle-detail-card h3 { margin: 0 0 4px; }
.vehicle-detail-card .vd-sub { color: var(--muted); margin: 0 0 16px; }
.vehicle-detail-card dl { display: grid; grid-template-columns: auto 1fr; gap: 6px 12px; margin: 0; }
.vehicle-detail-card dt { color: var(--muted); font-size: 13px; }
.vehicle-detail-card dd { margin: 0; font-size: 13px; }

.detail-actions { display: flex; gap: 10px; margin-bottom: 16px; }

/* ── Modal ───────────────────────────────────────────────────── */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.45);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  z-index: 500;
}

.modal-card {
  width: 100%;
  max-width: 420px;
  max-height: 90dvh;
  overflow-y: auto;
  background: var(--card-bg);
  border-radius: 16px;
  padding: 24px;
}

.modal-card h2 { margin: 0 0 16px; font-size: 18px; }

.form-row { display: flex; gap: 12px; }
.form-row label { flex: 1; }

.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 14px;
  margin-top: 6px;
}
.modal-actions .btn-primary { width: auto; }
.record-delete-link { margin-right: auto; color: var(--error); }

select {
  display: block;
  width: 100%;
  margin-top: 6px;
  padding: 10px 12px;
  font-size: 15px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--bg);
  color: var(--text);
}

.field-optional { font-weight: 400; color: var(--muted); }

/* ── Record list (Service History / Fuel Log) ───────────────────── */
.record-list { display: flex; flex-direction: column; gap: 8px; margin-top: 12px; }

.record-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 14px;
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: 10px;
  cursor: pointer;
  text-align: left;
}

.record-row-main { font-weight: 600; font-size: 14px; }
.record-row-sub { font-size: 12px; color: var(--muted); margin-top: 2px; }
.record-row-cost { font-weight: 600; white-space: nowrap; }

.upgrade-note {
  background: color-mix(in srgb, var(--accent) 12%, transparent);
  color: var(--accent);
  border-radius: 8px;
  padding: 10px 12px;
  margin-top: 10px;
}

/* ── Reminder status pills ───────────────────────────────────────── */
.status-pill {
  display: inline-block;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.02em;
  border-radius: 999px;
  padding: 3px 9px;
  white-space: nowrap;
}
.status-pill.overdue { background: color-mix(in srgb, var(--error) 18%, transparent); color: var(--error); }
.status-pill.soon { background: color-mix(in srgb, #b8860b 18%, transparent); color: #b8860b; }
.status-pill.ok { background: color-mix(in srgb, var(--muted) 18%, transparent); color: var(--muted); }
.status-pill.paused { background: color-mix(in srgb, var(--muted) 12%, transparent); color: var(--muted); }

.checkbox-label {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  color: var(--text2);
  margin-bottom: 14px;
}
.checkbox-label input { width: auto; margin: 0; }

/* Due-soon badge on a Garage vehicle card */
.vehicle-card { position: relative; }
.vehicle-card-badge {
  position: absolute;
  top: 10px;
  right: 10px;
}

/* Quiet footer link for account deletion — present (Play requires an in-app
   path) but deliberately low-key so it isn't mistaken for a primary action. */
.account-footer { margin-top: 40px; text-align: center; font-size: 12px; }
.account-footer a { color: var(--muted); }

/* In demo mode the read-only banner, not #top-bar, is the topmost element,
   so the safe-area padding has to move to it — otherwise the banner renders
   under the status bar and #top-bar leaves an empty gap below it (caught in
   the Play Store screenshot pass on Android). */
body.is-demo-mode .demo-banner { padding-top: max(10px, env(safe-area-inset-top)); }
body.is-demo-mode #top-bar { padding-top: 0; }

/* #top-bar has a fixed height and the global border-box sizing, so its
   safe-area padding-top was being carved out of that height instead of added
   to it — the bar's contents got pushed under the status bar on every signed-in
   screen (found in the Play screenshot pass). Grow the height by the inset. */
#top-bar { height: calc(var(--nav-h) + env(safe-area-inset-top)); }
body.is-demo-mode #top-bar { height: var(--nav-h); }
