/*!
 * QFC "Ask Faisal" avatar chatbot widget — floating launcher + iframe panel.
 * Ported from the live qfc.qa widget. Colours run through widget-scoped vars so
 * light mode matches the live site and dark mode re-themes automatically.
 */

#bbody {
    --chat-accent: #521892;      /* brand purple — launcher/panel/border (matches live) */
    --chat-surface: #ffffff;     /* panel body + speech-bubble background */
    --chat-on-surface: #333333;  /* speech-bubble text */
}

html.dark-mode #bbody {
    --chat-accent: var(--primary);
    --chat-surface: var(--surface-2);
    --chat-on-surface: var(--text);
}

/* ---- Launcher ---- */
/* The GIF is a self-contained branded button; no circle/border wrapper — the
   control hugs the image's natural size. */
#bbody #chatControl {
    position: fixed;
    bottom: 20px;
    right: 20px;
    z-index: 999999;
    cursor: pointer;
    display: inline-block;
    line-height: 0;
}

#bbody #chatControl .chatIcon {
    position: relative;
    display: inline-block;
    transition: transform 0.3s ease;
}

#bbody #chatControl .chatIcon:hover {
    transform: scale(1.05);
}

#bbody #chatControl .chatIcon img {
    display: block;
    width: auto;
    height: auto;
    max-width: 150px;
}

/* ---- Hover speech bubble ("Hi, I'm Faisal…") ---- */
#bbody .chatIcon .talk-bubble {
    display: none;
}

#bbody .chatIcon:hover .talk-bubble,
#bbody .chatIcon:focus .talk-bubble {
    display: inline-block;
    position: absolute;
    bottom: 0;
    width: 340px;
    height: auto;
    background-color: var(--chat-surface);
    box-shadow: rgba(0, 0, 0, 0.1) 0px 0px 12px;
}

html[lang="en"] #bbody .chatIcon:hover .talk-bubble,
html[lang="en"] #bbody .chatIcon:focus .talk-bubble {
    right: calc(100% + 20px);
}

html[lang="ar-QA"] #bbody .chatIcon:hover .talk-bubble,
html[lang="ar-QA"] #bbody .chatIcon:focus .talk-bubble {
    left: calc(100% + 20px);
}

#bbody .tri-right.right-in {
    border-radius: 30px;
}

#bbody .tri-right.right-in::after {
    content: " ";
    position: absolute;
    width: 0;
    height: 0;
    top: 18px;
    border: 12px solid;
}

html[lang="en"] #bbody .tri-right.right-in::after {
    left: auto;
    right: -20px;
    border-color: var(--chat-surface) transparent transparent var(--chat-surface);
}

html[lang="ar-QA"] #bbody .tri-right.right-in::after {
    right: auto;
    left: -20px;
    border-color: var(--chat-surface) var(--chat-surface) transparent transparent;
}

#bbody .talktext {
    padding: 20px 15px;
    text-align: start;
    font-size: 0.8rem;
    color: var(--chat-on-surface);
}

#bbody .talktext p {
    margin-block: 0;
}

/* ---- Chat panel ---- */
#bbody #chatArea {
    position: fixed;
    bottom: 20px;
    right: 100px;
    z-index: 99999999;
    width: 570px;
    border: 0;
    border-radius: 12px;
    box-shadow: rgba(0, 0, 0, 0.3) 0px 4px 12px;
    overflow: hidden;
    visibility: hidden;
}

#bbody #chatArea.ActiveBot {
    visibility: visible;
}

#bbody #chatArea .bodyChatArea {
    height: 840px;
    max-height: 80vh;
    background: var(--chat-surface);
    border-radius: 12px;
    overflow: hidden;
}

#bbody #myIframe {
    width: 100%;
    height: 100%;
    border: 0;
    opacity: 1;
}

/* ---- Close button (mobile only; desktop closes via click-outside) ---- */
#bbody .chatbot-close {
    display: none;
    position: absolute;
    top: 10px;
    width: 34px;
    height: 34px;
    align-items: center;
    justify-content: center;
    padding: 0;
    border: 0;
    border-radius: 50%;
    background: var(--chat-accent);
    color: #ffffff;
    cursor: pointer;
    z-index: 2;
}

html[lang="en"] #bbody .chatbot-close { right: 10px; }
html[lang="ar-QA"] #bbody .chatbot-close { left: 10px; }

/* ---- Mobile: full-width bottom sheet ---- */
@media (max-width: 767px) {
    #bbody #chatArea {
        left: 0;
        right: 0;
        bottom: 0;
        width: 100%;
        border-radius: 16px 16px 0 0;
    }

    #bbody #chatArea .bodyChatArea {
        height: 85vh;
        max-height: none;
        border-radius: 16px 16px 0 0;
    }

    #bbody .chatbot-close {
        display: inline-flex;
    }

    #bbody #chatControl {
        bottom: 16px;
        right: 16px;
    }

    #bbody .chatIcon:hover .talk-bubble,
    #bbody .chatIcon:focus .talk-bubble {
        display: none;
    }
}

/* Hide when printing */
@media print {
    #bbody { display: none; }
}
