/* =========================================================
   SADV Chatbot v1.2.0 — Scoped Styles
   All selectors are prefixed #sadv-* / .sadv-cb-* to
   prevent bleeding into the theme.
   Dynamic colour values come from CSS vars set by JS.
   ========================================================= */

:root {
    --sadv-primary:         #1F539C;
    --sadv-header-bg:       #FFCB05;
    --sadv-highlight:       #FFCB05;
    --sadv-user-bubble-bg:  #1F539C;
    --sadv-user-bubble-txt: #ffffff;
    --sadv-bot-bubble-bg:   #ffffff;
    --sadv-bot-bubble-bdr:  #cccccc;
    --sadv-opt-btn-bdr:     #1F539C;
    --sadv-opt-btn-txt:     #1F539C;
}

/* ── Open button ─────────────────────────────────────── */
#sadv-chatbot-open-btn {
    position: fixed;
    bottom: 0;
    right: 0;
    border: none;
    cursor: pointer;
    z-index: 10000;
    background-color: transparent;
    padding: 0;
    line-height: 0;
}

/* ── Speech bubble ───────────────────────────────────── */
#sadv-speech-bubble {
    position: fixed;
    z-index: 10001;
    background: var(--sadv-header-bg);
    color: var(--sadv-primary);
    font-weight: 700;
    font-size: 14px;
    font-family: sans-serif;
    padding: 10px 14px;
    border-radius: 10px 10px 10px 0;
    line-height: 1.4;
    pointer-events: none;
    white-space: pre-line;
    max-width: 180px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.15);
}

/* ── Chat container ──────────────────────────────────── */
#sadv-chatbot-container {
    position: fixed;
    bottom: 20px;
    right: 20px;
    width: 300px;
    max-height: 85vh;
    min-height: 400px;
    border: 2px solid var(--sadv-primary);
    border-radius: 10px;
    background-color: #ffffff;
    overflow: visible;          /* allows avatar to extend above */
    z-index: 9999;
    display: none;
    flex-direction: column;
    font-family: sans-serif;
    box-shadow: 0 4px 20px rgba(0,0,0,0.18);
}

/* ── Header ──────────────────────────────────────────── */
#sadv-bot-header {
    background-color: var(--sadv-header-bg);
    border-radius: 8px 8px 0 0;
    position: relative;
    overflow: visible;          /* avatar extends above header */
    flex-shrink: 0;

    /* Flexbox: title grows in middle, button group sits on the right */
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 10px 10px 10px;
    min-height: 50px;
    gap: 8px;
}

/* ── Avatar ──────────────────────────────────────────── */
/* Position, size, and alignment are injected inline by JS.
   Only non-positional base styles live here.            */
#sadv-chatbot-avatar {
    display: block;
    border-radius: 0;
    pointer-events: none;
    flex-shrink: 0;
    z-index: 2;
    /* JS sets: position:absolute; bottom:0; left/right/transform; width */
}

/* ── Header title ────────────────────────────────────── */
#sadv-chatbot-title {
    font-family: sans-serif;
    color: var(--sadv-primary);
    margin: 0;
    font-weight: 600;
    font-size: 15px;
    line-height: 1.3;
    flex: 1;                    /* grows to fill space between avatar gap and buttons */
    text-align: center;
    /* JS sets padding-left or padding-right to clear the avatar */
}

/* ── Header button group ─────────────────────────────── */
#sadv-header-btns {
    display: flex;
    align-items: center;
    gap: 6px;
    flex-shrink: 0;
}

#sadv-chatbot-minimise,
#sadv-chatbot-end {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    border-radius: 6px;
    background-color: var(--sadv-primary);
    color: #ffffff;
    border: none;
    cursor: pointer;
    font-size: 16px;
    font-weight: 700;
    line-height: 1;
    padding: 0;
    transition: filter 0.2s;
    flex-shrink: 0;
}

#sadv-chatbot-minimise:hover,
#sadv-chatbot-end:hover {
    filter: brightness(0.82);
}

/* ── Chat area ───────────────────────────────────────── */
#sadv-chat-area {
    flex: 1;
    overflow-y: auto;
    padding: 10px;
    border-left: 1px solid #e0e0e0;
    border-right: 1px solid #e0e0e0;
    background-color: #ffffff;
    display: flex;
    flex-direction: column;
    min-height: 0;              /* required for flex child scroll */
}

/* ── Message wrappers ────────────────────────────────── */
.sadv-msg-wrap {
    padding: 8px 0;
    width: 100%;
    display: flex;
    flex-direction: column;
    align-items: flex-start;
}

.sadv-msg-wrap.sadv-user {
    align-items: flex-end;
    text-align: right;
}

.sadv-timestamp {
    color: #999;
    font-size: 11px;
    font-family: sans-serif;
    margin-bottom: 3px;
}

/* ── Chat bubbles ────────────────────────────────────── */
#sadv-chat-area p.sadv-bubble {
    margin: 0;
    padding: 8px 12px;
    border-radius: 14px;
    max-width: 85%;
    font-family: sans-serif;
    font-size: 14px;
    line-height: 1.45;
    display: inline-block;
    word-break: break-word;
}

#sadv-chat-area p.sadv-bubble-user {
    background-color: var(--sadv-user-bubble-bg);
    color: var(--sadv-user-bubble-txt);
    border-radius: 14px 14px 4px 14px;
}

#sadv-chat-area p.sadv-bubble-bot {
    background-color: var(--sadv-bot-bubble-bg);
    border: 1px solid var(--sadv-bot-bubble-bdr);
    color: #333;
    border-radius: 14px 14px 14px 4px;
}

/* ── Bot name highlight ──────────────────────────────── */
.sadv-bot-highlight {
    font-weight: bold;
    color: var(--sadv-highlight);
}

/* ── Option buttons ──────────────────────────────────── */
#sadv-chat-options {
    display: flex;
    flex-direction: row;
    flex-wrap: wrap;
    gap: 8px;
    padding: 6px 0 4px;
}

#sadv-chat-options button {
    background-color: transparent;
    border: 1px solid var(--sadv-opt-btn-bdr);
    color: var(--sadv-opt-btn-txt);
    padding: 6px 10px;
    cursor: pointer;
    font-size: 13px;
    font-family: sans-serif;
    border-radius: 6px;
    transition: background-color 0.2s, color 0.2s;
}

#sadv-chat-options button:hover {
    background-color: var(--sadv-primary);
    color: #ffffff;
}

/* ── Input area ──────────────────────────────────────── */
#sadv-input-area {
    display: flex;
    padding: 8px;
    gap: 6px;
    border-top: 1px solid #e0e0e0;
    background: #f9f9f9;
    border-radius: 0 0 8px 8px;
    flex-shrink: 0;
}

#sadv-chatbot-input {
    flex: 1;
    padding: 8px 10px;
    border: 1px solid var(--sadv-primary);
    border-radius: 6px;
    font-size: 13px;
    font-family: sans-serif;
    outline: none;
    min-width: 0;
}

#sadv-chatbot-input:focus {
    border-color: var(--sadv-primary);
    box-shadow: 0 0 0 2px rgba(31,83,156,0.15);
}

#sadv-chatbot-send {
    padding: 8px 14px;
    border: none;
    border-radius: 6px;
    background-color: var(--sadv-primary);
    color: #ffffff;
    cursor: pointer;
    font-size: 13px;
    font-family: sans-serif;
    font-weight: 600;
    white-space: nowrap;
    transition: filter 0.2s;
    flex-shrink: 0;
}

#sadv-chatbot-send:hover {
    filter: brightness(0.85);
}
