/**
 * Call Widget Styles
 * Стили для виджета связи
 */

.call-widget-container {
    position: fixed;
    z-index: 10003;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    /* Убеждаемся, что контейнер не создает изолированный stacking context для меню */
    isolation: auto;
}

/* Контейнер с открытым меню должен быть выше overlay, но меню все равно будет выше через fixed позиционирование */
.call-widget-container.menu-open {
    z-index: 10005;
}

/* Обертка для кнопки с эффектом стекла */
.call-widget-trigger-wrapper {
    position: relative;
    border-radius: 50% !important;
    overflow: visible !important; /* Изменено с hidden на visible, чтобы меню было видно */
    cursor: pointer;
    z-index: 10003 !important; /* По умолчанию на уровне контейнера */
    /* Оранжевый фон с эффектом стекла */
    background: hsl(20 100% 55% / 0.15) !important;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Когда меню открыто, кнопка должна быть позади overlay */
.call-widget-container.menu-open .call-widget-trigger-wrapper {
    z-index: 10003 !important; /* Ниже overlay (10004) */
}

/* Кнопка внутри обертки должна иметь overflow: hidden для круглой формы */
.call-widget-trigger-wrapper .call-widget-trigger {
    overflow: hidden;
}

/* Оранжевый фон для эффекта стекла */
.call-widget-trigger-wrapper.glass-surface--svg {
    background: rgba(235, 88, 15, 0.521) !important;
}

.call-widget-trigger-wrapper.glass-surface--fallback {
    background: rgba(235, 88, 15, 0.521) !important;
}

/* Исправление внутренних теней для круглой кнопки */
.call-widget-trigger-wrapper.glass-surface {
    /* Внутренние тени: светлее сверху слева, темнее снизу справа */
    box-shadow: 
        /* Внешние тени - только светлые свечения сверху */
        0 -6px 24px rgba(255, 255, 255, 0.25),
        0 -3px 12px rgba(255, 255, 255, 0.4),
        0 -2px 8px rgba(255, 255, 255, 0.1),
        0 3px 12px rgba(0, 0, 0, 0.06),
        0 6px 24px rgba(0, 0, 0, 0.09),
        0 9px 30px rgba(0, 0, 0, 0.11),
        /* Внутренние тени: светлее сверху слева, темнее снизу справа */
        inset -2px -2px 8px rgba(255, 255, 255, 0.2),
        inset -1px -1px 4px rgba(255, 255, 255, 0.3),
        inset 2px 2px 8px rgba(0, 0, 0, 0.15),
        inset 1px 1px 4px rgba(0, 0, 0, 0.1),
        /* Белый смазанный бордер по краям */
        inset 0 0 0 4px rgba(255, 255, 255, 0.4),
        inset 0 0 8px rgba(255, 255, 255, 0.2),
        inset 0 0 12px rgba(255, 255, 255, 0.15) !important;
}

.call-widget-trigger-wrapper:hover {
    transform: scale(1.1);
}

.call-widget-trigger-wrapper:active {
    transform: scale(0.95);
}

/* Кнопка триггера - максимальная специфичность для перекрытия глобальных стилей */
.call-widget-container .call-widget-trigger-wrapper .call-widget-trigger,
.call-widget-trigger-wrapper .call-widget-trigger,
#call-widget-container .call-widget-trigger-wrapper button.call-widget-trigger,
button.call-widget-trigger {
    position: relative !important;
    border: none !important;
    border-radius: 50% !important;
    background: #ff6d01b3 !important;
    color: white !important;
    cursor: pointer !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    padding: 0 !important;
    margin: 0 !important;
    width: 100% !important;
    height: 100% !important;
    z-index: 1 !important;
    box-shadow: none !important;
    outline: none !important;
    font-size: inherit !important;
    line-height: inherit !important;
    text-decoration: none !important;
    /* Перекрываем все возможные глобальные стили для кнопок */
    appearance: none !important;
    -webkit-appearance: none !important;
    -moz-appearance: none !important;
    text-transform: none !important;
    letter-spacing: normal !important;
    font-weight: normal !important;
}

.call-widget-trigger-wrapper .call-widget-trigger svg,
.call-widget-container .call-widget-trigger-wrapper .call-widget-trigger svg {
    width: 60% !important;
    height: 60% !important;
    filter: drop-shadow(0 1px 2px rgba(0, 0, 0, 0.3));
    flex-shrink: 0;
}

/* Позиционирование контейнера */
.call-widget-container[data-position="bottom-right"] {
    bottom: 0;
    right: 0;
}

.call-widget-container[data-position="bottom-left"] {
    bottom: 0;
    left: 0;
}

.call-widget-container[data-position="top-right"] {
    top: 0;
    right: 0;
}

.call-widget-container[data-position="top-left"] {
    top: 0;
    left: 0;
}

/* Позиционирование кнопки внутри контейнера */
.call-widget-container[data-position="bottom-right"] .call-widget-trigger-wrapper {
    position: absolute;
    bottom: var(--offset-y, 20px);
    right: var(--offset-x, 20px);
}

.call-widget-container[data-position="bottom-left"] .call-widget-trigger-wrapper {
    position: absolute;
    bottom: var(--offset-y, 20px);
    left: var(--offset-x, 20px);
}

.call-widget-container[data-position="top-right"] .call-widget-trigger-wrapper {
    position: absolute;
    top: var(--offset-y, 20px);
    right: var(--offset-x, 20px);
}

.call-widget-container[data-position="top-left"] .call-widget-trigger-wrapper {
    position: absolute;
    top: var(--offset-y, 20px);
    left: var(--offset-x, 20px);
}

/* Меню каналов связи - позиционируется относительно кнопки */
.call-widget-menu {
    position: fixed !important; /* Изменено с absolute на fixed для правильного позиционирования */
    display: none; /* Скрыто по умолчанию */
    flex-direction: column;
    gap: 12px;
    z-index: 10010 !important; /* Выше overlay (10004) и всех элементов */
    align-items: center;
    pointer-events: auto !important;
    visibility: hidden;
    opacity: 0;
    /* Убеждаемся, что меню создает новый stacking context */
    isolation: isolate;
    /* Меню должно быть выше всего */
    transform: translateZ(0); /* Создает новый stacking context */
}

/* Меню видимо только когда открыто */
.call-widget-container.menu-open .call-widget-menu,
.call-widget-menu[style*="display: flex"],
.call-widget-menu[style*="display:flex"] {
    display: flex !important;
    visibility: visible !important;
    opacity: 1 !important;
    animation: slideInMenu 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    z-index: 10010 !important; /* Должно совпадать с базовым z-index меню и быть выше overlay */
    position: fixed !important; /* Переопределяем на fixed когда открыто */
    transform: translateZ(0); /* Создает новый stacking context */
}

/* Меню позиционируется относительно кнопки (trigger-wrapper) - используется только для начального позиционирования */
.call-widget-trigger-wrapper .call-widget-menu {
    /* Позиционирование теперь устанавливается через JavaScript inline стили */
    pointer-events: auto !important;
}

/* Позиционирование меню теперь устанавливается через JavaScript inline стили */
/* Эти стили используются только для выравнивания элементов внутри меню */
.call-widget-container[data-position="bottom-right"] .call-widget-trigger-wrapper .call-widget-menu,
.call-widget-container[data-position="top-right"] .call-widget-trigger-wrapper .call-widget-menu {
    align-items: flex-end;
}

.call-widget-container[data-position="bottom-left"] .call-widget-trigger-wrapper .call-widget-menu,
.call-widget-container[data-position="top-left"] .call-widget-trigger-wrapper .call-widget-menu {
    align-items: flex-start;
}

@keyframes slideInMenu {
    from {
        opacity: 0;
        transform: translateY(10px) scale(0.9);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

/* Элементы меню - только иконки */
.call-widget-item {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0;
    padding: 12px;
    background: white;
    border-radius: 50%;
    text-decoration: none;
    color: #333;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15);
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    width: 48px;
    height: 48px;
    min-width: 48px;
    font-weight: 500;
    font-size: 14px;
    position: relative;
    z-index: 10007 !important; /* Выше меню и overlay */
}

.call-widget-item:hover {
    transform: translateX(-4px);
    box-shadow: 0 6px 25px rgba(0, 0, 0, 0.2);
    color: #333;
}

.call-widget-item svg {
    flex-shrink: 0;
    width: 24px;
    height: 24px;
}

.call-widget-item img {
    width: 100% !important;
    height: 100% !important;
    flex-shrink: 0;
    object-fit: cover;
    display: block;
    border-radius: 50%;
}

.call-widget-item span {
    display: none; /* Скрываем текст, оставляем только иконки */
}

.call-widget-telegram {
    background: transparent !important;
    color: white;
    padding: 0 !important;
}

.call-widget-telegram:hover {
    color: white;
    background: transparent !important;
}

.call-widget-phone {
    background: linear-gradient(135deg, #ff5314 0%, #ff6b35 100%);
    color: white;
}

.call-widget-phone:hover {
    color: white;
    background: linear-gradient(135deg, #e6490f 0%, #ff5a2a 100%);
}

/* Кнопка закрытия */
.call-widget-close,
:is(.btn,.button,button,[type=submit],[type=button]).call-widget-close,
.call-widget-menu .call-widget-close {
    width: 48px !important;
    height: 48px !important;
    min-width: 48px !important;
    min-height: 48px !important;
    max-width: 48px !important;
    max-height: 48px !important;
    border: none !important;
    border-radius: 50% !important;
    background: rgba(255, 255, 255, 0.95) !important;
    color: #666 !important;
    cursor: pointer !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15) !important;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1) !important;
    align-self: center !important;
    position: relative !important;
    z-index: 10007 !important;
    padding: 0 !important;
    margin: 0 !important;
    font-size: inherit !important;
    line-height: 1 !important;
    text-align: center !important;
    text-decoration: none !important;
    appearance: none !important;
    -webkit-appearance: none !important;
    -moz-appearance: none !important;
    text-transform: none !important;
    letter-spacing: normal !important;
    font-weight: normal !important;
    box-sizing: border-box !important;
}

.call-widget-close:hover,
:is(.btn,.button,button,[type=submit],[type=button]).call-widget-close:hover {
    background: #f5f5f5 !important;
    transform: rotate(90deg) !important;
    width: 48px !important;
    height: 48px !important;
}

.call-widget-close svg {
    width: 28px !important;
    height: 28px !important;
}

/* Затемнение фона */
.call-widget-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
    z-index: 10004 !important; /* Ниже меню (10009), но выше контейнера (10003) */
    animation: fadeIn 0.3s ease-out;
    pointer-events: auto;
    /* Убеждаемся, что overlay не создает новый stacking context, который бы изолировал меню */
    isolation: auto;
    /* Overlay должен быть ниже меню */
    will-change: opacity;
}

@keyframes fadeIn {
    from {
        opacity: 0;
    }
    to {
        opacity: 1;
    }
}

/* Анимация волны для круга */
@keyframes wavePulse {
    0% {
        transform: scale(1);
        opacity: 1;
    }
    50% {
        transform: scale(1.15);
        opacity: 0.7;
    }
    100% {
        transform: scale(1.3);
        opacity: 0;
    }
}

/* Анимация shake для иконки */
@keyframes iconShake {
    0%, 100% {
        transform: translate(0, 0) rotate(0deg);
    }
    5%, 15%, 25%, 35%, 45% {
        transform: translate(-2px, -1px) rotate(-2deg);
    }
    10%, 20%, 30%, 40% {
        transform: translate(2px, 1px) rotate(2deg);
    }
}

/* Волновые круги вокруг кнопки */
.call-widget-trigger-wrapper.widget-animated::before,
.call-widget-trigger-wrapper.widget-animated::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    border-radius: 70%;
    border: 2px solid rgba(236, 73, 9, 0.418);
    transform-origin: center center;
    pointer-events: none;
    z-index: -1;
    box-sizing: border-box;
    /* Убеждаемся, что волны точно в позиции кнопки */
    margin: 0;
    padding: 0;
}

.call-widget-trigger-wrapper.widget-animated::before {
    animation: wavePulse 2s ease-out infinite;
}

.call-widget-trigger-wrapper.widget-animated::after {
    animation: wavePulse 2s ease-out 1s infinite;
}

/* Пауза между повторениями shake анимации */
@keyframes iconShakeWithPause {
    0%, 25% {
        transform: translate(0, 0) rotate(0deg);
    }
    26%, 30% {
        transform: translate(-2px, -1px) rotate(-2deg);
    }
    31%, 35% {
        transform: translate(2px, 1px) rotate(2deg);
    }
    36%, 40% {
        transform: translate(-2px, -1px) rotate(-2deg);
    }
    41%, 45% {
        transform: translate(2px, 1px) rotate(2deg);
    }
    46%, 50% {
        transform: translate(-1px, 0) rotate(-1deg);
    }
    51%, 100% {
        transform: translate(0, 0) rotate(0deg);
    }
}

/* Shake анимация для иконки с паузами */
.call-widget-trigger svg.icon-shake {
    animation: iconShakeWithPause 1s ease-in-out infinite;
    animation-delay: 3s;
}

/* Адаптация для мобильных */
.call-widget-container.mobile .call-widget-item {
    min-width: 160px;
    padding: 10px 16px;
    font-size: 13px;
}

.call-widget-container.mobile .call-widget-close {
    width: 44px !important;
    height: 44px !important;
    min-width: 44px !important;
    min-height: 44px !important;
    max-width: 44px !important;
    max-height: 44px !important;
}

/* Кнопка только Telegram (вне рабочего времени) */
.call-widget-telegram-only {
    position: fixed;
    width: var(--widget-size, 56px);
    height: var(--widget-size, 56px);
    border-radius: 50%;
    display: none;
    align-items: center;
    justify-content: center;
    text-decoration: none;
    z-index: 10003;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    background: linear-gradient(135deg, #0088cc 0%, #229ED9 100%);
}

.call-widget-telegram-only:hover {
    transform: scale(1.1);
    box-shadow: 0 6px 25px rgba(0, 0, 0, 0.2);
}

.call-widget-telegram-only img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    border-radius: 50%;
}

/* Позиционирование кнопки только Telegram */
.call-widget-container[data-position="bottom-right"] .call-widget-telegram-only {
    bottom: var(--offset-y, 20px);
    right: var(--offset-x, 20px);
}

.call-widget-container[data-position="bottom-left"] .call-widget-telegram-only {
    bottom: var(--offset-y, 20px);
    left: var(--offset-x, 20px);
}

.call-widget-container[data-position="top-right"] .call-widget-telegram-only {
    top: var(--offset-y, 20px);
    right: var(--offset-x, 20px);
}

.call-widget-container[data-position="top-left"] .call-widget-telegram-only {
    top: var(--offset-y, 20px);
    left: var(--offset-x, 20px);
}

