/* BidFinder — buyer-facing search UI */
:root {
  --bg: #f6f7f9;
  --surface: #ffffff;
  --border: #e2e5ea;
  --text: #17202a;
  --muted: #66707d;
  --accent: #1a63d8;
  --accent-hover: #1550b4;
  --ok: #0f8a4d;
  --warn: #c2410c;
  --live: #d62828;
  --radius: 12px;
  --shadow: 0 1px 2px rgba(16, 24, 40, .06), 0 4px 12px rgba(16, 24, 40, .05);
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #11151b;
    --surface: #191f27;
    --border: #2b333e;
    --text: #e8edf3;
    --muted: #98a3b2;
    --accent: #5b9bff;
    --accent-hover: #7fb2ff;
    --ok: #43c67f;
    --warn: #fb923c;
    --live: #ff6b6b;
    --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 4px 14px rgba(0, 0, 0, .25);
  }
}

* { box-sizing: border-box; }

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

.wrap { max-width: 1240px; margin: 0 auto; padding: 0 20px; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ---------- header ---------- */
.site-header {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  position: sticky; top: 0; z-index: 20;
}
.header-inner { display: flex; align-items: center; justify-content: space-between; height: 62px; }
.brand { display: flex; align-items: center; gap: 9px; font-size: 19px; color: var(--text); }
.brand:hover { text-decoration: none; }
.brand-mark { font-size: 22px; }
.brand-name strong { font-weight: 700; }
.header-nav { display: flex; align-items: center; gap: 18px; font-size: 14px; }
.data-freshness {
  color: var(--muted); font-size: 12.5px;
  border: 1px solid var(--border); border-radius: 20px; padding: 3px 11px;
}

/* ---------- hero ---------- */
.hero { padding: 34px 0 20px; }
.hero h1 { margin: 0 0 6px; font-size: 30px; letter-spacing: -.4px; }
.hero p { margin: 0; color: var(--muted); font-size: 15.5px; }

/* ---------- search panel ---------- */
.search-panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px;
  box-shadow: var(--shadow);
  margin-bottom: 22px;
}
.search-row { display: flex; gap: 14px; align-items: flex-end; flex-wrap: wrap; }
.field { display: flex; flex-direction: column; gap: 5px; min-width: 180px; }
.field.grow { flex: 1; min-width: 220px; }
.field label { font-size: 12.5px; font-weight: 600; color: var(--muted); }

select, input[type="search"], input[type="number"] {
  font: inherit;
  padding: 9px 11px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--bg);
  color: var(--text);
  min-height: 40px;
}
select:focus, input:focus { outline: 2px solid var(--accent); outline-offset: -1px; }
select:disabled { opacity: .55; }

/* ---------- searchable combobox ---------- */
.combo { position: relative; }
.combo .combo-input { width: 100%; padding-right: 30px; }
.combo.is-disabled .combo-input { opacity: .55; cursor: not-allowed; }

.combo-clear {
  position: absolute; top: 50%; right: 8px; transform: translateY(-50%);
  width: 20px; height: 20px; padding: 0; line-height: 1;
  display: flex; align-items: center; justify-content: center;
  border: none; border-radius: 50%; cursor: pointer;
  background: var(--border); color: var(--text);
  font-size: 15px;
}
.combo-clear:hover { background: var(--muted); color: var(--surface); }

.combo-list {
  position: absolute; z-index: 60;
  top: calc(100% + 4px); left: 0; right: 0;
  /* The whole point: a bounded, scrollable list instead of a full-screen
     native dropdown for 84 brands / 150+ models. */
  max-height: 296px; overflow-y: auto;
  margin: 0; padding: 4px; list-style: none;
  background: var(--surface);
  border: 1px solid var(--border); border-radius: 9px;
  box-shadow: 0 8px 26px rgba(16, 24, 40, .16);
}
.combo-option {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  padding: 8px 10px; border-radius: 6px; cursor: pointer; font-size: 14px;
}
.combo-option .count { color: var(--muted); font-size: 12px; flex-shrink: 0; }
.combo-option:hover, .combo-option.active { background: var(--accent); color: #fff; }
.combo-option:hover .count, .combo-option.active .count { color: rgba(255, 255, 255, .82); }
.combo-all { font-weight: 600; border-bottom: 1px solid var(--border); border-radius: 6px 6px 0 0; }
.combo-empty { padding: 10px; color: var(--muted); font-size: 13.5px; text-align: center; }

.btn-primary, .btn-secondary {
  font: inherit; font-weight: 600; cursor: pointer;
  padding: 10px 20px; border-radius: 8px; min-height: 40px;
  border: 1px solid transparent;
}
.btn-primary { background: var(--accent); color: #fff; }
.btn-primary:hover { background: var(--accent-hover); text-decoration: none; }
.btn-secondary { background: var(--surface); color: var(--text); border-color: var(--border); }
.btn-primary.block { display: block; width: 100%; text-align: center; margin-top: 12px; }

.more-filters { margin-top: 14px; border-top: 1px solid var(--border); padding-top: 12px; }
.more-filters summary { cursor: pointer; font-size: 13.5px; font-weight: 600; color: var(--accent); }
.filter-grid {
  display: grid; gap: 14px; margin-top: 14px;
  grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
  align-items: end;
}
.check { display: flex; align-items: center; gap: 8px; font-size: 13.5px; color: var(--text); }

/* ---------- results bar ---------- */
.results-bar {
  display: flex; justify-content: space-between; align-items: center;
  gap: 16px; flex-wrap: wrap; margin-bottom: 14px;
}
.count { margin: 0; font-size: 15px; color: var(--muted); }
.count strong { color: var(--text); font-size: 17px; }
.sort { display: flex; align-items: center; gap: 8px; font-size: 13.5px; color: var(--muted); }

/* ---------- card grid ---------- */
.grid {
  display: grid; gap: 18px;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
}
.grid-compact { grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); }

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow);
  display: flex; flex-direction: column;
  transition: transform .12s ease, box-shadow .12s ease;
}
.card:hover { transform: translateY(-2px); box-shadow: 0 6px 20px rgba(16, 24, 40, .12); }

.card-media { position: relative; display: block; aspect-ratio: 4/3; background: var(--bg); }
.card-media img { width: 100%; height: 100%; object-fit: cover; display: block; }
.no-photo {
  width: 100%; height: 100%; display: flex; align-items: center; justify-content: center;
  color: var(--muted); font-size: 13px;
}
.no-photo.big { aspect-ratio: 4/3; border: 1px dashed var(--border); border-radius: var(--radius); }

.badge {
  position: absolute; top: 10px; left: 10px;
  font-size: 11px; font-weight: 700; letter-spacing: .3px;
  padding: 4px 9px; border-radius: 5px; color: #fff; background: #444;
}
.badge-iaai { background: #c1272d; }
.badge-copart { background: #0b5ea8; }
.badge-live { left: auto; right: 10px; background: var(--live); }
.photo-count {
  position: absolute; bottom: 10px; right: 10px;
  background: rgba(0, 0, 0, .68); color: #fff;
  font-size: 11.5px; padding: 3px 8px; border-radius: 5px;
}

/* ---------- inline photo browsing on result cards ---------- */
.card-media-link { display: block; width: 100%; height: 100%; }

.img-nav {
  position: absolute; top: 50%; transform: translateY(-50%);
  width: 30px; height: 30px; padding: 0;
  display: flex; align-items: center; justify-content: center;
  border: none; border-radius: 50%; cursor: pointer;
  background: rgba(0, 0, 0, .55); color: #fff;
  font-size: 19px; line-height: 1;
  opacity: 0; transition: opacity .13s ease, background .13s ease;
  z-index: 3;
}
.img-nav:hover { background: rgba(0, 0, 0, .8); }
.img-prev { left: 8px; }
.img-next { right: 8px; }

/* Reveal on hover, or whenever a control has keyboard focus. */
.card:hover .img-nav,
.img-nav:focus-visible { opacity: 1; }

/* Hide the "previous" arrow on the first photo so it is obvious where the
   set begins; it comes back as soon as you move forward. */
.card-media.at-start .img-prev { opacity: 0; pointer-events: none; }
.card:hover .card-media.at-start .img-prev { opacity: .35; pointer-events: auto; }

.img-pos {
  position: absolute; bottom: 10px; left: 10px; z-index: 3;
  background: rgba(0, 0, 0, .68); color: #fff;
  font-size: 11.5px; padding: 3px 8px; border-radius: 5px;
  opacity: 0; transition: opacity .13s ease;
}
.card:hover .img-pos { opacity: 1; }

/* Touch devices have no hover: keep the controls permanently visible. */
@media (hover: none) {
  .img-nav, .img-pos { opacity: 1; }
  .card-media.at-start .img-prev { opacity: .35; pointer-events: auto; }
}

.card-body { padding: 13px 14px 14px; display: flex; flex-direction: column; gap: 10px; flex: 1; }
.card-body h3 { margin: 0; font-size: 15px; line-height: 1.35; }
.card-body h3 a { color: var(--text); }

.specs { margin: 0; display: grid; grid-template-columns: 1fr 1fr; gap: 7px 12px; }
.specs > div { display: flex; flex-direction: column; }
.specs dt { font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: .3px; }
.specs dd {
  margin: 0; font-size: 13px;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.specs dd.ok { color: var(--ok); font-weight: 600; }

.card-foot {
  margin-top: auto; padding-top: 11px; border-top: 1px solid var(--border);
  display: flex; align-items: flex-end; justify-content: space-between; gap: 10px;
}
.bid { display: flex; flex-direction: column; }
.bid-label { font-size: 10.5px; color: var(--muted); text-transform: uppercase; letter-spacing: .3px; }
.bid-value { font-size: 18px; font-weight: 700; }
.when { font-size: 11.5px; color: var(--muted); text-align: right; max-width: 130px; }

/* ---------- pagination ---------- */
.pagination {
  display: flex; align-items: center; justify-content: center; gap: 18px;
  margin: 30px 0 10px; font-size: 14px;
}
.page-info { color: var(--muted); }

/* ---------- empty state ---------- */
.empty {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 44px 24px; text-align: center; box-shadow: var(--shadow);
}
.empty p { margin: 0 0 8px; color: var(--muted); }
.empty .btn-secondary { display: inline-block; margin-top: 14px; }

/* ---------- lot detail ---------- */
.back-link { display: inline-block; margin: 20px 0 14px; font-size: 14px; }
.lot-layout {
  display: grid; grid-template-columns: minmax(0, 1.55fr) minmax(300px, 1fr);
  gap: 26px; align-items: start;
}
.gallery-main {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); overflow: hidden; aspect-ratio: 4/3;
}
.gallery-main img { width: 100%; height: 100%; object-fit: contain; display: block; background: #000; }
.thumbs { display: grid; grid-template-columns: repeat(auto-fill, minmax(76px, 1fr)); gap: 8px; margin-top: 10px; }
.thumb {
  padding: 0; border: 2px solid transparent; border-radius: 7px;
  overflow: hidden; cursor: pointer; background: none; aspect-ratio: 4/3;
}
.thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.thumb.active { border-color: var(--accent); }

.lot-side { display: flex; flex-direction: column; gap: 18px; }
.lot-head { position: relative; }
.lot-head .badge { position: static; display: inline-block; margin: 0 6px 8px 0; }
.lot-head h1 { margin: 4px 0 6px; font-size: 24px; line-height: 1.25; letter-spacing: -.3px; }
.vin { margin: 0; color: var(--muted); font-size: 13px; font-family: ui-monospace, SFMono-Regular, Menlo, monospace; }

.bid-box {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 18px; box-shadow: var(--shadow);
}
.bid-big { display: block; font-size: 30px; font-weight: 700; line-height: 1.2; }
.auction-when { margin: 10px 0 0; font-size: 13.5px; color: var(--muted); }
.est { margin: 6px 0 0; font-size: 13px; color: var(--muted); }
.disclaimer { margin: 10px 0 0; font-size: 11.5px; color: var(--muted); text-align: center; }

.detail-list {
  margin: 0; background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 6px 16px; box-shadow: var(--shadow);
}
.detail-list > div {
  display: flex; justify-content: space-between; gap: 16px;
  padding: 10px 0; border-bottom: 1px solid var(--border);
}
.detail-list > div:last-child { border-bottom: none; }
.detail-list dt { color: var(--muted); font-size: 13px; flex-shrink: 0; }
.detail-list dd { margin: 0; font-size: 13.5px; text-align: right; font-weight: 500; }
.detail-list dd.warn { color: var(--warn); }

.media-links { display: flex; gap: 14px; font-size: 13.5px; }

.panel { margin: 34px 0; }
.panel h2 { font-size: 19px; margin: 0 0 14px; }

.history {
  width: 100%; border-collapse: collapse;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); overflow: hidden; box-shadow: var(--shadow);
}
.history th, .history td { padding: 10px 14px; text-align: left; font-size: 13.5px; border-bottom: 1px solid var(--border); }
.history th { background: var(--bg); font-size: 12px; text-transform: uppercase; letter-spacing: .3px; color: var(--muted); }
.history tr:last-child td { border-bottom: none; }

/* ---------- auth + alerts ---------- */
.user-email {
  color: var(--muted); font-size: 12.5px;
  max-width: 170px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.inline-form { display: inline; margin: 0; }
.link-button {
  background: none; border: none; padding: 0; cursor: pointer;
  color: var(--accent); font: inherit; font-size: 14px;
}
.link-button:hover { text-decoration: underline; }
.btn-primary.small, .btn-secondary.small, .btn-danger.small {
  padding: 6px 13px; min-height: 32px; font-size: 13px;
}
.btn-danger {
  background: var(--surface); color: var(--live);
  border: 1px solid var(--border); border-radius: 8px;
  font: inherit; font-weight: 600; cursor: pointer; padding: 10px 20px;
}
.btn-danger:hover { background: var(--live); color: #fff; border-color: var(--live); }

.flashes { margin: 18px 0 0; display: flex; flex-direction: column; gap: 8px; }
.flash {
  padding: 11px 15px; border-radius: 9px; font-size: 14px;
  border: 1px solid var(--border); background: var(--surface);
}
.flash-ok { border-left: 3px solid var(--ok); }
.flash-error { border-left: 3px solid var(--live); }

.auth-card {
  max-width: 430px; margin: 52px auto; padding: 32px;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); box-shadow: var(--shadow); text-align: center;
}
.auth-card h1 { margin: 0 0 8px; font-size: 24px; }
.auth-icon { font-size: 40px; margin-bottom: 10px; }
.lede { margin: 0 0 20px; color: var(--muted); font-size: 14.5px; line-height: 1.55; }
.auth-form { text-align: left; }
.auth-form .field { margin-bottom: 16px; }
.auth-form input { width: 100%; }
.fineprint {
  margin: 22px 0 0; font-size: 12.5px; color: var(--muted); line-height: 1.55;
  border-top: 1px solid var(--border); padding-top: 16px;
}

.code-input {
  width: 100%; text-align: center;
  font-size: 26px; font-weight: 700; letter-spacing: 8px;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  padding: 12px 10px;
}

.dev-banner {
  display: flex; flex-direction: column; gap: 4px; text-align: left;
  background: color-mix(in srgb, var(--warn) 12%, transparent);
  border: 1px solid var(--warn); border-radius: 9px;
  padding: 11px 14px; margin: 0 0 18px; font-size: 12.5px; line-height: 1.5;
}
.dev-banner strong { color: var(--warn); font-size: 12px; text-transform: uppercase; letter-spacing: .4px; }
.dev-banner code {
  font-size: 13px; font-weight: 700;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 4px; padding: 1px 6px;
}

.page-head {
  display: flex; justify-content: space-between; align-items: flex-start;
  gap: 20px; flex-wrap: wrap; margin: 30px 0 20px;
}
.page-head h1 { margin: 0 0 5px; font-size: 26px; letter-spacing: -.3px; }
.page-head .lede { margin: 0; }

.alert-list { display: flex; flex-direction: column; gap: 12px; }
.alert-card {
  display: flex; justify-content: space-between; align-items: center;
  gap: 18px; flex-wrap: wrap;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 16px 18px; box-shadow: var(--shadow);
}
.alert-card.is-paused { opacity: .62; }
.alert-main h3 { margin: 0 0 4px; font-size: 16px; display: flex; align-items: center; gap: 9px; }
.alert-criteria { margin: 0 0 4px; font-size: 13.5px; color: var(--text); }
.alert-meta { margin: 0; font-size: 12.5px; color: var(--muted); }
.pill {
  font-size: 10.5px; font-weight: 700; letter-spacing: .3px; text-transform: uppercase;
  background: var(--border); color: var(--muted); padding: 3px 8px; border-radius: 20px;
}
.pill-wait {
  background: color-mix(in srgb, var(--accent) 15%, transparent);
  color: var(--accent); text-transform: none; letter-spacing: 0;
}
.alert-actions { display: flex; gap: 8px; align-items: center; }
.alert-actions form { margin: 0; }

.alert-builder .field { min-width: 0; }
.alert-builder > .field { max-width: 420px; margin-bottom: 16px; }
.opt { font-weight: 400; color: var(--muted); text-transform: none; letter-spacing: 0; }
.checks-row { display: flex; gap: 22px; flex-wrap: wrap; margin: 16px 0 4px; }

.damage-set {
  border: 1px solid var(--border); border-radius: var(--radius);
  padding: 14px 16px; margin: 18px 0 0;
}
.damage-set legend { font-size: 12.5px; font-weight: 600; color: var(--muted); padding: 0 6px; }
/* ---------- "ready to buy" date ---------- */
.date-input {
  font: inherit; padding: 9px 11px; min-height: 40px;
  border: 1px solid var(--border); border-radius: 8px;
  background: var(--bg); color: var(--text);
}
.date-input:focus { outline: 2px solid var(--accent); outline-offset: -1px; }

.buy-when {
  margin: 20px 0 4px; padding: 14px 16px;
  border: 1px solid var(--border); border-radius: var(--radius); background: var(--bg);
}
.buy-when > label { display: block; font-size: 13.5px; font-weight: 600; margin-bottom: 3px; }
.buy-hint { margin: 0 0 11px; font-size: 12.5px; color: var(--muted); line-height: 1.5; }
.buy-row { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; }

.chips { display: flex; gap: 7px; flex-wrap: wrap; }
.chip {
  font: inherit; font-size: 12.5px; cursor: pointer;
  padding: 7px 13px; border-radius: 20px;
  border: 1px solid var(--border); background: var(--surface); color: var(--text);
}
.chip:hover { border-color: var(--accent); color: var(--accent); }
.chip.is-on { background: var(--accent); border-color: var(--accent); color: #fff; }

.damage-hint {
  display: flex; align-items: center; justify-content: space-between;
  gap: 14px; flex-wrap: wrap; margin: 2px 0 12px; font-size: 13px;
}

.damage-groups { display: flex; flex-direction: column; gap: 8px; }

.dmg-group {
  border: 1px solid var(--border); border-radius: 9px;
  background: var(--bg); overflow: hidden;
}
.dmg-group[open] { background: var(--surface); }
.dmg-group > summary {
  cursor: pointer; padding: 10px 14px; list-style: none;
  display: flex; flex-direction: column; gap: 2px;
}
.dmg-group > summary::-webkit-details-marker { display: none; }
.dmg-group > summary::before {
  content: "▸"; position: absolute; margin-left: -12px;
  color: var(--muted); font-size: 11px; transition: transform .15s;
}
.dmg-group[open] > summary::before { content: "▾"; }
.dmg-group > summary:hover { background: color-mix(in srgb, var(--accent) 7%, transparent); }

.dmg-head { display: flex; align-items: center; gap: 9px; }
.dmg-name { font-weight: 600; font-size: 14px; }
.dmg-badge {
  font-size: 11px; font-weight: 700; letter-spacing: .2px;
  background: var(--accent); color: #fff; padding: 2px 8px; border-radius: 20px;
}
/* The member preview is the point: a collapsed group still shows what's in it. */
.dmg-preview {
  font-size: 12px; color: var(--muted);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.dmg-group[open] .dmg-preview { display: none; }

.dmg-body { padding: 2px 14px 14px; }
.dmg-all {
  font-size: 12.5px; color: var(--muted); font-weight: 600;
  padding-bottom: 9px; margin-bottom: 9px; border-bottom: 1px solid var(--border);
}
.dmg-count {
  color: var(--muted); font-size: 11.5px; margin-left: 6px;
  background: var(--bg); border: 1px solid var(--border);
  border-radius: 20px; padding: 0 6px;
}
.dmg-group[open] .dmg-count { background: var(--bg); }

.damage-grid {
  display: grid; gap: 9px 16px;
  grid-template-columns: repeat(auto-fill, minmax(190px, 1fr));
}

.alert-submit {
  display: flex; justify-content: space-between; align-items: center;
  gap: 16px; flex-wrap: wrap; margin-top: 20px;
  border-top: 1px solid var(--border); padding-top: 18px;
}
.preview { margin: 0; font-size: 14px; }
.muted { color: var(--muted); }

/* ---------- footer ---------- */
.site-footer { margin-top: 50px; padding: 22px 0 34px; border-top: 1px solid var(--border); }
.site-footer p { margin: 0; color: var(--muted); font-size: 12.5px; max-width: 760px; }

/* ---------- responsive ---------- */
@media (max-width: 900px) {
  .lot-layout { grid-template-columns: 1fr; }
}
@media (max-width: 640px) {
  .hero h1 { font-size: 24px; }
  .search-row { flex-direction: column; align-items: stretch; }
  .field { min-width: 0; }
  .btn-primary { width: 100%; }
  .grid { grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); }
}
