@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&display=swap');

/* ============================================================
   AI Chatbot — Modern 2026 UI
   ============================================================ */

:root {
    --cb-primary: var(--chatbot-primary-color, #6366f1);
    --cb-primary-dark: color-mix(in srgb, var(--cb-primary) 75%, black);
    --cb-primary-light: color-mix(in srgb, var(--cb-primary) 15%, white);
    --cb-radius: 20px;
    --cb-font: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
}

/* ── Container ──────────────────────────────────────────── */
.ai-chatbot-container {
    position: fixed;
    z-index: 999999;
    font-family: var(--cb-font);
}

/* Theme override hardening (some themes globally restyle buttons/svg) */
.ai-chatbot-container button {
    -webkit-appearance: none;
    appearance: none;
    padding: 0;
    margin: 0;
    font: inherit;
    letter-spacing: inherit;
    text-transform: none;
    border: 0;
    outline: none;
    background: none;
}

.ai-chatbot-container button svg {
    display: block;
    flex-shrink: 0;
    opacity: 1;
    filter: none;
}

.ai-chatbot-container button:focus-visible {
    box-shadow: 0 0 0 3px color-mix(in srgb, var(--cb-primary) 20%, transparent);
}

.ai-chatbot-container.bottom-right { bottom: 24px; right: 24px; }
.ai-chatbot-container.bottom-left  { bottom: 24px; left:  24px; }

/* ── Toggle Button ──────────────────────────────────────── */
.ai-chatbot-toggle {
    position: relative;
    width: 62px;
    height: 62px;
    border-radius: 50%;
    border: none;
    background: linear-gradient(135deg, var(--cb-primary), var(--cb-primary-dark));
    box-shadow: 0 8px 32px color-mix(in srgb, var(--cb-primary) 45%, transparent),
                0 2px 8px rgba(0,0,0,.15);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform .3s cubic-bezier(.34,1.56,.64,1), box-shadow .3s ease;
    color: white;
}

.ai-chatbot-toggle:hover {
    transform: scale(1.08) translateY(-2px);
    box-shadow: 0 14px 40px color-mix(in srgb, var(--cb-primary) 55%, transparent),
                0 4px 12px rgba(0,0,0,.2);
}

.ai-chatbot-toggle svg { width: 26px; height: 26px; flex-shrink: 0; }

/* Pulse ring */
.ai-chatbot-toggle::before {
    content: '';
    position: absolute;
    inset: -6px;
    border-radius: 50%;
    border: 2px solid color-mix(in srgb, var(--cb-primary) 50%, transparent);
    animation: cb-pulse 2.4s ease-out infinite;
}

@keyframes cb-pulse {
    0%   { transform: scale(1); opacity: .7; }
    100% { transform: scale(1.5); opacity: 0; }
}

/* Notification badge */
.ai-chatbot-badge {
    position: absolute;
    top: 2px; right: 2px;
    width: 14px; height: 14px;
    background: #ef4444;
    border: 2px solid white;
    border-radius: 50%;
    display: none;
}

.ai-chatbot-badge.show { display: block; }

/* ── Widget Panel ───────────────────────────────────────── */
.ai-chatbot-widget {
    position: absolute;
    bottom: 80px;
    right: 0;
    width: 390px;
    max-width: calc(100vw - 48px);
    height: 580px;
    max-height: calc(100vh - 120px);
    background: #fff;
    border-radius: var(--cb-radius);
    box-shadow: 0 24px 64px rgba(0,0,0,.14), 0 8px 24px rgba(0,0,0,.08);
    border: 1px solid rgba(0,0,0,.06);
    display: none;
    flex-direction: column;
    overflow: hidden;
    transform-origin: bottom right;
}

.ai-chatbot-container.bottom-left .ai-chatbot-widget {
    right: auto;
    left: 0;
    transform-origin: bottom left;
}

.ai-chatbot-widget.active {
    display: flex;
    animation: cb-open .28s cubic-bezier(.34,1.56,.64,1) forwards;
}

@keyframes cb-open {
    from { opacity: 0; transform: scale(.88) translateY(16px); }
    to   { opacity: 1; transform: scale(1)   translateY(0); }
}

/* ── Header ─────────────────────────────────────────────── */
.ai-chatbot-header {
    background: linear-gradient(135deg, var(--cb-primary) 0%, var(--cb-primary-dark) 100%);
    padding: 18px 20px;
    display: flex;
    align-items: center;
    gap: 12px;
    flex-shrink: 0;
}

.ai-chatbot-header-avatar {
    width: 42px;
    height: 42px;
    border-radius: 50%;
    background: rgba(255,255,255,.2);
    border: 2px solid rgba(255,255,255,.4);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.ai-chatbot-header-avatar svg { width: 22px; height: 22px; color: white; }

.ai-chatbot-header-info { flex: 1; min-width: 0; }

.ai-chatbot-header-name {
    margin: 0;
    font-size: 15px;
    font-weight: 700;
    color: white;
    letter-spacing: -.02em;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.ai-chatbot-header-status {
    display: flex;
    align-items: center;
    gap: 5px;
    font-size: 12px;
    color: rgba(255,255,255,.8);
    margin-top: 2px;
    font-weight: 500;
}

.ai-chatbot-status-dot {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: #4ade80;
    box-shadow: 0 0 0 2px rgba(74,222,128,.3);
    flex-shrink: 0;
    animation: cb-blink 2s ease-in-out infinite;
}

@keyframes cb-blink {
    0%, 100% { opacity: 1; }
    50%       { opacity: .5; }
}

.ai-chatbot-header-actions { display: flex; gap: 6px; flex-shrink: 0; }

.ai-chatbot-close {
    width: 32px;
    height: 32px;
    min-width: 32px;
    min-height: 32px;
    border-radius: 50% !important;
    border: none !important;
    background: rgba(255,255,255,.15) !important;
    color: #fff !important;
    font-size: 16px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background .2s ease;
    line-height: 1;
}

.ai-chatbot-close:hover { background: rgba(255,255,255,.28); }

.ai-chatbot-close svg {
    width: 14px;
    height: 14px;
    opacity: 1;
}

/* ── Messages Area ──────────────────────────────────────── */
.ai-chatbot-messages {
    flex: 1;
    overflow-y: auto;
    padding: 20px 16px 12px;
    display: flex;
    flex-direction: column;
    gap: 4px;
    background: #f8f9fb;
    scroll-behavior: smooth;
}

/* Scrollbar */
.ai-chatbot-messages::-webkit-scrollbar { width: 4px; }
.ai-chatbot-messages::-webkit-scrollbar-track { background: transparent; }
.ai-chatbot-messages::-webkit-scrollbar-thumb { background: #d1d5db; border-radius: 4px; }
.ai-chatbot-messages::-webkit-scrollbar-thumb:hover { background: #9ca3af; }

/* ── Message Group ──────────────────────────────────────── */
.ai-chatbot-msg-group {
    display: flex;
    flex-direction: column;
    gap: 2px;
    margin-bottom: 10px;
    animation: cb-msg-in .25s ease forwards;
}

@keyframes cb-msg-in {
    from { opacity: 0; transform: translateY(10px); }
    to   { opacity: 1; transform: translateY(0); }
}

.ai-chatbot-msg-group.user  { align-items: flex-end; }
.ai-chatbot-msg-group.bot   { align-items: flex-start; }

/* Bot avatar in group */
.ai-chatbot-msg-group.bot .ai-chatbot-msg-avatar {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--cb-primary), var(--cb-primary-dark));
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    margin-bottom: 2px;
}

.ai-chatbot-msg-group.bot .ai-chatbot-msg-avatar svg {
    width: 14px;
    height: 14px;
    color: white;
}

/* ── Individual Message Bubble ──────────────────────────── */
.ai-chatbot-message {
    max-width: 82%;
    padding: 11px 15px;
    border-radius: 18px;
    font-size: 14px;
    line-height: 1.55;
    word-wrap: break-word;
    position: relative;
}

.ai-chatbot-message.user {
    background: linear-gradient(135deg, var(--cb-primary), var(--cb-primary-dark));
    color: white;
    border-bottom-right-radius: 5px;
    box-shadow: 0 2px 8px color-mix(in srgb, var(--cb-primary) 35%, transparent);
}

.ai-chatbot-message.bot {
    background: white;
    color: #1e293b;
    border: 1px solid #e2e8f0;
    border-bottom-left-radius: 5px;
    box-shadow: 0 2px 6px rgba(0,0,0,.05);
}

.ai-chatbot-message-time {
    font-size: 10.5px;
    color: #94a3b8;
    margin-top: 3px;
    padding: 0 4px;
}

.ai-chatbot-msg-group.user .ai-chatbot-message-time { text-align: right; }

/* ── Typing Indicator ───────────────────────────────────── */
.ai-chatbot-typing {
    display: none;
    align-items: center;
    gap: 6px;
    padding: 10px 15px;
    background: white;
    border: 1px solid #e2e8f0;
    border-radius: 18px;
    border-bottom-left-radius: 5px;
    max-width: 80px;
    box-shadow: 0 2px 6px rgba(0,0,0,.05);
    margin: 0 0 4px 36px;
    animation: cb-msg-in .25s ease forwards;
}

.ai-chatbot-typing.active { display: flex; }

.ai-chatbot-typing-dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: #94a3b8;
    animation: cb-typing 1.4s ease-in-out infinite;
}

.ai-chatbot-typing-dot:nth-child(2) { animation-delay: .2s; }
.ai-chatbot-typing-dot:nth-child(3) { animation-delay: .4s; }

@keyframes cb-typing {
    0%, 60%, 100% { transform: translateY(0); opacity: .5; }
    30%            { transform: translateY(-5px); opacity: 1; }
}

/* ── Quick Replies ──────────────────────────────────────── */
.ai-chatbot-quick-replies {
    padding: 0 16px 10px;
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    background: #f8f9fb;
    flex-shrink: 0;
}

.ai-chatbot-quick-reply {
    padding: 6px 13px;
    border: 1.5px solid var(--cb-primary);
    color: var(--cb-primary);
    background: white;
    border-radius: 20px;
    font-size: 12.5px;
    font-family: var(--cb-font);
    font-weight: 500;
    cursor: pointer;
    transition: all .2s ease;
    white-space: nowrap;
    max-width: 200px;
    overflow: hidden;
    text-overflow: ellipsis;
}

.ai-chatbot-quick-reply:hover {
    background: var(--cb-primary);
    color: white;
    transform: translateY(-1px);
    box-shadow: 0 4px 12px color-mix(in srgb, var(--cb-primary) 30%, transparent);
}

/* ── Input Area ─────────────────────────────────────────── */
.ai-chatbot-input-container {
    padding: 12px 16px;
    border-top: 1px solid #f1f5f9;
    background: white;
    display: flex;
    align-items: flex-end;
    gap: 10px;
    flex-shrink: 0;
}

.ai-chatbot-input-wrapper { flex: 1; position: relative; }

.ai-chatbot-input {
    width: 100%;
    padding: 11px 16px;
    border: 1.5px solid #e2e8f0;
    border-radius: 22px;
    font-size: 14px;
    font-family: var(--cb-font);
    outline: none;
    resize: none;
    max-height: 100px;
    min-height: 20px;
    line-height: 1.5;
    background: #f8fafc;
    color: #000 !important;
    caret-color: #000;
    transition: border-color .2s ease, background .2s ease, box-shadow .2s ease;
    box-sizing: border-box;
    display: block;
}

.ai-chatbot-input:focus {
    border-color: var(--cb-primary);
    background: white;
    box-shadow: 0 0 0 3px color-mix(in srgb, var(--cb-primary) 12%, transparent);
}

.ai-chatbot-input::placeholder { color: #94a3b8; }

.ai-chatbot-send {
    width: 42px;
    height: 42px;
    min-width: 42px;
    min-height: 42px;
    border-radius: 50% !important;
    border: none !important;
    background: linear-gradient(135deg, var(--cb-primary), var(--cb-primary-dark)) !important;
    color: #fff !important;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    transition: transform .2s cubic-bezier(.34,1.56,.64,1), box-shadow .2s ease, opacity .2s;
    box-shadow: 0 4px 14px color-mix(in srgb, var(--cb-primary) 40%, transparent);
}

.ai-chatbot-send svg {
    width: 18px;
    height: 18px;
    color: currentColor;
    opacity: 1;
    filter: none;
}

.ai-chatbot-send:hover {
    transform: scale(1.1);
    box-shadow: 0 6px 20px color-mix(in srgb, var(--cb-primary) 50%, transparent);
}

.ai-chatbot-send:disabled {
    opacity: .5;
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
}

/* ── Footer ─────────────────────────────────────────────── */
.ai-chatbot-footer {
    text-align: center;
    padding: 6px 16px 10px;
    font-size: 11px;
    color: #94a3b8;
    background: white;
    font-weight: 500;
    letter-spacing: .01em;
    flex-shrink: 0;
}

.ai-chatbot-footer a {
    color: inherit;
    text-decoration: none;
}

.ai-chatbot-footer a:hover { color: var(--cb-primary); }

/* ── Date Divider ───────────────────────────────────────── */
.ai-chatbot-date-divider {
    text-align: center;
    margin: 8px 0 14px;
    position: relative;
}

.ai-chatbot-date-divider span {
    background: #f8f9fb;
    padding: 0 10px;
    font-size: 11px;
    color: #94a3b8;
    font-weight: 500;
    position: relative;
    z-index: 1;
}

.ai-chatbot-date-divider::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 0; right: 0;
    height: 1px;
    background: #e2e8f0;
}

/* ── Mobile ─────────────────────────────────────────────── */
@media (max-width: 520px) {
    .ai-chatbot-container.bottom-right,
    .ai-chatbot-container.bottom-left {
        bottom: 16px;
        right: 16px;
        left: auto;
    }

    .ai-chatbot-widget {
        width: calc(100vw - 32px);
        right: 0;
        left: auto;
        height: 72vh;
        bottom: 76px;
    }

    .ai-chatbot-container.bottom-left .ai-chatbot-widget {
        left: auto;
        right: 0;
    }
}
