/* AI Chatbot WP - Floating & Inline */
.ai-chatbot-wp-wrap {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen-Sans, Ubuntu, sans-serif;
    font-size: 15px;
    box-sizing: border-box;
}
.ai-chatbot-wp-wrap *,
.ai-chatbot-wp-wrap *::before,
.ai-chatbot-wp-wrap *::after {
    box-sizing: border-box;
}

/* Floating button */
.ai-chatbot-wp-float {
    position: fixed;
    bottom: 24px;
    right: 24px;
    z-index: 999998;
}
.ai-chatbot-wp-float-btn {
    width: 56px;
    height: 56px;
    border-radius: 50%;
    border: none;
    background: linear-gradient(135deg, #2563eb 0%, #1d4ed8 100%);
    color: #fff;
    cursor: pointer;
    box-shadow: 0 4px 14px rgba(37, 99, 235, 0.45);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.2s, box-shadow 0.2s;
}
.ai-chatbot-wp-float-btn:hover {
    transform: scale(1.05);
    box-shadow: 0 6px 20px rgba(37, 99, 235, 0.5);
}
.ai-chatbot-wp-float-btn svg {
    width: 28px;
    height: 28px;
}

/* Panel */
.ai-chatbot-wp-panel {
    position: fixed;
    bottom: 90px;
    right: 24px;
    width: 380px;
    max-width: calc(100vw - 48px);
    height: 500px;
    max-height: calc(100vh - 140px);
    background: #fff;
    border-radius: 16px;
    box-shadow: 0 12px 48px rgba(0, 0, 0, 0.15);
    display: flex;
    flex-direction: column;
    z-index: 999997;
    overflow: hidden;
    opacity: 0;
    visibility: hidden;
    transform: translateY(10px) scale(0.96);
    transition: opacity 0.2s, visibility 0.2s, transform 0.2s;
}
.ai-chatbot-wp-panel.is-open {
    opacity: 1;
    visibility: visible;
    transform: translateY(0) scale(1);
}

/* Inline: panel inside page */
.ai-chatbot-wp-inline .ai-chatbot-wp-panel {
    position: relative;
    bottom: auto;
    right: auto;
    width: 100%;
    height: 480px;
    max-height: 70vh;
    opacity: 1;
    visibility: visible;
    transform: none;
}
.ai-chatbot-wp-inline .ai-chatbot-wp-float {
    display: none;
}

/* Header */
.ai-chatbot-wp-header {
    padding: 14px 16px;
    background: linear-gradient(135deg, #2563eb 0%, #1d4ed8 100%);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-shrink: 0;
}
.ai-chatbot-wp-header h3 {
    margin: 0;
    font-size: 1rem;
    font-weight: 600;
}
.ai-chatbot-wp-close {
    background: none;
    border: none;
    color: inherit;
    cursor: pointer;
    padding: 4px;
    opacity: 0.9;
}
.ai-chatbot-wp-close:hover {
    opacity: 1;
}
.ai-chatbot-wp-close svg {
    width: 22px;
    height: 22px;
}

/* Messages area */
.ai-chatbot-wp-messages {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
    background: #f8fafc;
    display: flex;
    flex-direction: column;
    gap: 12px;
}
.ai-chatbot-wp-msg {
    max-width: 85%;
    padding: 10px 14px;
    border-radius: 14px;
    line-height: 1.5;
    word-wrap: break-word;
}
.ai-chatbot-wp-msg.user {
    align-self: flex-end;
    background: #2563eb;
    color: #fff;
    border-bottom-right-radius: 4px;
}
.ai-chatbot-wp-msg.bot {
    align-self: flex-start;
    background: #fff;
    color: #1e293b;
    border: 1px solid #e2e8f0;
    border-bottom-left-radius: 4px;
}
.ai-chatbot-wp-msg.error {
    align-self: flex-start;
    background: #fef2f2;
    color: #b91c1c;
    border: 1px solid #fecaca;
}
.ai-chatbot-wp-msg .content {
    white-space: pre-wrap;
}

/* Input area */
.ai-chatbot-wp-input-wrap {
    padding: 12px 16px;
    background: #fff;
    border-top: 1px solid #e2e8f0;
    flex-shrink: 0;
}
.ai-chatbot-wp-input-row {
    display: flex;
    gap: 8px;
    align-items: flex-end;
}
.ai-chatbot-wp-input {
    flex: 1;
    padding: 12px 14px;
    border: 1px solid #e2e8f0;
    border-radius: 12px;
    font-size: 15px;
    resize: none;
    min-height: 44px;
    max-height: 120px;
    font-family: inherit;
    transition: border-color 0.2s;
}
.ai-chatbot-wp-input:focus {
    outline: none;
    border-color: #2563eb;
}
.ai-chatbot-wp-send {
    width: 44px;
    height: 44px;
    border: none;
    border-radius: 12px;
    background: #2563eb;
    color: #fff;
    cursor: pointer;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s;
}
.ai-chatbot-wp-send:hover:not(:disabled) {
    background: #1d4ed8;
}
.ai-chatbot-wp-send:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}
.ai-chatbot-wp-send svg {
    width: 20px;
    height: 20px;
}

/* Typing indicator */
.ai-chatbot-wp-typing {
    align-self: flex-start;
    padding: 12px 18px;
    background: #fff;
    border: 1px solid #e2e8f0;
    border-radius: 14px;
    border-bottom-left-radius: 4px;
}
.ai-chatbot-wp-typing span {
    display: inline-block;
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: #94a3b8;
    margin: 0 2px;
    animation: ai-chatbot-wp-bounce 0.6s ease-in-out infinite;
}
.ai-chatbot-wp-typing span:nth-of-type(2) { animation-delay: 0.1s; }
.ai-chatbot-wp-typing span:nth-of-type(3) { animation-delay: 0.2s; }
@keyframes ai-chatbot-wp-bounce {
    0%, 80%, 100% { transform: translateY(0); }
    40% { transform: translateY(-6px); }
}

/* ===== UI Enhancements (JS đã render thêm avatar/bubble/status) ===== */

.ai-chatbot-wp-header-left {
    display: flex;
    align-items: center;
    gap: 12px;
}

.ai-chatbot-wp-status {
    font-size: 12px;
    font-weight: 700;
    color: rgba(255, 255, 255, 0.95);
    background: rgba(255, 255, 255, 0.16);
    border: 1px solid rgba(255, 255, 255, 0.22);
    padding: 4px 10px;
    border-radius: 999px;
    letter-spacing: 0.2px;
}

.ai-chatbot-wp-messages {
    /* giữ nguyên padding/cấu trúc cũ; chỉ làm đẹp nền */
    background:
        radial-gradient(1200px 450px at 20% -10%, rgba(37, 99, 235, 0.12), transparent 60%),
        radial-gradient(900px 380px at 90% 0%, rgba(29, 78, 216, 0.10), transparent 55%),
        #f8fafc;
}

/* Thay cách hiển thị tin nhắn để có avatar + bubble */
.ai-chatbot-wp-msg {
    position: relative;
    max-width: 88%;
    padding: 0;
    border-radius: 16px;
    display: flex;
    align-items: flex-end;
    gap: 10px;
}

.ai-chatbot-wp-avatar {
    width: 30px;
    height: 30px;
    border-radius: 999px;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 11px;
    font-weight: 800;
    border: 1px solid #e2e8f0;
    background: rgba(255, 255, 255, 0.95);
    color: #1d4ed8;
}

.ai-chatbot-wp-bubble {
    padding: 11px 14px;
    border-radius: 16px;
    line-height: 1.5;
    word-wrap: break-word;
}

.ai-chatbot-wp-msg.user {
    align-self: flex-end;
    background: transparent;
    color: inherit;
    flex-direction: row-reverse;
}

.ai-chatbot-wp-msg.bot {
    align-self: flex-start;
}

.ai-chatbot-wp-msg.error {
    align-self: flex-start;
}

.ai-chatbot-wp-msg.user .ai-chatbot-wp-bubble {
    background: linear-gradient(135deg, #2563eb 0%, #1d4ed8 100%);
    color: #fff;
    border-bottom-right-radius: 8px;
}

.ai-chatbot-wp-msg.bot .ai-chatbot-wp-bubble {
    background: #fff;
    color: #1e293b;
    border: 1px solid #e2e8f0;
    border-bottom-left-radius: 8px;
}

.ai-chatbot-wp-msg.error .ai-chatbot-wp-bubble {
    background: linear-gradient(180deg, #fff5f5 0%, #fef2f2 100%);
    color: #b91c1c;
    border: 1px solid #fecaca;
    border-bottom-left-radius: 8px;
}

/* typing indicator: JS hiện label + 3 chấm */
.ai-chatbot-wp-typing {
    display: flex;
    align-items: center;
    gap: 10px;
}

.ai-chatbot-wp-typing-label {
    font-size: 12px;
    font-weight: 800;
    color: #64748b;
    white-space: nowrap;
}

/* tránh xung đột style cũ */
.ai-chatbot-wp-msg .content {
    white-space: pre-wrap;
}
