/*
 * AI-ассистент покупателя — стили виджета (docs/ai-assistant/widget.md §9).
 * Bootstrap 4 контекст. Фирменные цвета Снабженца: индиго #323b86 + жёлтый #feec00.
 */
#assistant-widget {
  --asst-indigo: #323b86;
  --asst-indigo-dark: #28306e;
  --asst-yellow: #feec00;
  --asst-bot-bg: #eef1f8;
  --asst-text: #2e3846;
  --asst-muted: #7d8597;
  --asst-radius: 18px;
  --asst-z: 10500;
}

/* ---- launcher (кнопка-маскот + сообщение) ---- */
.assistant-fab {
  position: fixed;
  right: 24px;
  bottom: 24px;
  z-index: var(--asst-z);
  display: flex;
  align-items: center;
  gap: 10px;
}
.assistant-fab__msg {
  background: #fff;
  color: var(--asst-indigo);
  font-size: 13px;
  font-weight: 600;
  border: 1px solid #e6e9f2;
  border-radius: 16px 16px 4px 16px;
  padding: 9px 14px;
  box-shadow: 0 6px 18px rgba(50, 59, 134, 0.18);
  cursor: pointer;
  max-width: 180px;
  line-height: 1.3;
  animation: asst-msg-in 0.4s ease both;
  transition: opacity 0.35s ease, transform 0.35s ease;
}
.assistant-fab__msg:hover { background: #f5f6fb; }
@keyframes asst-msg-in { from { opacity: 0; transform: translateX(12px); } to { opacity: 1; transform: none; } }
/* свёрнут (через пару секунд после захода): бабл скрыт, иконка-маскот остаётся */
.assistant-fab.fab-collapsed .assistant-fab__msg {
  opacity: 0;
  transform: translateX(10px) scale(0.92);
  pointer-events: none;
}
.assistant-launcher {
  position: relative;
  flex: 0 0 auto;
  width: 64px;
  height: 64px;
  border-radius: 50%;
  border: none;
  padding: 0;
  background: var(--asst-indigo);
  box-shadow: 0 8px 24px rgba(50, 59, 134, 0.4);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}
.assistant-launcher:hover { transform: translateY(-3px) scale(1.04); box-shadow: 0 12px 30px rgba(50, 59, 134, 0.5); }
/* иконка (прозрачный PNG) на белом круге внутри индиго-launcher */
.assistant-launcher .assistant-mascot { width: 50px; height: 50px; background: #fff; border-radius: 50%; padding: 6px; box-sizing: border-box; }
/* пульс-кольцо (жёлтый акцент) — мягко привлекает внимание */
.assistant-launcher__pulse {
  position: absolute;
  inset: 0;
  border-radius: 50%;
  border: 2px solid var(--asst-yellow);
  opacity: 0;
  animation: asst-pulse 2.6s ease-out infinite;
  pointer-events: none;
}
@keyframes asst-pulse {
  0% { transform: scale(1); opacity: 0.7; }
  70% { transform: scale(1.5); opacity: 0; }
  100% { opacity: 0; }
}
#assistant-widget.assistant-open .assistant-fab { display: none; }

.assistant-mascot { display: block; object-fit: contain; }

/* ---- panel ---- */
.assistant-panel {
  position: fixed;
  right: 24px;
  bottom: 24px;
  width: 384px;
  height: 560px;
  max-height: calc(100vh - 40px);
  background: #fff;
  border-radius: var(--asst-radius);
  box-shadow: 0 16px 48px rgba(33, 40, 90, 0.32);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  z-index: var(--asst-z);
  color: var(--asst-text);
}
.assistant-panel[hidden] { display: none; }

/* ---- header (аватар-маскот + заголовки) ---- */
.assistant-header {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 13px 16px;
  background: linear-gradient(135deg, var(--asst-indigo) 0%, var(--asst-indigo-dark) 100%);
  color: #fff;
}
.assistant-avatar {
  flex: 0 0 auto;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 0 0 2px var(--asst-yellow);
}
.assistant-avatar .assistant-mascot { width: 30px; height: 30px; }
.assistant-header__titles { flex: 1 1 auto; display: flex; flex-direction: column; line-height: 1.2; min-width: 0; }
.assistant-title { font-weight: 700; font-size: 15px; }
.assistant-subtitle { font-size: 11.5px; opacity: 0.8; }
.assistant-subtitle::before {
  content: ''; display: inline-block; width: 7px; height: 7px; border-radius: 50%;
  background: #3ad07a; margin-right: 5px; vertical-align: middle;
}
.assistant-close {
  flex: 0 0 auto;
  background: none; border: none; color: #fff; font-size: 26px; line-height: 1;
  cursor: pointer; opacity: 0.85; padding: 0 2px;
}
.assistant-close:hover { opacity: 1; }

/* ---- лента сообщений ---- */
.assistant-lenta {
  flex: 1 1 auto;
  overflow-y: auto;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  background: #f7f8fb;
}
.assistant-msg {
  max-width: 88%;
  padding: 10px 13px;
  border-radius: 14px;
  font-size: 14px;
  line-height: 1.45;
  word-wrap: break-word;
  white-space: pre-wrap;
}
.assistant-msg--user {
  align-self: flex-end;
  background: var(--asst-indigo);
  color: #fff;
  border-bottom-right-radius: 5px;
}
.assistant-msg--bot {
  align-self: flex-start;
  background: var(--asst-bot-bg);
  color: var(--asst-text);
  border-bottom-left-radius: 5px;
}
.assistant-msg--error { background: #fdecec; color: #a12020; }
.assistant-retry { background: none; border: none; color: var(--asst-indigo); text-decoration: underline; cursor: pointer; padding: 0; font: inherit; }
.assistant-empty { font-style: italic; color: var(--asst-muted); }
.assistant-fallback-link { margin-top: 8px; display: inline-block; }

/* индикатор «печатает» */
.assistant-typing { color: var(--asst-muted); font-style: italic; }
.assistant-typing span {
  display: inline-block; width: 6px; height: 6px; margin-right: 2px; border-radius: 50%;
  background: var(--asst-indigo); opacity: 0.5; animation: asst-blink 1.2s infinite both;
}
.assistant-typing span:nth-child(2) { animation-delay: 0.2s; }
.assistant-typing span:nth-child(3) { animation-delay: 0.4s; }
@keyframes asst-blink { 0%, 80%, 100% { opacity: 0.25; } 40% { opacity: 1; } }

/* каретка во время «печати» ответа (плавный стриминг) */
.assistant-msg--streaming .assistant-msg__text::after {
  content: '';
  display: inline-block;
  width: 2px;
  height: 1.05em;
  margin-left: 1px;
  vertical-align: -2px;
  background: var(--asst-indigo);
  opacity: 0.7;
  animation: asst-caret 0.9s step-end infinite;
}
@keyframes asst-caret { 0%, 100% { opacity: 0.7; } 50% { opacity: 0; } }

/* ---- онбординг ---- */
.assistant-onboarding { padding: 4px 2px; }
.assistant-onboarding__title { font-size: 17px; font-weight: 700; color: var(--asst-indigo); margin-bottom: 5px; }
.assistant-onboarding__hi { font-size: 13.5px; color: var(--asst-text); margin-bottom: 13px; line-height: 1.5; }
.assistant-chips { display: flex; flex-wrap: wrap; gap: 8px; }
.assistant-chip {
  border: 1.5px solid #d7dbef;
  color: var(--asst-indigo);
  background: #fff;
  border-radius: 18px;
  padding: 7px 13px;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.12s ease, color 0.12s ease, border-color 0.12s ease;
}
.assistant-chip:hover { background: var(--asst-indigo); color: #fff; border-color: var(--asst-indigo); }

/* ---- карточки товаров ---- */
.assistant-cards { display: flex; flex-direction: column; gap: 9px; align-self: stretch; }
.assistant-card {
  display: flex;
  gap: 11px;
  border: 1px solid #e6e9f2;
  border-radius: 12px;
  padding: 9px;
  background: #fff;
  box-shadow: 0 1px 3px rgba(50, 59, 134, 0.06);
}
.assistant-card__thumb { flex: 0 0 66px; width: 66px; height: 66px; }
.assistant-card__thumb img { width: 66px; height: 66px; object-fit: contain; border-radius: 8px; }
.assistant-card__body { flex: 1 1 auto; min-width: 0; display: flex; flex-direction: column; gap: 3px; }
.assistant-card__title {
  font-size: 13px; font-weight: 600; color: var(--asst-text); text-decoration: none; line-height: 1.3;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}
.assistant-card__title:hover { color: var(--asst-indigo); }
.assistant-card__price { font-size: 14px; }
.assistant-card__price .product-price,
.assistant-card__price .product-price-discount { font-weight: 700; color: var(--asst-indigo); }
.assistant-card__price .product-price-default { color: var(--asst-muted); font-size: 12px; margin-right: 4px; text-decoration: line-through; }
.assistant-card__actions { display: flex; align-items: center; gap: 6px; margin-top: 3px; flex-wrap: wrap; }
.assistant-card__actions .assistant-go {
  font-size: 12px; padding: 5px 8px; color: var(--asst-indigo); font-weight: 600;
  text-decoration: none; background: none; border: none; cursor: pointer; border-radius: 8px;
}
.assistant-card__actions .assistant-go:hover { text-decoration: underline; }
.assistant-card__actions .assistant-add {
  font-size: 12px; padding: 6px 13px; border-radius: 9px; border: none; cursor: pointer;
  background: var(--asst-indigo); color: #fff !important; font-weight: 600; line-height: 1.2;
}
.assistant-card__actions .assistant-add:hover { background: var(--asst-indigo-dark); color: #fff !important; }
.assistant-card__actions .assistant-add i { margin-right: 4px; color: #fff !important; }
.assistant-card__actions .assistant-await {
  font-size: 12px; padding: 6px 13px; border-radius: 9px; border: 1px solid #d7dbe6;
  background: #eef0f5; color: var(--asst-muted); cursor: default; font-weight: 500;
}

/* «Добавить комплект» — кнопка под набором карточек (≥2 товара в наличии) */
.assistant-kit {
  align-self: stretch;
  margin-top: 3px;
  padding: 10px 14px;
  border: none;
  border-radius: 10px;
  background: var(--asst-yellow);
  color: var(--asst-indigo);
  font-weight: 700;
  font-size: 13.5px;
  cursor: pointer;
  transition: filter 0.12s ease;
}
.assistant-kit:hover { filter: brightness(0.95); }
.assistant-kit:disabled { cursor: default; opacity: 0.9; }
.assistant-kit--done { background: #e3f6ea; color: #1c7a3e; }

/* бейджи наличия */
.assistant-badge { display: inline-block; font-size: 11px; padding: 1px 8px; border-radius: 10px; width: fit-content; font-weight: 500; }
.assistant-badge.in-stock { background: #e3f6ea; color: #1c7a3e; }
.assistant-badge.low { background: #fff3e0; color: #a35a00; }
.assistant-badge.await { background: #eceef6; color: var(--asst-muted); }

/* ---- инпут (textarea авто-рост) ---- */
.assistant-inputbar {
  flex: 0 0 auto;
  display: flex;
  align-items: flex-end;
  gap: 8px;
  padding: 11px 13px;
  border-top: 1px solid #eceef4;
  background: #fff;
}
.assistant-input {
  flex: 1 1 auto;
  border: 1.5px solid #d6dae8;
  border-radius: 20px;
  padding: 9px 15px;
  font-size: 14px;
  font-family: inherit;
  line-height: 1.4;
  outline: none;
  resize: none;
  overflow-y: auto;
  max-height: 120px;
  min-height: 40px;
}
.assistant-input:focus { border-color: var(--asst-indigo); }
.assistant-send {
  flex: 0 0 auto;
  width: 42px; height: 42px;
  border-radius: 50%;
  border: none;
  background: var(--asst-yellow);
  color: var(--asst-indigo);
  font-size: 16px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: filter 0.12s ease;
}
.assistant-send:hover { filter: brightness(0.94); }
.assistant-send:disabled { opacity: 0.5; cursor: default; }

/* кнопка голосового ввода (видна только если браузер поддерживает Web Speech API) */
.assistant-mic {
  flex: 0 0 auto;
  width: 42px; height: 42px;
  border-radius: 50%;
  border: none;
  background: #eef1f8;
  color: var(--asst-indigo);
  font-size: 15px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.12s ease, color 0.12s ease;
}
.assistant-mic[hidden] { display: none; }
.assistant-mic:hover { background: #e2e6f3; }
/* активное прослушивание — красный с пульсом */
.assistant-mic.listening { background: #e7402f; color: #fff; animation: asst-mic-pulse 1.3s ease-out infinite; }
@keyframes asst-mic-pulse {
  0% { box-shadow: 0 0 0 0 rgba(231, 64, 47, 0.5); }
  70% { box-shadow: 0 0 0 11px rgba(231, 64, 47, 0); }
  100% { box-shadow: 0 0 0 0 rgba(231, 64, 47, 0); }
}

/* ---- мобилка: панель на весь экран ---- */
@media (max-width: 767px) {
  .assistant-panel {
    right: 0; bottom: 0; top: 0; left: 0;
    width: 100%; height: 100%;
    max-height: 100%;
    border-radius: 0;
  }
  .assistant-fab { right: 14px; bottom: 14px; gap: 8px; }
  .assistant-launcher { width: 58px; height: 58px; }
  .assistant-fab__msg { max-width: 148px; font-size: 12px; padding: 8px 12px; }
  /* >=16px — iOS Safari НЕ зумит страницу при фокусе в поле ("без приближений") */
  .assistant-input { font-size: 16px; }
  .assistant-msg { max-width: 90%; }
  .assistant-onboarding__title { font-size: 18px; }
}

/* Уведомление о рекомендательных технологиях (149-ФЗ ст. 10.2-2) — мелкая строка под полем ввода */
.assistant-disclaimer { font-size: 10px; line-height: 1.3; text-align: center; color: #9aa0a6; padding: 3px 12px 7px; }
.assistant-disclaimer a { color: #9aa0a6; text-decoration: underline; }
