/* ─── Chatbot Widget & Block ──────────────────────────────────────────────── */

/* ── Floating widget button ──────────────────────────────────────────────── */
.chatbot-fab {
    position: fixed;
    bottom: 1.5rem;
    right: 1.5rem;
    z-index: 9998;
    width: 3rem;
    height: 3rem;
    border-radius: 50%;
    background: #fff;
    color: #888;
    border: 1.5px solid #ccc;
    cursor: pointer;
    font-size: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 2px 8px rgba(0,0,0,.1);
    transition: border-color .15s, color .15s, box-shadow .15s;
}
.chatbot-fab svg {
    width: 1.25rem;
    height: 1.25rem;
    stroke: currentColor;
    fill: none;
    stroke-width: 1.5;
    stroke-linecap: round;
    stroke-linejoin: round;
}
.chatbot-fab:hover {
    color: #555;
    border-color: #999;
    box-shadow: 0 3px 10px rgba(0,0,0,.15);
}
.chatbot-fab[aria-expanded="true"] {
    color: #555;
    border-color: #999;
}

/* ── Panel (floating widget) ─────────────────────────────────────────────── */
.chatbot-panel {
    position: fixed;
    bottom: 6rem;
    right: 1.5rem;
    z-index: 9999;
    width: 360px;
    max-width: calc(100vw - 2rem);
    max-height: 70vh;
    display: flex;
    flex-direction: column;
    background: #fff;
    border: 1px solid #ccc;
    border-radius: 12px;
    box-shadow: 0 8px 28px rgba(0,0,0,.2);
    overflow: hidden;
    transform: scale(.95) translateY(10px);
    opacity: 0;
    pointer-events: none;
    transition: transform .2s, opacity .2s;
}
.chatbot-panel.is-open {
    transform: scale(1) translateY(0);
    opacity: 1;
    pointer-events: auto;
}

/* ── Inline block (embedded in a site page) ──────────────────────────────── */
.chatbot-inline {
    display: flex;
    flex-direction: column;
    border: 1px solid #ddd;
    border-radius: 8px;
    overflow: hidden;
    max-height: 560px;
    background: #fff;
}

/* ── Shared inner layout ─────────────────────────────────────────────────── */
.chatbot-header {
    background: var(--color-primary, #3a6fa8);
    color: #fff;
    padding: .75rem 1rem;
    font-weight: 600;
    font-size: 1rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-shrink: 0;
}
.chatbot-close-btn {
    background: transparent;
    border: none;
    color: #fff;
    cursor: pointer;
    font-size: 1.25rem;
    line-height: 1;
    padding: 0;
    opacity: .8;
}
.chatbot-close-btn:hover { opacity: 1; }

.chatbot-messages {
    flex: 1;
    overflow-y: auto;
    padding: .75rem 1rem;
    display: flex;
    flex-direction: column;
    gap: .6rem;
}

.chatbot-message {
    max-width: 85%;
    padding: .55rem .85rem;
    border-radius: 14px;
    font-size: .9rem;
    line-height: 1.45;
    word-break: break-word;
}
.chatbot-message.user {
    align-self: flex-end;
    background: var(--color-primary, #3a6fa8);
    color: #fff;
    border-bottom-right-radius: 4px;
}
.chatbot-message.bot {
    align-self: flex-start;
    background: #f0f4f8;
    color: #111;
    border-bottom-left-radius: 4px;
}
.chatbot-message.error {
    align-self: flex-start;
    background: #fff0f0;
    color: #c00;
}
.chatbot-message.typing {
    align-self: flex-start;
    background: #f0f4f8;
    color: #888;
    font-style: italic;
}

.chatbot-message p { margin: 0 0 .3rem; }
.chatbot-message p:last-child { margin-bottom: 0; }

.chatbot-citation {
    color: inherit;
    text-decoration: underline dotted;
    font-size: .75em;
}

/* ── Sources ─────────────────────────────────────────────────────────────── */
.chatbot-sources {
    margin-top: .5rem;
    padding-top: .5rem;
    border-top: 1px solid #ddd;
    font-size: .8rem;
}
.chatbot-sources h4 {
    margin: 0 0 .3rem;
    font-size: .8rem;
    color: #555;
    text-transform: uppercase;
    letter-spacing: .03em;
}
.chatbot-source-item {
    margin-bottom: .25rem;
}
.chatbot-source-item a {
    color: var(--color-primary, #3a6fa8);
}
.chatbot-source-snippet {
    color: #666;
    font-size: .78rem;
}

/* ── Input area ──────────────────────────────────────────────────────────── */
.chatbot-input-area {
    display: flex;
    gap: .4rem;
    padding: .6rem .75rem;
    border-top: 1px solid #ddd;
    background: #fafafa;
    flex-shrink: 0;
}
.chatbot-input {
    flex: 1;
    padding: .45rem .7rem;
    border: 1px solid #ccc;
    border-radius: 20px;
    font-size: .9rem;
    outline: none;
    resize: none;
    font-family: inherit;
    line-height: 1.4;
}
.chatbot-input:focus { border-color: var(--color-primary, #3a6fa8); }
.chatbot-send-btn {
    padding: .45rem .9rem;
    border: none;
    border-radius: 20px;
    background: var(--color-primary, #3a6fa8);
    color: #fff;
    font-size: .9rem;
    cursor: pointer;
    white-space: nowrap;
    transition: background .15s;
}
.chatbot-send-btn:hover { background: #2a5a90; }
.chatbot-send-btn:disabled { background: #aaa; cursor: default; }

/* ── Block heading ───────────────────────────────────────────────────────── */
.chatbot-block__heading {
    margin-bottom: .75rem;
}

/* ── Responsive ──────────────────────────────────────────────────────────── */
@media (max-width: 480px) {
    .chatbot-panel { width: calc(100vw - 1rem); right: .5rem; bottom: 5rem; }
}
