/* ============================================================
   САКУРА — чат на сайте.
   Виджет в духе Telegram: круглая кнопка в углу, окошко поверх
   страницы, пузыри сообщений. Цвета — палитра сайта, акцент
   переопределяется настройкой «Цвет» (--skc-accent).

   ⚠️ Размер кнопки ОДИН на всех экранах — 54px, как у кнопки
   мессенджеров (.sk-chat-btn). Кнопка чата стоит на её месте,
   а кнопка мессенджеров поднимается выше (см. style.css).
   ============================================================ */

.skc {
  --skc-accent: #a8627a;
  --skc-accent-deep: #8a4a60;
  --skc-paper: #fff;
  --skc-line: #f0dde3;
  --skc-ink: #2a2528;
  --skc-muted: #8a7d84;
  --skc-in: #f4eef0;
  --skc-on: #fff;
  --skc-btn: 54px;
  font-family: var(--f-text, 'Jost', 'Inter', -apple-system, 'Segoe UI', sans-serif);
  position: fixed;
  top: auto;
  left: auto;
  right: 18px;
  bottom: 22px;
  width: auto;
  height: auto;
  /* Ниже выехавшего списка мессенджеров (у него 1095): список открывается поверх. */
  z-index: 1090;
  line-height: 1.45;
}

/* ── Круглая кнопка ─────────────────────────────────────────── */
.skc-bubble {
  position: relative;
  display: grid;
  place-items: center;
  width: var(--skc-btn);
  height: var(--skc-btn);
  min-width: var(--skc-btn);
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--skc-accent), var(--skc-accent-deep));
  color: #fff;
  box-shadow: 0 10px 26px rgba(94, 52, 68, .38);
  cursor: pointer;
  transition: transform .18s ease, box-shadow .18s ease;
}
.skc-bubble:hover { transform: translateY(-2px); box-shadow: 0 14px 32px rgba(94, 52, 68, .46); }
.skc-bubble:active { transform: translateY(0) scale(.96); }
.skc-bub-ico { display: inline-flex; }
.skc-bub-ico svg { display: block; width: 26px; height: 26px; }
.skc-bub-text { display: none; }
.skc-nobub .skc-bubble { padding: 0; }

.skc-badge {
  position: absolute;
  top: -2px;
  right: -2px;
  min-width: 20px;
  height: 20px;
  padding: 0 5px;
  border-radius: 10px;
  background: #fff;
  color: var(--skc-accent-deep);
  font: 700 11.5px/20px var(--f-text, 'Jost'), sans-serif;
  text-align: center;
  box-shadow: 0 2px 8px rgba(0, 0, 0, .18);
  animation: skc-pop .28s ease;
}
.skc-badge[hidden] { display: none; }

@keyframes skc-pop { from { transform: scale(.4); opacity: 0; } to { transform: scale(1); opacity: 1; } }

/* ── Окно чата ─────────────────────────────────────────────── */
.skc-win {
  position: absolute;
  right: 0;
  bottom: calc(var(--skc-btn) + 14px);
  width: 372px;
  max-width: calc(100vw - 24px);
  height: 560px;
  max-height: calc(100vh - 120px);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  background: var(--skc-paper);
  border-radius: 18px;
  box-shadow: 0 30px 70px rgba(60, 30, 40, .28), 0 2px 6px rgba(60, 30, 40, .08);
  transform-origin: bottom right;
  animation: skc-in .22s cubic-bezier(.2, .9, .3, 1.2);
}
.skc-win[hidden] { display: none !important; }
@keyframes skc-in { from { opacity: 0; transform: translateY(14px) scale(.96); } to { opacity: 1; transform: none; } }

/* Шапка */
.skc-head {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 14px;
  background: linear-gradient(135deg, var(--skc-accent), var(--skc-accent-deep));
  color: #fff;
}
.skc-ava { position: relative; flex: 0 0 auto; width: 44px; height: 44px; }
.skc-ava img,
.skc-ava .skc-ini {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  object-fit: cover;
  background: rgba(255, 255, 255, .22);
  color: #fff;
  font: 600 19px/1 var(--f-head, Georgia), serif;
}
.skc-dot {
  position: absolute;
  right: 0;
  bottom: 1px;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: #67d47c;
  border: 2px solid var(--skc-accent-deep);
}
.skc-who { flex: 1 1 auto; min-width: 0; }
.skc-name { font: 600 16px/1.2 var(--f-head, Georgia), serif; letter-spacing: .2px; }
.skc-sub { font-size: 12.5px; opacity: .85; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.skc-x {
  flex: 0 0 auto;
  width: 34px;
  height: 34px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 0;
  border-radius: 50%;
  background: rgba(255, 255, 255, .14);
  color: #fff;
  cursor: pointer;
  transition: background .15s ease;
}
.skc-x:hover { background: rgba(255, 255, 255, .28); }

/* Лента сообщений */
.skc-body {
  flex: 1 1 auto;
  display: flex;
  flex-direction: column;
  min-height: 0;
  background:
    radial-gradient(1200px 300px at 100% 0, #fdf4f7, transparent 60%),
    #fbf7f8;
}
.skc-day {
  align-self: center;
  flex: 0 0 auto;
  margin: 10px 0 4px;
  padding: 3px 10px;
  border-radius: 10px;
  background: rgba(42, 37, 40, .06);
  color: var(--skc-muted);
  font-size: 11.5px;
}
.skc-list {
  flex: 1 1 auto;
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: 8px 12px 12px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  scrollbar-width: thin;
}
.skc-list::-webkit-scrollbar { width: 6px; }
.skc-list::-webkit-scrollbar-thumb { background: #e3d2d8; border-radius: 3px; }

.skc-msg {
  max-width: 82%;
  padding: 8px 12px 20px;
  position: relative;
  font-size: 14.5px;
  white-space: pre-wrap;
  word-wrap: break-word;
  overflow-wrap: anywhere;
  box-shadow: 0 1px 1px rgba(60, 30, 40, .06);
  animation: skc-msg .18s ease;
}
@keyframes skc-msg { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }

/* Ссылки на страницы и товары внутри реплик агента. */
.skc-msg a {
  color: inherit;
  text-decoration: underline;
  text-underline-offset: 2px;
  font-weight: 600;
  word-break: break-all;
}
.skc-msg a:hover { opacity: .8; }

.skc-msg.out {
  align-self: flex-start;
  background: var(--skc-paper);
  color: var(--skc-ink);
  border-radius: 4px 16px 16px 16px;
}
.skc-msg.in {
  align-self: flex-end;
  background: linear-gradient(135deg, var(--skc-accent), var(--skc-accent-deep));
  color: #fff;
  border-radius: 16px 4px 16px 16px;
}
.skc-msg.sys {
  align-self: center;
  max-width: 90%;
  padding: 5px 12px;
  border-radius: 12px;
  background: rgba(42, 37, 40, .06);
  color: var(--skc-muted);
  font-size: 12.5px;
  text-align: center;
  box-shadow: none;
}
.skc-msg .skc-t {
  position: absolute;
  right: 10px;
  bottom: 4px;
  font-size: 10.5px;
  opacity: .55;
}
.skc-msg.in .skc-t { color: rgba(255, 255, 255, .9); opacity: .8; }

/* Не дошло: сеть моргнула или сервер отказал. */
.skc-msg.skc-fail { box-shadow: 0 0 0 2px #e05a6a inset; opacity: .85; }

/* «Печатает…» */
.skc-typing { align-self: flex-start; display: inline-flex; gap: 4px; padding: 12px 14px; border-radius: 4px 16px 16px 16px; background: #fff; }
.skc-typing i { width: 7px; height: 7px; border-radius: 50%; background: var(--skc-accent); opacity: .45; animation: skc-dot 1.1s infinite; }
.skc-typing i:nth-child(2) { animation-delay: .15s; }
.skc-typing i:nth-child(3) { animation-delay: .3s; }
@keyframes skc-dot { 0%, 60%, 100% { opacity: .3; transform: translateY(0); } 30% { opacity: 1; transform: translateY(-3px); } }

/* Поля ввода */
.skc-form { flex: 0 0 auto; padding: 8px 10px 10px; background: #fbf7f8; border-top: 1px solid var(--skc-line); }
/* Над строкой ввода: подсказка «Представьтесь пож-та» и поля имя/телефон в одну строку. */
.skc-fields { display: block; margin-bottom: 8px; }
.skc-fields[hidden] { display: none; }
.skc-fields-title { font-size: 12.5px; font-weight: 600; color: #7a666d; padding: 0 2px 5px; }
.skc-fields-row { display: flex; gap: 8px; }
.skc-fields .form-control {
  flex: 1 1 0;
  min-width: 0;
  height: 36px;
  border: 1px solid var(--skc-line);
  border-radius: 10px;
  font-size: 14px;
  background: #fff;
  box-shadow: none;
}
.skc-fields .form-control:focus { border-color: var(--skc-accent); box-shadow: 0 0 0 3px rgba(168, 98, 122, .12); }

/* ── Строка ввода: поле + скрепка + «Отправить» — ОДНА капсула ─────────
   Заказчик: «кнопку отправить и скрепку объедини визуально в один блок
   с полем ввода». Рамку и фон рисует сама строка, у поля и кнопок своих
   рамок нет; скрепка стоит внутри справа от текста. */
.skc-inrow {
  display: flex;
  align-items: flex-end;
  gap: 4px;
  padding: 4px 4px 4px 6px;
  border: 1px solid var(--skc-line);
  border-radius: 24px;
  background: #fff;
  transition: border-color .15s ease, box-shadow .15s ease;
}
.skc-inrow:focus-within { border-color: var(--skc-accent); box-shadow: 0 0 0 3px rgba(168, 98, 122, .12); }
.skc-inrow .form-control {
  flex: 1 1 auto;
  min-height: 36px;
  max-height: 118px;
  padding: 8px 6px 8px 8px;
  border: 0;
  border-radius: 20px;
  background: transparent;
  font: inherit;
  font-size: 14.5px;
  line-height: 1.4;
  resize: none;
  box-shadow: none;
  outline: none;
}
.skc-inrow .form-control:focus { border: 0; box-shadow: none; outline: none; }
.skc-send {
  flex: 0 0 auto;
  width: 38px;
  height: 38px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 0;
  border-radius: 50%;
  background: var(--skc-accent);
  color: #fff;
  cursor: pointer;
  transition: background .15s ease, transform .12s ease;
}
.skc-send:hover { background: var(--skc-accent-deep); }
.skc-send:active { transform: scale(.94); }
.skc-send:disabled { opacity: .45; cursor: default; }
.skc-send svg { display: block; }

/* ── Скрепка: между полем ввода и «Отправить» ──────────────────────────
   Стоит ВНУТРИ общей капсулы ряда (`skc-inrow`): своей рамки нет,
   только прозрачный кружок с иконкой — визуально одна панель. */
.skc-clip {
  flex: 0 0 auto;
  width: 38px;
  height: 38px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 0;
  border-radius: 50%;
  background: transparent;
  color: var(--skc-accent-deep);
  cursor: pointer;
  transition: background .15s ease, color .15s ease, transform .12s ease;
}
.skc-clip:hover { background: #fdf1f5; color: var(--skc-accent); }
.skc-clip:active { transform: scale(.94); }
.skc-clip:disabled { opacity: .45; cursor: default; }
.skc-clip svg { display: block; }

/* Строка подсказки под полем: «файл уходит…», «расчёт до суток». */
.skc-hint-line { margin: 6px 2px 0; font-size: 12px; line-height: 1.35; color: #7a666d; }
.skc-hint-line[hidden] { display: none; }
.skc-hint-line.is-err { color: #b3394b; }

/* ── Карточка файла в ленте ────────────────────────────────────────────
   Человек видит, что приложено, каким оно ушло и что с ним дальше.
   Картинка показывается превью, документы — значком и именем. */
.skc-file {
  display: flex;
  align-items: center;
  gap: 10px;
  max-width: 100%;
  padding: 8px 10px;
  border-radius: 12px;
  background: #fff;
  border: 1px solid var(--skc-line);
  text-decoration: none;
  color: inherit;
}
.skc-file.skc-in { align-self: flex-end; }
.skc-file-pic { flex: 0 0 auto; width: 46px; height: 46px; border-radius: 8px; object-fit: cover; display: block; }
/* Снимок в переписке — просто картинка, без пузыря, фона и подписи. */
.skc-msg.skc-pic-msg,
.skc-msg.in.skc-pic-msg,
.skc-msg.out.skc-pic-msg {
  padding: 0;
  background: none;
  color: inherit;
  border: 0;
  border-radius: 12px;
  box-shadow: none;
  line-height: 0;
  /* Снимок стоит у своей стороны: своё — справа, ответ — слева. */
  align-self: flex-start;
}
.skc-msg.in.skc-pic-msg { align-self: flex-end; }
.skc-msg.skc-pic-msg .skc-t { display: none; }
.skc-pic { display: block; margin: 0; }
.skc-pic img { display: block !important; max-width: 220px; max-height: 220px; width: auto !important; height: auto !important; border-radius: 10px; }
.skc-file-link { display: inline-block; margin-left: 6px; font-size: 12.5px; text-decoration: underline; color: inherit; opacity: .9; }
.skc-file-ico {
  flex: 0 0 auto;
  width: 46px;
  height: 46px;
  border-radius: 8px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: #fdf1f5;
  color: var(--skc-accent-deep);
  font-size: 22px;
}
.skc-file-body { min-width: 0; }
.skc-file-name { display: block; font-size: 13.5px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.skc-file-meta { display: block; font-size: 11.5px; color: #8d7a80; }
.skc-file.is-wait .skc-file-meta { color: #a8627a; }

/* Согласие на обработку данных.
   Строка живёт, пока человек не поставил галочку. По нажатию справа
   рисуется зелёная галочка (обводка + проставляется «птичка»), и только
   ПОСЛЕ анимации строка плавно исчезает. Состояния — классы на строке:
   `is-checked` (идёт анимация), `is-gone` (строка ушла). */
.skc-consent {
  display: flex;
  align-items: center;
  gap: 7px;
  margin: 8px 4px 0;
  color: var(--skc-muted);
  font-size: 11.5px;
  line-height: 1.35;
  cursor: pointer;
  user-select: none;
  max-height: 60px;
  overflow: hidden;
  transition: opacity .45s ease, max-height .45s ease, margin .45s ease;
}
.skc-consent > span { flex: 1 1 auto; }
.skc-consent input { flex: 0 0 auto; width: 14px; height: 14px; margin: 0; accent-color: var(--skc-accent); }
.skc-consent a { color: var(--skc-accent-deep); text-decoration: underline; }
.skc-consent.skc-need span { color: #c2410c; }

/* ── Согласие: зелёная галочка справа ─────────────────────────────── */
.skc-ticksvg {
  flex: 0 0 auto;
  width: 22px;
  height: 22px;
  opacity: 0;
  transform: scale(.5);
  transition: opacity .18s ease, transform .25s cubic-bezier(.2, .9, .3, 1.4);
}
.skc-ticksvg svg { width: 100%; height: 100%; display: block; }
.skc-ticksvg circle {
  fill: rgba(41, 178, 107, .14);
  stroke: #29b26b;
  stroke-width: 2;
  stroke-dasharray: 70;
  stroke-dashoffset: 70;
}
.skc-ticksvg path {
  fill: none;
  stroke: #29b26b;
  stroke-width: 2.6;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-dasharray: 24;
  stroke-dashoffset: 24;
}
.skc-consent.is-checked .skc-ticksvg { opacity: 1; transform: scale(1); }
.skc-consent.is-checked .skc-ticksvg circle { animation: skc-ring .45s ease forwards; }
.skc-consent.is-checked .skc-ticksvg path { animation: skc-tick .35s .28s ease forwards; }
@keyframes skc-ring { to { stroke-dashoffset: 0; } }
@keyframes skc-tick { to { stroke-dashoffset: 0; } }

/* Строка уходит только после анимации галочки. */
.skc-consent.is-gone { opacity: 0; max-height: 0; margin-top: 0; margin-bottom: 0; }
.skc-agreed .skc-consent { display: none; }

/* ── Мобильный ─────────────────────────────────────────────── */
@media (max-width: 767.98px) {
  /* Та же точка привязки, что у кнопки мессенджеров: чат встаёт на её
     место, а мессенджеры поднимаются выше (см. style.css). */
  .skc { right: 11px; bottom: calc(66px + var(--skc-btn) + 10px); }
  .skc-win {
    position: fixed;
    right: 0;
    left: 0;
    bottom: 0;
    top: auto;
    width: 100vw;
    max-width: 100vw;
    height: 82vh;
    max-height: 82vh;
    border-radius: 18px 18px 0 0;
  }
}

/* Окно не мешает печати и не показывается в «Рассказать о нас». */
@media print { .skc { display: none !important; } }

@media (prefers-reduced-motion: reduce) {
  .skc-win, .skc-msg, .skc-badge { animation: none; }
  .skc-typing i { animation: none; opacity: .6; }
}
