#cac-widget-root, .cac-inline-root {
    --cac-primary: #7c3aed;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

/* ---------- Nút bong bóng nổi ---------- */
.cac-bubble {
    position: fixed;
    bottom: 24px;
    width: 60px;
    height: 60px;
    border-radius: 50%;
    background: var(--cac-primary);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    box-shadow: 0 6px 20px rgba(0,0,0,0.2);
    z-index: 999998;
    border: none;
    transition: transform 0.15s ease;
}
.cac-bubble:hover { transform: scale(1.06); }
.cac-position-bottom-right .cac-bubble { right: 24px; }
.cac-position-bottom-left .cac-bubble { left: 24px; }
.cac-bubble svg { width: 28px; height: 28px; }

/* ---------- Cửa sổ chat ---------- */
.cac-window {
    position: fixed;
    bottom: 96px;
    width: 360px;
    max-width: calc(100vw - 32px);
    height: 500px;
    max-height: calc(100vh - 140px);
    background: #fff;
    border-radius: 16px;
    box-shadow: 0 10px 40px rgba(0,0,0,0.25);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    z-index: 999999;
    opacity: 0;
    transform: translateY(12px);
    pointer-events: none;
    transition: opacity 0.18s ease, transform 0.18s ease;
}
.cac-position-bottom-right .cac-window { right: 24px; }
.cac-position-bottom-left .cac-window { left: 24px; }
.cac-window.cac-open {
    opacity: 1;
    transform: translateY(0);
    pointer-events: auto;
}

.cac-inline-root .cac-window {
    position: static;
    width: 100%;
    max-width: 480px;
    height: 520px;
    opacity: 1;
    transform: none;
    pointer-events: auto;
    box-shadow: 0 2px 16px rgba(0,0,0,0.12);
    margin: 0 auto;
}

.cac-header {
    background: var(--cac-primary);
    color: #fff;
    padding: 14px 16px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    font-weight: 600;
    font-size: 15px;
}
.cac-header button {
    background: transparent;
    border: none;
    color: #fff;
    cursor: pointer;
    font-size: 18px;
    line-height: 1;
    opacity: 0.85;
}
.cac-header button:hover { opacity: 1; }

.cac-messages {
    flex: 1;
    overflow-y: auto;
    padding: 14px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    background: #f7f7fb;
}

.cac-msg {
    max-width: 82%;
    padding: 9px 13px;
    border-radius: 14px;
    font-size: 14px;
    line-height: 1.45;
    white-space: pre-wrap;
    word-wrap: break-word;
}
.cac-msg.user {
    align-self: flex-end;
    background: var(--cac-primary);
    color: #fff;
    border-bottom-right-radius: 4px;
}
.cac-msg.assistant {
    align-self: flex-start;
    background: #fff;
    color: #222;
    border: 1px solid #e7e7ee;
    border-bottom-left-radius: 4px;
}
.cac-msg.typing { display: flex; gap: 4px; align-items: center; }
.cac-dot {
    width: 6px; height: 6px; border-radius: 50%; background: #999;
    animation: cac-blink 1.2s infinite ease-in-out;
}
.cac-dot:nth-child(2) { animation-delay: 0.2s; }
.cac-dot:nth-child(3) { animation-delay: 0.4s; }
@keyframes cac-blink { 0%, 80%, 100% { opacity: 0.3; } 40% { opacity: 1; } }

.cac-error {
    align-self: center;
    color: #b42318;
    background: #fef3f2;
    border: 1px solid #fecdca;
    font-size: 13px;
    padding: 8px 12px;
    border-radius: 10px;
}

.cac-input-row {
    display: flex;
    align-items: flex-end;
    gap: 8px;
    padding: 10px;
    border-top: 1px solid #eee;
    background: #fff;
}
.cac-input-row textarea {
    flex: 1;
    resize: none;
    border: 1px solid #ddd;
    border-radius: 10px;
    padding: 9px 12px;
    font-size: 14px;
    font-family: inherit;
    max-height: 90px;
    outline: none;
}
.cac-input-row textarea:focus { border-color: var(--cac-primary); }
.cac-send-btn {
    background: var(--cac-primary);
    border: none;
    color: #fff;
    width: 40px;
    height: 40px;
    border-radius: 10px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}
.cac-send-btn:disabled { opacity: 0.5; cursor: not-allowed; }
.cac-send-btn svg { width: 18px; height: 18px; }
