/* Chatbot Widget CSS */
.chat-widget {
    position: fixed;
    bottom: 90px;
    right: 30px;
    width: 350px;
    height: 500px;
    background: #fff;
    border-radius: 15px;
    box-shadow: 0 5px 25px rgba(0,0,0,0.15);
    display: none; /* Hidden by default */
    flex-direction: column;
    z-index: 9999;
    overflow: hidden;
    border: 1px solid rgba(0,0,0,0.05);
    font-family: 'Cairo', sans-serif;
}

.chat-widget.active {
    display: flex;
    animation: slideIn 0.3s ease;
}

@keyframes slideIn {
    from { opacity: 0; transform: translateY(20px); }
    to { opacity: 1; transform: translateY(0); }
}

.chat-header {
    background: var(--primary);
    color: #fff;
    padding: 15px;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.chat-header h3 {
    margin: 0;
    font-size: 1rem;
    display: flex;
    align-items: center;
    gap: 8px;
}

.chat-close {
    background: none;
    border: none;
    color: #fff;
    cursor: pointer;
    font-size: 1.2rem;
}

.chat-messages {
    flex: 1;
    padding: 15px;
    overflow-y: auto;
    background: #f9f9f9;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.message {
    max-width: 80%;
    padding: 10px 15px;
    border-radius: 15px;
    font-size: 0.9rem;
    line-height: 1.4;
    position: relative;
    word-wrap: break-word;
}

.message.bot {
    background: #fff;
    align-self: flex-start;
    border-bottom-right-radius: 2px; /* RTL fix */
    box-shadow: 0 2px 5px rgba(0,0,0,0.05);
    color: var(--text-primary);
}

.ltr .message.bot {
    border-bottom-right-radius: 15px;
    border-bottom-left-radius: 2px;
}

.message.user {
    background: var(--primary);
    color: #fff;
    align-self: flex-end;
    border-bottom-left-radius: 2px; /* RTL fix */
}

.ltr .message.user {
    border-bottom-left-radius: 15px;
    border-bottom-right-radius: 2px;
}

.chat-input-area {
    padding: 15px;
    background: #fff;
    border-top: 1px solid rgba(0,0,0,0.05);
    display: flex;
    gap: 10px;
}

.chat-input-area input {
    flex: 1;
    border: 1px solid #ddd;
    border-radius: 20px;
    padding: 10px 15px;
    font-family: inherit;
    outline: none;
    transition: border-color 0.2s;
}

.chat-input-area input:focus {
    border-color: var(--primary);
}

.chat-send {
    background: var(--primary);
    color: #fff;
    border: none;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s;
}

.chat-send:hover {
    background: var(--secondary);
}

.typing-indicator {
    font-size: 0.8rem;
    color: #999;
    margin-bottom: 5px;
    display: none;
}

/* Chat Options */
.chat-options {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 10px;
    justify-content: flex-end; /* Align to right for RTL */
}

.ltr .chat-options {
    justify-content: flex-start;
}

.chat-option-btn {
    background: #fff;
    border: 1px solid var(--primary);
    color: var(--primary);
    padding: 8px 15px;
    border-radius: 20px;
    cursor: pointer;
    font-size: 0.85rem;
    transition: all 0.2s;
    font-family: inherit;
}

.chat-option-btn:hover {
    background: var(--primary);
    color: #fff;
    transform: translateY(-2px);
    box-shadow: 0 2px 5px rgba(0,0,0,0.1);
}

/* Menu Toggle Button */
.chat-menu-toggle {
    background: none;
    border: none;
    color: #888;
    font-size: 1.2rem;
    cursor: pointer;
    padding: 0 5px;
    transition: color 0.2s;
}

.chat-menu-toggle:hover, .chat-menu-toggle.active {
    color: var(--primary);
}

/* Chat Menu Popup */
.chat-menu-popup {
    position: absolute;
    bottom: 70px; /* Above input area */
    left: 0;
    right: 0;
    background: #fff;
    border-top: 1px solid rgba(0,0,0,0.1);
    box-shadow: 0 -5px 15px rgba(0,0,0,0.05);
    padding: 10px;
    max-height: 50%; /* Half the chat widget height */
    overflow-y: auto;
    display: none; /* Hidden by default */
    flex-wrap: wrap;
    gap: 8px;
    z-index: 10;
    border-top-left-radius: 15px;
    border-top-right-radius: 15px;
    scrollbar-width: thin;
    scrollbar-color: var(--primary) #f0f0f0;
}

.chat-menu-popup.active {
    display: flex;
    animation: slideUp 0.2s ease;
}

@keyframes slideUp {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

/* Update Chat Options styles */
.chat-option-btn {
    flex: 1 0 45%; /* Grid like */
    text-align: center;
    margin: 2px;
}

/* RTL Support */
.rtl .chat-widget {
    right: auto;
    left: 30px;
}
body.rtl .chat-widget {
    left: 30px; 
    right: auto;
}
body.ltr .chat-widget {
    right: 30px;
    left: auto;
}
