#asc-chat-bubble {
    position: fixed;
    bottom: 24px;
    right: 24px;
    width: 56px;
    height: 56px;
    background: var(--asc-primary, #2563eb);
    color: #fff;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 26px;
    cursor: pointer;
    box-shadow: 0 4px 14px rgba(0,0,0,0.25);
    z-index: 99998;
    transition: transform .15s ease;
}
#asc-chat-bubble:hover { transform: scale(1.08); }

#asc-unread-badge {
    position: absolute;
    top: -4px;
    right: -4px;
    background: #ef4444;
    color: #fff;
    font-size: 11px;
    font-weight: 700;
    min-width: 18px;
    height: 18px;
    border-radius: 9px;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0 4px;
    border: 2px solid #fff;
}
#asc-unread-badge.asc-hidden { display: none; }

#asc-chat-box {
    position: fixed;
    bottom: 90px;
    right: 24px;
    width: 380px;
    max-height: 560px;
    background: #fff;
    border-radius: 14px;
    box-shadow: 0 8px 30px rgba(0,0,0,0.25);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    z-index: 99999;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Arial, sans-serif;
}
#asc-chat-box.asc-hidden { display: none; }

#asc-chat-header {
    background: var(--asc-primary, #2563eb);
    color: #fff;
    padding: 12px 16px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-weight: 600;
}
#asc-chat-close { cursor: pointer; font-size: 20px; line-height: 1; }

#asc-chat-messages {
    flex: 1;
    padding: 12px;
    overflow-y: auto;
    max-height: 420px;
    background: #f8fafc;
}

.asc-msg { margin-bottom: 10px; display: flex; }
.asc-msg.asc-user { justify-content: flex-end; }
.asc-msg-bubble {
    max-width: 88%;
    padding: 8px 12px;
    border-radius: 10px;
    font-size: 14px;
    line-height: 1.45;
}
.asc-msg.asc-bot .asc-msg-bubble { background: #e5e7eb; color: #111; border-top-left-radius: 2px; }
.asc-msg.asc-user .asc-msg-bubble { background: var(--asc-primary, #2563eb); color: #fff; border-top-right-radius: 2px; white-space: pre-wrap; }

/* Render đẹp nội dung markdown AI trả về (bảng, list, bold...) */
.asc-msg-bubble p { margin: 0 0 8px; }
.asc-msg-bubble p:last-child { margin-bottom: 0; }
.asc-msg-bubble ul, .asc-msg-bubble ol { margin: 4px 0 8px; padding-left: 20px; }
.asc-msg-bubble strong { font-weight: 700; }
.asc-msg-bubble .asc-table-wrap {
    overflow-x: auto;
    margin: 6px 0;
    border-radius: 8px;
    border: 1px solid #d1d5db;
}
.asc-msg-bubble table {
    border-collapse: collapse;
    width: 100%;
    font-size: 13px;
    background: #fff;
}
.asc-msg-bubble th, .asc-msg-bubble td {
    border: 1px solid #e5e7eb;
    padding: 6px 8px;
    text-align: left;
    vertical-align: top;
    white-space: normal;
}
.asc-msg-bubble th {
    background: var(--asc-primary, #2563eb);
    color: #fff;
    font-weight: 600;
}
.asc-msg-bubble tr:nth-child(even) td { background: #f8fafc; }

.asc-quick-replies {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin: 4px 0 10px;
    padding-left: 2px;
}
.asc-quick-reply-btn {
    background: #fff;
    border: 1px solid var(--asc-primary, #2563eb);
    color: var(--asc-primary, #2563eb);
    border-radius: 16px;
    padding: 6px 12px;
    font-size: 13px;
    cursor: pointer;
}
.asc-quick-reply-btn:hover { background: var(--asc-primary, #2563eb); color: #fff; }

#asc-chat-typing {
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 6px 16px;
    background: #f8fafc;
}
#asc-chat-typing.asc-hidden { display: none; }
#asc-chat-typing span {
    width: 6px;
    height: 6px;
    background: #94a3b8;
    border-radius: 50%;
    animation: asc-typing-bounce 1.2s infinite ease-in-out;
}
#asc-chat-typing span:nth-child(2) { animation-delay: .2s; }
#asc-chat-typing span:nth-child(3) { animation-delay: .4s; }
@keyframes asc-typing-bounce {
    0%, 60%, 100% { transform: translateY(0); opacity: .5; }
    30% { transform: translateY(-4px); opacity: 1; }
}

#asc-chat-input-area {
    display: flex;
    border-top: 1px solid #e5e7eb;
    padding: 8px;
    background: #fff;
}
#asc-chat-input {
    flex: 1;
    border: 1px solid #d1d5db;
    border-radius: 8px;
    padding: 8px 10px;
    font-size: 14px;
    resize: none;
    max-height: 70px;
}
#asc-chat-send {
    margin-left: 8px;
    background: var(--asc-primary, #2563eb);
    color: #fff;
    border: none;
    border-radius: 8px;
    padding: 0 14px;
    cursor: pointer;
    font-size: 14px;
}
#asc-chat-send:hover { background: var(--asc-primary-dark, #1d4ed8); }
#asc-chat-send:disabled { background: #93c5fd; cursor: not-allowed; }

@media (max-width: 480px) {
    #asc-chat-box {
        width: 100vw;
        height: 100vh;
        max-height: 100vh;
        right: 0;
        bottom: 0;
        left: 0;
        top: 0;
        border-radius: 0;
    }
    #asc-chat-messages { max-height: none; }
}
