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

/* ============ герой главной: стеклянная консоль подбора ============ */
.console {
  margin-top: 26px; padding: 16px; border-radius: 22px;
  background: linear-gradient(180deg, rgba(255,255,255,.10), rgba(255,255,255,.035));
  border: 1px solid var(--hair-2); backdrop-filter: blur(18px);
  box-shadow: 0 24px 60px rgba(0,0,0,.45), inset 0 1px 0 rgba(255,255,255,.14);
}
.console-top { display: flex; align-items: center; gap: 9px; margin-bottom: 12px; }
.console-top label {
  font-family: var(--font-m); font-size: 11px; letter-spacing: .12em;
  text-transform: uppercase; color: var(--steel);
}
.dot3 { display: inline-flex; gap: 4px; }
.dot3 i {
  display: block; width: 6px; height: 6px; border-radius: 50%; background: var(--brand);
  animation: cn-blip 1.5s ease-in-out infinite;
}
.dot3 i:nth-child(2) { animation-delay: .2s; opacity: .75; }
.dot3 i:nth-child(3) { animation-delay: .4s; opacity: .5; }
@keyframes cn-blip { 0%, 100% { transform: translateY(0); opacity: .45; } 50% { transform: translateY(-3px); opacity: 1; } }

.console-row {
  display: flex; align-items: center; gap: 10px; padding: 7px 7px 7px 15px;
  background: rgba(6,9,13,.62); border: 1px solid var(--hair); border-radius: 14px;
}
.console-row > svg { color: var(--ember); flex: none; }
.console-row input {
  flex: 1; min-width: 0; height: 46px; padding: 0;
  background: none; border: 0; color: #fff; font-size: 15px;
}
.console-row input::placeholder { color: #7C8B9C; }
.console-row input:focus { outline: none; }
.btn-go {
  flex: none; height: 46px; padding: 0 24px; border: 0; border-radius: 11px; white-space: nowrap;
  background: linear-gradient(180deg, var(--ember), var(--brand)); color: #fff;
  font-weight: 600; font-size: 14.5px;
  box-shadow: 0 8px 22px var(--brand-glow); transition: filter .16s, transform .08s;
}
.btn-go:hover { filter: brightness(1.08); }
.btn-go:active { transform: translateY(1px); }
@media (max-width: 560px) {
  .console-row { flex-wrap: wrap; padding: 12px; gap: 10px; }
  .console-row > svg { display: none; }
  .console-row input { flex: 1 1 100%; height: 34px; font-size: 15px; }
  .btn-go { flex: 1 1 100%; height: 48px; }
}

/* подсказки-примеры: на мобиле горизонтальный скроллер с намёком на продолжение */
.hints { display: flex; flex-wrap: wrap; gap: 7px; margin-top: 12px; }
.ai-hint {
  padding: 8px 13px; border: 1px solid var(--hair); border-radius: 999px;
  background: rgba(255,255,255,.045); color: var(--steel);
  font-size: 12.5px; white-space: nowrap;
  transition: border-color .16s, color .16s, background .16s;
}
.ai-hint:hover { border-color: var(--brand); color: #fff; background: rgba(245,91,15,.15); }
@media (max-width: 719px) {
  .hints {
    flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none;
    margin-inline: -4px; padding: 2px 4px 4px;
    -webkit-mask-image: linear-gradient(90deg, #000 86%, transparent);
    mask-image: linear-gradient(90deg, #000 86%, transparent);
  }
  .hints::-webkit-scrollbar { display: none; }
  .ai-hint { flex: none; }
}

/* ============ страница чата ============ */
.as-chat {
  display: flex; flex-direction: column;
  height: calc(100dvh - 210px); min-height: 380px; margin-top: 10px;
}
@media (min-width: 768px) { .as-chat { height: calc(100dvh - 250px); 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: 11px 15px; font-size: 14.5px; line-height: 1.5;
  border-radius: 14px; overflow-wrap: break-word;
}
.as-user .as-bubble { background: var(--brand); color: #fff; border-bottom-right-radius: 4px; }
.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 {
  min-height: 40px; padding: 8px 13px; 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: var(--bg-soft); 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 {
  align-self: stretch; 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);
}
.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: 6px 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: 48px; 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); }

/* ============ плавающая кнопка ИИ (на всех страницах, кроме главной и чата) ============ */
.ai-fab {
  position: fixed; right: 16px; z-index: 80;
  bottom: calc(16px + env(safe-area-inset-bottom));
  display: inline-flex; align-items: center; gap: 9px;
  min-height: 48px; 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,.28);
  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: calc(12px + env(safe-area-inset-bottom)); padding: 13px; }
  .ai-fab-tx { display: none; }
  /* запас снизу, чтобы кнопка не легла на последнюю строку страницы */
  body:has(.ai-fab) .ftr-bottom { padding-bottom: 78px; }
}
/* в корзине/чекауте снизу свои кнопки — приподнимаем, чтобы не перекрывать */
body.has-bottom-bar .ai-fab { bottom: calc(76px + env(safe-area-inset-bottom)); }

/* ============ плашка контекста товара в чате ============ */
.as-ctx {
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
  margin: 12px 0 0; padding: 10px 14px;
  background: var(--brand-soft); border: 1px solid rgba(245,91,15,.28);
  border-radius: var(--r-s);
}
.as-ctx-lbl {
  font-family: var(--font-m); font-size: 10.5px; letter-spacing: .08em;
  text-transform: uppercase; color: var(--brand-hot); flex: none;
}
.as-ctx-name { flex: 1; min-width: 160px; font-size: 13.5px; font-weight: 500; color: var(--ink); }
.as-ctx-name:hover { color: var(--brand-hot); }
.as-ctx-sku { font-size: 12px; color: var(--txt-3); }
.as-ctx-off {
  flex: none; width: 26px; height: 26px; display: grid; place-items: center;
  border-radius: 50%; color: var(--txt-2); font-size: 13px;
}
.as-ctx-off:hover { background: #fff; color: var(--bad); }

/* кнопка «Перейти в каталог» под ответом консультанта */
.as-more {
  display: inline-flex; align-items: center; gap: 9px; margin-top: 12px;
  padding: 10px 18px; border-radius: 999px;
  background: var(--brand); color: #fff; font-size: 14px; font-weight: 600;
  transition: background .15s, box-shadow .15s, transform .06s;
}
.as-more:hover { background: var(--brand-hot); color: #fff; box-shadow: 0 6px 18px var(--brand-glow); }
.as-more:active { transform: translateY(1px); }
.as-more b {
  padding: 2px 8px; border-radius: 999px; background: rgba(255,255,255,.22);
  font-family: var(--font-m); font-size: 12px; font-weight: 600;
}
