/* ====================== ВПКСевер — чат-лендинг ======================
   Mobile-first. Стиль мессенджера. Без внешних шрифтов/библиотек. */

:root {
  --army: #1d2c20;        /* тёмно-зелёный (шапка, облачко пользователя) */
  --army-2: #2f4636;      /* светлее зелёный */
  --gold: #c8a04b;        /* акцент */
  --gold-dark: #a9842f;
  --ink: #14181a;         /* основной текст */
  --bot-bg: #ffffff;      /* облачко консультанта */
  --user-bg: #2f4636;     /* облачко пользователя */
  --user-fg: #f3efe5;
  --chat-bg: #ece6db;     /* «обои» чата */
  --chip-bg: #ffffff;
  --chip-br: #d9cfbd;
  --muted: #6b6f6b;
  --ok: #3ec46d;
  --radius: 18px;
  --maxw: 480px;
  --header-h: 64px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  color: var(--ink);
  background: var(--army);
  -webkit-font-smoothing: antialiased;
  line-height: 1.45;
}

/* Колонка-приложение: на десктопе центрируем узкой колонкой */
.app {
  max-width: var(--maxw);
  margin: 0 auto;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  background: var(--chat-bg);
  box-shadow: 0 0 40px rgba(0,0,0,.35);
}

/* ----------------------------- Шапка ----------------------------- */
.chat-header {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 14px;
  padding-top: max(10px, env(safe-area-inset-top));
  background: var(--army);
  color: #f3efe5;
  min-height: var(--header-h);
}
.chat-header__avatar { flex: 0 0 auto; width: 44px; height: 44px; }

/* Аватар: фото менеджера поверх силуэта-заглушки.
   Если фото нет/не загрузилось — img скрывается (onerror) и виден силуэт. */
.avatar, .mini-avatar {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 48 48'%3E%3Crect width='48' height='48' fill='%232f4636'/%3E%3Ccircle cx='24' cy='19' r='8' fill='%23e8e4da'/%3E%3Cpath d='M8 44c0-9 7.2-15 16-15s16 6 16 15z' fill='%23e8e4da'/%3E%3C/svg%3E");
  background-size: cover;
  background-position: center;
  border-radius: 50%;
  overflow: hidden;
}
.avatar__img, .mini-avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}
.chat-header__info { flex: 1 1 auto; min-width: 0; }
.chat-header__name { font-weight: 700; font-size: 1rem; }
.chat-header__brand { color: var(--gold); font-weight: 600; }
.chat-header__status { font-size: .78rem; color: #c7cfc7; display: flex; align-items: center; gap: 6px; }
.chat-header__status .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--ok); box-shadow: 0 0 0 3px rgba(62,196,109,.25); }
.chat-header__call {
  flex: 0 0 auto;
  color: #f3efe5;
  background: rgba(255,255,255,.08);
  width: 40px; height: 40px;
  display: flex; align-items: center; justify-content: center;
  border-radius: 50%;
  text-decoration: none;
  border: none;
  padding: 0;
  cursor: pointer;
}
.chat-header__call:active { background: rgba(255,255,255,.18); }

/* ----------------------------- Лента ----------------------------- */
.chat {
  flex: 1 1 auto;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  /* лёгкий «узор обоев» */
  background-image:
    radial-gradient(rgba(0,0,0,.025) 1px, transparent 1px);
  background-size: 18px 18px;
}
.feed {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 16px 12px 24px;
  min-height: 100%;
}

/* Облачка */
.msg {
  max-width: 84%;
  padding: 9px 13px;
  border-radius: var(--radius);
  font-size: .96rem;
  position: relative;
  word-wrap: break-word;
  animation: pop .22s ease-out;
  box-shadow: 0 1px 1px rgba(0,0,0,.08);
}
@keyframes pop {
  from { opacity: 0; transform: translateY(6px) scale(.98); }
  to   { opacity: 1; transform: none; }
}

.msg--bot {
  align-self: flex-start;
  background: var(--bot-bg);
  color: var(--ink);
  border-bottom-left-radius: 5px;
}
.msg--user {
  align-self: flex-end;
  background: var(--user-bg);
  color: var(--user-fg);
  border-bottom-right-radius: 5px;
}

/* Ряд «аватар + облачко» для бота */
.row-bot {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  max-width: 100%;
}
.row-bot .mini-avatar {
  flex: 0 0 auto;
  width: 28px; height: 28px;
  border-radius: 50%;
  overflow: hidden;
  line-height: 0;
  opacity: 0;            /* показываем только у первого облачка группы */
}
.row-bot.show-avatar .mini-avatar { opacity: 1; }
.row-bot .msg { box-shadow: 0 1px 1px rgba(0,0,0,.08); }

/* Индикатор «печатает…» */
.typing {
  display: inline-flex;
  gap: 4px;
  padding: 13px 14px;
}
.typing span {
  width: 7px; height: 7px;
  background: #9aa39a;
  border-radius: 50%;
  animation: blink 1.2s infinite ease-in-out both;
}
.typing span:nth-child(2) { animation-delay: .2s; }
.typing span:nth-child(3) { animation-delay: .4s; }
@keyframes blink {
  0%, 80%, 100% { opacity: .3; transform: translateY(0); }
  40% { opacity: 1; transform: translateY(-3px); }
}

/* ----------------------------- Чипы-ответы ----------------------------- */
.chips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: flex-end;
  margin: 4px 0 6px;
  animation: pop .22s ease-out;
}
.chip {
  appearance: none;
  border: 1px solid var(--chip-br);
  background: var(--chip-bg);
  color: var(--army);
  font: inherit;
  font-weight: 600;
  font-size: .92rem;
  padding: 9px 15px;
  border-radius: 22px;
  cursor: pointer;
  transition: transform .08s, background .15s, color .15s, border-color .15s;
}
.chip:hover { border-color: var(--gold); color: var(--gold-dark); }
.chip:active { transform: scale(.96); }
.chip--other { border-style: dashed; }

/* ----------------------------- Форма заявки ----------------------------- */
.lead-form {
  align-self: stretch;
  background: var(--bot-bg);
  border-radius: var(--radius);
  padding: 14px;
  margin-top: 2px;
  box-shadow: 0 2px 8px rgba(0,0,0,.10);
  animation: pop .22s ease-out;
}
.lead-form__row { margin-bottom: 10px; }
.lead-form__input {
  width: 100%;
  font: inherit;
  font-size: 1rem;
  padding: 13px 14px;
  border: 1.5px solid var(--chip-br);
  border-radius: 12px;
  background: #fbf9f4;
  color: var(--ink);
}
.lead-form__input:focus {
  outline: none;
  border-color: var(--gold);
  background: #fff;
}
.lead-form__agree {
  display: flex;
  gap: 9px;
  align-items: flex-start;
  font-size: .8rem;
  color: var(--muted);
  margin: 4px 0 12px;
  cursor: pointer;
}
.lead-form__agree input { margin-top: 2px; flex: 0 0 auto; width: 17px; height: 17px; accent-color: var(--army-2); }
.lead-form__agree a { color: var(--army-2); }
.lead-form__submit {
  width: 100%;
  font: inherit;
  font-weight: 700;
  font-size: 1.02rem;
  color: var(--ink);
  background: var(--gold);
  border: none;
  border-radius: 12px;
  padding: 14px;
  cursor: pointer;
  transition: background .15s, transform .08s;
}
.lead-form__submit:hover { background: var(--gold-dark); color: #fff; }
.lead-form__submit:active { transform: scale(.99); }
.lead-form__submit[disabled] { opacity: .6; cursor: default; }
.lead-form__status {
  margin: 10px 2px 0;
  font-size: .85rem;
  color: #c0392b;
  min-height: 1em;
}

/* honeypot */
.hp { position: absolute; left: -9999px; width: 1px; height: 1px; overflow: hidden; }

/* ----------------------------- Инлайн-ввод (другой город) ----------------------------- */
.inline-input {
  align-self: flex-end;
  display: flex;
  gap: 8px;
  width: 84%;
  animation: pop .22s ease-out;
}
.inline-input__field {
  flex: 1 1 auto;
  font: inherit;
  font-size: 1rem;
  padding: 11px 14px;
  border: 1.5px solid var(--chip-br);
  border-radius: 22px;
  background: #fff;
}
.inline-input__field:focus { outline: none; border-color: var(--gold); }
.inline-input__btn {
  flex: 0 0 auto;
  width: 44px; height: 44px;
  border: none;
  border-radius: 50%;
  background: var(--gold);
  color: var(--ink);
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
}
.inline-input__btn:active { background: var(--gold-dark); }

/* ----------------------------- Модальная форма заявки ----------------------------- */
/* Mobile-first: диалог на весь экран. Десктоп (ниже) — карточка-полоса по центру. */
.lead-modal {
  width: 100%;
  max-width: 100%;
  height: 100%;
  max-height: 100%;
  margin: 0;
  padding: 0;
  border: none;
  background: transparent;
  color: var(--ink);
  overflow: hidden;
}
.lead-modal::backdrop { background: rgba(12,18,13,.62); }

.lead-modal__inner {
  position: relative;
  box-sizing: border-box;
  min-height: 100%;              /* на мобилке .inner заполняет экран, контент по центру */
  width: 100%;
  background: var(--chat-bg);
  display: flex;
  flex-direction: column;
  justify-content: center;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding: 26px 20px calc(26px + env(safe-area-inset-bottom));
  padding-top: max(26px, calc(env(safe-area-inset-top) + 18px));
  animation: modalIn .25s ease-out;
}
@keyframes modalIn {
  from { opacity: 0; transform: translateY(12px); }
  to   { opacity: 1; transform: none; }
}

.lead-modal__close {
  position: absolute;
  top: max(12px, env(safe-area-inset-top));
  right: 12px;
  width: 40px; height: 40px;
  display: flex; align-items: center; justify-content: center;
  border: none;
  border-radius: 50%;
  background: rgba(0,0,0,.06);
  color: var(--ink);
  cursor: pointer;
}
.lead-modal__close:hover { background: rgba(0,0,0,.12); }

.lead-modal__head { margin: 0 auto 18px; text-align: center; max-width: 420px; }
.lead-modal__title { font-size: 1.35rem; font-weight: 700; color: var(--army); }
.lead-modal__sub { font-size: .92rem; color: var(--muted); margin-top: 6px; }

/* Внутри модалки форма без собственной «карточки» — фон даёт .inner */
.lead-modal .lead-form {
  background: transparent;
  box-shadow: none;
  padding: 0;
  margin: 0 auto;
  width: 100%;
  max-width: 420px;
}

/* ----------------------------- Десктоп ----------------------------- */
@media (min-width: 520px) {
  body { padding: 0; }
  .app {
    margin: 0 auto;
    min-height: 100dvh;
  }

  /* Модалка — центрированная карточка-полоса.
     height:fit-content, т.к. auto у модального <dialog> растягивается на весь экран. */
  .lead-modal {
    width: 440px;
    max-width: calc(100% - 32px);
    height: fit-content;
    max-height: calc(100dvh - 48px);
    margin: auto;
    border-radius: 22px;
    box-shadow: 0 24px 60px rgba(0,0,0,.4);
  }
  .lead-modal__inner {
    min-height: 0;              /* на компе карточка обнимает контент */
    justify-content: flex-start;
    border-radius: 22px;
    padding: 36px 32px;
  }
}
