/* САНАТА-АВТО — стили виджета ИИ-чата.
   Использует только существующие переменные из styles.css (:root) —
   без новой палитры. Инлайн-style="" не используется (html-validate). */

.chatw {
  position: fixed;
  right: 16px;
  bottom: 16px;
  z-index: 60;
}

/* ---------- Кнопка-переключатель ---------- */
.chatw__toggle {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 56px;
  height: 56px;
  border: none;
  border-radius: var(--r-pill);
  background: var(--blue-accent);
  color: var(--white);
  box-shadow: var(--sh-lg);
  transition: background var(--tr), box-shadow var(--tr), transform var(--tr);
}
.chatw__toggle:hover {
  background: var(--blue-accent-hover);
  box-shadow: var(--sh-hover);
}
.chatw__toggle:active {
  background: var(--blue-accent-press);
  transform: translateY(1px);
}
.chatw__toggle .icon {
  width: 26px;
  height: 26px;
}
.chatw__icon-close {
  display: none;
}
.chatw__toggle.is-open .chatw__icon-open {
  display: none;
}
.chatw__toggle.is-open .chatw__icon-close {
  display: block;
}

/* ---------- Панель ---------- */
.chatw__panel {
  position: fixed;
  right: 16px;
  bottom: 84px;
  width: min(380px, calc(100vw - 32px));
  height: min(560px, calc(100vh - 96px));
  display: flex;
  flex-direction: column;
  background: var(--white);
  border-radius: var(--r-xl);
  box-shadow: var(--sh-lg);
  overflow: hidden;
  border: 1px solid var(--border);
}

/* Атрибут hidden должен побеждать display:flex — иначе панель раскрыта при загрузке */
.chatw__panel[hidden] {
  display: none;
}

@media (max-width: 600px) {
  .chatw__panel {
    inset: 0;
    right: 0;
    bottom: 0;
    width: 100%;
    height: 100%;
    border-radius: 0;
    border: none;
  }
}

/* ---------- Шапка панели ---------- */
.chatw__header {
  display: flex;
  align-items: baseline;
  gap: var(--sp-2);
  padding: var(--sp-4) var(--sp-5);
  background: var(--blue-deep);
  color: var(--white);
  flex: none;
  position: relative;
}
.chatw__title {
  font-weight: 700;
  font-size: var(--fs-body);
}
.chatw__subtitle {
  font-size: var(--fs-xs);
  color: var(--text-on-dark);
}
.chatw__close {
  margin-left: auto;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border: none;
  border-radius: var(--r-sm);
  background: transparent;
  color: var(--white);
  flex: none;
}
.chatw__close:hover {
  background: rgba(255, 255, 255, 0.12);
}
.chatw__close .icon {
  width: 18px;
  height: 18px;
}

/* ---------- Лента сообщений ---------- */
.chatw__messages {
  flex: 1 1 auto;
  overflow-y: auto;
  padding: var(--sp-4) var(--sp-4);
  display: flex;
  flex-direction: column;
  gap: var(--sp-2);
  background: var(--bg-light);
}

.chatw__row {
  display: flex;
}
.chatw__row--user {
  justify-content: flex-end;
}
.chatw__row--bot,
.chatw__row--operator {
  justify-content: flex-start;
}

.chatw__bubble {
  max-width: 84%;
  padding: 0.6rem 0.85rem;
  border-radius: var(--r-md);
  font-size: var(--fs-small);
  line-height: var(--lh);
  word-wrap: break-word;
  overflow-wrap: anywhere;
}
.chatw__bubble--user {
  background: var(--blue-accent);
  color: var(--white);
  border-bottom-right-radius: var(--r-sm);
}
.chatw__bubble--bot {
  background: var(--white);
  color: var(--text);
  border: 1px solid var(--border);
  border-bottom-left-radius: var(--r-sm);
}
.chatw__bubble--operator {
  background: var(--surface-on-dark);
  color: var(--white);
  border-bottom-left-radius: var(--r-sm);
}
.chatw__bubble ul {
  margin: var(--sp-1) 0;
  padding-left: 1.1em;
  list-style: disc;
}
.chatw__bubble strong {
  font-weight: 700;
}

.chatw__note {
  align-self: center;
  font-size: var(--fs-xs);
  color: var(--text-muted);
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: var(--r-pill);
  padding: 0.3rem 0.75rem;
}

/* ---------- Статус (печатает…) ---------- */
.chatw__status {
  min-height: 1.2em;
  padding: 0 var(--sp-4);
  font-size: var(--fs-xs);
  color: var(--text-muted);
  flex: none;
}

/* ---------- Форма ввода ---------- */
.chatw__form {
  display: flex;
  align-items: center;
  gap: var(--sp-2);
  padding: var(--sp-3) var(--sp-4);
  border-top: 1px solid var(--border);
  background: var(--white);
  flex: none;
}
.chatw__input {
  flex: 1 1 auto;
  min-height: 44px;
  padding: 0.6rem 0.9rem;
  border: 1.5px solid var(--border-strong);
  border-radius: var(--r-pill);
  font: inherit;
  font-size: var(--fs-small);
  color: var(--text);
  background: var(--bg-light);
}
.chatw__input:focus-visible {
  outline: 3px solid var(--blue-accent);
  outline-offset: 1px;
}
.chatw__send {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  flex: none;
  border: none;
  border-radius: var(--r-pill);
  background: var(--blue-accent);
  color: var(--white);
  transition: background var(--tr);
}
.chatw__send:hover {
  background: var(--blue-accent-hover);
}
.chatw__send:disabled {
  opacity: 0.6;
  cursor: default;
}
.chatw__send .icon {
  width: 20px;
  height: 20px;
}
