/* CarFinder24 design system — warm neutrals, no gray, one accent.
   Light/dark via CSS variables; [data-theme="dark"] on <html> flips them. */

:root {
  --bg: #f8f6f2;
  --surface: #ffffff;
  --surface2: #fffdf9;
  --ink: #1c1917;
  --sub: #7c6247;
  --border: #e8e2d9;
  --accent: #2563eb;
  --accent-soft: #eff6ff;
  --accent-ink: #1d4ed8;
  --danger: #dc2626;
  --bubble: #f3ede3;
  --chip-km-bg: #f3ede3;
  --chip-km-ink: #7c6247;
  --chip-diesel-bg: #fef3c7;  --chip-diesel-ink: #92400e;
  --chip-petrol-bg: #ccfbf1;  --chip-petrol-ink: #0f766e;
  --chip-electric-bg: #dcfce7; --chip-electric-ink: #166534;
  --chip-hybrid-bg: #ecfccb;  --chip-hybrid-ink: #3f6212;
  --shadow: 0 8px 24px rgba(28, 25, 23, 0.12);
  --photo-bg: linear-gradient(135deg, #dbeafe 0%, #ede9dd 100%);
}

[data-theme="dark"] {
  --bg: #1c1917;
  --surface: #292524;
  --surface2: #241f1d;
  --ink: #f5f0e8;
  --sub: #c4b39c;
  --border: #3f3a35;
  --accent: #3b82f6;
  --accent-soft: #1e2a45;
  --accent-ink: #93c5fd;
  --bubble: #332e28;
  --chip-km-bg: #332e28;
  --chip-km-ink: #d3c3ab;
  --chip-diesel-bg: #3d2e10;  --chip-diesel-ink: #fbbf24;
  --chip-petrol-bg: #0f2e2a;  --chip-petrol-ink: #5eead4;
  --chip-electric-bg: #122e1b; --chip-electric-ink: #86efac;
  --chip-hybrid-bg: #263312;  --chip-hybrid-ink: #bef264;
  --shadow: 0 8px 24px rgba(0, 0, 0, 0.45);
  --photo-bg: linear-gradient(135deg, #1e2a45 0%, #332e28 100%);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
}

body {
  font-family: Inter, system-ui, -apple-system, "Segoe UI", sans-serif;
  background: var(--bg);
  color: var(--ink);
  -webkit-font-smoothing: antialiased;
}

#root { height: 100%; }

button {
  font: inherit;
  cursor: pointer;
  border: none;
  background: none;
  color: inherit;
  padding: 0;
}

.icon {
  width: 16px;
  height: 16px;
  stroke: currentColor;
  fill: none;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
  flex-shrink: 0;
}

/* ---------- app frame ---------- */

.app {
  height: 100%;
  display: flex;
  flex-direction: column;
}

.app-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 14px 22px;
  background: var(--surface2);
  border-bottom: 1px solid var(--border);
  position: relative;
}

.wordmark {
  font-weight: 700;
  font-size: 18px;
  letter-spacing: -0.02em;
  color: var(--ink);
}

.wordmark b { color: var(--accent); font-weight: 700; }

.icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  border-radius: 9px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--sub);
}

.icon-btn:hover { color: var(--ink); }

.icon-btn.active {
  background: var(--accent-soft);
  color: var(--accent-ink);
  border-color: transparent;
}

/* ---------- settings popover ---------- */

.settings-pop {
  position: absolute;
  top: 54px;
  right: 18px;
  z-index: 40;
  width: 250px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  box-shadow: var(--shadow);
  padding: 14px;
  font-size: 13px;
}

.settings-title {
  font-weight: 700;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--sub);
  margin: 0 0 12px;
}

.settings-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
}

.settings-row + .settings-row {
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px solid var(--border);
}

.seg {
  display: inline-flex;
  border: 1px solid var(--border);
  border-radius: 8px;
  overflow: hidden;
}

.seg button {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 5px 10px;
  font-size: 12px;
  color: var(--sub);
}

.seg button.on {
  background: var(--accent-soft);
  color: var(--accent-ink);
  font-weight: 600;
}

.conn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-weight: 600;
  color: #166534;
}

[data-theme="dark"] .conn { color: #86efac; }

.conn .dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #22c55e;
}

.conn.off { color: var(--sub); }
.conn.off .dot { background: var(--sub); }

/* ---------- landing ---------- */

.landing {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 18px;
  padding: 32px;
  text-align: center;
}

.landing h1 {
  font-size: 42px;
  letter-spacing: -0.03em;
  margin: 0;
}

.landing h1 b { color: var(--accent); font-weight: 700; }

.landing .tagline {
  color: var(--sub);
  font-size: 17px;
  max-width: 460px;
  line-height: 1.55;
  margin: 0;
}

.start-btn {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  background: var(--accent);
  color: #fff;
  font-weight: 600;
  font-size: 16px;
  padding: 13px 28px;
  border-radius: 999px;
  margin-top: 8px;
}

.start-btn:hover { filter: brightness(1.08); }

.landing .error {
  color: var(--danger);
  font-size: 14px;
  max-width: 480px;
}

/* ---------- workspace ---------- */

.workspace {
  flex: 1;
  display: flex;
  min-height: 0;
}

.results {
  flex: 1;
  overflow-y: auto;
  padding: 20px 22px;
}

.results-empty {
  height: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 10px;
  color: var(--sub);
  text-align: center;
  padding: 24px;
}

.results-empty .icon { width: 34px; height: 34px; opacity: 0.55; }

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

.car-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  overflow: hidden;
}

.car-photo {
  height: 140px;
  background: var(--photo-bg);
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}

.car-photo img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.car-photo .icon {
  width: 40px;
  height: 40px;
  color: var(--accent);
  opacity: 0.5;
}

.car-body { padding: 12px 14px; }

.car-title { font-weight: 600; font-size: 15px; }

.car-price { font-weight: 700; font-size: 17px; margin: 4px 0 8px; }

.chips { display: flex; flex-wrap: wrap; gap: 5px; }

.chip {
  font-size: 11px;
  font-weight: 600;
  padding: 3px 9px;
  border-radius: 999px;
  white-space: nowrap;
}

.chip-year { background: var(--accent-soft); color: var(--accent-ink); }
.chip-km { background: var(--chip-km-bg); color: var(--chip-km-ink); }
.chip-diesel { background: var(--chip-diesel-bg); color: var(--chip-diesel-ink); }
.chip-petrol { background: var(--chip-petrol-bg); color: var(--chip-petrol-ink); }
.chip-electric { background: var(--chip-electric-bg); color: var(--chip-electric-ink); }
.chip-hybrid { background: var(--chip-hybrid-bg); color: var(--chip-hybrid-ink); }

.car-city {
  display: flex;
  align-items: center;
  gap: 5px;
  color: var(--sub);
  font-size: 12px;
  margin-top: 9px;
}

.car-city .icon { width: 12px; height: 12px; }

.msg-bubble {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 14px 16px;
  font-size: 15px;
  line-height: 1.55;
  max-width: 560px;
  white-space: pre-wrap;
}

/* ---------- transcript ---------- */

.transcript {
  width: 340px;
  flex-shrink: 0;
  border-left: 1px solid var(--border);
  background: var(--surface2);
  display: flex;
  flex-direction: column;
  padding: 14px;
  gap: 9px;
  overflow-y: auto;
}

.transcript-title {
  font-weight: 700;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--sub);
}

.t-msg {
  font-size: 13.5px;
  line-height: 1.45;
  padding: 8px 12px;
  max-width: 88%;
}

.t-msg.me {
  align-self: flex-end;
  background: var(--accent);
  color: #fff;
  border-radius: 13px 13px 4px 13px;
}

.t-msg.agent {
  align-self: flex-start;
  background: var(--bubble);
  color: var(--ink);
  border-radius: 13px 13px 13px 4px;
}

.sheet-handle { display: none; }

/* ---------- call bar ---------- */

.call-bar {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 12px 20px;
  background: var(--surface2);
  border-top: 1px solid var(--border);
}

.mic-btn {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: var(--accent);
  color: #fff;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: none;
}

.mic-btn[data-lk-enabled="false"],
.mic-btn.muted {
  background: var(--surface);
  color: var(--danger);
  border: 1px solid var(--danger);
}

.meter {
  display: flex;
  gap: 3px;
  align-items: flex-end;
  height: 16px;
}

.meter span {
  width: 3px;
  min-height: 3px;
  background: var(--accent);
  border-radius: 2px;
  transition: height 90ms linear;
}

.call-status { font-size: 13px; color: var(--sub); }

.call-right {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 10px;
}

.end-btn {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  background: var(--danger);
  color: #fff;
  font-size: 13px;
  font-weight: 600;
  border-radius: 999px;
  padding: 9px 18px;
  border: none;
}

.end-btn:hover { filter: brightness(1.1); }

/* ---------- approval modal ---------- */

.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(28, 25, 23, 0.45);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 60;
  padding: 20px;
}

.modal {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 14px;
  box-shadow: var(--shadow);
  max-width: 420px;
  width: 100%;
  padding: 22px;
}

.modal h3 { margin: 0 0 8px; font-size: 17px; }

.modal p { margin: 0 0 18px; color: var(--sub); font-size: 14px; line-height: 1.5; }

.modal-actions { display: flex; gap: 10px; justify-content: flex-end; }

.btn-primary {
  background: var(--accent);
  color: #fff;
  font-weight: 600;
  font-size: 14px;
  border-radius: 9px;
  padding: 9px 20px;
}

.btn-outline {
  border: 1px solid var(--border);
  color: var(--ink);
  font-weight: 600;
  font-size: 14px;
  border-radius: 9px;
  padding: 9px 20px;
  background: var(--surface);
}

/* hide the LiveKit StartAudio helper unless it's needed */
.lk-start-audio-button { position: fixed; bottom: 76px; right: 20px; z-index: 50; }

/* ---------- car detail (product page) ---------- */

.car-detail { max-width: 860px; margin: 0 auto; }

.detail-hero {
  display: grid;
  grid-template-columns: minmax(0, 380px) 1fr;
  gap: 22px;
  align-items: start;
}
.detail-photo {
  aspect-ratio: 4 / 3;
  border-radius: 14px;
  overflow: hidden;
  background: var(--surface);
  border: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: center;
}
.detail-photo img { width: 100%; height: 100%; object-fit: cover; display: block; }
.detail-photo .icon { width: 44px; height: 44px; opacity: 0.5; }

.detail-summary h2 { font-size: 24px; margin: 2px 0 0; }
.detail-version { color: var(--sub); font-size: 13px; margin: 4px 0 10px; }
.detail-price {
  font-size: 27px;
  font-weight: 700;
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 10px;
}
.detail-hint { color: var(--sub); font-size: 13px; margin-top: 14px; }

.detail-specs {
  display: grid;
  grid-template-columns: 1fr 1fr;
  column-gap: 28px;
  margin: 22px 0 6px;
}
.spec-row {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 8px 0;
  border-bottom: 1px solid var(--border);
  font-size: 14px;
}
.spec-label { color: var(--sub); }
.spec-value { font-weight: 600; text-align: right; }

.detail-condition { margin: 14px 0 4px; }

.equip-group { margin-top: 18px; }
.equip-group h4 {
  margin: 0 0 8px;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--sub);
}

/* ---------- typed input row ---------- */

.chat-row {
  display: flex;
  gap: 8px;
  padding: 8px 18px;
  background: var(--surface2);
  border-top: 1px solid var(--border);
}
.chat-row input {
  flex: 1;
  min-width: 0;
  padding: 10px 14px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--ink);
  font: inherit;
  font-size: 14px;
}
.chat-row input:focus { outline: 2px solid var(--accent); outline-offset: -1px; }

/* ---------- avatar PiP (lower right, Zoom-style) ---------- */

.avatar-pip {
  position: fixed;
  right: 14px;
  bottom: 80px; /* clears the call bar */
  width: 220px;
  aspect-ratio: 16 / 9;
  border-radius: 12px;
  overflow: hidden;
  border: 1px solid var(--border);
  background: var(--surface);
  box-shadow: 0 8px 28px rgba(28, 25, 23, 0.25);
  z-index: 45;
}
.avatar-pip.raised { bottom: 138px; } /* clears the typed-input row too */
.avatar-pip video { width: 100%; height: 100%; object-fit: cover; display: block; }

/* ---------- mobile (≤720px) ---------- */

@media (max-width: 720px) {
  .app-header { padding: 12px 16px; }
  .results { padding: 14px 16px; }
  .cars-grid { grid-template-columns: 1fr; }
  .car-photo { height: 160px; }

  .workspace { position: relative; }

  .transcript {
    position: absolute;
    left: 0;
    right: 0;
    bottom: 0;
    top: 32%;
    width: auto;
    border-left: none;
    border-top: 1px solid var(--border);
    border-radius: 16px 16px 0 0;
    box-shadow: var(--shadow);
    z-index: 30;
  }

  .sheet-handle {
    display: block;
    width: 36px;
    height: 4px;
    border-radius: 2px;
    background: var(--border);
    margin: 0 auto 4px;
  }

  .call-bar { padding: 10px 14px; gap: 10px; }
  .call-status { display: none; }
  .end-btn { padding: 9px 14px; }

  .detail-hero { grid-template-columns: 1fr; }
  .detail-specs { grid-template-columns: 1fr; }

  .avatar-pip { width: 150px; right: 10px; bottom: 72px; }
  .avatar-pip.raised { bottom: 124px; }
}
