/* =============================================================================
   Messenger Widget
   ============================================================================= */

/* Trigger button */
@keyframes mw-pulse {
  0%   { transform: scale(1);   opacity: 0.55; }
  100% { transform: scale(2.2); opacity: 0; }
}

@keyframes mw-wiggle {
  0%   { transform: rotate(0deg); }
  2%   { transform: rotate(-16deg) scale(1.1); }
  5%   { transform: rotate(14deg) scale(1.05); }
  8%   { transform: rotate(-10deg); }
  11%  { transform: rotate(8deg); }
  14%  { transform: rotate(-4deg); }
  17%  { transform: rotate(0deg); }
  100% { transform: rotate(0deg); }
}

.mw-trigger {
  position: fixed;
  right: 24px;
  bottom: 24px;
  z-index: 2147483630;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 60px;
  height: 60px;
  border-radius: 50%;
  border: none;
  cursor: pointer;
  outline: none;
  overflow: visible;
  background: linear-gradient(135deg, #0187fb 0%, #4dabfc 100%);
  box-shadow: 0 4px 20px rgba(1, 135, 251, 0.5);
  color: #fff;
  transition: transform 0.25s ease, box-shadow 0.25s ease;
}

/* Расходящиеся волны — два псевдоэлемента со сдвигом по времени */
.mw-trigger::before,
.mw-trigger::after {
  content: '';
  position: absolute;
  inset: 0;
  border-radius: 50%;
  background: rgba(1, 135, 251, 0.45);
  animation: mw-pulse 2.8s ease-out infinite;
  pointer-events: none;
  z-index: -1;
}

.mw-trigger::after {
  animation-delay: 1.1s;
}

.mw-trigger:hover {
  transform: scale(1.08);
  box-shadow: 0 6px 28px rgba(1, 135, 251, 0.65);
}

.mw-trigger:hover .mw-trigger__icon {
  animation: mw-wiggle 0.7s ease-in-out;
}

.mw-trigger:active {
  transform: scale(0.96);
}

.mw-trigger__icon,
.mw-trigger__close {
  position: absolute;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: opacity 0.25s ease, transform 0.25s ease;
}

/* Периодичное покачивание иконки: цикл 7s, активная фаза ~1.2s, потом пауза */
.mw-trigger__icon {
  animation: mw-wiggle 7s ease-in-out 3s infinite;
}

.mw-trigger__close {
  opacity: 0;
  transform: rotate(-90deg) scale(0.7);
}

/* При открытом модале — волны и покачивание останавливаются */
.mw-trigger--open::before,
.mw-trigger--open::after {
  animation-play-state: paused;
  opacity: 0;
}

.mw-trigger--open .mw-trigger__icon {
  animation: none;
  opacity: 0;
  transform: rotate(90deg) scale(0.7);
}

.mw-trigger--open .mw-trigger__close {
  opacity: 1;
  transform: rotate(0deg) scale(1);
}

/* Overlay */
.mw-overlay {
  position: fixed;
  inset: 0;
  z-index: 2147483631;
  display: flex;
  align-items: flex-end;
  justify-content: flex-end;
  padding: 0 24px calc(60px + 24px + 16px) 24px;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.25s ease;
}

.mw-overlay--visible {
  opacity: 1;
  pointer-events: auto;
}

/* Modal */
.mw-modal {
  position: relative;
  width: 100%;
  max-width: 360px;
  background: #1b1b1b;
  border-radius: 20px;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.45);
  overflow: hidden;
  transform: translateY(20px) scale(0.97);
  transition: transform 0.25s ease;
}

.mw-overlay--visible .mw-modal {
  transform: translateY(0) scale(1);
}

.mw-modal__close {
  position: absolute;
  top: 14px;
  right: 14px;
  z-index: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  border: none;
  cursor: pointer;
  outline: none;
  background: rgba(255, 255, 255, 0.08);
  color: #ffffff;
  transition: background 0.25s ease;
}

.mw-modal__close:hover {
  background: rgba(255, 255, 255, 0.16);
}

.mw-modal__header {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 24px 24px 16px;
}

.mw-modal__header-icon {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  border-radius: 12px;
  background: rgba(1, 135, 251, 0.15);
  color: #0187fb;
  margin-top: 2px;
}

.mw-modal__header-text {
  flex: 1;
  min-width: 0;
}

.mw-modal__title {
  margin: 0 0 4px;
  font-size: 15px;
  font-weight: 600;
  line-height: 1.3;
  color: #ffffff;
}

.mw-modal__subtitle {
  margin: 0;
  font-size: 13px;
  line-height: 1.45;
  color: rgba(255, 255, 255, 0.55);
}

.mw-modal__body {
  padding: 4px 12px 16px;
}

/* List */
.mw-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.mw-list__item {
  margin: 0;
}

/* Messenger buttons */
.mw-btn {
  display: flex;
  align-items: center;
  gap: 12px;
  width: stretch;
  padding: 12px 14px;
  border-radius: 14px;
  text-decoration: none;
  color: #ffffff;
  background: #252525;
  transition: background 0.25s ease, transform 0.25s ease;
  box-shadow: none;
  outline: none;
}

.mw-btn:link,
.mw-btn:visited {
  color: #ffffff;
  text-decoration: none;
  background: #252525;
}

.mw-btn:hover,
.mw-btn:focus {
  background: #2e2e2e;
  transform: translateX(2px);
  color: #ffffff;
  text-decoration: none;
  box-shadow: none;
  outline: none;
}

.mw-btn:active {
  transform: translateX(0);
  color: #ffffff;
  text-decoration: none;
}

.mw-btn__icon {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  border-radius: 10px;
  overflow: hidden;
}

.mw-btn__icon svg,
.mw-btn__icon img {
  width: 28px;
  height: 28px;
  display: block;
}

.mw-btn__label {
  flex: 1;
  font-size: 15px;
  font-weight: 500;
  line-height: 1;
}

.mw-btn__arrow {
  flex-shrink: 0;
  color: rgba(255, 255, 255, 0.55);
  display: flex;
  align-items: center;
  transition: transform 0.25s ease, color 0.25s ease;
}

.mw-btn:hover .mw-btn__arrow {
  transform: translateX(3px);
  color: #ffffff;
}

/* Per-messenger icon backgrounds */
.mw-btn--telegram .mw-btn__icon { background: #2ca5e0; }
.mw-btn--whatsapp .mw-btn__icon { background: #25d366; }
.mw-btn--instagram .mw-btn__icon { background: linear-gradient(45deg, #f09433, #e6683c, #dc2743, #cc2366, #bc1888); }
.mw-btn--max      .mw-btn__icon { background: linear-gradient(to right top, #4564fd, #615bf6, #7552ee, #8647e5, #943bdb); padding: 0; }
.mw-btn--phone    .mw-btn__icon { background: #4caf50; }

/* Body scroll lock */
body.mw-no-scroll {
  overflow: hidden;
}

/* Mobile */
@media screen and (max-width: 480px) {
  .mw-trigger {
    right: 16px;
    bottom: 16px;
  }

  .mw-overlay {
    padding: 0 8px calc(60px + 16px + 12px) 8px;
    align-items: flex-end;
    justify-content: center;
  }

  .mw-modal {
    max-width: 100%;
  }
}
