/* Чат-виджет «Аня» — в палитре frontend2 (redesign.css :root). Фолбэки на случай,
   если переменные не подгрузились. Шалфейный акцент (--sage, «спокойное доверие»),
   янтарные CTA (--amber, как кнопки сайта), кремовые фоны, текст --ink, шрифт Manrope. */

#kc-chat {
  position: fixed; right: 24px; bottom: 24px; z-index: 9999;
  font-family: 'Manrope', system-ui, -apple-system, sans-serif;
  color: var(--ink, #2B2620);
}

/* атрибут hidden должен прятать элементы с явным display (flex переопределяет [hidden]) */
.kc-chat__launcher[hidden], .kc-chat__window[hidden], .kc-chat__lead[hidden] { display: none; }

/* ── лаунчер ── */
.kc-chat__launcher {
  width: 60px; height: 60px; border-radius: 50%; border: none; cursor: pointer;
  background: var(--sage, #5C7A68); color: var(--cream, #F7F2E9);
  display: flex; align-items: center; justify-content: center;
  box-shadow: var(--shadow-sm, 10px 14px 30px -16px rgba(60,42,18,.30));
  transition: transform .18s ease, box-shadow .18s ease;
}
.kc-chat__launcher:hover { transform: translateY(-2px); box-shadow: var(--shadow, 24px 32px 64px -28px rgba(60,42,18,.28)); }
.kc-chat__launcher svg { width: 26px; height: 26px; }

/* ── окно ── */
.kc-chat__window {
  width: 372px; max-width: calc(100vw - 32px);
  height: 540px; max-height: calc(100vh - 48px);
  background: var(--cream-2, #FBF8F2);
  border: 1px solid var(--line, #E5DACA);
  border-radius: var(--r, 22px);
  box-shadow: var(--shadow, 24px 32px 64px -28px rgba(60,42,18,.28));
  display: flex; flex-direction: column; overflow: hidden;
}

/* ── шапка ── */
.kc-chat__header {
  display: flex; align-items: center; gap: 10px;
  padding: 14px 16px;
  background: var(--sage, #5C7A68); color: var(--cream, #F7F2E9);
}
.kc-chat__avatar {
  width: 34px; height: 34px; border-radius: 50%; flex: 0 0 auto;
  background: var(--amber-glow, #F0C886); color: var(--ink, #2B2620);
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 15px; letter-spacing: .01em;
}
.kc-chat__title { flex: 1; font-weight: 600; font-size: 14px; line-height: 1.25; }
.kc-chat__close {
  background: none; border: none; color: var(--cream, #F7F2E9);
  font-size: 24px; line-height: 1; cursor: pointer; opacity: .85; padding: 0 2px;
}
.kc-chat__close:hover { opacity: 1; }

/* ── лента сообщений ── */
.kc-chat__log {
  flex: 1; overflow-y: auto; padding: 16px;
  display: flex; flex-direction: column; gap: 10px;
  background: var(--cream, #F7F2E9);
}
.kc-chat__log::-webkit-scrollbar { width: 8px; }
.kc-chat__log::-webkit-scrollbar-thumb { background: var(--sand, #EBE0CF); border-radius: 8px; }

.kc-chat__msg {
  max-width: 86%; padding: 10px 14px; border-radius: 16px;
  font-size: 14px; line-height: 1.5; white-space: pre-wrap; word-wrap: break-word;
}
.kc-chat__msg--assistant {
  align-self: flex-start; background: #fff;
  border: 1px solid var(--line, #E5DACA);
  border-bottom-left-radius: 6px; color: var(--ink, #2B2620);
}
.kc-chat__msg--user {
  align-self: flex-end; background: var(--sage-soft, #E4ECE5);
  border-bottom-right-radius: 6px; color: var(--ink, #2B2620);
}
.kc-chat__typing { opacity: .7; font-style: italic; color: var(--ink-soft, #6A6155); }
.kc-chat__tel { color: var(--amber-deep, #9C6322); font-weight: 600; text-decoration: underline; white-space: nowrap; }

/* ── форма заявки ── */
.kc-chat__lead {
  display: flex; gap: 8px; padding: 10px 14px;
  border-top: 1px solid var(--line, #E5DACA); background: var(--cream-2, #FBF8F2);
}
.kc-chat__lead input {
  flex: 1; min-width: 0; padding: 10px 12px; font: inherit; font-size: 14px;
  color: var(--ink, #2B2620); background: #fff;
  border: 1px solid var(--line, #E5DACA); border-radius: 12px;
}

/* ── поле ввода ── */
.kc-chat__form {
  display: flex; gap: 8px; align-items: flex-end; padding: 12px 14px;
  border-top: 1px solid var(--line, #E5DACA); background: var(--cream-2, #FBF8F2);
}
.kc-chat__input {
  flex: 1; resize: none; max-height: 96px; padding: 10px 12px;
  font: inherit; font-size: 14px; color: var(--ink, #2B2620); background: #fff;
  border: 1px solid var(--line, #E5DACA); border-radius: 14px;
}
.kc-chat__input:focus, .kc-chat__lead input:focus {
  outline: none; border-color: var(--sage, #5C7A68);
  box-shadow: 0 0 0 3px var(--sage-soft, #E4ECE5);
}

/* ── кнопки-CTA (янтарь, как на сайте) ── */
.kc-chat__send {
  flex: 0 0 auto; width: 42px; height: 42px; border: none; cursor: pointer;
  border-radius: 12px; background: var(--amber, #C58A3D); color: #fff;
  display: flex; align-items: center; justify-content: center;
  transition: background .15s ease;
}
.kc-chat__send svg { width: 20px; height: 20px; }
.kc-chat__lead-send {
  flex: 0 0 auto; padding: 0 16px; border: none; cursor: pointer; border-radius: 12px;
  background: var(--amber, #C58A3D); color: #fff; font: inherit; font-weight: 600; font-size: 14px;
  transition: background .15s ease;
}
.kc-chat__send:hover, .kc-chat__lead-send:hover { background: var(--amber-deep, #9C6322); }

.kc-chat__disclaimer {
  padding: 8px 14px 12px; font-size: 11px; text-align: center;
  color: var(--ink-faint, #9A9081); background: var(--cream-2, #FBF8F2);
}

@media (max-width: 480px) {
  #kc-chat { right: 16px; bottom: 16px; }
  .kc-chat__window {
    position: fixed; right: 0; bottom: 0; width: 100vw; height: 100dvh;
    max-width: 100vw; max-height: 100dvh; border: none; border-radius: 0;
  }
}
