/* Bina-Istra Chatbot Widget for Joomla */
#bina-chatbot-toggle {
    position: fixed;
    bottom: 24px;
    right: 24px;
    width: 60px;
    height: 60px;
    border-radius: 50%;
    background: var(--bina-chat-primary, #003087);
    color: #fff;
    border: none;
    cursor: pointer;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.25);
    font-size: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 99999;
    transition: transform 0.2s, background 0.2s;
    line-height: 1;
}
#bina-chatbot-toggle:hover {
    transform: scale(1.1);
}

#bina-chatbot-window {
    position: fixed;
    bottom: 96px;
    right: 24px;
    width: 380px;
    max-height: 520px;
    background: #fff;
    border-radius: 4px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.15);
    z-index: 99998;
    display: none;
    flex-direction: column;
    overflow: hidden;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}
#bina-chatbot-window.bina-open {
    display: flex;
}

.bina-chat-header {
    background: var(--bina-chat-primary, #003087);
    color: #fff;
    padding: 16px 20px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    font-size: 16px;
    font-weight: 600;
}
.bina-chat-header .bina-close {
    background: none;
    border: none;
    color: #fff;
    font-size: 22px;
    cursor: pointer;
    opacity: 0.8;
    line-height: 1;
}
.bina-chat-header .bina-close:hover { opacity: 1; }

.bina-chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
    min-height: 300px;
    max-height: 360px;
}

.bina-msg {
    margin-bottom: 12px;
    display: flex;
}
.bina-msg.bina-user { justify-content: flex-end; }
.bina-msg.bina-bot  { justify-content: flex-start; }

.bina-msg .bina-bubble {
    max-width: 80%;
    padding: 10px 14px;
    border-radius: 4px;
    font-size: 14px;
    line-height: 1.4;
    word-wrap: break-word;
}
.bina-msg.bina-user .bina-bubble {
    background: var(--bina-chat-primary, #003087);
    color: #fff;
    border-bottom-right-radius: 4px;
}
.bina-msg.bina-bot .bina-bubble {
    background: #f0f2f5;
    color: #3a3b3c;
    border-bottom-left-radius: 4px;
}

.bina-chat-input {
    padding: 12px 16px;
    border-top: 1px solid #e4e6eb;
    display: flex;
    gap: 8px;
    align-items: center;
}
.bina-chat-input input {
    flex: 1;
    border: 1px solid #e4e6eb;
    border-radius: 24px;
    padding: 10px 16px;
    font-size: 14px;
    outline: none;
}
.bina-chat-input input:focus {
    border-color: var(--bina-chat-primary, #003087);
}
.bina-chat-input button {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: var(--bina-chat-primary, #003087);
    color: #fff;
    border: none;
    cursor: pointer;
    font-size: 16px;
    display: flex;
    align-items: center;
    justify-content: center;
}
.bina-chat-input button:disabled {
    background: #e4e6eb;
    cursor: not-allowed;
}

.bina-chat-footer {
    text-align: center;
    padding: 6px;
    font-size: 11px;
    color: #65676b;
    border-top: 1px solid #e4e6eb;
}

.bina-typing span {
    display: inline-block;
    width: 6px;
    height: 6px;
    background: #65676b;
    border-radius: 50%;
    margin: 0 2px;
    animation: binaTyping 1.2s infinite;
}
.bina-typing span:nth-child(2) { animation-delay: 0.2s; }
.bina-typing span:nth-child(3) { animation-delay: 0.4s; }

@keyframes binaTyping {
    0%, 60%, 100% { opacity: 0.3; transform: translateY(0); }
    30% { opacity: 1; transform: translateY(-4px); }
}

.bina-char-count {
    font-size: 11px;
    color: #65676b;
    min-width: 45px;
    text-align: right;
}
.bina-char-count.bina-warn { color: #e74c3c; }

@media (max-width: 480px) {
    #bina-chatbot-window {
        width: calc(100vw - 16px);
        right: 8px;
        bottom: 88px;
        max-height: 70vh;
    }
}

/* Markdown formatting in bubbles */
.bina-bubble ul { margin: 6px 0; padding-left: 18px; }
.bina-bubble li { margin-bottom: 3px; }
.bina-bubble strong { font-weight: 700; }

/* Operator and system message styles */
.bina-msg .bina-bubble.bina-operator-bubble {
    background: linear-gradient(135deg, #f59e0b, #d97706) !important;
    color: #fff !important;
}
.bina-msg.bina-system {
    justify-content: center;
}
.bina-msg.bina-system .bina-bubble {
    background: #fef3c7 !important;
    color: #92400e !important;
    text-align: center;
    font-size: 12px;
    font-weight: 600;
    max-width: 90%;
}
