/* ============================================================
   CURBLOW — bold automotive UI system
   Orange = brand/action · Green = savings/good deal · Amber = caution · Red = danger
   (CSS variable names + component class names are kept stable so app.js keeps working.)
   ============================================================ */

:root {
  --bg:        #09090B;
  --bg-2:      #0D0D10;
  --bg-3:      #17171C;   /* app.js: dropdowns/selects */
  --bg-4:      #22222A;   /* app.js: hover */
  --surface:   #101014;
  --surface-2: #16161C;

  --text:   #FAFAFA;
  --text-2: #9A9AA6;   /* app.js */
  --text-3: #62626D;   /* app.js */

  --border:       rgba(255,255,255,0.07);   /* app.js */
  --border-light: rgba(255,255,255,0.13);   /* app.js */

  --accent:    #FF6A2B;                 /* Curblow orange — brand + action */
  --accent-2:  #A6EE4E;                 /* volt green — savings / good deal */
  --accent-bg: rgba(255,106,43,0.12);
  --green-bg:  rgba(166,238,78,0.11);
  --amber:  #F5B451;  --amber-bg: rgba(245,180,81,0.10);   /* app.js */
  --red:    #FF5C5C;  --red-bg:   rgba(255,92,92,0.10);
  --violet: #B8AEF0;

  --radius: 14px;                                 /* app.js */
  --ease:   cubic-bezier(0.32, 0.72, 0, 1);
  --font-display: "Clash Display", "Space Grotesk", "Plus Jakarta Sans", sans-serif;
  --font-body:    "Plus Jakarta Sans", system-ui, sans-serif;
  --maxw: 1160px;
}

* { margin: 0; padding: 0; box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
  font-family: var(--font-body);
  background: var(--bg);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  min-height: 100vh;
  overflow-x: hidden;
}

/* Ambient brand glow + film grain (fixed, GPU-cheap) */
body::before {
  content: ""; position: fixed; inset: 0; z-index: 0; pointer-events: none;
  background:
    radial-gradient(60% 45% at 78% -5%, rgba(255,106,43,0.16), transparent 60%),
    radial-gradient(50% 40% at 10% 8%, rgba(166,238,78,0.06), transparent 60%);
}
body::after {
  content: ""; position: fixed; inset: 0; z-index: 1; pointer-events: none; opacity: 0.035;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='140' height='140'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='3'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
}
main, nav, .modal-overlay { position: relative; z-index: 2; }

::selection { background: rgba(255,106,43,0.28); color: #fff; }

/* ---------------- NAV (floating glass island) ---------------- */
.nav {
  position: sticky; top: 0; z-index: 40;
  padding: 18px 20px 0;
}
.nav-inner {
  max-width: var(--maxw); margin: 0 auto;
  display: flex; align-items: center; justify-content: space-between;
  padding: 11px 12px 11px 18px;
  background: rgba(18,18,22,0.72);
  backdrop-filter: blur(20px) saturate(140%);
  -webkit-backdrop-filter: blur(20px) saturate(140%);
  border: 1px solid var(--border);
  border-radius: 999px;
  box-shadow: 0 12px 40px -18px rgba(0,0,0,0.8), inset 0 1px 0 rgba(255,255,255,0.04);
}
.logo {
  display: inline-flex; align-items: center; gap: 11px;
  font-family: var(--font-display);
  font-weight: 600; font-size: 20px; letter-spacing: -0.02em;
  color: var(--text); text-decoration: none;
}
.logo .logo-mark {
  width: 30px; height: 30px; border-radius: 9px; flex-shrink: 0;
  display: grid; place-items: center;
  background: linear-gradient(150deg, #1b1b1f, #0c0c0e);
  border: 1px solid var(--border-light);
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.08);
}
.logo .logo-mark svg { display: block; }
.logo b { color: var(--accent); font-weight: 600; }

.nav-links { display: flex; align-items: center; gap: 4px; }
.nav-link {
  font-size: 14px; font-weight: 500; color: var(--text-2); text-decoration: none;
  padding: 8px 16px; border-radius: 999px;
  transition: color .4s var(--ease), background .4s var(--ease);
}
.nav-link:hover { color: var(--text); }
.nav-link.active { color: #0a0a0a; background: var(--accent); box-shadow: 0 4px 16px -4px rgba(255,106,43,0.6); }

/* ---------------- PAGES ---------------- */
main { max-width: var(--maxw); margin: 0 auto; padding: 0 20px 120px; }
.page { display: none; animation: pageIn .6s var(--ease); }
.page.active { display: block; }
@keyframes pageIn { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }

/* ---------------- HERO ---------------- */
.hero { padding: 84px 0 44px; max-width: 820px; }
.hero-sm { padding: 60px 0 30px; }
.hero-eyebrow {
  display: inline-block;
  font-size: 11px; font-weight: 600; letter-spacing: 0.22em; text-transform: uppercase;
  color: var(--accent);
  padding: 6px 13px; border-radius: 999px;
  background: var(--accent-bg); border: 1px solid rgba(255,106,43,0.25);
  margin-bottom: 22px;
}
.hero-title {
  font-family: var(--font-display);
  font-weight: 600; font-size: clamp(40px, 7vw, 76px); line-height: 0.98;
  letter-spacing: -0.03em; color: var(--text);
}
.hero-title em { font-style: normal; color: var(--accent); }
.hero-sub {
  margin-top: 20px; font-size: clamp(15px, 2vw, 18px); line-height: 1.6;
  color: var(--text-2); max-width: 560px;
}

/* ---------------- SEARCH FORM (double-bezel) ---------------- */
.search-section { margin-top: 8px; }
.search-form {
  background: rgba(255,255,255,0.03);
  border: 1px solid var(--border);
  border-radius: 26px;
  padding: 7px;
}
.search-form > .form-row {
  background: var(--surface);
  border: 1px solid var(--border);
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.05);
}
.search-form > .form-row:first-child { border-radius: 20px 20px 0 0; border-bottom: none; }
.search-form > .form-row:last-child  { border-radius: 0 0 20px 20px; }
.form-row {
  display: flex; gap: 8px; padding: 16px 18px; flex-wrap: wrap; align-items: flex-end;
}
.field { display: flex; flex-direction: column; gap: 8px; flex: 1; min-width: 130px; }
.field-wide { flex: 2.2; }
.field-btn { flex: 0 0 auto; min-width: auto; }
.field label {
  font-size: 10.5px; font-weight: 600; letter-spacing: 0.14em; text-transform: uppercase;
  color: var(--text-3);
}
.field input, .field select {
  width: 100%;
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-radius: 11px;
  color: var(--text);
  font-family: var(--font-body); font-size: 15px; font-weight: 500;
  padding: 12px 14px;
  transition: border-color .35s var(--ease), box-shadow .35s var(--ease), background .35s var(--ease);
}
.field input::placeholder { color: var(--text-3); font-weight: 400; }
.field input:focus, .field select:focus {
  outline: none; border-color: rgba(255,106,43,0.55);
  box-shadow: 0 0 0 4px rgba(255,106,43,0.12); background: var(--surface-2);
}
.field select { cursor: pointer; appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' fill='none' stroke='%2362626d' stroke-width='2'%3E%3Cpath d='M2 4l4 4 4-4'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 14px center; padding-right: 34px;
}
.split-input { display: flex; align-items: center; gap: 8px; }
.split-input input { flex: 1; }
.split-sep { color: var(--text-3); font-size: 14px; }
.input-prefix { display: flex; align-items: center; background: var(--bg-2);
  border: 1px solid var(--border); border-radius: 11px; padding-left: 13px;
  transition: border-color .35s var(--ease), box-shadow .35s var(--ease); }
.input-prefix:focus-within { border-color: rgba(255,106,43,0.55); box-shadow: 0 0 0 4px rgba(255,106,43,0.12); }
.input-prefix span { color: var(--text-3); font-size: 15px; font-weight: 500; }
.input-prefix input { border: none; background: none; box-shadow: none !important; padding-left: 6px; }

/* Primary CTA — island button with nested icon */
.search-btn {
  display: inline-flex; align-items: center; gap: 10px;
  background: var(--accent); color: #0a0a0a;
  font-family: var(--font-body); font-weight: 700; font-size: 15px;
  border: none; border-radius: 12px; padding: 13px 22px; cursor: pointer;
  white-space: nowrap;
  box-shadow: 0 8px 24px -8px rgba(255,106,43,0.65), inset 0 1px 0 rgba(255,255,255,0.25);
  transition: transform .4s var(--ease), box-shadow .4s var(--ease), filter .3s var(--ease);
}
.search-btn::after {
  content: "→"; display: grid; place-items: center;
  width: 22px; height: 22px; border-radius: 999px;
  background: rgba(0,0,0,0.18); font-size: 13px;
  transition: transform .4s var(--ease);
}
.search-btn:hover { transform: translateY(-1px); filter: brightness(1.04); }
.search-btn:hover::after { transform: translateX(3px); }
.search-btn:active { transform: scale(0.98); }
.search-btn:disabled { opacity: 0.75; cursor: default; }
.btn-spinner svg { animation: spin 0.9s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------------- STATS BAR ---------------- */
.stats-bar {
  display: flex; align-items: center; gap: 6px; flex-wrap: wrap;
  margin-top: 26px; padding: 18px 22px;
  background: var(--surface); border: 1px solid var(--border); border-radius: 18px;
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.04);
}
.stat { display: flex; flex-direction: column; gap: 3px; padding: 0 20px; }
.stat-num { font-family: var(--font-display); font-weight: 600; font-size: 24px; letter-spacing: -0.02em; color: var(--text); font-variant-numeric: tabular-nums; }
.stat:nth-child(3) .stat-num { color: var(--accent-2); }
.stat-label { font-size: 11px; color: var(--text-3); letter-spacing: 0.05em; text-transform: uppercase; }
.stat-divider { width: 1px; height: 30px; background: var(--border); }

/* ---------------- SORT / FILTER ---------------- */
.results-controls { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin: 32px 0 16px; flex-wrap: wrap; }
.results-label { font-size: 14px; color: var(--text-2); font-weight: 500; }
.sort-pills { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.sort-label { font-size: 13px; color: var(--text-3); margin-right: 2px; }
.pill {
  background: var(--surface); border: 1px solid var(--border); color: var(--text-2);
  font-family: var(--font-body); font-size: 13px; font-weight: 500;
  padding: 7px 14px; border-radius: 999px; cursor: pointer;
  transition: all .35s var(--ease);
}
.pill:hover { color: var(--text); border-color: var(--border-light); }
.pill.active { background: var(--text); color: #0a0a0a; border-color: var(--text); font-weight: 600; }
.runs-filter input[type="checkbox"] { accent-color: var(--accent); width: 15px; height: 15px; }

/* ---------------- LISTINGS ---------------- */
.listings-grid { display: flex; flex-direction: column; gap: 12px; }
.listing-card {
  display: flex; gap: 18px; align-items: center;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 18px; padding: 16px; cursor: pointer;
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.03);
  transition: transform .5s var(--ease), border-color .5s var(--ease), box-shadow .5s var(--ease), background .5s var(--ease);
  animation: cardIn .55s var(--ease) both;
  will-change: transform;
}
@keyframes cardIn { from { opacity: 0; transform: translateY(14px); } to { opacity: 1; transform: none; } }
.listing-card:hover {
  transform: translateY(-3px);
  border-color: var(--border-light);
  background: var(--surface-2);
  box-shadow: 0 18px 40px -22px rgba(0,0,0,0.9);
}
.listing-card.is-best {
  border-color: rgba(166,238,78,0.4);
  box-shadow: 0 0 0 1px rgba(166,238,78,0.18), 0 18px 44px -26px rgba(166,238,78,0.35);
}
.card-thumb {
  width: 116px; height: 82px; flex-shrink: 0; border-radius: 12px; overflow: hidden;
  background: var(--bg-3); display: grid; place-items: center; color: var(--text-3);
  border: 1px solid var(--border);
}
.card-thumb img { width: 100%; height: 100%; object-fit: cover; }
.card-main { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 8px; }
.card-title {
  font-family: var(--font-display); font-weight: 500; font-size: 17px; letter-spacing: -0.01em;
  color: var(--text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.card-meta { display: flex; gap: 8px; flex-wrap: wrap; font-size: 13px; color: var(--text-3); }
.card-meta span::after { content: "·"; margin-left: 8px; color: var(--border-light); }
.card-meta span:last-child::after { content: ""; }
.card-badges { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 2px; }
.card-right { text-align: right; flex-shrink: 0; display: flex; flex-direction: column; align-items: flex-end; gap: 3px; }
.card-was { font-size: 12px; color: var(--text-3); text-decoration: line-through; opacity: 0.7; }
.card-price {
  font-family: var(--font-display); font-weight: 600; font-size: 27px; letter-spacing: -0.02em;
  color: var(--text); line-height: 1; font-variant-numeric: tabular-nums;
}
.card-delta-pos { font-size: 11.5px; color: var(--accent-2); font-weight: 600; }
.card-delta-neg { font-size: 11.5px; color: var(--red); font-weight: 600; }
.card-age { font-size: 11px; color: var(--text-3); margin-top: 2px; }

/* ---------------- BADGES ---------------- */
.badge {
  display: inline-flex; align-items: center; gap: 5px;
  font-size: 11px; font-weight: 600; letter-spacing: 0.01em;
  padding: 3px 9px; border-radius: 999px;
  border: 1px solid transparent;
}
.badge-run-yes    { background: var(--green-bg); color: var(--accent-2); border-color: rgba(166,238,78,0.22); }
.badge-run-no     { background: var(--red-bg); color: var(--red); border-color: rgba(255,92,92,0.22); }
.badge-run-unk    { background: rgba(255,255,255,0.04); color: var(--text-3); border-color: var(--border); }
.badge-bait       { background: var(--amber-bg); color: var(--amber); border-color: rgba(245,180,81,0.24); }
.badge-placeholder{ background: rgba(184,174,240,0.10); color: var(--violet); border-color: rgba(184,174,240,0.24); }
.badge-best       { background: var(--accent-2); color: #0a0a0a; border-color: transparent; font-weight: 700; }
.badge-good       { background: var(--green-bg); color: var(--accent-2); border-color: rgba(166,238,78,0.22); }
.badge-amber      { background: var(--amber-bg); color: var(--amber); border-color: rgba(245,180,81,0.22); }
.badge-muted      { background: rgba(255,255,255,0.03); color: var(--text-3); border-color: var(--border); }
.badge-source     { background: rgba(255,255,255,0.04); color: var(--text-3); border-color: var(--border); font-size: 10px; letter-spacing: 0.06em; text-transform: uppercase; }
.badge-drop       { background: var(--green-bg); color: var(--accent-2); border-color: rgba(166,238,78,0.32); font-weight: 700; }
.badge-dealer     { background: var(--amber-bg); color: var(--amber); border-color: rgba(245,180,81,0.22); }
.badge-auction    { background: var(--red-bg); color: var(--red); border-color: rgba(255,92,92,0.24); }
.badge-private    { background: rgba(255,255,255,0.04); color: var(--text-3); border-color: var(--border); }
.badge-run-yes::before, .badge-run-no::before, .badge-run-unk::before,
.badge-bait::before, .badge-placeholder::before, .badge-dealer::before, .badge-auction::before {
  content: ""; width: 5px; height: 5px; border-radius: 50%; background: currentColor;
}

/* ---------------- EMPTY / SKELETON ---------------- */
.empty-state {
  display: flex; flex-direction: column; align-items: center; gap: 12px;
  padding: 80px 20px; text-align: center; color: var(--text-3);
}
.empty-state svg { opacity: 0.4; }
.empty-state p { font-family: var(--font-display); font-size: 18px; color: var(--text-2); }
.empty-state span { font-size: 13px; max-width: 380px; }
.skeleton-card {
  display: flex; gap: 18px; align-items: center;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 18px; padding: 16px;
}
.skel { background: linear-gradient(100deg, var(--bg-3) 30%, var(--bg-4) 50%, var(--bg-3) 70%);
  background-size: 200% 100%; animation: shimmer 1.3s var(--ease) infinite; border-radius: 6px; }
.skeleton-card > div:nth-child(2) { flex: 1; }
@keyframes shimmer { to { background-position: -200% 0; } }

/* ---------------- ALERTS ---------------- */
.alerts-form-card, .active-alerts {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 22px; padding: 28px; box-shadow: inset 0 1px 0 rgba(255,255,255,0.04);
  max-width: 820px;
}
.active-alerts { margin-top: 20px; }
.alert-row {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 12px 14px; border-radius: 12px; background: var(--surface-2);
  border: 1px solid var(--border); font-size: 14px; color: var(--text-2);
}
.alert-row + .alert-row { margin-top: 8px; }
.alert-cancel {
  background: transparent; border: 1px solid var(--border-light); color: var(--text-2);
  border-radius: 8px; padding: 6px 12px; font-size: 13px; cursor: pointer;
  transition: color .2s var(--ease), border-color .2s var(--ease);
}
.alert-cancel:hover { color: var(--red); border-color: var(--red); }
.alert-cancel:disabled { opacity: .5; cursor: default; }
.card-title { font-family: var(--font-display); font-weight: 600; font-size: 20px; letter-spacing: -0.01em; margin-bottom: 20px; }
.alerts-form-card .form-row { padding: 0 0 14px; }
.alert-success {
  display: flex; align-items: center; gap: 8px; margin-top: 8px;
  color: var(--accent-2); font-size: 14px; font-weight: 500;
  background: var(--green-bg); border: 1px solid rgba(166,238,78,0.22);
  padding: 12px 16px; border-radius: 12px;
}

/* ---------------- MODAL ---------------- */
.modal-overlay {
  position: fixed; inset: 0; z-index: 60;
  background: rgba(6,6,8,0.72); backdrop-filter: blur(10px);
  display: flex; align-items: center; justify-content: center; padding: 24px;
  animation: fadeIn .3s var(--ease);
}
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
.modal {
  position: relative; width: 100%; max-width: 520px; max-height: 88vh; overflow-y: auto;
  background: var(--surface-2); border: 1px solid var(--border-light);
  border-radius: 24px; padding: 8px;
  box-shadow: 0 40px 100px -30px rgba(0,0,0,0.9);
  animation: modalIn .5s var(--ease);
}
@keyframes modalIn { from { opacity: 0; transform: translateY(24px) scale(0.97); } to { opacity: 1; transform: none; } }
.modal-close {
  position: absolute; top: 18px; right: 18px; z-index: 2;
  width: 34px; height: 34px; border-radius: 999px; cursor: pointer;
  background: rgba(0,0,0,0.4); border: 1px solid var(--border-light); color: var(--text-2);
  display: grid; place-items: center; transition: all .3s var(--ease);
}
.modal-close:hover { color: var(--text); background: rgba(0,0,0,0.6); }
.modal-body { padding: 10px; }
.modal-thumb { width: 100%; height: 240px; border-radius: 16px; overflow: hidden; background: var(--bg-3); display: grid; place-items: center; color: var(--text-3); margin-bottom: 20px; }
.modal-title { font-family: var(--font-display); font-weight: 600; font-size: 23px; letter-spacing: -0.02em; }
.modal-price { font-family: var(--font-display); font-weight: 600; font-size: 34px; color: var(--accent-2); margin: 6px 0 22px; font-variant-numeric: tabular-nums; }
.modal-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 12px; margin-bottom: 20px; }
.modal-stat { background: var(--bg-2); border: 1px solid var(--border); border-radius: 12px; padding: 12px 14px; }
.modal-stat-label { font-size: 11px; color: var(--text-3); text-transform: uppercase; letter-spacing: 0.08em; margin-bottom: 4px; }
.modal-stat-value { font-size: 15px; font-weight: 600; color: var(--text); }
.modal-desc { font-size: 14px; line-height: 1.6; color: var(--text-2); margin-bottom: 14px; }
.modal-cta { display: flex; gap: 10px; margin-top: 8px; }
.cta-primary {
  flex: 1; text-align: center; text-decoration: none;
  background: var(--accent); color: #0a0a0a; font-weight: 700; font-size: 14px;
  padding: 13px; border-radius: 12px; transition: transform .3s var(--ease), filter .3s var(--ease);
  box-shadow: 0 8px 24px -8px rgba(255,106,43,0.6);
}
.cta-primary:hover { transform: translateY(-1px); filter: brightness(1.05); }
.cta-secondary { background: var(--bg-3); border: 1px solid var(--border-light); color: var(--text-2);
  font-family: var(--font-body); font-weight: 600; font-size: 14px; padding: 13px 20px; border-radius: 12px; cursor: pointer; transition: all .3s var(--ease); }
.cta-secondary:hover { color: var(--text); }

/* ---------------- AUTOCOMPLETE ---------------- */
.ac-item { padding: 9px 12px; font-size: 14px; font-weight: 500; color: var(--text-2); border-radius: 8px; cursor: pointer; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; transition: background .2s var(--ease), color .2s var(--ease); }
.ac-item:hover { background: var(--bg-4); color: var(--text); }

/* ---------------- RESPONSIVE ---------------- */
@media (max-width: 760px) {
  .nav { padding: 12px 12px 0; }
  .hero { padding: 56px 0 32px; }
  main { padding: 0 14px 90px; }
  .form-row { flex-direction: column; align-items: stretch; padding: 14px; }
  .field { min-width: 0; }
  .field-btn .search-btn { width: 100%; justify-content: center; }
  .listing-card { flex-wrap: wrap; gap: 12px; }
  .card-thumb { width: 84px; height: 62px; }
  .card-right { width: 100%; flex-direction: row; align-items: baseline; justify-content: space-between; margin-top: 4px; }
  .stat { padding: 0 12px; }
  .modal-grid { grid-template-columns: 1fr; }
}
