/* تصميم مساعد العلم والإيمان الذكي  */
#ai-chatbot-container {
    position: fixed;
    bottom: 20px;
    right: 20px;
    left: auto;
    z-index: 9999;
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    direction: rtl;
}

/* زر تفعيل الدردشة */
#chatbot-toggle {
    background: linear-gradient(135deg, #c8965c 0%, #a07a4d 100%);
    color: white;
    border: none;
    padding: 15px 20px;
    border-radius: 50px;
    cursor: pointer;
    font-size: 16px;
    font-weight: bold;
    box-shadow: 0 4px 15px rgba(0, 124, 186, 0.3);
    transition: all 0.3s ease;
    animation: pulse 2s infinite;
    position: relative;
}

#chatbot-toggle:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(0, 124, 186, 0.4);
}

@keyframes pulse {
    0%, 100% { box-shadow: 0 4px 15px rgba(0,124,186,0.3); }
    50% { box-shadow: 0 4px 25px rgba(0,124,186,0.5); }
}

/* إشعار الرسائل الجديدة */
.notification-badge {
    position: absolute;
    top: -8px;
    right: -8px;
    background: #c8965c;
    color: white;
    border-radius: 50%;
    width: 20px;
    height: 20px;
    font-size: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    animation: bounce 0.5s ease;
}

@keyframes bounce {
    0%, 20%, 50%, 80%, 100% { transform: translateY(0); }
    40% { transform: translateY(-10px); }
    60% { transform: translateY(-5px); }
}

/* نافذة الدردشة */
#chatbot-window {
    position: fixed;
    bottom: 50px;
    right: 20px;
    left: auto;
    width: 400px;
    height: 650px;
    max-height: calc(100vh - 60px);
    background: white;
    border-radius: 20px;
    box-shadow: 0 15px 50px rgba(0, 0, 0, 0.2);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    animation: slideUp 0.3s ease;
    border: 1px solid rgba(200, 150, 92, 0.2);
    z-index: 9999;
}

@keyframes slideUp {
    from { opacity: 0; transform: translateY(20px); }
    to { opacity: 1; transform: translateY(0); }
}

/* رأس نافذة الدردشة */
#chat-header {
    background: linear-gradient(135deg, #c8965c 0%, #a07a4d 100%);
    color: white;
    padding: 12px 15px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    position: relative;
    min-height: 50px;
}

#chat-header h4 {
    margin: 0;
    font-size: 16px;
    font-weight: bold;
    display: flex;
    align-items: center;
    gap: 10px;
}

#chat-header .controls {
    display: flex;
    gap: 8px;
    align-items: center;
}

#chat-header button {
    background: rgba(255, 255, 255, 0.2);
    border: none;
    color: white;
    width: 32px;
    height: 32px;
    border-radius: 6px;
    cursor: pointer;
    font-size: 14px;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
}

#chat-header button:hover {
    background: rgba(255, 255, 255, 0.3);
    transform: scale(1.1);
}

/* إشعار الحالة */
.status-indicator {
    display: inline-block;
    width: 8px;
    height: 8px;
    background: #a07a4d;
    border-radius: 50%;
    margin-left: 8px;
    animation: blink 1.5s infinite;
}

.status-indicator.offline {
    background: #c8965c;
}

@keyframes blink {
    0%, 50% { opacity: 1; }
    51%, 100% { opacity: 0.3; }
}

/* منطقة الرسائل */
#chat-messages {
    flex: 1;
    padding: 10px 12px;
    overflow-y: auto !important;
    background: #fff;
    display: flex;
    flex-direction: column;
    gap: 10px;
    scroll-behavior: smooth;
    max-height: calc(600px - 140px);
    border-radius: 0;
}

/* شريط التمرير المخصص */
#chat-messages::-webkit-scrollbar {
    width: 8px;
}

#chat-messages::-webkit-scrollbar-track {
    background: #f1f1f1;
}

#chat-messages::-webkit-scrollbar-thumb {
    background: #c8965c;
    border-radius: 4px;
}

/* تصميم الرسائل */
.message {
    max-width: 85%;
    border-radius: 18px;
    line-height: 1.5;
    font-size: 14px;
    animation: fadeIn 0.4s ease;
    position: relative;
    word-wrap: break-word;
    margin: 8px 0;
    font-family: 'Noto Naskh Arabic', serif !important;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

.message:hover {
    transform: translateY(-1px);
    transition: transform 0.2s ease;
}

.message.user {
    background: linear-gradient(135deg, #c8965c 0%, #0056b3 100%);
    color: white;
    align-self: flex-end;
    padding: 12px 18px;
    border-bottom-right-radius: 5px;
    box-shadow: 0 2px 10px rgba(0, 124, 186, 0.2);
    max-width: 80%;
    font-size: 15px;
}

.message.bot {
    background: white;
    color: #333;
    border: 1px solid #e1e5e9;
    align-self: flex-start;
    border-bottom-left-radius: 5px;
    box-shadow: 0 2px 15px rgba(0, 0, 0, 0.1);
    overflow: visible;
    max-width: 90%;
    word-wrap: break-word;
}

/* محتوى رسالة البوت */
.bot-message-content {
    padding: 15px 18px;
    max-height: none;
    overflow: visible;
    line-height: 1.8;
    font-family: 'Noto Naskh Arabic', serif !important;
    font-size: 17px !important;
    color: #2c3e50 !important;
    font-weight: 500 !important;
}

.user-message-content {
    font-family: 'Cairo', sans-serif;
    font-size: 14px;
}

/* أزرار التحكم في الرسالة */
.message-actions {
    display: flex;
    justify-content: flex-end;
    gap: 6px;
    padding: 6px 12px;
    background: #f8f9fa;
    border-top: 1px solid #e9ecef;
    flex-shrink: 0;
}

.action-btn {
    background: transparent;
    border: 1px solid #dee2e6;
    color: #6c757d;
    border-radius: 6px;
    padding: 4px 8px;
    cursor: pointer;
    font-size: 11px;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    gap: 4px;
}

.action-btn:hover {
    background: #c8965c;
    color: white;
    border-color: #c8965c;
}

.action-btn.liked {
    background: #a07a4d;
    color: white;
    border-color: #a07a4d;
}

.action-btn.disliked {
    background: #c8965c;
    color: white;
    border-color: #c8965c;
}

/* بطاقات المصادر */
.sources-container {
    margin-top: 10px;
    padding: 10px 12px;
    background: #f8f9fa;
    border-top: 1px solid #e9ecef;
    max-height: 200px;
    overflow-y: auto;
}

.sources-title {
    font-weight: bold;
    color: #495057;
    margin-bottom: 10px;
    font-size: 13px;
    display: flex;
    align-items: center;
    gap: 5px;
}

.source-card {
    background: white;
    border: 1px solid #dee2e6;
    border-radius: 8px;
    padding: 8px 10px;
    margin-bottom: 6px;
    transition: all 0.3s ease;
    cursor: pointer;
    position: relative;
}

.source-card:hover {
    border-color: #c8965c;
    box-shadow: 0 2px 8px rgba(0, 124, 186, 0.15);
    transform: translateX(2px);
}

.source-title {
    font-weight: 600;
    color: #c8965c;
    font-size: 13px;
    margin-bottom: 4px;
    text-decoration: none;
}

.source-meta {
    font-size: 11px;
    color: #6c757d;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.relevance-score {
    background: #e9ecef;
    color: #495057;
    padding: 2px 6px;
    border-radius: 12px;
    font-size: 10px;
}

.relevance-score.high {
    background: #d4edda;
    color: #155724;
}

.relevance-score.medium {
    background: #fff3cd;
    color: #856404;
}

/* اقتراحات ذكية */
.suggestions-container {
    padding: 8px 12px;
    background: #f8f9fa;
    border-top: 1px solid #e9ecef;
}

.suggestions-title {
    font-size: 12px;
    color: #6c757d;
    margin-bottom: 8px;
    font-weight: 600;
}

.suggestions-list {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

.suggestion-btn {
    background: white;
    border: 1px solid #dee2e6;
    color: #495057;
    border-radius: 15px;
    padding: 5px 10px;
    font-size: 11px;
    cursor: pointer;
    transition: all 0.3s ease;
    white-space: nowrap;
    margin: 2px;
}

.suggestion-btn:hover {
    background: #c8965c;
    color: white;
    border-color: #c8965c;
    transform: translateY(-1px);
}

/* منطقة الإدخال */
#chat-input {
    padding: 10px 12px;
    background: #f8f9fa;
    border-top: 1px solid #e1e5e9;
    display: flex;
    gap: 10px;
    align-items: flex-end;
}

#message-input {
    flex: 1;
    border: 2px solid #e9ecef;
    border-radius: 15px;
    padding: 10px 15px;
    font-size: 14px;
    outline: none;
    transition: all 0.3s ease;
    resize: none;
    min-height: 20px;
    max-height: 100px;
    line-height: 1.4;
}

#message-input:focus {
    border-color: #c8965c;
    box-shadow: 0 0 0 3px rgba(0, 124, 186, 0.1);
}

#chat-input button {
    background: linear-gradient(135deg, #c8965c 0%, #0056b3 100%);
    color: white;
    border: none;
    border-radius: 20px;
    padding: 12px 20px;
    cursor: pointer;
    font-weight: bold;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    gap: 5px;
    min-width: 80px;
    justify-content: center;
}

#chat-input button:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(0, 124, 186, 0.3);
}

#chat-input button:active {
    transform: scale(0.98);
}

#chat-input button:disabled {
    background: #6c757d;
    cursor: not-allowed;
    transform: none;
}

/* حالة الكتابة */
.typing-indicator {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 12px 18px;
    background: white;
    border: 1px solid #e1e5e9;
    border-radius: 18px;
    border-bottom-left-radius: 5px;
    align-self: flex-start;
    animation: fadeIn 0.3s ease;
    max-width: 85%;
}

.typing-dots {
    display: flex;
    gap: 3px;
}

.typing-dot {
    width: 6px;
    height: 6px;
    background: #c8965c;
    border-radius: 50%;
    animation: typing 1.4s infinite;
}

.typing-dot:nth-child(2) { animation-delay: 0.2s; }
.typing-dot:nth-child(3) { animation-delay: 0.4s; }

@keyframes typing {
    0%, 60%, 100% { transform: scale(1); opacity: 0.5; }
    30% { transform: scale(1.2); opacity: 1; }
}

/* تاريخ المحادثات */
.conversation-header {
    background: #f8f9fa;
    padding: 10px 15px;
    border-bottom: 1px solid #e9ecef;
    text-align: center;
}

.conversation-date {
    font-size: 11px;
    color: #6c757d;
    font-weight: 600;
}

/* تأثيرات إضافية */
.highlight-text {
    background: linear-gradient(120deg, rgba(0, 124, 186, 0.1) 0%, rgba(0, 124, 186, 0.2) 100%);
    padding: 2px 4px;
    border-radius: 3px;
    font-weight: 500;
}

.fade-in {
    animation: fadeIn 0.5s ease;
}

.slide-left {
    animation: slideLeft 0.3s ease;
}

@keyframes slideLeft {
    from { transform: translateX(20px); opacity: 0; }
    to { transform: translateX(0); opacity: 1; }
}

/* مؤشرات التحميل المحسّنة */
.loading-spinner {
    display: inline-block;
    width: 16px;
    height: 16px;
    border: 2px solid #e9ecef;
    border-radius: 50%;
    border-top-color: #c8965c;
    animation: spin 1s ease-in-out infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* تحسين حجم النافذة للكمبيوتر */
@media (min-width: 1200px) {
    #chatbot-window {
        width: 600px;
        height: 750px;
        right: 20px;
        left: auto;
        bottom: 80px;
        max-height: calc(100vh - 100px);
    }
    
    .bot-message-content {
        font-size: 19px !important;
        line-height: 1.9 !important;
    }
}

@media (min-width: 900px) and (max-width: 1199px) {
    #chatbot-window {
        width: 450px;
        height: 700px;
        max-height: calc(100vh - 120px);
        right: 20px;
        left: auto;
    }
}

/* تحسين للشاشات الصغيرة */
@media (max-height: 750px) {
    #chatbot-window {
        height: calc(100vh - 120px);
        bottom: 15px;
    }
}

/* تصميم مستجيب للهواتف */
@media (max-width: 480px) {
    #ai-chatbot-container {
        bottom: 20px;
        right: 10px;
        left: auto;
    }
    
	/* إصلاح المسافة الفارغة أسفل منطقة الرسائل على الهاتف */
#chat-messages {
    max-height: none;
}

    #chatbot-window {
        width: calc(100vw - 20px);
        height: calc(100vh - 100px);
        bottom: 15px;
        right: 10px;
        left: 10px;
        border-radius: 15px;
        max-height: calc(100vh - 100px);
    }
    
    #chatbot-toggle {
        bottom: 20px;
        left: 50%;
        right: auto;
        transform: translateX(-50%);
        padding: 12px 18px;
    }
    
    .message {
        max-width: 90%;
    }
    
    .source-card {
        margin-bottom: 6px;
    }
    
    .suggestions-list {
        gap: 4px;
    }
    
    .suggestion-btn {
        font-size: 10px;
        padding: 5px 10px;
    }
    
    /* إصلاح المسافة الفارغة أسفل الإدخال على الهاتف */
    #chat-input {
        padding: 4px 8px !important;
        min-height: auto;
        margin-bottom: 0;
    }
    
    #message-input {
        padding: 6px 12px !important;
        margin: 0;
        min-height: 18px;
        max-height: 70px;
    }
    
    #chat-input button {
        padding: 6px 10px !important;
        min-width: 50px;
        font-size: 12px;
    }
    
    /* للهواتف خط مناسب ومقروء */
    .bot-message-content {
        font-size: 16px !important;
        line-height: 1.75 !important;
    }
    
    /* التأكد من عدم وجود مساحات إضافية */
    #chatbot-window {
        padding-bottom: 0 !important;
        margin-bottom: 0 !important;
    }
}



