/* ============================================================
   Dom.models — чат на сайте. Токены берутся из основного CSS сайта,
   у каждого есть запасное значение.
   ============================================================ */

.dmc {
  --dmc-bg: var(--popover, #fbf8f3);
  --dmc-ink: var(--foreground, #3a2a1d);
  --dmc-muted: var(--muted-foreground, #7a6a5a);
  --dmc-line: var(--border, #e4dccf);
  --dmc-primary: var(--primary, #4a3423);
  --dmc-primary-ink: var(--primary-foreground, #fbf6ee);
  --dmc-them: var(--card, #ffffff);
  --dmc-me: var(--secondary, #efe4d2);
  --dmc-gold: var(--gold, #c9a24a);
  --dmc-ok: #4f7a4a;
  font-family: var(--font-sans, "Manrope", system-ui, sans-serif);
  color: var(--dmc-ink);
}
.dmc *, .dmc *::before, .dmc *::after { box-sizing: border-box; }

/* ---------- Кнопка ---------- */
.dmc-launcher {
  position: fixed;
  right: 1.25rem;
  bottom: 1.25rem;
  z-index: 55;
  display: inline-flex;
  align-items: center;
  gap: .55rem;
  min-height: 52px;
  padding: 0 1.25rem 0 1.05rem;
  border: 0;
  border-radius: 999px;
  background: var(--dmc-primary);
  color: var(--dmc-primary-ink);
  font: 600 .92rem/1 var(--font-sans, "Manrope", system-ui, sans-serif);
  box-shadow: 0 10px 30px -12px rgba(58, 42, 29, .55), 0 2px 6px rgba(58, 42, 29, .12);
  cursor: pointer;
  transition: transform .2s ease, box-shadow .2s ease;
}
.dmc-launcher:hover { transform: translateY(-2px); }
.dmc-launcher:focus-visible { outline: 2px solid var(--dmc-gold); outline-offset: 3px; }
.dmc.is-open .dmc-launcher { display: none; }
.dmc-badge {
  position: absolute;
  top: -.3rem;
  right: -.3rem;
  min-width: 1.35rem;
  height: 1.35rem;
  padding: 0 .35rem;
  border-radius: 999px;
  background: var(--dmc-gold);
  color: #2b1d12;
  font-size: .72rem;
  font-weight: 700;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 2px solid var(--dmc-bg);
}
.dmc-badge[hidden] { display: none; }
.dmc.has-unread .dmc-launcher { animation: dmc-nudge 2.4s ease-in-out 1; }
@keyframes dmc-nudge { 0%, 100% { transform: none; } 8% { transform: translateY(-4px); } 16% { transform: none; } 24% { transform: translateY(-2px); } 32% { transform: none; } }

/* Бронирование открыто — кнопка не мешает */
body.modal-open .dmc-launcher { display: none; }

/* На страницах 18+ и 14–17 справа уже стоят «Записаться» и ссылка на чат —
   ссылку прячем (кнопка чата её заменяет), «Записаться» поднимаем выше. */
body .mobile-floating-actions { bottom: 5.25rem; }
body .mobile-floating-actions > a { display: none; }

/* ---------- Мобильный ---------- */
@media (max-width: 767px) {
  .dmc-launcher { right: 1rem; bottom: calc(1rem + env(safe-area-inset-bottom)); width: 56px; height: 56px; min-height: 0; padding: 0; justify-content: center; }
  .dmc-launcher-text { display: none; }
  .dmc-has-nav .dmc-launcher { bottom: calc(76px + env(safe-area-inset-bottom)); }
  /* В нижней панели уже есть пункт «Чат» — отдельная кнопка не нужна */
  .dmc-nav-chat .dmc:not(.has-unread) .dmc-launcher { display: none; }
  .dmc-nav-chat .dmc.has-unread .dmc-launcher { display: inline-flex; }
  html.dmc-lock, html.dmc-lock body { overflow: hidden; }
  /* Пока открыта плашка про статистику, кнопка под ней не выглядывает */
  body:has(.dm-privacy.is-shown:not(.is-hidden)) .dmc-launcher { opacity: 0; pointer-events: none; }
}

/* ---------- Окно ---------- */
.dmc-panel {
  position: fixed;
  right: 1.25rem;
  bottom: 1.25rem;
  z-index: 70;
  width: min(24.5rem, calc(100vw - 2.5rem));
  height: min(38rem, calc(100vh - 2.5rem));
  height: min(38rem, calc(100dvh - 2.5rem));
  display: flex;
  flex-direction: column;
  background: var(--dmc-bg);
  border: 1px solid var(--dmc-line);
  border-radius: 1.5rem;
  box-shadow: 0 30px 80px -30px rgba(58, 42, 29, .45), 0 4px 14px rgba(58, 42, 29, .08);
  overflow: hidden;
  animation: dmc-in .22s ease-out;
}
.dmc-panel[hidden] { display: none; }
@keyframes dmc-in { from { opacity: 0; transform: translateY(12px) scale(.98); } to { opacity: 1; transform: none; } }
@media (max-width: 767px) {
  .dmc-panel { inset: 0; width: auto; height: auto; border-radius: 0; border: 0; }
}
@media (prefers-reduced-motion: reduce) {
  .dmc-panel, .dmc.has-unread .dmc-launcher { animation: none; }
}

.dmc-head {
  display: flex;
  align-items: center;
  gap: .75rem;
  padding: calc(1rem + env(safe-area-inset-top)) 1rem 1rem 1.25rem;
  border-bottom: 1px solid var(--dmc-line);
}
.dmc-head-text { flex: 1; min-width: 0; }
.dmc-title { margin: 0; font-family: var(--font-display, "Playfair Display", Georgia, serif); font-size: 1.25rem; line-height: 1.2; }
.dmc-status { margin: .2rem 0 0; font-size: .8rem; color: var(--dmc-muted); display: flex; align-items: center; gap: .4rem; }
.dmc-status::before { content: ""; width: .5rem; height: .5rem; border-radius: 50%; background: #c4b8a8; flex: none; }
.dmc.is-online .dmc-status::before { background: var(--dmc-ok); box-shadow: 0 0 0 3px rgba(79, 122, 74, .18); }
.dmc-close {
  flex: none;
  width: 44px;
  height: 44px;
  border: 0;
  border-radius: 50%;
  background: transparent;
  color: var(--dmc-muted);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.dmc-close:hover { background: var(--dmc-me); color: var(--dmc-ink); }

.dmc-body { flex: 1; min-height: 0; overflow-y: auto; padding: 1rem 1rem .5rem; overscroll-behavior: contain; }

/* ---------- Сообщения ---------- */
.dmc-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: .45rem; }
.dmc-msg {
  max-width: 86%;
  padding: .6rem .85rem .45rem;
  border-radius: 1.1rem;
  font-size: .93rem;
  line-height: 1.5;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}
.dmc-msg.is-them { align-self: flex-start; background: var(--dmc-them); border: 1px solid var(--dmc-line); border-bottom-left-radius: .35rem; }
.dmc-msg.is-me { align-self: flex-end; background: var(--dmc-primary); color: var(--dmc-primary-ink); border-bottom-right-radius: .35rem; }
.dmc-msg.is-greet { max-width: 92%; }
.dmc-msg-text { display: block; }
.dmc-msg-time { display: block; margin-top: .15rem; font-size: .68rem; opacity: .65; text-align: right; }
.dmc-msg.is-greet .dmc-msg-time { display: none; }
.dmc-msg.is-failed { background: #f3dcd6; color: #6d2a1d; cursor: pointer; }

/* ---------- Первый экран ---------- */
.dmc-intro { margin-top: 1rem; display: grid; gap: .75rem; }
.dmc-intro[hidden], .dmc-offline[hidden], .dmc-composer[hidden] { display: none; }
.dmc-field { display: grid; gap: .3rem; }
.dmc-label { font-size: .82rem; font-weight: 600; }
.dmc-label small { font-weight: 400; color: var(--dmc-muted); }
.dmc-input {
  width: 100%;
  min-height: 44px;
  padding: .6rem .85rem;
  border: 1px solid var(--input, #cfc3b3);
  border-radius: .9rem;
  background: #fff;
  color: var(--dmc-ink);
  font: inherit;
  font-size: 16px;               /* без зума на iPhone */
  line-height: 1.4;
}
.dmc-input:focus { outline: 2px solid var(--ring, var(--dmc-gold)); outline-offset: 0; border-color: transparent; }
.dmc-textarea { resize: none; min-height: 5.5rem; }
.dmc-hp { position: absolute; left: -9999px; width: 1px; height: 1px; opacity: 0; }
.dmc-consent { display: flex; gap: .6rem; align-items: flex-start; font-size: .76rem; line-height: 1.45; color: var(--dmc-muted); }
.dmc-consent input { margin-top: .15rem; width: 1rem; height: 1rem; flex: none; accent-color: var(--dmc-primary); }
.dmc-consent a { color: var(--dmc-ink); text-decoration: underline; text-underline-offset: 2px; }
.dmc-error { margin: 0; font-size: .82rem; color: #a13a26; }
.dmc-error[hidden] { display: none; }
.dmc-primary, .dmc-secondary {
  min-height: 46px;
  border: 0;
  border-radius: 999px;
  font: 600 .92rem/1 var(--font-sans, "Manrope", system-ui, sans-serif);
  cursor: pointer;
}
.dmc-primary { background: var(--dmc-primary); color: var(--dmc-primary-ink); }
.dmc-secondary { padding: 0 1.1rem; background: var(--dmc-me); color: var(--dmc-ink); flex: none; }
.dmc-primary:disabled, .dmc-secondary:disabled { opacity: .6; cursor: default; }

/* ---------- Нет в сети: оставить контакт ---------- */
.dmc-offline {
  margin-top: .9rem;
  padding: .85rem;
  border: 1px dashed var(--dmc-gold);
  border-radius: 1rem;
  background: rgba(201, 162, 74, .08);
}
.dmc-offline-text { margin: 0 0 .6rem; font-size: .84rem; line-height: 1.5; }
.dmc-offline-row { display: flex; gap: .5rem; }

/* ---------- Поле ответа ---------- */
.dmc-composer {
  display: flex;
  align-items: flex-end;
  gap: .5rem;
  padding: .6rem .75rem;
  border-top: 1px solid var(--dmc-line);
}
.dmc-compose { flex: 1; resize: none; max-height: 120px; border-radius: 1.3rem; }
.dmc-send {
  flex: none;
  width: 44px;
  height: 44px;
  border: 0;
  border-radius: 50%;
  background: var(--dmc-primary);
  color: var(--dmc-primary-ink);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.dmc-foot { margin: 0; padding: .1rem 1rem calc(.55rem + env(safe-area-inset-bottom)); font-size: .68rem; color: var(--dmc-muted); text-align: center; }

.dmc a:focus-visible, .dmc button:focus-visible { outline: 2px solid var(--dmc-gold); outline-offset: 2px; }

@media print { .dmc { display: none !important; } }
