/* ==========================================================================
   Виджет живого чата. Вёрстка взята из «Чат-виджет салона.html» и переведена
   с палитры Manrope/коралл на палитру сайта (Onest, бежевое золото).
   Все классы с префиксом mcw- — с сайтом не конфликтуют.
   Логика — static/js/chat.js, сервер — /chat/.
   ========================================================================== */
.mcw, .mcw * { box-sizing: border-box; }
.mcw [hidden] { display: none !important; }

.mcw {
  position: fixed;
  right: 24px;
  bottom: 24px;
  z-index: 99999;
  font-family: var(--font, 'Onest', sans-serif);
}

@keyframes mcw-dot { 0%, 60%, 100% { transform: translateY(0); opacity: .35 } 30% { transform: translateY(-4px); opacity: 1 } }
@keyframes mcw-pop { from { opacity: 0; transform: translateY(16px) scale(.96) } to { opacity: 1; transform: translateY(0) scale(1) } }
@keyframes mcw-in { from { opacity: 0; transform: translateY(8px) } to { opacity: 1; transform: translateY(0) } }

/* --------------------------------------------------------------- кнопка */
.mcw-launcher {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  position: relative;
  border: none;
  cursor: pointer;
  padding: 15px 22px;
  border-radius: 40px;
  background: linear-gradient(135deg, #e2493a, #a52c24);
  color: #fff;
  font-weight: 600;
  font-size: 13.5px;
  box-shadow: 0 12px 30px -10px rgba(0, 0, 0, .8);
  transition: transform .16s, box-shadow .16s;
}
.mcw-launcher:hover { transform: translateY(-2px); box-shadow: 0 16px 34px -10px rgba(0, 0, 0, .9); }
/* Кнопка не исчезает при открытии: иконка перетекает в крестик,
   и тот же элемент закрывает панель. */
/* Открытую панель закрывают крестиком в её шапке, поэтому ярлык прячем:
   две кнопки «закрыть» рядом только путали. */
.mcw.is-open .mcw-launcher { display: none; }

.mcw.has-unread .mcw-launcher { animation: mcw-pulse 1.9s infinite; }
@keyframes mcw-pulse {
  0%, 100% { box-shadow: 0 12px 30px -10px rgba(0, 0, 0, .8), 0 0 0 0 rgba(226, 73, 58, .45); }
  50% { box-shadow: 0 12px 30px -10px rgba(0, 0, 0, .8), 0 0 0 9px rgba(226, 73, 58, 0); }
}

.mcw-badge {
  position: absolute;
  top: -4px;
  right: -4px;
  min-width: 20px;
  height: 20px;
  border-radius: 10px;
  background: #c9503f;
  color: #fff;
  font-size: 11px;
  font-weight: 700;
  display: grid;
  place-items: center;
  padding: 0 5px;
}

/* --------------------------------------------------------------- панель */
.mcw-panel {
  display: none;
  margin-bottom: 12px;
  width: 340px;
  max-width: calc(100vw - 32px);
  height: 520px;
  max-height: calc(100vh - 48px);
  flex-direction: column;
  overflow: hidden;
  border-radius: 18px;
  border: 1px solid rgba(230, 190, 152, .18);
  background: #120d0b;
  box-shadow: 0 30px 70px -20px rgba(0, 0, 0, .9),
              0 0 0 1px rgba(255, 255, 255, .03),
              0 0 60px -30px rgba(230, 190, 152, .35);
}
.mcw.is-open .mcw-panel { display: flex; animation: mcw-pop .22s ease; }
.mcw { display: flex; flex-direction: column; align-items: flex-end; }

.mcw-head {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 11px 12px 11px 14px;
  border-bottom: 1px solid rgba(255, 255, 255, .05);
  background: linear-gradient(135deg, rgba(230, 190, 152, .14), rgba(230, 190, 152, .03));
}
.mcw-name { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 3px; }
.mcw-name b {
  display: flex; align-items: center; gap: 7px;
  font-weight: 600; font-size: 13px; color: #f6efe6;
}
.mcw-name span { font-weight: 400; font-size: 10.5px; color: #8a7a6b; }
.mcw-online { width: 7px; height: 7px; border-radius: 50%; background: var(--live, #2fa96e); flex-shrink: 0; }
.mcw.is-offline .mcw-online { background: #7d6f62; }

.mcw-icon {
  flex-shrink: 0; width: 30px; height: 30px;
  display: grid; place-items: center;
  border: 1px solid var(--bd-16, rgba(230, 190, 152, .16));
  border-radius: 8px; background: transparent;
  color: var(--acc, #e6be98); cursor: pointer;
}
.mcw-icon:hover { border-color: var(--acc, #e6be98); }

/* ------------------------------------------------------------ сообщения */
.mcw-body {
  flex: 1;
  overflow-y: auto;
  padding: 12px 11px;
  display: flex;
  flex-direction: column;
  gap: 9px;
  background: #120d0b;
  scrollbar-width: thin;
}
.mcw-body::-webkit-scrollbar { width: 6px; }
.mcw-body::-webkit-scrollbar-thumb { background: rgba(230, 190, 152, .2); border-radius: 3px; }

.mcw-day {
  align-self: center;
  font-weight: 500; font-size: 10px; letter-spacing: .06em; color: #8a7a6b;
  background: #241b16; padding: 3px 10px; border-radius: 10px;
}
.mcw-row { display: flex; gap: 8px; align-items: flex-end; animation: mcw-in .25s ease; }
.mcw-row.me { flex-direction: row-reverse; }

.mcw-bubble { max-width: 232px; padding: 9px 12px; font-weight: 400; font-size: 12.5px; line-height: 1.5; }
.mcw-bubble.them { background: #27201b; color: #f2e7db; border-radius: 4px 14px 14px 14px; }
/* Ответы салона — на всю ширину окна и крупнее: их читают, а не пролистывают. */
.mcw-bubble.them { flex: 1 1 auto; max-width: none; padding: 11px 14px; font-size: 14px; line-height: 1.5; }
.mcw-bubble.them .mcw-time { font-size: 10.5px; }
.mcw-bubble.me { background: var(--acc, #e6be98); color: var(--on-acc, #0d0a08); border-radius: 14px 4px 14px 14px; font-weight: 500; }
.mcw-bubble a { color: var(--acc-lt, #eecfb2); border-bottom: 1px solid rgba(238, 207, 178, .4); }
.mcw-bubble.me a { color: #3a2a1c; border-bottom-color: rgba(58, 42, 28, .4); }
.mcw-time { font-weight: 600; font-size: 10px; text-align: right; margin-top: 4px; opacity: .6; }

/* сообщение не ушло на сервер */
.mcw-row.is-failed .mcw-bubble.me { background: rgba(230, 190, 152, .18); color: #f2e7db; }
.mcw-row.is-failed .mcw-time::after { content: ' · не отправлено'; }

/* ------------------------------------------- вложения от администратора */
.mcw-bubble .mcw-media { display: block; max-width: 100%; border-radius: 10px; }
.mcw-bubble .mcw-photo { cursor: zoom-in; }
.mcw-bubble .mcw-round { width: 190px; height: 190px; border-radius: 50%; object-fit: cover; }
.mcw-bubble .mcw-sticker { display: block; width: 140px; height: 140px; object-fit: contain; }
.mcw-tgs img, .mcw-tgs svg { display: block; width: 100%; height: 100%; }
.mcw-bubble .mcw-audio { display: block; width: 210px; max-width: 100%; margin: 2px 0; }
.mcw-bubble .mcw-caption { margin-top: 6px; }
/* карточка мастера от бота: слайдер кадров анкеты, подпись поверх фото,
   под ним — кнопка «Посмотреть анкету». Кадр 3/4, как на сайте. */
.mcw-bubble .mcw-card { position: relative; border-radius: 10px; overflow: hidden; aspect-ratio: 3 / 4; background: #1a1411; }
.mcw-bubble .mcw-card__track {
  display: flex; height: 100%; overflow-x: auto; scroll-snap-type: x mandatory;
  scrollbar-width: none; -ms-overflow-style: none;
}
.mcw-bubble .mcw-card__track::-webkit-scrollbar { display: none; }
.mcw-bubble .mcw-card__shot { flex: 0 0 100%; width: 100%; height: 100%; object-fit: cover; scroll-snap-align: center; }
.mcw-bubble .mcw-card__cap {
  position: absolute; inset: auto 0 0 0; padding: 26px 10px 9px; pointer-events: none;
  background: linear-gradient(to top, rgba(13, 10, 8, .88), rgba(13, 10, 8, 0));
  color: #f2e7db; font-weight: 500; font-size: 13px; line-height: 1.3; white-space: pre-line;
}
.mcw-bubble .mcw-card__nav {
  position: absolute; top: 50%; transform: translateY(-50%); z-index: 2;
  width: 28px; height: 28px; padding: 0; border: 0; border-radius: 7px;
  background: rgba(18, 14, 11, .5); color: var(--acc-lt, #eecfb2);
  font-size: 20px; line-height: 26px; cursor: pointer; transition: background .2s;
}
.mcw-bubble .mcw-card__nav:hover { background: rgba(18, 14, 11, .8); }
.mcw-bubble .mcw-card__nav--prev { left: 6px; }
.mcw-bubble .mcw-card__nav--next { right: 6px; }
.mcw-bubble .mcw-card__dots {
  position: absolute; top: 9px; left: 50%; transform: translateX(-50%); z-index: 2;
  display: flex; gap: 6px; pointer-events: none;
}
.mcw-bubble .mcw-card__dot {
  width: 5px; height: 5px; border-radius: 50%;
  background: rgba(255, 250, 244, .72); box-shadow: 0 0 0 1px rgba(13, 10, 8, .35), 0 1px 4px rgba(13, 10, 8, .7);
  transition: background .2s, transform .2s;
}
.mcw-bubble .mcw-card__dot.is-on { background: var(--acc-lt, #eecfb2); transform: scale(1.35); }
.mcw-bubble .mcw-card__btn {
  display: block; margin: 6px 2px 2px; padding: 8px 10px;
  border: 1px solid rgba(230, 190, 152, .45); border-radius: 8px;
  color: var(--acc-lt, #eecfb2); font-size: 12px; font-weight: 500; text-align: center; text-decoration: none;
  transition: background .2s, border-color .2s;
}
.mcw-bubble .mcw-card__btn:hover { background: rgba(230, 190, 152, .1); border-color: var(--acc, #e6be98); }
/* карточка мастера — прежней ширины: на всю ширину фото 3/4 выходит слишком высоким */
.mcw-bubble.them:has(> .mcw-card) { flex: 0 0 232px; padding: 4px; width: 232px; }
.mcw-bubble .mcw-file {
  display: inline-block; max-width: 100%; overflow-wrap: anywhere;
  color: var(--acc-lt, #eecfb2); border-bottom: 1px solid rgba(238, 207, 178, .4);
}
/* у стикера и кружочка фон пузыря лишний */
.mcw-bubble.them:has(> .mcw-sticker), .mcw-bubble.them:has(> .mcw-round) {
  background: transparent; padding: 0;
}

/* ------------------------------------- системные строки и контакты */
.mcw-row--system { justify-content: center; }
.mcw-system {
  max-width: 92%;
  text-align: center;
  font-weight: 400; font-size: 11.5px; line-height: 1.5; color: #a4937f;
  background: #241b16; padding: 7px 12px; border-radius: 12px;
}
.mcw-contacts { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; }
.mcw-cbtn {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 8px 14px; border-radius: 20px;
  border: 1px solid var(--bd-25, rgba(230, 190, 152, .25));
  background: rgba(230, 190, 152, .08);
  color: var(--acc-lt, #eecfb2);
  font-weight: 600; font-size: 12.5px; text-decoration: none;
}
.mcw-cbtn:hover { background: rgba(230, 190, 152, .16); border-color: var(--acc, #e6be98); }
/* «Ждём вас» от бота после записи: адрес и кнопки внутри пузыря */
.mcw-bubble .mcw-wait { font-weight: 400; }
.mcw-bubble .mcw-wait__addr { margin-top: 2px; color: #cdbfb1; }
.mcw-bubble .mcw-contacts--card { justify-content: flex-start; margin-top: 10px; gap: 6px; }
.mcw-bubble .mcw-contacts--card .mcw-cbtn { padding: 7px 12px; font-size: 12.5px; border-bottom: 1px solid var(--bd-25, rgba(230, 190, 152, .25)); }

/* ------------------------------------------------------------ лайтбокс */
.mcw-lb {
  position: fixed; inset: 0; z-index: 100000;
  display: flex; align-items: center; justify-content: center;
  background: rgba(6, 4, 3, .92); cursor: zoom-out;
  animation: mcw-pop .18s ease;
}
.mcw-lb img { max-width: 92vw; max-height: 88vh; border-radius: 12px; object-fit: contain; }
.mcw-lb__fig { margin: 0; display: flex; flex-direction: column; align-items: center; gap: 12px; max-width: 92vw; }
.mcw-lb__fig img { max-height: calc(100vh - 150px); max-height: calc(100dvh - 150px); }
.mcw-lb__cap { display: flex; flex-wrap: wrap; align-items: center; justify-content: center; gap: 8px 14px; cursor: default; color: #f2e7db; font-size: 15px; text-align: center; }
.mcw-lb__count { font-style: normal; color: #b6a596; font-size: 13px; }
.mcw-lb__btn {
  padding: 8px 16px; border: 1px solid rgba(230, 190, 152, .45); border-radius: 999px;
  color: var(--acc, #e6be98); font-size: 13.5px; text-decoration: none;
}
.mcw-lb__btn:hover { background: rgba(230, 190, 152, .12); }
.mcw-lb__nav {
  position: absolute; top: 50%; transform: translateY(-50%);
  width: 44px; height: 44px; display: grid; place-items: center;
  border: 1px solid rgba(230, 190, 152, .3); border-radius: 50%;
  background: rgba(6, 4, 3, .5); color: var(--acc, #e6be98); font-size: 26px; line-height: 1; cursor: pointer;
}
.mcw-lb__nav--prev { left: 14px; }
.mcw-lb__nav--next { right: 14px; }
.mcw-bubble .mcw-card__shot { cursor: zoom-in; }
@media (max-width: 520px) { .mcw-lb__nav { top: auto; bottom: 22px; transform: none; } }
.mcw-lb__close {
  position: absolute; top: 16px; right: 18px;
  width: 40px; height: 40px; display: grid; place-items: center;
  border: 1px solid rgba(230, 190, 152, .3); border-radius: 50%;
  background: transparent; color: var(--acc, #e6be98); cursor: pointer;
}

.mcw-typing {
  display: flex; gap: 4px; align-items: center;
  background: #27201b; border-radius: 4px 14px 14px 14px; padding: 12px 13px;
}
.mcw-typing span {
  width: 6px; height: 6px; border-radius: 50%;
  background: var(--acc, #e6be98); display: inline-block;
  animation: mcw-dot 1.2s infinite;
}
.mcw-typing span:nth-child(2) { animation-delay: .2s; }
.mcw-typing span:nth-child(3) { animation-delay: .4s; }

/* ------------------------------------------------------- быстрые ответы */
.mcw-quick { padding: 10px 12px 4px; display: flex; flex-direction: column; gap: 6px; background: #1a1411; }
.mcw-qtitle {
  font-weight: 600; font-size: 10px; color: #8a7a6b;
  letter-spacing: .06em; text-transform: uppercase; padding-left: 2px;
}
.mcw-chip {
  text-align: left;
  border: 1px solid rgba(230, 190, 152, .2);
  background: rgba(230, 190, 152, .05);
  color: var(--acc-lt, #eecfb2);
  font-weight: 500; font-size: 12px;
  padding: 8px 12px; border-radius: 11px; cursor: pointer;
  transition: background .15s, border-color .15s;
}
.mcw-chip:hover { background: rgba(230, 190, 152, .14); border-color: var(--acc, #e6be98); }

/* Прокрутка переписки не перетекает на страницу за чатом */
.mcw-panel, .mcw-body { overscroll-behavior: contain; }

/* ------------------------------------------------------------- ввод */
.mcw-input {
  display: flex; gap: 8px; align-items: flex-end;
  padding: 10px 12px;
  border-top: 1px solid var(--bd-14, rgba(230, 190, 152, .14));
  background: #120d0b;
}
/* Поле переносит длинный текст и растёт под него; высоту считает chat.js.
   Пять строк — предел, дальше прокрутка внутри поля. */
.mcw-input textarea {
  flex: 1; min-width: 0; border: none; outline: none; background: transparent;
  color: #f2e7db; font-family: inherit; font-weight: 400; font-size: 13px;
  line-height: 1.45; padding: 0; margin: 0;
  resize: none; overflow-y: auto; max-height: 92px; min-height: 19px;
}
.mcw-input textarea::placeholder { color: #7d6f62; }
.mcw-send {
  flex-shrink: 0; border: none;
  width: 34px; height: 34px; border-radius: 50%;
  background: var(--acc, #e6be98); color: var(--on-acc, #0d0a08);
  display: grid; place-items: center; cursor: pointer;
  transition: transform .15s;
}
.mcw-send:hover { transform: scale(1.06); }

.mcw-foot {
  padding: 0 12px 9px;
  font-weight: 400; font-size: 10px; line-height: 1.45; color: #7d6f62;
  background: #120d0b;
}

@media (max-width: 760px) {
  .mcw { right: 14px; bottom: 14px; }
  .mcw-launcher { padding: 13px 18px; font-size: 13px; }
}

/* Самолётик визуально тяжелее сверху справа — сдвигаем на пиксель,
   иначе в круглой кнопке он смотрится не по центру. */
.mcw-send svg { transform: translate(-1px, 1px); }

/* ------------------------------------------------ когда кнопка на экране */
/* Очередь первого экрана (ui.js, initIntro): до mars-chat-ready кнопки нет —
   на телефоне она лезла поверх окна 18+ и cookie. Открытое окно чата
   видно всегда. */
html:not(.mars-chat-ready) .mcw:not(.is-open) { display: none; }
html.mars-chat-ready .mcw-launcher { animation: mcw-in .35s ease; }
/* Лайтбокс фото: кнопка закрывала стрелку «следующее фото». */
html.mars-lb-open .mcw:not(.is-open) { display: none; }
/* Окно cookie внизу во всю ширину — кнопка встала бы на его кнопки. */
@media (max-width: 760px) {
  html:has(#osnova-cookie.is-open) .mcw:not(.is-open),
  html:has(.cookie.is-open) .mcw:not(.is-open) { display: none; }
}
