/* /chatbot/assets/chatbot.css */
#bm-chatbot-wrapper {
    position: fixed;
    bottom: 30px;
    right: 30px;
    z-index: 99999; /* Extremely high to sit above navbar/footers */
    font-family: 'Inter', sans-serif;
}

/* Launcher Button */
#bm-chat-launcher {
    width: 60px;
    height: 60px;
    border-radius: 50%;
    background: linear-gradient(135deg, #6366f1 0%, #d946ef 100%);
    color: white;
    border: none;
    box-shadow: 0 10px 20px rgba(99, 102, 241, 0.4);
    cursor: pointer;
    font-size: 24px;
    transition: transform 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
}

#bm-chat-launcher:hover {
    transform: scale(1.1);
}

/* Unread Badge */
.bm-chat-badge {
    position: absolute;
    top: -2px;
    right: -2px;
    background-color: #ef4444;
    color: white;
    font-size: 11px;
    font-weight: bold;
    width: 22px;
    height: 22px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 2px solid #050505;
    opacity: 0;
    transform: scale(0);
    transition: all 0.3s ease;
}

.bm-chat-badge.active {
    opacity: 1;
    transform: scale(1);
}

/* Notification Toast (Mobile preview bubble) */
#bm-chat-toast {
    position: absolute;
    bottom: 80px;
    right: 0;
    background: #0f0f0f;
    border: 1px solid #333;
    color: white;
    padding: 12px 18px;
    border-radius: 12px;
    box-shadow: 0 10px 25px rgba(0,0,0,0.8);
    font-size: 0.9rem;
    white-space: nowrap;
    opacity: 0;
    pointer-events: none;
    transform: translateY(10px);
    transition: all 0.3s ease;
}

#bm-chat-toast::after {
    content: '';
    position: absolute;
    bottom: -6px;
    right: 24px;
    width: 12px;
    height: 12px;
    background: #0f0f0f;
    border-bottom: 1px solid #333;
    border-right: 1px solid #333;
    transform: rotate(45deg);
}

#bm-chat-toast.active {
    opacity: 1;
    transform: translateY(0);
}

/* Chat Window */
#bm-chat-window {
    position: absolute;
    bottom: 80px;
    right: 0;
    width: 360px;
    height: 550px;
    background: #0f0f0f;
    border: 1px solid #333;
    border-radius: 20px;
    box-shadow: 0 20px 40px rgba(0,0,0,0.8);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    opacity: 0;
    pointer-events: none;
    transform: translateY(20px);
    transition: all 0.3s ease;
}

#bm-chat-window.active {
    opacity: 1;
    pointer-events: all;
    transform: translateY(0);
}

.bm-chat-header {
    background: #050505;
    padding: 15px 20px;
    border-bottom: 1px solid #1f1f1f;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.bm-chat-header h4 { margin: 0; color: white; font-size: 1.05rem; font-weight: 600; }
.bm-chat-header .status { font-size: 0.75rem; color: #10b981; }

.bm-chat-body {
    flex: 1;
    padding: 15px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 12px;
    scrollbar-width: thin;
    scrollbar-color: #333 #0f0f0f;
}

.bm-msg {
    max-width: 80%;
    padding: 12px 16px;
    border-radius: 14px;
    font-size: 0.95rem;
    line-height: 1.4;
}

.bm-msg.ai, .bm-msg.admin {
    background: #1f1f1f;
    color: #e5e7eb;
    align-self: flex-start;
    border-bottom-left-radius: 4px;
}

.bm-msg.admin { border: 1px solid #6366f1; }

.bm-msg.user {
    background: linear-gradient(135deg, #6366f1 0%, #8b5cf6 100%);
    color: white;
    align-self: flex-end;
    border-bottom-right-radius: 4px;
}

.bm-chat-input {
    padding: 15px;
    background: #050505;
    border-top: 1px solid #1f1f1f;
    display: flex;
    gap: 10px;
}

.bm-chat-input input {
    flex: 1;
    background: #0f0f0f;
    border: 1px solid #333;
    color: white;
    padding: 12px 15px;
    border-radius: 20px;
    outline: none;
    font-size: 16px; /* Prevents iOS auto-zoom */
}

.bm-chat-input button {
    background: transparent;
    color: #6366f1;
    border: none;
    cursor: pointer;
    font-size: 1.3rem;
    padding: 0 10px;
}

/* Typing Indicator */
.typing-dots { display: none; align-self: flex-start; padding: 12px 16px; background: #1f1f1f; border-radius: 14px; }
.typing-dots span { display: inline-block; width: 6px; height: 6px; background: #9ca3af; border-radius: 50%; margin: 0 2px; animation: blink 1.4s infinite both; }
.typing-dots span:nth-child(2) { animation-delay: 0.2s; }
.typing-dots span:nth-child(3) { animation-delay: 0.4s; }
@keyframes blink { 0% { opacity: 0.2; } 20% { opacity: 1; } 100% { opacity: 0.2; } }

/* ========================================= */
/* MOBILE FRIENDLY ADJUSTMENTS               */
/* ========================================= */
@media (max-width: 768px) {
    #bm-chatbot-wrapper {
        bottom: 20px;
        right: 20px;
    }

    #bm-chat-window {
        position: fixed !important; /* Force fixed to viewport */
        top: 0;
        left: 0;
        right: 0;
        bottom: 0;
        width: 100vw;
        height: 100dvh; /* Uses dynamic viewport height for mobile browsers */
        border-radius: 0;
        border: none;
        transform: translateY(100%); /* Slide up from bottom */
    }

    #bm-chat-window.active {
        transform: translateY(0);
    }

    /* THE FIX: Smoothly hide the launcher button when the chat is open */
    #bm-chat-window.active ~ #bm-chat-launcher {
        opacity: 0;
        visibility: hidden;
        pointer-events: none;
        transform: scale(0);
        transition: all 0.3s ease;
    }

    .bm-chat-header {
        padding: 20px 15px;
        background: #000;
    }
    
    .bm-chat-input {
        padding: 10px 15px 20px 15px; /* Extra bottom padding for iOS home bar */
    }
}