/* Colours of the dealer's site (CLAUDE.md 5c.14): black, red accent, yellow only for small details. */
:root {
  --bg: #050506;
  --bg-raised: #151518;
  --on-dark: #f4f4f5;
  --on-dark-muted: #a7a7b0;
  --accent: #eb1920;
  --accent-strong: #c3121a;
  --highlight: #ffff00;
  --surface: #ffffff;
  --surface-soft: #f3f3f5;
  --line: #e3e3e8;
  --text: #17171b;
  --text-muted: #63636e;
  --ok: #157f3b;
  --warn: #9a6400;
  --radius: 20px;
  --shadow: 0 24px 60px rgb(0 0 0 / 45%);
  --side: clamp(16px, 5vw, 96px);
  --page-zoom: 1;
  --view-h: calc(100vh / var(--page-zoom));
  --chat-compact-w: 460px;
  --ease: 0.35s ease;
  color-scheme: light;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: radial-gradient(circle at 15% 20%, #2a0608 0%, transparent 45%), linear-gradient(160deg, #0f0f11 0%, var(--bg) 70%);
  background-color: var(--bg);
  color: var(--on-dark);
  font-family: "Segoe UI", system-ui, -apple-system, Roboto, Arial, sans-serif;
  line-height: 1.45;
}
button { font: inherit; cursor: pointer; }
textarea { font: inherit; }
a { color: inherit; }
[hidden] { display: none !important; }
.visually-hidden { position: absolute; inset: auto; width: 1px; height: 1px; margin: -1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }

/* ---------- Intro (left on desktop, under the chat on phones) ---------- */
.intro-title { margin: 0 0 10px; font-size: 27px; line-height: 1.2; }
.intro-lead { margin: 0 0 22px; font-size: 15px; color: var(--on-dark-muted); max-width: 52ch; }
.intro-stats { display: flex; gap: 28px; margin: 0 0 22px; }
.intro-stats div { display: flex; flex-direction: column-reverse; }
.intro-stats dt { font-size: 12px; color: var(--on-dark-muted); }
.intro-stats dd { margin: 0; font-size: 18px; font-weight: 700; color: var(--highlight); }
.intro-list { margin: 0 0 22px; padding-left: 18px; font-size: 13px; color: var(--on-dark); max-width: 56ch; }
.intro-list li { margin-bottom: 6px; }
.intro-list li::marker { color: var(--accent); }
.intro-warning {
  margin: 0; max-width: 56ch; padding: 10px 12px; font-size: 12px; color: var(--on-dark-muted);
  border: 1px solid rgb(255 255 0 / 35%); border-radius: 10px; background: rgb(255 255 255 / 4%);
}
.intro-warning strong { color: var(--highlight); }

/* ---------- Chat window ---------- */
.chat {
  display: flex; flex-direction: column; overflow: hidden;
  background: var(--surface); color: var(--text); border-radius: var(--radius); box-shadow: var(--shadow);
}
.chat-head {
  display: flex; align-items: center; gap: 10px; padding: 14px 16px;
  background: #0d0d0f; color: var(--on-dark); border-bottom: 3px solid var(--accent);
}
.chat-dot { width: 10px; height: 10px; border-radius: 50%; background: var(--accent); box-shadow: 0 0 0 4px rgb(235 25 32 / 25%); }
.chat-title { flex: 1; margin: 0; font-size: 17px; }
.icon-button {
  width: 34px; height: 34px; border: 1px solid rgb(255 255 255 / 18%); border-radius: 50%;
  background: transparent; color: var(--on-dark); font-size: 16px; line-height: 1;
}
.icon-button:hover, .icon-button:focus-visible { background: rgb(255 255 255 / 10%); }
.icon-button:disabled { opacity: 0.4; cursor: not-allowed; }

.chat-body { position: relative; flex: 1; min-height: 0; display: grid; grid-template-columns: minmax(0, 1fr); }
.messages {
  list-style: none; margin: 0; padding: 16px; overflow-y: auto; overscroll-behavior: contain;
  display: flex; flex-direction: column; gap: 10px; min-height: 0;
}
.msg { max-width: 85%; padding: 10px 14px; border-radius: 16px; font-size: 15px; overflow-wrap: anywhere; }
.msg p { margin: 0; }
.msg ul { margin: 0; padding-left: 20px; list-style: disc; }
.msg.bot { align-self: flex-start; background: var(--surface-soft); border-bottom-left-radius: 4px; }
.msg.user { align-self: flex-end; background: var(--accent); color: #fff; border-bottom-right-radius: 4px; }
.msg.welcome { max-width: 100%; }
.chat:not(.is-wide) .messages > .msg:first-child { margin-top: 20px; }
.msg a { color: var(--accent-strong); font-weight: 600; }
.msg.user a { color: #fff; }
.welcome-buttons { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 10px; }
.chip {
  padding: 7px 12px; border: 1px solid var(--accent); border-radius: 999px; background: #fff;
  color: var(--accent-strong); font-size: 14px; font-weight: 600;
}
.chip:hover, .chip:focus-visible { background: var(--accent); color: #fff; }

.typing { display: inline-flex; gap: 5px; align-items: center; padding: 14px; }
.typing span { width: 7px; height: 7px; border-radius: 50%; background: var(--text-muted); animation: blink 1.2s infinite ease-in-out; }
.typing span:nth-child(2) { animation-delay: 0.15s; }
.typing span:nth-child(3) { animation-delay: 0.3s; }
@keyframes blink { 0%, 80%, 100% { opacity: 0.25; } 40% { opacity: 1; } }

/* ---------- Composer ---------- */
.composer { display: flex; align-items: flex-end; gap: 10px; padding: 26px 16px 44px; border-top: 1px solid var(--line); background: var(--surface); }
.composer textarea {
  flex: 1; height: auto; resize: none; padding: 14px; font-size: 17px; line-height: 1.4; color: var(--text);
  border: 1px solid var(--line); border-radius: 14px; background: var(--surface-soft); outline: none;
}
.composer textarea:focus { border-color: var(--accent); background: #fff; }
.send-button {
  display: inline-flex; flex-direction: row-reverse; align-items: center; justify-content: center; gap: 8px; min-height: 48px; padding: 0 18px;
  border: 0; border-radius: 14px; background: var(--accent); color: #fff; font-weight: 700;
}
.send-button:hover, .send-button:focus-visible { background: var(--accent-strong); }
.send-button:disabled { opacity: 0.45; cursor: not-allowed; }
.send-icon { width: 22px; height: 22px; flex: none; }
.send-icon .plane { fill: #fff; }
.send-icon .fold { fill: none; stroke: var(--accent); stroke-width: 1.4; stroke-linecap: round; }
/* Round send button: compact desktop chat and phones (one rule set, class set by the page). */
.composer.is-round .send-button { width: 48px; height: 48px; min-height: 0; padding: 0; border-radius: 50%; }
.composer.is-round .send-label { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }

/* ---------- Results panel ---------- */
.results { display: flex; flex-direction: column; gap: 10px; min-height: 0; padding: 14px 16px; background: #fafafb; }
.results-count { margin: 0; font-size: 14px; color: var(--text-muted); }
.cards { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 12px; flex: 1; min-height: 0; }
.card {
  flex: 1; min-height: 0; display: flex; flex-direction: column; overflow: hidden;
  border: 1px solid var(--line); border-radius: 16px; background: #fff;
}
.card-photo { position: relative; flex: 1; min-height: 0; background: #e9e9ee; border: 0; padding: 0; }
.card-photo img { width: 100%; height: 100%; object-fit: cover; display: block; }
.badge {
  position: absolute; top: 10px; left: 10px; padding: 3px 9px; border-radius: 999px; font-size: 12px; font-weight: 700;
  background: rgb(13 13 15 / 85%); color: #fff;
}
.badge.available { background: var(--ok); }
.badge.la_comanda, .badge.incoming { background: var(--warn); }
.card-info { padding: 10px 14px 12px; display: grid; gap: 4px; }
.card-title { margin: 0; font-size: 18px; line-height: 1.25; }
.card-price { margin: 0; font-size: 26px; font-weight: 800; color: var(--accent-strong); line-height: 1.1; }
.card-data { margin: 0; font-size: 14px; color: var(--text-muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.card-foot { display: flex; align-items: center; justify-content: space-between; gap: 8px; flex-wrap: wrap; }
.card-actions { display: flex; gap: 8px; }
.button-primary, .button-ghost, .link-button {
  display: inline-flex; align-items: center; justify-content: center; padding: 8px 14px; border-radius: 10px;
  font-size: 14px; font-weight: 700; text-decoration: none;
}
.button-primary, .link-button { border: 0; background: var(--accent); color: #fff; }
.button-primary:hover, .link-button:hover { background: var(--accent-strong); }
.button-ghost { border: 1px solid var(--line); background: #fff; color: var(--text); }
.button-ghost:hover { border-color: var(--accent); }
.button-ghost:disabled, .button-primary:disabled { opacity: 0.45; cursor: not-allowed; }
.pager { display: flex; justify-content: space-between; gap: 8px; }

.zero { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; gap: 8px; padding: 10px; }
.zero-art svg { width: 190px; height: auto; }
.zero-title { margin: 0; font-size: 18px; }
.zero-advice { margin: 0; color: var(--text-muted); font-size: 14px; }
.zero-actions { display: flex; flex-wrap: wrap; justify-content: center; gap: 8px; margin-top: 6px; }

/* ---------- Car sheet ---------- */
.sheet { position: relative; z-index: 2; min-height: 0; overflow-y: auto; overscroll-behavior: contain; background: #fff; padding: 14px 16px 24px; }
.sheet-head { display: flex; align-items: flex-start; gap: 10px; }
.sheet-title { flex: 1; margin: 0; font-size: 20px; line-height: 1.25; }
.gallery { position: relative; margin-top: 12px; border-radius: 14px; overflow: hidden; background: #e9e9ee; aspect-ratio: 16 / 10; }
.gallery > img { width: 100%; height: 100%; object-fit: cover; display: block; }
.gallery-arrow {
  position: absolute; top: 50%; transform: translateY(-50%); width: 38px; height: 38px; border-radius: 50%;
  border: 0; background: rgb(13 13 15 / 70%); color: #fff; font-size: 22px; line-height: 1;
}
.gallery-arrow.prev { left: 10px; }
.gallery-arrow.next { right: 10px; }
.thumbs { display: flex; gap: 6px; margin: 8px 0 0; padding: 0 0 4px; list-style: none; overflow-x: auto; overscroll-behavior: contain; }
.thumbs button { flex: none; width: 72px; height: 50px; padding: 0; border: 2px solid transparent; border-radius: 8px; overflow: hidden; background: none; }
.thumbs button[aria-current="true"] { border-color: var(--accent); }
.thumbs img { width: 100%; height: 100%; object-fit: cover; display: block; }
.sheet-price { margin: 12px 0 2px; font-size: 26px; font-weight: 800; color: var(--accent-strong); }
.sheet-status { margin: 0 0 10px; font-size: 14px; color: var(--text-muted); }
.sheet-note { margin: 0 0 10px; font-size: 13px; color: var(--warn); }
.sheet-tabs { display: flex; flex-wrap: wrap; gap: 6px; margin: 12px 0; }
.sheet-section { padding-top: 6px; }
.sheet-section h4 { margin: 10px 0 6px; font-size: 15px; }
.spec-list { display: grid; grid-template-columns: auto 1fr; gap: 6px 14px; margin: 0; font-size: 14px; }
.spec-list dt { color: var(--text-muted); }
.spec-list dd { margin: 0; font-weight: 600; }

/* ---------- Floating buttons ---------- */
.reopen {
  position: fixed; right: 20px; bottom: 20px; z-index: 20; display: inline-flex; align-items: center; gap: 8px;
  padding: 12px 18px; border: 0; border-radius: 999px; background: var(--accent); color: #fff; font-weight: 700;
  box-shadow: 0 10px 30px rgb(0 0 0 / 40%); animation: pop 0.3s ease;
}
.reopen svg { width: 20px; height: 20px; fill: #fff; }
@keyframes pop { from { transform: scale(0.8); opacity: 0; } to { transform: none; opacity: 1; } }
.page-scroll { display: none; }
body:not(.chat-open) .chat { display: none; }

/* ---------- Desktop (≥ 980 px) ---------- */
@media (min-width: 980px) {
  html, body { height: 100%; overflow: hidden; }
  body { zoom: var(--page-zoom); }
  .page {
    max-width: 1560px; height: var(--view-h); margin: 0 auto; padding: 0 var(--side);
    display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 48px; align-items: center;
  }
  .intro { transform: translate(calc(-1 * min(3vw, 60px)), calc(-1 * min(2.5vh, 28px))); }
  .chat {
    --reach: min(108px, calc(var(--side) - 16px));
    width: var(--chat-compact-w); height: min(700px, calc(var(--view-h) - 140px));
    margin-left: auto; margin-right: max(0px, calc((100% - var(--chat-compact-w)) / 2));
    transition: width var(--ease), height var(--ease), margin var(--ease);
  }
  .chat.is-wide {
    width: calc(100% + min(60px, var(--reach)));
    height: min(780px, calc(var(--view-h) - 140px));
    margin-right: calc(-1 * var(--reach));
    margin-left: calc(var(--reach) - min(60px, var(--reach)));
  }
  .chat.is-wide .chat-body { grid-template-columns: minmax(0, 1fr) minmax(0, 1.15fr); }
  .chat.is-wide .results, .chat.is-wide .sheet { border-left: 1px solid var(--line); }
  .sheet { grid-column: 2; grid-row: 1; }
  .results { grid-column: 2; grid-row: 1; }
  .reopen { right: 32px; bottom: 32px; }
}

/* ---------- Phones and tablets (< 980 px): like a messaging app ---------- */
@media (max-width: 979.98px) {
  html { min-height: 100%; }
  body.chat-open, html:has(body.chat-open) { overflow: hidden; }
  .page { padding: 0; display: flex; flex-direction: column; }
  .chat { order: -1; }
  .chat { width: auto; height: calc(100svh - 32px); margin: 16px; border-radius: var(--radius); }
  .chat-body { grid-template-columns: minmax(0, 1fr); }
  .intro { padding: 32px 20px 96px; }
  .composer { padding: 10px 12px 44px; gap: 8px; }
  .composer textarea { height: 44px; padding: 9px 14px; font-size: 16px; }
  .composer .send-button { width: 44px; height: 44px; }
  .msg { font-size: 15px; }
  .chip { padding: 5px 10px; font-size: 13px; }
  .results-slot { list-style: none; }
  .results { padding: 8px 0 0; background: transparent; gap: 8px; }
  .cards { flex: none; gap: 8px; }
  .card { flex: none; flex-direction: row; height: 104px; }
  .card-photo { flex: none; width: 36%; }
  .card-info { flex: 1; min-width: 0; padding: 7px 10px; gap: 3px; align-content: start; }
  .card-foot { gap: 4px; }
  .card-title { font-size: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .card-price { font-size: 17px; }
  .card-data { font-size: 12px; }
  .card-actions .button-primary, .card-actions .button-ghost, .card-actions .link-button { padding: 4px 9px; font-size: 12px; }
  .badge { top: 6px; left: 6px; padding: 2px 6px; font-size: 10px; }
  .pager .button-ghost { padding: 6px 12px; font-size: 13px; }
  .zero-art svg { width: 140px; }
  .sheet { position: absolute; inset: 0; z-index: 5; }
  .page-scroll {
    display: block; position: fixed; right: 8px; top: 50%; transform: translateY(-50%); z-index: 15;
    width: 36px; height: 36px; border-radius: 50%; border: 2px solid #fff; background: var(--accent); color: #fff;
    font-size: 18px; line-height: 1; box-shadow: 0 6px 18px rgb(0 0 0 / 45%);
  }
  body:not(.chat-open) .page-scroll { display: none; }
}
@media (max-width: 559.98px) {
  .chat { margin: 0; border-radius: 0; height: 100svh; }
}

@media (prefers-reduced-motion: reduce) {
  .typing span, .reopen { animation: none; }
  .chat { transition: none; }
}
