/* شات بوت البلدية */
.chatbot-container {
    position: fixed;
    bottom: 20px;
    left: 20px;
    z-index: 10000;
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
}

/* أيقونة الشات بوت */
.chatbot-icon {
    width: 60px;
    height: 60px;
    background: linear-gradient(135deg, #7c070d 0%, #910611 100%);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.2);
    transition: all 0.3s ease;
    border: 2px solid white;
}

.chatbot-icon:hover {
    transform: scale(1.1);
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.3);
    background: linear-gradient(135deg, #780202 0%, #650202 100%);
}

.chatbot-icon i {
    color: white;
    font-size: 24px;
}

/* نافذة الشات */
.chatbot-window {
    width: 350px;
    height: 500px;
    background-color: #f8f8f8;
    border-radius: 12px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.15);
    display: flex;
    flex-direction: column;
    position: absolute;
    bottom: 70px;
    left: 0;
    border: 1px solid #e0e0e0;
    overflow: hidden;
    display: none;
}

.chatbot-header {
    background: linear-gradient(135deg, #b53d3f 0%, #b53d3f 100%);
    color: white;
    padding: 15px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-top-left-radius: 12px;
    border-top-right-radius: 12px;
}

.chatbot-header h3 {
    margin: 0;
    font-size: 16px;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 8px;
}

.chatbot-header h3 i {
    font-size: 14px;
}

.close-btn {
    background: none;
    border: none;
    color: white;
    font-size: 18px;
    cursor: pointer;
    padding: 0;
    width: 30px;
    height: 30px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    transition: background-color 0.3s;
}

.close-btn:hover {
    background-color: rgba(255, 255, 255, 0.1);
}

/* منطقة الرسائل */
.chat-messages {
    flex: 1;
    padding: 15px;
    overflow-y: auto;
    background-color: #f8f8f8;
    display: flex;
    flex-direction: column;
}

.welcome-message {
    background: linear-gradient(135deg, #cbcccd 0%, #d8dadc 100%);
    border-radius: 12px;
    padding: 15px;
    margin-bottom: 15px;
    border-left: 4px solid #acafb1;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
}

.welcome-message p {
    margin: 0 0 10px 0;
    color: #090c10;
    font-size: 15px;
    line-height: 1.5;
    font-weight: 500;
    letter-spacing: 0.2px;
}

.welcome-message .hint {
    font-size: 13px;
    color: #060709;
    font-style: italic;
    margin-bottom: 0;
    line-height: 1.4;
    opacity: 0.9;
}

.message {
    margin-bottom: 12px;
    padding: 12px 16px;
    border-radius: 16px;
    max-width: 85%;
    word-wrap: break-word;
    position: relative;
    line-height: 1.5;
    font-size: 14.5px;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.08);
}

.user-message {
    background: linear-gradient(135deg, #f7f9fb 0%, #f7fefe 100%);
    color: rgb(12, 10, 10);
    margin-left: auto;
    margin-right: 0;
    border-bottom-right-radius: 6px;
    border-top-right-radius: 16px;
    border-top-left-radius: 16px;
    border-bottom-left-radius: 6px;
}

.bot-message {
    background: linear-gradient(135deg, #ffffff 0%, #f7fafc 100%);
    color: #2d3748;
    margin-right: auto;
    margin-left: 0;
    border: 1px solid #e2e8f0;
    border-bottom-left-radius: 6px;
    border-top-left-radius: 16px;
    border-top-right-radius: 16px;
    border-bottom-right-radius: 6px;
}

/* منطقة الإدخال - تم التعديل */
.chat-input-area {
    padding: 15px;
    background-color: white;
    border-top: 1px solid #e0e0e0;
    display: flex;
    align-items: center;
    gap: 10px;
}

.chat-input {
    flex: 1;
    border: 1px solid #cbd5e0;
    border-radius: 20px;
    padding: 12px 40px 12px 18px;
    font-size: 14.5px;
    resize: none;
    outline: none;
    font-family: inherit;
    line-height: 1.4;
    background-color: #fff;
    transition: all 0.3s;
    height: 45px;
    max-height: 80px; /* تم تعديله من 60px إلى 80px */
    min-height: 45px;
    overflow-y: auto;
    box-shadow: inset 0 1px 3px rgba(0, 0, 0, 0.05);
    color: #2d3748;
    letter-spacing: 0.3px;
}

.chat-input::placeholder {
    color: #718096;
    opacity: 0.9;
    font-size: 14px;
}

.chat-input:focus {
    border-color: #0e1011;
    box-shadow: 0 0 0 3px rgba(66, 153, 225, 0.15);
    background-color: #f7fafc;
}

/* إضافة أسهم التمرير لحقل الإدخال */
.chat-input::-webkit-scrollbar {
    width: 12px;
}

.chat-input::-webkit-scrollbar-track {
    background: #f1f1f1;
    border-radius: 20px;
    margin: 4px 0;
}

.chat-input::-webkit-scrollbar-thumb {
    background: #c1c1c1;
    border-radius: 20px;
    border: 3px solid #f1f1f1;
}

.chat-input::-webkit-scrollbar-thumb:hover {
    background: #a1a1a1;
}

.chat-input::-webkit-scrollbar-button {
    display: block;
    background-color: #e0e0e0;
    background-repeat: no-repeat;
    background-position: center;
    border-radius: 20px;
    height: 16px;
}

.chat-input::-webkit-scrollbar-button:vertical:decrement {
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6' viewBox='0 0 10 6'%3E%3Cpath fill='%23718096' d='M5 0L0 5l1.5 1.5L5 3 8.5 6.5 10 5z'/%3E%3C/svg%3E");
    background-position: center 5px;
}

.chat-input::-webkit-scrollbar-button:vertical:increment {
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6' viewBox='0 0 10 6'%3E%3Cpath fill='%23718096' d='M5 6L10 1 8.5-.5 5 3 1.5-.5 0 1z'/%3E%3C/svg%3E");
    background-position: center 4px;
}

.chat-input::-webkit-scrollbar-button:vertical:decrement:hover {
    background-color: #d0d0d0;
}

.chat-input::-webkit-scrollbar-button:vertical:increment:hover {
    background-color: #d0d0d0;
}

/* Firefox */
.chat-input {
    scrollbar-width: thin;
    scrollbar-color: #c1c1c1 #f1f1f1;
    scrollbar-arrow-color: #718096;
}

/* زر الصوت */
.voice-btn {
    width: 45px;
    height: 45px;
    border-radius: 50%;
    background: linear-gradient(135deg, #b53d3f 0%, #b53d3f 100%);
    border: none;
    color: white;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease;
    flex-shrink: 0;
}

.voice-btn:hover {
    transform: scale(1.05);
    background: linear-gradient(135deg, #b53d3f 0%, #b53d3f100%);
}

.voice-btn.listening {
    background: linear-gradient(135deg, #f56565 0%, #c53030 100%);
    animation: pulse 1.5s infinite;
}

@keyframes pulse {
    0% { transform: scale(1); }
    50% { transform: scale(1.1); }
    100% { transform: scale(1); }
}

.send-btn {
    width: 45px;
    height: 45px;
    border-radius: 50%;
    background: linear-gradient(135deg, #b53d3f 0%, #b53d3f 100%);
    border: none;
    color: white;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease;
    flex-shrink: 0;
}

.send-btn:hover:not(:disabled) {
    transform: scale(1.05);
    background: linear-gradient(135deg, #b53d3f 0%, #b53d3f 100%);
}

.send-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* مؤشر الكتابة - تم التعديل */
.typing-indicator {
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 10px 16px;
    background: linear-gradient(135deg, #ffffff 0%, #f7fafc 100%);
    border-radius: 16px;
    border: 1px solid #e2e8f0;
    margin-right: auto;
    margin-left: 0;
    max-width: 120px;
    border-bottom-left-radius: 6px;
    border-top-left-radius: 16px;
    border-top-right-radius: 16px;
    border-bottom-right-radius: 6px;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
}

.typing-indicator span {
    width: 6px;
    height: 6px;
    background-color: #a0aec0;
    border-radius: 50%;
    display: inline-block;
    animation: typing 1.4s infinite ease-in-out;
}

.typing-indicator span:nth-child(1) { animation-delay: -0.32s; }
.typing-indicator span:nth-child(2) { animation-delay: -0.16s; }
.typing-indicator span:nth-child(3) { animation-delay: 0s; }

@keyframes typing {
    0%, 80%, 100% { 
        transform: scale(0.8);
        opacity: 0.5;
    }
    40% { 
        transform: scale(1);
        opacity: 1;
    }
}

/* إخفاء شريط التمرير */
.chat-messages::-webkit-scrollbar {
    width: 6px;
}

.chat-messages::-webkit-scrollbar-track {
    background: #f1f1f1;
    border-radius: 3px;
}

.chat-messages::-webkit-scrollbar-thumb {
    background: #c1c1c1;
    border-radius: 3px;
}

.chat-messages::-webkit-scrollbar-thumb:hover {
    background: #a1a1a1;
}

/* تحسينات للعربية */
[dir="rtl"] .chatbot-container {
    left: auto;
    right: 20px;
}

[dir="rtl"] .chatbot-window {
    left: auto;
    right: 0;
}

[dir="rtl"] .user-message {
    margin-left: 0;
    margin-right: auto;
    border-bottom-left-radius: 6px;
    border-bottom-right-radius: 6px;
    border-top-left-radius: 16px;
    border-top-right-radius: 16px;
}

[dir="rtl"] .bot-message {
    margin-right: 0;
    margin-left: auto;
    border-bottom-right-radius: 6px;
    border-bottom-left-radius: 6px;
    border-top-right-radius: 16px;
    border-top-left-radius: 16px;
}

[dir="rtl"] .welcome-message {
    border-left: none;
    border-right: 4px solid #858586;
}

[dir="rtl"] .typing-indicator {
    margin-right: 0;
    margin-left: auto;
    border-bottom-right-radius: 6px;
    border-bottom-left-radius: 6px;
    border-top-right-radius: 16px;
    border-top-left-radius: 16px;
}

[dir="rtl"] .chat-input {
    padding: 12px 18px 12px 40px;
}

/* تصميم متجاوب */
@media (max-width: 768px) {
    .chatbot-container {
        bottom: 15px;
        left: 15px;
    }
    
    [dir="rtl"] .chatbot-container {
        left: auto;
        right: 15px;
    }
    
    .chatbot-window {
        width: 300px;
        height: 450px;
        bottom: 65px;
    }
    
    .chatbot-icon {
        width: 55px;
        height: 55px;
    }
    
    .voice-btn, .send-btn {
        width: 42px;
        height: 42px;
    }
    
    .chat-input {
        height: 42px;
        max-height: 70px; /* تم تعديله من 55px إلى 70px */
        min-height: 42px;
        padding: 10px 35px 10px 15px;
    }
    
    [dir="rtl"] .chat-input {
        padding: 10px 15px 10px 35px;
    }
}

@media (max-width: 480px) {
    .chatbot-window {
        width: calc(100vw - 40px);
        height: 70vh;
        bottom: 70px;
        left: 0;
        right: 0;
        margin: 0 auto;
    }
    
    [dir="rtl"] .chatbot-window {
        left: 0;
        right: 0;
    }
    
    .message {
        max-width: 90%;
        font-size: 14px;
        padding: 10px 14px;
    }
    
    .chat-input {
        font-size: 14px;
        padding: 10px 35px 10px 15px;
        height: 40px;
        max-height: 65px; /* تم تعديله من 50px إلى 65px */
        min-height: 40px;
    }
    
    [dir="rtl"] .chat-input {
        padding: 10px 15px 10px 35px;
    }
    
    .voice-btn, .send-btn {
        width: 40px;
        height: 40px;
    }
    
    .welcome-message p {
        font-size: 14.5px;
    }
    
    .welcome-message .hint {
        font-size: 12.5px;
    }
}

/* تأثيرات عند التحميل */
@keyframes fadeIn {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

.message {
    animation: fadeIn 0.3s ease-out;
}

.chatbot-icon {
    animation: bounce 2s infinite;
}

@keyframes bounce {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-5px); }
}

.chatbot-icon:hover {
    animation: none;
}