/* ================================================================
   ПЛАВАЮЩИЙ ВИДЖЕТ ЧАТА — правый нижний угол. Видна только главная
   кнопка (мигающая зелёная с плавной пульсацией) — по клику раскрывает
   способы связи (телефон / Telegram / MAX) над ней. Появляется плавно
   при скролле вниз (класс .is-visible, добавляется JS-ом в chat-widget.php).
   ================================================================ */

.grd-cw {
  position: fixed;
  right: 20px;
  bottom: 20px;
  z-index: 9999;
  opacity: 0;
  transform: translateY(18px) scale(.92);
  pointer-events: none;
  transition: opacity .5s ease, transform .5s cubic-bezier(.16, 1, .3, 1);
}

.grd-cw.is-visible {
  opacity: 1;
  transform: none;
  pointer-events: auto;
}

/* Класс+тег (специфичность 0,1,1) — надёжно перебивает возможные
   ресеты темы вида "button { ... }" вне зависимости от порядка подключения. */
button.grd-cw__main {
  position: relative !important;
  width: 68px !important;
  height: 68px !important;
  border: none !important;
  border-radius: 50% !important;
  padding: 0 !important;
  background: #25D366 !important;
  display: flex !important;
  align-items: center !important;
  justify-content: center !important;
  cursor: pointer;
  box-shadow: 0 6px 22px rgba(37, 211, 102, .5);
  animation: grd-cw-breathe 2.6s ease-in-out infinite;
  transition: box-shadow .2s;
}

button.grd-cw__main:hover,
button.grd-cw__main:focus {
  background: #25D366 !important;
  box-shadow: 0 8px 26px rgba(37, 211, 102, .65);
}

@keyframes grd-cw-breathe {
  0%, 100% { transform: scale(1); }
  50%      { transform: scale(1.08); }
}

.grd-cw__ring {
  position: absolute;
  inset: 0;
  border-radius: 50%;
  background: #25D366;
  animation: grd-cw-pulse-ring 2.2s cubic-bezier(.22, .61, .36, 1) infinite;
  pointer-events: none;
}

@keyframes grd-cw-pulse-ring {
  0%   { transform: scale(.95); opacity: .55; }
  70%  { transform: scale(1.9); opacity: 0; }
  100% { transform: scale(1.9); opacity: 0; }
}

/* "Непрочитанное сообщение" — узнаваемый сигнал уведомления, повышает
   кликабельность кнопки. Гасится, когда виджет открыт. */
.grd-cw__badge {
  position: absolute;
  top: 1px;
  right: 1px;
  width: 15px;
  height: 15px;
  border-radius: 50%;
  background: #ff4757;
  box-shadow: 0 0 0 2.5px rgba(255,255,255,.95), 0 2px 6px rgba(0,0,0,.25);
  transition: opacity .2s, transform .2s;
  z-index: 1;
}

.grd-cw.is-open .grd-cw__badge {
  opacity: 0;
  transform: scale(.4);
}

.grd-cw__icon {
  position: absolute;
  inset: 0;
  margin: auto;
  width: 30px;
  height: 30px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: opacity .18s, transform .18s;
}

.grd-cw__icon svg { width: 100% !important; height: 100% !important; max-width: none !important; display: block !important; }

/* Крестик держится только на stroke — явно защищаем от глобальных
   стилей темы вида "svg path { fill: currentColor }". Значок чата
   (bubble + точки) уже задаёт свои fill инлайн и в защите не нуждается —
   если оставить это правило общим для .grd-cw__icon, оно перебьёт заливку
   точек внутри bubble обратно в fill:none. */
.grd-cw__icon--close svg,
.grd-cw__icon--close svg path {
  fill: none !important;
  stroke: #fff !important;
}

.grd-cw__icon--close {
  opacity: 0;
  transform: scale(.6) rotate(-45deg);
}

.grd-cw.is-open .grd-cw__main {
  animation: none;
  transform: none;
}
.grd-cw.is-open .grd-cw__ring {
  animation: none;
  opacity: 0;
}
.grd-cw.is-open .grd-cw__icon--chat {
  opacity: 0;
  transform: scale(.6) rotate(45deg);
}
.grd-cw.is-open .grd-cw__icon--close {
  opacity: 1;
  transform: scale(1) rotate(0deg);
}

/* ---------- РАСКРЫВАЮЩИЕСЯ СПОСОБЫ СВЯЗИ ---------- */
.grd-cw__items {
  position: absolute;
  right: 6px;
  bottom: 82px;
  display: flex;
  flex-direction: column-reverse;
  gap: 10px;
  align-items: flex-end;
}

.grd-cw__item {
  width: 54px;
  height: 54px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  text-decoration: none;
  overflow: hidden;
  flex-shrink: 0;
  box-shadow: 0 4px 14px rgba(0, 0, 0, .18);
  opacity: 0;
  transform: translateY(14px) scale(.85);
  pointer-events: none;
  transition: opacity .22s ease, transform .22s ease, box-shadow .2s;
}

.grd-cw__item:hover {
  transform: translateY(0) scale(1.08) !important;
}

.grd-cw.is-open .grd-cw__item {
  opacity: 1;
  transform: translateY(0) scale(1);
  pointer-events: auto;
}

.grd-cw.is-open .grd-cw__item:nth-child(1) { transition-delay: .12s; }
.grd-cw.is-open .grd-cw__item:nth-child(2) { transition-delay: .08s; }
.grd-cw.is-open .grd-cw__item:nth-child(3) { transition-delay: .04s; }

.grd-cw__item svg {
  width: 54px;
  height: 54px;
  display: block;
  flex-shrink: 0;
}

/* Иконки-силуэты (телефон) — свой фон-круг задан инлайн через
   style="background:...", svg внутри меньше и по центру */
.grd-cw__item[style*="background"] svg {
  width: 26px;
  height: 26px;
}

.grd-cw__item[style*="background"] svg path {
  fill: #fff !important;
}

/* ---------- ПРИВЕТСТВЕННАЯ КАРТОЧКА (тизер) ----------
   Всплывает один раз за загрузку страницы рядом с кнопкой (см. JS в chat-widget.php),
   стиль — узнаваемая "карточка оператора": аватар, имя, статус, фраза.
   Клик по карточке (не по крестику) открывает виджет. */
.grd-cw__teaser {
  position: absolute;
  right: 0;
  bottom: 82px;
  width: 264px;
  max-width: calc(100vw - 40px);
  background: #fff;
  border-radius: 16px;
  box-shadow: 0 14px 40px rgba(0,0,0,.18), 0 2px 8px rgba(0,0,0,.08);
  padding: 14px 16px 16px;
  cursor: pointer;
  opacity: 0;
  transform: translateY(12px) scale(.96);
  pointer-events: none;
  transition: opacity .3s ease, transform .3s cubic-bezier(.16,1,.3,1);
}

.grd-cw__teaser.is-visible {
  opacity: 1;
  transform: none;
  pointer-events: auto;
}

.grd-cw__teaser::after {
  content: "";
  position: absolute;
  right: 26px;
  bottom: -7px;
  width: 14px;
  height: 14px;
  background: #fff;
  transform: rotate(45deg);
  border-radius: 2px;
  box-shadow: 3px 3px 6px rgba(0,0,0,.04);
}

.grd-cw__teaser-close {
  position: absolute !important;
  top: 4px;
  right: 4px;
  z-index: 5;
  width: 32px;
  height: 32px;
  border: none;
  background: transparent;
  color: rgba(10,10,10,.35);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  border-radius: 50%;
  pointer-events: auto;
  transition: background .15s, color .15s;
}
.grd-cw__teaser-close:hover {
  background: rgba(10,10,10,.06);
  color: rgba(10,10,10,.7);
}
.grd-cw__teaser-close svg { width: 14px; height: 14px; }

.grd-cw__teaser-row {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 8px;
  padding-right: 18px;
}

/* Обёртка БЕЗ overflow:hidden — иначе она обрезает зелёный кружок "онлайн",
   который намеренно выступает за край фото (позиционирован в притык к углу).
   Скругление и обрезка самого фото — на внутреннем .grd-cw__teaser-avatar-img. */
.grd-cw__teaser-avatar {
  position: relative;
  flex-shrink: 0;
  width: 40px;
  height: 40px;
}
.grd-cw__teaser-avatar-img {
  display: block;
  width: 100%;
  height: 100%;
  border-radius: 50%;
  overflow: hidden;
  background: #eef1f6;
}
.grd-cw__teaser-avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}
.grd-cw__teaser-online {
  position: absolute;
  right: -1px;
  bottom: -1px;
  width: 11px;
  height: 11px;
  border-radius: 50%;
  background: #25D366;
  box-shadow: 0 0 0 2px #fff;
}

.grd-cw__teaser-who {
  display: flex;
  flex-direction: column;
  min-width: 0;
}
.grd-cw__teaser-name {
  font-family: var(--font-family, sans-serif);
  font-size: 14px;
  font-weight: 600;
  color: #0a0a0a;
  line-height: 1.3;
}
.grd-cw__teaser-role {
  font-family: var(--font-family, sans-serif);
  font-size: 12px;
  color: rgba(10,10,10,.5);
  line-height: 1.3;
}

.grd-cw__teaser-text {
  font-family: var(--font-family, sans-serif);
  font-size: 13.5px;
  line-height: 1.5;
  color: #0a0a0a;
  margin: 0;
}

@media (max-width: 767px) {
  .grd-cw {
    right: 15px;
    bottom: 15px;
  }

  button.grd-cw__main {
    width: 58px !important;
    height: 58px !important;
  }

  .grd-cw__badge {
    width: 13px;
    height: 13px;
  }

  .grd-cw__icon {
    width: 26px;
    height: 26px;
  }

  .grd-cw__items {
    right: 4px;
    bottom: 70px;
  }

  .grd-cw__item {
    width: 48px;
    height: 48px;
  }

  .grd-cw__item svg {
    width: 48px;
    height: 48px;
  }

  .grd-cw__item[style*="background"] svg {
    width: 23px;
    height: 23px;
  }

  .grd-cw__teaser {
    bottom: 70px;
    width: 236px;
  }
}

/* Уважаем настройку "меньше анимаций" */
@media (prefers-reduced-motion: reduce) {
  .grd-cw {
    transition: opacity .2s ease;
    transform: none;
  }
  .grd-cw__main,
  .grd-cw__ring {
    animation: none;
  }
}
