
/*
Theme Name: Ruqya Theme
Theme URI: http://alestinara.com/
Author: Alestinara
Description: قالب الرقية الشرعية المطور (إصلاح انزلاق التحديد + تحديد صارم)
Version: 5.4
Text Domain: ruqya-theme
*/

/* =========================================
   1. متغيرات النظام (Variables)
   ========================================= */
:root {
    --primary-color: #003333;      
    --secondary-color: #005555;    
    
    --accent-color: #FFD700;       
    --text-main: #333333;
    --text-light: #ffffff;
    --bg-body: #F8F5E6;            
    --bg-content: #ffffff;
    
    --header-height: 450px;      
    --header-height-mobile: 140px;
    --sidebar-collapsed: 80px;     
    --sidebar-expanded: 320px;     
}

/* =========================================
   2. إعدادات عامة
   ========================================= */
* { box-sizing: border-box; margin: 0; padding: 0; }

html { 
    font-size: 18px; 
    scroll-behavior: smooth; 
    overflow-x: hidden; 
    width: 100%;
}

body {
    font-family: 'Tajawal', Tahoma, Arial, sans-serif;
    line-height: 1.8;
    color: var(--text-main);
    background-color: var(--bg-body);
    direction: rtl;
    overflow-x: hidden;
    width: 100%;
    position: relative;
    -webkit-font-smoothing: antialiased;
    text-rendering: optimizeLegibility;
}

strong, b { color: var(--secondary-color); font-weight: 800; }
.site-header, .main-navigation, .site-footer { margin: 0; padding: 0; }
ul { list-style: none; }

/* =========================================
   3. الهيدر (Header)
   ========================================= */
.alestinara-header {
    width: 100%; height: var(--header-height);
    background-size: cover; background-position: center center;
    background-color: var(--primary-color);
    position: relative; z-index: 10;
    -webkit-mask-image: linear-gradient(to bottom, black 0%, black 70%, transparent 100%);
    mask-image: linear-gradient(to bottom, black 0%, black 70%, transparent 100%);
}

.header-container {
    width: 95%; margin: 0 auto; display: flex; 
    justify-content: space-between; align-items: center;
    padding: 0 20px; height: 100%;
    text-shadow: 0 2px 10px rgba(0,0,0,0.4);
}

.logo-container {
    width: 110px; height: 110px;
    background: rgba(255,255,255,0.1); border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
    border: 2px solid rgba(255,255,255,0.4);
    backdrop-filter: blur(5px); cursor: pointer; transition: transform 0.3s ease;
}
.logo-container:hover { transform: scale(1.05); border-color: var(--accent-color); }
.logo-image { width: 100%; height: 100%; object-fit: cover; border-radius: 50%; }

.header-menu { display: flex; gap: 15px; }
.header-menu a {
    color: var(--text-light); text-decoration: none;
    font-size: 1rem; font-weight: 600; padding: 8px 20px;
    border-radius: 30px; background: rgba(0,0,0,0.4);
    border: 1px solid rgba(255,255,255,0.3); transition: all 0.3s ease;
}
.header-menu a:hover { background: var(--text-light); color: var(--primary-color); }
@media (max-width: 768px) { .header-left { display: none; } }

/* =========================================
   4. التخطيط الرئيسي والشريط الجانبي
   ========================================= */
.alestinara-main-container {
    display: flex; min-height: calc(100vh - var(--header-height));
    position: relative; width: 100%; margin-top: 0; 
    z-index: 20; max-width: 100vw; overflow-x: hidden;
}

.alestinara-sidebar {
    width: var(--sidebar-collapsed);
    background: linear-gradient(180deg, var(--secondary-color) 0%, var(--primary-color) 100%);
    transition: width 0.4s cubic-bezier(0.25, 0.46, 0.45, 0.94);
    position: relative; z-index: 100;
    box-shadow: 3px 0 15px rgba(0,0,0,0.1);
    flex-shrink: 0; cursor: pointer;
    border-top-left-radius: 0; overflow: visible; 
}

.alestinara-sidebar.expanded { 
    width: var(--sidebar-expanded); 
    cursor: default; overflow-y: auto; overflow-x: hidden !important;
}

.sidebar-menu { display: flex; flex-direction: column; padding: 10px 0; width: 100%; }

/* هام: إضافة z-index للعنصر لمنع التداخل */
.sidebar-menu li { 
    width: 100%; 
    position: relative; 
    z-index: 1;
}

.sidebar-menu a {
    display: flex; align-items: center;
    color: var(--text-light); text-decoration: none;
    margin: 4px 0; 
    border-radius: 0; 
    background: transparent; 
    min-height: 60px; 
    transition: all 0.2s ease;
    
    /* التوسيط */
    justify-content: center; 
    padding: 0;
    
    white-space: normal !important; word-break: break-word !important; hyphens: auto;
    border-bottom: 1px solid rgba(255,255,255,0.05); 
}

/* عند فتح القائمة: محاذاة النص لليمين */
.alestinara-sidebar.expanded .sidebar-menu a { 
    justify-content: flex-start; 
    padding-right: 25px; 
}

/* تأثير التمرير (Hover) */
.sidebar-menu a:hover {
    background: rgba(255,255,255,0.1); 
    box-shadow: inset 5px 0 0 var(--accent-color);
}

.menu-text { display: none; }

.alestinara-sidebar.expanded .menu-text {
    display: block; font-weight: 700; font-size: 1.1rem; animation: fadeInText 0.4s ease;
    width: 100%;
}

@keyframes fadeInText { from { opacity: 0; transform: translateX(10px); } to { opacity: 1; transform: translateX(0); } }

/* =========================================
   5. الأيقونات (منطق التمييز الصارم - Strict Logic)
   ========================================= */

/* أ) الوضع الافتراضي */
.menu-fa-icon {
    color: var(--accent-color); 
    font-size: 40px; 
    width: 100%; 
    height: 100%; 
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    margin: 0; 
    filter: drop-shadow(0 2px 3px rgba(0,0,0,0.4));
    transition: all 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

/* ب) إخفاء الأيقونات عند فتح القائمة */
.alestinara-sidebar.expanded .menu-fa-icon {
    display: none !important;
}

/* ج) التمييز - استخدام (>) لضمان عدم انتقال التحديد للجار */

/* 1. عند المرور بالماوس */
html body .sidebar-menu a:hover .menu-fa-icon {
    color: #ffffff !important;
    transform: scale(1.15);
    filter: drop-shadow(0 0 8px rgba(255, 215, 0, 0.6));
}

/* 2. العنصر النشط حالياً (The Active Item) */
/* نرفع z-index للعنصر النشط ليكون فوق الجميع */
html body .sidebar-menu li.current-menu-item {
    z-index: 10;
}

html body .sidebar-menu li.current-menu-item > a .menu-fa-icon {
    color: #ffffff !important;
    transform: scale(1.15);
    filter: drop-shadow(0 0 8px rgba(255, 215, 0, 0.6));
}

/* 3. الأب المباشر للفرع (Parent of Active Sub-item) */
html body .sidebar-menu li.current-menu-ancestor > a .menu-fa-icon,
html body .sidebar-menu li.current-menu-parent > a .menu-fa-icon {
    color: #ffffff !important;
    transform: scale(1.15);
    filter: drop-shadow(0 0 8px rgba(255, 215, 0, 0.6));
}

/* =========================================
   6. القوائم الفرعية (SUB-MENUS)
   ========================================= */
.sub-menu {
    display: none; background: rgba(0, 0, 0, 0.3); 
    margin: 0; padding: 0; width: 100%;
}
.alestinara-sidebar.expanded li.open > .sub-menu {
    display: block; animation: slideDown 0.3s ease-out;
    position: static; box-shadow: none; border: none; width: 100%;
}
@keyframes slideDown { from { opacity: 0; transform: translateY(-10px); } to { opacity: 1; transform: translateY(0); } }

.sub-menu li a {
    font-size: 0.95rem; background: transparent; 
    padding: 10px 20px; margin: 0; 
    justify-content: flex-start !important; height: auto;
    box-shadow: none; white-space: normal !important; max-width: 100%;
    border-bottom: 1px solid rgba(255,255,255,0.03);
}
.sub-menu li a:hover { color: var(--accent-color); background: rgba(255,255,255,0.05); }

.sub-menu .sub-menu {
    background: rgba(0, 0, 0, 0.2); margin-right: 0; 
    border-right: 3px solid rgba(255,255,255,0.1);
}
.sub-menu .sub-menu li a { padding-right: 15px !important; font-size: 0.9rem; }

.menu-item-has-children > a::after {
    content: '◀'; position: absolute; left: 15px;
    font-size: 0.7rem; display: none; transition: transform 0.3s;
}
.alestinara-sidebar.expanded .menu-item-has-children > a::after { display: block; opacity: 0.7; }
.alestinara-sidebar.expanded li.open > a::after { transform: rotate(-90deg); }

/* =========================================
   7. منطقة المحتوى (Content)
   ========================================= */
.alestinara-content {
    flex: 1; padding: 20px; background: var(--bg-body);
    width: 100%; max-width: 100%; overflow-x: hidden;
    transition: opacity 0.3s;
    scroll-margin-top: 20px;
}

.content-area {
    display: none; background: var(--bg-content);
    padding: 40px; border-radius: 15px;
    box-shadow: 0 5px 20px rgba(0,0,0,0.05);
    max-width: 1000px; margin: 0 auto;
    animation: fadeInUp 0.5s ease;
}
.content-area.active { display: block; }
@keyframes fadeInUp { from { opacity: 0; transform: translateY(20px); } to { opacity: 1; transform: translateY(0); } }

.content-area h1 { color: var(--primary-color); margin-bottom: 20px; border-bottom: 2px solid #eee; padding-bottom: 10px; }
.content-area p { margin-bottom: 15px; color: #555; text-align: justify; }

/* =========================================
   8. التجاوب (Mobile)
   ========================================= */
.sidebar-overlay { display: none !important; }

@media (max-width: 768px) {
    html { font-size: 15px; }
    .alestinara-header { height: var(--header-height-mobile); }
    .alestinara-main-container {
        padding-right: 0; margin-top: 0;
        min-height: calc(100vh - var(--header-height-mobile));
    }
    .alestinara-sidebar {
        position: relative; top: auto; right: auto;
        height: auto; min-height: 100%; width: 60px; border-radius: 0;
    }
    .alestinara-sidebar .menu-fa-icon { font-size: 28px; } 
    .alestinara-sidebar.expanded { width: 260px; max-width: 80vw; }
    .alestinara-content { padding: 10px; width: 100%; flex: 1; min-width: 0; }
    .content-area { padding: 25px 15px; }
    .content-area p { font-size: 0.9rem; line-height: 1.6; }
    .content-area h1 { font-size: 1.3rem; line-height: 1.4; }
}

#backToTop {
    display: none; position: fixed; bottom: 30px; left: 30px;
    z-index: 999; border: none; outline: none;
    background-color: var(--accent-color); color: #333;
    cursor: pointer; padding: 12px 16px; border-radius: 50%;
    font-size: 20px; box-shadow: 0 4px 10px rgba(0,0,0,0.3);
}

/* =========================================
   9. منطق التمييز النهائي للخلفيات
   ========================================= */

/* أ) إلغاء الستايل الافتراضي */
html body .alestinara-sidebar .menu-item-has-children.current-menu-ancestor > a,
html body .alestinara-sidebar .menu-item-has-children.current-menu-parent > a {
    color: var(--text-light) !important;
    background: transparent !important;
    box-shadow: none !important;
    font-weight: normal !important;
}

/* ب) تمييز العنصر النشط فقط (استخدام > لضمان عدم الانزلاق) */
html body .alestinara-sidebar li.current-menu-item > a {
    color: var(--accent-color) !important;       
    font-weight: bold !important;
    background: rgba(255,255,255,0.15) !important;
    box-shadow: inset 5px 0 0 var(--accent-color) !important;
}

/* ج) استثناء للقائمة المغلقة: إضاءة خلفية الأب */
html body .alestinara-sidebar:not(.expanded) li.current-menu-ancestor > a,
html body .alestinara-sidebar:not(.expanded) li.current-menu-parent > a {
    background: rgba(255,255,255,0.15) !important;
    box-shadow: inset 5px 0 0 var(--accent-color) !important;
}