/* ИИ-ассистент — плавающая кнопка и панель чата. Отдельный файл, чтобы
   не раздувать site.css: виджет подключается на все страницы одним script,
   а стили ему нужны свои — цвета и радиусы берём из токенов :root в site.css. */

.assist__fab {
  position: fixed;
  right: clamp(16px, 4vw, 32px);
  bottom: clamp(16px, 4vw, 32px);
  z-index: 70;
  width: 60px;
  height: 60px;
  border-radius: 50%;
  border: 0;
  background: var(--navy);
  color: #fff;
  box-shadow: 0 12px 32px rgba(3, 12, 20, .38);
  cursor: pointer;
  display: grid;
  place-items: center;
  transition: bottom .25s ease, transform .2s ease, background-color .2s ease;
}
.assist__fab:hover { background: #143f63; transform: scale(1.04); }
.assist__fab svg { width: 26px; height: 26px; }
.assist__fab .assist__fab-close { display: none; }
.assist__fab.is-open .assist__fab-chat { display: none; }
.assist__fab.is-open .assist__fab-close { display: block; }
.assist__fab-dot {
  position: absolute;
  top: 3px;
  right: 3px;
  width: 13px;
  height: 13px;
  border-radius: 50%;
  background: var(--amber);
  border: 2px solid var(--navy-bar);
}
.assist__fab-badge {
  position: absolute;
  inset: 0;
  border-radius: 50%;
  border: 2px solid var(--amber);
  opacity: 0;
  animation: assist-pulse 2.4s ease-out 1.2s 2;
}
@keyframes assist-pulse {
  0% { transform: scale(1); opacity: .7; }
  100% { transform: scale(1.5); opacity: 0; }
}

.assist__panel {
  position: fixed;
  right: clamp(12px, 4vw, 32px);
  bottom: clamp(84px, 12vw, 104px);
  z-index: 70;
  width: min(378px, calc(100vw - 24px));
  height: min(560px, calc(100vh - 120px));
  background: var(--surface);
  border-radius: 20px;
  box-shadow: 0 24px 64px rgba(3, 12, 20, .32);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  opacity: 0;
  transform: translateY(16px) scale(.98);
  pointer-events: none;
  transition: opacity .2s ease, transform .2s ease, bottom .25s ease;
}
.assist__panel.is-open { opacity: 1; transform: none; pointer-events: auto; }

.assist__head {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 16px 18px;
  background: var(--navy);
  color: #fff;
}
.assist__head-mark {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: rgba(255, 255, 255, .12);
  display: grid;
  place-items: center;
  flex: 0 0 auto;
}
.assist__head-mark img { width: 20px; height: 20px; }
.assist__head-info { line-height: 1.3; min-width: 0; }
.assist__head-name { font-size: 15px; font-weight: 700; letter-spacing: normal; }
.assist__head-status { font-size: 12px; color: var(--on-dark-2); display: flex; align-items: center; gap: 6px; }
.assist__head-status::before {
  content: "";
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #4ADE80;
  flex: 0 0 auto;
}
.assist__head-actions {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 2px;
  flex: 0 0 auto;
}
.assist__head-close,
.assist__head-reset {
  border: 0;
  background: transparent;
  color: rgba(255, 255, 255, .7);
  width: 30px;
  height: 30px;
  border-radius: 50%;
  cursor: pointer;
  display: grid;
  place-items: center;
  flex: 0 0 auto;
}
.assist__head-close:hover,
.assist__head-reset:hover:not(:disabled) { background: rgba(255, 255, 255, .12); color: #fff; }
/* кнопка сброса появляется только когда есть что сбрасывать — в пустом чате
   она бы только путала */
.assist__head-reset[hidden] { display: none; }
.assist__head-reset:disabled { opacity: .35; cursor: default; }

.assist__body {
  flex: 1 1 auto;
  overflow-y: auto;
  padding: 16px 16px 8px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  background: var(--surface-alt);
}

.assist__msg { display: flex; }
.assist__msg--bot { justify-content: flex-start; }
.assist__msg--user { justify-content: flex-end; }
.assist__bubble {
  max-width: 84%;
  padding: 10px 14px;
  border-radius: 16px;
  font-size: 14px;
  line-height: 1.5;
  letter-spacing: normal;
  white-space: pre-wrap;
  word-break: break-word;
}
.assist__msg--bot .assist__bubble { background: #fff; color: var(--ink); border: 1px solid var(--line-soft); border-bottom-left-radius: 4px; }
.assist__msg--user .assist__bubble { background: var(--navy); color: #fff; border-bottom-right-radius: 4px; }
.assist__msg--error .assist__bubble { background: #fdecea; color: #a4342a; border-color: #f3c6c1; }

.assist__typing { display: inline-flex; gap: 4px; padding: 4px 2px; }
.assist__typing span {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--muted);
  /* Экспоненциальное замедление вместо ease-in-out: точка всплывает быстро
     и мягко оседает, как настоящий предмет. Подъём убавлен с 4 до 3 px -
     индикатор набора не должен перетягивать внимание с самого ответа. */
  animation: assist-typing 1s infinite cubic-bezier(.22, 1, .36, 1);
}
.assist__typing span:nth-child(2) { animation-delay: .15s; }
.assist__typing span:nth-child(3) { animation-delay: .3s; }
@keyframes assist-typing { 0%, 60%, 100% { transform: translateY(0); opacity: .45; } 30% { transform: translateY(-3px); opacity: 1; } }

.assist__chips { display: flex; flex-wrap: wrap; gap: 8px; padding: 0 0 4px; }
.assist__chip {
  border: 1px solid var(--line);
  background: #fff;
  color: var(--navy);
  border-radius: 9999px;
  padding: 7px 14px;
  font-size: 13px;
  letter-spacing: normal;
  cursor: pointer;
  transition: background-color .15s ease, border-color .15s ease;
}
.assist__chip:hover { background: var(--surface-alt); border-color: var(--navy); }

.assist__foot { flex: 0 0 auto; border-top: 1px solid var(--line-soft); background: #fff; padding: 10px 12px; }
.assist__form { display: flex; align-items: flex-end; gap: 8px; }
.assist__input {
  flex: 1 1 auto;
  resize: none;
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 10px 14px;
  font: inherit;
  font-size: 14px;
  line-height: 1.4;
  max-height: 90px;
  color: var(--ink);
}
.assist__input:focus { outline: 2px solid var(--amber); outline-offset: 1px; }
.assist__send {
  flex: 0 0 auto;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  border: 0;
  background: var(--amber);
  color: var(--navy);
  cursor: pointer;
  display: grid;
  place-items: center;
  transition: background-color .15s ease, opacity .15s ease;
}
.assist__send:hover { background: #ffb254; }
.assist__send:disabled { opacity: .4; cursor: default; }
.assist__send svg { width: 18px; height: 18px; }
/* 12 px - нижняя граница читаемости. Здесь она особенно важна: в дисклеймере
   стоит телефон, по которому уходят из чата к живому менеджеру. */
.assist__disclaimer { margin-top: 6px; color: var(--muted); font-size: 12px; line-height: 1.35; letter-spacing: normal; }

/* На странице каталога снизу липнет ещё и панель выбранных позиций —
   поднимаем кнопку ассистента, чтобы они не перекрывались. */
body:has([data-pickbar]:not([hidden])) .assist__fab { bottom: 92px; }
body:has([data-pickbar]:not([hidden])) .assist__panel { bottom: 160px; }

@media (max-width: 480px) {
  .assist__panel { right: 8px; left: 8px; width: auto; bottom: 78px; height: min(72vh, 560px); }
  .assist__fab { right: 14px; bottom: 14px; width: 54px; height: 54px; }
  body:has([data-pickbar]:not([hidden])) .assist__fab { bottom: 86px; }
  body:has([data-pickbar]:not([hidden])) .assist__panel { bottom: 148px; }
}
