/* Live chat bubble and widget container */
.chat-bubble-wrap {
    position: fixed;
    z-index: 9999;
}
.chat-bubble-wrap.chat-bubble-bottom-right {
    bottom: 24px;
    right: 24px;
}
.chat-bubble-wrap.chat-bubble-bottom-left {
    bottom: 24px;
    left: 24px;
}

.chat-bubble-btn {
    width: 54px;
    height: 54px;
    border-radius: 50%;
    border: none;
    background: var(--bubble-bg, #6366f1);
    color: var(--bubble-icon, #ffffff);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 14px rgba(0, 0, 0, 0.12), 0 2px 6px rgba(0, 0, 0, 0.06);
    transition: transform 0.2s ease, box-shadow 0.2s ease, filter 0.2s ease;
}
.chat-bubble-btn:hover {
    transform: translateY(-2px) scale(1.02);
    box-shadow: 0 6px 18px rgba(0, 0, 0, 0.14), 0 3px 8px rgba(0, 0, 0, 0.08);
    filter: brightness(0.97);
}
.chat-bubble-btn:active {
    transform: translateY(0) scale(1);
}
.chat-bubble-btn:focus-visible {
    outline: 2px solid var(--bubble-bg, #6366f1);
    outline-offset: 2px;
}

.chat-bubble-icon {
    pointer-events: none;
}

/* Bubble icon animation when widget is open (tail points up); only when enabled */
.chat-bubble-wrap--animate .chat-bubble-icon {
    transition: transform 0.28s ease;
}
.chat-bubble-wrap--animate .chat-bubble-btn.is-open .chat-bubble-icon {
    transform: rotate(180deg);
}
.chat-bubble-wrap--animate .chat-bubble-btn.is-open .chat-bubble-icon img {
    transform: rotate(180deg);
}

.chat-widget-container {
    position: absolute;
    bottom: 62px;
    width: 400px;
    max-width: calc(100vw - 32px);
    height: 704px;
    max-height: calc(100vh - 72px);
    background: #fff;
    border-radius: 20px;
    box-shadow: 0 12px 40px rgba(0, 0, 0, 0.1), 0 2px 12px rgba(0, 0, 0, 0.06);
    overflow: hidden;
    display: flex;
    flex-direction: column;
    opacity: 1;
    transform: translateY(0) scale(1);
    transform-origin: bottom right;
    will-change: opacity, transform;
    transition: opacity 160ms cubic-bezier(0.2, 0.8, 0.2, 1), transform 160ms cubic-bezier(0.2, 0.8, 0.2, 1);
}

/* LiveChat-style theme: 345x605 desktop, 100% responsive on small screens */
.chat-widget-container[data-widget-theme="livechat"] {
    width: 345px;
    height: 605px;
    max-height: calc(100vh - 72px);
}
@media (max-width: 480px) {
    .chat-widget-container[data-widget-theme="livechat"] {
        position: fixed;
        left: 0;
        right: 0;
        bottom: 62px;
        width: 100%;
        max-width: none;
        height: calc(100vh - 62px);
        max-height: calc(100vh - 62px);
        border-radius: 18px 18px 0 0;
    }
    .chat-bubble-bottom-right .chat-widget-container[data-widget-theme="livechat"],
    .chat-bubble-bottom-left .chat-widget-container[data-widget-theme="livechat"] {
        left: 0;
        right: 0;
    }
}

.chat-bubble-bottom-left .chat-widget-container {
    transform-origin: bottom left;
}
.chat-widget-container.is-opening {
    opacity: 0;
    transform: translateY(12px) scale(0.98);
}
.chat-widget-container.is-closing {
    opacity: 0;
    transform: translateY(10px) scale(0.985);
    transition: opacity 140ms cubic-bezier(0.4, 0, 0.2, 1), transform 140ms cubic-bezier(0.4, 0, 0.2, 1);
}
@media (max-width: 420px) {
    .chat-widget-container {
        position: fixed;
        left: 0;
        right: 0;
        bottom: 62px;
        width: 100%;
        max-width: none;
        border-radius: 18px 18px 0 0;
    }
    .chat-bubble-bottom-right .chat-widget-container,
    .chat-bubble-bottom-left .chat-widget-container {
        left: 0;
        right: 0;
    }
}
.chat-bubble-bottom-right .chat-widget-container {
    right: 0;
}
.chat-bubble-bottom-left .chat-widget-container {
    left: 0;
}

.chat-widget-container[hidden] {
    display: none !important;
}

/* Campaign teaser: floating stack above the bubble, panel stays closed */
.chat-widget-container.is-campaign-teaser {
    background: transparent !important;
    box-shadow: none !important;
    border-radius: 0 !important;
    overflow: visible !important;
    height: auto;
    max-width: calc(100vw - 16px);
    margin-bottom: max(0px, env(safe-area-inset-bottom));
}
.chat-widget-container.is-campaign-teaser-bar {
    max-width: min(calc(100vw - 16px), 480px);
}
.chat-widget-container.is-campaign-teaser iframe {
    background: transparent;
}
.chat-widget-container.is-campaign-teaser-opening {
    animation: livechat-campaign-teaser-in 0.34s cubic-bezier(0.22, 1, 0.36, 1) both;
}
@keyframes livechat-campaign-teaser-in {
    from { opacity: 0; transform: translateY(12px); }
    to { opacity: 1; transform: translateY(0); }
}
@media (max-width: 480px) {
    .chat-bubble-bottom-right .chat-widget-container.is-campaign-teaser,
    .chat-bubble-bottom-left .chat-widget-container.is-campaign-teaser {
        right: max(0px, env(safe-area-inset-right));
        left: max(0px, env(safe-area-inset-left));
    }
}

.chat-widget-container iframe {
    flex: 1;
    width: 100%;
    height: 100%;
    border: none;
}
@media (prefers-reduced-motion: reduce) {
    .chat-widget-container {
        transition: none !important;
        transform: none !important;
        opacity: 1 !important;
    }
    .chat-widget-container.is-campaign-teaser-opening {
        animation: none !important;
    }
}
