/* =========================================================
   نظام التصميم الموحد (Design Tokens)
   مركز تجميعات - البحث ومصادر المعلومات
   يدعم: فاتح / داكن / تلقائي (حسب نظام الجهاز)
   ========================================================= */

:root {
  /* الألوان الأساسية للهوية (ثابتة بالوضعين) - هادئة ومريحة للعين */
  --brand-primary: #4a93a0;
  --brand-primary-dark: #3a7581;
  --brand-secondary: #2c3e46;
  --brand-accent: #d98a63;
  --brand-accent-hover: #e4a37f;

  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;

  --font-main: 'Cairo', 'Tahoma', sans-serif;

  --shadow-sm: 0 2px 8px rgba(0,0,0,.08);
  --shadow-md: 0 6px 20px rgba(0,0,0,.12);

  --header-height: 66px;

  --transition-fast: .2s ease;
  --transition-theme: background-color .25s ease, color .25s ease, border-color .25s ease;
}

/* ============ الوضع الفاتح (الافتراضي) ============ */
:root,
[data-theme="light"] {
  --bg: #f7f9fa;
  --bg-elevated: #ffffff;
  --bg-header: #ffffff;
  --text-primary: #263238;
  --text-secondary: #62757d;
  --border-color: #e6ecee;
  --card-shadow: var(--shadow-sm);
  --footer-bg: var(--brand-secondary);
  --footer-text: #f5f7f7;
  --overlay: rgba(0,0,0,.4);
  --link-hover-bg: rgba(74,147,160,.08);
}

/* ============ الوضع الداكن ============ */
[data-theme="dark"] {
  --bg: #141b1f;
  --bg-elevated: #1c262b;
  --bg-header: #171f24;
  --text-primary: #dbe4e6;
  --text-secondary: #93a3a9;
  --border-color: #2a363c;
  --card-shadow: 0 2px 10px rgba(0,0,0,.4);
  --footer-bg: #0e1417;
  --footer-text: #c4d0d3;
  --overlay: rgba(0,0,0,.55);
  --link-hover-bg: rgba(74,147,160,.15);
}

/* ============ الوضع التلقائي (حسب نظام الجهاز) ============
   يُفعَّل فقط إذا لم يختر المستخدم وضعاً يدوياً (data-theme="auto") */
@media (prefers-color-scheme: dark) {
  [data-theme="auto"] {
    --bg: #141b1f;
    --bg-elevated: #1c262b;
    --bg-header: #171f24;
    --text-primary: #dbe4e6;
    --text-secondary: #93a3a9;
    --border-color: #2a363c;
    --card-shadow: 0 2px 10px rgba(0,0,0,.4);
    --footer-bg: #0e1417;
    --footer-text: #c4d0d3;
    --overlay: rgba(0,0,0,.55);
    --link-hover-bg: rgba(74,147,160,.15);
  }
}

/* ============ تطبيق عام على العناصر ============ */
html {
  color-scheme: light dark;
}

body {
  background-color: var(--bg) !important;
  color: var(--text-primary) !important;
  font-family: var(--font-main);
  transition: var(--transition-theme);
}

/* عناصر عامة قابلة لإعادة الاستخدام في كل الصفحات */
.surface-card,
.card,
.file-card {
  background: var(--bg-elevated) !important;
  color: var(--text-primary) !important;
  border: 1px solid var(--border-color);
  box-shadow: var(--card-shadow) !important;
  transition: var(--transition-theme);
}

footer {
  background: var(--footer-bg) !important;
  color: var(--footer-text) !important;
  transition: var(--transition-theme);
}

/* =========================================================
   زر تبديل الوضع (فاتح / داكن / تلقائي)
   ========================================================= */
.theme-switcher {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  background: var(--bg-elevated);
  border: 1px solid var(--border-color);
  border-radius: 999px;
  padding: 4px;
  margin-inline-start: 10px;
}

/* داخل قائمة الجوال (nav__list) نعرضه بشكل مركزي وبخلفية مناسبة للشريط الداكن */
.nav__list .theme-switcher {
  margin: 14px auto 0;
  background: rgba(255,255,255,.08);
  border-color: rgba(255,255,255,.15);
}
.nav__list .theme-switcher button {
  color: #cfd8dc;
}
.nav__list .theme-switcher button:hover {
  color: #fff;
}
.nav__list li:has(.theme-switcher) {
  display: flex;
  justify-content: center;
  background: var(--black-color, #1a222b);
  padding-bottom: 14px;
}

.theme-switcher button {
  border: none;
  background: transparent;
  color: var(--text-secondary);
  width: 32px;
  height: 32px;
  border-radius: 999px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  transition: var(--transition-fast);
}

.theme-switcher button:hover {
  background: var(--link-hover-bg);
  color: var(--brand-primary);
}

.theme-switcher button.active {
  background: var(--brand-primary);
  color: #fff;
}

/* =========================================================
   أساس متجاوب عام لكل الصفحات (تحسين الجوال)
   ========================================================= */
* { box-sizing: border-box; }

img { max-width: 100%; height: auto; }

.container {
  width: 100%;
  max-width: 1200px;
  margin-inline: auto;
  padding-inline: 16px;
}

@media (max-width: 480px) {
  html { font-size: 15px; }
}
