/*
 * BPBytes AI assistant widget.
 * Styling for custom/themes/BPBytes/js/customChatbot.js's panel — kept entirely in CSS (using the
 * theme's own color tokens) rather than the widget's original inline JS styles, so it re-colors
 * automatically whenever variables.css changes. Uses the sidebar's own background token (flat,
 * no gradient) so it stays visually tied to the sidebar's color.
 *
 * The trigger itself is a normal topbar icon button (custom/themes/BPBytes/tpls/
 * _headerModuleList.tpl, id="chatbotButton") styled by the shared .bpbytes-icon-btn rule in
 * topbar.css — only its "panel is open" active state is styled here, via body.bpbytes-chatbot-
 * is-open (see customChatbot.js's setOpen()).
 */

body.bpbytes-chatbot-is-open #chatbotButton {
    background: var(--bp-primary-soft);
    color: var(--bp-primary);
}

/* Full-height slide-in panel docked to the right edge, opening below the topbar — a "side panel"
   rather than the small floating box this used to be, matching a modern AI-assistant pattern
   (Notion AI / Copilot Chat-style) and giving far more room for a real conversation. No dimming
   overlay behind it on purpose: the whole point is to keep referencing the record/list you were
   just looking at while asking about it. */
.bpbytes-chatbot-panel {
    position: fixed;
    top: var(--bp-topbar-height);
    right: 0;
    bottom: 0;
    width: 420px;
    max-width: 92vw;
    background: var(--bp-surface);
    border-left: 1px solid var(--bp-border);
    box-shadow: -12px 0 32px rgba(30, 27, 75, 0.16);
    /* Not displayed at all while closed: a panel parked off to the right (translated out of view) still made the
       page scroll sideways on a phone and stretched the top bar past the screen. */
    display: none;
    flex-direction: column;
    overflow: hidden;
    font-family: var(--bp-font);
    font-size: 14px;
    z-index: 10000;
}

.bpbytes-chatbot-panel.is-open {
    display: flex;
    animation: bpbytes-chatbot-in 0.25s ease;
}

@keyframes bpbytes-chatbot-in {
    from {
        transform: translateX(100%);
    }
    to {
        transform: translateX(0);
    }
}

.bpbytes-chatbot-header {
    background: var(--bp-title);
    color: #fff;
    padding: 16px 18px;
    font-weight: 700;
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex: 0 0 auto;
}

.bpbytes-chatbot-close {
    background: transparent;
    border: none;
    color: #fff;
    opacity: 0.75;
    font-size: 22px;
    line-height: 1;
    cursor: pointer;
    padding: 0;
}

.bpbytes-chatbot-close:hover {
    opacity: 1;
}

.bpbytes-chatbot-messages {
    flex: 1 1 auto;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    background: var(--bp-surface-alt);
}

.bpbytes-chatbot-inputarea {
    flex: 0 0 auto;
    padding: 12px;
    background: var(--bp-surface);
    border-top: 1px solid var(--bp-border);
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.bpbytes-chatbot-textarea {
    width: 100%;
    padding: 10px;
    border: 1px solid var(--bp-border-strong);
    border-radius: var(--bp-radius-sm);
    outline: none;
    resize: none;
    font-family: var(--bp-font);
    font-size: 14px;
    color: var(--bp-text);
    background: var(--bp-surface);
    box-sizing: border-box;
}

.bpbytes-chatbot-textarea:focus {
    border-color: var(--bp-primary);
    box-shadow: 0 0 0 3px var(--bp-primary-soft);
}

.bpbytes-chatbot-send {
    width: 100%;
    background: var(--bp-title);
    color: #fff;
    border: none;
    padding: 12px;
    border-radius: var(--bp-radius-sm);
    cursor: pointer;
    font-weight: 700;
    font-family: var(--bp-font);
}

.bpbytes-chatbot-send:hover {
    opacity: 0.92;
}

.bpbytes-chatbot-message {
    display: flex;
    width: 100%;
}

.bpbytes-chatbot-message--user {
    justify-content: flex-end;
}

.bpbytes-chatbot-message--ai {
    justify-content: flex-start;
}

.bpbytes-chatbot-bubble {
    font-size: 14px;
    line-height: 1.6;
    word-break: break-word;
}

.bpbytes-chatbot-bubble--user {
    background: var(--bp-title);
    color: #fff;
    padding: 10px 14px;
    margin: 8px 12px;
    border-radius: var(--bp-radius) var(--bp-radius) 0 var(--bp-radius);
    max-width: 80%;
}

.bpbytes-chatbot-bubble--ai {
    width: 100%;
    padding: 15px 20px;
    color: var(--bp-text);
    box-sizing: border-box;
}

@media (max-width: 640px) {
    .bpbytes-chatbot-panel {
        width: 100vw;
        max-width: 100vw;
    }
}
