
/* ── CHAT BUTTON ─────────────────────────────────────────────────────────── */
#ai-chat-btn {
    bottom: 24px;
    right: 24px;
    width: 60px;
    height: 60px;
    z-index: 1050;
    font-size: 26px;
    background: linear-gradient(135deg, #3b82f6 0%, #1e40af 100%);
    border: none;
    box-shadow: 0 10px 30px rgba(59, 130, 246, 0.4);
    transition: all 0.25s ease;
}
#ai-chat-btn:hover {
    transform: scale(1.08);
    box-shadow: 0 15px 35px rgba(59, 130, 246, 0.55);
}

/* ── CHAT WINDOW ─────────────────────────────────────────────────────────── */
#ai-chat-window {
    width: 420px;
    max-width: calc(100vw - 32px);
    z-index: 1050;
    border-radius: 18px;
    overflow: hidden;
    border: none;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.18);
    bottom: 100px;
    right: 24px;
    display: none;
    flex-direction: column;
}

#ai-chat-window .card-header {
    background: linear-gradient(135deg, #3b82f6 0%, #1e40af 100%) !important;
    padding: 14px 18px !important;
    border: none;
}

#ai-chat-window .card-footer {
    background: #fff !important;
    border-top: 1px solid #f1f5f9 !important;
    padding: 12px !important;
}

/* ── CHAT BOX SCROLL AREA ────────────────────────────────────────────────── */
#chat-box {
    height: 440px;
    overflow-y: auto;
    padding: 16px !important;
    background: #f8fafc !important;
}

#chat-box::-webkit-scrollbar { width: 6px; }
#chat-box::-webkit-scrollbar-thumb { background: #cbd5e1; border-radius: 4px; }
#chat-box::-webkit-scrollbar-thumb:hover { background: #94a3b8; }

/* ── MESSAGE BUBBLES ─────────────────────────────────────────────────────── */
.msg-bubble {
    padding: 10px 14px;
    border-radius: 16px;
    max-width: 85%;
    word-wrap: break-word;
    font-size: 0.92rem;
    line-height: 1.45;
    box-shadow: 0 2px 6px rgba(0,0,0,0.04);
    animation: msg-fade-in 0.25s ease;
}

.msg-user {
    background: linear-gradient(135deg, #3b82f6 0%, #2563eb 100%);
    color: #fff;
    border-bottom-right-radius: 6px;
}

.msg-bot {
    background: #fff;
    color: #1e293b;
    border: 1px solid #f1f5f9;
    border-bottom-left-radius: 6px;
}

.msg-bot .msg-content {
    margin-top: 4px;
}

.msg-bot strong { color: #1e40af; }
.msg-bot em     { color: #475569; }
.msg-bot code   {
    background: #f1f5f9;
    color: #b45309;
    padding: 2px 6px;
    border-radius: 4px;
    font-size: 0.86em;
    font-family: 'Courier New', monospace;
}

.msg-bot ul {
    margin: 6px 0;
    padding-left: 20px;
}
.msg-bot ul li {
    margin-bottom: 3px;
}

/* Source badge — chỉ hiện cho rule/cache/fallback */
.msg-source {
    margin-top: 6px;
    font-size: 0.7rem;
    color: #94a3b8;
    text-align: right;
    font-style: italic;
}

/* ── TYPING DOTS ANIMATION ───────────────────────────────────────────────── */
.typing-dots {
    display: inline-flex;
    gap: 4px;
    align-items: center;
    padding: 4px 2px;
}
.typing-dots span {
    width: 8px;
    height: 8px;
    background: #94a3b8;
    border-radius: 50%;
    display: inline-block;
    animation: typing-bounce 1.2s infinite ease-in-out;
}
.typing-dots span:nth-child(2) { animation-delay: 0.2s; }
.typing-dots span:nth-child(3) { animation-delay: 0.4s; }

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

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

/* ── INPUT AREA ──────────────────────────────────────────────────────────── */
#user-input {
    border-radius: 24px !important;
    border: 1px solid #e2e8f0 !important;
    padding: 10px 16px !important;
    font-size: 0.92rem !important;
}
#user-input:focus {
    border-color: #3b82f6 !important;
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1) !important;
}

#ai-chat-window .btn-send {
    border-radius: 24px;
    padding: 8px 22px;
    font-weight: 600;
    background: linear-gradient(135deg, #3b82f6 0%, #2563eb 100%);
    border: none;
    color: #fff;
}
#ai-chat-window .btn-send:hover {
    background: linear-gradient(135deg, #2563eb 0%, #1e40af 100%);
}

.retry-btn {
    border-radius: 20px !important;
    font-size: 0.85rem !important;
}

/* ── MOBILE RESPONSIVE ───────────────────────────────────────────────────── */
@media (max-width: 576px) {
    #ai-chat-window {
        width: calc(100vw - 24px);
        bottom: 92px;
        right: 12px;
    }
    #chat-box { height: 60vh; }
    .msg-bubble { max-width: 90%; }
}
