/* ===========================
   CSS الموحد لصفحات المعلومات
   تم التوحيد مع الصفحة الرئيسية مع الحفاظ على الهيكل
=========================== */

/* ===== المتغيرات الأساسية ===== */
:root {
  /* الألوان */
  --bg-color: #f5f7fb;
  --text-color: #1f2937;
  --primary-text: #1f2937;
  --secondary-text: #6b7280;
  --card-bg: #ffffff;
  --accent-color: #2f71d3;
  --accent-hover: #1d4ed8;
  --btn-bg: var(--accent-color);
  --btn-color: #fff;
  --border-color: #f3f4f6;
  --warning-bg: #fef3cd;
  --warning-border: #f59e0b;
  --danger-bg: #fef2f2;
  --danger-border: #ef4444;
  --success-bg: #f0fdf4;
  --success-border: #22c55e;
  
  /* الظلال */
  --shadow-sm: 0 1px 2px rgba(0,0,0,0.04);
  --shadow-md: 0 4px 6px rgba(0,0,0,0.07);
  --shadow-lg: 0 10px 15px rgba(0,0,0,0.1);
  --shadow-hover: 0 20px 25px rgba(0,0,0,0.15);
  
  /* الأنماط */
  --border-radius: 12px;
  --border-radius-sm: 8px;
  
  /* التحويلات */
  --transition-fast: 0.3s;
  --transition-slow: 0.8s;
}

/* تحسين تحميل الخطوط */
@font-face {
  font-family: 'Cairo';
  font-display: swap;
}

/* الوضع الداكن */
body.dark-mode {
  --bg-color: #111827;
  --text-color: #f9fafb;
  --primary-text: #f9fafb;
  --secondary-text: #9ca3af;
  --card-bg: #1f2937;
  --accent-color: #3b82f6;
  --accent-hover: #2563eb;
  --border-color: #374151;
  --warning-bg: #332701;
  --warning-border: #f59e0b;
  --danger-bg: #2a0f0f;
  --danger-border: #ef4444;
  --success-bg: #052e16;
  --success-border: #22c55e;
}

/* تحسينات متقدمة للوضع الداكن */
body.dark-mode {
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* ===== الأساسيات والتهيئة ===== */
* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: 'Cairo', Arial, sans-serif;
  background: var(--bg-color);
  color: var(--text-color);
  line-height: 1.6;
  direction: rtl;
  transition: background var(--transition-fast), color var(--transition-fast);
}

/* تحسينات للأداء */
img {
  content-visibility: auto;
}

/* تحسينات للرسوم المتحركة */
@media (prefers-reduced-motion: reduce) {
  * {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

/* تحسينات للوصول */
button:focus-visible,
a:focus-visible {
  outline: 2px solid var(--accent-color);
  outline-offset: 2px;
}

/* ===== إمكانية الوصول ===== */
.skip-link {
  position: absolute;
  top: -40px;
  left: 0;
  background: var(--accent-color);
  color: var(--btn-color);
  padding: 8px 16px;
  z-index: 10000;
  text-decoration: none;
  border-radius: 0 0 var(--border-radius-sm) 0;
  font-weight: bold;
  transition: top var(--transition-fast) ease;
}

.skip-link:focus {
  top: 0;
  outline: 2px solid var(--btn-color);
  outline-offset: -2px;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

/* ===== التخطيط العام ===== */
.container {
  max-width: 800px;
  margin: 100px auto 50px;
  padding: 0 20px;
}

/* ===== العناوين ===== */
h1 {
  color: var(--accent-color);
  border-bottom: 2px solid var(--accent-color);
  padding-bottom: 10px;
  margin-bottom: 30px;
  font-size: 2.2rem;
  font-weight: 700;
  position: relative;
  padding-right: 15px; /* ✅ مساحة إضافية لمنع تداخل البوردر */
}

/* ✅ إصلاح مشكلة البوردر - نقل البوردر الجانبي إلى بعد النص */
h1::before {
  content: '';
  position: absolute;
  top: 0;
  right: 0;
  width: 4px;
  height: 100%;
  background: linear-gradient(135deg, var(--accent-color), #8b5cf6);
  border-radius: 0 var(--border-radius) var(--border-radius) 0;
  opacity: 0.7;
  transition: opacity var(--transition-fast) ease;
}

h1:hover::before {
  opacity: 1;
}

h2 {
  color: var(--accent-hover);
  margin-top: 2.5rem;
  margin-bottom: 1.2rem;
  font-size: 1.6rem;
  border-right: 3px solid var(--accent-color);
  padding-right: 15px;
  font-weight: 600;
  position: relative;
  transition: color var(--transition-fast) ease;
}

h2:hover {
  color: var(--accent-color);
}

h3 {
  color: var(--secondary-text);
  margin-top: 2rem;
  margin-bottom: 1rem;
  font-size: 1.3rem;
  font-weight: 600;
  position: relative;
}

/* ===== النصوص والفقرات ===== */
.container p {
  line-height: 1.8;
  margin-bottom: 20px;
  font-size: 17px;
  text-align: justify;
}

strong {
  color: var(--accent-color);
  font-weight: 700;
}

/* ===== القوائم - التصحيح الكامل للنقاط ===== */
ul {
  padding-right: 0;
  margin-bottom: 2rem;
  list-style: none;
}

li {
  margin-bottom: 0.8rem;
  line-height: 1.6;
  position: relative;
  font-size: 17px;
  padding-right: 1.5rem;
}

/* النقطة الزرقاء الجميلة مع تأثير التدرج */
li:before {
  content: "";
  position: absolute;
  right: 0;
  top: 0.7rem;
  width: 6px;
  height: 6px;
  background: linear-gradient(135deg, var(--accent-color), #8b5cf6);
  border-radius: 50%;
  transform: translateY(-50%);
  transition: all var(--transition-fast) ease;
}

li:hover:before {
  transform: translateY(-50%) scale(1.2);
}

/* ===== المكونات الخاصة ===== */
.last-updated {
  background: var(--card-bg);
  padding: 15px;
  border-radius: var(--border-radius);
  border: 1px solid var(--border-color);
  margin-bottom: 2rem;
  position: relative;
  box-shadow: var(--shadow-sm);
  padding-right: 20px; /* ✅ مساحة إضافية */
}

.last-updated::before {
  content: '';
  position: absolute;
  top: 0;
  right: 0;
  width: 4px;
  height: 100%;
  background: linear-gradient(135deg, var(--accent-color), #8b5cf6);
  border-radius: 0 var(--border-radius) var(--border-radius) 0;
}

.notice {
  background: var(--warning-bg);
  border: 1px solid var(--warning-border);
  border-radius: var(--border-radius);
  padding: 20px;
  margin: 20px 0;
  position: relative;
  box-shadow: var(--shadow-sm);
  padding-right: 24px; /* ✅ مساحة إضافية */
}

.notice::before {
  content: '';
  position: absolute;
  top: 0;
  right: 0;
  width: 4px;
  height: 100%;
  background: var(--warning-border);
  border-radius: 0 var(--border-radius) var(--border-radius) 0;
}

.notice strong {
  color: #d97706;
}

.contact-info {
  background: var(--card-bg);
  padding: 20px;
  border-radius: var(--border-radius);
  margin-top: 2rem;
  border: 1px solid var(--border-color);
  position: relative;
  box-shadow: var(--shadow-sm);
  padding-right: 24px; /* ✅ مساحة إضافية */
}

.contact-info::before {
  content: '';
  position: absolute;
  top: 0;
  right: 0;
  width: 4px;
  height: 100%;
  background: linear-gradient(135deg, var(--accent-color), #8b5cf6);
  border-radius: 0 var(--border-radius) var(--border-radius) 0;
}

.warning {
  background: var(--danger-bg);
  border: 1px solid var(--danger-border);
  border-radius: var(--border-radius);
  padding: 15px;
  margin: 15px 0;
  position: relative;
  box-shadow: var(--shadow-sm);
  padding-right: 20px; /* ✅ مساحة إضافية */
}

.warning::before {
  content: '';
  position: absolute;
  top: 0;
  right: 0;
  width: 4px;
  height: 100%;
  background: var(--danger-border);
  border-radius: 0 var(--border-radius) var(--border-radius) 0;
}

/* ===== تحسينات الصور ===== */
.lazy-image {
  opacity: 0;
  transition: opacity var(--transition-slow) ease;
}

.lazy-image.loaded {
  opacity: 1;
}

/* ===== تحسينات الهيدر ===== */
.main-header {
  opacity: 0 !important;
  visibility: hidden !important;
  pointer-events: none !important;
}

.main-header.visible {
  opacity: 1 !important;
  visibility: visible !important;
  pointer-events: all !important;
  transition: var(--transition-fast) !important;
}

/* ===== تحسينات للهواتف ===== */
@media (max-width: 768px) {
  .container {
    margin: 80px auto 30px;
    padding: 0 15px;
  }
  
  h1 {
    font-size: 1.8rem;
    padding-right: 12px; /* ✅ مساحة أقل في الهواتف */
  }
  
  h2 {
    font-size: 1.4rem;
    margin-top: 2rem;
    padding-right: 12px; /* ✅ مساحة أقل في الهواتف */
  }
  
  h3 {
    font-size: 1.2rem;
  }
  
  p, li {
    font-size: 16px;
  }
  
  .last-updated,
  .notice,
  .contact-info,
  .warning {
    padding: 12px;
    padding-right: 16px; /* ✅ مساحة إضافية في الهواتف */
    margin: 15px -10px;
    border-radius: 0;
  }
  
  /* تصحيح النقاط للهواتف */
  li {
    padding-right: 1.2rem;
  }
  
  li:before {
    width: 5px;
    height: 5px;
    top: 0.6rem;
  }
}

/* ===== تحسينات للشاشات الصغيرة جداً (الهواتف الصغيرة) ===== */
@media (max-width: 480px) {
  .container {
    margin: 70px auto 20px;
    padding: 0 10px;
  }
  
  h1 {
    font-size: 1.6rem;
    padding-bottom: 8px;
    margin-bottom: 20px;
    padding-right: 10px;
  }
  
  h2 {
    font-size: 1.3rem;
    margin-top: 1.8rem;
    margin-bottom: 1rem;
    padding-right: 10px;
    border-right-width: 2px;
  }
  
  h3 {
    font-size: 1.1rem;
    margin-top: 1.5rem;
    margin-bottom: 0.8rem;
  }
  
  p, li {
    font-size: 15px;
    line-height: 1.7;
  }
  
  .container p {
    text-align: right; /* إلغاء justify في الشاشات الصغيرة */
  }
  
  .last-updated,
  .notice,
  .contact-info,
  .warning {
    padding: 10px;
    padding-right: 14px;
    margin: 12px -5px;
  }
  
  /* تصحيح النقاط للشاشات الصغيرة جداً */
  li {
    padding-right: 1rem;
    margin-bottom: 0.7rem;
  }
  
  li:before {
    width: 4px;
    height: 4px;
    top: 0.55rem;
  }
  
  /* تحسينات إضافية للقوائم */
  ul {
    margin-bottom: 1.5rem;
  }
  
  /* تحسينات للهيدر في الشاشات الصغيرة */
  .main-header {
    padding: 10px 0;
  }
  
  /* تحسينات للزر في الشاشات الصغيرة */
  .btn {
    padding: 10px 16px;
    font-size: 14px;
  }
}

/* ===== تحسينات للشاشات الصغيرة جداً جداً (أقل من 360px) ===== */
@media (max-width: 360px) {
  .container {
    margin: 60px auto 15px;
    padding: 0 8px;
  }
  
  h1 {
    font-size: 1.4rem;
    padding-bottom: 6px;
    margin-bottom: 15px;
  }
  
  h2 {
    font-size: 1.2rem;
    margin-top: 1.5rem;
    margin-bottom: 0.8rem;
  }
  
  h3 {
    font-size: 1rem;
  }
  
  p, li {
    font-size: 14px;
    line-height: 1.6;
  }
  
  .last-updated,
  .notice,
  .contact-info,
  .warning {
    padding: 8px;
    padding-right: 12px;
    margin: 10px -3px;
  }
  
  li {
    padding-right: 0.8rem;
  }
  
  li:before {
    width: 3px;
    height: 3px;
    top: 0.5rem;
  }
}

/* ===== تحسينات للشاشات الكبيرة ===== */
@media (min-width: 1200px) {
  .container {
    max-width: 900px;
  }
}

/* ===== تحسينات الطباعة ===== */
@media print {
  .skip-link,
  .main-header,
  #footer-placeholder {
    display: none !important;
  }
  
  .container {
    margin: 0;
    max-width: none;
  }
  
  body {
    background: white;
    color: black;
    font-size: 12pt;
  }
  
  h1, h2, h3 {
    color: black;
  }
  
  .notice,
  .warning,
  .contact-info {
    background: white;
    border: 1px solid black;
  }
  
  /* تصحيح النقاط للطباعة */
  li:before {
    background: black;
  }
  
  /* إخفاء تأثيرات البوردر الجانبية */
  h1::before,
  .last-updated::before,
  .notice::before,
  .contact-info::before,
  .warning::before {
    display: none;
  }
}

/* ===== فئة مساعدة للصفحات المحملة ===== */
.page-loaded {
  opacity: 1;
  transition: opacity var(--transition-fast) ease;
}

/* ===== تحسينات التنقل ===== */
.main-content:focus {
  outline: 2px solid var(--accent-color);
  outline-offset: 2px;
}

/* ===== تحسينات النماذج ===== */
input, textarea, select {
  font-family: 'Cairo', Arial, sans-serif;
}

/* ===== تأثيرات بصرية محسنة ===== */
h2, h3 {
  transition: color var(--transition-fast) ease;
}

/* ===== تحسينات إضافية للقوائم ===== */
ul.featured-list {
  background: var(--card-bg);
  padding: 20px;
  border-radius: var(--border-radius);
  margin: 20px 0;
  border: 1px solid var(--border-color);
  position: relative;
  box-shadow: var(--shadow-sm);
  padding-right: 24px; /* ✅ مساحة إضافية */
}

ul.featured-list::before {
  content: '';
  position: absolute;
  top: 0;
  right: 0;
  width: 4px;
  height: 100%;
  background: linear-gradient(135deg, var(--accent-color), #8b5cf6);
  border-radius: 0 var(--border-radius) var(--border-radius) 0;
}

ul.featured-list li {
  margin-bottom: 10px;
  padding-right: 1.5rem;
}

/* ===== حالة التحميل ===== */
.loading-state {
  display: flex;
  justify-content: center;
  align-items: center;
  padding: 2rem;
}

.loading-spinner {
  width: 40px;
  height: 40px;
  border: 4px solid rgba(47, 113, 211, 0.2);
  border-top: 4px solid var(--accent-color);
  border-radius: 50%;
  animation: spin 1s linear infinite;
}

@keyframes spin {
  0% { transform: rotate(0deg); }
  100% { transform: rotate(360deg); }
}

/* ===== 🎨 تحسينات الوضع الداكن ===== */

body.dark-mode .last-updated,
body.dark-mode .contact-info,
body.dark-mode ul.featured-list {
  background: var(--card-bg);
  border-color: var(--border-color);
}

body.dark-mode .notice strong {
  color: #fbbf24;
}

/* بوردر جانبي في الوضع الداكن */
body.dark-mode h1::before,
body.dark-mode .last-updated::before,
body.dark-mode .contact-info::before,
body.dark-mode ul.featured-list::before {
  background: linear-gradient(135deg, #3b82f6, #6366f1);
}

/* 🔹 الشاشات الكبيرة جداً (1600px) */
@media (min-width: 1600px) {
  .container {
    max-width: 1000px;
  }
}

/* 🔹 تحسينات للأجهزة ذات اللمس */
@media (hover: none) and (pointer: coarse) {
  li:hover:before {
    transform: translateY(-50%) scale(1);
  }
  
  h2:hover {
    color: var(--accent-hover);
  }
}

/* 🔹 تحسينات للشاشات عالية الدقة */
@media (min-resolution: 192dpi) {
  .loading-spinner {
    border-width: 3px;
  }
  
  li:before {
    width: 5px;
    height: 5px;
  }
}