/* ══════════════════════════════════════════
   لوحة الإدارة - التصميم
══════════════════════════════════════════ */
:root {
  --primary:        #0B6B3A;
  --primary-dark:   #084d2a;
  --primary-light:  #1FAF5A;
  --primary-soft:   #e8f5ee;
  --gold:           #D4AF37;
  --white:          #ffffff;
  --bg:             #f4f7f6;
  --sidebar-bg:     #0B6B3A;
  --sidebar-w:      260px;
  --text-dark:      #1a2332;
  --text-mid:       #4a5568;
  --text-light:     #718096;
  --border:         #e2e8f0;
  --danger:         #e53e3e;
  --danger-soft:    #fff5f5;
  --shadow-xs:      0 1px 4px rgba(0,0,0,.06);
  --shadow-sm:      0 2px 10px rgba(0,0,0,.08);
  --shadow-md:      0 6px 20px rgba(0,0,0,.12);
  --radius:         12px;
  --radius-sm:      8px;
  --transition:     all .25s ease;
  --header-h:       64px;
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
body {
  font-family: 'Tajawal', 'Arial', sans-serif;
  direction: rtl;
  background: var(--bg);
  color: var(--text-dark);
  line-height: 1.6;
  min-height: 100vh;
}
a { text-decoration: none; color: inherit; }
ul { list-style: none; }
img { max-width: 100%; }
button, input, select, textarea { font-family: inherit; }

/* ══════════════════════════════════════════
   صفحة تسجيل الدخول
══════════════════════════════════════════ */
.login-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(140deg, var(--primary-dark) 0%, var(--primary) 60%, #0f9950 100%);
  padding: 20px;
  position: relative;
  overflow: hidden;
}
.login-page::before {
  content: '';
  position: absolute;
  width: 500px; height: 500px;
  background: rgba(212,175,55,.1);
  border-radius: 50%;
  top: -200px; right: -100px;
}
.login-page::after {
  content: '';
  position: absolute;
  width: 300px; height: 300px;
  background: rgba(255,255,255,.05);
  border-radius: 50%;
  bottom: -100px; left: -50px;
}
.login-card {
  background: white;
  border-radius: 20px;
  padding: 44px 40px;
  width: 100%;
  max-width: 420px;
  box-shadow: 0 20px 60px rgba(0,0,0,.25);
  position: relative;
  z-index: 1;
}
.login-logo {
  text-align: center;
  margin-bottom: 28px;
}
.login-logo-icon {
  width: 68px;
  height: 68px;
  background: linear-gradient(135deg, var(--primary), var(--primary-light));
  border-radius: 18px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.8rem;
  font-weight: 900;
  color: white;
  margin: 0 auto 14px;
  box-shadow: 0 6px 20px rgba(11,107,58,.3);
}
.login-logo-icon::after { content: 'م'; }
.login-logo h1 { font-size: 1.1rem; font-weight: 800; color: var(--text-dark); margin-bottom: 4px; }
.login-logo p { font-size: .82rem; color: var(--text-light); }
.login-title {
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--text-mid);
  margin-bottom: 24px;
  text-align: center;
}

/* ══════════════════════════════════════════
   النماذج
══════════════════════════════════════════ */
.form-group {
  margin-bottom: 18px;
}
.form-label {
  display: block;
  font-size: .87rem;
  font-weight: 600;
  color: var(--text-mid);
  margin-bottom: 7px;
}
.form-label .required { color: var(--danger); }
.form-control {
  width: 100%;
  padding: 11px 14px;
  border: 2px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: .92rem;
  color: var(--text-dark);
  background: white;
  transition: var(--transition);
  outline: none;
  direction: rtl;
}
.form-control:focus { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(11,107,58,.1); }
.form-control.error { border-color: var(--danger); }
textarea.form-control { resize: vertical; min-height: 120px; line-height: 1.6; }
select.form-control { cursor: pointer; }
.form-hint { font-size: .78rem; color: var(--text-light); margin-top: 5px; }
.form-error { font-size: .8rem; color: var(--danger); margin-top: 5px; display: none; }
.form-error.show { display: block; }

/* ══════════════════════════════════════════
   رفع الصورة
══════════════════════════════════════════ */
.upload-area {
  border: 2px dashed var(--border);
  border-radius: var(--radius);
  padding: 30px;
  text-align: center;
  cursor: pointer;
  transition: var(--transition);
  background: var(--bg);
}
.upload-area:hover { border-color: var(--primary); background: var(--primary-soft); }
.upload-area.has-image { padding: 0; border-style: solid; overflow: hidden; }
.upload-icon { font-size: 2.5rem; margin-bottom: 10px; }
.upload-text { font-size: .88rem; color: var(--text-mid); font-weight: 500; }
.upload-sub { font-size: .78rem; color: var(--text-light); margin-top: 4px; }
.upload-preview {
  width: 100%;
  max-height: 260px;
  object-fit: contain;
  background: #f8f8f8;
}
.upload-change-btn {
  display: block;
  padding: 8px;
  text-align: center;
  font-size: .82rem;
  color: var(--primary);
  background: var(--primary-soft);
  font-weight: 600;
  cursor: pointer;
  transition: var(--transition);
}
.upload-change-btn:hover { background: var(--border); }
#imageInput { display: none; }

/* ══════════════════════════════════════════
   التخطيط العام للأدمن
══════════════════════════════════════════ */
.admin-layout { display: flex; min-height: 100vh; }

/* شريط جانبي */
.sidebar {
  width: var(--sidebar-w);
  background: var(--sidebar-bg);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  position: fixed;
  top: 0; right: 0;
  z-index: 200;
  box-shadow: 2px 0 16px rgba(0,0,0,.15);
}
.sidebar-brand {
  padding: 22px 20px;
  border-bottom: 1px solid rgba(255,255,255,.1);
  display: flex;
  align-items: center;
  gap: 12px;
}
.sidebar-logo {
  width: 42px; height: 42px;
  background: var(--gold);
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.2rem;
  font-weight: 900;
  color: var(--primary-dark);
  flex-shrink: 0;
}
.sidebar-logo::after { content: 'م'; }
.sidebar-brand-info { flex: 1; overflow: hidden; }
.sidebar-brand-name { font-size: .82rem; font-weight: 700; color: white; line-height: 1.3; }
.sidebar-brand-role { font-size: .72rem; color: rgba(255,255,255,.55); }

.sidebar-nav { flex: 1; padding: 16px 12px; overflow-y: auto; }
.sidebar-section-title {
  font-size: .7rem;
  font-weight: 700;
  color: rgba(255,255,255,.35);
  letter-spacing: 1px;
  text-transform: uppercase;
  padding: 12px 10px 6px;
}
.sidebar-link {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 11px 14px;
  border-radius: 10px;
  font-size: .88rem;
  font-weight: 500;
  color: rgba(255,255,255,.75);
  transition: var(--transition);
  margin-bottom: 3px;
  cursor: pointer;
  border: none;
  background: none;
  width: 100%;
  text-align: right;
}
.sidebar-link:hover { background: rgba(255,255,255,.1); color: white; }
.sidebar-link.active { background: rgba(255,255,255,.18); color: white; font-weight: 600; }
.sidebar-icon { font-size: 1.1rem; flex-shrink: 0; }
.sidebar-bottom {
  padding: 16px 12px;
  border-top: 1px solid rgba(255,255,255,.1);
}
.sidebar-user {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px;
  border-radius: 10px;
  margin-bottom: 8px;
}
.sidebar-avatar {
  width: 38px; height: 38px;
  background: var(--gold);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1rem;
  font-weight: 700;
  color: var(--primary-dark);
  flex-shrink: 0;
}
.sidebar-user-name { font-size: .82rem; font-weight: 600; color: white; }
.sidebar-user-email { font-size: .72rem; color: rgba(255,255,255,.5); }

/* المحتوى الرئيسي */
.admin-main {
  flex: 1;
  margin-right: var(--sidebar-w);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}
.admin-topbar {
  height: var(--header-h);
  background: white;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 28px;
  gap: 16px;
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: var(--shadow-xs);
}
.topbar-title { font-size: 1.1rem; font-weight: 700; color: var(--text-dark); }
.topbar-actions { display: flex; align-items: center; gap: 10px; }
.admin-content { padding: 28px; flex: 1; }

/* ══════════════════════════════════════════
   بطاقات الداشبورد
══════════════════════════════════════════ */
.stats-row {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 16px;
  margin-bottom: 28px;
}
.stat-card {
  background: white;
  border-radius: var(--radius);
  padding: 22px 20px;
  box-shadow: var(--shadow-xs);
  border: 1px solid var(--border);
  position: relative;
  overflow: hidden;
}
.stat-card::before {
  content: '';
  position: absolute;
  right: 0; top: 0; bottom: 0;
  width: 4px;
  background: var(--card-color, var(--primary));
  border-radius: 0 2px 2px 0;
}
.stat-card-num {
  font-size: 2.2rem;
  font-weight: 900;
  color: var(--card-color, var(--primary));
  line-height: 1;
}
.stat-card-label { font-size: .82rem; color: var(--text-light); margin-top: 6px; font-weight: 500; }

/* ══════════════════════════════════════════
   جدول الإنجازات
══════════════════════════════════════════ */
.panel-card {
  background: white;
  border-radius: var(--radius);
  box-shadow: var(--shadow-xs);
  border: 1px solid var(--border);
  overflow: hidden;
}
.panel-header {
  padding: 18px 22px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}
.panel-title { font-size: 1rem; font-weight: 700; color: var(--text-dark); }
.panel-actions { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.panel-filter {
  padding: 8px 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: .85rem;
  color: var(--text-mid);
  background: white;
  outline: none;
  cursor: pointer;
  font-family: inherit;
}
.achievements-list { padding: 0; }
.achievement-row {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 14px 22px;
  border-bottom: 1px solid var(--border);
  transition: var(--transition);
}
.achievement-row:last-child { border-bottom: none; }
.achievement-row:hover { background: var(--bg); }
.row-thumb {
  width: 60px;
  height: 60px;
  border-radius: 10px;
  overflow: hidden;
  flex-shrink: 0;
  background: var(--bg);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.5rem;
}
.row-thumb img { width: 100%; height: 100%; object-fit: cover; }
.row-info { flex: 1; min-width: 0; }
.row-title { font-size: .92rem; font-weight: 700; color: var(--text-dark); margin-bottom: 4px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.row-meta { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.row-badge {
  padding: 3px 10px;
  border-radius: 100px;
  font-size: .72rem;
  font-weight: 700;
  color: white;
}
.row-date { font-size: .75rem; color: var(--text-light); }
.row-actions { display: flex; gap: 8px; flex-shrink: 0; }

/* ══════════════════════════════════════════
   الأزرار
══════════════════════════════════════════ */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 11px 22px;
  border-radius: var(--radius-sm);
  font-size: .88rem;
  font-weight: 600;
  border: none;
  cursor: pointer;
  transition: var(--transition);
  font-family: inherit;
  white-space: nowrap;
}
.btn-primary { background: var(--primary); color: white; }
.btn-primary:hover { background: var(--primary-dark); transform: translateY(-1px); box-shadow: var(--shadow-sm); }
.btn-gold { background: var(--gold); color: var(--primary-dark); }
.btn-gold:hover { background: #c9a42e; }
.btn-outline { background: white; border: 2px solid var(--border); color: var(--text-mid); }
.btn-outline:hover { border-color: var(--primary); color: var(--primary); }
.btn-danger { background: var(--danger); color: white; }
.btn-danger:hover { background: #c53030; }
.btn-sm { padding: 7px 14px; font-size: .8rem; }
.btn-icon { padding: 8px; border-radius: var(--radius-sm); background: var(--bg); border: 1px solid var(--border); color: var(--text-mid); cursor: pointer; font-size: 1rem; transition: var(--transition); }
.btn-icon:hover { background: var(--primary-soft); color: var(--primary); border-color: var(--primary); }
.btn-icon.danger:hover { background: var(--danger-soft); color: var(--danger); border-color: var(--danger); }
.btn-full { width: 100%; justify-content: center; }
.btn-loading { opacity: .7; pointer-events: none; }

/* ══════════════════════════════════════════
   تنبيهات
══════════════════════════════════════════ */
.alert {
  padding: 14px 18px;
  border-radius: var(--radius-sm);
  font-size: .88rem;
  font-weight: 500;
  margin-bottom: 18px;
  display: none;
  border-right: 4px solid;
}
.alert.show { display: flex; align-items: flex-start; gap: 10px; }
.alert-success { background: #f0fdf4; color: #166534; border-color: #22c55e; }
.alert-error   { background: var(--danger-soft); color: #c53030; border-color: var(--danger); }
.alert-info    { background: #eff6ff; color: #1e40af; border-color: #3b82f6; }

/* ══════════════════════════════════════════
   حالات التحميل
══════════════════════════════════════════ */
.loading-row {
  text-align: center;
  padding: 40px;
  color: var(--text-light);
  font-size: .9rem;
}
.spinner-sm {
  width: 20px; height: 20px;
  border: 3px solid var(--border);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin .8s linear infinite;
  display: inline-block;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ══════════════════════════════════════════
   ترقيم الصفحات
══════════════════════════════════════════ */
.pagination {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 20px 22px;
  border-top: 1px solid var(--border);
}
.page-btn {
  min-width: 36px;
  height: 36px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: white;
  color: var(--text-mid);
  font-size: .85rem;
  cursor: pointer;
  transition: var(--transition);
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: inherit;
}
.page-btn:hover { border-color: var(--primary); color: var(--primary); }
.page-btn.active { background: var(--primary); border-color: var(--primary); color: white; font-weight: 700; }
.page-btn:disabled { opacity: .4; cursor: default; }

/* ══════════════════════════════════════════
   تأكيد الحذف
══════════════════════════════════════════ */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.5);
  z-index: 999;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  backdrop-filter: blur(3px);
  opacity: 0;
  pointer-events: none;
  transition: opacity .25s;
}
.modal-overlay.open { opacity: 1; pointer-events: all; }
.modal {
  background: white;
  border-radius: var(--radius);
  padding: 32px;
  max-width: 400px;
  width: 100%;
  box-shadow: 0 20px 60px rgba(0,0,0,.3);
  transform: scale(.95);
  transition: transform .25s;
}
.modal-overlay.open .modal { transform: scale(1); }
.modal-icon { font-size: 3rem; text-align: center; margin-bottom: 14px; }
.modal-title { font-size: 1.1rem; font-weight: 800; color: var(--text-dark); text-align: center; margin-bottom: 10px; }
.modal-text { font-size: .88rem; color: var(--text-mid); text-align: center; margin-bottom: 24px; line-height: 1.7; }
.modal-actions { display: flex; gap: 10px; }
.modal-actions .btn { flex: 1; justify-content: center; }

/* ══════════════════════════════════════════
   صفحة تغيير كلمة المرور
══════════════════════════════════════════ */
.change-pw-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg);
  padding: 20px;
}
.change-pw-card {
  background: white;
  border-radius: 18px;
  padding: 40px 36px;
  max-width: 440px;
  width: 100%;
  box-shadow: var(--shadow-md);
  border: 1px solid var(--border);
}
.change-pw-header { text-align: center; margin-bottom: 28px; }
.change-pw-icon { font-size: 2.5rem; margin-bottom: 12px; }
.change-pw-header h2 { font-size: 1.3rem; font-weight: 800; color: var(--text-dark); margin-bottom: 6px; }
.change-pw-header p { font-size: .85rem; color: var(--text-light); }

/* ══════════════════════════════════════════
   صفحة المستخدمين
══════════════════════════════════════════ */
.users-table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
thead tr { background: var(--bg); }
th { padding: 12px 18px; text-align: right; font-size: .8rem; font-weight: 700; color: var(--text-light); text-transform: uppercase; letter-spacing: .5px; border-bottom: 1px solid var(--border); white-space: nowrap; }
td { padding: 14px 18px; font-size: .88rem; color: var(--text-mid); border-bottom: 1px solid var(--border); }
tr:last-child td { border-bottom: none; }
tr:hover td { background: var(--bg); }
.role-badge { padding: 4px 12px; border-radius: 100px; font-size: .75rem; font-weight: 700; }
.role-super { background: #fdf4e7; color: #b45309; }
.role-school { background: var(--primary-soft); color: var(--primary-dark); }

/* ══════════════════════════════════════════
   شارة الحالة
══════════════════════════════════════════ */
.status-pill {
  display: inline-flex;
  align-items: center;
  padding: 2px 8px;
  border-radius: 100px;
  font-size: .7rem;
  font-weight: 700;
}
.status-pill.active   { background: #f0fdf4; color: #166534; }
.status-pill.inactive { background: #fef2f2; color: #991b1b; }

/* ══════════════════════════════════════════
   شريط التوست
══════════════════════════════════════════ */
.toast-container {
  position: fixed;
  top: 80px;
  left: 24px;
  z-index: 9999;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.toast {
  padding: 14px 20px;
  border-radius: var(--radius-sm);
  font-size: .88rem;
  font-weight: 600;
  color: white;
  box-shadow: var(--shadow-md);
  animation: slideIn .3s ease;
  max-width: 300px;
}
.toast-success { background: var(--primary); }
.toast-error   { background: var(--danger); }
@keyframes slideIn {
  from { opacity: 0; transform: translateX(-16px); }
  to   { opacity: 1; transform: translateX(0); }
}

/* استجابة */
@media (max-width: 768px) {
  .sidebar { transform: translateX(100%); transition: transform .3s; }
  .sidebar.open { transform: translateX(0); }
  .admin-main { margin-right: 0; }
  .admin-topbar { padding: 0 16px; }
  .admin-content { padding: 16px; }
  .achievement-row { flex-wrap: wrap; }
  .stats-row { grid-template-columns: repeat(2, 1fr); }
}
