/* =========================================
   Design System Variables (نظام تصميم جسفت)
========================================= */
@import url('https://fonts.googleapis.com/css2?family=IBM+Plex+Sans+Arabic:wght@400;500;600;700&family=Noto+Kufi+Arabic:wght@400;500;600;700;800&display=swap');

:root {
    /* Brand Colors */
    --primary: #5B2C86;
    --primary-hover: #472269;
    --primary-soft: #F8F5FB;
    
    --secondary: #00B0AD;
    --secondary-hover: #008A89;
    --secondary-soft: #EEFBFA;
    
    --accent: #FDB714;
    --accent-soft: #FFF0C2;
    
    /* Neutrals */
    --ink: #211A2A;
    --body-text: #51495B;
    --muted: #7C7484;
    --border: #E4DEE7;
    --input-border: #CFC4D4;
    --soft-bg: #F7F5F8;
    --canvas: #FCFBFD;
    --white: #FFFFFF;
    --dark-surface: #29183A;
    
    /* Semantics */
    --success: #168A62;
    --success-soft: #ECF9F3;
    --danger: #B53A4B;
    --danger-soft: #FFF0F2;
    
    /* Shadows & Radius */
    --shadow-sm: 0 2px 8px rgba(41, 24, 58, 0.06);
    --shadow-card: 0 10px 30px rgba(58, 37, 77, 0.06);
    --shadow-hover: 0 20px 54px rgba(41, 24, 58, 0.12);
    --focus-ring: 0 0 0 4px rgba(0, 176, 173, 0.16);
    
    --radius-sm: 6px;
    --radius-md: 10px;
    --radius-lg: 16px;
    --radius-full: 9999px;
}

/* =========================================
   General Styles
========================================= */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: 'IBM Plex Sans Arabic', system-ui, -apple-system, sans-serif;
}

html, body {
    background-color: var(--canvas);
    color: var(--body-text);
    line-height: 1.85;
    overflow-x: hidden; /* يمنع ظهور الفراغ الجانبي نهائياً */
    width: 100%;
    max-width: 100vw;
}

h1, h2, h3, h4, h5, h6, 
.content-title, .form-title, .pdf-header h3 {
    font-family: 'Noto Kufi Arabic', sans-serif;
    color: var(--ink);
    font-weight: 700;
}

img {
    max-width: 100%;
    height: auto;
}

/* =========================================
   تعديل تمدد الهيدر ليأخذ الارتفاع بالكامل
========================================= */
.header {
    background-color: var(--white);
    border-bottom: 1px solid var(--border);
    position: relative !important;
    z-index: 1000;
    padding: 0 !important; /* هام جداً: إزالة أي حواف تمنع الزر من الوصول للحافة */
}

.nav {
    display: flex;
    justify-content: space-between;
    align-items: stretch; /* إجبار العناصر على التمدد */
    max-width: 1280px;
    margin: 0 auto;
    height: 90px; /* تحديد ارتفاع صريح وثابت للهيدر (أكبر قليلاً وأفخم) */
    padding: 0 2rem;
}

.logo {
    display: flex;
    align-items: center;
    height: 100%;
}

.logo img {
    height: 55px;
}

.tools {
    display: flex;
    gap: 1.5rem;
    align-items: center;
}

.tools a {
    text-decoration: none;
    color: var(--body-text);
    transition: color 0.2s ease;
    font-weight: 500;
}

.tools a:hover {
    color: var(--secondary);
}

.nav-items {
    display: flex;
    align-items: stretch; /* إجبار عناصر القائمة على التمدد */
    height: 100%;
}

.nav-item {
    display: flex;
    align-items: stretch; /* إجبار الرابط الداخلي على التمدد */
    position: static !important;
}

.nav-item > a {
    display: flex;
    align-items: center; /* توسيط النص بداخل المساحة الممتدة */
    height: 100%; /* هام جداً: أخذ 100% من ارتفاع الهيدر (90px) */
    padding: 0 1.5rem;
    color: var(--ink);
    font-weight: 600;
    font-size: 1.15rem; /* تكبير الخط قليلاً ليتوازن مع حجم اللوجو */
    text-decoration: none;
    transition: all 0.3s ease;
    border-bottom: 4px solid transparent; /* زيادة سمك الخط السفلي قليلاً ليكون أبرز */
}

/* إضافة السهم بجانب النص */
.nav-item > a:not([href="index.php"])::after {
    content: "\f078";
    font-family: "Font Awesome 6 Free";
    font-weight: 900;
    font-size: 0.75rem;
    color: var(--muted);
    transition: transform 0.3s ease, color 0.3s ease;
    margin-right: 6px; /* <--- هذه هي الإضافة التي ستبعد السهم عن الكلمة مسافة ممتازة */
}

/* تأثير التفعيل عند الضغط (Active State) و المرور الخفيف */
.nav-item:hover > a {
    color: var(--primary);
}
.nav-item:hover > a::after {
    color: var(--primary);
}

.nav-item.active-mega > a {
    background-color: var(--primary);
    color: var(--white);
    border-bottom-color: var(--secondary);
}

.nav-item.active-mega > a::after {
    color: var(--white);
    transform: rotate(180deg);
}

/* القائمة الضخمة بعرض الشاشة */
.mega-menu {
    position: absolute;
    top: 100%;
    left: 0;
    width: 100%;
    background-color: var(--white);
    border-top: 1px solid var(--border);
    border-bottom: 3px solid var(--primary);
    box-shadow: 0 20px 40px rgba(58, 37, 77, 0.08);
    
    /* إخفاء القائمة افتراضياً لانتظار كليك الجافاسكريبت */
    opacity: 0;
    visibility: hidden;
    transform: translateY(15px);
    transition: all 0.3s cubic-bezier(0.2, 0.8, 0.2, 1);
    z-index: -1;
}

/* الفتح فقط عند إضافة كلاس active-mega عبر الجافاسكريبت */
.nav-item.active-mega .mega-menu {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
    z-index: 999;
}

.mega-menu-inner {
    max-width: 1280px;
    margin: 0 auto;
    /* زدنا المسافة العلوية (top) إلى 4rem لتنزيل المحتوى للأسفل قليلاً */
    padding: 2rem 2rem 3rem; 
}

.mega-column {
    min-width: 250px;
}

.mega-column-title {
    color: var(--primary);
    font-family: 'Noto Kufi Arabic', sans-serif;
    font-size: 1.35rem; /* كبرنا الخط من 1.125 إلى 1.35 */
    font-weight: 700;
    margin-bottom: 2rem; /* مسافة أكبر بين العنوان والروابط */
}

.mega-link-list {
    list-style: none;
    padding: 0;
    margin: 0;
    column-count: 3;
    column-gap: 3rem;
}

.mega-link-list li {
    margin-bottom: 1.25rem; /* زدنا التباعد بين كل رابط لتتنفس القائمة */
    break-inside: avoid;
}

.mega-link-list a {
    color: var(--body-text);
    text-decoration: none;
    font-size: 1.15rem; /* كبرنا الخط من 1rem إلى 1.15rem */
    font-weight: 500;
    transition: all 0.2s ease;
    display: inline-block;
}

.mega-link-list a:hover {
    color: var(--secondary);
    transform: translateX(-5px);
}

/* =========================================
   Main Content Layout
========================================= */
.main-content {
    max-width: 1280px;
    margin: 3rem auto;
    padding: 0 2rem;
}

.content-title {
    font-size: clamp(1.85rem, 3vw, 2.5rem);
    margin-bottom: 1rem;
    color: var(--primary);
    letter-spacing: -0.01em;
}

.content-description {
    color: var(--muted);
    font-size: 1.125rem;
    margin-bottom: 2.5rem;
}

/* Special case for content page */
.main-content.form {
    background: var(--white);
    border-radius: var(--radius-lg);
    border: 1px solid var(--border);
    box-shadow: var(--shadow-sm);
    padding: 3rem;
}

/* =========================================
   Forms & Inputs
========================================= */
.form-title {
    font-size: 1.8rem;
    margin-bottom: 1rem;
    color: var(--primary);
}

.form-description {
    color: var(--muted);
    margin-bottom: 2.5rem;
}

.required-info {
    color: var(--danger);
    margin-bottom: 2rem;
    font-size: 0.875rem;
}

.form-group {
    margin-bottom: 1.5rem;
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 2rem;
}

.input-group {
    margin-bottom: 1.5rem;
}

.input-group label {
    display: block;
    margin-bottom: 0.5rem;
    font-weight: 600;
    font-size: 0.875rem;
    color: var(--ink);
}

.input-group label .required {
    color: var(--danger);
    margin-right: 4px;
}

.form-control {
    width: 100%;
    min-height: 48px; 
    padding: 0.75rem 1rem;
    background-color: var(--white);
    border: 1px solid var(--input-border);
    border-radius: var(--radius-md);
    font-size: 1rem;
    color: var(--ink);
    transition: all 0.2s ease;
}

.form-control::placeholder {
    color: var(--muted);
}

.form-control:focus {
    outline: none;
    border-color: var(--secondary);
    box-shadow: var(--focus-ring);
}

.form-control.with-icon {
    padding-left: 2.5rem;
}

textarea.form-control {
    min-height: 120px;
    resize: vertical;
    line-height: 1.6;
}

/* Select Dropdown */
select.form-control {
    appearance: none;
    -webkit-appearance: none;
    -moz-appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%2351495B' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'%3E%3C/polyline%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: left 1rem center;
    background-size: 1rem;
}

[dir="rtl"] select.form-control {
    background-position: left 1rem center;
    padding-left: 1rem;
    padding-right: 1rem;
}

.input-icon, .input-with-icon i {
    position: absolute;
    left: 1rem;
    top: 50%;
    transform: translateY(-50%);
    color: var(--muted);
}

.input-with-icon {
    position: relative;
}

.helper-text {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    color: var(--muted);
    font-size: 0.875rem;
    margin-top: 0.5rem;
}

.helper-text i {
    color: var(--secondary);
}

/* =========================================
   Buttons
========================================= */
.form-buttons {
    display: flex;
    justify-content: flex-end;
    gap: 1rem;
    margin-top: 3rem;
    padding-top: 1.5rem;
    border-top: 1px solid var(--border);
}

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    height: 48px;
    padding: 0 2rem;
    border-radius: var(--radius-md);
    border: none;
    font-weight: 600;
    font-size: 1rem;
    cursor: pointer;
    transition: all 0.2s cubic-bezier(0.2, 0.8, 0.2, 1);
}

.btn-primary {
    background-color: var(--primary);
    color: var(--white);
}

.btn-primary:hover {
    background-color: var(--primary-hover);
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(92, 44, 135, 0.2);
}

.btn-secondary {
    background-color: var(--secondary);
    color: var(--white);
}

.btn-secondary:hover {
    background-color: var(--secondary-hover);
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 176, 173, 0.2);
}

/* =========================================
   Text Content
========================================= */
.text-content {
    line-height: 1.9;
    color: var(--body-text);
    font-size: 1.125rem;
    margin-bottom: 2rem;
}

.content-footer {
    margin-top: 3rem;
    padding-top: 1.5rem;
    border-top: 1px solid var(--border);
    display: flex;
    justify-content: flex-end;
}

.last-update {
    color: var(--muted);
    font-size: 0.875rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.last-update i {
    color: var(--secondary);
}

/* =========================================
   Components (PDF, Cards, Files)
========================================= */
.pdf-viewer-container {
    margin-top: 2rem;
    background: var(--white);
    border-radius: var(--radius-lg);
    border: 1px solid var(--border);
    box-shadow: var(--shadow-card);
    padding: 2rem;
}

.pdf-header {
    margin-bottom: 1.5rem;
    padding-bottom: 1.5rem;
    border-bottom: 1px solid var(--border);
}

.file-description {
    color: var(--muted);
    margin-bottom: 1rem;
}

.empty-state {
    text-align: center;
    padding: 4rem 2rem;
    background: var(--soft-bg);
    border-radius: var(--radius-lg);
    border: 1px dashed var(--input-border);
    color: var(--muted);
}

.empty-state i {
    margin-bottom: 1rem;
    color: var(--accent);
    font-size: 2.5rem;
}

/* Files Grid */
.files-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 1.5rem;
    margin-top: 2rem;
}

.file-card {
    background: var(--white);
    border-radius: var(--radius-lg);
    border: 1px solid var(--border);
    box-shadow: var(--shadow-sm);
    padding: 1.5rem;
    display: flex;
    flex-direction: column;
    transition: all 0.2s cubic-bezier(0.2, 0.8, 0.2, 1);
}

.file-card:hover {
    transform: translateY(-4px);
    box-shadow: var(--shadow-hover);
}

.file-icon {
    text-align: center;
    margin-bottom: 1.5rem;
    color: var(--primary);
    background-color: var(--primary-soft);
    padding: 1rem;
    border-radius: var(--radius-md);
    width: fit-content;
    margin-left: auto;
    margin-right: auto;
}

.file-info h3 {
    margin: 0 0 0.5rem;
    color: var(--ink);
    font-size: 1.125rem;
}

.file-meta {
    display: flex;
    justify-content: space-between;
    font-size: 0.875rem;
    color: var(--muted);
    margin-bottom: 1.5rem;
    padding-top: 1rem;
    border-top: 1px solid var(--soft-bg);
}

.file-meta span {
    display: flex;
    align-items: center;
    gap: 0.4rem;
}

.file-actions {
    display: flex;
    gap: 0.75rem;
    margin-top: auto;
}

.file-actions .btn {
    flex: 1;
    height: 40px;
    padding: 0 1rem;
    font-size: 0.875rem;
    background-color: var(--soft-bg);
    color: var(--primary);
}

.file-actions .btn:hover {
    background-color: var(--primary-soft);
}

/* =========================================
   News Grid & Cards
========================================= */
.news-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(350px, 1fr));
    gap: 1.5rem;
    margin-top: 2rem;
}

.news-card {
    background: var(--white);
    border-radius: var(--radius-lg);
    border: 1px solid var(--border);
    box-shadow: var(--shadow-card);
    overflow: hidden;
    display: flex;
    flex-direction: column;
    transition: all 0.2s ease;
}

.news-card:hover {
    transform: translateY(-4px);
    box-shadow: var(--shadow-hover);
}

.news-image {
    aspect-ratio: 16/10;
    overflow: hidden;
}

.news-image img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform 0.3s;
}

.news-card:hover .news-image img {
    transform: scale(1.03);
}

.news-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem 1.5rem;
    background-color: var(--white);
    border-bottom: 1px solid var(--soft-bg);
}

.news-type {
    padding: 6px 12px;
    border-radius: var(--radius-full);
    font-size: 0.75rem;
    font-weight: 600;
}

.news-type.خبر {
    background-color: var(--primary-soft);
    color: var(--primary);
}

.news-type.اعلان {
    background-color: var(--secondary-soft);
    color: var(--secondary);
}

.news-date {
    font-size: 0.875rem;
    color: var(--muted);
    display: flex;
    align-items: center;
    gap: 0.4rem;
}

.news-body {
    padding: 1.5rem;
    flex: 1;
}

.news-body h3 {
    margin: 0 0 1rem;
    color: var(--ink);
    font-size: 1.25rem;
    line-height: 1.5;
}

/* =========================================
   Filters & Pagination
========================================= */
.filter-container {
    background-color: var(--soft-bg);
    border-radius: var(--radius-lg);
    padding: 1.5rem;
    margin-bottom: 2rem;
    border: 1px solid var(--border);
}

.filter-form {
    display: flex;
    flex-wrap: wrap;
    gap: 15px;
    align-items: flex-end;
}

.filter-form .form-group {
    flex: 1;
    min-width: 200px;
    margin-bottom: 0;
}

.filter-summary {
    background-color: var(--white);
    border-radius: var(--radius-md);
    padding: 1rem 1.5rem;
    margin-bottom: 2rem;
    border: 1px solid var(--border);
}

.filter-summary h3 {
    font-size: 1rem;
    color: var(--ink);
}

.filter-summary li {
    background: var(--primary-soft);
    border: 1px solid var(--border);
    border-radius: var(--radius-full);
    padding: 4px 12px;
    margin: 5px 5px 0 0;
    font-size: 0.875rem;
    color: var(--primary);
}

/* Pagination */
.pagination {
    display: flex;
    justify-content: center;
    margin-top: 3rem;
    gap: 0.5rem;
}

.pagination a, 
.pagination span {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 40px;
    height: 40px;
    padding: 0 0.5rem;
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    color: var(--body-text);
    text-decoration: none;
    font-weight: 500;
    transition: all 0.2s ease;
}

.pagination a:hover {
    background-color: var(--primary-soft);
    color: var(--primary);
    border-color: var(--primary);
}

.pagination .active {
    background-color: var(--primary);
    color: var(--white);
    border-color: var(--primary);
}

/* =========================================
   Alerts (Semantic)
========================================= */
.alert {
    padding: 1rem 1.5rem;
    border-radius: var(--radius-md);
    margin-bottom: 1.5rem;
    display: flex;
    align-items: center;
    gap: 0.75rem;
    font-weight: 500;
}

.alert-success {
    background-color: var(--success-soft);
    color: var(--success);
    border: 1px solid rgba(22, 138, 98, 0.2);
}

.alert-danger {
    background-color: var(--danger-soft);
    color: var(--danger);
    border: 1px solid rgba(181, 58, 75, 0.2);
}

/* =========================================
   Footer (Updated & Stable)
========================================= */
.footer {
    /* استخدام المتغير، وفي حال عدم وجوده يستخدم البنفسجي الغامق جداً الخاص بالجمعية */
    background-color: var(--dark-surface, #3b1c57); 
    color: var(--white, #ffffff);
    padding: 4rem 2rem 2rem;
    width: 100%;
    clear: both; /* يمنع تداخل الفوتر مع العناصر العائمة قبله */
    position: relative;
    margin-top: auto; /* يدفعه لأسفل الصفحة دائماً */
    z-index: 10;
}

.footer-content {
    max-width: 1280px;
    margin: 0 auto;
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 3rem;
}

/* في الشاشات الصغيرة يندمج في عمود واحد لتجنب التشوه */
@media (max-width: 768px) {
    .footer-content {
        grid-template-columns: 1fr;
        gap: 2rem;
    }
}

.footer-section h3 {
    margin-bottom: 1.5rem;
    font-size: 1.25rem;
    /* استخدام المتغير، وفي حال عدم وجوده يستخدم التركواز */
    color: var(--accent, #00B0AD); 
}

.footer-section ul {
    list-style: none;
    padding: 0;
    margin: 0;
}

.footer-section ul li {
    margin-bottom: 1rem;
}

.footer-section a {
    color: rgba(255, 255, 255, 0.85);
    text-decoration: none;
    transition: all 0.2s ease;
}

.footer-section a:hover {
    color: var(--accent, #00B0AD);
}

.social-icons {
    display: flex;
    gap: 1rem;
    margin-top: 1.5rem;
}

.social-icons a {
    width: 44px;
    height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
    background-color: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 50%; /* بديل آمن لـ var(--radius-full) */
    transition: all 0.2s;
    color: #fff;
}

.social-icons a:hover {
    /* استخدام المتغير، وفي حال عدم وجوده يستخدم الأصفر/الذهبي */
    background-color: var(--secondary, #FDB713);
    border-color: var(--secondary, #FDB713);
    color: var(--white, #ffffff);
    transform: translateY(-2px);
}

.footer-bottom {
    max-width: 1280px;
    margin: 3rem auto 0;
    padding-top: 1.5rem;
    border-top: 1px solid rgba(255, 255, 255, 0.1);
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 0.875rem;
    color: rgba(255, 255, 255, 0.6);
}

@media (max-width: 768px) {
    .footer-bottom {
        flex-direction: column;
        gap: 1rem;
        text-align: center;
    }
}

.footer-bottom a {
    color: rgba(255, 255, 255, 0.6);
    text-decoration: none;
    margin: 0 0.5rem;
    transition: color 0.2s;
}

.footer-bottom a:hover {
    color: var(--accent, #00B0AD);
}

/* =========================================
   Responsive Design (المتجاوب للجوال)
========================================= */
.menu-toggle {
    display: none;
    cursor: pointer;
    font-size: 1.5rem;
    background: none;
    border: none;
    color: var(--primary);
}

@media (max-width: 1024px) {
    .nav { flex-wrap: wrap; padding: 0 1rem; min-height: 70px; }
    .logo { order: 1; }
    .menu-toggle { display: block; order: 2; margin-left: auto; margin-top:12px; }
    
    .tools {
        order: 3;
        width: 100%;
        padding: 1rem 0;
        border-bottom: 1px solid var(--border);
        justify-content: center;
    }
    
    /* قائمة الجوال */
    .nav-items {
        display: none;
        flex-direction: column;
        width: 100%;
        order: 4;
        position: absolute;
        top: 100%;
        right: 0;
        background: var(--white);
        border-top: 1px solid var(--border);
        height: auto;
        z-index: 1001;
    }
    
    .nav-items.active { display: flex; }
    
    .nav-item { flex-direction: column; position: relative !important; }
    
    .nav-item > a {
        padding: 1rem;
        border-bottom: 1px solid var(--soft-bg);
    }
    
    .nav-item:hover > a, .nav-item.active-mega > a {
        background-color: transparent;
        color: var(--primary);
        border-bottom-color: var(--soft-bg);
    }
    
    .nav-item.active-mega > a::after {
        color: var(--primary);
    }
    
    /* القائمة الضخمة في الجوال */
    .mega-menu {
        position: relative;
        box-shadow: none;
        border: none;
        padding: 0;
        opacity: 1;
        visibility: visible;
        transform: none;
        display: none;
        background-color: var(--soft-bg);
        z-index: 1;
    }
    
    .nav-item.active-mega .mega-menu {
        display: block;
    }
    
    .mega-menu-inner {
        padding: 1.5rem;
    }
    
    .mega-link-list {
        column-count: 1; /* عرض الروابط تحت بعض في الجوال */
    }

    .main-content { padding: 0 1.5rem; }
    .form-group { grid-template-columns: 1fr; gap: 0; }
    .footer-content { grid-template-columns: repeat(2, 1fr); gap: 2rem; }
}

@media (max-width: 768px) {
    .logo img { height: 45px; }
    .form-buttons { flex-direction: column; gap: 1rem; align-items: stretch; }
    .btn { width: 100%; }
    .footer-content { grid-template-columns: 1fr; }
    .footer-bottom { flex-direction: column; text-align: center; gap: 1rem; }
    .pdf-viewer iframe { height: 400px; }
    .main-content.form { padding: 1.5rem; }
}

@media (max-width: 480px) {
    .main-content { padding: 0 1rem; }
    .filter-form .form-group { min-width: 100%; }
    .pagination { flex-wrap: wrap; }
    .pdf-viewer iframe { height: 300px; }
}

/* RTL Helpers */
[dir="rtl"] .menu-toggle {
    margin-right: 0;
    margin-left: 0;
}