/* Чат на сайте. Все ресурсы локальные, внешних библиотек нет. */
.site-chat {
  position: fixed;
  right: max(1.15rem, env(safe-area-inset-right));
  bottom: max(1.15rem, env(safe-area-inset-bottom));
  z-index: 180;
  font-family: var(--font-body);
  transition: bottom .25s var(--ease), opacity .18s var(--ease), visibility .18s var(--ease);
}

.cookie-banner-visible .site-chat {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
}

.site-chat__launcher {
  position: relative;
  min-height: 54px;
  display: inline-flex;
  align-items: center;
  gap: .55rem;
  padding: .8rem 1.15rem;
  border: 0;
  border-radius: 999px;
  background: var(--primary-700);
  color: #fff;
  box-shadow: 0 12px 32px rgba(20, 52, 48, .24);
  font: 700 .98rem/1 var(--font-body);
  cursor: pointer;
}
.site-chat__launcher:hover { background: var(--primary); transform: translateY(-1px); }
.site-chat__launcher:focus-visible { outline: 3px solid rgba(46, 110, 102, .32); outline-offset: 3px; }
.site-chat__launcher svg { width: 23px; height: 23px; flex: 0 0 auto; }
.site-chat.is-open .site-chat__launcher {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transform: scale(.96);
}
.site-chat__badge {
  position: absolute;
  top: 0;
  right: .1rem;
  width: 13px;
  height: 13px;
  border: 2px solid #fff;
  border-radius: 50%;
  background: #d65353;
}

.site-chat__panel {
  position: absolute;
  right: 0;
  bottom: 0;
  width: min(400px, calc(100vw - 2rem));
  height: min(660px, calc(100dvh - 7rem));
  padding: 0;
  display: grid;
  grid-template-rows: auto auto minmax(110px, 1fr) auto auto;
  overflow: hidden;
  border: 1px solid var(--border);
  border-radius: 20px;
  background: #edf2f1;
  box-shadow: 0 24px 64px rgba(17, 35, 32, .26);
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transform: translateY(12px) scale(.98);
  transform-origin: bottom right;
  transition: opacity .2s var(--ease), transform .2s var(--ease), visibility .2s;
}
.site-chat.is-open .site-chat__panel {
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
  transform: none;
}

.site-chat__header {
  grid-row: 1;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: .78rem .9rem;
  background: var(--primary-700);
  color: #fff;
}
.site-chat__person { min-width: 0; display: flex; align-items: center; gap: .7rem; }
.site-chat__person > div { min-width: 0; display: grid; gap: .16rem; }
.site-chat__avatar {
  width: 42px;
  height: 42px;
  flex: 0 0 auto;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: rgba(255, 255, 255, .16);
  border: 1px solid rgba(255, 255, 255, .24);
  font-family: var(--font-head);
  font-weight: 600;
}
.site-chat__header strong { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font: 700 1rem/1.2 var(--font-body); }
.site-chat__header span:not(.site-chat__avatar) { color: rgba(255,255,255,.78); font-size: .76rem; }
.site-chat__header-actions { display: flex; align-items: center; gap: .1rem; }
.site-chat__close,
.site-chat__expand {
  width: 38px;
  height: 38px;
  flex: 0 0 auto;
  display: grid;
  place-items: center;
  border: 0;
  border-radius: 50%;
  background: transparent;
  color: #fff;
  line-height: 1;
  cursor: pointer;
}
.site-chat__close { font-size: 1.45rem; }
.site-chat__expand { text-decoration: none; }
.site-chat__expand svg { width: 20px; height: 20px; }
.site-chat__close:hover,
.site-chat__expand:hover { background: rgba(255,255,255,.12); }
.site-chat__close:focus-visible,
.site-chat__expand:focus-visible { outline: 2px solid #fff; outline-offset: -3px; }

.site-chat__intro {
  grid-row: 2;
  padding: .7rem .9rem;
  border-bottom: 1px solid var(--border);
  background: #f7faf9;
  color: var(--ink-soft);
  font-size: .79rem;
  line-height: 1.45;
  overflow-wrap: anywhere;
}
.site-chat__intro[hidden] { display: none; }
.site-chat__register-link {
  display: inline;
  padding: 0;
  border: 0;
  background: none;
  color: var(--primary-700);
  font: inherit;
  font-weight: 700;
  text-decoration: underline;
  text-underline-offset: 2px;
  cursor: pointer;
}

.site-chat__messages {
  grid-row: 3;
  min-width: 0;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: .55rem;
  padding: .9rem;
  scrollbar-gutter: stable;
  background:
    radial-gradient(circle at 12% 22%, rgba(42, 95, 88, .04) 0 2px, transparent 2.5px) 0 0 / 28px 28px,
    #edf2f1;
}
.site-chat__empty { margin: auto; padding: 1rem; color: var(--ink-muted); font-size: .82rem; text-align: center; }
.site-chat__message {
  max-width: 84%;
  padding: .62rem .72rem .42rem;
  border-radius: 15px;
  box-shadow: 0 1px 2px rgba(17, 35, 32, .08);
  color: var(--ink);
  font-size: .88rem;
  line-height: 1.42;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}
.site-chat__message--client { align-self: flex-end; border-bottom-right-radius: 4px; background: #d9eee8; }
.site-chat__message--admin { align-self: flex-start; border-bottom-left-radius: 4px; background: #fff; }
.site-chat__message--system {
  align-self: center;
  max-width: 92%;
  border: 1px solid var(--border);
  background: rgba(255,255,255,.78);
  color: var(--ink-soft);
  text-align: center;
  font-size: .78rem;
}
.site-chat__message-time { display: block; margin-top: .18rem; color: var(--ink-muted); font-size: .65rem; text-align: right; }
.site-chat__message-link {
  display: inline-flex;
  margin-top: .5rem;
  padding: .45rem .7rem;
  border-radius: 999px;
  background: var(--primary-700);
  color: #fff;
  font-weight: 700;
  text-decoration: none;
}
.site-chat__attachments { display: grid; gap: .45rem; white-space: normal; }
.site-chat__attachment {
  min-width: 190px;
  max-width: 100%;
  display: grid;
  gap: .45rem;
  overflow: hidden;
  border: 1px solid rgba(35, 79, 74, .16);
  border-radius: 11px;
  background: rgba(255,255,255,.72);
  color: var(--ink);
  text-decoration: none;
}
.site-chat__attachment:hover { border-color: var(--primary); text-decoration: none; }
.site-chat__attachment img { width: 100%; max-height: 190px; display: block; object-fit: cover; background: var(--surface-alt); }
.site-chat__attachment-details { min-width: 0; display: grid; gap: .08rem; padding: .5rem .58rem; }
.site-chat__attachment-details strong { overflow: hidden; color: var(--ink); font-size: .78rem; text-overflow: ellipsis; white-space: nowrap; }
.site-chat__attachment-details small { color: var(--ink-muted); font-size: .65rem; }
.site-chat__reactions { position: relative; display: flex; flex-wrap: wrap; align-items: center; gap: .22rem; margin-top: .35rem; white-space: normal; }
.site-chat__reaction,
.site-chat__reaction-add,
.site-chat__reaction-picker button {
  border: 1px solid var(--border);
  background: rgba(255,255,255,.76);
  cursor: pointer;
}
.site-chat__reaction { min-height: 26px; padding: .16rem .42rem; border-radius: 999px; font-size: .73rem; }
.site-chat__reaction.is-mine { border-color: var(--primary); background: #cce5df; }
.site-chat__reaction-add { width: 27px; height: 27px; padding: 0; border-radius: 50%; color: var(--ink-muted); font-size: .84rem; }
.site-chat__reaction:hover,
.site-chat__reaction-add:hover { border-color: var(--primary); }
.site-chat__reaction-picker {
  position: absolute;
  left: 0;
  bottom: 2rem;
  z-index: 4;
  display: flex;
  gap: .15rem;
  padding: .3rem;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: #fff;
  box-shadow: var(--shadow-md);
}
.site-chat__message--client .site-chat__reaction-picker { right: 0; left: auto; }
.site-chat__reaction-picker[hidden] { display: none; }
.site-chat__reaction-picker button { width: 30px; height: 30px; padding: 0; border-radius: 50%; font-size: .9rem; }
.site-chat__reaction-picker button:hover { background: var(--surface-alt); }

.site-chat__save {
  grid-row: 4;
  padding: .58rem .85rem;
  border-top: 1px solid var(--border);
  background: #f7faf9;
}
.site-chat__save p { margin: 0; color: var(--ink-soft); font-size: .73rem; line-height: 1.4; }
.site-chat__login-actions { display: flex; flex-wrap: wrap; gap: .4rem; margin-top: .48rem; }
.site-chat__login {
  padding: .46rem .65rem;
  border: 1px solid var(--border-strong);
  border-radius: 9px;
  background: #fff;
  color: var(--ink);
  font-size: .73rem;
  font-weight: 700;
  text-decoration: none;
}
.site-chat__login:hover { border-color: var(--primary); text-decoration: none; }
.site-chat__login--yandex::before { content: "Я"; color: #d12e2e; margin-right: .35rem; }
.site-chat__login--vk::before { content: "VK"; color: #1673d1; margin-right: .35rem; }

.site-chat__form {
  grid-row: 5;
  display: grid;
  gap: .5rem;
  min-width: 0;
  padding: .62rem .72rem .72rem;
  border-top: 1px solid var(--border);
  background: #f7faf9;
}
.site-chat__first-fields {
  display: grid;
  gap: .48rem;
  padding: .75rem;
  border: 1px solid var(--border);
  border-radius: 14px;
  background: #fff;
  box-shadow: var(--shadow-sm);
}
.site-chat__first-fields[hidden] { display: none; }
.site-chat__first-fields strong { color: var(--ink); font-size: .9rem; text-align: center; }
.site-chat__first-fields small { color: var(--ink-muted); font-size: .68rem; line-height: 1.35; }
.site-chat__first-fields input[type="text"] {
  width: 100%;
  min-height: 42px;
  padding: .62rem .75rem;
  border: 1px solid var(--border-strong);
  border-radius: 11px;
  background: #fff;
  color: var(--ink);
  font: 400 .9rem/1.4 var(--font-body);
}
.site-chat__first-fields input[type="text"]:focus { outline: 3px solid rgba(46,110,102,.14); border-color: var(--primary); }
.site-chat__consent { display: flex; align-items: flex-start; gap: .45rem; color: var(--ink-soft); font-size: .7rem; line-height: 1.35; }
.site-chat__consent span { min-width: 0; overflow-wrap: anywhere; }
.site-chat__consent input { margin-top: .12rem; flex: 0 0 auto; }
.site-chat__consent a { color: var(--primary-700); }

.site-chat__composer {
  position: relative;
  overflow: visible;
  border: 1px solid var(--border-strong);
  border-radius: 17px;
  background: #fff;
  box-shadow: 0 2px 10px rgba(17, 35, 32, .07);
}
.site-chat__composer textarea {
  width: 100%;
  min-height: 42px;
  max-height: 96px;
  display: block;
  overflow-y: auto;
  resize: none;
  padding: .7rem .78rem .28rem;
  border: 0;
  border-radius: 17px 17px 0 0;
  background: transparent;
  color: var(--ink);
  font: 400 .9rem/1.4 var(--font-body);
}
.site-chat__composer textarea:focus { outline: 0; }
.site-chat__composer:focus-within { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(46,110,102,.12); }
.site-chat__composer-bar { min-height: 42px; display: flex; align-items: center; justify-content: space-between; gap: .5rem; padding: .2rem .3rem .3rem .4rem; }
.site-chat__tools { display: flex; align-items: center; gap: .1rem; }
.site-chat__tool,
.site-chat__send {
  display: grid;
  place-items: center;
  border: 0;
  border-radius: 50%;
  cursor: pointer;
}
.site-chat__tool { width: 36px; height: 36px; background: transparent; color: var(--ink-muted); }
.site-chat__tool:hover { background: var(--surface-alt); color: var(--primary-700); }
.site-chat__tool:disabled { cursor: wait; opacity: .52; }
.site-chat__tool svg { width: 22px; height: 22px; }
.site-chat__send { width: 38px; height: 38px; background: var(--primary-700); color: #fff; }
.site-chat__send:hover { background: var(--primary); }
.site-chat__send:disabled { cursor: wait; opacity: .62; }
.site-chat__send svg { width: 21px; height: 21px; }
.site-chat__emoji-picker {
  position: absolute;
  left: .45rem;
  bottom: 3rem;
  z-index: 2;
  display: flex;
  flex-wrap: wrap;
  gap: .1rem;
  max-width: 260px;
  padding: .4rem;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: #fff;
  box-shadow: var(--shadow-md);
}
.site-chat__emoji-picker[hidden] { display: none; }
.site-chat__emoji-picker button { width: 34px; height: 34px; padding: 0; border: 0; border-radius: 8px; background: transparent; font-size: 1.15rem; cursor: pointer; }
.site-chat__emoji-picker button:hover { background: var(--surface-alt); }
.site-chat__status { min-height: 0; color: #9c3d3d; font-size: .73rem; line-height: 1.35; }
.site-chat__status[data-tone="info"] { color: var(--ink-soft); }
.site-chat__status:empty { display: none; }

@media (max-width: 760px) {
  .site-chat { right: .75rem; bottom: max(.75rem, env(safe-area-inset-bottom)); }
  .site-chat__panel {
    position: fixed;
    right: .5rem;
    left: .5rem;
    bottom: .5rem;
    width: auto;
    height: min(720px, calc(100dvh - 1rem));
    border-radius: 18px;
    transform-origin: bottom center;
  }
}

@media (max-width: 380px) {
  .site-chat__panel { right: .25rem; left: .25rem; bottom: .25rem; height: calc(100dvh - .5rem); }
  .site-chat__header { padding-inline: .7rem; }
}

@media (prefers-reduced-motion: reduce) {
  .site-chat__panel, .site-chat__launcher { transition: none; }
}

.sr-only {
  position: absolute !important;
  width: 1px !important;
  height: 1px !important;
  padding: 0 !important;
  margin: -1px !important;
  overflow: hidden !important;
  clip: rect(0, 0, 0, 0) !important;
  white-space: nowrap !important;
  border: 0 !important;
}
