/* Единый блок: «наверх» + чат */

.float-actions {
  position: fixed;
  right: 20px;
  bottom: 20px;
  z-index: 9999;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0;
  width: 64px;
  height: 64px;
  padding: 8px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.96);
  border: 1px solid #e3e8f7;
  box-shadow: 0 10px 28px rgba(25, 25, 50, 0.14);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  box-sizing: border-box;
  transition:
    height 0.38s cubic-bezier(0.22, 1, 0.36, 1),
    gap 0.38s cubic-bezier(0.22, 1, 0.36, 1),
    box-shadow 0.25s ease,
    bottom 0.25s ease;
}

.float-actions--scrolled {
  height: 120px;
  gap: 8px;
}

.scroll-to-top,
.chat-widget {
  position: relative;
  display: grid;
  place-items: center;
  width: 48px;
  height: 48px;
  margin: 0;
  padding: 0;
  border: none;
  border-radius: 50%;
  cursor: pointer;
  flex: 0 0 auto;
  -webkit-tap-highlight-color: transparent;
}

.scroll-to-top {
  z-index: 1;
  height: 0;
  min-height: 0;
  opacity: 0;
  overflow: hidden;
  visibility: hidden;
  pointer-events: none;
  transform: translateY(12px) scale(0.55);
  background: var(--secondary, #2255f5);
  color: #fff;
  box-shadow: none;
  font-size: 1rem;
  transition:
    height 0.38s cubic-bezier(0.22, 1, 0.36, 1),
    opacity 0.28s ease,
    transform 0.38s cubic-bezier(0.22, 1, 0.36, 1),
    visibility 0.38s ease,
    background-color 0.2s ease;
}

.scroll-to-top.is-visible {
  height: 48px;
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
  transform: translateY(0) scale(1);
}

.scroll-to-top:hover {
  background: #1b49e6;
}

.scroll-to-top:focus-visible,
.chat-widget:focus-visible {
  outline: 2px solid var(--secondary, #2255f5);
  outline-offset: 2px;
}

.chat-widget {
  z-index: 2;
  background: var(--accent, #bbff00);
  color: #1f1c1c;
  box-shadow: 0 4px 12px rgba(187, 255, 0, 0.28);
  transition: transform 0.2s ease, background-color 0.2s ease, box-shadow 0.2s ease;
}

.chat-widget:hover {
  background: #c8ff3d;
  transform: translateY(-1px);
}

.chat-widget-active {
  background: #191932;
  color: #fff;
  box-shadow: 0 4px 12px rgba(25, 25, 50, 0.22);
}

.chat-widget-active:hover {
  background: #252545;
}

.chat-widget-icon-wrap {
  position: relative;
  display: grid;
  place-items: center;
  width: 100%;
  height: 100%;
}

.chat-widget-icon,
.chat-widget-close-icon {
  position: absolute;
  display: grid;
  place-items: center;
  font-size: 1.15rem;
  transition: opacity 0.18s ease, transform 0.18s ease;
}

.chat-widget-close-icon {
  opacity: 0;
  transform: rotate(-40deg) scale(0.7);
}

.chat-widget-active .chat-widget-icon {
  opacity: 0;
  transform: rotate(40deg) scale(0.7);
}

.chat-widget-active .chat-widget-close-icon {
  opacity: 1;
  transform: rotate(0) scale(1);
}

.chat-widget-pulse {
  position: absolute;
  inset: -4px;
  border-radius: 50%;
  border: 1.5px solid rgba(187, 255, 0, 0.55);
  pointer-events: none;
  animation: chat-widget-pulse 2.2s ease-out infinite;
}

.chat-widget-active .chat-widget-pulse {
  display: none;
}

.chat-widget-dot {
  position: absolute;
  top: 6px;
  right: 6px;
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: #2255f5;
  border: 1.5px solid #bbff00;
  z-index: 2;
}

.chat-widget-active .chat-widget-dot {
  display: none;
}

.chat-widget-panel {
  position: absolute;
  right: 0;
  bottom: calc(100% + 10px);
  z-index: 9998;
  width: 300px;
  max-width: calc(100vw - 36px);
  background: #fff;
  border: 1px solid #e3e8f7;
  border-radius: 18px;
  box-shadow: 0 16px 40px rgba(25, 25, 50, 0.16);
  opacity: 0;
  transform: translateY(10px) scale(0.96);
  transform-origin: bottom right;
  transition: opacity 0.22s ease, transform 0.22s ease;
  pointer-events: none;
  overflow: hidden;
}

.chat-widget-panel[aria-hidden="false"] {
  opacity: 1;
  transform: translateY(0) scale(1);
  pointer-events: auto;
}

.chat-widget-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 14px 12px;
  background: linear-gradient(135deg, #2255f5 0%, #00a2ff 100%);
  color: #fff;
}

.chat-widget-header h3 {
  margin: 0;
  font-size: 0.98rem;
  font-weight: 700;
}

.chat-widget-header p {
  margin: 3px 0 0;
  font-size: 0.78rem;
  opacity: 0.88;
}

.chat-widget-close {
  display: grid;
  place-items: center;
  width: 30px;
  height: 30px;
  border: none;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.18);
  color: #fff;
  cursor: pointer;
  transition: background-color 0.2s ease, transform 0.2s ease;
  padding: 0;
  flex: 0 0 auto;
}

.chat-widget-close:hover {
  background: rgba(255, 255, 255, 0.28);
  transform: rotate(90deg);
}

.chat-widget-close:focus-visible {
  outline: 2px solid #fff;
  outline-offset: 2px;
}

.chat-widget-options {
  display: grid;
  gap: 6px;
  padding: 12px;
}

.chat-widget-option {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px;
  border-radius: 12px;
  border: 1px solid #e8edf8;
  background: #f8faff;
  color: var(--dark, #191932);
  text-decoration: none;
  cursor: pointer;
  transition: transform 0.2s ease, border-color 0.2s ease, background-color 0.2s ease;
}

.chat-widget-option:hover {
  background: #fff;
  border-color: #c9d6f8;
  transform: translateY(-1px);
}

.chat-widget-option:focus-visible {
  outline: 2px solid var(--secondary);
  outline-offset: 2px;
}

.chat-option-icon {
  display: grid;
  place-items: center;
  width: 36px;
  height: 36px;
  border-radius: 10px;
  font-size: 1.05rem;
  flex-shrink: 0;
  color: #fff;
}

.chat-widget-whatsapp .chat-option-icon {
  background: #25d366;
}

.chat-widget-telegram .chat-option-icon {
  background: #2aabee;
}

.chat-widget-phone .chat-option-icon {
  background: #2255f5;
}

.chat-option-content {
  display: flex;
  flex-direction: column;
  gap: 1px;
  min-width: 0;
}

.chat-option-content strong {
  font-size: 0.9rem;
  font-weight: 700;
}

.chat-option-content span {
  font-size: 0.75rem;
  color: var(--gray, #696969);
}

@keyframes chat-widget-pulse {
  0% {
    transform: scale(0.96);
    opacity: 0.65;
  }
  100% {
    transform: scale(1.22);
    opacity: 0;
  }
}

@media (max-width: 768px) {
  .float-actions {
    right: 14px;
    bottom: max(14px, env(safe-area-inset-bottom, 0px));
    width: 58px;
    height: 58px;
    padding: 7px;
  }

  .float-actions--scrolled {
    height: 110px;
    gap: 6px;
  }

  .scroll-to-top,
  .chat-widget {
    width: 44px;
  }

  .scroll-to-top.is-visible {
    height: 44px;
  }

  .float-actions .chat-widget-panel {
    width: min(300px, calc(100vw - 28px));
    right: 0;
  }
}

/* Когда открыт cookie-баннер — поднимаем плавающие кнопки, чтобы не перекрывали его и футер */
body.cookie-banner-visible .float-actions {
  bottom: calc(120px + env(safe-area-inset-bottom, 0px));
}

@media (max-width: 420px) {
  body.cookie-banner-visible .float-actions {
    bottom: calc(180px + env(safe-area-inset-bottom, 0px));
  }
}

@media (prefers-reduced-motion: reduce) {
  .float-actions,
  .scroll-to-top,
  .chat-widget,
  .chat-widget-panel,
  .chat-widget-icon,
  .chat-widget-close-icon,
  .chat-widget-option {
    transition: none;
  }

  .chat-widget-pulse {
    animation: none;
    opacity: 0.3;
  }
}
