/* Wbee AI Conversational Search — v1.0.0 */
.wbee-ais-wrap {
    /* ── Themeable colour tokens ─────────────────────────── */
    --ais-header-bg:    #1a56db;   /* header + send button background */
    --ais-header-dark:  #1041b0;   /* header hover / send hover       */
    --ais-header-text:  #ffffff;   /* header text + send icon          */
    --ais-link:         #1a56db;   /* links inside bubbles & sources   */
    --ais-user-bg:      #1a56db;   /* user bubble background           */
    --ais-user-fg:      #ffffff;   /* user bubble text                 */
    --ais-ai-bg:        #ffffff;   /* AI bubble background             */
    --ais-ai-fg:        #111827;   /* AI bubble text                   */
    --ais-badge-bg:     #e5e7eb;   /* post-type badge background       */
    --ais-badge-fg:     #6b7280;   /* post-type badge text             */

    /* ── Structural tokens (not exposed in settings) ─────── */
    --ais-bg:           #f9fafb;
    --ais-border:       #e5e7eb;
    --ais-radius:       14px;
    --ais-font:         -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    --ais-shadow:       0 4px 24px rgba(0, 0, 0, .10);

    font-family: var(--ais-font);
    border: 1px solid var(--ais-border);
    border-radius: var(--ais-radius);
    overflow: hidden;
    box-shadow: var(--ais-shadow);
    display: flex;
    flex-direction: column;
    background: var(--ais-bg);
    max-width: 780px;
    margin: 0 auto 2rem;
}

/* ── Header ─────────────────────────────── */
.wbee-ais-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 13px 16px;
    background: var(--ais-header-bg);
    color: var(--ais-header-text);
    flex-shrink: 0;
}
.wbee-ais-title {
    display: flex;
    align-items: center;
    gap: 8px;
    font-weight: 600;
    font-size: 15px;
}
.wbee-ais-new-chat {
    display: flex;
    align-items: center;
    gap: 5px;
    background: rgba(128, 128, 128, .18);
    border: 1px solid rgba(128, 128, 128, .30);
    color: var(--ais-header-text);
    border-radius: 6px;
    padding: 5px 11px;
    font-size: 12px;
    font-family: var(--ais-font);
    cursor: pointer;
    transition: background .18s;
}
.wbee-ais-new-chat:hover { background: rgba(128, 128, 128, .30); }

/* ── Message area ───────────────────────── */
.wbee-ais-messages {
    overflow-y: auto;
    padding: 18px 16px;
    display: flex;
    flex-direction: column;
    gap: 14px;
    scroll-behavior: smooth;
    flex: 1;
}

/* ── Message bubbles ────────────────────── */
.wbee-ais-msg {
    display: flex;
    flex-direction: column;
    max-width: 86%;
}
.wbee-ais-msg--user { align-self: flex-end;   align-items: flex-end;   }
.wbee-ais-msg--ai   { align-self: flex-start; align-items: flex-start; }

.wbee-ais-bubble {
    padding: 10px 14px;
    border-radius: 13px;
    font-size: 14px;
    line-height: 1.65;
    word-break: break-word;
}
.wbee-ais-msg--user .wbee-ais-bubble {
    background: var(--ais-user-bg);
    color: var(--ais-user-fg);
    border-bottom-right-radius: 3px;
}
.wbee-ais-msg--ai .wbee-ais-bubble {
    background: var(--ais-ai-bg);
    color: var(--ais-ai-fg);
    border: 1px solid var(--ais-border);
    border-bottom-left-radius: 3px;
}
.wbee-ais-error .wbee-ais-bubble {
    background: #fef2f2;
    border-color: #fca5a5;
    color: #b91c1c;
}

/* ── Markdown content ───────────────────── */
.wbee-ais-bubble p             { margin: 0 0 8px; }
.wbee-ais-bubble p:last-child  { margin-bottom: 0; }
.wbee-ais-bubble ul,
.wbee-ais-bubble ol            { margin: 5px 0 5px 18px; padding: 0; }
.wbee-ais-bubble li            { margin-bottom: 3px; }
.wbee-ais-bubble a             { color: var(--ais-link); text-decoration: underline; }
.wbee-ais-bubble strong        { font-weight: 600; }
.wbee-ais-bubble em            { font-style: italic; }
.wbee-ais-bubble code          { background: #f3f4f6; border-radius: 4px; padding: 1px 5px; font-size: 13px; font-family: 'SFMono-Regular', Consolas, monospace; }
.wbee-ais-bubble pre           { background: #1e293b; color: #e2e8f0; border-radius: 8px; padding: 12px; overflow-x: auto; margin: 8px 0; }
.wbee-ais-bubble pre code      { background: transparent; color: inherit; padding: 0; font-size: 13px; }

/* ── Sources panel ──────────────────────── */
.wbee-ais-sources {
    margin-top: 8px;
    font-size: 12px;
    color: #6b7280;
    max-width: 100%;
}
.wbee-ais-sources-label {
    display: block;
    margin-bottom: 4px;
    color: #374151;
    font-weight: 600;
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: .4px;
}
.wbee-ais-source-item {
    display: flex;
    align-items: baseline;
    gap: 5px;
    margin-bottom: 3px;
}
.wbee-ais-source-item::before { content: '→'; color: #9ca3af; }
.wbee-ais-source-item a       { color: var(--ais-link); text-decoration: none; }
.wbee-ais-source-item a:hover { text-decoration: underline; }
.wbee-ais-badge {
    display: inline-block;
    background: var(--ais-badge-bg);
    color: var(--ais-badge-fg);
    border-radius: 4px;
    padding: 1px 5px;
    font-size: 10px;
    text-transform: uppercase;
    letter-spacing: .4px;
}

/* ── Typing indicator ───────────────────── */
.wbee-ais-typing .wbee-ais-bubble {
    display: flex;
    align-items: center;
    gap: 5px;
    padding: 13px 17px;
}
.wbee-ais-dot {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: #9ca3af;
    animation: wbee-ais-bounce .85s infinite ease-in-out;
}
.wbee-ais-dot:nth-child(2) { animation-delay: .16s; }
.wbee-ais-dot:nth-child(3) { animation-delay: .32s; }
@keyframes wbee-ais-bounce {
    0%, 80%, 100% { transform: translateY(0);    }
    40%           { transform: translateY(-7px); }
}

/* ── Input row ──────────────────────────── */
.wbee-ais-input-row {
    display: flex;
    align-items: flex-end;
    gap: 8px;
    padding: 12px 14px;
    border-top: 1px solid var(--ais-border);
    background: #fff;
    flex-shrink: 0;
}
.wbee-ais-input {
    flex: 1;
    resize: none;
    border: 1px solid var(--ais-border);
    border-radius: 10px;
    padding: 9px 13px;
    font-size: 14px;
    font-family: var(--ais-font);
    line-height: 1.5;
    max-height: 120px;
    overflow-y: auto;
    outline: none;
    transition: border-color .18s, box-shadow .18s;
    background: #fff;
    color: #111827;
}
.wbee-ais-input:focus {
    border-color: var(--ais-header-bg);
    box-shadow: 0 0 0 3px var(--ais-focus-ring, rgba(26, 86, 219, .13));
}
.wbee-ais-input:disabled { background: #f9fafb; color: #9ca3af; }

.wbee-ais-send {
    flex-shrink: 0;
    width: 40px;
    height: 40px;
    border-radius: 10px;
    background: var(--ais-header-bg);
    color: var(--ais-header-text);
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background .18s, opacity .18s, transform .1s;
}
.wbee-ais-send:hover   { background: var(--ais-header-dark); }
.wbee-ais-send:active  { transform: scale(.95); }
.wbee-ais-send:disabled { opacity: .45; cursor: not-allowed; transform: none; }

/* ── Footer ─────────────────────────────── */
.wbee-ais-footer {
    text-align: center;
    font-size: 11px;
    color: #9ca3af;
    padding: 6px;
    border-top: 1px solid var(--ais-border);
    flex-shrink: 0;
}
.wbee-ais-footer a { color: #9ca3af; text-decoration: none; }
.wbee-ais-footer a:hover { text-decoration: underline; }

/* ── Responsive ─────────────────────────── */
@media (max-width: 520px) {
    .wbee-ais-msg { max-width: 94%; }
    .wbee-ais-bubble { font-size: 13.5px; }
}
