        :root {
            --primary-color: #3e2723;
            --secondary-color: #d7ccc8;
            --accent-color: #ffb300;
            --text-color: #212121;
            --bg-color: #f5f5f5;
            --chat-bg-user: #eefeeb;
            --chat-bg-ai: #ffffff;
            --sidebar-width: 300px;
        }
        /* ✅ تم حذف i لضمان ظهور النصوص المائلة في الشات بشكل صحيح */
	.fa, .fas, .far, .bi, .material-icons, [class^="icon-"] {
		font-family: "Font Awesome 5 Free", "FontAwesome", sans-serif !important; 
		}
        .sidebar, .sidebar button, .sidebar div, .sidebar span {
            font-family: 'Cairo', sans-serif !important;
        }

/* 1. تنسيق جسم الصفحة أو حاوية الشات الرئيسية */
body {
    background-image: 
        /* هنا التغيير: حطينا لون السايدبار بدل الأسود */
        /* الأرقام (44, 62, 80) دي هي كود لون سايدبار مشهور */
        /* الرقم 0.90 هو درجة الشفافية (عشان يغطي الخشب قوي ويبقى شبه السايدبار) */
        linear-gradient(rgba(62, 39, 35, 0.70), rgba(44, 62, 80, 0.90)),
        
        url('/images/background.png'); 

    /* باقي التنسيقات زي ما هي */
    background-repeat: repeat;
    background-size: auto;
    background-attachment: fixed;
    
    color: #ffffff;
    margin: 0;
    font-family: 'Segoe UI', sans-serif;
}

/* ============================================================
   تنسيق صندوق الكتابة الموحد (النسخة النهائية النظيفة)
   ============================================================ */
form, .input-group-form, .input-box-container {
    /* 1. التموضع والتثبيت */
    position: fixed !important;
    bottom: 20px !important;
    z-index: 9999 !important;

    /* 2. معادلة السنترة للكمبيوتر (عشان السايدبار) */
    /* يبدأ من نص الشاشة + نص عرض السايدبار */
    right: calc(50% + 150px) !important; 
    transform: translateX(50%) !important;

    /* 3. الأبعاد */
    width: calc(100% - 340px) !important;
    max-width: 800px !important;

    /* 4. الشكل الجمالي (الألوان والحدود) */
    background: #ffffff !important; /* خلفية بيضاء واضحة */
    border: 1px solid #d4af37 !important; /* برواز ذهبي شيك */
    border-radius: 10px !important; /* تدوير الحواف */
    box-shadow: 0 5px 20px rgba(0,0,0,0.2) !important; /* ظل يبرزه عن الخلفية */

    /* 5. ترتيب المحتوى الداخلي */
    display: flex !important;
    align-items: center !important;
    padding: 8px 12px !important; 
}

/* --- تعديل خاص للموبايل فقط --- */
@media (max-width: 768px) {
    form, .input-group-form, .input-box-container {
        /* إلغاء معادلة السايدبار واستخدام السنترة العادية */
        right: auto !important;
        left: 50% !important;
        transform: translateX(-50%) !important;
        
        width: 95% !important;
		max-width: none !important; /* إلغاء الحد الأقصى أو ضبطه حسب الرغبة */
        bottom: 10px !important; /* نقربه شوية من تحت في الموبايل */
    }
}

   /* 1. جعل الشريط السفلي بالكامل شفاف (عشان الخلفية الخشبية تبان في الأجناب) */
    .footer, .chat-footer, .input-area, .fixed-bottom {
        background: transparent !important;     /* يلغي اللون */
        background-color: transparent !important;
        background-image: none !important;      /* يلغي التدرج الأبيض لو موجود */
        box-shadow: none !important;            /* يلغي الضل الأبيض */
        border: none !important;
        backdrop-filter: none !important;       /* يلغي التغبيش لو موجود في الشريط كله */
    }
    /* تنسيق الصندوق نفسه */

/* ثانياً: إخفاء أي شريط فوتر قديم تماماً */
    /* بنستخدم display: none للعناصر الفاضية عشان ماتاخدش مكان */
    .footer:not(:has(form)), 
    .fixed-bottom:not(:has(form)), 
    footer:not(:has(form)) {
        background: transparent !important;
        box-shadow: none !important;
        border: none !important;
		background-color: transparent !important;
    }

    /* لون الكلام داخل البوكس (أسود عشان الخلفية بيضاء) */
    .form-control, input[type="text"], textarea {
        background: transparent !important;
        border: none !important;
        color: #333333 !important; /* أسود غامق */
        box-shadow: none !important;
    }

    /* لون النص الشفاف (Placeholder) */
    ::placeholder {
        color: #999999 !important;
    }

    /* زرار الإرسال */
    .btn, button[type="submit"] {
        background-color: #6d4c41 !important; /* بني */
        color: #fff !important;
        border-radius: 50% !important;
        width: 45px !important;
        height: 45px !important;
        display: flex !important;
        justify-content: center !important;
        align-items: center !important;
    }
    


/* إلغاء الحدود من الزرار وحقل الكتابة */
    form .btn, form button, form input, form .form-control {
        border: none !important;       /* يشيل أي خطوط */
        outline: none !important;      /* يشيل البرواز الأزرق لما تدوس */
        box-shadow: none !important;   /* يشيل أي ظل */
        background-image: none !important;
    }

body, .main-content, .chat-container {
        padding-bottom: 100px !important; /* مسافة أمان كبيرة */
    }






/* ⚠️ تأكد أن حاوية الشات شفافة عشان الخلفية تبان */
.chat-container, #chat-box, .main-content {
    background-color: transparent !important;
}


/* إخفاء كل شيء عند محاولة الطباعة المتصفح */
@media print {
    body * {
        display: none !important;
    }
    body:after {
        content: "الطباعة غير متاحة من المتصفح مباشرة. استخدم زر PDF.";
        display: block;
        font-size: 20px;
        text-align: center;
        margin-top: 50px;
    }
}

/* --- 1. تنسيق السايدبار الأساسي (للكمبيوتر فقط) --- */
.sidebar {
    width: var(--sidebar-width);
    background-color: var(--primary-color);
    color: #fff;
    display: flex;
    flex-direction: column;
    padding: 15px;
    transition: transform 0.3s ease;
    z-index: 1000;
    
    /* ✅ التعديل هنا: */
    position: relative !important; /* عشان يزق المحتوى جنبه ومايغطيش عليه */
    
    /* خصائص لضمان ظهوره على الكمبيوتر */
    transform: none !important;
    height: 100vh !important;
    box-shadow: none !important;
    flex-shrink: 0; /* يمنعه من الانكماش */
}


        /* تنسيقات الأزرار والقائمة */
        .new-chat-btn, .new-folder-btn, .history-item, .clear-history-btn {
            display: flex !important;
            align-items: center !important;
            justify-content: flex-start !important;
            text-align: right !important;
            width: 100% !important;
            padding: 10px 15px !important;
            font-weight: 700 !important;
            font-size: 0.95rem !important;
            border-radius: 5px;
            transition: 0.3s;
            cursor: pointer;
            gap: 10px !important;
            margin-bottom: 10px !important;
            margin-top: 0 !important;
        }

        .folder-header {
            display: flex !important;
            align-items: center !important;
            justify-content: space-between !important;
            text-align: right !important;
            width: 100% !important;
            padding: 10px 10px !important;
            font-weight: 700 !important;
            font-size: 0.95rem !important;
            border-radius: 5px;
            transition: 0.3s;
            cursor: pointer;
            gap: 10px !important;
            margin-bottom: 10px !important;
            position: relative;
            background: rgba(255, 255, 255, 0.05) !important;
            color: #d7ccc8 !important;
            border: none !important;
        }

        .folder-header:hover { background: rgba(255, 255, 255, 0.1) !important; color: #fff !important; }
        
        .folder-header .dots-btn { opacity: 0; color: #d7ccc8; padding: 5px 10px; }
        .folder-header:hover .dots-btn { opacity: 1; }
        .folder-header:hover .arrow-icon, .folder-header:hover .dots-btn { color: #fff; }
        
        .folder-header .arrow-icon {
            margin-right: auto !important;
            margin-left: 0 !important;
            font-family: "Font Awesome 6 Free", "Font Awesome 5 Free", sans-serif !important;
            font-weight: 900 !important;
            font-size: 0.8em;
            transition: transform 0.3s;
        }

        /* ألوان الأزرار */
        .new-chat-btn { background-color: transparent !important; border: 1px solid rgba(255,255,255,0.2) !important; color: #fff !important; margin-bottom: 5px; }
        .new-chat-btn:hover { background-color: rgba(255,255,255,0.1) !important; }
        
        .new-folder-btn { background-color: transparent !important; border: 1px dashed rgba(255, 179, 0, 0.5) !important; color: #ffb300 !important; margin-bottom: 10px; }
        .new-folder-btn:hover { background-color: rgba(255, 179, 0, 0.1) !important; }
        
        .clear-history-btn { background-color: transparent !important; border: 1px solid rgba(255, 82, 82, 0.4) !important; color: #ff8a80 !important; margin-top: 5px; margin-bottom: 20px !important; }
        .clear-history-btn:hover { background-color: rgba(255, 82, 82, 0.1) !important; border-color: #ff5252 !important; color: #ff5252 !important; }

        /* العناصر التاريخية */
        .history-item { 
			color: #d7ccc8 !important; 
			background: transparent; 
			display: flex !important;
			align-items: center !important;
			justify-content: space-between !important; /* هذا هو السر: يوزع العناصر على الأطراف */
			width: 100% !important;
			padding: 10px !important;
			box-sizing: border-box !important;
			overflow: visible !important; /* عشان القائمة تخرج برا حدود العنصر */
			position: relative !important; 
			z-index: 1 !important; /* ترتيب مبدئي */
			}
		/* تنسيق النص (عشان ياخد المساحة المتبقية ومايزقش النقط بره) */
		.history-text {
			flex-grow: 1 !important;        /* يملأ المساحة الفاضية */
			text-align: right !important;   /* الكلام يمين */
			white-space: nowrap !important; /* سطر واحد بس */
			overflow: hidden !important;    /* لو الكلام كتير يقصه */
			text-overflow: ellipsis !important; /* يحط ... */
			margin-left: 10px !important;   /* مسافة بين الكلام والنقط */
		}
        .history-item:hover { background-color: rgba(255,255,255,0.1) !important; color: #fff !important; z-index: 100 !important; }
        .history-item.active { background-color: rgba(255, 179, 0, 0.2) !important; color: #ffb300 !important; border-right: 3px solid #ffb300 !important; }

        /* زر داخل المجلد */
        .new-chat-folder-btn {
            display: block !important; text-align: right !important; width: 100%; margin-top: 5px;
            font-family: 'Cairo', sans-serif !important; font-size: 0.85em !important;
            color: #ffb300 !important; background: rgba(255, 179, 0, 0.05) !important;
            padding: 8px 15px !important; border-radius: 5px; border: none !important; cursor: pointer;
        }
        .new-chat-folder-btn:hover { background: rgba(255, 179, 0, 0.15) !important; }

        /* الأساسيات */
        * { margin: 0; padding: 0; box-sizing: border-box; }
        body { font-family: 'Cairo', sans-serif; background-color: var(--bg-color); height: 100vh; display: flex; overflow: hidden; }

		
        .logo-section { display: flex; align-items: center; gap: 10px; margin-bottom: 5px !important; padding-bottom: 10px !important; border-bottom: 1px solid rgba(255,255,255,0.1); }
        .logo-img { width: 40px; height: auto; }
        .logo-text { font-size: 1.2rem; font-weight: bold; color: var(--accent-color); }
        
        .fixed-links { margin-top: 5px !important; padding-bottom: 15px !important; margin-bottom: 15px !important; border-bottom: 1px solid rgba(255,255,255,0.2) !important; }
        
        .history-list { flex: 1; overflow-y: auto; margin-top: 10px; padding-bottom: 50px; }
        .folder-item { margin-bottom: 5px; }
        .folder-content { padding-right: 10px; border-right: 2px solid rgba(255, 255, 255, 0.1); margin-top: 2px; margin-right: 5px; display: none; }

        /* القوائم المنسدلة */
        .menu-container { 
			position: relative !important;
			overflow: visible !important; 
			margin-right: auto; 
			flex-shrink: 0 !important;      /* يمنعها من الانكماش */
			margin-right: 0 !important;     /* إلغاء الـ auto القديم */
			width: 40px !important;         /* عرض ثابت للحاوية */
			display: flex !important;
			justify-content: center !important; /* توسيط الأيقونة جوة الحاوية */
		}
        .dots-btn { background: none; border: none; color: #aaa; padding: 5px 8px; cursor: pointer; font-size: 1rem; transition: 0.3s; border-radius: 50%; opacity: 0; }
        .history-item:hover .dots-btn { opacity: 1; }
        .dots-btn:hover { color: #fff; background-color: rgba(255,255,255,0.1); }
        /* تنسيق القائمة المنسدلة (النسخة الداكنة المتناسقة) */
.dropdown-menu {
    display: none; /* للإخفاء المبدئي */
    position: absolute;
    z-index: 999999; /* رقم عالي جداً */
    
    /* 🎨 استعادة الألوان الأصلية */
    background-color: #2d1e1b; /* بني غامق جداً (زي الهيدر) */
    border: 1px solid rgba(255, 179, 0, 0.3); /* حدود ذهبية خفيفة */
    color: #ffffff; /* النص أبيض */
    
    /* الشكل والظل */
    border-radius: 8px;
    box-shadow: 0 4px 15px rgba(0,0,0,0.5); /* ظل قوي */
    padding: 5px 0;
    min-width: 180px;
    font-size: 0.9rem;
    text-align: right;
}

/* تنسيق العناصر داخل القائمة */
.menu-item {
    padding: 10px 15px;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 10px;
    transition: all 0.2s ease;
    color: #e0e0e0; /* أبيض هادي */
    border-bottom: 1px solid rgba(255,255,255,0.05); /* خط فاصل خفيف */
}
		.menu-item:last-child {
    border-bottom: none;
}
        .menu-item:hover {
    background-color: rgba(255, 255, 255, 0.1); /* تفتيح الخلفية */
    color: #ffb300; /* النص يتحول لذهبي */
    padding-right: 20px; /* حركة بسيطة لليمين */
}
        .menu-item.delete-option:hover {
    background-color: rgba(211, 47, 47, 0.2);
    color: #ff8a80;
}
.menu-item.delete-option:hover i {
    color: #ff8a80;
}
        .gold-icon { color: #ffd700; margin-right: auto; font-size: 0.8rem; }

        .user-profile { border-top: 1px solid rgba(255,255,255,0.2); padding-top: 15px; display: flex; align-items: center; justify-content: space-between; gap: 10px; }
        .user-info { display: flex; align-items: center; gap: 10px; }
        .user-avatar { width: 30px; height: 30px; background: var(--accent-color); border-radius: 50%; display: flex; justify-content: center; align-items: center; color: var(--primary-color); font-weight: bold; }
        .logout-btn { background: none; border: none; color: #ff8a80; cursor: pointer; font-size: 1.1rem; transition: 0.2s; }
        .logout-btn:hover { color: #ff5252; transform: scale(1.1); }

        .main-content { flex: 1; display: flex; flex-direction: column; position: relative; background-color: var(--bg-color); width: 100% !important; margin-left: 0 !important; }
        .mobile-header { display: none !important; background: var(--primary-color); color: white; padding: 10px; align-items: center; justify-content: space-between; }
        .chat-container { flex: 1; overflow-y: auto; padding: 20px; display: flex; flex-direction: column; gap: 20px; padding-bottom: 100px; }
        
        .message { display: flex; gap: 15px; max-width: 800px; margin: 0 auto; width: 100%; padding: 10px; border-radius: 8px; position: relative; }
        .message.user { background-color: var(--chat-bg-user); }
        .message.ai { background-color: var(--chat-bg-ai); border: 1px solid #ddd; padding-bottom: 35px; }
        .message-avatar { width: 35px; height: 35px; border-radius: 5px; display: flex; justify-content: center; align-items: center; flex-shrink: 0; }
        .user .message-avatar { background-color: #4CAF50; color: white; }
        .ai .message-avatar { background-color: var(--primary-color); color: var(--accent-color); }
        
		/* 3. تنسيق محتوى الرسالة (الألوان والأحجام) */
.message-content {
    font-family: 'Cairo', sans-serif;
    color: #212121;
    line-height: 1.8;
    font-size: 1rem;
    text-align: right;
}

/* تنسيق القوائم والنقاط */
.message-content ul, .message-content ol { 
    margin-right: 25px !important; 
    padding-right: 0 !important; 
}
.message-content li { 
    display: list-item !important; 
    margin-bottom: 5px; 
}

/* تنسيق النص العريض (Bold) - يظهر باللون الأحمر القاني */
.message-content strong, .message-content b { 
    font-weight: 800 !important; 
    color: #b71c1c !important; 
}

/* تنسيق العناوين - تظهر باللون البني وتحتها خط */
.message-content h1, .message-content h2, .message-content h3 { 
    color: #3e2723; 
    font-weight: 700; 
    margin-top: 15px; 
    border-bottom: 2px solid #ffcc80; 
}

/* 4. تنسيق مؤشر الكتابة الوامض */
.typing-cursor::after { 
    content: "▋"; 
    display: inline-block; 
    color: var(--primary-color); 
    animation: blink 1s infinite; 
    margin-right: 2px; 
    font-size: 0.8em; 
}

@keyframes blink { 
    0%, 100% { opacity: 1; } 
    50% { opacity: 0; } 
}

/* --- تنسيقات منطقة الكتابة الأساسية --- */
.input-area { 
    position: absolute; 
    bottom: 0; 
    left: 0; 
    right: 0; 
    background: transparent; 
    padding: 20px; 
    display: flex; 
    justify-content: center; 
    background-image: linear-gradient(to top, var(--bg-color) 80%, transparent); 
    z-index: 20; 
}


textarea { 
    flex: 1; 
    border: none; 
    outline: none; 
    resize: none; 
    padding: 10px; 
    font-family: 'Cairo', sans-serif; 
    max-height: 200px; 
    height: 50px; 
}

.send-btn { 
    background: var(--primary-color); 
    color: var(--accent-color); 
    border: none; 
    border-radius: 5px; 
    width: 40px; 
    height: 40px; 
    cursor: pointer; 
    transition: 0.2s; 
}

.send-btn:hover { background-color: #5d4037; }

.typing-indicator { 
    display: none; 
    position: absolute; 
    bottom: 90px; 
    left: 50%; 
    transform: translateX(-50%); 
    font-style: italic; 
    color: #888; 
    font-size: 0.9rem; 
    z-index: 10; 
    background-color: rgba(255,255,255,0.8); 
    padding: 2px 10px; 
    border-radius: 10px; 
}

/* --- إعدادات الموبايل (الكود المصحح بالكامل) --- */
@media (max-width: 768px) {
    
    /* 1. إصلاح اختفاء البار العلوي */
    .mobile-header {
        /* السطر السحري اللي كان ناقص لإظهار البار */
        display: flex !important; 
        align-items: center !important;
        justify-content: space-between !important;

        /* التثبيت والأبعاد */
        position: fixed !important;
        top: 0 !important;
        left: 0 !important;
        width: 100% !important;
        min-height: 60px !important;
        z-index: 1001 !important;
        
        /* التعامل مع النوتش (Notch) */
        padding-top: env(safe-area-inset-top, 10px) !important;
        padding-bottom: 10px !important;
        padding-left: 15px !important;
        padding-right: 15px !important;
        
        margin: 0 !important;
        background-color: var(--primary-color) !important;
    }

    /* 2. ضبط هوامش الشات عشان الكلام مايستخباش */
    .chat-container {
        padding-top: 90px !important;   /* مسافة للهيدر */
        padding-bottom: 100px !important; /* مسافة لبوكس الكتابة */
    }

    /* 3. تثبيت صندوق الكتابة أسفل الشاشة */
    .input-area {
        position: fixed !important;
        bottom: 0 !important;
        left: 0 !important;
        width: 100% !important;
        
        background: #fff !important;
        border-top: 1px solid #eee;
        
        padding: 10px !important;
        padding-bottom: env(safe-area-inset-bottom, 10px) !important;
        
        z-index: 1002 !important;
		padding-bottom: max(10px, env(safe-area-inset-bottom)) !important;
    }

    /* 4. رفع مؤشر الكتابة (Typing...) فوق الصندوق */
    .typing-indicator { 
        bottom: 90px !important; 
        position: fixed !important; /* تثبيت عشان مايتحركش مع السكرول */
    }

    /* 5. تحسين عرض الرسائل في الموبايل */
    .message {
        max-width: 90% !important;
    }
    
    .message.ai { 
        padding-bottom: 30px; 
    }
    
    /* 6. إعدادات السايدبار والقوائم */
    .sidebar { 
        position: fixed !important; 
        top: 0 !important; 
        right: 0 !important; 
        width: 280px !important; 
        height: 100% !important; 
        
        /* 🔥 هذا هو الحل: نضيف !important عشان يغلب كود الكمبيوتر */
        transform: translateX(100%) !important; 
        
        z-index: 2000 !important; 
        box-shadow: -2px 0 10px rgba(0,0,0,0.5) !important; 
        transition: transform 0.3s ease !important; /* نعومة الحركة */
    }

    /* وتأكد أن كود الفتح موجود تحته */
    .sidebar.active { 
        transform: translateX(0) !important; 
    }
    
    
    .sidebar button, .sidebar div, .sidebar span, .sidebar i { 
        position: static !important; 
        transform: none !important; 
    }
    
    .close-sidebar-btn { 
        display: flex !important; 
        justify-content: center; 
        align-items: center; 
        position: absolute !important; 
        top: 15px !important; 
        left: 15px !important; 
        z-index: 2001 !important; 
        width: 40px; 
        height: 40px; 
        background-color: rgba(0,0,0,0.2); 
        border-radius: 50%; 
        border: 2px solid rgba(255,255,255,0.3); 
        color: #ffffff !important; 
        font-size: 1.5rem; 
        cursor: pointer; 
    }
    
    .dots-btn { 
        opacity: 1 !important; 
        color: rgba(255, 255, 255, 0.8); 
        padding: 12px 15px !important; 
        font-size: 1.4rem; 
        min-width: 44px; 
        min-height: 44px; 
        display: flex; 
        align-items: center; 
        justify-content: center; 
    }
    
    .menu-container { 
        margin-right: -10px; 
        padding-left: 10px; 
    }
}


        .modal { display: flex; position: fixed; top: 0; left: 0; width: 100%; height: 100%; background: rgba(0,0,0,0.6); z-index: 2000; justify-content: center; align-items: center; }
        .modal-content { background: white; padding: 25px; border-radius: 10px; width: 90%; max-width: 400px; text-align: center; box-shadow: 0 4px 15px rgba(0,0,0,0.2); position: relative; }
        .modal h3 { color: var(--primary-color); margin-bottom: 15px; }
        /* ابحث عن هذا الجزء وعدله */
		.modal input { 
			width: 100%; 
			padding: 12px; 
			margin: 8px 0; 
			/* 👇 التعديل هنا: ضيفنا !important ولون أغمق شوية عشان يبان */
			border: 1px solid #ccc !important; 
			border-radius: 5px; 
			font-family: 'Cairo'; 
		}
        .modal button { width: 100%; padding: 12px; background: var(--primary-color); color: white; border: none; border-radius: 5px; cursor: pointer; font-weight: bold; margin-top: 10px; }
        .modal button:hover { background-color: #5d4037; }
        .close-modal-btn { position: absolute; top: 10px; right: 15px; font-size: 1.8rem; color: #aaa; cursor: pointer; font-weight: bold; line-height: 1; transition: 0.2s; }
        .close-modal-btn:hover { color: #d32f2f; }
        .switch-auth-link { display: block; margin-top: 15px; color: var(--primary-color); cursor: pointer; font-size: 0.9rem; text-decoration: underline; }

/* ==================================================
   إصلاح فونتات وألوان نافذة البروفايل (شامل)
   ================================================== */

		/* 1. تطبيق خط Cairo مع دعم الإيموجي */
		#profile-modal,
		#profile-modal input,
		#profile-modal button,
		#profile-modal h3,
		#profile-modal p,
		#profile-modal span,
		#profile-modal div {
			font-family: 'Cairo', 'Segoe UI Emoji', 'Apple Color Emoji', 'Noto Color Emoji', sans-serif !important;
		}

		/* 2. 🔥 إصلاح الألوان (عشان الكلام يبان) 🔥 */
		/* جعل النصوص الأساسية باللون البني الغامق بدل الأبيض الموروث */
		#profile-modal .modal-content,
		#profile-modal p, 
		#profile-modal span, 
		#profile-modal strong,
		#profile-modal div {
			color: #3e2723 !important; /* بني غامق */
		}

/* 3. استثناء الأزرار (عشان تفضل كتابتها بيضاء) */
		#profile-modal button {
			font-weight: 700;
			letter-spacing: 0.5px;
			color: #3e2723 !important; /* الكتابة جوه الزرار تضل بيضاء */
		}

/* 4. ضبط خانات الإدخال */
		#profile-modal input {
			font-weight: 600;
			font-size: 0.95rem;
			color: #333 !important; /* النص اللي بيتكتب يكون غامق */
		}

/* 5. تنسيق الأيقونات (الخط + اللون) */
		#profile-modal i {
			font-family: "Font Awesome 5 Free", "Font Awesome 6 Free", sans-serif !important;
			font-weight: 900 !important;
			color: #ffb300 !important; /* لون ذهبي للأيقونات عشان تبان */
			margin-left: 5px;
		}


        @media print {
            body * { visibility: hidden; }
            body::before { content: "⚠️ عذراً، الطباعة متاحة فقط من خلال زر 'تحويل PDF' للمشتركين المميزين."; visibility: visible; position: fixed; top: 50%; left: 50%; transform: translate(-50%, -50%); font-size: 20px; color: #b71c1c; font-weight: bold; text-align: center; width: 100%; }
        }
        .overlay { position: fixed; top: 0; left: 0; width: 100%; height: 100%; background-color: rgba(0, 0, 0, 0.5); z-index: 1999; display: none; opacity: 0; transition: opacity 0.3s ease; }
        .overlay.active { display: block; opacity: 1; }


/* --- تخصيص السكرول بار للسايدبار الجديد --- */

/* توحيد شكل السكرول في الموقع كله */
.sidebar-scroll-area::-webkit-scrollbar,
.chat-container::-webkit-scrollbar,
.history-list::-webkit-scrollbar {
    width: 6px;
}

.sidebar-scroll-area::-webkit-scrollbar-track,
.chat-container::-webkit-scrollbar-track,
.history-list::-webkit-scrollbar-track {
    background: transparent;
}

.sidebar-scroll-area::-webkit-scrollbar-thumb,
.chat-container::-webkit-scrollbar-thumb,
.history-list::-webkit-scrollbar-thumb {
    background-color: rgba(215, 204, 200, 0.4); /* لون هادي */
    border-radius: 20px;
}

.sidebar-scroll-area::-webkit-scrollbar-thumb:hover,
.chat-container::-webkit-scrollbar-thumb:hover,
.history-list::-webkit-scrollbar-thumb:hover {
    background-color: rgba(62, 39, 35, 0.6); /* لون أغمق عند الماوس */
}
.sidebar-scroll-area {
    scrollbar-width: thin;
    scrollbar-color: rgba(215, 204, 200, 0.3) transparent;
}

/* حل مشكلة الزووم في الآيفون */
@media screen and (max-width: 768px) {
    input, textarea, select, #user-input {
        font-size: 16px !important;
    }
}

/* --- تنسيق القائمة المنسدلة العلوية للموبايل --- */
/* تنسيق قائمة هيدر الموبايل */
.header-dropdown {
    display: none;
    position: absolute;
    
    /* مكان القائمة */
    top: 110%; /* تحت الزرار */
    left: 0;   /* 👈 محاذاة لليسار عشان الزرار في أقصى الشمال */
    /* لو الزرار علي اليمين (عربي) خليها left: 0 ولو انجليزي right: 0 */
    
    width: 170px;
    background-color: #2d1e1b;
    border: 1px solid rgba(255, 179, 0, 0.3);
    border-radius: 8px;
    box-shadow: 0 4px 15px rgba(0,0,0,0.5);
    z-index: 3000; /* رقم عالي عشان تظهر فوق كل حاجة */
    text-align: right;
    padding: 5px 0;
}

.header-menu-item {
    padding: 10px 15px;
    color: #fff;
    font-size: 0.9rem;
    cursor: pointer;
    border-bottom: 1px solid rgba(255,255,255,0.05);
    display: flex;
    align-items: center;
    gap: 10px;
}

.header-menu-item:last-child {
    border-bottom: none;
}

.header-menu-item:hover {
    background-color: rgba(255, 255, 255, 0.1);
    color: #ffb300;
}

/* إظهار القائمة */
.header-dropdown.show {
    display: block;
}

.header-menu-item i {
    width: 20px;        /* مهم للمحاذاة */
    text-align: center; /* توسيط الأيقونة */
    color: #ffb300;     /* 🔥 لون ذهبي متناسق مع باقي الموقع */
}

@keyframes fadeInMenu {
    from { opacity: 0; transform: translateY(-10px); }
    to { opacity: 1; transform: translateY(0); }
}

/* تنسيق أزرار الهيدر الجديدة في السايدبار */
.sidebar-actions {
    display: flex;
    gap: 15px;
    align-items: center;
    margin-right: auto; /* عشان يروحوا أقصى اليسار */
    padding-left: 10px;
}

.sidebar-icon-btn {
    background: none;
    border: none;
    color: #d7ccc8;
    font-size: 1.2rem;
    cursor: pointer;
    transition: 0.2s;
    padding: 5px;
    border-radius: 5px;
}

.sidebar-icon-btn:hover {
    color: #fff;
    background-color: rgba(255, 255, 255, 0.1);
    transform: scale(1.1);
}

/* تنسيق القائمة المنسدلة في السايدبار (تصحيح العرض المضغوط) */
/* تنسيق القائمة المنسدلة (أسلوب الـ 3 نقط) */
.sidebar-dropdown {
    display: none; /* مخفية افتراضياً */
    position: absolute; /* مطلقة بالنسبة للعلبة اللي هي فيها */
    
    /* 🔥 المكان: تحت العلبة (الزرار) مباشرة 🔥 */
    top: 110%; 
    
    /* 🔥 المحاذاة: ابدأ من الشمال (عشان إحنا في أقصى اليسار) 🔥 */
    left: 0;  
    
    /* الأبعاد والشكل */
    width: 180px; /* عرض مناسب */
    background-color: #2d1e1b;
    border: 1px solid rgba(255, 179, 0, 0.3);
    border-radius: 8px;
    box-shadow: 0 4px 15px rgba(0,0,0,0.5);
    z-index: 1000;
    text-align: right;
    padding: 5px 0;
}

/* تنسيق العناصر جوه القائمة */
.sidebar-dropdown .menu-item {
    padding: 10px 15px;
    color: #fff;
    cursor: pointer;
    font-size: 0.9rem;
    transition: background 0.2s;
    display: flex;
    align-items: center;
    gap: 10px;
}

.sidebar-dropdown .menu-item:hover {
    background-color: rgba(255, 255, 255, 0.1);
    color: #ffb300;
}

/* كلاس مساعد لإظهار القائمة بالجافاسكريبت */
.sidebar-dropdown.show {
    display: block;
}

.sidebar-dropdown .menu-item i {
    width: 20px;
    text-align: center;
    color: #ffb300; /* أيقونات ذهبية */
}

/* عشان الأيقونات تكون مضبوطة */
.menu-item i {
    width: 20px;
    text-align: center;
    color: #ffb300; /* الأيقونات ذهبية دائماً */
}

/* =========================================
   🔥 إصلاح شامل لتخطيط الصفحة والمسافات 🔥
   ========================================= */

/* 1. ضبط هيدر الموبايل (عشان مياكلش الكلام) */
.mobile-header {
    position: relative !important; /* يزق المحتوى تحته */
    width: 100%;
    z-index: 1000;
}

/* 2. إخفاء هيدر الموبايل في شاشات الكمبيوتر */
@media (min-width: 769px) {
    .mobile-header {
        display: none !important;
    }
    /* تعديل المسافة للعنوان في الكمبيوتر */
    #chat-header-title {
        margin-top: 15px !important;
    }
}

/* 3. ضبط المسافات في الموبايل (الحل الجذري) */
@media (max-width: 768px) {
    
    /* أ) ضبط حاوية السكرول عشان تبدأ بعد الهيدر */
    #scroll-container {
        padding-top: 0px !important; /* الهيدر Relative فمش محتاجين حشو */
        
        /* 👇👇👇 ضيف السطور دي ضروري للآيفون 👇👇👇 */
        overflow-anchor: none !important;  /* يمنع المتصفح من تغيير المكان تلقائياً */
        -webkit-overflow-scrolling: touch; /* يخلي السكرول ناعم وطبيعي */
    }

    /* ب) ضبط العنوان الأصفر (لصق في الهيدر والشات) */
    #chat-header-title {
        margin-top: 10px !important;    /* مسافة صغيرة تحت الهيدر */
        margin-bottom: 0px !important;  /* 🔥 إلغاء المسافة اللي تحته */
    }

    /* ج) ضبط صندوق الشات (عشان يلزق في العنوان) */
    #chat-box {
        margin-top: 0px !important;
        padding-top: 5px !important;    /* مسافة صغيرة جداً بينه وبين العنوان */
    }

    /* د) إلغاء أي مسافة فوق أول رسالة (عشان الفراغ الكبير يختفي) */
    #chat-box > div:first-child {
        margin-top: 0px !important;
    }

    /* هـ) إصلاح رسالة الترحيب (لو مقصوصة أو بعيدة) */
    .welcome-message, .empty-state {
        margin-top: 10px !important;    /* تقريبها من فوق */
        padding-top: 0 !important;
    }
}

/* --- تنسيقات خاصة وقت تصدير PDF --- */

/* 1. إجبار الخلفية تكون بيضاء (أو أي لون تحبه) وقت الطباعة */
/* --- ألوان مخصصة للـ PDF (إجبارية) --- */
/* بنستخدم Hex Codes بدل الـ Variables عشان المكتبة تقرأها صح */

/* 1. خلفية الشات والكونتينر */
.printing-mode {
    background-color: #f5f5f5 !important; /* رمادي فاتح للخلفية */
    color: #000000 !important;
    font-family: 'Cairo', sans-serif !important;
}

/* 2. رسائل المستخدم (User) */
.printing-mode .message.user {
    background-color: #e8f5e9 !important; /* أخضر فاتح جداً */
    color: #1b5e20 !important;             /* أخضر غامق للنص */
    border: 1px solid #c8e6c9 !important;
}

/* 3. رسائل المساعد (AI) */
.printing-mode .message.ai {
    background-color: #ffffff !important; /* أبيض */
    color: #212121 !important;            /* رمادي غامق للنص */
    border: 1px solid #e0e0e0 !important;
}

/* 4. إخفاء أيقونات النسخ والـ PDF والأزرار داخل الـ PDF */
.printing-mode .message-actions,
.printing-mode .copy-btn,
.printing-mode .pdf-btn {
    display: none !important;
}

/* 5. ضبط العنوان الأصفر */
.printing-mode #chat-header-title {
    background-color: #fff3e0 !important;
    color: #e65100 !important;
    border: 1px solid #ffe0b2 !important;
}

/* 6. إخفاء مؤشر الكتابة */
.printing-mode #typing-indicator {
    display: none !important;
}

.download-img-btn {
    background: #e91e63; /* لون وردي مميز للصور */
    color: white;
    border: none;
    padding: 5px 10px;
    border-radius: 5px;
    cursor: pointer;
    font-size: 0.9rem;
    transition: background 0.3s;
}

.download-img-btn:hover {
    background: #c2185b;
}


/* تنسيق رسائل الشات داخل لوحة التحكم */
.chat-msg {
    margin-bottom: 15px;
    padding: 10px 15px;
    border-radius: 8px;
    line-height: 1.6;
    font-size: 0.95rem;
}

.chat-msg.user {
    background-color: #e3f2fd; /* لون أزرق فاتح للسؤال */
    border-right: 4px solid #2196f3;
    margin-left: 20px;
}

.chat-msg.ai {
    background-color: #ffffff; /* لون أبيض للإجابة */
    border: 1px solid #ddd;
    border-right: 4px solid #4caf50; /* أخضر للإجابة */
    margin-right: 20px;
}

.msg-label {
    font-weight: bold;
    display: block;
    margin-bottom: 5px;
    font-size: 0.8rem;
    color: #555;
}

/* ================================================= */
/* 🔥 مؤشر الكتابة (مكان مظبوط + شفافية + حركة) 🔥 */
/* ================================================= */

/* 1. الحاوية (مسؤولة عن المكان والتوسيط فقط) */
#typing-container {
    position: absolute !important; /* مكانها بالنسبة لمنطقة الشات */
    bottom: 90px !important;       /* فوق شريط الكتابة */
    left: 0 !important;
    width: 100% !important;        /* بعرض الشات */
    
    display: flex;                 /* السر في التوسيط */
    justify-content: center;       /* سنتر يا بطل */
    z-index: 1000;
    pointer-events: none;          /* عشان متمنعش الضغط حواليها */
}

/* 2. المؤشر نفسه (مسؤول عن الشكل والأنيميشن) */
#typing-indicator {
    /* أ) الشفافية (Glassmorphism) */
    background: rgba(255, 255, 255, 0.85) !important; /* أبيض شفاف */
    backdrop-filter: blur(8px) !important;            /* تغييم الخلفية وراه */
    -webkit-backdrop-filter: blur(8px);               /* لسفاري */
    
    /* ب) الحدود والظلال */
    border: 1px solid rgba(255, 167, 38, 0.4) !important; /* حدود برتقالي خفيفة */
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.1) !important; /* ضل ناعم */
    border-radius: 50px !important;
    padding: 10px 30px !important;
    
    /* ج) النص */
    color: #e65100 !important;
    font-weight: bold;
    font-size: 0.9rem;
    text-align: center;
    white-space: nowrap;
    
    /* د) التشغيل */
    pointer-events: auto;
    display: none; /* الجافاسكريبت بيظهره */
    
    /* هـ) الحركة (النبض) */
    animation: glassPulse 2s infinite ease-in-out !important;
}

/* 3. تعريف حركة النبض */
@keyframes glassPulse {
    0% {
        transform: scale(1);
        box-shadow: 0 0 0 0 rgba(230, 81, 0, 0.1);
    }
    50% {
        transform: scale(1.05); /* تكبير خفيف */
        border-color: #ff9800;  /* الحدود بتنور */
        box-shadow: 0 0 15px 0 rgba(230, 81, 0, 0.2); /* توهج */
    }
    100% {
        transform: scale(1);
        box-shadow: 0 0 0 0 rgba(230, 81, 0, 0);
    }
}

/* ==================================================
   🔥 تنسيق مؤشر التحميل الجديد (خط بيلف) 🔥
   ================================================== */

.message.ai {
    position: relative !important; 
}

.message-spinner {
    position: absolute;
    /* 👇 تغيير المكان: أرقام موجبة عشان يدخل جوة */
    top: 15px;       
    left: 15px;      
    z-index: 10;
    
    /* 👇 تصميم الخط اللي بيلف (CSS Pure) */
    width: 25px;
    height: 25px;
    border: 3px solid rgba(255, 179, 0, 0.2); /* اللون الباهت (التراك) */
    border-top: 3px solid #ffb300;            /* اللون الذهبي المتحرك */
    border-radius: 50%;                       /* عشان يبقى دايرة */
    
    /* 👇 الحركة */
    animation: rotation 1s linear infinite;
    
    /* إلغاء الخلفية البيضاء القديمة ليكون شفافاً ونظيفاً */
    background-color: transparent; 
    box-shadow: none;
}

/* تعريف حركة الدوران */
@keyframes rotation {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* تنسيق للموبايل (ممكن نصغره شوية لو حابب) */
@media (max-width: 768px) {
    .message-spinner {
        width: 20px;
        height: 20px;
        border-width: 2px; /* خط أرفع شوية في الموبايل */
        top: 10px;
        left: 10px;
    }
}


/* -----------------------------------------------------------
   توحيد شكل السكرول بار (Scrollbar Styling)
   ----------------------------------------------------------- */

/* 1. عرض السكرول بار (للجسم ولأي عنصر تاني) */
::-webkit-scrollbar {
    width: 8px;  /* عرض السكرول الرأسي (رفيع وشيك) */
    height: 8px; /* ارتفاع السكرول الأفقي */
}

/* 2. لون المسار (Track) - الخلفية اللي بيمشي فيها */
::-webkit-scrollbar-track {
    background: rgba(0, 0, 0, 0.2); /* لون غامق شفاف جداً */
    border-radius: 4px; /* تدوير الحواف */
}

/* 3. لون المقبض (Thumb) - الجزء اللي بتحركه */
::-webkit-scrollbar-thumb {
    background-color: #5d4037; /* لون بني غامق (نفس ثيم الخشب) */
    border-radius: 4px; /* مدور */
    border: 1px solid rgba(255, 255, 255, 0.1); /* برواز خفيف جداً يبرزه */
}

/* 4. لما الماوس يجي عليه (Hover) */
::-webkit-scrollbar-thumb:hover {
    background-color: #8d6e63; /* يفتح شوية عشان يبان إنه نشط */
}

/* --- دعم متصفح Firefox (اختياري) --- */
* {
    scrollbar-width: thin;          /* رفيع */
    scrollbar-color: #5d4037 rgba(0, 0, 0, 0.2); /* (لون المقبض) (لون المسار) */
}