/**
 * ملف التصميم الموحد لصفحات E_School
 * يتطابق مع التصميم الرئيسي للموقع
 * يدعم الثيم الفاتح والداكن
 */

@import url('https://fonts.googleapis.com/css2?family=Cairo:wght@200;300;400;500;600;700;800&family=Noto+Sans+Arabic:wght@400;500;600;700&display=swap');

/* ========== CSS Variables (نفس الموقع الرئيسي) ========== */
:root {
  color-scheme: dark;
  
  /* Colors - Dark Theme */
  --bg-primary: #020f13;
  --bg-secondary: #04242c;
  --bg-tertiary: #063842;
  --surface: rgba(4, 20, 26, 0.92);
  --surface-elevated: rgba(6, 28, 35, 0.95);
  --surface-strong: rgba(9, 38, 46, 0.95);
  --surface-hover: rgba(32, 163, 159, 0.15);
  --surface-muted: rgba(255, 255, 255, 0.05);
  --chip-bg: rgba(32, 163, 159, 0.22);
  --overlay: rgba(1, 12, 16, 0.8);
  
  /* Primary Colors */
  --primary: #045977;
  --secondary: #079b90;
  --accent: #20a39f;
  --accent-muted: rgba(32, 163, 159, 0.35);
  
  /* Text Colors */
  --text-primary: #f2fffb;
  --text-secondary: #bcd7d2;
  --text-muted: #8ab1ad;
  
  /* Borders */
  --border: rgba(32, 163, 159, 0.32);
  --card-border: rgba(32, 163, 159, 0.25);
  
  /* Shadows */
  --shadow-sm: 0 4px 12px rgba(0, 0, 0, 0.35);
  --shadow-md: 0 10px 30px rgba(0, 0, 0, 0.35);
  --shadow-lg: 0 20px 40px rgba(0, 0, 0, 0.45);
  --shadow-xl: 0 30px 60px rgba(0, 0, 0, 0.5);
}

/* Light Theme */
body.light-theme {
  color-scheme: light;
  
  --bg-primary: #f2fbf8;
  --bg-secondary: #e0f5ef;
  --bg-tertiary: #c8ede3;
  --surface: rgba(255, 255, 255, 0.98);
  --surface-elevated: rgba(255, 255, 255, 0.98);
  --surface-strong: rgba(255, 255, 255, 0.95);
  --surface-hover: rgba(195, 228, 220, 0.5);
  --surface-muted: rgba(4, 89, 119, 0.08);
  --chip-bg: rgba(195, 228, 220, 0.45);
  --overlay: rgba(1, 46, 52, 0.65);
  
  --primary: #045977;
  --secondary: #079b90;
  --accent: #20a39f;
  --accent-muted: #c3e4dc;
  
  --text-primary: #0f2f2d;
  --text-secondary: #3a5d5b;
  --text-muted: #5f7c7b;
  
  --border: rgba(4, 89, 119, 0.2);
  --card-border: rgba(195, 228, 220, 0.9);
  
  --shadow-sm: 0 1px 3px rgba(4, 89, 119, 0.08);
  --shadow-md: 0 6px 16px rgba(4, 89, 119, 0.12);
  --shadow-lg: 0 16px 30px rgba(4, 89, 119, 0.15);
  --shadow-xl: 0 24px 45px rgba(4, 89, 119, 0.18);
}

/* ========== Global Styles ========== */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  font-family: 'Cairo', 'Noto Sans Arabic', sans-serif;
  font-size: 16px;
  background: linear-gradient(135deg, var(--bg-primary) 0%, var(--bg-secondary) 45%, var(--bg-tertiary) 100%);
  background-attachment: fixed;
  color: var(--text-primary) !important;
  min-height: 100vh;
  transition: all 0.3s ease;
  overflow-x: hidden;
  line-height: 1.6;
}

/* ========== Force Readable Text Colors ========== */
/* إصلاح شامل لضمان قراءة النصوص في جميع الأوضاع */

/* جميع النصوص */
body *, 
p, span, div, label, li, td, th, 
h1, h2, h3, h4, h5, h6,
a, button, input, textarea, select {
  color: var(--text-primary) !important;
}

/* النصوص الثانوية */
.text-secondary,
.subtitle,
.description,
small,
.muted {
  color: var(--text-secondary) !important;
}

/* النصوص الباهتة */
.text-muted,
.hint,
.note {
  color: var(--text-muted) !important;
}

/* الروابط */
a {
  color: var(--accent) !important;
  text-decoration: none;
}

a:hover {
  color: var(--primary) !important;
  text-decoration: underline;
}

/* إلغاء الألوان الثابتة في inline styles */
[style*="color: #"] {
  color: var(--text-primary) !important;
}

[style*="color:#"] {
  color: var(--text-primary) !important;
}

[style*="color: rgb"] {
  color: var(--text-primary) !important;
}

/* الاستثناءات للألوان الخاصة */
.success-text,
.status-pass,
[class*="success"] {
  color: #10b981 !important;
}

.error-text,
.status-fail,
[class*="error"],
[class*="danger"] {
  color: #ef4444 !important;
}

.warning-text,
[class*="warning"] {
  color: #f59e0b !important;
}

.info-text,
[class*="info"] {
  color: #3b82f6 !important;
}

/* ========== Scrollbar ========== */
body::-webkit-scrollbar {
  width: 8px;
}

body::-webkit-scrollbar-track {
  background: var(--bg-primary);
}

body::-webkit-scrollbar-thumb {
  background: var(--primary);
  border-radius: 4px;
}

body::-webkit-scrollbar-thumb:hover {
  background: var(--secondary);
}

/* ========== Container ========== */
.container {
  max-width: 1400px;
  margin: 0 auto;
  padding: 20px;
}

/* ========== Header ========== */
.page-header {
  background: var(--surface-elevated);
  backdrop-filter: blur(20px);
  border-radius: 16px;
  padding: 32px;
  margin-bottom: 40px;
  box-shadow: var(--shadow-lg);
  border: 1px solid var(--border);
  text-align: center;
  animation: fadeInDown 0.6s ease-out;
}

.page-header h1 {
  font-size: 2.5rem;
  font-weight: 800;
  color: var(--text-primary);
  margin-bottom: 12px;
  background: linear-gradient(135deg, var(--primary), var(--accent));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.page-header p {
  font-size: 1.1rem;
  color: var(--text-secondary);
  font-weight: 400;
}

/* ========== Cards ========== */
.card {
  background: var(--surface-elevated);
  backdrop-filter: blur(20px);
  border-radius: 16px;
  padding: 28px;
  margin-bottom: 24px;
  box-shadow: var(--shadow-md);
  border: 1px solid var(--card-border);
  transition: all 0.3s ease;
}

.card:hover {
  box-shadow: var(--shadow-lg);
  transform: translateY(-2px);
  border-color: var(--accent);
}

.card h2 {
  font-size: 1.8rem;
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: 16px;
  display: flex;
  align-items: center;
  gap: 12px;
}

.card h3 {
  font-size: 1.4rem;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 12px;
}

/* ========== Buttons ========== */
.btn {
  padding: 12px 28px;
  border-radius: 12px;
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  border: none;
  transition: all 0.3s ease;
  font-family: 'Cairo', sans-serif;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  text-decoration: none;
  box-shadow: var(--shadow-sm);
}

.btn-primary {
  background: linear-gradient(135deg, var(--primary), var(--secondary));
  color: white;
}

.btn-primary:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
  filter: brightness(1.1);
}

.btn-secondary {
  background: var(--surface);
  color: var(--text-primary);
  border: 1px solid var(--border);
}

.btn-secondary:hover {
  background: var(--surface-hover);
  border-color: var(--accent);
  transform: translateY(-2px);
}

.btn-accent {
  background: var(--accent);
  color: white;
}

.btn-accent:hover {
  filter: brightness(1.15);
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
}

.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  transform: none !important;
}

/* ========== Forms & Inputs ========== */
input, select, textarea {
  width: 100%;
  padding: 14px 18px;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text-primary);
  font-size: 1rem;
  font-family: 'Cairo', sans-serif;
  transition: all 0.3s ease;
}

input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-muted);
}

label {
  display: block;
  margin-bottom: 8px;
  font-weight: 600;
  color: var(--text-primary);
  font-size: 0.95rem;
}

/* ========== Tables ========== */
table {
  width: 100%;
  border-collapse: collapse;
  background: var(--surface);
  border-radius: 12px;
  overflow: hidden;
  box-shadow: var(--shadow-sm);
}

thead {
  background: linear-gradient(135deg, var(--primary), var(--secondary));
}

thead th {
  color: white;
  padding: 16px;
  text-align: center;
  font-weight: 700;
  font-size: 1rem;
}

tbody tr {
  border-bottom: 1px solid var(--border);
  transition: all 0.2s ease;
}

tbody tr:hover {
  background: var(--surface-hover);
}

tbody td {
  padding: 14px;
  text-align: center;
  color: var(--text-primary);
}

/* ========== Theme Toggle Button ========== */
.theme-toggle {
  position: fixed;
  top: 20px;
  left: 20px;
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: var(--surface-elevated);
  border: 2px solid var(--border);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.35s cubic-bezier(0.4, 0, 0.2, 1);
  box-shadow: var(--shadow-md);
  z-index: 1000;
  padding: 0;
}

.theme-toggle .material-icons {
  font-size: 28px;
  color: var(--text-primary) !important;
  transition: all 0.35s cubic-bezier(0.4, 0, 0.2, 1);
  user-select: none;
}

.theme-toggle:hover {
  transform: scale(1.12);
  box-shadow: var(--shadow-lg);
  border-color: var(--accent);
  background: var(--surface-strong);
}

.theme-toggle:hover .material-icons {
  transform: rotate(180deg);
  color: var(--accent) !important;
}

.theme-toggle:active {
  transform: scale(0.95);
}

/* ========== Badges & Chips ========== */
.badge {
  display: inline-block;
  padding: 6px 14px;
  border-radius: 20px;
  font-size: 0.85rem;
  font-weight: 600;
  background: var(--chip-bg);
  color: var(--accent);
  border: 1px solid var(--border);
}

.badge-success {
  background: rgba(16, 185, 129, 0.2);
  color: #10b981;
  border-color: rgba(16, 185, 129, 0.3);
}

.badge-warning {
  background: rgba(245, 158, 11, 0.2);
  color: #f59e0b;
  border-color: rgba(245, 158, 11, 0.3);
}

.badge-danger {
  background: rgba(239, 68, 68, 0.2);
  color: #ef4444;
  border-color: rgba(239, 68, 68, 0.3);
}

/* ========== Loading Spinner ========== */
.spinner {
  border: 3px solid var(--surface-muted);
  border-top: 3px solid var(--accent);
  border-radius: 50%;
  width: 40px;
  height: 40px;
  animation: spin 1s linear infinite;
  margin: 20px auto;
}

@keyframes spin {
  0% { transform: rotate(0deg); }
  100% { transform: rotate(360deg); }
}

/* ========== Animations ========== */
@keyframes fadeInDown {
  from {
    opacity: 0;
    transform: translateY(-20px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes fadeInUp {
  from {
    opacity: 0;
    transform: translateY(20px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

/* ========== Utility Classes ========== */
.text-center { text-align: center; }
.text-right { text-align: right; }
.text-left { text-align: left; }

.mt-1 { margin-top: 0.5rem; }
.mt-2 { margin-top: 1rem; }
.mt-3 { margin-top: 1.5rem; }
.mt-4 { margin-top: 2rem; }

.mb-1 { margin-bottom: 0.5rem; }
.mb-2 { margin-bottom: 1rem; }
.mb-3 { margin-bottom: 1.5rem; }
.mb-4 { margin-bottom: 2rem; }

.flex { display: flex; }
.flex-center { display: flex; align-items: center; justify-content: center; }
.flex-between { display: flex; align-items: center; justify-content: space-between; }
.gap-1 { gap: 0.5rem; }
.gap-2 { gap: 1rem; }
.gap-3 { gap: 1.5rem; }

/* ========== Responsive ========== */
@media (max-width: 768px) {
  .container {
    padding: 15px;
  }
  
  .page-header {
    padding: 24px;
  }
  
  .page-header h1 {
    font-size: 1.8rem;
  }
  
  .card {
    padding: 20px;
  }
  
  .card h2 {
    font-size: 1.5rem;
  }
  
  .btn {
    padding: 10px 20px;
    font-size: 0.9rem;
  }
  
  .theme-toggle {
    width: 48px;
    height: 48px;
    top: 15px;
    left: 15px;
  }
  
  .theme-toggle .material-icons {
    font-size: 24px;
  }
  
  table {
    font-size: 0.9rem;
  }
  
  thead th, tbody td {
    padding: 10px 8px;
  }
}

@media (max-width: 480px) {
  .page-header h1 {
    font-size: 1.5rem;
  }
  
  .card h2 {
    font-size: 1.3rem;
  }
  
  .btn {
    padding: 8px 16px;
    font-size: 0.85rem;
  }
}

/* ========== إصلاحات إضافية للقراءة ========== */

/* إلغاء أي لون أبيض على خلفية فاتحة */
body.light-theme [style*="color: #fff"],
body.light-theme [style*="color:#fff"],
body.light-theme [style*="color: white"],
body.light-theme [style*="color:white"],
body.light-theme [style*="color: #ffffff"],
body.light-theme [style*="color:#ffffff"] {
  color: var(--text-primary) !important;
}

/* إلغاء أي لون داكن على خلفية داكنة */
body:not(.light-theme) [style*="color: #000"],
body:not(.light-theme) [style*="color:#000"],
body:not(.light-theme) [style*="color: black"],
body:not(.light-theme) [style*="color:black"],
body:not(.light-theme) [style*="color: #2c3e50"],
body:not(.light-theme) [style*="color:#2c3e50"],
body:not(.light-theme) [style*="color: #5a6c7d"],
body:not(.light-theme) [style*="color:#5a6c7d"] {
  color: var(--text-primary) !important;
}

/* Headers - دائماً مقروءة */
.page-header h1,
.page-header h2,
.page-header h3,
.page-header p,
.page-header span,
header h1,
header h2,
header h3,
header p,
header span {
  color: var(--text-primary) !important;
}

/* إصلاح النصوص في الكاردات */
.card p,
.card span,
.card div:not(.chart):not(canvas) {
  color: var(--text-primary) !important;
}

/* إصلاح النصوص في الأزرار */
button,
.btn,
[role="button"] {
  color: white !important;
}

button:not(.btn-primary):not(.btn-accent),
.btn-secondary,
.btn-outline {
  color: var(--text-primary) !important;
}

/* إصلاح النصوص في النماذج */
input::placeholder,
textarea::placeholder,
select option {
  color: var(--text-muted) !important;
  opacity: 0.7;
}

/* إصلاح Labels */
label,
.label,
.form-label {
  color: var(--text-primary) !important;
  font-weight: 600;
}

/* إصلاح القوائم */
ul li,
ol li {
  color: var(--text-primary) !important;
}

/* إصلاح الفقرات */
p {
  color: var(--text-primary) !important;
  line-height: 1.8;
}

/* إصلاح العناوين */
h1, h2, h3, h4, h5, h6 {
  color: var(--text-primary) !important;
  font-weight: 700;
}

/* إصلاح النصوص في الـ Tables */
table,
table * {
  color: var(--text-primary) !important;
}

thead th {
  color: white !important;
}

/* إصلاح Modals */
.modal,
.modal-content,
.modal-body,
.modal-header,
.modal-footer {
  color: var(--text-primary) !important;
}

/* إصلاح Tooltips */
.tooltip,
.hint,
.info-box {
  color: var(--text-primary) !important;
  background: var(--surface-elevated) !important;
}

/* إصلاح Alert Boxes */
.alert,
.notification,
.message-box {
  color: var(--text-primary) !important;
}

/* إصلاح Code Blocks */
code,
pre {
  background: var(--surface-muted) !important;
  color: var(--accent) !important;
  padding: 4px 8px;
  border-radius: 6px;
}

/* إصلاح Dividers */
hr {
  border-color: var(--border) !important;
  opacity: 0.5;
}

/* إصلاح Blockquotes */
blockquote {
  border-left: 4px solid var(--accent);
  padding-left: 16px;
  color: var(--text-secondary) !important;
  font-style: italic;
}

/* إصلاح Progress Bars */
.progress {
  background: var(--surface-muted) !important;
}

.progress-bar {
  background: linear-gradient(135deg, var(--primary), var(--accent)) !important;
  color: white !important;
}

/* إصلاح Tabs */
.tab,
.tab-item {
  color: var(--text-primary) !important;
}

.tab.active,
.tab-item.active {
  color: var(--accent) !important;
  border-bottom-color: var(--accent) !important;
}

/* إصلاح Breadcrumbs */
.breadcrumb,
.breadcrumb-item {
  color: var(--text-secondary) !important;
}

/* إصلاح Pagination */
.pagination,
.page-item {
  color: var(--text-primary) !important;
}

/* إصلاح Dropdown */
.dropdown,
.dropdown-menu,
.dropdown-item {
  background: var(--surface-elevated) !important;
  color: var(--text-primary) !important;
}

/* إصلاح أي نص متبقي */
* {
  color: inherit;
}

body * {
  color: var(--text-primary);
}

/* التأكد من عدم وجود نصوص شفافة */
* {
  opacity: 1;
}

.text-opacity-0 {
  opacity: 0;
}
