/* ============================================================
   contact-fab.css — Стили для плавающего виджета контактов
   ============================================================ */

.fab-wrapper {
    position: fixed;
    bottom: 2rem;
    right: 2rem;
    z-index: 1000;
    display: flex;
    flex-direction: column;
    align-items: flex-end;
}

/* --- Всплывающие сообщения (Bubbles) --- */
.fab-bubbles-container {
    position: absolute;
    bottom: calc(100% + 16px);
    right: 0;
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    pointer-events: none;
}

.fab-bubble {
    position: absolute;
    /* Делаем абсолютным, чтобы второе сообщение заменяло первое на том же месте */
    bottom: 0;
    right: 0;
    background: #ffffff;
    color: var(--color-on-surface);
    padding: 1rem 2.5rem 1rem 1.25rem;
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-el-3);
    width: max-content;
    max-width: 280px;
    font-size: var(--text-sm);
    line-height: 1.5;
    pointer-events: auto;

    /* Анимация появления/исчезновения */
    opacity: 0;
    transform: translateY(20px) scale(0.95);
    visibility: hidden;
    transition: all 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275), visibility 0.4s;
    z-index: 10;
}

.fab-bubble.is-visible {
    opacity: 1;
    transform: translateY(0) scale(1);
    visibility: visible;
    z-index: 11;
}

/* Треугольничек (хвостик сообщения), смотрящий вниз-вправо */
.fab-bubble::after {
    content: '';
    position: absolute;
    bottom: -8px;
    right: 20px;
    border-width: 8px 8px 0 0;
    border-style: solid;
    border-color: #ffffff transparent transparent transparent;
}

.fab-bubble-close {
    position: absolute;
    top: 6px;
    right: 6px;
    width: 24px;
    height: 24px;
    border: none;
    background: transparent;
    color: var(--color-neutral);
    font-size: 16px;
    cursor: pointer;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background var(--transition-fast), color var(--transition-fast);
}

.fab-bubble-close:hover {
    background: var(--color-surface-high);
    color: var(--color-error);
}

/* --- Единая карточка меню (Dropup Card) --- */
.fab-menu-card {
    position: absolute;
    bottom: 76px;
    /* Над кнопкой */
    right: 0;
    background: #ffffff;
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-el-4);
    min-width: 220px;
    overflow: hidden;
    pointer-events: none;

    /* Анимация карточки */
    opacity: 0;
    transform: translateY(20px) scale(0.95);
    transform-origin: bottom right;
    transition: opacity 0.3s cubic-bezier(0.4, 0, 0.2, 1), transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.fab-menu-card.is-active {
    opacity: 1;
    transform: translateY(0) scale(1);
    pointer-events: auto;
}

.fab-menu-header {
    padding: 16px 20px 8px;
    font-size: 14px;
    color: var(--color-neutral);
    font-weight: 500;
}

.fab-menu-list {
    display: flex;
    flex-direction: column;
    padding-bottom: 8px;
}

.fab-menu-item {
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 12px 20px;
    text-decoration: none;
    color: var(--color-primary-dark);
    font-size: 16px;
    font-weight: 500;
    transition: background var(--transition-fast);
}

.fab-menu-item:hover {
    background: var(--color-surface-container);
}

.fab-menu-item svg {
    flex-shrink: 0;
}

/* --- Основная кнопка (FAB) --- */
.fab-button {
    width: 60px;
    height: 60px;
    border-radius: 50%;
    background: var(--color-primary-dark);
    border: none;
    color: #ffffff;
    cursor: pointer;
    box-shadow: 0 4px 14px rgba(46, 16, 101, 0.4);
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    z-index: 2;
    transition: transform 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275), box-shadow 0.3s ease, background 0.3s ease;
}

.fab-button:hover {
    transform: scale(1.05);
    box-shadow: 0 6px 20px rgba(46, 16, 101, 0.5);
}

.fab-button:active {
    transform: scale(0.95);
}

.fab-icon-container {
    position: relative;
    width: 28px;
    height: 28px;
}

.fab-icon {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    transition: opacity 0.3s ease, transform 0.3s ease;
}

/* Иконка закрытия (появляется только при открытом меню) */
.fab-icon.icon-close {
    opacity: 0;
    transform: rotate(-90deg) scale(0.5);
}

.fab-wrapper.is-open .fab-icon.icon-close {
    opacity: 1;
    transform: rotate(0) scale(1);
}

/* Меняем фон кнопки на более светлый при открытии */
.fab-wrapper.is-open .fab-button {
    background: var(--color-primary);
    box-shadow: var(--shadow-el-3);
}

/* --- Анимация ротации иконок контактов --- */
/* Если меню открыто, все циклические иконки прячутся */
.fab-wrapper.is-open .cycle-icon {
    animation: none !important;
    opacity: 0 !important;
    transform: scale(0.5) rotate(90deg) !important;
}

.cycle-icon {
    opacity: 0;
    transform: scale(0.5) rotate(-30deg);
    animation: fabCycle 15s infinite ease-in-out;
}

/* 5 иконок по 3 сек. Каждая видима 3 сек (20% времени от 15 сек) */
.icon-chat {
    animation-delay: 0s;
}

.icon-phone {
    animation-delay: 3s;
}

.icon-whatsapp {
    animation-delay: 6s;
}

.icon-telegram {
    animation-delay: 9s;
}

.icon-mail {
    animation-delay: 12s;
}

/* 
  От 0% до 2% — плавное появление.
  От 2% до 18% — иконка статично видима.
  От 18% до 20% — плавное исчезновение. 
*/
@keyframes fabCycle {

    0%,
    20%,
    100% {
        opacity: 0;
        transform: scale(0.5) rotate(-30deg);
    }

    2%,
    18% {
        opacity: 1;
        transform: scale(1) rotate(0deg);
    }

    19.99% {
        opacity: 0;
        transform: scale(0.5) rotate(30deg);
    }
}

/* --- Респонсив (Мобилки) --- */
@media (max-width: 768px) {
    .fab-wrapper {
        bottom: 1.5rem;
        right: 1.5rem;
    }
}

@media (max-width: 480px) {
    .fab-wrapper {
        bottom: 1rem;
        right: 1rem;
    }

    .fab-bubble {
        max-width: 260px;
        padding: 0.875rem 2.25rem 0.875rem 1rem;
        font-size: 13px;
    }
}