/* =========================================================
   CHAT WIDGET FIX
   Правки для онлайн-чата:
   - можно двигать мышкой за шапку
   - не перекрывает соцсети справа
   - прилипает к левому / правому краю
   - аккуратен на мобильных
   - анимация "печатает..."
   - кнопка связи с оператором
   ========================================================= */

/* ---------- Базовые переменные ---------- */
:root {
  --chat-safe-right: 92px; /* запас справа под соцсети */
  --chat-safe-left: 16px;
  --chat-safe-bottom: 16px;
  --chat-width: 390px;
  --chat-max-height: min(78vh, 720px);

  --chat-bg: rgba(8, 20, 40, 0.94);
  --chat-bg-2: rgba(14, 30, 54, 0.98);
  --chat-border: rgba(255, 255, 255, 0.10);
  --chat-shadow: 0 18px 45px rgba(0, 0, 0, 0.45);

  --chat-text: #f2f7ff;
  --chat-muted: #9ab4d1;
  --chat-accent: #2bb7ff;
  --chat-accent-2: #21e18a;
  --chat-bubble: rgba(255, 255, 255, 0.07);
  --chat-bubble-2: rgba(43, 183, 255, 0.14);
}

/* ---------- Сам виджет ---------- */
.chat-widget {
  position: fixed;
  right: var(--chat-safe-right);
  bottom: var(--chat-safe-bottom);
  width: min(var(--chat-width), calc(100vw - var(--chat-safe-right) - 16px));
  max-height: var(--chat-max-height);
  display: flex;
  flex-direction: column;
  border-radius: 24px;
  background:
    linear-gradient(180deg, rgba(18, 42, 74, 0.98), rgba(5, 15, 30, 0.98));
  border: 1px solid var(--chat-border);
  box-shadow: var(--chat-shadow);
  overflow: hidden;
  z-index: 9990; /* ниже соцсетей, если их z-index выше */
  backdrop-filter: blur(18px);
  -webkit-backdrop-filter: blur(18px);
  user-select: none;
  transition:
    box-shadow 0.25s ease,
    transform 0.25s ease,
    width 0.25s ease,
    height 0.25s ease;
}

.chat-widget:hover {
  box-shadow: 0 22px 55px rgba(0, 0, 0, 0.52);
}

/* ---------- Когда чат скрыт ---------- */
.chat-widget.is-minimized {
  height: 76px;
  max-height: 76px;
}

.chat-widget.is-hidden-body .chat-widget__body,
.chat-widget.is-hidden-body .chat-widget__footer {
  display: none;
}

/* ---------- Шапка чата ---------- */
.chat-widget__header {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 16px 18px;
  background: linear-gradient(180deg, rgba(11, 45, 81, 0.95), rgba(10, 32, 58, 0.95));
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  cursor: grab; /* тащим за шапку */
  touch-action: none;
}

.chat-widget.is-dragging .chat-widget__header {
  cursor: grabbing;
}

.chat-widget__title-wrap {
  min-width: 0;
}

.chat-widget__title {
  margin: 0;
  font-size: 18px;
  line-height: 1.15;
  font-weight: 800;
  color: var(--chat-text);
}

.chat-widget__subtitle {
  margin: 4px 0 0;
  font-size: 14px;
  line-height: 1.2;
  color: var(--chat-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* ---------- Кнопки шапки ---------- */
.chat-widget__actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

.chat-widget__btn {
  width: 42px;
  height: 42px;
  border: 0;
  outline: 0;
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.08);
  color: #fff;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: transform 0.18s ease, background 0.18s ease, opacity 0.18s ease;
}

.chat-widget__btn:hover {
  transform: translateY(-1px);
  background: rgba(255, 255, 255, 0.14);
}

.chat-widget__btn svg {
  width: 18px;
  height: 18px;
  pointer-events: none;
}

/* ---------- Тело чата ---------- */
.chat-widget__body {
  padding: 14px 12px 10px;
  overflow-y: auto;
  overflow-x: hidden;
  background:
    radial-gradient(circle at top right, rgba(43, 183, 255, 0.10), transparent 28%),
    linear-gradient(180deg, rgba(5, 18, 35, 0.98), rgba(4, 12, 24, 0.98));
  scrollbar-width: thin;
  scrollbar-color: rgba(255,255,255,.25) transparent;
}

.chat-widget__body::-webkit-scrollbar {
  width: 8px;
}

.chat-widget__body::-webkit-scrollbar-thumb {
  background: rgba(255,255,255,.18);
  border-radius: 10px;
}

/* ---------- Сообщения ---------- */
.chat-msg {
  display: flex;
  margin-bottom: 10px;
}

.chat-msg--bot {
  justify-content: flex-start;
}

.chat-msg--user {
  justify-content: flex-end;
}

.chat-msg__bubble {
  max-width: 88%;
  padding: 14px 16px;
  border-radius: 18px;
  line-height: 1.45;
  font-size: 15px;
  color: var(--chat-text);
  border: 1px solid rgba(255,255,255,.06);
  box-shadow: inset 0 1px 0 rgba(255,255,255,.03);
}

.chat-msg--bot .chat-msg__bubble {
  background: linear-gradient(180deg, rgba(255,255,255,.08), rgba(255,255,255,.05));
}

.chat-msg--user .chat-msg__bubble {
  background: linear-gradient(180deg, rgba(43, 183, 255, .26), rgba(43, 183, 255, .16));
}

/* ---------- Плашки быстрых кнопок ---------- */
.chat-quick {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  margin: 10px 0 12px;
}

.chat-quick__btn {
  min-height: 52px;
  padding: 12px 14px;
  border-radius: 16px;
  border: 1px solid rgba(255,255,255,.08);
  background: linear-gradient(180deg, rgba(255,255,255,.06), rgba(255,255,255,.03));
  color: #eef6ff;
  font-size: 15px;
  font-weight: 700;
  cursor: pointer;
  transition: transform 0.18s ease, border-color 0.18s ease, background 0.18s ease;
}

.chat-quick__btn:hover {
  transform: translateY(-2px);
  border-color: rgba(43, 183, 255, .40);
  background: linear-gradient(180deg, rgba(43,183,255,.12), rgba(255,255,255,.04));
}

/* ---------- Текст-подсказка ---------- */
.chat-note {
  margin: 6px 4px 12px;
  font-size: 14px;
  line-height: 1.4;
  color: #7fc8ff;
}

/* ---------- Блок "печатает..." ---------- */
.chat-typing {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 10px 14px;
  border-radius: 16px;
  background: var(--chat-bubble);
  border: 1px solid rgba(255,255,255,.06);
}

.chat-typing__dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #dbeeff;
  opacity: 0.35;
  animation: chatTyping 1.2s infinite ease-in-out;
}

.chat-typing__dot:nth-child(2) { animation-delay: 0.15s; }
.chat-typing__dot:nth-child(3) { animation-delay: 0.30s; }

@keyframes chatTyping {
  0%, 80%, 100% {
    transform: translateY(0);
    opacity: 0.35;
  }
  40% {
    transform: translateY(-4px);
    opacity: 1;
  }
}

/* ---------- Низ чата ---------- */
.chat-widget__footer {
  padding: 12px;
  background: linear-gradient(180deg, rgba(8, 20, 40, 0.95), rgba(6, 16, 30, 0.98));
  border-top: 1px solid rgba(255,255,255,.06);
}

.chat-operator {
  display: flex;
  gap: 10px;
  margin-bottom: 10px;
}

.chat-operator__btn {
  flex: 1;
  min-height: 48px;
  border: 0;
  border-radius: 16px;
  cursor: pointer;
  font-size: 15px;
  font-weight: 800;
  color: #fff;
  background: linear-gradient(135deg, #1fa2ff, #19d97c);
  box-shadow: 0 10px 24px rgba(31, 162, 255, 0.22);
  transition: transform .18s ease, filter .18s ease;
}

.chat-operator__btn:hover {
  transform: translateY(-1px);
  filter: brightness(1.05);
}

.chat-form {
  display: flex;
  align-items: center;
  gap: 10px;
}

.chat-form__input {
  flex: 1;
  min-width: 0;
  height: 52px;
  border-radius: 18px;
  border: 1px solid rgba(255,255,255,.08);
  background: rgba(255,255,255,.04);
  color: #fff;
  padding: 0 16px;
  outline: none;
  font-size: 16px;
}

.chat-form__input::placeholder {
  color: rgba(255,255,255,.45);
}

.chat-form__submit {
  width: 54px;
  height: 54px;
  flex-shrink: 0;
  border: 0;
  border-radius: 18px;
  background: linear-gradient(135deg, #2bb7ff, #3aa5ff);
  color: #081424;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  box-shadow: 0 10px 22px rgba(43, 183, 255, 0.25);
  transition: transform 0.18s ease, filter 0.18s ease;
}

.chat-form__submit:hover {
  transform: translateY(-1px);
  filter: brightness(1.05);
}

.chat-form__submit svg {
  width: 22px;
  height: 22px;
}

/* ---------- Плавающая кнопка открытия ---------- */
.chat-launcher {
  position: fixed;
  right: var(--chat-safe-right);
  bottom: 16px;
  z-index: 9989;
  width: 64px;
  height: 64px;
  border: 0;
  border-radius: 50%;
  background: linear-gradient(135deg, #2bb7ff, #1de18f);
  color: #06203a;
  font-weight: 900;
  cursor: pointer;
  box-shadow: 0 16px 34px rgba(13, 167, 255, 0.35);
  display: none;
}

.chat-launcher.is-visible {
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

/* ---------- Эффект прилипания ---------- */
.chat-widget.snap-left {
  right: auto !important;
  left: var(--chat-safe-left) !important;
}

.chat-widget.snap-right {
  left: auto !important;
  right: var(--chat-safe-right) !important;
}

/* ---------- Во время drag ---------- */
.chat-widget.is-dragging {
  transition: none !important;
  opacity: 0.98;
}

/* ---------- Мобильная адаптация ---------- */
@media (max-width: 991px) {
  :root {
    --chat-safe-right: 16px; /* на планшетах почти нет соцсетей справа */
  }

  .chat-widget {
    width: min(390px, calc(100vw - 32px));
  }

  .chat-launcher {
    right: 16px;
  }
}

@media (max-width: 767px) {
  .chat-widget {
    left: 12px !important;
    right: 12px !important;
    bottom: 12px !important;
    width: auto !important;
    max-height: 78vh;
    border-radius: 22px;
  }

  .chat-widget.snap-left,
  .chat-widget.snap-right {
    left: 12px !important;
    right: 12px !important;
  }

  .chat-launcher {
    right: 12px;
    bottom: 12px;
    width: 58px;
    height: 58px;
  }

  .chat-quick {
    grid-template-columns: 1fr 1fr;
  }

  .chat-form__input {
    font-size: 15px;
  }

  .chat-widget__title {
    font-size: 17px;
  }

  .chat-widget__subtitle {
    font-size: 13px;
  }
}

@media (max-width: 480px) {
  .chat-quick {
    grid-template-columns: 1fr;
  }

  .chat-widget__header {
    padding: 14px;
  }

  .chat-widget__body {
    padding: 12px 10px 8px;
  }

  .chat-widget__footer {
    padding: 10px;
  }
}
/* добавил  */
.chat-widget.is-minimized {
  height: 76px;
  max-height: 76px;
  overflow: hidden;
}

.chat-widget.is-hidden-body .chat-widget__body,
.chat-widget.is-hidden-body .chat-widget__footer {
  display: none;
}