/* ── Trigger button (fixed, bottom-right) ────────────────────────────────── */
.mai-chatbot__trigger {
    --c: #00fff7;
    --p: 10%;
    --l: 10px;
    --a: 10deg;
    transition: --c .7s, --p .5s, --l .5s;
    background: linear-gradient(90deg, var(--c) var(--p), #00ffa0);
    border: 2px solid rgba(0, 0, 0, 0);
    position: fixed;
    bottom: 24px;
    right: 50px;
    z-index: 9999;
    width: 54px;
    height: 54px;
    border-radius: 50%;
    color: var(--Pure-Black, #000);
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 16px rgba(0, 0, 0, .25);
    transition: background .2s, transform .2s, right .3s, bottom .3s, top .3s, left .3s;
}

.mai-chatbot__trigger:hover {
    --c: #000;
    --p: 100%;
    --l: 100%;
    color: #fff;
    border: 2px solid #fff;
    transform: scale(1.08);
}

.mai-chatbot__trigger.mai-chatbot--open {
    right: 510px;
}

/* Toggle icons */
.mai-chatbot__trigger-icon--close { display: none; }

.mai-chatbot--open .mai-chatbot__trigger-icon--open  { display: none; }
.mai-chatbot--open .mai-chatbot__trigger-icon--close { 
    display: block; 
}

/* ── Overlay / backdrop ──────────────────────────────────────────────────── */
.mai-chatbot__overlay {
    position: fixed;
    inset: 0;
    z-index: 9998;
    background: rgba(0, 0, 0, .35);
    opacity: 0;
    pointer-events: none;
    transition: opacity .25s ease;
}

.mai-chatbot__overlay.is-open {
    opacity: 1;
    pointer-events: auto;
    
}

/* ── Sidebar panel ───────────────────────────────────────────────────────── */
.mai-chatbot {
    position: fixed;
    top: 0;
    right: 0;
    z-index: 9999;
    width: 500px;
    max-width: 100vw;
    height: 100dvh;
    display: flex;
    flex-direction: column;
    background: #fff;
    box-shadow: -4px 0 24px rgba(0, 0, 0, .18);
    transform: translateX(100%);
    transition: transform .3s cubic-bezier(.4, 0, .2, 1);
    overflow: hidden;
}

.mai-chatbot__overlay.is-open .mai-chatbot {
    transform: translateX(0);
}

/* ── Header ──────────────────────────────────────────────────────────────── */
.mai-chatbot__header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 16px;
    background: linear-gradient(280deg, #000 4.35%, #32343B 60.44%);
    color: #fff;
    flex-shrink: 0;
}

.mai-chatbot__header-title {
    font-weight: 600;
    font-size: 0.97rem;
    letter-spacing: .02em;
}

.mai-chatbot__header-actions {
    display: flex;
    align-items: center;
    gap: 4px;
}

.mai-chatbot__clear-btn {
    background: transparent;
    border: none;
    color: #fff;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 4px;
    border-radius: 4px;
    opacity: .7;
    transition: opacity .15s, background .15s;
}

.mai-chatbot__clear-btn:hover {
    background: rgba(255, 255, 255, .2);
    opacity: 1;
}

.mai-chatbot__close-btn {
    background: transparent;
    border: none;
    color: #fff;
    font-size: 1.1rem;
    cursor: pointer;
    line-height: 1;
    padding: 2px 4px;
    border-radius: 4px;
    transition: background .15s;
}

.mai-chatbot__close-btn:hover {
    background: rgba(255, 255, 255, .2);
}

/* ── Conversation history ────────────────────────────────────────────────── */
.mai-chatbot__history {
    flex: 1;
    overflow-y: auto;
    padding: 14px 12px;
    background: #fafafa;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

/* ── Individual message ──────────────────────────────────────────────────── */
.mai-chatbot__msg {
    padding: 9px 12px;
    border-radius: 8px;
    max-width: 88%;
    line-height: 1.55;
    font-size: 0.9rem;
}

.mai-chatbot__msg--user {
    align-self: flex-end;
    background: linear-gradient(280deg, #000 4.35%, #32343B 60.44%);
    color: #fff;
    border-bottom-right-radius: 2px;
}

.mai-chatbot__msg--agent {
    align-self: flex-start;
    background: #fff;
    border: 1px solid #e0e0e0;
    color: #333;
    border-bottom-left-radius: 2px;
}

.mai-chatbot__msg--thinking {
    font-style: italic;
    color: #999;
    border: none;
    background: transparent;
    padding-left: 4px;
}

.mai-chatbot__msg-label {
    display: block;
    font-size: 0.68rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .05em;
    margin-bottom: 3px;
    opacity: .65;
}

.mai-chatbot__msg-text { margin: 0; }

/* ── Markdown content inside agent bubbles ───────────────────────────────── */
.mai-chatbot__msg-md { font-size: 0.88rem; line-height: 1.6; }

.mai-chatbot__msg-md > *:first-child { margin-top: 0; }
.mai-chatbot__msg-md > *:last-child  { margin-bottom: 0; }

.mai-chatbot__msg-md p            { margin: 0 0 .5em; font-size: 0.88rem;}
.mai-chatbot__msg-md ul,
.mai-chatbot__msg-md ol           { margin: .25em 0 .5em 1.2em; padding: 0; font-size: 0.88rem;}
.mai-chatbot__msg-md li           { margin-bottom: .2em;  font-size: 0.88rem;}
.mai-chatbot__msg-md h1,
.mai-chatbot__msg-md h2,
.mai-chatbot__msg-md h3           { margin: .6em 0 .3em; font-size: 1em; font-weight: 700; }
.mai-chatbot__msg-md strong       { font-weight: 700; }
.mai-chatbot__msg-md em           { font-style: italic; }
.mai-chatbot__msg-md blockquote   { margin: .4em 0; padding-left: .75em;
                                    border-left: 3px solid #32343B; color: #555; font-size: 0.88rem;}
.mai-chatbot__msg-md a            { color: #32343B; text-decoration: underline; }
.mai-chatbot__msg-md a:hover      { color: #000; }

/* Inline code */
.mai-chatbot__msg-md code {
    background: #f0f0f0;
    border-radius: 3px;
    padding: 1px 3px;
    font-family: ui-monospace, monospace;
    font-size: .85em;
    color: #c7254e;
}


/* Code blocks */
.mai-chatbot__msg-md pre {
    background: #1e1e1e;
    color: #d4d4d4;
    border-radius: 6px;
    padding: 10px 12px;
    overflow-x: auto;
    margin: .5em 0;
    font-size: 0.88rem;
}
.mai-chatbot__msg-md pre code {
    background: none;
    color: inherit;
    padding: 0;
    font-size: .82em;
    white-space: pre;
}

.mai-chatbot__msg-md code, 
.mai-chatbot__msg-md kbd, 
.mai-chatbot__msg-md pre, 
.mai-chatbot__msg-md samp {
    font-size: 0.82rem !important;
}

/* Tables */
.mai-chatbot__msg-md table     { border-collapse: collapse; width: 100%; margin: .5em 0; font-size: .85em; }
.mai-chatbot__msg-md th,
.mai-chatbot__msg-md td        { border: 1px solid #ddd; padding: 4px 8px; text-align: left; font-size: 0.85rem;}
.mai-chatbot__msg-md th        { background: #32343B; color: #fff; font-weight: 600; font-size: 0.85rem;}
.mai-chatbot__msg-md tr:nth-child(even) td { background: #fafafa; }

/* ── Input area ──────────────────────────────────────────────────────────── */
.mai-chatbot__input-area {
    display: flex;
    flex-direction: column;
    gap: 8px;
    padding: 10px 12px;
    background: #fff;
    border-top: 1px solid #e0e0e0;
    flex-shrink: 0;
    margin-bottom: 20px;
}

.mai-chatbot__textarea {
    width: 100%;
    resize: none;
    border: 1px solid #ccc;
    border-radius: 6px;
    padding: 8px 10px;
    font-size: 0.9rem;
    font-family: inherit;
    line-height: 1.5;
    box-sizing: border-box;
    transition: border-color .2s;
}

.mai-chatbot__textarea:focus {
    outline: none;
    border-color: #32343B;
}

.mai-chatbot__textarea:disabled { background: #f5f5f5; }

.mai-chatbot__send-btn {
    align-self: flex-end;
    padding: 8px 20px;
    background: linear-gradient(90deg, #00fff7 10%, #00ffa0);
    color: #000;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    font-size: 0.9rem;
    font-weight: 600;
    transition: opacity .2s, transform .2s;
}

.mai-chatbot__send-btn:hover:not(:disabled) {
    opacity: .85;
    transform: scale(1.03);
}

.mai-chatbot__send-btn:disabled,
.mai-chatbot__send-btn.is-loading {
    opacity: .55;
    cursor: not-allowed;
}

/* ── Copy button ─────────────────────────────────────────────────────────── */
.mai-chatbot__msg {
    position: relative;
}

.mai-chatbot__copy-btn {
    position: absolute;
    top: 6px;
    right: 6px;
    background: rgba(255,255,255,.85);
    border: 1px solid #ddd;
    border-radius: 4px;
    padding: 3px 5px;
    cursor: pointer;
    color: #555;
    display: flex;
    align-items: center;
    opacity: 0;
    transition: opacity .15s, background .15s, color .15s;
    line-height: 1;
}

.mai-chatbot__msg:hover .mai-chatbot__copy-btn {
    opacity: 1;
}

.mai-chatbot__copy-btn:hover {
    background: #fff;
    color: #000;
    border-color: #aaa;
}

.mai-chatbot__copy-btn.is-copied {
    color: #00a67e;
    border-color: #00a67e;
    opacity: 1;
}

.mai-chatbot__msg--user .mai-chatbot__copy-btn {
    background: rgba(0,0,0,.25);
    border-color: rgba(255,255,255,.3);
    color: #fff;
}

.mai-chatbot__msg--user .mai-chatbot__copy-btn:hover {
    background: rgba(0,0,0,.45);
}

/* ── Rating widget ───────────────────────────────────────────────────────── */
.mai-chatbot__rating {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 4px;
    margin-top: 8px;
    padding-top: 8px;
    border-top: 1px solid #e8e8e8;
}

.mai-chatbot__thumb {
    background: transparent;
    border: 1px solid #ddd;
    border-radius: 4px;
    padding: 4px 6px;
    cursor: pointer;
    color: #888;
    display: flex;
    align-items: center;
    transition: color .15s, border-color .15s, background .15s;
    line-height: 1;
}

.mai-chatbot__thumb:hover          { color: #333; border-color: #aaa; }
.mai-chatbot__thumb--up.is-active  { color: #00a67e; border-color: #00a67e; background: #f0faf7; }
.mai-chatbot__thumb--down.is-active{ color: #d94040; border-color: #d94040; background: #fdf2f2; }

.mai-chatbot__rating-form {
    width: 100%;
    display: flex;
    flex-direction: column;
    gap: 6px;
    margin-top: 4px;
}

.mai-chatbot__rating-textarea {
    width: 100%;
    resize: none;
    border: 1px solid #ccc;
    border-radius: 6px;
    padding: 6px 8px;
    font-size: 0.82rem;
    font-family: inherit;
    line-height: 1.4;
    box-sizing: border-box;
    transition: border-color .2s;
}

.mai-chatbot__rating-textarea:focus {
    outline: none;
    border-color: #32343B;
}

.mai-chatbot__rating-submit {
    align-self: flex-end;
    padding: 5px 14px;
    background: linear-gradient(90deg, #00fff7 10%, #00ffa0);
    color: #000;
    border: none;
    border-radius: 5px;
    cursor: pointer;
    font-size: 0.82rem;
    font-weight: 600;
    transition: opacity .2s;
}

.mai-chatbot__rating-submit:hover:not(:disabled) { opacity: .8; }
.mai-chatbot__rating-submit:disabled { opacity: .5; cursor: not-allowed; }

.mai-chatbot__rating-thanks {
    margin: 6px 0 0;
    font-size: 0.8rem;
    color: #00a67e;
    font-style: italic;
}

/* ── Keyboard-focus ring ─────────────────────────────────────────────────── */
.mai-chatbot__trigger:focus-visible,
.mai-chatbot__send-btn:focus-visible,
.mai-chatbot__close-btn:focus-visible,
.mai-chatbot__clear-btn:focus-visible,
.mai-chatbot__copy-btn:focus-visible,
.mai-chatbot__thumb:focus-visible,
.mai-chatbot__rating-submit:focus-visible {
    outline: 3px solid #f0c33c;
    outline-offset: 2px;
}