/* ==========================================================
   Chatbot – toggle button, container, messages, input area
   ========================================================== */

/* Fixed toggle button */
#chatbotToggleButton {
    position: fixed !important;
    bottom: 20px !important;
    right: 20px !important;
    left: auto !important;
    background-color: var(--primary-blue);
    color: white;
    width: 60px;
    height: 60px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 24px;
    cursor: pointer;
    z-index: 9999 !important;
    box-shadow: 0 4px 15px rgba(0, 102, 204, 0.5);
    transition: transform 0.2s ease-out, background-color 0.2s;
    border: none;
    -webkit-transform: translateZ(0);
    transform: translateZ(0);
    will-change: transform;
}
#chatbotToggleButton:hover {
    transform: scale(1.1);
    background-color: var(--accent-blue);
}

/* Desktop: always visible */
@media (min-width: 769px) {
    #chatbotToggleButton {
        display: flex !important;
        visibility: visible !important;
        opacity: 1 !important;
        pointer-events: auto !important;
    }
}

/* Chat container */
#chatbotContainer {
    position: fixed;
    bottom: 90px;
    right: 20px !important;
    left: auto !important;
    width: 350px;
    max-width: 90vw;
    height: 450px;
    max-height: 70vh;
    background-color: var(--chat-bg);
    border: 1px solid rgba(0, 102, 204, 0.3);
    border-radius: 12px;
    box-shadow: 0 10px 30px rgba(0,0,0,0.5);
    z-index: 999;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    opacity: 0;
    transform: translateY(20px) scale(0.95);
    transition: opacity 0.3s ease, transform 0.3s ease;
    direction: rtl;
    will-change: transform, opacity;
}
#chatbotContainer.active {
    opacity: 1;
    transform: translateY(0) scale(1);
}

/* Header */
#chatbotHeader {
    background: rgba(20, 20, 25, 0.9);
    padding: 12px 15px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    color: var(--text-color);
    font-weight: bold;
    border-bottom: 1px solid rgba(0, 102, 204, 0.2);
    direction: rtl;
}
#closeChatbotButton {
    background: none;
    border: none;
    color: var(--text-color);
    font-size: 20px;
    cursor: pointer;
}

/* Message list */
#chatMessages {
    flex-grow: 1;
    padding: 15px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    direction: rtl;
    scroll-behavior: smooth;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: thin;
    scrollbar-color: #3a3a3a rgba(0,0,0,0.3);
}
#chatMessages::-webkit-scrollbar       { width: 6px; }
#chatMessages::-webkit-scrollbar-track { background: rgba(0,0,0,0.3); border-radius: 3px; }
#chatMessages::-webkit-scrollbar-thumb { background: #3a3a3a; border-radius: 3px; transition: background 0.3s ease; }
#chatMessages::-webkit-scrollbar-thumb:hover { background: #4d4d4d; }

/* Message bubbles */
.chat-message {
    max-width: 85%;
    padding: 10px 15px;
    border-radius: 10px;
    margin-bottom: 10px;
    font-size: 0.95rem;
    line-height: 1.5;
    word-wrap: break-word;
    direction: rtl;
    text-align: right;
}
.user-message {
    background-color: var(--user-msg-bg);
    color: white;
    margin-right: auto;
    border-bottom-left-radius: 0;
}
.bot-message {
    background-color: var(--bot-msg-bg);
    color: var(--text-color);
    margin-left: auto;
    border-bottom-right-radius: 0;
}

/* Typing indicator */
.typing-indicator span {
    display: inline-block;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background-color: var(--accent-blue);
    margin: 0 2px;
    animation: typing-bounce 1s infinite ease-in-out;
}
.typing-indicator span:nth-child(2) { animation-delay: 0.2s; }
.typing-indicator span:nth-child(3) { animation-delay: 0.4s; }

@keyframes typing-bounce {
    0%, 100% { transform: translateY(0); }
    50%       { transform: translateY(-4px); }
}

/* Input area */
#chatbotInputArea {
    display: flex;
    padding: 15px;
    border-top: 1px solid rgba(0, 102, 204, 0.2);
    direction: rtl;
}
#chatInput {
    flex-grow: 1;
    background-color: var(--chat-input-bg);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 20px;
    padding: 10px 15px;
    color: var(--text-color);
    font-size: 0.9rem;
    margin-left: 10px;
    text-align: right;
    direction: rtl;
}
#chatInput:focus { outline: none; border-color: var(--accent-blue); }

#sendChatMsg {
    background-color: var(--primary-blue);
    color: white;
    border: none;
    border-radius: 20px;
    padding: 10px 15px;
    cursor: pointer;
    font-weight: 500;
    transition: background-color 0.2s;
}
#sendChatMsg:hover    { background-color: var(--accent-blue); }
#sendChatMsg:disabled { background-color: #555; cursor: not-allowed; }

/* Limit / notice bar */
#chatLimitMessage {
    background-color: rgba(255, 215, 0, 0.1);
    color: #ffd700;
    padding: 10px;
    font-size: 0.85rem;
    text-align: center;
    direction: rtl;
}
#chatLimitMessage a { color: var(--accent-blue); text-decoration: underline; }
