/* NobilAuto — Asistent Auto AI. All colors are variables, defined once here. */
:root {
  --bg-1: #1a1e27;
  --bg-2: #222732;
  --bg-3: #2d3342;
  --accent: #fc7926;
  --accent-strong: #c84b0e;
  --accent-soft: rgba(252, 121, 38, 0.12);
  --surface: #ffffff;
  --surface-2: #f5f6f8;
  --line: #e3e5ea;
  --text: #1d212b;
  --text-soft: #5d6372;
  --text-on-dark: #f4f5f7;
  --text-on-dark-soft: #b9bdc8;
  --bubble-bot: #f1f2f5;
  --bubble-user: #222732;
  --shadow: 0 24px 60px rgba(0, 0, 0, 0.35);
  --radius: 22px;
  --page-zoom: 1;
  --chat-compact-w: 460px;
  --gutter: clamp(16px, 5vw, 96px);
  --chat-h: min(700px, calc(100vh / var(--page-zoom) - 140px));
  --chat-h-big: min(780px, calc(100vh / var(--page-zoom) - 140px));
  font-family: "Segoe UI", system-ui, -apple-system, Roboto, Arial, sans-serif;
}

*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }

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

body {
  background: radial-gradient(1200px 700px at 85% 10%, var(--bg-3), transparent 60%), linear-gradient(160deg, var(--bg-2), var(--bg-1));
  background-attachment: fixed;
  color: var(--text-on-dark);
  overflow: hidden;
}

button, textarea { font: inherit; }
button { cursor: pointer; }
button:focus-visible, a:focus-visible, textarea:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }

.visually-hidden { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* ---------- Desktop layout ---------- */
.page {
  zoom: var(--page-zoom);
  max-width: 1560px;
  height: calc(100vh / var(--page-zoom));
  margin: 0 auto;
  padding: 0 var(--gutter);
  display: grid;
  grid-template-columns: minmax(300px, 0.8fr) minmax(0, 1.2fr);
  align-items: center;
  gap: 48px;
}

.intro {
  position: relative;
  left: calc(-1 * min(3vw, 60px));
  top: calc(-1 * min(2.5vh, 28px));
  max-width: 470px;
}
.intro-brand { margin: 0 0 6px; color: var(--accent); font-weight: 700; letter-spacing: 0.08em; text-transform: uppercase; font-size: 13px; }
.intro h1 { margin: 0 0 12px; font-size: 27px; line-height: 1.2; }
.intro-text { margin: 0 0 18px; font-size: 15px; line-height: 1.55; color: var(--text-on-dark-soft); }
.intro-stats { list-style: none; padding: 0; margin: 0 0 18px; display: flex; gap: 22px; }
.intro-stats li { display: flex; flex-direction: column; }
.intro-stats strong { font-size: 18px; color: var(--text-on-dark); }
.intro-stats span { font-size: 12px; color: var(--text-on-dark-soft); }
.intro-list { margin: 0 0 18px; padding-left: 18px; font-size: 13px; line-height: 1.7; color: var(--text-on-dark-soft); }
.intro-list li::marker { color: var(--accent); }
.intro-note { margin: 0; padding: 10px 12px; font-size: 12px; line-height: 1.5; border-left: 3px solid var(--accent); background: rgba(255, 255, 255, 0.05); border-radius: 8px; color: var(--text-on-dark-soft); }

.chat-column { position: relative; height: 100%; display: flex; align-items: center; }

.chat {
  position: relative;
  display: flex;
  flex-direction: column;
  flex: none;
  width: var(--chat-compact-w);
  height: var(--chat-h);
  margin-left: auto;
  margin-right: max(0px, calc((100% - var(--chat-compact-w)) / 2));
  background: var(--surface);
  color: var(--text);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
  transition: width 0.35s ease, height 0.35s ease, margin 0.35s ease, transform 0.35s ease;
}

/* Expanded only when the results panel or a car's sheet is needed (one JS function decides). */
/* --edge = free space right of the column (set by the page script); the chat never goes closer
   than 16px to the window edge, so no sideways scrolling appears. */
.chat[data-mode="expanded"] {
  --grow: max(0px, min(60px, var(--edge, 76px) - 16px));
  width: calc(100% + var(--grow));
  height: var(--chat-h-big);
  margin-right: 0;
  transform: translateX(max(0px, min(48px, var(--edge, 76px) - 16px - var(--grow))));
}

.chat-head { display: flex; align-items: center; gap: 12px; padding: 14px 16px; background: var(--bg-2); color: var(--text-on-dark); }
.chat-avatar { width: 40px; height: 40px; border-radius: 50%; display: grid; place-items: center; background: var(--accent); color: #fff; flex: none; }
.chat-title { flex: 1; min-width: 0; }
.chat-title h2 { margin: 0; font-size: 16px; }
.chat-title p { margin: 2px 0 0; font-size: 12px; color: var(--text-on-dark-soft); }
.online-dot { display: inline-block; width: 8px; height: 8px; margin-right: 6px; border-radius: 50%; background: #3ccf7a; }
.head-btn { width: 36px; height: 36px; border: 0; border-radius: 50%; background: rgba(255, 255, 255, 0.1); color: var(--text-on-dark); font-size: 17px; }
.head-btn:hover { background: rgba(255, 255, 255, 0.2); }

.chat-body { position: relative; flex: 1; min-height: 0; display: grid; grid-template-columns: minmax(0, 1fr); }
.chat[data-mode="expanded"] .chat-body { grid-template-columns: minmax(330px, 0.9fr) minmax(0, 1.1fr); }
/* The sheet covers the results column; closing it shows the same results again. */
.chat[data-mode="expanded"] .results, .chat[data-mode="expanded"] .detail { grid-column: 2; grid-row: 1; }
.chat[data-mode="expanded"] .detail { z-index: 2; }

/* ---------- Messages ---------- */
.messages { list-style: none; margin: 0; padding: 16px; overflow-y: auto; overscroll-behavior: contain; display: flex; flex-direction: column; gap: 10px; }
.msg { max-width: 85%; padding: 10px 14px; border-radius: 16px; font-size: 15px; line-height: 1.5; overflow-wrap: anywhere; }
.msg p { margin: 0; }
.msg ul { margin: 2px 0; padding-left: 20px; list-style: disc; }
.msg a { color: var(--accent-strong); font-weight: 600; }
.msg-bot { align-self: flex-start; background: var(--bubble-bot); border-bottom-left-radius: 6px; }
.msg-user { align-self: flex-end; background: var(--bubble-user); color: var(--text-on-dark); border-bottom-right-radius: 6px; }
.msg-welcome { max-width: 100%; align-self: stretch; }
.chat[data-mode="compact"] .messages > .msg:first-child { margin-top: 20px; }
.welcome-buttons { display: flex; flex-wrap: nowrap; gap: 8px; margin-top: 10px; }
.welcome-buttons button { flex: 1 1 auto; padding: 8px 10px; border: 1px solid var(--accent); border-radius: 999px; background: var(--surface); color: var(--accent-strong); font-size: 13px; font-weight: 600; white-space: nowrap; }
.welcome-buttons button:hover { background: var(--accent-soft); }
.typing { display: inline-flex; gap: 4px; padding: 14px 16px; }
.typing span { width: 7px; height: 7px; border-radius: 50%; background: var(--text-soft); 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; } }

/* ---------- Results panel ---------- */
.results { min-height: 0; overflow-y: auto; overscroll-behavior: contain; padding: 16px; background: var(--surface-2); border-left: 1px solid var(--line); }
.results-head { display: flex; justify-content: space-between; align-items: baseline; margin-bottom: 12px; }
.results-count { margin: 0; font-weight: 700; font-size: 16px; }
.results-page { margin: 0; font-size: 13px; color: var(--text-soft); }
.cards { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; }
.card { display: flex; flex-direction: column; background: var(--surface); border: 1px solid var(--line); border-radius: 16px; overflow: hidden; cursor: pointer; }
.card:hover { border-color: var(--accent); }
.card-photo { width: 100%; aspect-ratio: 1.15; object-fit: cover; background: var(--line); display: block; }
.card-info { padding: 12px 14px 14px; }
.card-title { margin: 0; font-size: 18px; }
.card-price { margin: 4px 0; font-size: 26px; font-weight: 800; color: var(--accent-strong); }
.card-price del { margin-left: 8px; font-size: 15px; font-weight: 500; color: var(--text-soft); }
.card-specs { margin: 0 0 10px; font-size: 14px; color: var(--text-soft); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.card-actions { display: flex; gap: 8px; }
.card-actions > * { flex: 1; white-space: nowrap; padding-left: 8px; padding-right: 8px; }
.results-nav { display: flex; justify-content: space-between; gap: 10px; margin-top: 14px; }
.nav-btn { flex: 1; padding: 9px 12px; border: 1px solid var(--line); border-radius: 12px; background: var(--surface); font-weight: 600; color: var(--text); }
.nav-btn:disabled { opacity: 0.4; cursor: default; }

.btn-primary, .btn-secondary { display: inline-flex; align-items: center; justify-content: center; padding: 9px 14px; border-radius: 12px; font-weight: 700; font-size: 14px; text-decoration: none; border: 1px solid var(--accent-strong); }
.btn-primary { background: var(--accent-strong); color: #fff; }
.btn-secondary { background: var(--surface); color: var(--accent-strong); }
.btn-primary:hover { background: #a93d09; }

.results-zero { text-align: center; padding: 24px 10px; }
.zero-art { width: 210px; max-width: 70%; height: auto; }
.zero-shadow { fill: rgba(34, 39, 50, 0.12); }
.zero-body { fill: var(--bg-2); }
.zero-glass { fill: #8f9bb3; opacity: 0.55; }
.zero-light { fill: var(--accent); }
.zero-grille { fill: #4a5163; }
.zero-bubble { fill: var(--accent); }
.zero-mark { fill: none; stroke: #fff; stroke-width: 4; stroke-linecap: round; }
.zero-dot { fill: #fff; }
.results-zero h3 { margin: 12px 0 6px; font-size: 18px; }
.results-zero p { margin: 0 0 16px; color: var(--text-soft); }
.zero-actions { display: flex; flex-wrap: wrap; gap: 10px; justify-content: center; }

/* ---------- Car sheet ---------- */
.detail { min-height: 0; display: flex; flex-direction: column; background: var(--surface); border-left: 1px solid var(--line); }
.detail-top { padding: 10px 14px; border-bottom: 1px solid var(--line); }
.detail-back { border: 0; background: none; color: var(--accent-strong); font-weight: 700; padding: 4px 0; }
.detail-scroll { flex: 1; min-height: 0; overflow-y: auto; overscroll-behavior: contain; padding: 14px 16px 24px; }
.gallery { position: relative; border-radius: 14px; overflow: hidden; background: var(--line); }
.gallery img { display: block; width: 100%; aspect-ratio: 4 / 3; object-fit: cover; }
.gallery-arrow { position: absolute; top: 50%; transform: translateY(-50%); width: 38px; height: 38px; border: 0; border-radius: 50%; background: rgba(0, 0, 0, 0.55); color: #fff; font-size: 22px; line-height: 1; }
.gallery-arrow.prev { left: 10px; }
.gallery-arrow.next { right: 10px; }
.thumbs { list-style: none; display: flex; gap: 6px; margin: 8px 0 0; padding: 0 0 4px; overflow-x: auto; overscroll-behavior: contain; }
.thumbs button { padding: 0; border: 2px solid transparent; border-radius: 8px; overflow: hidden; background: none; flex: none; }
.thumbs button[aria-current="true"] { border-color: var(--accent); }
.thumbs img { display: block; width: 64px; height: 48px; object-fit: cover; }
.detail-title { margin: 14px 0 2px; font-size: 20px; }
.detail-price { margin: 0 0 10px; font-size: 24px; font-weight: 800; color: var(--accent-strong); }
.detail-price del { margin-left: 8px; font-size: 15px; font-weight: 500; color: var(--text-soft); }
.detail-link { width: 100%; }
.detail-tabs { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; margin: 12px 0; }
.detail-tabs button { padding: 8px 4px; border: 1px solid var(--line); border-radius: 10px; background: var(--surface-2); font-size: 13px; font-weight: 600; color: var(--text); }
.detail-section { padding: 12px 0; border-top: 1px solid var(--line); }
.detail-section h4 { margin: 0 0 8px; font-size: 15px; }
.detail-section p { margin: 0 0 6px; color: var(--text-soft); line-height: 1.5; }
.detail-section ul { margin: 0 0 6px; padding-left: 18px; color: var(--text-soft); }
.detail-section a { color: var(--accent-strong); font-weight: 600; }
.specs { display: grid; grid-template-columns: auto 1fr; gap: 6px 14px; margin: 0; font-size: 14px; }
.specs dt { color: var(--text-soft); }
.specs dd { margin: 0; font-weight: 600; text-align: right; }
.detail-pad { height: 40vh; }

/* ---------- Composer ---------- */
.composer { display: flex; align-items: flex-end; gap: 10px; margin-top: 26px; padding: 0 16px 36px; border-top: 0; position: relative; }
.composer::before { content: ""; position: absolute; left: 0; right: 0; top: -26px; border-top: 1px solid var(--line); }
.composer textarea { flex: 1; height: auto; padding: 14px; font-size: 17px; line-height: 1.45; border: 1px solid var(--line); border-radius: 16px; resize: none; color: var(--text); background: var(--surface-2); }
.send { flex: none; width: 52px; height: 52px; border: 0; border-radius: 50%; background: var(--accent-strong); color: #fff; display: grid; place-items: center; }
.send:disabled { opacity: 0.5; cursor: not-allowed; }
.send-label { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
.send-icon .plane { fill: #fff; }
.send-icon .fold { fill: none; stroke: var(--accent-strong); stroke-width: 1.6; stroke-linecap: round; }

/* ---------- Launcher and scroll button ---------- */
.launcher { 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-strong); color: #fff; font-weight: 700; box-shadow: var(--shadow); animation: pop 0.25s ease; }
@keyframes pop { from { transform: scale(0.85); opacity: 0; } to { transform: scale(1); opacity: 1; } }
.scroll-btn { position: fixed; right: 8px; top: 50%; transform: translateY(-50%); z-index: 15; width: 36px; height: 36px; border: 2px solid #fff; border-radius: 50%; background: var(--accent-strong); color: #fff; font-size: 17px; line-height: 1; box-shadow: 0 4px 14px rgba(0, 0, 0, 0.35); }

html:not(.chat-open) .chat-column { display: none; }
html:not(.chat-open) .page { grid-template-columns: minmax(300px, 1fr); justify-items: center; }

/* ---------- Phone and tablet ---------- */
@media (max-width: 979px) {
  html, body { height: auto; }
  html { min-height: 100%; }
  body { overflow: visible; }
  html.chat-open, html.chat-open body { overflow: hidden; }
  .page { zoom: 1; height: auto; display: flex; flex-direction: column; padding: 0; }
  .chat-column { order: -1; }
  .chat-column { height: 100vh; height: 100dvh; padding: 12px; }
  .chat, .chat[data-mode="expanded"] { width: 100%; height: 100%; margin: 0; transform: none; }
  .chat-body, .chat[data-mode="expanded"] .chat-body { grid-template-columns: minmax(0, 1fr); }
  .intro { left: 0; top: 0; max-width: 640px; margin: 0 auto; padding: 28px 20px 96px; }
  .results { padding: 0; border: 0; background: none; overflow: visible; }
  .results-holder { list-style: none; max-width: 100%; }
  .card { flex-direction: row; }
  .card-photo { width: 36%; aspect-ratio: auto; height: auto; min-height: 104px; }
  .card-info { flex: 1; min-width: 0; padding: 8px 10px; }
  .card-title { font-size: 14px; }
  .card-price { font-size: 17px; margin: 2px 0; }
  .card-price del { font-size: 12px; }
  .card-specs { font-size: 12px; margin-bottom: 6px; }
  .card-actions .btn-primary, .card-actions .btn-secondary { padding: 5px 9px; font-size: 12px; border-radius: 9px; }
  .cards { grid-template-columns: minmax(0, 1fr); gap: 8px; }
  .results-head { margin-bottom: 8px; }
  .results-count { font-size: 14px; }
  .results-nav { margin-top: 8px; }
  .nav-btn { padding: 6px 10px; font-size: 13px; }
  .detail { position: absolute; inset: 0; z-index: 5; border: 0; }
  .composer { margin-top: 0; padding: 10px 12px 44px; border-top: 1px solid var(--line); }
  .composer::before { display: none; }
  .composer textarea { height: 44px; padding: 9px 12px; font-size: 16px; }
  .send { width: 44px; height: 44px; }
  .welcome-buttons button { padding: 6px 8px; font-size: 12px; }
  .msg { font-size: 14px; }
  .chat[data-mode="compact"] .messages > .msg:first-child { margin-top: 0; }
}

@media (max-width: 559px) {
  .chat-column { padding: 0; }
  .chat, .chat[data-mode="expanded"] { border-radius: 0; box-shadow: none; }
  .welcome-buttons { flex-wrap: wrap; }
}

@media (min-width: 980px) {
  .chat[data-mode="expanded"] .send { width: auto; height: 52px; border-radius: 999px; padding: 0 18px; display: inline-flex; gap: 8px; align-items: center; }
  .chat[data-mode="expanded"] .send-label { position: static; width: auto; height: auto; overflow: visible; clip: auto; font-weight: 700; }
}

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