/* ==========================================================================
   MBT Chatbot Pro - Streamlined Stylesheet v4.1.0
   ========================================================================== */

/* --- BIẾN MÀU SẮC & VỊ TRÍ (CSS Variables) --- */
:root {
    --mbt-chat-header-bg: #d93025;
    --mbt-chat-user-msg-bg: #0073aa;
    --mbt-chat-bot-msg-bg: #f1f3f4;
    --mbt-chat-send-btn-bg: #0073aa;
    --mbt-suggestion-bg-color: #ffffff;
    --mbt-suggestion-text-color: #333333;
    --mbt-suggestion-border-color: #e0e0e0;
    --mbt-suggestion-font-size: 14px;
    --mbt-chat-pos-top: auto;
    --mbt-chat-pos-bottom: 20px;
    --mbt-chat-pos-left: auto;
    --mbt-chat-pos-right: 20px;
    --mbt-icon-size-desktop: 56px;
    --mbt-icon-size-mobile: 50px;
}

/* --- HIỆU ỨNG ANIMATION --- */
@keyframes slideInUp { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: translateY(0); } }
@keyframes ellipsis { 0% { content: "."; } 33% { content: ".."; } 66% { content: "..."; } 100% { content: "."; } }
@keyframes mbt-pulse {
    0% { transform: scale(1); }
    50% { transform: scale(1.1); }
    100% { transform: scale(1); }
}

/* --- CÁC THÀNH PHẦN CHÍNH --- */
#mbt-chatbot-icon, #mbt-chatbot-teaser, #mbt-chat-popup {
    position: fixed;
    top: var(--mbt-chat-pos-top);
    bottom: var(--mbt-chat-pos-bottom);
    left: var(--mbt-chat-pos-left);
    right: var(--mbt-chat-pos-right);
}

#mbt-chatbot-icon {
    z-index: 999997; 
    width: var(--mbt-icon-size-desktop);
    height: var(--mbt-icon-size-desktop);
    background-color: var(--mbt-chat-header-bg);
    border-radius: 50%;
    box-shadow: 0 4px 12px rgba(0,0,0,0.25);
    cursor: pointer;
    display: flex;
    justify-content: center;
    align-items: center;
    animation: mbt-pulse 1.5s ease-in-out infinite !important;
    animation-delay: 3s !important;
}
#mbt-chatbot-icon.animation-paused { animation-play-state: paused !important; transform: scale(1) !important; }
#mbt-chatbot-icon:hover { animation-play-state: paused !important; transform: scale(1.1) !important; }
#mbt-chatbot-icon img { width: 55%; height: 55%; object-fit: contain; filter: brightness(0) invert(1); }
#mbt-chatbot-icon.mbt-pure-icon { background: none !important; box-shadow: none !important; }
#mbt-chatbot-icon.mbt-pure-icon img { width: 100%; height: 100%; filter: none !important; }

#mbt-chatbot-teaser {
    display: none;
    bottom: calc(var(--mbt-chat-pos-bottom) + var(--mbt-icon-size-desktop) + 10px);
    background: #fff; padding: 12px 16px; border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.15); max-width: 250px;
    font-size: 14px; cursor: pointer; z-index: 999998;
}

#mbt-chat-popup {
    visibility: hidden; opacity: 0;
    transform: translateY(20px) scale(0.95);
    bottom: calc(var(--mbt-chat-pos-bottom) + var(--mbt-icon-size-desktop) + 10px);
    width: 380px; max-width: calc(100vw - 20px); height: 70vh; max-height: 600px;
    background: #fff; border-radius: 12px; box-shadow: 0 8px 24px rgba(0,0,0,0.2);
    display: flex; flex-direction: column; z-index: 1000000;
    overflow: hidden; transition: visibility 0s, opacity 0.3s ease, transform 0.3s ease;
}
#mbt-chat-popup.active { visibility: visible; opacity: 1; transform: translateY(0) scale(1); }

#mbt-chat-backdrop { position: fixed; top: 0; left: 0; width: 100%; height: 100%; background: transparent; z-index: 999999; display: none; }
#mbt-chat-backdrop.active { display: block; }

.mbt-chat-header { padding: 10px 15px; display: flex; justify-content: center; align-items: center; background-color: var(--mbt-chat-header-bg); color: #fff; flex-shrink: 0; }
.mbt-chat-title { font-weight: 600; font-size: 15px; }

.mbt-chat-body { flex-grow: 1; padding: 15px; overflow-y: auto; background-color: #fff; }
.mbt-chat-message { margin-bottom: 12px; padding: 10px 16px; border-radius: 18px; max-width: 85%; line-height: 1.6; word-wrap: break-word; animation: slideInUp 0.4s ease-out forwards; opacity: 0; }
.mbt-chat-message.user-message { background-color: var(--mbt-chat-user-msg-bg); color: #fff; margin-left: auto; border-bottom-right-radius: 5px; }
.mbt-chat-message.bot-message { background-color: var(--mbt-chat-bot-msg-bg); color: #202124; margin-right: auto; border-bottom-left-radius: 5px; }
.mbt-chat-message.bot-message.typing { font-style: italic; color: #666; }
.mbt-chat-message.bot-message.typing::after { content: "..."; animation: ellipsis 1.5s infinite; display: inline-block; width: 1em; text-align: left; }
.mbt-chat-message.bot-message.error { background-color: #fce8e6; color: #a50e0e; border: 1px solid #f6c8c6; }

.mbt-chat-in-chat-suggestions { display: flex; flex-direction: column; gap: 8px; margin: 10px 0; animation: slideInUp 0.5s 0.3s ease-out forwards; opacity: 0; }
.mbt-in-chat-suggestion-btn { width: 100%; padding: 12px; text-align: center; border-radius: 8px; cursor: pointer; background-color: var(--mbt-suggestion-bg-color); color: var(--mbt-suggestion-text-color); border: 1px solid var(--mbt-suggestion-border-color); font-size: var(--mbt-suggestion-font-size); transition: background-color 0.2s, border-color 0.2s; }
.mbt-in-chat-suggestion-btn:hover { background-color: #f5f5f5; border-color: #ccc; }

.mbt-chat-footer { padding: 10px 15px; border-top: 1px solid #e0e0e0; background-color: #f9f9f9; flex-shrink: 0; }
#mbt-chatbot-form { display: flex; align-items: center; gap: 10px; }
.mbt-input-wrapper { flex-grow: 1; position: relative; }
#mbt-chatbot-input { width: 100%; box-sizing: border-box; border: 1px solid #dadce0; padding: 10px 16px; border-radius: 20px; font-size: 15px; }
#mbt-char-counter { position: absolute; right: 15px; bottom: -18px; font-size: 11px; color: #aaa; }
#mbt-char-counter.limit-exceeded { color: red; font-weight: bold; }
#mbt-chatbot-form button { background-color: var(--mbt-chat-send-btn-bg); border: none; border-radius: 50%; width: 44px; height: 44px; display: flex; justify-content: center; align-items: center; cursor: pointer; flex-shrink: 0; transition: opacity 0.2s; }
#mbt-chatbot-form button:hover { opacity: 0.85; }
#mbt-chatbot-form button img { width: 22px; height: 22px; }
.mbt-chat-branding { text-align: center; font-size: 12px; color: #777; margin-top: 8px; }
.mbt-chat-branding a { color: #555; text-decoration: none; }
.mbt-chat-branding a:hover { text-decoration: underline; }

@media (max-width: 768px) {
    #mbt-chatbot-icon { width: var(--mbt-icon-size-mobile); height: var(--mbt-icon-size-mobile); }
    #mbt-chatbot-teaser, #mbt-chat-popup { bottom: calc(var(--mbt-chat-pos-bottom) + var(--mbt-icon-size-mobile) + 10px); }
    #mbt-chat-popup { width: calc(100vw - 30px); max-width: 380px; height: 75vh; max-height: 550px; transform-origin: bottom right; }
    #mbt-chat-popup.active { transform: translateY(0) scale(1); }
}