/* ── Palette taken from the Android app (ui/theme/Color.kt) ── */
:root {
  color-scheme: light;
  --blue: #3978e0;          /* AppGreen / primary */
  --blue-dark: #2c5fb8;     /* header / pressed */
  --pass: #3978e0;          /* AppPass */
  --fail: #cb444a;          /* AppFail */
  --warning: #ff9800;       /* AppWarning */
  --text: #212121;          /* AppBlack */
  --muted: #616161;         /* AppDarkGrey */
  --bg: #ffffff;
  --surface: #f5f5f5;       /* AppLightGrey */
  --surface-2: #eeeeee;     /* AppVeryLightGrey */
  --card: #ffffff;
  --border: #e4e4e4;
  --plate-yellow: #f4d801;
  --plate-gb: #063298;
  --shadow: 0 2px 10px rgba(33, 33, 33, 0.08);
  --shadow-lg: 0 10px 30px rgba(33, 33, 33, 0.12);
}

html.dark {
  color-scheme: dark;
  --blue: #3978e0;
  --blue-dark: #1f1f1f;
  --pass: #3978e0;
  --fail: #cb444a;
  --text: #ffffff;
  --muted: #9e9e9e;
  --bg: #000000;
  --surface: #161616;
  --surface-2: #1f1f1f;
  --card: #121212;
  --border: #2a2a2a;
  --shadow: 0 2px 10px rgba(0, 0, 0, 0.5);
  --shadow-lg: 0 10px 30px rgba(0, 0, 0, 0.6);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: "Poppins", system-ui, -apple-system, "Segoe UI", sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
}

button,
input {
  font: inherit;
}

.hidden {
  display: none !important;
}

/* ── App bar ── */
.appbar {
  background: var(--blue);
  padding-bottom: 40px;
}

html.dark .appbar {
  background: var(--blue-dark);
  border-bottom: 1px solid var(--border);
}

.appbar-inner {
  max-width: 760px;
  margin: 0 auto;
  padding: 16px 20px 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
}

.mot-mark {
  display: grid;
  place-items: center;
}

.brand-title {
  color: #fff;
  font-weight: 700;
  font-size: 1.25rem;
  letter-spacing: 0.01em;
}

.icon-btn {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  border: none;
  background: rgba(255, 255, 255, 0.15);
  color: #fff;
  cursor: pointer;
  font-size: 1.1rem;
  display: grid;
  place-items: center;
  transition: background 0.15s ease;
}

.icon-btn:hover {
  background: rgba(255, 255, 255, 0.28);
}

/* ── Layout ── */
main {
  max-width: 760px;
  margin: 0 auto;
  padding: 0 20px 40px;
}

.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 16px;
  box-shadow: var(--shadow);
}

/* ── Search hero ── */
.hero {
  margin-top: -32px;
}

.search-card {
  background: var(--card);
  border-radius: 18px;
  box-shadow: var(--shadow-lg);
  padding: 22px;
}

.search-heading {
  margin: 0 0 16px;
  font-size: 1.15rem;
  font-weight: 700;
  text-align: center;
}

.search-form {
  display: grid;
  gap: 14px;
}

/* Number-plate styled input */
.plate {
  display: flex;
  align-items: stretch;
  height: 64px;
  background: var(--plate-yellow);
  border: 2px solid #111;
  border-radius: 10px;
  overflow: hidden;
}

.plate-gb {
  width: 46px;
  background: var(--plate-gb);
  color: #fff;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  flex-shrink: 0;
}

.plate-stars {
  font-size: 0.7rem;
  color: #ffd700;
  line-height: 1;
}

.plate-uk {
  font-weight: 700;
  font-size: 0.95rem;
  letter-spacing: 0.05em;
}

.plate input {
  flex: 1;
  min-width: 0;
  border: none;
  background: transparent;
  color: #111;
  text-align: center;
  font-weight: 700;
  font-size: 2rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.plate input::placeholder {
  color: rgba(17, 17, 17, 0.45);
}

.plate input:focus {
  outline: none;
}

.check-btn {
  border: none;
  border-radius: 12px;
  background: var(--blue);
  color: #fff;
  font-weight: 700;
  font-size: 1.05rem;
  padding: 16px;
  cursor: pointer;
  transition: background 0.15s ease, transform 0.1s ease;
}

.check-btn:hover {
  background: var(--blue-dark);
}

html.dark .check-btn:hover {
  background: #4d86e8;
}

.check-btn:active {
  transform: scale(0.99);
}

.search-hint {
  margin: 16px 0 0;
  text-align: center;
  color: var(--blue);
  font-weight: 500;
}

html.dark .search-hint {
  color: #6fa7ff;
}

/* Decorative plates */
.hero-art {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
  margin: 30px 0 10px;
}

.hero-swirl {
  width: 70px;
  height: auto;
  margin-bottom: 4px;
  opacity: 0.85;
}

html.dark .hero-swirl {
  filter: brightness(0) invert(1) opacity(0.6);
}

.plate-demo {
  width: 220px;
  max-width: 80%;
  text-align: center;
  font-weight: 700;
  font-size: 1.8rem;
  letter-spacing: 0.1em;
  padding: 12px 0;
  border: 2px solid #111;
  border-radius: 10px;
  color: #111;
}

.plate-demo--front {
  background: #fff;
}

.plate-demo--rear {
  background: var(--plate-yellow);
}

/* ── Results ── */
.results {
  margin-top: 22px;
  display: grid;
  gap: 16px;
}

.vehicle-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 18px;
}

.vehicle-head {
  display: flex;
  align-items: center;
  gap: 14px;
  min-width: 0;
}

.make-logo {
  width: 46px;
  height: 46px;
  border-radius: 12px;
  display: grid;
  place-items: center;
  flex-shrink: 0;
}

/* Dark mode: subtle light chip behind the logo so every make stays crisp. */
html.dark .make-logo {
  background: rgba(255, 255, 255, 0.92);
  padding: 4px;
}

.make-logo img {
  width: 80%;
  height: 80%;
  object-fit: contain;
}

/* When no make logo exists we fall back to the MOT mark (black source SVG);
   tint it to the brand blue so it shows in both light and dark mode. */
.make-logo img.make-fallback {
  width: 58%;
  height: 58%;
  filter: invert(40%) sepia(57%) saturate(1015%) hue-rotate(193deg) brightness(94%) contrast(88%);
}

.make {
  margin: 0;
  font-size: 1.2rem;
  font-weight: 700;
  text-transform: uppercase;
}

.model {
  margin: 2px 0 0;
  color: var(--muted);
  font-size: 0.9rem;
}

.reg-tag {
  flex-shrink: 0;
  background: var(--plate-yellow);
  color: #111;
  border: 2px solid #111;
  border-radius: 7px;
  padding: 6px 10px;
  font-weight: 700;
  letter-spacing: 0.08em;
}

/* Quick facts strip */
.facts {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 16px;
  box-shadow: var(--shadow);
  overflow: hidden;
}

.fact {
  padding: 14px 8px;
  text-align: center;
  border-right: 1px solid var(--border);
}

.fact:last-child {
  border-right: none;
}

.fact-label {
  display: block;
  color: var(--blue);
  font-size: 0.78rem;
  font-weight: 500;
  margin-bottom: 6px;
}

.fact-value {
  display: block;
  font-size: 0.95rem;
}

.fact-value.pass {
  color: var(--pass);
}

.fact-value.fail {
  color: var(--fail);
}

/* Info row */
.info-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}

.info-card {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 18px;
}

.info-icon {
  width: 28px;
  height: 28px;
  flex-shrink: 0;
  /* recolour the black source SVG to the brand blue */
  filter: invert(40%) sepia(57%) saturate(1015%) hue-rotate(193deg) brightness(94%) contrast(88%);
}

.info-label {
  margin: 0;
  color: var(--muted);
  font-size: 0.85rem;
}

.info-value {
  font-size: 1.05rem;
}

/* Valuation upsell */
.valuation-card,
.hpi-card {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 18px;
}

.valuation-icon {
  width: 48px;
  height: 48px;
  border-radius: 12px;
  background: var(--blue);
  display: grid;
  place-items: center;
  flex-shrink: 0;
}

.valuation-icon img {
  width: 24px;
  height: 24px;
  /* white on the blue tile */
  filter: brightness(0) invert(1);
}

.hpi-icon {
  width: 48px;
  height: 48px;
  border-radius: 12px;
  background: var(--surface);
  border: 1px solid var(--border);
  display: grid;
  place-items: center;
  font-size: 1.4rem;
  flex-shrink: 0;
}

.valuation-copy,
.hpi-copy {
  flex: 1;
  min-width: 0;
}

.valuation-title,
.hpi-title {
  margin: 0 0 3px;
  font-weight: 700;
}

.valuation-sub,
.hpi-sub {
  margin: 0;
  color: var(--muted);
  font-size: 0.88rem;
  line-height: 1.5;
}

.valuation-btn,
.hpi-btn {
  flex-shrink: 0;
  border: none;
  border-radius: 10px;
  padding: 12px 16px;
  font-weight: 700;
  cursor: pointer;
  transition: background 0.15s ease;
}

.valuation-btn {
  background: var(--blue);
  color: #fff;
}

.valuation-btn:hover {
  background: var(--blue-dark);
}

html.dark .valuation-btn:hover {
  background: #4d86e8;
}

.hpi-btn {
  background: transparent;
  color: var(--blue);
  border: 1.5px solid var(--blue);
}

.hpi-btn:hover {
  background: rgba(57, 120, 224, 0.08);
}

/* MOT history */
.history-title {
  margin: 8px 0 12px;
  font-size: 1.3rem;
}

.history-list {
  display: grid;
  gap: 14px;
}

.history-item {
  border: 1px solid var(--border);
  border-radius: 14px;
  overflow: hidden;
  box-shadow: var(--shadow);
  background: var(--card);
}

.history-banner {
  padding: 12px 16px;
  font-weight: 700;
  color: #fff;
}

.history-banner.pass {
  background: var(--blue);
}

.history-banner.fail {
  background: var(--fail);
}

.history-body {
  padding: 4px 16px 12px;
}

.history-line {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 9px 0;
  border-bottom: 1px solid var(--border);
  font-size: 0.9rem;
}

.history-line:last-child {
  border-bottom: none;
}

.history-line span {
  color: var(--muted);
}

.history-line strong {
  text-align: right;
  font-weight: 500;
}

.history-advisory strong {
  color: var(--warning);
}

/* ── App promo ── */
.app-promo {
  margin-top: 36px;
  text-align: center;
  padding: 28px 20px;
  background: var(--surface);
  border-radius: 18px;
}

.app-promo h3 {
  margin: 0 0 6px;
}

.app-promo p {
  margin: 0 0 18px;
  color: var(--muted);
}

.store-badges {
  display: flex;
  gap: 12px;
  justify-content: center;
  flex-wrap: wrap;
}

.store-badge {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  text-decoration: none;
  background: #111;
  color: #fff;
  border-radius: 12px;
  padding: 10px 18px;
  min-width: 160px;
}

html.dark .store-badge {
  background: #fff;
  color: #111;
}

.store-badge-icon {
  font-size: 1.5rem;
}

.store-badge small {
  display: block;
  font-size: 0.7rem;
  opacity: 0.85;
}

.store-badge strong {
  display: block;
  font-size: 1.05rem;
}

/* ── Footer ── */
.site-footer {
  text-align: center;
  color: var(--muted);
  font-size: 0.85rem;
  padding: 24px 20px 40px;
}

/* ── Modal ── */
.modal {
  position: fixed;
  inset: 0;
  z-index: 40;
  background: rgba(0, 0, 0, 0.5);
  display: grid;
  place-items: center;
  padding: 20px;
}

.modal-panel {
  width: min(440px, 100%);
  background: var(--card);
  border-radius: 18px;
  padding: 26px;
  box-shadow: var(--shadow-lg);
  position: relative;
}

.modal-close {
  position: absolute;
  top: 14px;
  right: 16px;
  border: none;
  background: transparent;
  color: var(--muted);
  font-size: 1.6rem;
  cursor: pointer;
  line-height: 1;
}

.modal-panel h2 {
  margin: 0 0 6px;
  font-size: 1.3rem;
}

.modal-intro {
  margin: 0 0 18px;
  color: var(--muted);
}

.auth-form,
.auth-step {
  display: grid;
  gap: 10px;
}

.auth-step {
  margin-top: 18px;
}

.auth-form label,
.auth-step label {
  font-weight: 500;
  font-size: 0.9rem;
}

.auth-form input,
.auth-step input {
  width: 100%;
  padding: 14px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--surface);
  color: var(--text);
}

.auth-form input:focus,
.auth-step input:focus {
  outline: 2px solid var(--blue);
  outline-offset: 0;
}

.auth-form button,
.auth-step button {
  border: none;
  background: var(--blue);
  color: #fff;
  border-radius: 12px;
  padding: 15px;
  font-weight: 700;
  cursor: pointer;
  margin-top: 4px;
}

.auth-form button:hover,
.auth-step button:hover {
  background: var(--blue-dark);
}

html.dark .auth-form button:hover,
html.dark .auth-step button:hover {
  background: #4d86e8;
}

/* ── Toast ── */
.toast {
  position: fixed;
  left: 50%;
  bottom: 24px;
  transform: translateX(-50%);
  padding: 14px 20px;
  border-radius: 12px;
  background: #212121;
  color: #fff;
  max-width: 90%;
  text-align: center;
  z-index: 60;
  box-shadow: var(--shadow-lg);
}

/* ── Responsive ── */
@media (max-width: 560px) {
  .facts {
    grid-template-columns: repeat(2, 1fr);
  }

  .fact:nth-child(2) {
    border-right: none;
  }

  .fact:nth-child(1),
  .fact:nth-child(2) {
    border-bottom: 1px solid var(--border);
  }

  .info-row {
    grid-template-columns: 1fr;
  }

  .valuation-card,
  .hpi-card {
    flex-wrap: wrap;
  }

  .valuation-btn,
  .hpi-btn {
    width: 100%;
  }

  .plate input {
    font-size: 1.6rem;
  }
}

/* ────────────────────────────────────────────────────────────
   Detail pages (valuation.html, check.html)
   Mirrors the Android Compose detail screens (RectView / CheckResult)
   ──────────────────────────────────────────────────────────── */

/* App bar variant with a back button + centred VRM */
.appbar-inner.detail {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
}

.back-btn {
  justify-self: start;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: #fff;
  text-decoration: none;
  font-weight: 500;
  padding: 6px 4px;
}

.back-btn:hover {
  opacity: 0.85;
}

.appbar-vrm {
  justify-self: center;
  color: #fff;
  font-weight: 700;
  font-size: 1.2rem;
  letter-spacing: 0.06em;
}

.appbar-inner.detail .appbar-actions {
  justify-self: end;
}

/* Icon tints (monochrome source SVGs recoloured to status colours) */
.tint-blue {
  filter: invert(40%) sepia(57%) saturate(1015%) hue-rotate(193deg) brightness(94%) contrast(88%);
}
.tint-red {
  filter: invert(33%) sepia(64%) saturate(1100%) hue-rotate(314deg) brightness(92%) contrast(90%);
}
.tint-amber {
  filter: invert(63%) sepia(92%) saturate(1180%) hue-rotate(360deg) brightness(103%) contrast(101%);
}
.tint-neutral {
  filter: none;
}
html.dark .tint-neutral {
  filter: invert(1);
}

/* Coloured text helpers */
.t-blue { color: var(--blue); }
.t-red { color: var(--fail); }
.t-amber { color: var(--warning); }
.t-muted { color: var(--muted); }

/* Page intro under the app bar */
.detail-main {
  max-width: 760px;
  margin: 0 auto;
  padding: 0 16px 40px;
}

.detail-title {
  text-align: center;
  color: var(--blue);
  font-weight: 700;
  font-size: 0.95rem;
  margin: 18px 0 6px;
}

/* Section banner (blue, rounded top) — matches Compose header rows */
.detail-banner {
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--blue);
  color: #fff;
  padding: 12px 16px;
  border-radius: 14px;
  font-weight: 700;
  margin: 16px 0 14px;
}

.detail-banner img {
  width: 22px;
  height: 22px;
  filter: brightness(0) invert(1);
}

/* ── Valuation rows (RectView) ── */
.val-list {
  display: grid;
  gap: 12px;
}

.val-row {
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: 54px;
  padding: 10px 16px;
  border: 2px solid var(--text);
  border-radius: 12px;
  background: var(--card);
}

.val-row.highlight {
  border: 2px solid transparent;
  background:
    linear-gradient(var(--card), var(--card)) padding-box,
    linear-gradient(90deg, #ff595a, #ffc766, #35a07f, #35a07f, #ffc766, #ff595a) border-box;
}

.val-row img {
  width: 26px;
  height: 26px;
  flex-shrink: 0;
}

.val-title {
  flex: 1;
  font-size: 0.95rem;
}

.val-amount {
  font-weight: 700;
  color: var(--muted);
  white-space: nowrap;
}

.val-row.highlight .val-amount {
  color: var(--blue);
}

/* ── Check rows (CheckResult) ── */
.check-list {
  display: grid;
}

.check-row {
  display: grid;
  grid-template-columns: 40px 1fr auto;
  align-items: start;
  gap: 8px;
  padding: 10px 4px;
  border-bottom: 1px solid var(--border);
}

.check-row .check-icon {
  width: 26px;
  height: 26px;
  margin-top: 2px;
}

.check-row .check-icon.flip {
  transform: rotate(180deg);
}

.check-text .check-title {
  font-weight: 700;
  font-size: 0.95rem;
  margin: 0;
}

.check-text .check-result {
  margin: 4px 0 0;
  font-size: 0.9rem;
  line-height: 1.5;
  white-space: pre-line;
}

.check-status {
  width: 24px;
  height: 24px;
  margin-top: 2px;
}

/* CO2 + extra details blocks */
.detail-block {
  margin-top: 20px;
}

.detail-block h3 {
  font-size: 1.05rem;
  margin: 0 0 10px;
}

.co2-img {
  width: 100%;
  max-width: 360px;
  height: auto;
}

.spec-list {
  display: grid;
  gap: 6px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.spec-list li {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  padding: 8px 0;
  border-bottom: 1px solid var(--border);
  font-size: 0.92rem;
}

.spec-list li span {
  color: var(--muted);
}

.spec-list li strong {
  font-weight: 500;
  text-align: right;
}

/* Support + share actions (from SupportEmail / ShareButton) */
.detail-actions {
  display: grid;
  gap: 12px;
  margin-top: 24px;
}

.detail-action {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  width: 100%;
  border: 1.5px solid var(--blue);
  background: transparent;
  color: var(--blue);
  border-radius: 12px;
  padding: 14px;
  font-weight: 700;
  font-size: 1rem;
  cursor: pointer;
  text-decoration: none;
}

.detail-action:hover {
  background: rgba(57, 120, 224, 0.08);
}

.detail-action.primary {
  background: var(--blue);
  color: #fff;
}

.detail-action.primary:hover {
  background: var(--blue-dark);
}

/* Disclaimer note */
.detail-note {
  margin-top: 18px;
  color: var(--muted);
  font-size: 0.82rem;
  line-height: 1.6;
  text-align: center;
}

/* ── Vehicle showcase: image + side nav buttons (SideButtonsView) ── */
.vehicle-showcase {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 8px 0 4px;
}

.showcase-img {
  flex: 1;
  min-width: 0;
}

.showcase-img img {
  display: block;
  width: 100%;
  /* crop the middle 60%: lose 20% top + 20% bottom of the 440x330 image */
  aspect-ratio: 440 / 198;
  object-fit: cover;
  object-position: center;
  border-radius: 12px;
}

.side-buttons {
  display: flex;
  flex-direction: column;
  gap: 10px;
  flex-shrink: 0;
}

/* Matches SideButton.kt: rounded tile, icon over label, blue→cyan gradient
   border when unselected, solid blue fill when selected. */
.side-button {
  width: 92px;
  min-height: 56px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  padding: 8px 4px;
  border-radius: 10px;
  border: 2px solid transparent;
  background:
    linear-gradient(var(--card), var(--card)) padding-box,
    linear-gradient(135deg, #3978e0, #00bcd4) border-box;
  color: var(--text);
  text-decoration: none;
  font-weight: 700;
  font-size: 0.8rem;
  line-height: 1.1;
  text-align: center;
  cursor: pointer;
}

.side-button img {
  width: 20px;
  height: 20px;
  filter: invert(40%) sepia(57%) saturate(1015%) hue-rotate(193deg) brightness(94%) contrast(88%);
}

.side-button.selected {
  background: var(--blue);
  border: 2px solid var(--blue);
  color: #fff;
}

.side-button.selected img {
  filter: brightness(0) invert(1);
}

@media (max-width: 480px) {
  .side-button {
    width: 76px;
    font-size: 0.72rem;
  }
}

/* "Get the app" page — back link */
.link-back {
  color: var(--blue);
  text-decoration: none;
  font-weight: 500;
}
.link-back:hover {
  text-decoration: underline;
}
