/* ── Awedesk Chatbot Widget ─────────────────────────────────────────────── */

.alsp-chatbot {
    --cb-accent:   var(--C-B);
    --cb-accent-h: var(--C-B-D);
    --cb-radius:   14px;
    --cb-shadow:   0 8px 32px rgba(0, 0, 0, .15);
    position: fixed;
    bottom: 24px;
    right:  24px;
    z-index: 9999;
    font-family: Inter, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    font-size: 14px;
    line-height: 1.5;
}

/* ── Toggle button ─────────────────────────────────────────────────────── */

.alsp-chatbot__toggle {
    width: 56px;
    height: 56px;
    border-radius: 50%;
    background: var(--cb-accent);
    color: #fff;
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 16px color-mix(in srgb, var(--cb-accent), transparent 50%);
    transition: background .18s, transform .18s, box-shadow .18s;
    padding: 0;
    position: relative;
}
.alsp-chatbot__toggle:hover {
    background: var(--cb-accent-h);
    transform: scale(1.06);
}
.alsp-chatbot__toggle svg {
    width: 22px;
    height: 22px;
    position: absolute;
    transition: opacity .2s, transform .2s;
}
.alsp-chatbot__icon-close {
    opacity: 0;
    transform: rotate(90deg) scale(.8);
}
.alsp-chatbot--open .alsp-chatbot__icon-chat {
    opacity: 0;
    transform: rotate(-90deg) scale(.8);
}
.alsp-chatbot--open .alsp-chatbot__icon-close {
    opacity: 1;
    transform: rotate(0deg) scale(1);
}

/* ── Panel ─────────────────────────────────────────────────────────────── */

.alsp-chatbot__panel {
    position: absolute;
    bottom: 68px;
    right: 0;
    width: 340px;
    max-height: 500px;
    background: #fff;
    border-radius: var(--cb-radius);
    box-shadow: var(--cb-shadow);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    opacity: 0;
    transform: translateY(10px) scale(.97);
    pointer-events: none;
    transition: opacity .2s, transform .2s;
    border: 1px solid rgba(0, 0, 0, .08);
}
.alsp-chatbot--open .alsp-chatbot__panel {
    opacity: 1;
    transform: translateY(0) scale(1);
    pointer-events: auto;
}

/* ── Header ────────────────────────────────────────────────────────────── */

.alsp-chatbot__header {
    background: var(--cb-accent);
    color: #fff;
    padding: 14px 16px;
    font-weight: 600;
    font-size: 15px;
    flex-shrink: 0;
    letter-spacing: .01em;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
}

/* ── Maximize button ───────────────────────────────────────────────────── */

.alsp-chatbot__maximize {
    flex-shrink: 0;
    background: none;
    border: none;
    color: rgba(255,255,255,.75);
    cursor: pointer;
    padding: 2px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 4px;
    transition: color .15s, background .15s;
}
.alsp-chatbot__maximize:hover { color: #fff; background: rgba(255,255,255,.15); }
.alsp-chatbot__maximize svg  { width: 15px; height: 15px; }

.alsp-chatbot__icon-compress { display: none; }
.alsp-chatbot--maximized .alsp-chatbot__icon-expand   { display: none; }
.alsp-chatbot--maximized .alsp-chatbot__icon-compress { display: block; }

/* ── Maximized panel ───────────────────────────────────────────────────── */

.alsp-chatbot--maximized .alsp-chatbot__panel {
    width:      min(760px, calc(100vw - 32px));
    max-height: min(680px, calc(100vh - 110px));
}

/* ── Header avatar ─────────────────────────────────────────────────────── */

.alsp-chatbot__header-avatar {
    width: 32px;
    height: 32px;
    border: 2px solid rgba(255, 255, 255, .35);
    flex-shrink: 0;
}
.alsp-chatbot__header-avatar.alsp-chatbot__avatar--bot {
    background: rgba(255, 255, 255, .2);
    padding: 5px;
}

/* ── Messages ──────────────────────────────────────────────────────────── */

.alsp-chatbot__messages {
    flex: 1;
    overflow-y: auto;
    padding: 14px 12px;
    display: flex;
    flex-direction: column;
    gap: 8px;
    scroll-behavior: smooth;
}

/* ── Message rows (avatar + bubble) ───────────────────────────────────── */

.alsp-chatbot__row {
    display: flex;
    align-items: flex-end;
    gap: 8px;
    animation: alsp-cb-fadein .18s ease;
}
.alsp-chatbot__row--user {
    flex-direction: row-reverse;
}

/* ── Avatars ───────────────────────────────────────────────────────────── */

.alsp-chatbot__avatar {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    flex-shrink: 0;
    object-fit: cover;
}
.alsp-chatbot__avatar--bot {
    background: var(--cb-accent);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 5px;
}
.alsp-chatbot__avatar--user {
    background: #64748b;
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 5px;
}
.alsp-chatbot__avatar svg {
    width: 100%;
    height: 100%;
}

/* ── Bubbles ───────────────────────────────────────────────────────────── */

.alsp-chatbot__msg {
    max-width: 78%;
    padding: 9px 13px;
    border-radius: 16px;
    word-break: break-word;
}
@keyframes alsp-cb-fadein {
    from { opacity: 0; transform: translateY(4px); }
    to   { opacity: 1; transform: translateY(0); }
}

.alsp-chatbot__msg--user {
    background: var(--cb-accent);
    color: #fff;
    border-bottom-right-radius: 4px;
}
.alsp-chatbot__msg--bot {
    background: #f1f5f9;
    color: #1e293b;
    border-bottom-left-radius: 4px;
}
.alsp-chatbot__msg a {
    color: var(--cb-accent);
    text-decoration: underline;
}
.alsp-chatbot__msg--user a {
    color: #bfdbfe;
}

/* ── Markdown rendering inside bot bubbles ─────────────────────────────── */

.alsp-chatbot__msg--bot p {
    margin: 0 0 6px;
}
.alsp-chatbot__msg--bot p:last-child { margin-bottom: 0; }
.alsp-chatbot__msg--bot .alsp-cb-ul,
.alsp-chatbot__msg--bot .alsp-cb-ol {
    margin: 4px 0 6px;
    display: block;
}
.alsp-chatbot__msg--bot .alsp-cb-li {
    display: flex;
    align-items: baseline;
    gap: 0.45em;
    margin-bottom: 2px;
}
.alsp-chatbot__msg--bot .alsp-cb-bullet {
    flex-shrink: 0;
}
.alsp-chatbot__msg--bot .alsp-cb-num {
    flex-shrink: 0;
    min-width: 1.4em;
    text-align: right;
}
.alsp-chatbot__msg--bot .alsp-cb-ul--sub {
    margin: 3px 0 1px;
}
.alsp-chatbot__msg--bot .alsp-cb-li--sub {
    margin-bottom: 1px;
}
.alsp-chatbot__msg--bot code {
    font-family: ui-monospace, 'SFMono-Regular', Consolas, monospace;
    font-size: .85em;
    background: rgba(0,0,0,.07);
    border-radius: 3px;
    padding: 1px 4px;
}
.alsp-chatbot__msg--bot pre {
    margin: 6px 0;
    padding: 8px 10px;
    background: rgba(0,0,0,.07);
    border-radius: 6px;
    overflow-x: auto;
    font-size: .8em;
}
.alsp-chatbot__msg--bot pre code {
    background: none;
    padding: 0;
}

/* ── Typing indicator ──────────────────────────────────────────────────── */

.alsp-chatbot__typing {
    display: flex !important;
    gap: 4px;
    align-items: center;
    padding: 13px !important;
}
.alsp-chatbot__typing span {
    width: 6px;
    height: 6px;
    background: #94a3b8;
    border-radius: 50%;
    animation: alsp-cb-bounce 1.1s infinite ease-in-out;
}
.alsp-chatbot__typing span:nth-child(2) { animation-delay: .18s; }
.alsp-chatbot__typing span:nth-child(3) { animation-delay: .36s; }
@keyframes alsp-cb-bounce {
    0%, 60%, 100% { transform: translateY(0); }
    30% { transform: translateY(-5px); }
}

/* ── Department hint ───────────────────────────────────────────────────── */

.alsp-chatbot__dept-hint {
    align-self: flex-start;
    background: transparent !important;
    color: var(--cb-accent) !important;
    border: 1.5px solid var(--cb-accent);
    font-size: 12px;
    font-weight: 500;
    padding: 5px 12px !important;
    border-radius: 20px;
    animation: alsp-cb-fadein .18s ease;
}

/* ── Not-helpful hint ──────────────────────────────────────────────────── */

.alsp-chatbot__not-helpful {
    align-self: flex-start;
    margin-left: 36px;
    background: none;
    border: none;
    padding: 0 0 4px;
    font-size: 11px;
    font-family: inherit;
    color: #94a3b8;
    cursor: pointer;
    text-decoration: underline;
    text-underline-offset: 2px;
    transition: color .15s;
    animation: alsp-cb-fadein .18s ease;
}
.alsp-chatbot__not-helpful:hover { color: var(--cb-accent); }

/* ── Escalate button ───────────────────────────────────────────────────── */

.alsp-chatbot__escalate-btn {
    align-self: flex-start;
    padding: 8px 16px;
    background: transparent;
    color: var(--cb-accent);
    border: 1.5px solid var(--cb-accent);
    border-radius: 20px;
    cursor: pointer;
    font-size: 13px;
    font-weight: 500;
    font-family: inherit;
    transition: background .15s, color .15s;
    animation: alsp-cb-fadein .18s ease;
}
.alsp-chatbot__escalate-btn:hover:not(:disabled) {
    background: var(--cb-accent);
    color: #fff;
}
.alsp-chatbot__escalate-btn:disabled {
    opacity: .55;
    cursor: default;
}

/* ── Ticket link button ────────────────────────────────────────────────── */

.alsp-chatbot__ticket-btn {
    align-self: flex-start;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 9px 18px;
    background: #16a34a;
    color: #fff;
    border: none;
    border-radius: 20px;
    cursor: pointer;
    font-size: 13px;
    font-weight: 600;
    font-family: inherit;
    text-decoration: none;
    transition: background .15s, transform .15s;
    animation: alsp-cb-fadein .18s ease;
}
.alsp-chatbot__ticket-btn:hover {
    background: #15803d;
    color: #fff;
    transform: translateY(-1px);
    text-decoration: none;
}

/* ── Footer / input ────────────────────────────────────────────────────── */

.alsp-chatbot__footer {
    padding: 10px 12px;
    border-top: 1px solid #e2e8f0;
    flex-shrink: 0;
}
.alsp-chatbot__input-row {
    display: flex;
    gap: 8px;
    align-items: center;
}
.alsp-chatbot__input {
    flex: 1;
    padding: 9px 14px;
    border: 1.5px solid #cbd5e1;
    border-radius: 22px;
    outline: none;
    font-size: 14px;
    font-family: inherit;
    background: #fff;
    color: #1e293b;
    transition: border-color .15s;
}
.alsp-chatbot__input:focus  { border-color: var(--cb-accent); }
.alsp-chatbot__input:disabled { background: #f8fafc; }

.alsp-chatbot__send {
    flex-shrink: 0;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: var(--cb-accent);
    color: #fff;
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background .15s, transform .15s;
    padding: 0;
}
.alsp-chatbot__send svg { width: 15px; height: 15px; }
.alsp-chatbot__send:hover:not(:disabled) { background: var(--cb-accent-h); transform: scale(1.06); }
.alsp-chatbot__send:disabled { opacity: .5; cursor: default; }

/* ── Dark mode ─────────────────────────────────────────────────────────── */

@media (prefers-color-scheme: dark) {
    .alsp-chatbot__panel        { background: #1e293b; border-color: rgba(255,255,255,.07); }
    .alsp-chatbot__msg--bot     { background: #334155; color: #e2e8f0; }
    .alsp-chatbot__avatar--user { background: #475569; }
    .alsp-chatbot__input        { background: #1e293b; color: #e2e8f0; border-color: #475569; }
    .alsp-chatbot__input:focus  { border-color: #60a5fa; }
    .alsp-chatbot__footer       { border-color: #334155; }
}

/* ── Mobile ────────────────────────────────────────────────────────────── */

@media (max-width: 420px) {
    .alsp-chatbot__panel                       { width: calc(100vw - 32px); right: -12px; }
    .alsp-chatbot--maximized .alsp-chatbot__panel {
        width:      calc(100vw - 24px);
        max-height: calc(100vh - 90px);
        right: -12px;
    }
}

@media (max-width: 61.24em) {
    .alsp-chatbot {
        right: 12px;
        bottom: 72px;
    }
}
