/* ============================================
   F11: Sales Chatbot Widget
   ============================================ */

.mb-chatbot-toggle {
    position: fixed;
    bottom: 24px;
    right: 24px;
    width: 56px;
    height: 56px;
    border-radius: 50%;
    background: var(--mb-primary, #1B4D8E);
    color: #fff;
    border: none;
    cursor: pointer;
    box-shadow: 0 4px 16px rgba(0,0,0,0.2);
    z-index: 9998;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.2s, box-shadow 0.2s;
}

.mb-chatbot-toggle:hover {
    transform: scale(1.05);
    box-shadow: 0 6px 20px rgba(0,0,0,0.25);
}

/* Bounce animation to invite tap on mobile */
.mb-chatbot-toggle.mb-chatbot-bounce {
    animation: mb-chatbot-bounce 1s ease-in-out 3;
}

@keyframes mb-chatbot-bounce {
    0%, 100% { transform: translateY(0); }
    30% { transform: translateY(-12px); }
    50% { transform: translateY(0); }
    70% { transform: translateY(-6px); }
}

.mb-chatbot-toggle svg { width: 24px; height: 24px; fill: #fff; }

.mb-chatbot-panel {
    position: fixed;
    bottom: 96px;
    right: 24px;
    width: 380px;
    height: 520px;
    background: #fff;
    border-radius: 16px;
    box-shadow: 0 8px 32px rgba(0,0,0,0.15);
    z-index: 9999;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.mb-chatbot-panel[hidden] { display: none; }

.mb-chatbot-header {
    background: var(--mb-primary, #1B4D8E);
    color: #fff;
    padding: 16px 20px;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.mb-chatbot-header-info strong { font-size: 16px; display: block; }
.mb-chatbot-header-info span { font-size: 12px; opacity: 0.8; }

.mb-chatbot-minimize {
    background: none;
    border: none;
    color: #fff;
    font-size: 24px;
    cursor: pointer;
    padding: 0;
    line-height: 1;
    opacity: 0.8;
}

.mb-chatbot-minimize:hover { opacity: 1; }

.mb-chatbot-messages {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.mb-chat-msg {
    max-width: 85%;
    padding: 10px 14px;
    border-radius: 12px;
    font-size: 14px;
    line-height: 1.5;
    word-wrap: break-word;
}

.mb-chat-msg.assistant {
    background: var(--mb-light, #F3F4F6);
    color: var(--mb-dark, #1F2937);
    align-self: flex-start;
    border-bottom-left-radius: 4px;
}

.mb-chat-msg.user {
    background: var(--mb-primary, #1B4D8E);
    color: #fff;
    align-self: flex-end;
    border-bottom-right-radius: 4px;
}

.mb-chat-typing {
    display: flex;
    gap: 4px;
    padding: 10px 14px;
    align-self: flex-start;
}

.mb-chat-typing span {
    width: 8px;
    height: 8px;
    background: #94a3b8;
    border-radius: 50%;
    animation: mb-typing-bounce 1.4s infinite;
}

.mb-chat-typing span:nth-child(2) { animation-delay: 0.2s; }
.mb-chat-typing span:nth-child(3) { animation-delay: 0.4s; }

@keyframes mb-typing-bounce {
    0%, 80%, 100% { transform: translateY(0); }
    40% { transform: translateY(-6px); }
}

.mb-chatbot-input {
    display: flex;
    border-top: 1px solid #e5e7eb;
    padding: 12px 16px;
    gap: 8px;
}

.mb-chatbot-input input {
    flex: 1;
    border: 1px solid #d1d5db;
    border-radius: 8px;
    padding: 10px 14px;
    font-size: 14px;
    font-family: var(--mb-font, 'Inter', sans-serif);
    outline: none;
}

.mb-chatbot-input input:focus { border-color: var(--mb-primary-light, #3B82F6); }

.mb-chatbot-input button {
    background: var(--mb-accent, #10B981);
    color: #fff;
    border: none;
    border-radius: 8px;
    padding: 10px 14px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s;
}

.mb-chatbot-input button:hover { background: var(--mb-accent-hover, #059669); }
.mb-chatbot-input button svg { width: 18px; height: 18px; fill: #fff; }

/* Feedback buttons */
.mb-chat-feedback {
    display: flex;
    gap: 4px;
    margin-top: 6px;
}

.mb-feedback-btn {
    background: none;
    border: 1px solid #d1d5db;
    border-radius: 4px;
    padding: 3px 6px;
    cursor: pointer;
    color: #6b7280;
    display: flex;
    align-items: center;
    transition: color 0.15s, border-color 0.15s, background 0.15s;
}

.mb-feedback-btn:hover { color: #374151; border-color: #9ca3af; background: #e5e7eb; }

.mb-feedback-btn.mb-feedback-selected {
    color: var(--mb-primary, #1B4D8E);
    border-color: var(--mb-primary, #1B4D8E);
    cursor: default;
}

.mb-feedback-btn.mb-feedback-dimmed {
    opacity: 0.3;
    cursor: default;
    pointer-events: none;
}

.mb-feedback-btn:disabled:not(.mb-feedback-selected):not(.mb-feedback-dimmed) {
    opacity: 0.5;
    cursor: wait;
}

/* Mobile */
@media (max-width: 767px) {
    .mb-chatbot-panel {
        width: 100%;
        height: calc(100vh - 80px);
        bottom: 0;
        right: 0;
        border-radius: 16px 16px 0 0;
    }
    .mb-chatbot-toggle { bottom: 16px; right: 16px; }
}

/* RTL */
[dir="rtl"] .mb-chatbot-toggle { right: auto; left: 24px; }
[dir="rtl"] .mb-chatbot-panel { right: auto; left: 24px; }
[dir="rtl"] .mb-chat-msg.user { align-self: flex-start; border-bottom-right-radius: 12px; border-bottom-left-radius: 4px; }
[dir="rtl"] .mb-chat-msg.assistant { align-self: flex-end; border-bottom-left-radius: 12px; border-bottom-right-radius: 4px; }
