/* Чат-помощник сайта. Все классы с префиксом wkchat-, чтобы не пересекаться с остальными стилями.
   Цвета — из палитры сайта: brand-700 #db2777 (кнопки), brand-50 #fff0f7, brand-900 #7a1543. */
.wkchat {
  position: fixed;
  right: 16px;
  bottom: 16px;
  z-index: 60;
  font-family: "Nunito Variable", "Nunito", ui-sans-serif, system-ui, sans-serif;
  color: #1c1917;
}

/* Кнопка чата: консультант в гарнитуре, от неё расходятся два кольца; рядом подпись «Задайте вопрос».
   Анимируем только transform и opacity — их рисует видеокарта, страница не дёргается. */
.wkchat-fab {
  display: inline-flex;
  align-items: center;
  flex-direction: row-reverse;
  position: relative;
  gap: 12px;
  padding: 0;
  border: 0;
  background: transparent;
  color: #1c1917;
  font: inherit;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}
.wkchat-avatar {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 62px;
  height: 62px;
  flex: none;
  border-radius: 50%;
  background: linear-gradient(145deg, #f472b6, #db2777 55%, #b31f63);
  color: #fff;
  box-shadow: 0 8px 22px rgba(179, 31, 99, 0.42), inset 0 1px 0 rgba(255, 255, 255, 0.35);
  transition: transform 0.18s ease-out;
}
.wkchat-avatar svg { width: 38px; height: 38px; }
.wkchat-avatar::before,
.wkchat-avatar::after {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: 50%;
  border: 2px solid #ec4899;
  opacity: 0;
  animation: wkchat-ring 2.4s ease-out infinite;
  pointer-events: none;
}
.wkchat-avatar::after { animation-delay: 1.2s; }
.wkchat-online {
  position: absolute;
  right: 2px;
  bottom: 3px;
  width: 13px;
  height: 13px;
  border-radius: 50%;
  background: #22c55e;
  border: 2.5px solid #fff;
}
.wkchat-fab:hover .wkchat-avatar { transform: scale(1.06); }
.wkchat-fab:active .wkchat-avatar { transform: scale(0.96); }
.wkchat-fab-label {
  position: relative;
  padding: 9px 15px;
  border-radius: 16px 16px 4px 16px;
  background: #fff;
  color: #b31f63;
  font-size: 14.5px;
  font-weight: 800;
  white-space: nowrap;
  box-shadow: 0 6px 18px rgba(122, 21, 67, 0.2);
  transform-origin: 100% 100%;
  animation: wkchat-nudge 4.8s ease-in-out infinite;
}
@keyframes wkchat-ring {
  0% { transform: scale(1); opacity: 0.65; }
  100% { transform: scale(1.75); opacity: 0; }
}
@keyframes wkchat-nudge {
  0%, 82%, 100% { transform: scale(1); }
  88% { transform: scale(1.06); }
  94% { transform: scale(0.99); }
}
.wkchat-open .wkchat-avatar::before,
.wkchat-open .wkchat-avatar::after,
.wkchat-open .wkchat-fab-label { animation: none; }
.wkchat-open .wkchat-fab-label { display: none; }

.wkchat-panel {
  position: absolute;
  right: 0;
  bottom: 74px;
  display: flex;
  flex-direction: column;
  width: min(380px, calc(100vw - 32px));
  height: min(560px, calc(100dvh - 124px));
  overflow: hidden;
  border-radius: 20px;
  background: #fff;
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.25);
}
.wkchat-panel[hidden] { display: none; }

.wkchat-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 12px 14px;
  background: #db2777;
  color: #fff;
}
.wkchat-title { margin: 0; font-size: 16px; font-weight: 800; line-height: 1.2; }
.wkchat-sub { margin: 2px 0 0; font-size: 12px; opacity: 0.9; }
.wkchat-close {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  margin: -6px -8px -6px 0;
  border: 0;
  border-radius: 999px;
  background: transparent;
  color: inherit;
  cursor: pointer;
}
.wkchat-close:hover { background: rgba(255, 255, 255, 0.18); }
.wkchat-close svg { width: 22px; height: 22px; }

.wkchat-log {
  flex: 1;
  overflow-y: auto;
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  overscroll-behavior: contain;
}
.wkchat-msg {
  max-width: 88%;
  padding: 9px 13px;
  border-radius: 16px;
  font-size: 15px;
  line-height: 1.45;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}
.wkchat-msg a { color: inherit; font-weight: 700; text-decoration: underline; }
.wkchat-bot { align-self: flex-start; background: #fff0f7; border-bottom-left-radius: 4px; }
.wkchat-user { align-self: flex-end; background: #db2777; color: #fff; border-bottom-right-radius: 4px; }

.wkchat-typing { display: inline-flex; gap: 4px; align-items: center; }
.wkchat-typing i {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #b31f63;
  animation: wkchat-bounce 1.1s infinite ease-in-out;
}
.wkchat-typing i:nth-child(2) { animation-delay: 0.15s; }
.wkchat-typing i:nth-child(3) { animation-delay: 0.3s; }
@keyframes wkchat-bounce {
  0%, 80%, 100% { transform: translateY(0); opacity: 0.5; }
  40% { transform: translateY(-4px); opacity: 1; }
}

.wkchat-chips { display: flex; flex-wrap: wrap; gap: 6px; padding: 0 14px 10px; }
.wkchat-chips:empty { display: none; }
.wkchat-chip {
  min-height: 36px;
  padding: 6px 12px;
  border: 1px solid #db2777;
  border-radius: 999px;
  background: #fff;
  color: #b31f63;
  font: inherit;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
}
.wkchat-chip:hover { background: #fff0f7; }

.wkchat-note {
  margin: 0;
  padding: 6px 14px;
  border-top: 1px solid #f3e1ea;
  background: #fffafc;
  color: #57534e;
  font-size: 11.5px;
  line-height: 1.35;
}

.wkchat-form { display: flex; align-items: flex-end; gap: 6px; padding: 10px 12px 12px; border-top: 1px solid #f3e1ea; }
.wkchat-input {
  flex: 1;
  min-width: 0;
  min-height: 44px;
  padding: 0 14px;
  border: 1px solid #d6d3d1;
  border-radius: 999px;
  font: inherit;
  font-size: 16px; /* 16px — чтобы iPhone не увеличивал страницу при вводе */
  color: inherit;
}
/* Поле ввода растёт по тексту до 40 % высоты экрана, дальше прокрутка внутри. */
.wkchat-grow {
  display: block;
  box-sizing: border-box;
  height: 44px;
  max-height: 40vh;
  padding: 10px 14px;
  border-radius: 22px;
  line-height: 1.4;
  resize: none;
  overflow-y: auto;
}
.wkchat-send {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  flex: none;
  border: 0;
  border-radius: 50%;
  background: #db2777;
  color: #fff;
  cursor: pointer;
}
.wkchat-send:hover { background: #b31f63; }
.wkchat-mic {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  flex: none;
  border: 1px solid #db2777;
  border-radius: 50%;
  background: #fff;
  color: #db2777;
  cursor: pointer;
}
.wkchat-mic:hover { background: #fff0f7; }
.wkchat-mic svg { width: 20px; height: 20px; }
.wkchat-mic-on {
  background: #db2777;
  color: #fff;
  animation: wkchat-rec 1.2s infinite ease-in-out;
}
@keyframes wkchat-rec {
  0%, 100% { box-shadow: 0 0 0 0 rgba(219, 39, 119, 0.5); }
  50% { box-shadow: 0 0 0 8px rgba(219, 39, 119, 0); }
}
.wkchat-mic:disabled { opacity: 0.55; cursor: default; }
.wkchat-voice-row { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.wkchat-send:disabled, .wkchat-input:disabled { opacity: 0.55; cursor: default; }
.wkchat-send svg { width: 20px; height: 20px; }

.wkchat button:focus-visible,
.wkchat-input:focus-visible,
.wkchat a:focus-visible {
  outline: 3px solid #7a1543;
  outline-offset: 2px;
}

@media (max-width: 480px) {
  .wkchat { right: 12px; bottom: 12px; }
  /* На телефоне окно — на весь экран, сайт под ним не виден. Закрывает крестик. */
  .wkchat-panel {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: auto;
    width: 100%;
    height: 100dvh;
    border-radius: 0;
    box-shadow: none;
  }
  .wkchat-open .wkchat-fab { display: none; }
  .wkchat-fab-label { font-size: 13px; padding: 7px 12px; }
  .wkchat-head { padding-top: max(12px, env(safe-area-inset-top)); }
  .wkchat-form { padding-bottom: max(12px, env(safe-area-inset-bottom)); }
}

@media (prefers-reduced-motion: reduce) {
  .wkchat-typing i { animation: none; opacity: 0.8; }
  .wkchat-avatar::before, .wkchat-avatar::after, .wkchat-fab-label, .wkchat-mic-on { animation: none; }
  .wkchat-avatar { transition: none; }
}

/* Цена по адресам: два поля, надпись юриста и кнопка — внутри ленты, под ответом. */
.wkchat-price {
  display: flex;
  flex-direction: column;
  gap: 8px;
  align-self: stretch;
  padding: 10px;
  border: 1px solid #f3e1ea;
  border-radius: 14px;
  background: #fffafc;
}
.wkchat-price .wkchat-input { flex: none; width: 100%; box-sizing: border-box; }
.wkchat-price .wkchat-chip { align-self: flex-start; }
.wkchat-price-note { margin: 0; color: #57534e; font-size: 11.5px; line-height: 1.35; }

/* Пока окно открыто на телефоне, страница под ним не прокручивается. */
html.wkchat-lock, html.wkchat-lock body { overflow: hidden; }

/* Форма «Имя / Телефон» перед первым вопросом (по желанию, юрист 18–19.11). */
.wkchat-contact { display: flex; flex-direction: column; gap: 8px; max-width: 100%; }
.wkchat-contact p { margin: 0; }
.wkchat-contact .wkchat-input { flex: none; width: 100%; box-sizing: border-box; background: #fff; }
.wkchat-agree { display: flex; gap: 8px; align-items: flex-start; color: #44403c; font-size: 12.5px; line-height: 1.4; cursor: pointer; }
.wkchat-agree input { flex: none; width: 20px; height: 20px; margin: 1px 0 0; accent-color: #db2777; }
.wkchat-contact-hint { min-height: 1.2em; color: #b31f63; font-size: 12.5px; font-weight: 700; }
.wkchat-contact-row { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; }
.wkchat-chip-main { background: #db2777; border-color: #db2777; color: #fff; }
.wkchat-chip-main:disabled { opacity: 0.5; cursor: default; }
.wkchat-skip { padding: 8px 2px; border: 0; background: transparent; color: #57534e; font: inherit; font-size: 13.5px; text-decoration: underline; cursor: pointer; }
.wkchat-skip:disabled { opacity: 0.5; cursor: default; }
