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

.msg-widget {
    position: fixed;
    right: 24px;
    bottom: 24px;
    z-index: 99999;
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 12px;
    font-family: var(--font-body), sans-serif;
}

/* ── Список кнопок мессенджеров ── */
.msg-widget__items {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 10px;
    opacity: 0;
    pointer-events: none;
    transform: translateY(12px);
    transition: opacity 0.25s ease, transform 0.25s ease;
}

.msg-widget__items.is-open {
    opacity: 1;
    pointer-events: all;
    transform: translateY(0);
}

/* ── Одна строка: подпись + иконка ── */
.msg-widget__item {
    display: flex;
    align-items: center;
    gap: 10px;
    text-decoration: none;
    cursor: pointer;
}

.msg-widget__label {
    background: #ffffff;
    color: #222;
    font-size: 13px;
    font-weight: 600;
    padding: 7px 14px;
    border-radius: 22px;
    box-shadow: 0 3px 12px rgba(0,0,0,0.18);
    white-space: nowrap;
    line-height: 1.4;
    transition: background 0.2s, color 0.2s, box-shadow 0.2s;
}

.msg-widget__item:hover .msg-widget__label {
    background: #ff5b01;
    color: #fff;
    box-shadow: 0 4px 16px rgba(255,91,1,0.35);
}

/* ── Круглая иконка мессенджера ── */
.msg-widget__icon {
    width: 48px;
    height: 48px;
    min-width: 48px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 3px 12px rgba(0,0,0,0.22);
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.msg-widget__item:hover .msg-widget__icon {
    transform: scale(1.1);
    box-shadow: 0 5px 18px rgba(0,0,0,0.28);
}

.msg-widget__icon svg {
    width: 22px;
    height: 22px;
    fill: #ffffff;
    display: block;
}

.msg-widget__icon--phone    { background: #ff5b01; }
.msg-widget__icon--whatsapp { background: #25d366; }
.msg-widget__icon--telegram { background: #2aabee; }
.msg-widget__icon--max      { background: linear-gradient(135deg, #44ccff 0%, #5533ee 55%, #9933dd 100%); }

/* ── Главная кнопка-триггер ── */
.msg-widget__trigger {
    width: 58px;
    height: 58px;
    border-radius: 50%;
    background: #ff5b01;
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 5px 18px rgba(255,91,1,0.5);
    transition: background 0.2s, transform 0.2s, box-shadow 0.2s;
    outline: none;
    position: relative;
    flex-shrink: 0;
    overflow: hidden; /* чтобы pulse не выходил за кнопку если нужно */
}

.msg-widget__trigger:hover {
    background: #e04e00;
    transform: scale(1.07);
    box-shadow: 0 7px 22px rgba(255,91,1,0.55);
}

/* ── Иконки внутри триггера ── */
/* Обёртки span центрируем через inset: 0 + margin auto */
.msg-widget__trigger .icon-open,
.msg-widget__trigger .icon-close {
    position: absolute;
    top: 0; left: 0; right: 0; bottom: 0;
    margin: auto;
    width: 26px;
    height: 26px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: opacity 0.25s ease, transform 0.25s ease;
}

.msg-widget__trigger svg {
    width: 26px;
    height: 26px;
    fill: #ffffff;
    display: block;
}

/* Дефолт: показываем chat-иконку */
.msg-widget__trigger .icon-open {
    opacity: 1;
    transform: rotate(0deg) scale(1);
}
.msg-widget__trigger .icon-close {
    opacity: 0;
    transform: rotate(-90deg) scale(0.6);
}

/* Открытое состояние: показываем крестик */
.msg-widget.is-open .msg-widget__trigger .icon-open {
    opacity: 0;
    transform: rotate(90deg) scale(0.6);
}
.msg-widget.is-open .msg-widget__trigger .icon-close {
    opacity: 1;
    transform: rotate(0deg) scale(1);
}

/* ── Пульсирующий ореол (только в закрытом состоянии) ── */
.msg-widget__trigger::before {
    content: '';
    position: absolute;
    inset: 0;
    border-radius: 50%;
    background: rgba(255, 91, 1, 0.4);
    animation: widgetPulse 2.4s ease-out infinite;
    pointer-events: none;
}
.msg-widget.is-open .msg-widget__trigger::before {
    animation: none;
    opacity: 0;
}

@keyframes widgetPulse {
    0%   { transform: scale(1);    opacity: 0.75; }
    70%  { transform: scale(1.65); opacity: 0; }
    100% { transform: scale(1.65); opacity: 0; }
}

/* ===== Мобильная адаптация ===== */
@media (max-width: 579px) {
    .msg-widget {
        right: 14px;
        bottom: 14px;
    }
    .msg-widget__trigger {
        width: 52px;
        height: 52px;
    }
    .msg-widget__icon {
        width: 46px;
        height: 46px;
        min-width: 46px;
    }
    .msg-widget__icon svg {
        width: 20px;
        height: 20px;
    }
    .msg-widget__label {
        font-size: 12px;
        padding: 6px 12px;
    }
}
