/* ПРАЙМ — AI-консультант: страница чата + AI-форма hero главной.
   Самодостаточный файл: подключается блоком extra_head из chat.html и home.html
   (в base.html его НЕТ). Токены берём из site.css (--brand, --line, ...). */

/* ============ чат ============ */
.as-chat {
  display: flex; flex-direction: column;
  /* полноэкранно под липкой шапкой: мобайл ~132px шапка+отступы */
  height: calc(100dvh - 132px);
  min-height: 380px;
  margin-top: 10px;
}
@media (min-width: 768px) {
  .as-chat { height: calc(100dvh - 196px); margin-top: 14px; }
}

.as-log {
  flex: 1; overflow-y: auto; -webkit-overflow-scrolling: touch;
  display: flex; flex-direction: column; gap: 12px;
  padding: 6px 2px 14px;
}

/* пузыри */
.as-msg { display: flex; }
.as-user { justify-content: flex-end; }
.as-bot { justify-content: flex-start; }
.as-bubble {
  max-width: min(680px, 88%);
  padding: 10px 14px; font-size: 14.5px; line-height: 1.5;
  border-radius: 14px; overflow-wrap: break-word;
}
.as-user .as-bubble {
  background: var(--brand-soft); border: 1px solid #FFD3B8;
  border-bottom-right-radius: 4px; color: var(--ink);
}
.as-bot .as-bubble {
  background: var(--paper); border: 1px solid var(--line);
  border-bottom-left-radius: 4px; box-shadow: var(--shadow);
}
.as-hello { margin: 0; }
.as-error { color: var(--bad); background: var(--bad-soft); border-color: #F5C6C6; }
.as-error a { color: var(--bad); font-weight: 600; text-decoration: underline; }

/* примеры-кнопки в приветствии */
.as-examples { display: flex; flex-wrap: wrap; gap: 7px; margin-top: 10px; }
.as-example {
  padding: 7px 12px; font-size: 13px; font-weight: 500;
  background: var(--bg-soft); color: var(--txt-2);
  border: 1.5px solid var(--line-2); border-radius: 18px;
  transition: border-color .15s, color .15s, background .15s;
}
.as-example:hover { border-color: var(--brand); color: var(--brand-hot); background: var(--brand-soft); }

/* спиннер «подбираю…» */
.as-typing { color: var(--txt-2); display: inline-flex; align-items: baseline; gap: 4px; }
.as-dots i {
  display: inline-block; width: 5px; height: 5px; margin-left: 3px;
  background: var(--brand); border-radius: 50%;
  animation: as-blink 1.2s infinite;
}
.as-dots i:nth-child(2) { animation-delay: .2s; }
.as-dots i:nth-child(3) { animation-delay: .4s; }
@keyframes as-blink { 0%, 60%, 100% { opacity: .25; } 30% { opacity: 1; } }

/* карточки товаров в сообщении: горизонтальный скролл-ряд */
.as-products {
  display: flex; gap: 10px; overflow-x: auto;
  margin: 10px -4px 2px; padding: 2px 4px 6px;
  scrollbar-width: thin;
}
.as-card {
  flex: 0 0 158px; display: flex; flex-direction: column;
  background: var(--paper); border: 1px solid var(--line); border-radius: var(--r-s);
  overflow: hidden; transition: box-shadow .15s, border-color .15s;
}
.as-card:hover { box-shadow: var(--shadow-up); border-color: var(--line-2); }
.as-card-img {
  height: 110px; display: grid; place-items: center;
  background: #fff; padding: 8px; border-bottom: 1px solid var(--line);
}
.as-card-img img { max-height: 100%; max-width: 100%; min-width: 0; min-height: 0; object-fit: contain; }
.as-noimg {
  font-family: var(--font-b); font-weight: 800; font-size: 13px;
  letter-spacing: .16em; color: var(--line-2);
}
.as-card-body { display: flex; flex-direction: column; align-items: flex-start; gap: 6px; flex: 1; padding: 8px 10px 10px; }
.as-card-name {
  font-size: 12.5px; line-height: 1.35; font-weight: 500; color: var(--txt);
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical;
  overflow: hidden; min-height: calc(1.35em * 2); align-self: stretch;
}
.as-card-name:hover { color: var(--brand-hot); }
.as-card .stock { font-size: 11px; padding: 2px 8px; }
.as-card-foot {
  margin-top: auto; align-self: stretch;
  display: flex; align-items: center; justify-content: space-between; gap: 6px;
}
.as-price {
  font-family: var(--font-d); font-weight: 700; font-size: 15.5px;
  letter-spacing: .02em; white-space: nowrap; color: var(--ink);
}
.as-price small { font-size: 11px; font-weight: 500; }
.as-open {
  padding: 5px 10px; font-size: 12px; font-weight: 600;
  background: var(--brand-soft); color: var(--brand-hot); border-radius: 6px;
  transition: background .15s, color .15s; white-space: nowrap;
}
.as-open:hover { background: var(--brand); color: #fff; }

/* липкий инпут снизу */
.as-input {
  display: flex; gap: 8px; padding: 10px 0 12px;
  border-top: 1px solid var(--line); background: var(--bg);
}
.as-input input {
  flex: 1; min-width: 0; height: 46px; padding: 0 15px;
  background: var(--bg-soft); border: 1.5px solid var(--line-2);
  border-radius: var(--r-s); color: var(--txt); font-size: 15px;
  transition: border-color .15s, box-shadow .15s, background .15s;
}
.as-input input::placeholder { color: var(--txt-3); }
.as-input input:focus {
  outline: none; background: #fff; border-color: var(--brand);
  box-shadow: 0 0 0 3px rgba(245, 91, 15, .18);
}

/* ============ hero главной: поле ИИ-подбора ============ */
.hero-ai { position: relative; z-index: 2; max-width: 560px; margin: 0; }
.hero-ai-lbl {
  display: block; margin-bottom: 8px;
  font-size: 13px; font-weight: 600; color: var(--txt-2);
}
.hero-ai-row {
  display: flex; align-items: center; gap: 8px; padding: 6px 6px 6px 14px;
  background: #fff; border: 1.5px solid var(--line-2); border-radius: 999px;
  box-shadow: var(--shadow); transition: border-color .15s, box-shadow .15s;
}
.hero-ai-row:focus-within { border-color: var(--brand); box-shadow: 0 0 0 4px rgba(245,91,15,.14); }
.hero-ai-ic { flex: none; color: var(--brand); }
.hero-ai-row input {
  flex: 1; min-width: 0; height: 42px; padding: 0;
  background: transparent; border: 0; color: var(--txt); font-size: 15px;
}
.hero-ai-row input::placeholder { color: var(--txt-3); }
.hero-ai-row input:focus { outline: none; }
.hero-ai-row .btn { flex: none; min-height: 42px; padding: 8px 22px; }
@media (max-width: 560px) {
  .hero-ai-row { flex-wrap: wrap; border-radius: var(--r); padding: 10px; }
  .hero-ai-row input { width: 100%; flex-basis: 100%; order: 1; padding: 0 4px; }
  .hero-ai-ic { display: none; }
  .hero-ai-row .btn { order: 2; width: 100%; }
}

/* подсказки-примеры под полем */
.hero-ai-hints { display: flex; flex-wrap: wrap; gap: 7px; margin-top: 10px; }
.ai-hint {
  padding: 6px 12px; font-size: 12.5px; font-weight: 500;
  background: #fff; color: var(--txt-2);
  border: 1px solid var(--line-2); border-radius: 999px;
  transition: border-color .15s, color .15s, background .15s;
}
.ai-hint:hover { border-color: var(--brand); color: var(--brand-hot); background: var(--brand-soft); }

/* ============ плавающая кнопка ИИ (на всех страницах) ============ */
.ai-fab {
  position: fixed; right: 16px; bottom: 16px; z-index: 80;
  display: inline-flex; align-items: center; gap: 9px;
  padding: 13px 18px; background: var(--ink); color: #fff;
  border-radius: 999px; font-size: 14px; font-weight: 600;
  box-shadow: 0 6px 18px rgba(20,24,29,.26);
  transition: background .16s, box-shadow .16s, transform .12s;
}
.ai-fab:hover { background: var(--brand); color: #fff; box-shadow: 0 8px 24px var(--brand-glow); transform: translateY(-2px); }
.ai-fab svg { flex: none; }
/* на узких экранах — компактный круг без подписи (не закрывает контент) */
@media (max-width: 560px) {
  .ai-fab { right: 12px; bottom: 12px; padding: 14px; }
  .ai-fab-tx { display: none; }
}
/* в корзине/чекауте снизу свои кнопки — приподнимаем, чтобы не перекрывать */
body.has-bottom-bar .ai-fab { bottom: 76px; }
