/* ==========================================================
   التصميم الرئيسي - تقرير الأداء المدرسي
   ========================================================== */

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

:root {
  --primary: #492a81;
  --primary-dark: #492a81;
  --primary-light: #492a81;
  --gold: #C9A227;
  --gold-dark: #a07d1f;
  --gray-bg: #f5f7fa;
  --text: #1e293b;
  --text-muted: #64748b;
  --border: #e2e8f0;
  --surface: #ffffff;
  --green-bg: #e8f5e9;
  --green-dark: #15803d;
  --red: #dc2626;
  --red-bg: #fee2e2;
  --blue: #2563eb;
  --blue-bg: #dbeafe;
  --orange: #ea580c;
  --orange-bg: #fff7ed;
  --yellow: #eab308;
  --yellow-bg: #fefce8;
}

[data-theme="dark"] {
  --gray-bg: #0f172a;
  --text: #f1f5f9;
  --text-muted: #e6ecf3;
  --border: #334155;
  --surface: #1e293b;
  --green-bg: #064e3b;
  --blue-bg: #1e3a8a;
  --orange-bg: #7c2d12;
  --yellow-bg: #713f12;
}

body {
  font-family: 'Cairo', 'Tajawal', sans-serif;
  background: var(--gray-bg);
  color: var(--text);
  line-height: 1.5;
}

.app {
  display: flex;
  min-height: 100vh;
}

/* ===== القائمة الجانبية ===== */
.sidebar {
  width: 270px;
  background: var(--surface);
  border-left: 1px solid var(--border);
  position: fixed;
  right: 0;
  top: 0;
  bottom: 0;
  z-index: 100;
  transition: transform 0.3s ease;
  overflow-y: auto;
  box-shadow: -2px 0 10px rgba(0,0,0,0.05);
}

.sidebar .logo {
  padding: 20px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 12px;
}

.sidebar .logo .badge {
  width: 45px;
  height: 45px;
  background: var(--primary);
  color: white;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 24px;
  font-weight: bold;
}

.sidebar .logo h2 {
  font-size: 18px;
  font-weight: 700;
  color: var(--primary);
}

.sidebar .logo p {
  font-size: 11px;
  color: var(--text-muted);
}

.sidebar nav {
  padding: 15px 10px;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  padding: 12px 15px;
  background: none;
  border: none;
  border-radius: 12px;
  font-size: 15px;
  font-weight: 500;
  color: var(--text);
  cursor: pointer;
  transition: all 0.2s;
  text-align: right;
  font-family: inherit;
}

.nav-item .ic {
  font-size: 20px;
}

.nav-item:hover {
  background: var(--border);
}

.nav-item.active {
  background: var(--primary);
  color: white;
}

/* ===== المحتوى الرئيسي ===== */
.main {
  flex: 1;
  margin-right: 270px;
  min-height: 100vh;
}

.topbar {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 12px 25px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  position: sticky;
  top: 0;
  z-index: 99;
}

.topbar .title h1 {
  font-size: 20px;
  font-weight: 700;
  color: var(--primary);
}

.topbar .title p {
  font-size: 12px;
  color: var(--text-muted);
}

.menu-toggle {
  display: none;
  font-size: 24px;
  background: none;
  border: none;
  cursor: pointer;
  color: var(--text);
}

.actions {
  display: flex;
  gap: 8px;
}

.btn {
  padding: 8px 16px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  cursor: pointer;
  font-family: inherit;
  font-size: 13px;
  transition: all 0.2s;
}

.btn-sm {
  padding: 5px 12px;
  font-size: 12px;
}

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

.btn-primary:hover {
  background: var(--primary-dark);
}

.btn-danger {
  background: var(--red);
  border-color: var(--red);
  color: white;
}

.btn-danger:hover {
  background: #b91c1c;
}

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

.btn-gold:hover {
  background: var(--gold-dark);
}

/* ===== المحتوى ===== */
.content {
  padding: 20px 25px;
}

.page {
  display: none;
}

.page.active {
  display: block;
}

.section-title {
  background: linear-gradient(135deg, var(--primary) 0%, var(--primary-light) 100%);
  color: white;
  padding: 12px 20px;
  border-radius: 12px;
  margin: 0 0 20px 0;
  font-weight: 700;
  font-size: 18px;
}

/* ===== البطاقات ===== */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 18px;
  margin-bottom: 20px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.05);
}

.card h3 {
  font-size: 16px;
  font-weight: 700;
  color: var(--primary);
  margin-bottom: 12px;
  padding-bottom: 8px;
  border-bottom: 2px solid var(--gold);
  display: inline-block;
}

/* ===== شبكة الإحصائيات ===== */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 20px;
  margin-bottom: 25px;
}

.stat-card {
  background: var(--surface);
  border-radius: 16px;
  padding: 18px;
  text-align: center;
  border: 1px solid var(--border);
}

.stat-card .label {
  font-size: 13px;
  color: var(--text-muted);
  margin-bottom: 8px;
}

.stat-card .value {
  font-size: 32px;
  font-weight: 800;
  color: var(--primary);
}

.stat-card .meta {
  font-size: 11px;
  color: var(--text-muted);
  margin-top: 6px;
}

.stat-card.green { border-top: 4px solid var(--primary); }
.stat-card.blue { border-top: 4px solid var(--blue); }
.stat-card.gold { border-top: 4px solid var(--gold); }
.stat-card.red { border-top: 4px solid var(--red); }

/* ===== شبكة عامة ===== */
.grid-2 {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 20px;
}

/* ===== الجداول ===== */
.table-wrap {
  overflow-x: auto;
}

.data-table, table.data {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

.data-table th, table.data th {
  background: var(--primary);
  color: white;
  padding: 10px;
  text-align: center;
  font-weight: 600;
}

.data-table td, table.data td {
  padding: 10px;
  border-bottom: 1px solid var(--border);
  text-align: center;
}

.data-table tr:nth-child(even), table.data tr:nth-child(even) {
  background: var(--gray-bg);
}

/* ===== شريط التقدم ===== */
.bar {
  background: #e5e7eb;
  border-radius: 20px;
  overflow: hidden;
}

.bar span {
  display: block;
  background: #15803d;
  height: 8px;
  border-radius: 20px;
}

.bar.yellow span { background: var(--yellow); }
.bar.orange span { background: var(--orange); }
.bar.red span { background: var(--red); }

/* ===== مستويات الأداء ===== */
.lvl {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 20px;
  font-size: 11px;
  font-weight: 600;
}

.lvl-excellence { background: #15803d20; color: #15803d; }
.lvl-progress { background: #a1620720; color: #a16207; }
.lvl-launch { background: #c2410c20; color: #c2410c; }
.lvl-prepare { background: #b91c1c20; color: #b91c1c; }

/* ===== الخطط التحسينية ===== */
.plan-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 15px;
  margin-bottom: 15px;
}

.plan-card.intensive { border-right: 4px solid var(--red); }
.plan-card.developmental { border-right: 4px solid var(--gold); }
.plan-card.sustain { border-right: 4px solid var(--primary); }

.plan-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 10px;
  margin-bottom: 12px;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--border);
}

.plan-head h4 {
  font-size: 15px;
  font-weight: 700;
  color: var(--primary);
}

.plan-meta {
  font-size: 12px;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(250px,1fr));
  gap: 8px;
}

.plan-meta div {
  padding: 5px 0;
}

/* ===== الرسوم البيانية ===== */
.chart-wrap {
  height: 280px;
  position: relative;
}

.chart-title {
  text-align: center;
  font-size: 12px;
  color: var(--text-muted);
  margin-bottom: 10px;
}

/* ===== النوافذ المنبثقة ===== */
.modal-backdrop {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0,0,0,0.5);
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  visibility: hidden;
  opacity: 0;
  transition: all 0.2s;
}

.modal-backdrop.show {
  visibility: visible;
  opacity: 1;
}

.modal {
  background: var(--surface);
  border-radius: 20px;
  width: 90%;
  max-width: 550px;
  max-height: 85vh;
  overflow-y: auto;
}

.modal header {
  padding: 15px 20px;
  border-bottom: 1px solid var(--border);
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.modal header h3 {
  color: var(--primary);
  font-size: 18px;
}

.close-x {
  background: none;
  border: none;
  font-size: 28px;
  cursor: pointer;
  color: var(--text-muted);
}

.modal .body {
  padding: 20px;
}

.modal .footer {
  padding: 15px 20px;
  border-top: 1px solid var(--border);
  display: flex;
  gap: 10px;
  justify-content: flex-end;
}

/* ===== التنبيهات ===== */
.toast-container {
  position: fixed;
  bottom: 20px;
  left: 20px;
  z-index: 1100;
}

.toast {
  background: var(--surface);
  border-right: 4px solid var(--primary);
  color: var(--text);
  padding: 12px 20px;
  border-radius: 12px;
  margin-top: 8px;
  box-shadow: 0 4px 12px rgba(0,0,0,0.1);
  direction: rtl;
  font-size: 14px;
}

.toast.error {
  border-right-color: var(--red);
}

.toast.warn {
  border-right-color: var(--gold);
}

/* ===== التوثيقات ===== */
.form-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px,1fr));
  gap: 15px;
}

.form-field label {
  display: block;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-muted);
  margin-bottom: 5px;
}

.form-field input, .form-field select, .form-field textarea {
  width: 100%;
  padding: 10px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--surface);
  color: var(--text);
  font-family: inherit;
  font-size: 13px;
}

.form-field textarea {
  min-height: 80px;
  resize: vertical;
}

/* ===== البحث ===== */
.search {
  padding: 10px 15px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--surface);
  color: var(--text);
  font-family: inherit;
  font-size: 13px;
}

/* ===== استجابة الشاشة ===== */
@media (max-width: 900px) {
  .sidebar {
    transform: translateX(100%);
  }
  .sidebar.open {
    transform: translateX(0);
  }
  .main {
    margin-right: 0;
  }
  .menu-toggle {
    display: block;
  }
  .stats-grid, .grid-2 {
    grid-template-columns: 1fr;
  }
}

@media print {
  .sidebar, .topbar, .menu-toggle, .toolbar, .actions, .no-print, #modal, .toast-container {
    display: none !important;
  }
  .main {
    margin: 0 !important;
    padding: 0 !important;
  }
  .card, .plan-card {
    break-inside: avoid;
  }
}

/* ===== تحسينات الهوية البصرية ===== */
:root {
  --gov-green: #1a5d3c;
  --gov-green-light: #2d6a4f;
  --gov-gold: #c9a227;
}

.export-buttons {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  margin: 15px 0;
}

.btn-print {
  background: var(--gov-green);
  color: white;
}

.btn-word {
  background: #1857b6;
  color: white;
}

.btn-excel {
  background: #1f724c;
  color: white;
}

/* ====== نافذة الترحيب الفاخرة ====== */
.welcome-modal {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 9999;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  visibility: hidden;
  transition: all 0.4s ease;
}

.welcome-modal.show {
  opacity: 1;
  visibility: visible;
}

.welcome-overlay {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: linear-gradient(135deg, rgba(0,0,0,0.85) 0%, #492a81 100%);
  backdrop-filter: blur(8px);
}

.welcome-card {
  position: relative;
  background: linear-gradient(145deg, #ffffff 0%, #f8fafc 100%);
  width: 90%;
  max-width: 450px;
  border-radius: 32px;
  padding: 35px 30px 30px;
  text-align: center;
  box-shadow: 0 25px 50px -12px rgba(0,0,0,0.5), 0 0 0 1px rgba(255,255,255,0.2);
  transform: scale(0.9) translateY(20px);
  transition: all 0.4s cubic-bezier(0.34, 1.2, 0.64, 1);
  direction: rtl;
}

.welcome-modal.show .welcome-card {
  transform: scale(1) translateY(0);
}

.welcome-close {
  position: absolute;
  top: 15px;
  left: 20px;
  background: rgba(0,0,0,0.05);
  border: none;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  font-size: 20px;
  cursor: pointer;
  color: #666;
  transition: all 0.2s;
  display: flex;
  align-items: center;
  justify-content: center;
}

.welcome-close:hover {
  background: #dc2626;
  color: white;
  transform: rotate(90deg);
}

.welcome-icon {
  margin-bottom: 20px;
}

.icon-shield {
  font-size: 60px;
  background: linear-gradient(135deg, #492a81 0%, #c9a227 100%);
  width: 90px;
  height: 90px;
  margin: 0 auto;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 45px;
  box-shadow: 0 10px 25px -5px rgba(26,93,60,0.4);
}

.welcome-title {
  font-size: 24px;
  font-weight: 800;
  background: linear-gradient(135deg, #492a81 0%, #492a81 100%);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  margin-bottom: 15px;
}

.welcome-divider {
  margin: 15px auto;
  width: 60px;
  height: 2px;
  background: linear-gradient(90deg, transparent, #c9a227, #492a81, #c9a227, transparent);
  position: relative;
}

.welcome-divider span {
  position: absolute;
  top: -12px;
  left: 50%;
  transform: translateX(-50%);
  background: white;
  padding: 0 8px;
  color: #c9a227;
  font-size: 14px;
}

.welcome-content {
  margin: 25px 0;
}

.copyright-text {
  font-size: 18px;
  font-weight: 500;
  color: #1e293b;
  margin: 15px 0;
  line-height: 1.6;
}

.copyright-symbol {
  font-size: 22px;
  color: #c9a227;
  margin-left: 5px;
}

.highlight {
  color: #492a81;
  font-weight: 800;
  position: relative;
  display: inline-block;
}

.highlight::after {
  content: '';
  position: absolute;
  bottom: -2px;
  left: 0;
  right: 0;
  height: 3px;
  background: linear-gradient(90deg, #c9a227, #1a5d3c);
  border-radius: 3px;
}

.dev-text {
  font-size: 16px;
  color: #475569;
  margin: 20px 0;
  font-weight: 500;
}

.dev-text strong {
  color: #c9a227;
  font-weight: 800;
  font-size: 18px;
}

.license-badge {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: linear-gradient(135deg, #1a5d3c10 0%, #c9a22710 100%);
  padding: 8px 18px;
  border-radius: 50px;
  margin-top: 10px;
  font-size: 13px;
  font-weight: 600;
  color: #1a5d3c;
  border: 1px solid rgba(26,93,60,0.2);
}

.license-icon {
  font-size: 18px;
}

.welcome-footer {
  margin-top: 25px;
}

.welcome-btn {
  background: linear-gradient(135deg, #492a81 0%, #492a81 100%);
  border: none;
  padding: 12px 32px;
  border-radius: 50px;
  font-size: 16px;
  font-weight: 700;
  color: white;
  cursor: pointer;
  transition: all 0.3s;
  font-family: 'Cairo', sans-serif;
  box-shadow: 0 4px 12px rgba(26,93,60,0.3);
  width: 80%;
}

.welcome-btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 20px rgba(26,93,60,0.4);
  background: linear-gradient(135deg, #2d6a4f 0%, #1a5d3c 100%);
}

.hint-text {
  font-size: 11px;
  color: #94a3b8;
  margin-top: 12px;
}

/* وضع الليل للنافذة */
[data-theme="dark"] .welcome-card {
  background: linear-gradient(145deg, #1e293b 0%, #0f172a 100%);
}

[data-theme="dark"] .welcome-title {
  background: linear-gradient(135deg, #4ade80 0%, #fbbf24 100%);
  -webkit-background-clip: text;
  background-clip: text;
}

[data-theme="dark"] .copyright-text {
  color: #e2e8f0;
}

[data-theme="dark"] .dev-text {
  color: #94a3b8;
}

[data-theme="dark"] .welcome-divider span {
  background: #1e293b;
}

[data-theme="dark"] .welcome-close {
  background: rgba(255,255,255,0.1);
  color: #94a3b8;
}