/* Чат поддержки на сайте (theme/site/html/site_chat_widget.tpl).
   Все селекторы с префиксом site-chat, чтобы не пересекаться с глобальными стилями.
   z-index: виджет 1050 ниже cookie-баннера (1100, custom.css) и модалок (9999, modal.css).
   --site-chat-offset выставляет site_chat.app.js: высота видимого cookie-баннера. */

.site-chat {
  --site-chat-offset: 0px;
  --site-chat-accent: #714c9f;
  --site-chat-accent-dark: #5b3b82;
  --site-chat-text: #252432;
  --site-chat-muted: #6b6a75;
  --site-chat-border: #e3ddee;
  --site-chat-error: #d0342c;
  --site-chat-success: #2e9e5b;
  font-family: inherit;
  font-size: 14px;
  line-height: 1.4;
  color: var(--site-chat-text);
}

.site-chat [hidden] {
  display: none !important;
}

/* Плавающая кнопка */
.site-chat__toggle {
  position: fixed;
  right: 16px;
  bottom: calc(16px + var(--site-chat-offset));
  z-index: 1050;
  width: 56px;
  height: 56px;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: var(--site-chat-accent);
  color: #fff;
  box-shadow: 0 8px 24px rgba(37, 36, 50, 0.28);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background-color 0.2s ease, transform 0.2s ease, bottom 0.2s ease;
  -webkit-tap-highlight-color: transparent;
}

.site-chat__toggle:hover {
  background: var(--site-chat-accent-dark);
  transform: translateY(-2px);
}

.site-chat__toggle:focus-visible {
  outline: 3px solid rgba(113, 76, 159, 0.4);
  outline-offset: 2px;
}

.site-chat__icon {
  display: block;
}

.site-chat__icon--close,
.site-chat--open .site-chat__icon--open {
  display: none;
}

.site-chat--open .site-chat__icon--close {
  display: block;
}

/* Панель */
.site-chat__panel {
  position: fixed;
  right: 16px;
  bottom: calc(84px + var(--site-chat-offset));
  z-index: 1050;
  width: 340px;
  max-width: calc(100vw - 32px);
  max-height: calc(100vh - 110px - var(--site-chat-offset));
  display: flex;
  flex-direction: column;
  background: #fff;
  border-radius: 16px;
  box-shadow: 0 16px 48px rgba(37, 36, 50, 0.24);
  overflow: hidden;
  transition: bottom 0.2s ease;
}

.site-chat__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 16px;
  background: var(--site-chat-accent);
  color: #fff;
  flex: 0 0 auto;
}

.site-chat__title {
  font-size: 16px;
  font-weight: 600;
}

.site-chat__close {
  width: 32px;
  height: 32px;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.16);
  color: #fff;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}

.site-chat__close:hover {
  background: rgba(255, 255, 255, 0.28);
}

.site-chat__form,
.site-chat__success {
  padding: 16px;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

.site-chat__hint {
  margin: 0 0 12px;
  color: var(--site-chat-muted);
  font-size: 13px;
}

.site-chat__label {
  display: block;
  margin: 0 0 10px;
  font-weight: 400;
}

.site-chat__label-text {
  display: block;
  margin-bottom: 4px;
  font-size: 12px;
  color: var(--site-chat-muted);
}

.site-chat__input,
.site-chat__textarea {
  display: block;
  width: 100%;
  box-sizing: border-box;
  margin: 0;
  padding: 10px 12px;
  border: 1px solid var(--site-chat-border);
  border-radius: 10px;
  background: #fff;
  color: var(--site-chat-text);
  font: inherit;
  font-size: 15px;
  line-height: 1.4;
  outline: 0;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.site-chat__input:focus,
.site-chat__textarea:focus {
  border-color: var(--site-chat-accent);
  box-shadow: 0 0 0 3px rgba(113, 76, 159, 0.16);
}

.site-chat__textarea {
  min-height: 96px;
  resize: vertical;
}

.site-chat__counter {
  margin: -6px 0 10px;
  text-align: right;
  font-size: 11px;
  color: var(--site-chat-muted);
}

.site-chat__counter--limit {
  color: var(--site-chat-error);
}

.site-chat__captcha {
  margin: 0 0 10px;
  min-height: 24px;
  font-size: 12px;
  color: var(--site-chat-muted);
}

.site-chat__captcha altcha-widget {
  --altcha-color-base: #fff;
  --altcha-color-border: var(--site-chat-border);
  --altcha-border-radius: 10px;
  --altcha-max-width: 100%;
  display: block;
  max-width: 100%;
}

/* common.css прячет все input[type=checkbox] (display:none) — внутри Altcha чекбокс нужен */
.site-chat__captcha altcha-widget .altcha-checkbox input[type="checkbox"] {
  display: block;
  position: static;
  opacity: 1;
  width: 22px;
  height: 22px;
  margin: 0;
  cursor: pointer;
  accent-color: var(--site-chat-accent);
}

.site-chat__captcha altcha-widget .altcha-checkbox-verifying input[type="checkbox"] {
  appearance: none;
  -webkit-appearance: none;
  opacity: 0;
  pointer-events: none;
}

.site-chat__captcha altcha-widget .altcha-label {
  font-size: 14px;
  cursor: pointer;
}

.site-chat__error {
  margin: 0 0 10px;
  padding: 8px 10px;
  border-radius: 8px;
  background: rgba(208, 52, 44, 0.08);
  color: var(--site-chat-error);
  font-size: 13px;
}

.site-chat__submit,
.site-chat__again {
  display: block;
  width: 100%;
  padding: 12px 16px;
  border: 0;
  border-radius: 10px;
  background: var(--site-chat-accent);
  color: #fff;
  font: inherit;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  transition: background-color 0.2s ease, opacity 0.2s ease;
}

.site-chat__submit:hover,
.site-chat__again:hover {
  background: var(--site-chat-accent-dark);
}

.site-chat__submit:disabled {
  opacity: 0.6;
  cursor: default;
}

.site-chat__success {
  text-align: center;
}

.site-chat__success-icon {
  width: 56px;
  height: 56px;
  margin: 8px auto 12px;
  border-radius: 50%;
  background: rgba(46, 158, 91, 0.12);
  color: var(--site-chat-success);
  display: flex;
  align-items: center;
  justify-content: center;
}

.site-chat__success-text {
  margin: 0 0 16px;
  font-size: 14px;
}

/* Мобильные: панель на весь экран поверх cookie-баннера, кнопка прячется */
@media (max-width: 480px) {
  .site-chat__toggle {
    right: 12px;
    width: 52px;
    height: 52px;
  }

  .site-chat__panel {
    top: 0;
    right: 0;
    bottom: 0;
    left: 0;
    z-index: 1200;
    width: auto;
    max-width: none;
    max-height: none;
    border-radius: 0;
  }

  .site-chat--open .site-chat__toggle {
    display: none;
  }
}
