/* AI consultant launcher and panel on the site pages (BTX-22443). Plain CSS on purpose:
   Bootstrap's unlayered `button` rules override Tailwind's layered utilities. */

#ai-chat-launcher {
    position: fixed;
    right: 20px;
    bottom: var(--ai-chat-bottom, 72px);
    /* Above the cookie banner (1035) only when it is lifted over it; below modal backdrops (1040). */
    z-index: 1034;
    display: inline-flex;
    align-items: center;
    gap: 10px;
    padding: 12px 22px 12px 16px;
    border: 0;
    border-radius: 999px;
    background: var(--primary, #3aafa9);
    color: #fff;
    font: 600 15px/1.2 "Open Sans", sans-serif;
    letter-spacing: 0.01em;
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.18);
    cursor: pointer;
    transition: transform 0.35s cubic-bezier(0.34, 1.56, 0.64, 1), opacity 0.2s ease, box-shadow 0.15s ease, background-color 0.15s ease;
}

/* The button gives way to the chat growing out of it, and pops back when the chat closes. */
#ai-chat-launcher.is-away {
    transform: scale(0.4);
    opacity: 0;
    pointer-events: none;
}

#ai-chat-launcher:hover {
    background: var(--primary-hover, #2d9d98);
    transform: translateY(-1px);
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.22);
}

#ai-chat-launcher:focus-visible {
    outline: 3px solid rgba(58, 175, 169, 0.45);
    outline-offset: 2px;
}

#ai-chat-launcher svg {
    flex: none;
    width: 22px;
    height: 22px;
}

#ai-chat-launcher[hidden],
#ai-chat-panel[hidden] {
    display: none;
}

#ai-chat-panel {
    position: fixed;
    inset: 0;
    /* Over the cookie banner (1035), under modal backdrops (1040). */
    z-index: 1038;
    overflow: hidden;
    background: #fff;
    /* The chat grows out of the launcher as a bubble and shrinks back into it. The open clip reaches
       past the box, so it never cuts the shadow. */
    --ai-chat-bubble: inset(calc(100% - var(--ai-chat-bottom, 72px) - 50px) 20px var(--ai-chat-bottom, 72px) calc(100% - 70px) round 25px);
    clip-path: inset(-60px round 0);
    transition:
        clip-path 0.5s cubic-bezier(0.22, 1, 0.36, 1),
        transform 0.5s cubic-bezier(0.34, 1.3, 0.64, 1),
        opacity 0.2s ease;
}

#ai-chat-panel:not(.is-open) {
    clip-path: var(--ai-chat-bubble);
    transform: scale(0.92);
    opacity: 0;
    pointer-events: none;
    transition:
        clip-path 0.3s cubic-bezier(0.55, 0, 1, 0.45),
        transform 0.3s cubic-bezier(0.55, 0, 1, 0.45),
        opacity 0.2s ease 0.1s;
}

#ai-chat-panel iframe {
    display: block;
    width: 100%;
    height: 100%;
    border: 0;
}

.ai-chat-resize {
    display: none;
}

@media (min-width: 576px) {
    #ai-chat-panel {
        inset: auto 20px var(--ai-chat-bottom, 72px) auto;
        width: var(--ai-chat-width, 380px);
        height: min(var(--ai-chat-height, 600px), calc(100vh - var(--ai-chat-bottom, 72px) - 24px));
        border-radius: 16px;
        box-shadow: 0 12px 40px rgba(0, 0, 0, 0.25);
        transform-origin: bottom right;
        --ai-chat-bubble: inset(calc(100% - 48px) 0 0 calc(100% - 48px) round 24px);
        clip-path: inset(-60px round 16px);
        transition:
            clip-path 0.5s cubic-bezier(0.22, 1, 0.36, 1),
            transform 0.5s cubic-bezier(0.34, 1.3, 0.64, 1),
            opacity 0.2s ease,
            width 0.45s cubic-bezier(0.22, 1, 0.36, 1),
            height 0.45s cubic-bezier(0.22, 1, 0.36, 1);
    }

    /* Dragging the corner follows the pointer at once. */
    #ai-chat-panel.is-resizing {
        transition: none;
    }

    /* Top-left corner: the panel is anchored bottom-right, so it grows up and to the left. */
    .ai-chat-resize {
        position: absolute;
        top: 0;
        left: 0;
        z-index: 1;
        display: block;
        width: 18px;
        height: 18px;
        cursor: nwse-resize;
        touch-action: none;
        background: linear-gradient(135deg, rgba(255, 255, 255, 0.85) 0 2px, transparent 2px 5px, rgba(255, 255, 255, 0.6) 5px 7px, transparent 7px);
        border-top-left-radius: 16px;
        opacity: 0.7;
    }

    .ai-chat-resize:hover {
        opacity: 1;
    }

    #ai-chat-panel.is-resizing iframe {
        pointer-events: none;
    }
}

@media (prefers-reduced-motion: reduce) {
    #ai-chat-launcher,
    #ai-chat-panel,
    #ai-chat-panel:not(.is-open) {
        transition: none;
    }
}

@media (max-width: 575px) {
    #ai-chat-launcher {
        padding: 14px;
    }

    #ai-chat-launcher .ai-chat-launcher__label {
        display: none;
    }
}
