/* ==========================================================================
   Виджет-консультант «Директор на связи» (ww = web widget)
   Файл: assets/theme/nabiullin/css/widget.css
   Подключается в чанке HEAD. Не конфликтует с legacy .w-feedback.
   ========================================================================== */

.ww {
  position: fixed;
  right: 120px;
  bottom: 120px;
  z-index: 1002;
  font-family: inherit;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

/* ── Кнопка-аватар ─────────────────────────────────────────── */
.ww-avatar {
  position: relative;
  width: 72px;
  height: 72px;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: transparent;
  cursor: pointer;
  filter: drop-shadow(0 10px 24px rgba(6, 135, 184, .35));
  transition: transform .25s cubic-bezier(.22, .68, 0, 1);
}
.ww-avatar:hover { transform: translateY(-2px) scale(1.04); }
.ww-avatar:focus-visible { outline: 3px solid #0687b8; outline-offset: 3px; }

.ww-avatar__img {
  position: relative;
  z-index: 2;
  display: block;
  width: 72px;
  height: 72px;
  border-radius: 50%;
  object-fit: cover;
  border: 3px solid #fff;
  background: #eef5f8;
}

/* Двойное пульсирующее кольцо */
.ww-avatar__ring {
  position: absolute;
  inset: 0;
  border-radius: 50%;
  pointer-events: none;
  box-shadow: 0 0 0 0 rgba(6, 135, 184, .55);
  animation: ww-pulse 2.4s cubic-bezier(.22, .68, 0, 1) infinite;
}
.ww-avatar__ring::after {
  content: '';
  position: absolute;
  inset: 0;
  border-radius: 50%;
  box-shadow: 0 0 0 0 rgba(6, 135, 184, .35);
  animation: ww-pulse 2.4s cubic-bezier(.22, .68, 0, 1) infinite 1.2s;
}
@keyframes ww-pulse {
  0%   { box-shadow: 0 0 0 0 rgba(6, 135, 184, .5); }
  70%  { box-shadow: 0 0 0 26px rgba(6, 135, 184, 0); }
  100% { box-shadow: 0 0 0 0 rgba(6, 135, 184, 0); }
}

.ww-avatar__badge {
  position: absolute;
  z-index: 3;
  top: -2px;
  right: -2px;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: #e63917;
  color: #fff;
  font-size: 11px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 2px 6px rgba(230, 57, 23, .5);
}
.ww-avatar__badge[hidden] { display: none; }

/* ── Окно чата ─────────────────────────────────────────────── */
.ww-window {
  position: absolute;
  right: 0;
  bottom: 88px;
  width: 360px;
  max-width: calc(100vw - 32px);
  max-height: 460px;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  background: rgba(255, 255, 255, .94);
  -webkit-backdrop-filter: blur(14px) saturate(160%);
  backdrop-filter: blur(14px) saturate(160%);
  border: 1px solid rgba(255, 255, 255, .6);
  border-radius: 20px;
  box-shadow: 0 24px 60px rgba(15, 32, 44, .22), 0 0 0 1px rgba(6, 135, 184, .06);
  transform-origin: bottom right;
}
.ww-window[hidden] { display: none; }
.ww-window.is-in { animation: ww-in .45s cubic-bezier(.22, .68, 0, 1); }
@keyframes ww-in {
  from { opacity: 0; transform: translateY(14px) scale(.94); }
  to   { opacity: 1; transform: none; }
}

.ww-head {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 16px;
  background: linear-gradient(135deg, #0687b8, #16a6d9);
  color: #fff;
  flex-shrink: 0;
}
.ww-head__ava {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  object-fit: cover;
  border: 2px solid rgba(255, 255, 255, .35);
  flex-shrink: 0;
}
.ww-head__info { flex: 1; min-width: 0; }
.ww-head__name {
  font-weight: 700;
  font-size: .95rem;
  line-height: 1.2;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.ww-head__status {
  display: flex;
  align-items: center;
  gap: 5px;
  margin-top: 2px;
  font-size: .72rem;
  opacity: .92;
}
.ww-head__status i {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #8ef0a4;
  box-shadow: 0 0 0 0 rgba(142, 240, 164, .7);
  animation: ww-online 1.8s infinite;
}
@keyframes ww-online {
  70%  { box-shadow: 0 0 0 7px rgba(142, 240, 164, 0); }
  100% { box-shadow: 0 0 0 0 rgba(142, 240, 164, 0); }
}
.ww-close {
  margin-left: auto;
  width: 30px;
  height: 30px;
  flex-shrink: 0;
  border: 0;
  border-radius: 50%;
  background: rgba(255, 255, 255, .2);
  color: #fff;
  font-size: 20px;
  line-height: 1;
  cursor: pointer;
  transition: background .2s;
}
.ww-close:hover { background: rgba(255, 255, 255, .35); }
.ww-close:focus-visible { outline: 2px solid #fff; outline-offset: 2px; }

.ww-body {
  padding: 16px;
  overflow-y: auto;
  flex: 1;
  min-height: 0;
}
.ww-msg__bubble {
  background: #fff;
  border: 1px solid #e6edf1;
  border-radius: 14px 14px 14px 4px;
  padding: 12px 14px;
  font-size: .92rem;
  line-height: 1.6;
  color: #1a1d23;
  animation: ww-fade .35s ease-out;
  word-wrap: break-word;
}
.ww-msg__bubble:empty { display: none; }
@keyframes ww-fade {
  from { opacity: 0; transform: translateY(6px); }
  to   { opacity: 1; }
}
.ww-msg__bubble strong { color: #0687b8; font-weight: 700; }
.ww-msg__bubble em { font-style: italic; color: #586069; }
.ww-msg__bubble .accent { color: #0687b8; font-weight: 600; }
.ww-msg__bubble .highlight {
  background: linear-gradient(120deg, #fef3c7, #fde68a);
  padding: 1px 6px;
  border-radius: 4px;
  font-weight: 600;
}
.ww-msg__bubble .warning { color: #e63917; font-weight: 600; }
.ww-msg__bubble a { color: #0687b8; font-weight: 600; text-decoration: underline; text-underline-offset: 2px; }
.ww-msg__bubble br { display: block; content: ''; margin: 3px 0; }

.ww-typing {
  display: flex;
  gap: 5px;
  align-items: center;
  padding: 0 4px 8px;
}
.ww-typing[hidden] { display: none; }
.ww-typing span {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #b7c6ce;
  animation: ww-bounce 1.4s ease-in-out infinite;
}
.ww-typing span:nth-child(2) { animation-delay: .2s; }
.ww-typing span:nth-child(3) { animation-delay: .4s; }
@keyframes ww-bounce {
  0%, 60%, 100% { transform: translateY(0); opacity: .35; }
  30%           { transform: translateY(-6px); opacity: 1; }
}

.ww-cta {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding: 12px 16px 16px;
  border-top: 1px solid #eef3f6;
  flex-shrink: 0;
}
.ww-cta[hidden] { display: none; }
.ww-btn {
  flex: 1 1 auto;
  text-align: center;
  padding: 10px 12px;
  border-radius: 12px;
  font-size: .85rem;
  font-weight: 600;
  text-decoration: none;
  white-space: nowrap;
  transition: .2s;
}
.ww-btn__primary {
  flex-basis: 100%;
  background: linear-gradient(135deg, #0687b8, #16a6d9);
  color: #fff;
}
.ww-btn__primary:hover { transform: translateY(-1px); box-shadow: 0 8px 20px rgba(6, 135, 184, .35); }
.ww-btn__ghost { background: #eef5f8; color: #0687b8; }
.ww-btn__ghost:hover { background: #e2eef3; }
.ww-btn[hidden] { display: none; }

/* ── Адаптив ───────────────────────────────────────────────── */
@media (max-width: 768px) {
  .ww { right: 20px; bottom: 20px; }
}
@media (max-width: 480px) {
  .ww { right: 12px; bottom: 12px; }
  .ww-window {
    position: fixed;
    right: 12px;
    left: 12px;
    bottom: 96px;
    width: auto;
    max-height: 70vh;
  }
}

/* ── Уважение к настройкам системы ─────────────────────────── */
@media (prefers-reduced-motion: reduce) {
  .ww-avatar__ring,
  .ww-avatar__ring::after,
  .ww-head__status i,
  .ww-window,
  .ww-typing span,
  .ww-msg__bubble { animation: none !important; }
  .ww-avatar:hover { transform: none; }
}
