/* ============================================================
   OA FAQ Chat Bubble — floating widget styles
   Chat panel internals (.oa-chatbot-*, .oa-faq-*) are handled
   by faq-assistant.css — this file covers the button + panel
   positioning, open/close animation, and bubble-specific chrome.
   ============================================================ */

/* ── DOM anchor (zero-size, stays in normal flow) ─────────── */

.oa-faq-bubble-wrap {
    position: static !important;
    display: block;
    width: 0;
    height: 0;
    overflow: visible;
}

/* ── Floating trigger button ─────────────────────────────── */

.oa-faq-bubble-btn {
    position: fixed;
    bottom: var(--oa-bubble-bottom, 24px);
    right:  var(--oa-bubble-side,   24px);
    z-index: 9999;

    display:     inline-flex;
    align-items: center;
    gap:         10px;

    padding:       0 20px 0 16px;
    height:        56px;
    min-width:     56px;
    border-radius: 999px;
    border:        none;
    cursor:        pointer;

    background: #1a1a2e;
    color:      #fff;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.22);

    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto,
                 'Helvetica Neue', Arial, sans-serif;
    font-size:   15px;
    font-weight: 600;
    line-height: 1;
    white-space: nowrap;

    transition: transform 0.2s ease, box-shadow 0.2s ease, background 0.2s ease;
}

/* No label: icon-only pill */
.oa-faq-bubble-btn.btn-icon-only {
    padding:    0;
    width:      56px;
    border-radius: 50%;
    justify-content: center;
}

.oa-faq-bubble-btn:hover {
    transform:  translateY(-2px);
    box-shadow: 0 8px 28px rgba(0, 0, 0, 0.28);
}

.oa-faq-bubble-btn:active {
    transform: translateY(0);
}

/* Left-position variant */
.oa-bubble-pos-left .oa-faq-bubble-btn {
    right: auto;
    left:  var(--oa-bubble-side, 24px);
}

/* Icons */
.oa-faq-bubble-icon-chat,
.oa-faq-bubble-icon-close {
    display:     inline-flex;
    align-items: center;
    flex-shrink: 0;
    transition:  opacity 0.2s, transform 0.2s;
}

.oa-faq-bubble-icon-close {
    position: absolute;
    opacity:  0;
    transform: rotate(-90deg) scale(0.7);
}

.oa-faq-bubble-btn.is-open .oa-faq-bubble-icon-chat {
    opacity:   0;
    transform: rotate(90deg) scale(0.7);
}

.oa-faq-bubble-btn.is-open .oa-faq-bubble-icon-close {
    opacity:   1;
    transform: rotate(0deg) scale(1);
}

.oa-faq-bubble-icon-chat svg,
.oa-faq-bubble-icon-close svg {
    width:  22px;
    height: 22px;
    display: block;
}

/* Label */
.oa-faq-bubble-label {
    pointer-events: none;
    transition: opacity 0.15s;
}

.oa-faq-bubble-btn.is-open .oa-faq-bubble-label {
    opacity: 0;
    width:   0;
    overflow: hidden;
    padding: 0;
}

/* Pulse ring — draws attention on first load */
@keyframes oa-bubble-pulse {
    0%   { box-shadow: 0 0 0 0   rgba(26, 26, 46, 0.5); }
    70%  { box-shadow: 0 0 0 14px rgba(26, 26, 46, 0); }
    100% { box-shadow: 0 0 0 0   rgba(26, 26, 46, 0); }
}

.oa-faq-bubble-btn:not(.is-open) {
    animation: oa-bubble-pulse 2.2s ease-out 1.5s 2;
}

/* ── Floating panel ──────────────────────────────────────── */

.oa-faq-bubble-panel {
    position: fixed;
    bottom:   calc(var(--oa-bubble-bottom, 24px) + 56px + 12px);
    right:    var(--oa-bubble-side, 24px);
    z-index:  9998;

    width:      var(--oa-bubble-width, 380px);
    /* Cap height so the panel never runs off the top of the viewport */
    max-height: calc(100vh - var(--oa-bubble-bottom, 24px) - 56px - 48px);

    border-radius: 14px;
    overflow:      hidden;
    box-shadow:    0 8px 40px rgba(0, 0, 0, 0.18);

    display:        flex;
    flex-direction: column;

    /* Hidden state */
    opacity:         0;
    pointer-events:  none;
    transform:       translateY(16px) scale(0.96);
    transform-origin: bottom right;
    transition:      opacity 0.22s ease, transform 0.22s ease;
}

/* Messages area inside the bubble — flex: 1 + min-height: 0 lets it
   shrink to fill remaining panel height and scroll when content overflows */
.oa-faq-bubble-messages {
    flex:       1;
    min-height: 80px;  /* always show at least a couple of messages */
    overflow-y: auto;
    scroll-behavior: smooth;
}

.oa-faq-bubble-panel.is-open {
    opacity:        1;
    pointer-events: auto;
    transform:      translateY(0) scale(1);
}

/* Left-position variant */
.oa-bubble-pos-left .oa-faq-bubble-panel {
    right:          auto;
    left:           var(--oa-bubble-side, 24px);
    transform-origin: bottom left;
}

/* ── Panel header (extends .oa-chatbot-header) ───────────── */

.oa-faq-bubble-header {
    display:         flex;
    align-items:     center;
    justify-content: space-between;
    padding:         14px 16px;
    background:      #1a1a2e;
    color:           #fff;
    flex-shrink:     0;
}

.oa-faq-bubble-close {
    width:         28px;
    height:        28px;
    border-radius: 50%;
    border:        none;
    background:    rgba(255, 255, 255, 0.15);
    color:         #fff;
    cursor:        pointer;
    display:       inline-flex;
    align-items:   center;
    justify-content: center;
    font-size:     18px;
    line-height:   1;
    flex-shrink:   0;
    transition:    background 0.15s;
    padding:       0;
}

.oa-faq-bubble-close:hover {
    background: rgba(255, 255, 255, 0.28);
}

/* ── Mobile: full-screen panel ───────────────────────────── */

@media (max-width: 480px) {
    .oa-faq-bubble-panel {
        position:      fixed;
        inset:         0;
        width:         100%;
        height:        100%;
        max-height:    100%;   /* override desktop max-height */
        border-radius: 0;
        bottom:        0;
        right:         0;
        left:          0;
        top:           0;
        transform-origin: bottom center;
    }

    .oa-faq-bubble-btn {
        bottom: var(--oa-bubble-bottom, 16px);
        right:  var(--oa-bubble-side,   16px);
    }

    .oa-bubble-pos-left .oa-faq-bubble-btn {
        left:  var(--oa-bubble-side, 16px);
        right: auto;
    }
}
