/*
Script Name: Q&A
Description: Question and answer script: Accuracy and professionalism in content writing
Version: 1.2.4
*/
@import url('https://fonts.googleapis.com/css2?family=Noto+Sans+Arabic:wght@400;700&display=swap');

:root {
    --color-primary: rgb(22, 68, 91);
    --color-primary-dark: rgb(15, 48, 65);
    --color-gold: #C8A051;
    --color-bg: #f8fafc;
    --color-white: #ffffff;
    --color-text-main: #1f2937;
    --color-text-muted: #6b7280;
    --font-main: 'Noto Sans Arabic', sans-serif;
}

* { box-sizing: border-box; }

body {
    font-family: var(--font-main);
    background-color: var(--color-bg);
    margin: 0;
    padding: 0;
    color: var(--color-text-main);
}

.container { max-width: 56rem; margin: 0 auto; padding: 0 1rem; }
.flex { display: flex; }
.justify-between { justify-content: space-between; }
.items-center { align-items: center; }
.text-center { text-align: center; }
.fixed { position: fixed; }
.gap-3 { gap: 0.75rem; }

/* Header */
header {
    background-color: var(--color-primary);
    color: var(--color-white);
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
    position: sticky;
    top: 0;
    z-index: 50;
}
.header-inner { padding: 1rem; }
.logo-area { display: flex; align-items: center; gap: 0.75rem; }
.logo-icon { color: var(--color-gold); }
.badge {
    background-color: rgba(0, 0, 0, 0.2);
    padding: 0.25rem 0.75rem;
    border-radius: 0.5rem;
    border: 1px solid rgba(200, 160, 81, 0.3);
    font-size: 0.875rem;
}
.nav-link {
    color: rgba(255,255,255,0.8);
    text-decoration: none;
    font-size: 0.9rem;
    padding: 0.5rem;
    border-radius: 0.375rem;
    transition: all 0.2s;
}
.nav-link:hover, .nav-link.active {
    color: white;
    background: rgba(255,255,255,0.1);
}

/* Chat */
.chat-container { padding-bottom: 6rem; min-height: calc(100vh - 140px); margin-top: 1rem; }

.message-wrapper { display: flex; width: 100%; margin-bottom: 1rem; animation: slideUp 0.3s ease-out; }
.message-bubble { max-width: 85%; padding: 1rem; border-radius: 1rem; line-height: 1.6; box-shadow: 0 1px 2px 0 rgba(0, 0, 0, 0.05); }
.bot-wrapper { justify-content: flex-start; }
.user-wrapper { justify-content: flex-end; }
.bot-bubble { background-color: var(--color-white); border: 1px solid #e5e7eb; border-top-right-radius: 0; color: var(--color-text-main); }
.user-bubble { background-color: var(--color-primary); color: var(--color-white); border-top-left-radius: 0; }

.btn { padding: 0.5rem 1rem; border-radius: 9999px; cursor: pointer; border: none; font-family: inherit; transition: all 0.2s; }
.btn-send { background-color: var(--color-primary); color: white; width: 2.5rem; height: 2.5rem; display: flex; align-items: center; justify-content: center; border-radius: 50%; }
.btn-send:hover { background-color: var(--color-primary-dark); }
.btn-action { font-size: 0.75rem; background-color: #eff6ff; color: var(--color-primary); padding: 0.25rem 0.75rem; text-decoration: none; display: inline-flex; align-items: center; gap: 0.25rem; }
.btn-action:hover { background-color: #dbeafe; }

.input-area { background-color: var(--color-white); border-top: 1px solid #e5e7eb; padding: 1rem; bottom: 0; left: 0; width: 100%; }
.input-wrapper { max-width: 56rem; margin: 0 auto; position: relative; }
.chat-input { width: 100%; background-color: #f9fafb; border: 1px solid #e5e7eb; border-radius: 9999px; padding: 1rem 1.5rem 1rem 3.5rem; font-size: 1rem; outline: none; font-family: inherit; }
.chat-input:focus { border-color: var(--color-primary); box-shadow: 0 0 0 2px rgba(22, 68, 91, 0.1); }
.send-icon-wrapper { position: absolute; left: 0.5rem; top: 50%; transform: translateY(-50%); }

/* QA Card (Single View) */
.qa-card { background: white; border-radius: 1rem; overflow: hidden; box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1); margin-bottom: 1.5rem; border: 1px solid #e5e7eb; }
.qa-header { background: #f9fafb; padding: 1rem 1.5rem; border-bottom: 1px solid #e5e7eb; font-weight: bold; }
.qa-body { padding: 1.5rem; font-size: 1.225rem; }
.qa-title { padding: 1.5rem; font-size: 1.425rem; font-weight: bold; }
.answer-card { border-top: 4px solid var(--color-primary); }
.answer-header { background: rgba(22, 68, 91, 0.05); color: var(--color-primary); padding: 1rem 1.5rem; font-weight: bold; color: #333; }

/* Related Questions Section */
.related-section { margin-top: 2rem; margin-bottom: 2rem; }
.related-header { 
    display: flex; align-items: center; gap: 0.5rem; 
    font-weight: bold; color: #4b5563; margin-bottom: 1rem; font-size: 1.1rem;
}
.related-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 0.75rem; }
.related-item { 
    background: white; border: 1px solid #e5e7eb; border-radius: 0.5rem; 
    padding: 1rem; text-decoration: none; color: var(--color-text-main);
    display: flex; gap: 0.75rem; transition: all 0.2s;
}
.related-item:hover { border-color: var(--color-gold); box-shadow: 0 2px 4px rgba(0,0,0,0.05); }
.related-icon { color: var(--color-gold); font-weight: bold; }
.related-text { font-size: 0.9rem; line-height: 1.4; }

/* Question List (Archive) */
.q-grid { display: grid; grid-template-columns: 1fr; gap: 1rem; }
.q-list-card { 
    display: flex; align-items: center; gap: 1rem;
    background: white; padding: 1.25rem; border-radius: 0.75rem;
    text-decoration: none; color: inherit; border: 1px solid #e5e7eb;
    transition: all 0.2s;
}
.q-list-card:hover { border-color: var(--color-gold); transform: translateY(-2px); box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.05); }
.q-icon { width: 40px; height: 40px; background: #eff6ff; color: var(--color-primary); border-radius: 50%; display: flex; align-items: center; justify-content: center; font-weight: bold; flex-shrink: 0; }
.q-content { flex: 1; }
.q-title { margin: 0 0 0.5rem 0; font-size: 1rem; font-weight: 600; color: var(--color-primary); }
.q-meta { font-size: 0.75rem; color: #9ca3af; display: flex; gap: 1rem; }
.q-arrow { color: #d1d5db; font-size: 1.2rem; }

/* Pagination */
.pagination { display: flex; justify-content: center; gap: 0.5rem; margin-top: 2rem; flex-wrap: wrap; }
.page-link {
display: flex;
    align-items: center;
    justify-content: center;
    width: 2.5rem;
    height: 2.5rem;
    border-radius: 0.5rem;
    background: white;
    border: 1px solid #e5e7eb;
    text-decoration: none;
    color: var(--color-text-main);
    font-size: 0.9rem;
    transition: all 0.2s;
    margin-bottom: 10px;
}
.page-link:hover, .page-link.active { background-color: var(--color-primary); color: white; border-color: var(--color-primary); }
.page-link.arrow { font-weight: bold; background: #f9fafb; }

@keyframes slideUp { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: translateY(0); } }

/* --- تنسيقات نافذة التحقق الأمني (Modal) --- */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.6); /* خلفية شبه شفافة داكنة */
    z-index: 9999; /* لضمان ظهورها فوق كل شيء */
    display: flex; /* لضبط التوسط */
    justify-content: center; /* توسيط أفقي */
    align-items: center; /* توسيط عمودي */
    backdrop-filter: blur(5px); /* تأثير ضبابي للخلفية (اختياري) */
}

.modal-content {
    background: #fff;
    padding: 2rem;
    border-radius: 15px;
    width: 90%;
    max-width: 400px; /* أقصى عرض للنافذة */
    text-align: center;
    box-shadow: 0 10px 25px rgba(0,0,0,0.2);
    animation: fadeIn 0.3s ease-in-out;
}

.modal-header h3 {
    margin: 0 0 1rem 0;
    color: #333;
    font-family: 'Noto Sans Arabic', sans-serif;
}

.captcha-box {
    background: #f3f4f6;
    padding: 1rem;
    border-radius: 8px;
    margin: 1rem 0;
    border: 2px dashed #ccc;
}

.form-input {
    width: 100%;
    padding: 10px;
    border: 1px solid #ddd;
    border-radius: 8px;
    outline: none;
    box-sizing: border-box; /* لضمان عدم خروج الحقل عن الإطار */
}

.form-input:focus {
    border-color: #007bff; /* لون حدود عند الكتابة */
}

.btn-submit {
    background-color: #007bff; /* لون الزر */
    color: white;
    border: none;
    padding: 10px 20px;
    border-radius: 8px;
    cursor: pointer;
    font-family: 'Noto Sans Arabic', sans-serif;
    font-weight: bold;
    width: 100%;
    transition: background 0.3s;
}

.btn-submit:hover {
    background-color: #0056b3;
}

/* حركة ظهور ناعمة */
@keyframes fadeIn {
    from { opacity: 0; transform: translateY(-20px); }
    to { opacity: 1; transform: translateY(0); }
}
/* --- تنسيقات الفوتر --- */
.site-footer {
    background-color: #16445b; /* لون خلفية داكن */
    color: #fff; /* لون النص */
    padding: 15px 0;
    text-align: center;
    position: relative; /* ضروري لتموضع زر الصعود */
    font-family: 'Noto Sans Arabic', sans-serif;
}

.site-footer .container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 15px;
    display: flex;
    flex-direction: column;
    gap: 15px; /* مسافة بين العناصر */
}

/* تنسيق الحقوق */
.copyright-row p {
    margin: 0;
    font-size: 14px;
    color: #ccc; /* رمادي فاتح */
}

/* تنسيق الروابط */
.footer-nav {
    list-style: none;
    padding: 0;
    margin: 0;
    display: flex;
    justify-content: center;
    gap: 20px; /* مسافة بين الروابط */
    flex-wrap: wrap;
}

.footer-nav li a {
    text-decoration: none;
    color: #fff;
    font-weight: bold;
    font-size: 16px;
    transition: color 0.3s;
}

.footer-nav li a:hover {
    color: #f1c40f; /* لون ذهبي عند المرور (يمكن تغييره) */
}

/* تنسيق أيقونات السوشيال ميديا */
.social-row {
    margin-top: 0px;
}

.social-row a {
    color: #fff;
    margin: 0 10px;
    font-size: 18px;
    transition: transform 0.3s;
    display: inline-block;
}

.social-row a:hover {
    transform: translateY(-3px); /* حركة بسيطة للأعلى عند المرور */
    color: #ddd;
}

/* --- زر الصعود للأعلى (عائم وثابت) --- */
#scrollToTopBtn {
    position: fixed; /* هذا ما يجعله يثبت على الشاشة */
    bottom: 30px;    /* المسافة من أسفل الشاشة */
    right: 30px;     /* المسافة من يمين الشاشة */
    z-index: 9999;   /* رقم كبير لضمان ظهوره فوق أي عنصر آخر */
    
    background-color: #000; /* اللون الأحمر (عدله لـ #000 إذا أردته أسود) */
    color: white;
    border: none;
    border-radius: 50%;
    width: 50px;      /* قمت بتكبيره قليلاً ليكون أوضح */
    height: 50px;
    cursor: pointer;
    font-size: 20px;
    display: none;    /* سنخفيه مبدئياً ونظهره بالجافاسكربت عند النزول */
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 10px rgba(0,0,0,0.3); /* ظل ليعطي تأثيراً عائماً */
    transition: background-color 0.3s, transform 0.3s;
}

#scrollToTopBtn:hover {
    background-color: #333; /* لون عند التحويم */
    transform: translateY(-5px); /* حركة بسيطة للأعلى عند التحويم */
}

/* --- تجاوب مع الموبايل --- */
@media (max-width: 768px) {
    #scrollToTopBtn {
        bottom: 20px; /* مسافة أقل قليلاً في الموبايل */
        right: 20px;
        width: 45px;
        height: 45px;
        font-size: 18px;
    }
}
/* --- أزرار التحكم في السؤال (للمشرفين) --- */
.admin-actions {
    display: flex;
    gap: 10px; /* مسافة بين زر التعديل والحذف */
}

.action-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    border-radius: 50%; /* شكل دائري */
    text-decoration: none;
    font-size: 14px;
    transition: all 0.2s ease;
    background-color: white; /* خلفية بيضاء لتمييزها عن خلفية الهيدر */
}

/* زر التعديل (أزرق) */
.action-btn.edit {
    color: #2563eb;
    border: 1px solid #2563eb;
}

.action-btn.edit:hover {
    background-color: #2563eb;
    color: white;
}

/* زر الحذف (أحمر) */
.action-btn.delete {
    color: #dc2626;
    border: 1px solid #dc2626;
}

.action-btn.delete:hover {
    background-color: #dc2626;
    color: white;
}
/* 1. تنسيق المنطقة الرئيسية لضمان عمل الخاصية بشكل صحيح */
main.container {
    position: relative; /* ضروري لعمل الـ sticky داخلها */
    min-height: 85vh;   /* لضمان أن المحتوى يملأ الشاشة والفوتر يبقى بالأسفل */
    display: flex;
    flex-direction: column;
}

/* 2. تنسيق صندوق المحادثة ليصبح "لاصقاً" وليس ثابتاً */
.input-area {
    position: sticky !important; /* التغيير الجوهري هنا */
    bottom: 20px;    /* مسافة صغيرة من أسفل الشاشة */
    z-index: 1000;
    margin-top: auto; /* يدفع الصندوق للأسفل في حال كان المحتوى قليلاً */
    
    /* تنسيقات جمالية إضافية */
    background: #fff;
    padding: 15px;
    box-shadow: 0 -5px 15px rgba(0,0,0,0.05); /* ظل خفيف */
    border-radius: 15px; /* حواف دائرية لجمالية أكثر */
    border: 1px solid #eee;
}
/* --- إضافات لتنظيف التنسيقات المضمنة (Inline Styles) --- */

/* تنسيقات الهيدر والشعار */
.logo-link {
    color: var(--color-white);
    text-decoration: none;
    display: flex;
    gap: 0.5rem;
    align-items: center;
}

.logo-text {
    font-weight: 700;
    font-size: 1.25rem;
    margin: 0;
}
.logo-title {
    font-weight: 700;
    font-size: 1.25rem;
}

.admin-link {
    color: #ef4444;
    font-weight: bold;
}

/* تنسيقات روابط الإدارة */
.nav-link-danger {
    color: #ef4444 !important;
    font-weight: bold;
}

/* تنسيقات المحتوى العام */
.page-title {
    font-size: 1.8rem;
    font-weight: bold;
    margin-bottom: 1rem;
}

/* تنسيقات خاصة بصفحة "عن الموقع" */
.highlight-title {
    margin-top: 0;
    color: #0369a1;
}

.no-margin-bottom {
    margin-bottom: 0;
}

.slogan-text {
    text-align: center;
    margin-top: 2rem;
    font-weight: bold;
    color: #2563eb;
    font-size: 1.2rem;
}
/* تنسيقات الصفحة الرئيسية (index.php) - عرض السؤال */
.qa-view-wrapper { margin-top: 2rem; }
.btn-back-link { background: none; padding-right: 0; margin-bottom: 1rem; }
.qa-header-flex { display: flex; justify-content: space-between; align-items: center; }

/* تنسيقات الصفحة الرئيسية - المحادثة */
.chat-welcome-box { margin-top: 4rem; opacity: 0.8; }
.chat-welcome-title { font-size: 1.5rem; font-weight: bold; margin-bottom: 1rem; }
.welcome-container { margin-top: 4rem; opacity: 0.8; }
/* --- Q&A Styles --- */
.qa-wrapper {
    margin-top: 2rem;
}
/* === إعدادات خاصة باللغة العربية (RTL) === */
html[dir="rtl"] body,
html[dir="rtl"] .site-footer {
    direction: rtl;
    text-align: right;
}

/* === إعدادات خاصة باللغة الإنجليزية (LTR) === */
html[dir="ltr"] body,
html[dir="ltr"] .site-footer {
    direction: ltr;
    text-align: left;
}