/* Оформление страницы /chat. Вынесено из chat.php 12.09.2026, чтобы стили
   и сценарий можно было править независимо. Версия в ссылке — в chat.php. */
:root {
  --ink: #131727; --ink-soft: #3f4859; --muted: #6b7688;
  --line: #e2e7ef; --ground: #f4f6fa; --surface: #fff;
  --accent: #8f42ec; --accent-dark: #7a34d0; --accent-soft: #f3ebfd;
  /* фон страницы чуть глубже фона ленты: иначе окно чата сливается с листом,
     и рамки с тенью не хватает, чтобы прочитать его как окно */
  --page: #edf0f6;
  /* высота липкой шапки сайта (.ch-head) — под неё подставляется шапка окна */
  --head-h: 70px;
}
* { box-sizing: border-box; }
body {
  margin: 0; background: var(--page); color: var(--ink);
  font: 16px/1.55 'Segoe UI', system-ui, -apple-system, sans-serif;
  -webkit-font-smoothing: antialiased;
}
a { color: var(--accent); }

/* шапка: только логотип и звонок — меню сайта на рекламной странице мешает */
.ch-head {
  background: var(--surface); border-bottom: 1px solid var(--line);
  position: sticky; top: 0; z-index: 5;
}
.ch-head__in {
  max-width: 760px; margin: 0 auto; padding: 14px 20px;
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
}
.ch-logo { font-size: 21px; font-weight: 700; letter-spacing: -.02em; color: var(--ink); text-decoration: none; }
.ch-logo span { color: #8f42ec; }
.ch-call {
  display: inline-block; padding: 10px 18px; border-radius: 10px;
  background: var(--accent); color: #fff; text-decoration: none; font-weight: 600; font-size: 15px;
}
.ch-call:hover { background: var(--accent-dark); }

.ch-wrap { max-width: 760px; margin: 0 auto; padding: 24px 20px 48px; }

/* --- окно чата ---------------------------------------------------------
   Заказчик: «не видно, что это чат». Лента раньше висела прямо на фоне
   страницы. Теперь она внутри карточки в языке сайта: белая шапка с
   оператором, серое тело переписки (пузыри белые — так они читаются как
   сообщения), тонкая полоса подсказки снизу.
   Внимание: у .ch-win НЕТ overflow:hidden — он сделал бы карточку
   скролл-контейнером, и липкая шапка окна перестала бы липнуть. Углы
   скругляем самим шапке и подвалу. */
.ch-win {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 20px;
  box-shadow: 0 18px 44px rgba(19, 23, 39, .09), 0 2px 6px rgba(19, 23, 39, .04);
}

.ch-win__head {
  display: flex; align-items: center; gap: 12px;
  padding: 13px 18px;
  background: var(--surface);
  border-bottom: 1px solid var(--line);
  border-radius: 19px 19px 0 0;
  /* липнет под шапкой сайта: z-index ниже её пятёрки, чтобы не наезжала */
  position: sticky; top: var(--head-h); z-index: 3;
}
/* картинка лежит внутри <picture>: обёртку тоже приводим к блоку, иначе
   строчный элемент добавляет отбивку под аватаром */
.ch-win__head picture { display: block; flex: 0 0 auto; line-height: 0; }
/* селектор по классу самого <img>, а не по потомку: класс стоит на картинке */
.ch-win__ava {
  display: block; flex: 0 0 auto;
  width: 44px; height: 44px; border-radius: 50%;
  object-fit: cover; object-position: center top;
  border: 1px solid var(--line); background: var(--ground);
}
.ch-win__who { min-width: 0; }
.ch-win__name { display: block; font-size: 16px; font-weight: 600; line-height: 1.25; }
.ch-win__role { display: block; font-size: 13px; line-height: 1.35; color: var(--muted); }
.ch-win__dot {
  display: inline-block; width: 8px; height: 8px; margin-right: 7px;
  border-radius: 50%; background: #22c55e; vertical-align: middle;
  box-shadow: 0 0 0 3px rgba(34, 197, 94, .18);
  animation: ch-live 2.6s infinite ease-in-out;
}
@keyframes ch-live {
  0%, 100% { box-shadow: 0 0 0 3px rgba(34, 197, 94, .18); }
  50%      { box-shadow: 0 0 0 5px rgba(34, 197, 94, .08); }
}

.ch-win__body { background: var(--ground); padding: 18px; }
.ch-win__foot {
  padding: 12px 18px; text-align: center;
  font-size: 13px; line-height: 1.4; color: var(--muted);
  background: var(--surface);
  border-top: 1px solid var(--line);
  border-radius: 0 0 19px 19px;
}

/* лента диалога */
.ch-feed { display: flex; flex-direction: column; gap: 14px; }
.ch-row { display: flex; gap: 10px; align-items: flex-end; }
.ch-row--me { justify-content: flex-end; }
/* аватар у сообщения: работает и как кружок с буквами (<div>), и как
   фотография (<img>, в том числе внутри <picture>). У картинки свой display
   и object-fit — иначе flex растягивает её и лицо сплющивается */
.ch-ava {
  flex: 0 0 auto; width: 34px; height: 34px; border-radius: 50%;
  background: var(--accent-soft); color: var(--accent);
  border: 1px solid var(--line); overflow: hidden;
  display: flex; align-items: center; justify-content: center; font-weight: 700; font-size: 13px;
}
img.ch-ava { display: block; object-fit: cover; object-position: center top; }
.ch-row picture { flex: 0 0 auto; display: block; line-height: 0; }
.ch-bub {
  max-width: 78%; padding: 12px 16px; border-radius: 16px;
  background: var(--surface); border: 1px solid var(--line); border-bottom-left-radius: 5px;
}
.ch-row--me .ch-bub {
  background: var(--accent); color: #fff; border-color: var(--accent);
  border-bottom-left-radius: 16px; border-bottom-right-radius: 5px;
}
.ch-bub p { margin: 0 0 8px; }
.ch-bub p:last-child { margin-bottom: 0; }
.ch-time { display: block; margin-top: 6px; font-size: 12px; color: var(--muted); }
.ch-row--me .ch-time { color: rgba(255,255,255,.72); }

/* индикатор «печатает» */
.ch-typing { display: inline-flex; gap: 4px; align-items: center; height: 12px; }
.ch-typing i {
  width: 6px; height: 6px; border-radius: 50%; background: var(--muted);
  animation: ch-dot 1.1s infinite ease-in-out;
}
.ch-typing i:nth-child(2) { animation-delay: .16s; }
.ch-typing i:nth-child(3) { animation-delay: .32s; }
@keyframes ch-dot { 0%, 60%, 100% { opacity: .25; transform: translateY(0); } 30% { opacity: 1; transform: translateY(-3px); } }

/* скриншоты систем — старая тройка картинок. Оставлено до тех пор, пока
   скрипт чата не перешёл на .ch-cases: без этих правил картинки в ленте
   развалились бы прямо на проде. После перехода блок можно удалить. */
.ch-shots { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-top: 10px; }
.ch-shots img { width: 100%; height: 88px; object-fit: cover; border-radius: 10px; border: 1px solid var(--line); display: block; }

/* --- кейс в сообщении ------------------------------------------------
   Кейсы идут отдельными сообщениями ленты: в пузыре одна
   карточка — картинка во всю ширину, под ней название и подпись,
   как фото в мессенджере. Сейчас это не ссылка, поэтому ни подъёма
   по наведению, ни курсора-указателя нет. Правила написаны по классу,
   чтобы работать и на <div>, и на <a>, если ссылки вернут. */
/* шесть экранов приходят одним сообщением — сетка по три в строку;
   каждая карточка это <button>, поэтому родные стили кнопки снимаем */
.ch-cases { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; margin-top: 10px; }
.ch-case {
  display: block; color: var(--ink); text-decoration: none;
  appearance: none; -webkit-appearance: none; background: none; border: 0; padding: 0;
  font: inherit; text-align: left; width: 100%; cursor: zoom-in;
}
.ch-case__img {
  /* height:auto обязателен: атрибут height="400" у картинки — это
     презентационная подсказка, и без сброса она перебивает aspect-ratio:
     кадр выходил 552x400 вместо 16/10 */
  display: block; width: 100%; height: auto; aspect-ratio: 16 / 10; object-fit: cover;
  border-radius: 12px; border: 1px solid var(--line); background: var(--ground);
}
.ch-case__name {
  display: block; margin-top: 9px;
  font-size: 15px; font-weight: 600; line-height: 1.3; color: var(--ink);
}
.ch-case__note {
  display: block; margin-top: 3px;
  font-size: 13px; line-height: 1.35; color: var(--muted);
}
/* единственное напоминание о кликабельности — только если карточка
   всё же ссылка: у <div> эти правила не срабатывают */
a.ch-case:hover .ch-case__img,
button.ch-case:hover .ch-case__img { border-color: var(--accent); }
a.ch-case:focus-visible,
button.ch-case:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; border-radius: 12px; }

/* просмотр экрана крупно */
.ch-shot {
  position: fixed; inset: 0; z-index: 60; background: rgba(19, 23, 39, .78);
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 12px; padding: 28px 20px;
}
.ch-shot img {
  max-width: min(1180px, 100%); max-height: 82vh; width: auto; height: auto;
  border-radius: 14px; box-shadow: 0 24px 60px rgba(0, 0, 0, .45); background: #fff;
}
.ch-shot__cap { color: #fff; font-size: 14px; font-weight: 600; text-align: center; }
.ch-shot__x {
  position: absolute; top: 16px; right: 20px; width: 40px; height: 40px;
  border: 0; border-radius: 50%; background: rgba(255, 255, 255, .16); color: #fff;
  font-size: 26px; line-height: 1; cursor: pointer;
}
.ch-shot__x:hover { background: rgba(255, 255, 255, .28); }
/* картинке тесно в обычных 78% — пузырь с кейсом чуть шире.
   flex-grow здесь не ради красоты: без него ширина считается по содержимому,
   и не загрузившаяся картинка (у неё width:100%) схлопывала пузырь
   в узкую плашку. Переполнить строку он не может: растёт только
   до свободного места рядом с аватаром */
/* сообщение с экранами — во всю ширину ленты: шесть превью в две строки */
.ch-bub:has(.ch-case) { max-width: 100%; flex: 1 1 auto; min-width: 0; }

/* блок вариантов — часть сообщения бота: в колонке под аватаром */
.ch-panel {
  margin: 10px 0 0 44px; max-width: 78%;
  background: #eef1f7; border: 1px solid var(--line);
  border-radius: 16px; padding: 14px;
}
.ch-panel--form { background: var(--surface); }
.ch-panel.is-done { opacity: .72; }
.ch-panel.is-done .ch-opt { cursor: default; }
.ch-panel.is-done .ch-opt:hover { border-color: var(--line); }
.ch-panel__title { font-weight: 600; margin: 0 0 12px; }
.ch-opts { display: grid; gap: 8px; }
.ch-opt {
  display: flex; align-items: flex-start; gap: 10px; padding: 12px 14px;
  border: 1px solid var(--line); border-radius: 12px; cursor: pointer; background: #fff;
  font-size: 15px; line-height: 1.4; text-align: left; width: 100%;
}
.ch-opt:hover { border-color: var(--accent); }
.ch-opt:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.ch-opt input { margin: 2px 0 0; accent-color: var(--accent); flex: 0 0 auto; }
.ch-opt.is-on { border-color: var(--accent); background: var(--accent-soft); }

.ch-actions { display: flex; gap: 10px; margin-top: 14px; flex-wrap: wrap; }
.ch-btn {
  padding: 12px 22px; border-radius: 12px; border: 0; cursor: pointer;
  background: var(--accent); color: #fff; font-size: 15px; font-weight: 600; font-family: inherit;
}
.ch-btn:hover:not(:disabled) { background: var(--accent-dark); }
.ch-btn:disabled { opacity: .5; cursor: default; }
/* второстепенная кнопка: фон задаём явно и перебиваем ховер основной кнопки —
   у .ch-btn:hover специфичность выше, из-за неё «Назад» окрашивался в синий */
.ch-btn--ghost { background: #fff; color: var(--ink-soft); border: 1px solid var(--line); }
.ch-btn.ch-btn--ghost:hover:not(:disabled) { background: #fff; border-color: var(--accent); color: var(--accent); }

/* форма */
.ch-field { margin-bottom: 12px; }
.ch-field label { display: block; font-size: 14px; color: var(--ink-soft); margin-bottom: 5px; }
.ch-field input[type=text], .ch-field input[type=tel], .ch-field input[type=email] {
  width: 100%; padding: 12px 14px; border: 1px solid var(--line); border-radius: 12px;
  font-size: 16px; font-family: inherit; color: var(--ink); background: #fff;
}
.ch-field input:focus { outline: 2px solid var(--accent); outline-offset: 1px; border-color: var(--accent); }
.ch-err { display: block; margin-top: 5px; font-size: 13px; color: #c64438; }
.ch-agree { display: flex; gap: 10px; align-items: flex-start; font-size: 14px; color: var(--ink-soft); margin: 14px 0 4px; }
.ch-agree input { margin-top: 3px; accent-color: var(--accent); }
.ch-note { margin: 10px 0 0; font-size: 13px; color: var(--muted); }

/* подвал */
.ch-foot { border-top: 1px solid var(--line); background: var(--surface); }
.ch-foot__in { max-width: 760px; margin: 0 auto; padding: 22px 20px 32px; font-size: 13px; color: var(--muted); }
.ch-foot__in p { margin: 0 0 6px; }

/* --- попап «Заказать звонок» -------------------------------------------
   Поля, согласие и кнопка переиспользуют оформление формы квиза
   (.ch-field, .ch-err, .ch-agree, .ch-btn, .ch-actions, .ch-note). */
.ch-modal {
  position: fixed; inset: 0; z-index: 50;
  display: flex; align-items: center; justify-content: center;
  padding: 20px;
}
/* специфичность выше, чем у .ch-modal — иначе display:flex перебил бы
   атрибут hidden и попап висел бы на экране постоянно */
.ch-modal[hidden] { display: none; }
.ch-modal__back { position: absolute; inset: 0; background: rgba(19, 23, 39, .55); }
.ch-modal__box {
  position: relative; z-index: 1;
  width: 100%; max-width: 460px;
  padding: 26px 26px 22px;
  background: var(--surface); border: 1px solid var(--line);
  border-radius: 20px; box-shadow: 0 24px 60px rgba(19, 23, 39, .3);
  /* на телефоне часть экрана съедает адресная строка — попап прокручивается
     внутри себя и всегда помещается целиком */
  max-height: 90vh; max-height: 90dvh; overflow-y: auto;
  animation: ch-pop .22s ease-out;
}
@keyframes ch-pop { from { opacity: 0; transform: translateY(12px); } to { opacity: 1; transform: none; } }
.ch-modal__x {
  position: absolute; top: 10px; right: 12px;
  width: 36px; height: 36px; padding: 0;
  border: 0; border-radius: 10px; background: transparent; cursor: pointer;
  font-family: inherit; font-size: 26px; line-height: 1; color: var(--muted);
}
.ch-modal__x:hover { background: var(--ground); color: var(--ink); }
.ch-modal__x:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.ch-modal__title { margin: 0 40px 6px 0; font-size: 20px; font-weight: 600; line-height: 1.3; }
.ch-modal__lead { margin: 0 0 18px; font-size: 14px; line-height: 1.5; color: var(--ink-soft); }
.ch-modal__ok { margin: 0; font-size: 16px; line-height: 1.55; color: var(--ink); }
.ch-modal .ch-actions { margin-top: 16px; }
.ch-modal .ch-btn { width: 100%; }

@media (max-width: 600px) {
  .ch-bub { max-width: 88%; }
  /* окно: поля поменьше, шапка компактнее — две липкие полосы подряд
     (шапка сайта и шапка окна) не должны съедать пол-экрана */
  .ch-win { border-radius: 16px; }
  .ch-win__head { padding: 11px 14px; gap: 10px; border-radius: 15px 15px 0 0; }
  .ch-win__ava { width: 40px; height: 40px; }
  .ch-win__body { padding: 14px 12px; }
  .ch-win__foot { padding: 11px 14px; font-size: 12px; border-radius: 0 0 15px 15px; }
  /* пузырь с кейсом на телефоне равен остальным: шире — и лента
     начинает распирать окно */
  .ch-bub:has(.ch-case) { max-width: 100%; }
  .ch-cases { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
  .ch-shot { padding: 16px 12px; }
  .ch-shot img { max-height: 72vh; }
  .ch-case__name { font-size: 14px; }
  .ch-case__note { font-size: 12px; }
  .ch-modal { padding: 14px; }
  .ch-modal__box { padding: 22px 18px 18px; border-radius: 18px; }
  .ch-modal__title { font-size: 18px; }
  .ch-panel { max-width: none; margin-left: 44px; }
  .ch-shots img { height: 70px; }
  .ch-btn { width: 100%; }
  .ch-actions { flex-direction: column; }   /* «Назад» над «Далее», как в исходном чате */
}
@media (prefers-reduced-motion: reduce) {
  .ch-typing i { animation: none; }
  .ch-win__dot, .ch-modal__box { animation: none; }
  .ch-case, .ch-case__img, .ch-case__name { transition: none; }
  .ch-case:hover { transform: none; }
  * { scroll-behavior: auto !important; }
}

/* Вводный блок: заголовок страницы и пояснение до начала диалога. */
.ch-intro{ max-width:720px; margin:0 auto 18px; text-align:center; }
.ch-intro__title{ margin:0 0 10px; font-size:clamp(22px,3vw,30px); font-weight:600; line-height:1.25; }
.ch-intro__lead{ margin:0; font-size:16px; line-height:1.55; opacity:.75; }
@media (max-width:600px){ .ch-intro{ margin-bottom:14px; } .ch-intro__lead{ font-size:15px; } }

/* Подпись «кто пишет» над первым сообщением группы — шапку окна с именем
   заказчик попросил убрать, имя теперь стоит в самой ленте, как в мессенджере. */
.ch-nick{
  display: block; margin: 0 0 6px; font-size: 13.5px; font-weight: 600; color: var(--ink);
}
.ch-nick i{
  display: block; font-style: normal; font-weight: 400; font-size: 12px; color: var(--muted);
  margin-top: 1px;
}
.ch-row--first{ margin-top: 6px; }
.ch-row--first:first-child{ margin-top: 0; }
