/* ============================================================
   AI Sales Chatbox — ai-chatbox.css
   Scoped under #ai-chatbox-widget to avoid global conflicts
   ============================================================ */

/* ── Toggle button ─────────────────────────────────────────── */
#ai-chatbox-widget {
    position: fixed;
    bottom: 24px;
    right: 24px;
    z-index: 9999;
    font-family: 'Be Vietnam Pro', 'Segoe UI', Arial, sans-serif;
}

.ai-chat-toggle {
    width: 56px;
    height: 56px;
    border-radius: 50%;
    background: #C62828;
    border: none;
    cursor: pointer;
    box-shadow: 0 4px 16px rgba(198,40,40,0.45);
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    transition: transform 0.2s, box-shadow 0.2s;
    outline: none;
}
.ai-chat-toggle:hover {
    transform: scale(1.08);
    box-shadow: 0 6px 20px rgba(198,40,40,0.55);
}
.ai-chat-toggle svg { color: #fff; }

.ai-chat-badge {
    position: absolute;
    top: -4px;
    right: -4px;
    background: #ff6b35;
    color: #fff;
    border-radius: 10px;
    font-size: 11px;
    font-weight: 700;
    min-width: 18px;
    height: 18px;
    line-height: 18px;
    text-align: center;
    padding: 0 4px;
    border: 2px solid #fff;
}

/* ── Chat window ───────────────────────────────────────────── */
.ai-chat-window {
    position: absolute;
    bottom: 68px;
    right: 0;
    width: 360px;
    max-height: 540px;
    background: #fff;
    border-radius: 16px;
    box-shadow: 0 8px 32px rgba(0,0,0,0.18);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    animation: ai-slide-up 0.25s ease;
}

@keyframes ai-slide-up {
    from { opacity: 0; transform: translateY(16px); }
    to   { opacity: 1; transform: translateY(0); }
}

/* ── Header ────────────────────────────────────────────────── */
.ai-chat-header {
    background: linear-gradient(135deg, #C62828 0%, #b71c1c 100%);
    padding: 14px 16px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-shrink: 0;
}
.ai-chat-header-info {
    display: flex;
    align-items: center;
    gap: 10px;
}
.ai-chat-avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: rgba(255,255,255,0.25);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    flex-shrink: 0;
}
.ai-chat-title {
    color: #fff;
    font-weight: 700;
    font-size: 14px;
    line-height: 1.3;
}
.ai-chat-status {
    color: rgba(255,255,255,0.8);
    font-size: 11px;
    display: flex;
    align-items: center;
    gap: 4px;
}
.ai-chat-status::before {
    content: '';
    width: 7px;
    height: 7px;
    background: #69f0ae;
    border-radius: 50%;
    display: inline-block;
}
.ai-chat-reset {
    background: none;
    border: none;
    color: rgba(255,255,255,0.5);
    font-size: 15px;
    line-height: 1;
    cursor: pointer;
    padding: 0 4px;
    transition: color 0.15s;
    outline: none;
    margin-right: 2px;
}
.ai-chat-reset:hover { color: rgba(255,255,255,0.9); }

.ai-chat-close {
    background: none;
    border: none;
    color: rgba(255,255,255,0.85);
    font-size: 22px;
    line-height: 1;
    cursor: pointer;
    padding: 0 4px;
    transition: color 0.15s;
    outline: none;
}
.ai-chat-close:hover { color: #fff; }

/* ── Message list ──────────────────────────────────────────── */
.ai-chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 14px 14px 8px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    min-height: 160px;
    max-height: 280px;
    scroll-behavior: smooth;
}
.ai-chat-messages::-webkit-scrollbar { width: 4px; }
.ai-chat-messages::-webkit-scrollbar-track { background: transparent; }
.ai-chat-messages::-webkit-scrollbar-thumb { background: #e0e0e0; border-radius: 2px; }

.ai-msg {
    display: flex;
    gap: 8px;
    max-width: 88%;
}
.ai-msg-bot { align-self: flex-start; }
.ai-msg-user { align-self: flex-end; flex-direction: row-reverse; }

.ai-msg-bubble {
    padding: 9px 13px;
    border-radius: 14px;
    font-size: 13.5px;
    line-height: 1.55;
    word-break: break-word;
    white-space: pre-line;
}
.ai-msg-bot .ai-msg-bubble {
    background: #f5f5f5;
    color: #212121;
    border-bottom-left-radius: 4px;
}
.ai-msg-user .ai-msg-bubble {
    background: #C62828;
    color: #fff;
    border-bottom-right-radius: 4px;
}

/* Zalo contact card */
.ai-zalo-card {
    background: #e3f2fd;
    border: 1px solid #90caf9;
    border-radius: 10px;
    padding: 10px 12px;
    margin-top: 6px;
    font-size: 13px;
}
.ai-zalo-card a {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    background: #0068ff;
    color: #fff;
    border-radius: 6px;
    padding: 6px 12px;
    font-size: 12px;
    font-weight: 600;
    text-decoration: none;
    margin-top: 8px;
    margin-right: 6px;
}
.ai-zalo-card a:hover { background: #0054cc; }

/* Typing indicator */
.ai-typing {
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 10px 14px;
    background: #f5f5f5;
    border-radius: 14px;
    border-bottom-left-radius: 4px;
    width: fit-content;
}
.ai-typing span {
    width: 7px;
    height: 7px;
    background: #bdbdbd;
    border-radius: 50%;
    display: inline-block;
    animation: ai-bounce 1.2s infinite;
}
.ai-typing span:nth-child(2) { animation-delay: 0.2s; }
.ai-typing span:nth-child(3) { animation-delay: 0.4s; }

@keyframes ai-bounce {
    0%, 60%, 100% { transform: translateY(0); }
    30%            { transform: translateY(-6px); }
}

/* ── Quick buttons ─────────────────────────────────────────── */
.ai-chat-quick-buttons {
    padding: 6px 12px 8px;
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    border-top: 1px solid #f0f0f0;
    flex-shrink: 0;
}
.ai-quick-btn {
    background: #fff;
    border: 1.5px solid #C62828;
    color: #C62828;
    border-radius: 16px;
    padding: 5px 12px;
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.15s, color 0.15s;
    white-space: nowrap;
    outline: none;
}
.ai-quick-btn:hover {
    background: #C62828;
    color: #fff;
}

/* ── Input row ─────────────────────────────────────────────── */
.ai-chat-input-row {
    display: flex;
    align-items: flex-end;
    gap: 8px;
    padding: 8px 12px 12px;
    border-top: 1px solid #f0f0f0;
    flex-shrink: 0;
}
.ai-chat-input {
    flex: 1;
    border: 1.5px solid #e0e0e0;
    border-radius: 20px;
    padding: 8px 14px;
    font-size: 13.5px;
    resize: none;
    outline: none;
    font-family: inherit;
    line-height: 1.4;
    max-height: 90px;
    overflow-y: auto;
    transition: border-color 0.15s;
}
.ai-chat-input:focus { border-color: #C62828; }
.ai-chat-input::placeholder { color: #9e9e9e; }

.ai-chat-send-btn {
    width: 38px;
    height: 38px;
    border-radius: 50%;
    background: #C62828;
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    transition: background 0.15s, transform 0.15s;
    outline: none;
}
.ai-chat-send-btn:hover { background: #b71c1c; transform: scale(1.05); }
.ai-chat-send-btn:disabled { background: #bdbdbd; cursor: default; transform: none; }
.ai-chat-send-btn svg { color: #fff; }

/* ── Product context card ──────────────────────────────────── */
.ai-product-card {
    background: #fff8f0;
    border: 1.5px solid #e8820c;
    border-radius: 10px;
    padding: 10px 12px;
    margin-top: 8px;
    font-size: 13px;
}
.ai-product-card-name {
    font-weight: 700;
    color: #1f2937;
    font-size: 13px;
    line-height: 1.4;
    margin-bottom: 4px;
}
.ai-product-card-price {
    color: #C62828;
    font-weight: 700;
    font-size: 14px;
    margin-bottom: 8px;
}
.ai-product-card-specs {
    list-style: none;
    padding: 0;
    margin: 0 0 8px;
    font-size: 12px;
    color: #444;
    line-height: 1.7;
}
.ai-product-card-specs li { padding: 1px 0; }
.ai-spec-label { color: #888; font-weight: 600; }

.ai-product-card-actions {
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
}
.ai-product-card-btn {
    display: inline-block;
    border-radius: 6px;
    padding: 5px 12px;
    font-size: 12px;
    font-weight: 600;
    text-decoration: none;
    cursor: pointer;
    white-space: nowrap;
}
.ai-product-card-btn-view {
    background: #1a3a5c;
    color: #fff;
}
.ai-product-card-btn-view:hover { background: #14304e; color: #fff; }
.ai-product-card-btn-quote {
    background: #C62828;
    color: #fff;
}
.ai-product-card-btn-quote:hover { background: #b71c1c; color: #fff; }

/* ── Action links (cart context etc.) ─────────────────────── */
.ai-action-links {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-top: 8px;
}
.ai-action-link {
    display: inline-block;
    background: #e3f2fd;
    border: 1px solid #90caf9;
    color: #1565c0;
    border-radius: 16px;
    padding: 5px 14px;
    font-size: 12px;
    font-weight: 600;
    text-decoration: none;
    white-space: nowrap;
}
.ai-action-link:hover { background: #bbdefb; color: #0d47a1; }

/* ── Mobile responsive ─────────────────────────────────────── */
@media (max-width: 480px) {
    #ai-chatbox-widget {
        bottom: 16px;
        right: 12px;
    }
    .ai-chat-window {
        position: fixed;
        bottom: 82px;
        right: 12px;
        width: calc(100vw - 24px);
        max-width: 360px;
        max-height: 62vh;
        border-radius: 16px;
        box-shadow: 0 8px 32px rgba(0,0,0,0.18);
    }
    .ai-chat-messages {
        max-height: calc(62vh - 220px);
    }
}
