/* ИИ-ассистент сайта — плавающий виджет.
   Сознательно НЕ похож на «связь с оператором» (никакого зелёного
   пульсирующего индикатора «онлайн», никакой иконки трубки/наушников):
   значок — искра/нейросеть, в шапке прямым текстом «ИИ» и пояснение,
   что это не оператор. */

.ai-fab {
  position: fixed; right: 22px; bottom: 22px; z-index: 200;
  width: 58px; height: 58px; border-radius: 50%;
  background: var(--teal); color: #fff; border: none; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  box-shadow: 0 6px 20px rgba(20,40,45,.25);
  transition: transform .15s, background .15s;
}
.ai-fab:hover { background: var(--teal-deep); transform: translateY(-2px); }
.ai-fab svg { width: 26px; height: 26px; }
.ai-fab .ai-fab-badge {
  position: absolute; top: -4px; right: -4px;
  background: var(--coral); color: #fff; font-size: .6rem; font-weight: 700;
  letter-spacing: .04em; padding: 2px 5px; border-radius: 7px;
  line-height: 1.2;
}
.ai-panel.open ~ .ai-fab, .ai-fab.hidden { display: none; }

.ai-panel {
  position: fixed; right: 22px; bottom: 22px; z-index: 201;
  width: 360px; max-width: calc(100vw - 32px);
  height: 520px; max-height: calc(100vh - 100px);
  background: var(--surface); border: 1px solid var(--line); border-radius: 16px;
  box-shadow: 0 12px 40px rgba(20,40,45,.22);
  display: none; flex-direction: column; overflow: hidden;
}
.ai-panel.open { display: flex; }

.ai-head {
  display: flex; align-items: center; gap: 10px;
  padding: 14px 14px 12px; background: var(--teal-tint); border-bottom: 1px solid var(--line);
}
.ai-head-ic {
  width: 34px; height: 34px; border-radius: 10px; background: var(--teal); color: #fff;
  display: flex; align-items: center; justify-content: center; flex-shrink: 0;
}
.ai-head-ic svg { width: 19px; height: 19px; }
.ai-head-txt { flex: 1; min-width: 0; }
.ai-head-txt b { display: block; font-size: .92rem; color: var(--ink); }
.ai-head-txt span { display: block; font-size: .72rem; color: var(--ink-soft); margin-top: 1px; }
.ai-close {
  background: none; border: none; cursor: pointer; color: var(--ink-soft);
  width: 28px; height: 28px; border-radius: 8px; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
}
.ai-close:hover { background: rgba(0,0,0,.06); color: var(--ink); }

.ai-body { flex: 1; overflow-y: auto; padding: 14px; display: flex; flex-direction: column; gap: 10px; }
.ai-msg { max-width: 86%; font-size: .88rem; line-height: 1.45; padding: 9px 12px; border-radius: 12px; white-space: pre-line; }
.ai-msg.bot { align-self: flex-start; background: var(--teal-tint); color: var(--ink); border-bottom-left-radius: 4px; }
.ai-msg.user { align-self: flex-end; background: var(--teal); color: #fff; border-bottom-right-radius: 4px; }
.ai-msg.err { align-self: flex-start; background: #fdeae4; color: #b34a30; border-bottom-left-radius: 4px; }
.ai-disclaimer {
  align-self: center; font-size: .72rem; color: var(--ink-soft); text-align: center;
  padding: 6px 10px; max-width: 92%;
}

.ai-typing { align-self: flex-start; display: flex; gap: 4px; padding: 9px 12px; }
.ai-typing span { width: 6px; height: 6px; border-radius: 50%; background: var(--teal); opacity: .5; animation: ai-bounce 1.2s infinite; }
.ai-typing span:nth-child(2) { animation-delay: .2s; }
.ai-typing span:nth-child(3) { animation-delay: .4s; }
@keyframes ai-bounce { 0%,60%,100%{transform:translateY(0);opacity:.4} 30%{transform:translateY(-4px);opacity:1} }

.ai-input-row {
  display: flex; gap: 8px; padding: 10px; border-top: 1px solid var(--line); background: var(--surface);
}
.ai-input-row textarea {
  flex: 1; resize: none; border: 1px solid var(--line); border-radius: 10px;
  padding: 9px 11px; font: inherit; font-size: .88rem; color: var(--ink); background: var(--bg);
  max-height: 90px;
}
.ai-input-row textarea:focus { outline: 2px solid var(--teal); outline-offset: 1px; }
.ai-send {
  width: 40px; height: 40px; flex-shrink: 0; border-radius: 10px; border: none; cursor: pointer;
  background: var(--teal); color: #fff; display: flex; align-items: center; justify-content: center;
}
.ai-send:hover { background: var(--teal-deep); }
.ai-send:disabled { opacity: .5; cursor: default; }

@media (max-width: 480px) {
  .ai-panel { right: 8px; bottom: 8px; left: 8px; width: auto; height: calc(100vh - 90px); }
  .ai-fab { right: 16px; bottom: 16px; }
}
