/* ==========================================================================
   Чат подбора запчастей. Та же палитра и типографика, что в панели,
   но интерфейс рассчитан на телефон в руке у клиента.
   ========================================================================== */

:root{
  --bg:        #f6f7f9;
  --surface:   #ffffff;
  --surface-2: #f1f3f6;
  --line:      #e5e8ee;
  --line-soft: #eef0f4;

  --ink:   #101419;
  --ink-2: #4a5361;
  --ink-3: #79828f;

  --accent:     #2f6fed;
  --accent-ink: #ffffff;
  --accent-soft:#2f6fed14;

  --ok:    #0a7f52;
  --ok-bg: #0a7f5214;
  --danger:#c9331f;
  --danger-bg:#c9331f14;

  --r:    12px;
  --r-lg: 18px;
  --bubble: 18px;
  --shadow: 0 1px 2px rgba(16,24,40,.05), 0 2px 8px rgba(16,24,40,.05);

  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;
}

@media (prefers-color-scheme: dark){
  :root{
    --bg:        #0e1117;
    --surface:   #161b23;
    --surface-2: #1e242e;
    --line:      #252d38;
    --line-soft: #1f2631;
    --ink:   #e7ebf1;
    --ink-2: #a3adbb;
    --ink-3: #78828f;
    --accent:#5b8def;  --accent-soft:#5b8def1f;
    --ok:#3fb98a;      --ok-bg:#3fb98a1c;
    --danger:#e8705c;  --danger-bg:#e8705c1c;
    --shadow: 0 1px 2px rgba(0,0,0,.3), 0 2px 10px rgba(0,0,0,.3);
  }
}

*,*::before,*::after{ box-sizing:border-box }
html{ -webkit-text-size-adjust:100% }

body{
  margin:0;
  background:var(--bg);
  color:var(--ink);
  font:400 15px/1.55 var(--font);
  -webkit-font-smoothing:antialiased;
  overscroll-behavior-y:none;
}

:focus-visible{ outline:2px solid var(--accent); outline-offset:2px; border-radius:6px }

@media (prefers-reduced-motion:reduce){
  *{ animation-duration:.01ms !important; transition-duration:.01ms !important; scroll-behavior:auto !important }
}

/* ---------------------------------------------------------------- каркас */

.chat{
  max-width:780px; margin:0 auto;
  height:100dvh; display:flex; flex-direction:column;
  background:var(--surface);
  border-left:1px solid var(--line); border-right:1px solid var(--line);
}
@media (max-width:820px){ .chat{ border-left:0; border-right:0 } }

.head{
  display:flex; align-items:center; gap:12px;
  padding:13px 18px calc(13px);
  padding-top:max(13px, env(safe-area-inset-top));
  border-bottom:1px solid var(--line);
  background:var(--surface);
  flex-shrink:0;
}
.logo{
  width:38px; height:38px; border-radius:11px; flex-shrink:0;
  background:var(--accent); color:#fff;
  display:grid; place-items:center;
}
.logo svg{ width:21px; height:21px }
.head h1{ font-size:15.5px; font-weight:650; margin:0; letter-spacing:-.01em }
.head .status{ display:flex; align-items:center; gap:6px; font-size:12.5px; color:var(--ink-3); margin-top:1px }
.dot{ width:7px; height:7px; border-radius:50%; background:var(--ok); flex-shrink:0 }

/* ---------------------------------------------------------------- лента */

.log{
  flex:1; overflow-y:auto; -webkit-overflow-scrolling:touch;
  padding:20px 18px 8px;
  display:flex; flex-direction:column; gap:14px;
  scroll-behavior:smooth;
}

.msg{ max-width:86%; display:flex; flex-direction:column; gap:4px }
.msg .body{
  padding:11px 15px; border-radius:var(--bubble);
  word-wrap:break-word; overflow-wrap:anywhere;
}
.msg .body p{ margin:0 }
.msg .body p + p{ margin-top:8px }
.msg .body ul{ margin:8px 0 0; padding-left:18px }
.msg .body li + li{ margin-top:4px }
.msg .body b{ font-weight:650 }
.msg .body code{ font-family:var(--mono); font-size:13.5px }

.msg.bot{ align-self:flex-start }
.msg.bot .body{
  background:var(--surface-2); color:var(--ink);
  border-bottom-left-radius:6px;
}
.msg.me{ align-self:flex-end; align-items:flex-end }
.msg.me .body{
  background:var(--accent); color:var(--accent-ink);
  border-bottom-right-radius:6px;
}

.msg .time{ font-size:11px; color:var(--ink-3); padding:0 6px }

.sys{
  align-self:center; max-width:100%; text-align:center;
  font-size:13px; color:var(--danger);
  background:var(--danger-bg); border:1px solid #c9331f2e;
  padding:9px 14px; border-radius:var(--r);
}

.tool{
  align-self:flex-start; display:flex; align-items:center; gap:7px;
  font-size:12px; color:var(--ink-3); padding-left:4px;
}
.tool svg{ width:13px; height:13px }

/* карточка успешной заявки */
.order-ok{
  align-self:stretch;
  border:1px solid #0a7f5233; background:var(--ok-bg);
  border-radius:var(--r); padding:14px 16px;
}
.order-ok .t{ font-weight:650; color:var(--ok); display:flex; align-items:center; gap:8px; font-size:14px }
.order-ok .t svg{ width:17px; height:17px }
.order-ok .no{ font-family:var(--mono); font-size:19px; font-weight:600; margin-top:6px; letter-spacing:.02em }
.order-ok .sub{ font-size:13px; color:var(--ink-2); margin-top:4px }

/* индикатор набора */
.typing{ display:flex; gap:4px; align-items:center; padding:14px 16px }
.typing i{
  width:7px; height:7px; border-radius:50%; background:var(--ink-3);
  animation:blink 1.3s infinite ease-in-out;
}
.typing i:nth-child(2){ animation-delay:.18s }
.typing i:nth-child(3){ animation-delay:.36s }
@keyframes blink{ 0%,64%,100%{ opacity:.22; transform:translateY(0) } 32%{ opacity:1; transform:translateY(-2px) } }

/* ---------------------------------------------------------------- подсказки */

.chips{ display:flex; gap:8px; flex-wrap:wrap; padding:6px 18px 14px; flex-shrink:0 }
.chip{
  font:inherit; font-size:13.5px;
  padding:8px 14px; border-radius:20px;
  border:1px solid var(--line); background:var(--surface);
  color:var(--ink-2); cursor:pointer;
  transition:border-color .12s, color .12s;
}
.chip:hover{ border-color:var(--accent); color:var(--accent) }

/* ---------------------------------------------------------------- ввод */

.composer{
  display:flex; gap:10px; align-items:flex-end;
  padding:12px 18px;
  padding-bottom:max(12px, env(safe-area-inset-bottom));
  border-top:1px solid var(--line);
  background:var(--surface);
  flex-shrink:0;
}
.composer textarea{
  flex:1; resize:none; font:inherit; color:var(--ink);
  padding:11px 15px; max-height:130px; min-height:44px;
  background:var(--bg); border:1px solid var(--line);
  border-radius:22px; line-height:1.45;
  transition:border-color .12s, box-shadow .12s;
}
.composer textarea::placeholder{ color:var(--ink-3) }
.composer textarea:focus{
  outline:none; border-color:var(--accent);
  box-shadow:0 0 0 3px var(--accent-soft);
}
.send{
  width:44px; height:44px; flex-shrink:0;
  border:0; border-radius:50%;
  background:var(--accent); color:#fff;
  display:grid; place-items:center; cursor:pointer;
  transition:filter .12s, opacity .12s;
}
.send svg{ width:19px; height:19px }
.send:hover{ filter:brightness(1.08) }
.send:disabled{ opacity:.45; cursor:default; filter:none }

.foot{
  font-size:11.5px; color:var(--ink-3); text-align:center;
  padding:0 18px 10px; padding-bottom:max(10px, env(safe-area-inset-bottom));
  flex-shrink:0; background:var(--surface);
}

/* доступно скринридеру, не видно глазом */
.sr-only{
  position:absolute; width:1px; height:1px; padding:0; margin:-1px;
  overflow:hidden; clip:rect(0 0 0 0); white-space:nowrap; border:0;
}
