/* ==========================================================================
   منصة إدارة التدريب التعاوني — معهد الفضيلة العالي للتدريب
   تصميم عربي RTL كامل (زمردي + ذهبي)
   ========================================================================== */

:root {
  --emerald-950: #022c22;
  --emerald-900: #064e3b;
  --emerald-800: #065f46;
  --emerald-700: #047857;
  --emerald-600: #059669;
  --emerald-300: #6ee7b7;
  --emerald-200: #a7f3d0;
  --emerald-100: #d1fae5;
  --emerald-50:  #ecfdf5;

  --amber-900: #78350f;
  --amber-800: #92400e;
  --amber-700: #b45309;
  --amber-600: #d97706;
  --amber-500: #f59e0b;
  --amber-400: #fbbf24;
  --amber-200: #fde68a;
  --amber-100: #fef3c7;
  --amber-50:  #fffbeb;

  --stone-900: #1c1917;
  --stone-800: #292524;
  --stone-700: #44403c;
  --stone-600: #57534e;
  --stone-500: #78716c;
  --stone-400: #a8a29e;
  --stone-300: #d6d3d1;
  --stone-200: #e7e5e4;
  --stone-100: #f5f5f4;
  --stone-50:  #fafaf9;

  --rose-700: #be123c;
  --rose-600: #e11d48;
  --rose-200: #fecdd3;
  --rose-50:  #fff1f2;

  --teal-700: #0f766e;
  --teal-50:  #f0fdfa;
  --sky-50:   #f0f9ff;
  --sky-800:  #075985;

  --radius: 12px;
  --radius-lg: 16px;
  --shadow-sm: 0 1px 3px rgba(0, 0, 0, .07);
  --shadow-md: 0 6px 18px rgba(6, 78, 59, .09);
  --border: var(--stone-200);
  --font-body: 'Tajawal', 'Segoe UI', Tahoma, sans-serif;
  --font-head: 'Cairo', 'Tajawal', Tahoma, sans-serif;
}

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

html { -webkit-text-size-adjust: 100%; }

body {
  font-family: var(--font-body);
  color: var(--stone-800);
  background: #fff;
  line-height: 1.7;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.site-main { flex: 1 0 auto; }

img, svg { max-width: 100%; }

h1, h2, h3, h4 { font-family: var(--font-head); line-height: 1.5; }

/* ------------------------------ أيقونات ------------------------------ */
.msi {
  font-family: 'Material Symbols Outlined';
  font-weight: normal;
  font-style: normal;
  font-size: 20px;
  line-height: 1;
  letter-spacing: normal;
  text-transform: none;
  display: inline-flex;
  white-space: nowrap;
  direction: ltr;
  -webkit-font-feature-settings: 'liga';
  font-feature-settings: 'liga';
  -webkit-font-smoothing: antialiased;
  vertical-align: middle;
  user-select: none;
}

/* ------------------------------ عناصر عامة ------------------------------ */
.container { width: 100%; max-width: 1152px; margin-inline: auto; padding-inline: 16px; }
@media (min-width: 640px) { .container { padding-inline: 24px; } }

.muted { color: var(--stone-500); font-size: 14px; }

.page-section { padding-block: 40px; }
@media (min-width: 640px) { .page-section { padding-block: 48px; } }

.row-between { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; flex-wrap: wrap; }

.hidden-md-down { display: none; }
.hidden-sm-down { display: none; }
@media (min-width: 768px) { .hidden-md-down { display: inline-flex; } }
@media (min-width: 640px) { .hidden-sm-down { display: inline-flex; } .hidden-md-up { display: none; } }

/* ------------------------------ الهيدر ------------------------------ */
.site-header {
  position: sticky;
  top: 0;
  z-index: 40;
  background: rgba(255, 255, 255, .88);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--border);
}

.header-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  height: 64px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  text-decoration: none;
  min-width: 0;
}

.brand-logo {
  flex: 0 0 auto;
  width: 44px;
  height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 12px;
  background: linear-gradient(135deg, var(--emerald-700), var(--emerald-950));
  color: #fff;
  box-shadow: 0 4px 10px rgba(6, 78, 59, .25);
}
.brand-logo .msi { font-size: 24px; }

.brand-text { display: flex; flex-direction: column; line-height: 1.4; min-width: 0; }
.brand-title { font-family: var(--font-head); font-weight: 800; color: var(--emerald-900); font-size: 17px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.brand-sub { font-size: 12px; color: var(--stone-500); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.header-actions { display: flex; align-items: center; gap: 8px; flex: 0 0 auto; }

@media (max-width: 480px) {
  .brand-sub { display: none; }
  .brand-title { font-size: 15px; }
}

/* ------------------------------ الأزرار ------------------------------ */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px 20px;
  border-radius: 10px;
  border: 1px solid var(--emerald-700);
  background: var(--emerald-700);
  color: #fff;
  font-family: var(--font-body);
  font-weight: 700;
  font-size: 15px;
  cursor: pointer;
  text-decoration: none;
  transition: background .2s, border-color .2s, transform .15s, box-shadow .2s;
  min-height: 44px;
}
.btn:hover { background: var(--emerald-800); border-color: var(--emerald-800); }
.btn:active { transform: translateY(1px); }
.btn:focus-visible { outline: 2px solid var(--emerald-600); outline-offset: 2px; }

.btn-sm { padding: 6px 14px; font-size: 13.5px; min-height: 36px; border-radius: 9px; }
.btn-lg { padding: 13px 24px; font-size: 16.5px; border-radius: 12px; }
.btn-block { width: 100%; }

.btn-outline { background: #fff; color: var(--stone-700); border-color: var(--stone-300); }
.btn-outline:hover { background: var(--stone-50); color: var(--stone-800); border-color: var(--stone-400); }

.btn-emerald { background: var(--emerald-700); }
.btn-emerald:hover { background: var(--emerald-800); }

.btn-amber { background: var(--amber-600); border-color: var(--amber-600); }
.btn-amber:hover { background: var(--amber-700); border-color: var(--amber-700); }

.btn-outline-amber { background: #fff; color: var(--amber-900); border-color: var(--amber-200); }
.btn-outline-amber:hover { background: var(--amber-100); color: var(--amber-900); border-color: var(--amber-400); }

.btn-danger { background: var(--rose-700); border-color: var(--rose-700); }
.btn-danger:hover { background: #9f1239; border-color: #9f1239; }

.icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  border-radius: 9px;
  border: none;
  background: transparent;
  cursor: pointer;
  color: var(--stone-500);
  transition: background .2s, color .2s;
}
.icon-btn:hover { background: var(--stone-100); color: var(--stone-800); }
.btn-edit { color: var(--amber-700); }
.btn-edit:hover { background: var(--amber-50); color: var(--amber-800); }
.btn-del { color: var(--rose-600); }
.btn-del:hover { background: var(--rose-50); color: var(--rose-700); }

/* ------------------------------ الشارات ------------------------------ */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 10px;
  border-radius: 999px;
  font-size: 11.5px;
  font-weight: 700;
  border: 1px solid transparent;
  line-height: 1.6;
  white-space: nowrap;
}
.badge-pdf   { background: var(--rose-50);  color: var(--rose-700);  border-color: var(--rose-200); }
.badge-word  { background: var(--emerald-50); color: var(--emerald-700); border-color: var(--emerald-200); }
.badge-excel { background: var(--teal-50);  color: var(--teal-700);  border-color: #99f6e4; }
.badge-image { background: var(--amber-50); color: var(--amber-800); border-color: var(--amber-200); }
.badge-zip, .badge-file { background: var(--stone-100); color: var(--stone-700); border-color: var(--stone-300); }
.badge-gray  { background: var(--stone-100); color: var(--stone-600); border-color: var(--stone-200); }
.badge-soft  { background: var(--emerald-50); color: var(--emerald-800); border-color: var(--emerald-200); }

/* ------------------------------ الهيرو ------------------------------ */
.hero {
  position: relative;
  overflow: hidden;
  background: var(--emerald-950);
  color: #fff;
}
.hero-bg {
  position: absolute;
  inset: 0;
  opacity: .4;
  pointer-events: none;
  background:
    radial-gradient(600px 300px at 85% -10%, rgba(16, 185, 129, .35), transparent),
    radial-gradient(500px 260px at 10% 110%, rgba(5, 150, 105, .3), transparent);
}
.hero-inner { position: relative; padding-block: 56px; }
.hero-compact .hero-inner { padding-block: 44px; }

.hero-pill {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  border: 1px solid rgba(52, 211, 153, .3);
  background: rgba(6, 78, 59, .6);
  color: var(--emerald-100);
  border-radius: 999px;
  padding: 6px 14px;
  font-size: 12.5px;
  font-weight: 500;
}
.hero-pill .dot { width: 6px; height: 6px; border-radius: 50%; background: var(--amber-300); }

.hero-title {
  margin-top: 20px;
  font-size: 32px;
  font-weight: 800;
  line-height: 1.45;
}
@media (min-width: 640px) { .hero-title { font-size: 40px; } }
@media (min-width: 1024px) { .hero-title { font-size: 44px; } }

.hero-text {
  margin-top: 12px;
  max-width: 640px;
  color: rgba(209, 250, 229, .9);
  font-size: 16px;
}
@media (min-width: 640px) { .hero-text { font-size: 17.5px; } }

.hero-info-grid {
  margin-top: 32px;
  display: grid;
  grid-template-columns: 1fr;
  gap: 12px;
}
@media (min-width: 640px) { .hero-info-grid { grid-template-columns: repeat(2, 1fr); } }
@media (min-width: 1024px) { .hero-info-grid { grid-template-columns: repeat(4, 1fr); } }

.hero-info-card {
  display: flex;
  align-items: center;
  gap: 12px;
  border: 1px solid rgba(255, 255, 255, .1);
  background: rgba(255, 255, 255, .1);
  backdrop-filter: blur(4px);
  border-radius: 12px;
  padding: 16px;
}
.hero-info-icon {
  flex: 0 0 auto;
  width: 40px;
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 10px;
  background: rgba(251, 191, 36, .2);
  color: #fde68a;
}
.info-label { font-size: 12px; color: rgba(167, 243, 208, .8); }
.info-value { font-size: 14px; font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.hero-steps {
  margin-top: 32px;
  display: grid;
  grid-template-columns: 1fr;
  gap: 12px;
  list-style: none;
}
@media (min-width: 640px) { .hero-steps { grid-template-columns: repeat(3, 1fr); } }
.hero-steps li {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  border: 1px solid rgba(52, 211, 153, .2);
  background: rgba(6, 78, 59, .4);
  border-radius: 12px;
  padding: 16px;
}
.step-num {
  flex: 0 0 auto;
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  background: var(--amber-400);
  color: var(--emerald-950);
  font-family: var(--font-head);
  font-weight: 800;
  font-size: 14px;
}
.step-title { display: flex; align-items: center; gap: 6px; font-weight: 700; font-size: 14px; }
.step-title .msi { color: #fcd34d; font-size: 17px; }
.step-desc { font-size: 12px; color: rgba(209, 250, 229, .75); line-height: 1.6; }

/* ------------------------------ صفحة البوابتين ------------------------------ */
.gateway-section { padding-block: 48px; }
@media (min-width: 640px) { .gateway-section { padding-block: 60px; } }

.gateway-heading { text-align: center; margin-bottom: 34px; }
.gateway-heading h2 { font-size: 25px; color: var(--stone-800); font-weight: 800; }
@media (min-width: 640px) { .gateway-heading h2 { font-size: 29px; } }
.gateway-heading p { margin-top: 8px; color: var(--stone-500); font-size: 14.5px; }
@media (min-width: 640px) { .gateway-heading p { font-size: 16px; } }

.gateway-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 20px;
}
@media (min-width: 1024px) { .gateway-grid { grid-template-columns: repeat(2, 1fr); } }

.portal-card {
  position: relative;
  display: flex;
  flex-direction: column;
  background: #fff;
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  transition: transform .3s, box-shadow .3s, border-color .3s;
  overflow: hidden;
}
.portal-card::before {
  content: '';
  position: absolute;
  top: 0; inset-inline: 0;
  height: 6px;
}
.portal-trainee { border: 1px solid var(--emerald-200); }
.portal-trainee::before { background: linear-gradient(to left, var(--emerald-500), var(--emerald-600), var(--emerald-700)); }
.portal-trainee:hover { transform: translateY(-4px); border-color: var(--emerald-300); box-shadow: 0 16px 40px rgba(6, 78, 59, .12); }

.portal-admin { border: 1px solid var(--amber-200); }
.portal-admin::before { background: linear-gradient(to left, var(--amber-400), var(--amber-500), var(--amber-600)); }
.portal-admin:hover { transform: translateY(-4px); border-color: var(--amber-400); box-shadow: 0 16px 40px rgba(120, 53, 15, .12); }

.portal-body { flex: 1; padding: 26px; }
@media (min-width: 640px) { .portal-body { padding: 32px; } }

.portal-top { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.portal-icon {
  width: 62px; height: 62px;
  display: flex; align-items: center; justify-content: center;
  border-radius: 16px; color: #fff;
}
.portal-icon .msi { font-size: 32px; }
.portal-icon-emerald { background: linear-gradient(135deg, var(--emerald-600), var(--emerald-800)); box-shadow: 0 8px 20px rgba(6, 78, 59, .25); }
.portal-icon-amber { background: linear-gradient(135deg, var(--amber-500), var(--amber-700)); box-shadow: 0 8px 20px rgba(120, 53, 15, .25); }

.portal-tag { border-radius: 999px; padding: 4px 12px; font-size: 12px; font-weight: 700; border: 1px solid transparent; }
.tag-emerald { background: var(--emerald-50); color: var(--emerald-800); border-color: var(--emerald-200); }
.tag-amber { background: var(--amber-50); color: var(--amber-800); border-color: var(--amber-200); }

.portal-card h3 { margin-top: 18px; font-size: 23px; font-weight: 800; }
.portal-trainee h3 { color: var(--emerald-900); }
.portal-admin h3 { color: var(--amber-900); }

.portal-desc { margin-top: 8px; color: var(--stone-500); font-size: 14px; }

.portal-features { margin-top: 18px; list-style: none; display: flex; flex-direction: column; gap: 10px; }
.portal-features li { display: flex; align-items: flex-start; gap: 8px; font-size: 14px; color: var(--stone-700); }
.portal-features .msi { font-size: 18px; margin-top: 4px; flex: 0 0 auto; }
.portal-trainee .portal-features .msi { color: var(--emerald-600); }
.portal-admin .portal-features .msi { color: var(--amber-600); }

.portal-footer { padding: 20px; border-top: 1px solid transparent; }
.portal-footer-emerald { border-color: var(--emerald-100); background: rgba(236, 253, 245, .5); }
.portal-footer-amber { border-color: var(--amber-100); background: rgba(255, 251, 235, .5); }

/* ------------------------------ التبويبات ------------------------------ */
.tabs {
  display: flex;
  align-items: center;
  gap: 6px;
  background: var(--stone-100);
  border: 1px solid var(--stone-200);
  border-radius: 12px;
  padding: 6px;
  margin-bottom: 26px;
  overflow-x: auto;
}
.tab {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 10px 16px;
  border-radius: 9px;
  font-weight: 700;
  font-size: 14px;
  color: var(--stone-600);
  text-decoration: none;
  border: none;
  background: transparent;
  white-space: nowrap;
  transition: background .2s, color .2s;
  min-height: 42px;
}
.tab:hover { color: var(--emerald-800); }
.tab.active { background: #fff; color: var(--emerald-800); box-shadow: var(--shadow-sm); }
.tab-count {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 20px;
  height: 20px;
  padding: 0 6px;
  border-radius: 999px;
  background: var(--amber-500);
  color: #fff;
  font-size: 11px;
  font-weight: 800;
}
.tab-refresh { margin-inline-start: auto; }

/* ------------------------------ البحث والتصفية ------------------------------ */
.filter-bar {
  display: flex;
  flex-direction: column;
  gap: 14px;
  margin-bottom: 22px;
}
@media (min-width: 640px) {
  .filter-bar { flex-direction: row; align-items: center; justify-content: space-between; flex-wrap: wrap; }
}

.search-box {
  position: relative;
  width: 100%;
  max-width: 320px;
}
.search-box .msi {
  position: absolute;
  inset-inline-start: 12px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--stone-400);
  font-size: 18px;
  pointer-events: none;
}
.search-box input {
  width: 100%;
  padding: 10px 40px 10px 14px;
  border: 1px solid var(--stone-300);
  border-radius: 10px;
  font-family: var(--font-body);
  font-size: 14.5px;
  color: var(--stone-800);
  background: #fff;
  min-height: 44px;
}
.search-box input:focus { outline: 2px solid var(--emerald-600); outline-offset: 1px; border-color: var(--emerald-600); }

.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip {
  border: 1px solid var(--border);
  background: #fff;
  color: var(--stone-500);
  border-radius: 999px;
  padding: 6px 14px;
  font-size: 12.5px;
  font-weight: 700;
  text-decoration: none;
  transition: all .2s;
  min-height: 32px;
  display: inline-flex;
  align-items: center;
}
.chip:hover { border-color: var(--emerald-300); color: var(--emerald-800); }
.chip.active { background: var(--emerald-700); border-color: var(--emerald-700); color: #fff; }

/* ------------------------------ بطاقات الملفات ------------------------------ */
.files-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 16px;
}
@media (min-width: 768px) { .files-grid { grid-template-columns: repeat(2, 1fr); } }
@media (min-width: 1200px) { .files-grid { grid-template-columns: repeat(3, 1fr); } }

.file-card {
  display: flex;
  flex-direction: column;
  height: 100%;
  transition: transform .2s, box-shadow .25s, border-color .25s;
}
.file-card:hover { transform: translateY(-3px); border-color: var(--emerald-300); box-shadow: var(--shadow-md); }

.card {
  background: #fff;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
}

.file-head { padding: 18px 18px 0; }
.file-top { display: flex; align-items: flex-start; justify-content: space-between; gap: 10px; }
.file-icon {
  flex: 0 0 auto;
  width: 44px; height: 44px;
  display: flex; align-items: center; justify-content: center;
  border-radius: 12px;
  border: 1px solid var(--emerald-200);
  background: var(--emerald-50);
  color: var(--emerald-700);
}
.file-icon.icon-guide { border-color: var(--amber-200); background: var(--amber-50); color: var(--amber-700); }
.file-badges { display: flex; flex-wrap: wrap; gap: 6px; justify-content: flex-end; }

.file-title { margin-top: 12px; font-size: 15.5px; font-weight: 800; color: var(--stone-800); }
.file-category { margin-top: 2px; font-size: 12px; font-weight: 700; color: var(--emerald-700); }

.file-body { flex: 1; padding: 10px 18px 14px; }
.file-desc { font-size: 13.5px; color: var(--stone-500); }

.instructions { margin-top: 12px; }
.instructions summary {
  list-style: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  border: 1px dashed var(--stone-300);
  background: var(--stone-50);
  border-radius: 10px;
  padding: 8px 12px;
  font-size: 12.5px;
  font-weight: 700;
  color: var(--stone-600);
  transition: border-color .2s, color .2s;
}
.instructions summary::-webkit-details-marker { display: none; }
.instructions summary:hover { border-color: var(--emerald-300); color: var(--emerald-800); }
.instructions summary .chev { transition: transform .2s; font-size: 17px; }
.instructions[open] summary .chev { transform: rotate(180deg); }
.instructions > p {
  margin-top: 8px;
  background: rgba(236, 253, 245, .7);
  border-radius: 10px;
  padding: 12px;
  font-size: 12.5px;
  color: var(--stone-700);
  line-height: 1.8;
}

.file-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 12px 18px;
  border-top: 1px solid var(--border);
}
.file-meta { font-size: 12.5px; color: var(--stone-500); }

/* ------------------------------ النماذج ------------------------------ */
.form-card { max-width: 720px; margin-inline: auto; }
.form-head {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 22px 24px;
  border-bottom: 1px solid var(--border);
}
.form-head-icon {
  flex: 0 0 auto;
  width: 46px; height: 46px;
  display: flex; align-items: center; justify-content: center;
  border-radius: 12px;
  background: var(--emerald-50);
  color: var(--emerald-700);
  border: 1px solid var(--emerald-200);
}
.form-head h2 { font-size: 18px; color: var(--emerald-900); }
.form-head p { font-size: 13.5px; color: var(--stone-500); margin-top: 2px; }

.form-grid { padding: 24px; display: flex; flex-direction: column; gap: 16px; }
.form-row { display: grid; grid-template-columns: 1fr; gap: 14px; }
@media (min-width: 640px) { .form-row { grid-template-columns: repeat(2, 1fr); } }

.field { display: flex; flex-direction: column; gap: 6px; }
.field label { font-size: 13.5px; font-weight: 700; color: var(--stone-700); }
.req { color: var(--rose-600); }

.field input[type="text"],
.field input[type="password"],
.field input[type="search"],
.field select,
.field textarea {
  width: 100%;
  padding: 10px 14px;
  border: 1px solid var(--stone-300);
  border-radius: 10px;
  font-family: var(--font-body);
  font-size: 14.5px;
  color: var(--stone-800);
  background: #fff;
  min-height: 44px;
  transition: border-color .2s;
}
.field textarea { resize: vertical; min-height: unset; }
.field input:focus, .field select:focus, .field textarea:focus {
  outline: none;
  border-color: var(--emerald-600);
  box-shadow: 0 0 0 3px rgba(5, 150, 105, .12);
}

.field input[type="file"].file-input {
  border: 1.5px dashed var(--stone-300);
  border-radius: 10px;
  padding: 12px;
  background: var(--stone-50);
  font-size: 13.5px;
  color: var(--stone-600);
  width: 100%;
}
.field input[type="file"].file-input:focus { outline: none; border-color: var(--emerald-600); }

.hint { font-size: 12px; color: var(--stone-500); }
.hint-file { color: var(--emerald-700); font-weight: 700; }

.form-actions { display: flex; justify-content: flex-end; gap: 10px; }

.password-box { position: relative; }
.password-box input { padding-inline-start: 14px; padding-inline-end: 44px; width: 100%; }
.pw-toggle {
  position: absolute;
  inset-inline-end: 6px;
  top: 50%;
  transform: translateY(-50%);
  border: none;
  background: transparent;
  cursor: pointer;
  color: var(--stone-400);
  padding: 6px;
  border-radius: 8px;
  display: inline-flex;
}
.pw-toggle:hover { color: var(--stone-700); background: var(--stone-100); }

/* ------------------------------ لوحة الإدارة ------------------------------ */
.admin-wrap { padding-block: 32px; }

.stats-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 12px;
  margin-bottom: 24px;
}
@media (min-width: 1024px) { .stats-grid { grid-template-columns: repeat(4, 1fr); } }

.stat-card {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 16px;
}
.stat-icon {
  flex: 0 0 auto;
  width: 40px; height: 40px;
  display: flex; align-items: center; justify-content: center;
  border-radius: 10px;
  background: var(--amber-50);
  color: var(--amber-700);
}
.stat-label { font-size: 12px; color: var(--stone-500); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.stat-value { font-family: var(--font-head); font-size: 20px; font-weight: 800; color: var(--amber-900); }

.admin-tabs { flex-wrap: nowrap; }

.card-head { padding: 20px 24px; border-bottom: 1px solid var(--border); }
.card-head h2 { font-size: 17px; color: var(--amber-900); }
.card-head p { margin-top: 3px; }

.settings-grid { display: grid; grid-template-columns: 1fr; gap: 16px; }
@media (min-width: 1024px) { .settings-grid { grid-template-columns: repeat(2, 1fr); } }
.settings-form { padding: 24px; }
.card-danger { border-color: var(--rose-200); }
.card-danger h2 { color: var(--rose-700); }
.card-danger form { padding: 24px; }

/* ------------------------------ الجداول ------------------------------ */
.table-scroll {
  margin: 20px 24px 24px;
  border: 1px solid var(--border);
  border-radius: 10px;
  overflow: auto;
  max-height: 576px;
}
.table-scroll::-webkit-scrollbar { width: 8px; height: 8px; }
.table-scroll::-webkit-scrollbar-thumb { background: var(--stone-300); border-radius: 8px; }

.table { width: 100%; border-collapse: collapse; font-size: 14px; min-width: 640px; }
.table thead th {
  position: sticky;
  top: 0;
  background: var(--stone-50);
  text-align: right;
  font-size: 12.5px;
  font-weight: 700;
  color: var(--stone-500);
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
  z-index: 1;
}
.table tbody td {
  padding: 14px 16px;
  border-bottom: 1px solid var(--stone-100);
  vertical-align: middle;
}
.table tbody tr:last-child td { border-bottom: none; }
.table tbody tr:hover { background: var(--stone-50); }
.row-muted { opacity: .6; }
.th-center, .td-center { text-align: center; }
.cell-title { font-weight: 700; color: var(--stone-800); max-width: 280px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cell-sub { display: flex; align-items: center; gap: 8px; margin-top: 3px; flex-wrap: wrap; font-size: 12px; color: var(--stone-500); }
.cell-note { font-size: 11.5px; color: var(--stone-400); max-width: 210px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; margin-top: 2px; }
.cell-sm { font-size: 12.5px; }
.file-link {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  color: var(--emerald-700);
  text-decoration: none;
  font-size: 12.5px;
  font-weight: 500;
}
.file-link:hover { color: var(--emerald-900); text-decoration: underline; }
.file-link .msi { font-size: 15px; }
.file-link .truncate { max-width: 150px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.row-actions { display: inline-flex; align-items: center; gap: 4px; }
.inline-form { display: inline; }

/* قائمة حالة التسليم */
.status-select {
  border: none;
  border-radius: 8px;
  padding: 6px 12px;
  font-family: var(--font-body);
  font-size: 12.5px;
  font-weight: 700;
  cursor: pointer;
  min-height: 34px;
  width: 130px;
}
.status-select:focus { outline: 2px solid var(--emerald-600); outline-offset: 1px; }
.status-جديد          { background: var(--amber-50); color: var(--amber-800); }
.status-قيد-المراجعة  { background: var(--sky-50); color: var(--sky-800); }
.status-تم-الاستلام   { background: var(--emerald-50); color: var(--emerald-800); }

/* ------------------------------ مفتاح التفعيل ------------------------------ */
.switch {
  position: relative;
  display: inline-block;
  width: 44px;
  height: 24px;
  border: none;
  border-radius: 999px;
  background: var(--stone-300);
  cursor: pointer;
  transition: background .2s;
  padding: 0;
  vertical-align: middle;
}
.switch .knob {
  position: absolute;
  top: 3px;
  inset-inline-start: 3px;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 1px 3px rgba(0, 0, 0, .25);
  transition: transform .2s;
}
.switch.on { background: var(--emerald-600); }
.switch.on .knob { transform: translateX(-20px); }

/* ------------------------------ النوافذ الحوارية ------------------------------ */
dialog.modal {
  border: none;
  border-radius: var(--radius-lg);
  box-shadow: 0 24px 64px rgba(0, 0, 0, .25);
  padding: 0;
  width: min(560px, calc(100vw - 32px));
  max-height: min(85vh, 720px);
}
dialog.modal-sm { width: min(420px, calc(100vw - 32px)); }
dialog.modal::backdrop { background: rgba(28, 25, 23, .55); backdrop-filter: blur(2px); }

.modal-form { padding: 24px; overflow-y: auto; max-height: min(85vh, 720px); display: flex; flex-direction: column; gap: 16px; }
.modal-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}
.modal-head h3 { font-size: 18px; color: var(--emerald-900); }
.modal-head p { margin-top: 3px; }
.modal-foot {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  padding-top: 6px;
}
.modal-warn { color: var(--stone-700); font-size: 14.5px; line-height: 1.9; }

.current-file-box {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  border: 1px dashed var(--stone-300);
  background: var(--stone-50);
  border-radius: 10px;
  padding: 10px 14px;
  flex-wrap: wrap;
}
.current-file-icon { color: var(--emerald-700); }
.current-file-info { flex: 1; min-width: 150px; }
.current-file-name { font-size: 13px; font-weight: 700; color: var(--stone-700); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.current-file-info .muted { font-size: 11.5px; }

/* ------------------------------ صفحة دخول الإدارة ------------------------------ */
.admin-login-wrap { display: flex; justify-content: center; padding-block: 48px; }
.login-card {
  width: 100%;
  max-width: 420px;
  text-align: center;
  border-color: var(--amber-200);
  box-shadow: 0 10px 32px rgba(120, 53, 15, .08);
  padding: 34px 28px;
}
.login-icon {
  margin-inline: auto;
  width: 56px; height: 56px;
  display: flex; align-items: center; justify-content: center;
  border-radius: 16px;
  background: linear-gradient(135deg, var(--amber-500), var(--amber-700));
  color: #fff;
  box-shadow: 0 8px 18px rgba(120, 53, 15, .25);
}
.login-icon .msi { font-size: 28px; }
.login-title { margin-top: 14px; font-size: 20px; color: var(--amber-900); }
.login-desc { margin-top: 8px; font-size: 13.5px; color: var(--stone-500); }
.login-form { margin-top: 20px; text-align: right; display: flex; flex-direction: column; gap: 14px; }
.login-back {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin-top: 18px;
  font-size: 13px;
  color: var(--stone-500);
  text-decoration: none;
  justify-content: center;
}
.login-back:hover { color: var(--emerald-800); }

/* ------------------------------ حالات الفراغ ------------------------------ */
.empty-state {
  padding: 56px 24px;
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
}
.empty-icon { font-size: 42px; color: var(--stone-300); }
.empty-title { font-weight: 700; font-size: 16px; color: var(--stone-700); }
.empty-desc { font-size: 13.5px; color: var(--stone-500); margin-bottom: 8px; }

/* ------------------------------ التنبيهات (Toast) ------------------------------ */
.toast {
  position: fixed;
  bottom: 20px;
  inset-inline-start: 20px;
  z-index: 100;
  display: flex;
  align-items: flex-start;
  gap: 10px;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 12px;
  box-shadow: 0 12px 32px rgba(0, 0, 0, .18);
  padding: 14px 16px;
  max-width: min(380px, calc(100vw - 40px));
  animation: toast-in .3s ease;
}
@keyframes toast-in { from { opacity: 0; transform: translateY(12px); } to { opacity: 1; transform: translateY(0); } }
.toast.toast-hide { opacity: 0; transform: translateY(8px); transition: opacity .4s, transform .4s; }
.toast-icon .msi { font-size: 22px; }
.toast-success .toast-icon .msi { color: var(--emerald-600); }
.toast-error .toast-icon .msi { color: var(--rose-600); }
.toast-msg { font-weight: 700; font-size: 14px; color: var(--stone-800); }
.toast-desc { font-size: 12.5px; color: var(--stone-500); margin-top: 2px; }
.toast-close { border: none; background: transparent; cursor: pointer; color: var(--stone-400); padding: 2px; }
.toast-close:hover { color: var(--stone-700); }

/* ------------------------------ الفوتر ------------------------------ */
.site-footer {
  margin-top: auto;
  background: var(--emerald-950);
  color: var(--emerald-100);
  border-top: 1px solid rgba(6, 78, 59, .2);
}
.footer-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 32px;
  padding-block: 40px;
}
@media (min-width: 768px) { .footer-grid { grid-template-columns: repeat(3, 1fr); } }
.footer-brand { display: flex; align-items: center; gap: 10px; }
.footer-logo {
  width: 40px; height: 40px;
  display: flex; align-items: center; justify-content: center;
  border-radius: 12px;
  background: var(--emerald-800);
  color: #fff;
}
.footer-title { font-family: var(--font-head); font-weight: 700; color: #fff; font-size: 15.5px; }
.footer-desc { margin-top: 12px; font-size: 13.5px; color: rgba(167, 243, 208, .8); line-height: 1.9; }
.footer-heading { font-family: var(--font-head); font-weight: 700; color: #fff; font-size: 14px; }
.footer-list { list-style: none; margin-top: 12px; display: flex; flex-direction: column; gap: 10px; font-size: 13.5px; color: rgba(167, 243, 208, .85); }
.footer-list .msi { color: #fcd34d; font-size: 17px; }
.footer-bottom { border-top: 1px solid rgba(6, 95, 70, .5); }
.footer-bottom p {
  max-width: 1152px;
  margin-inline: auto;
  padding: 16px;
  text-align: center;
  font-size: 12px;
  color: rgba(110, 231, 183, .7);
}

/* ------------------------------ شريط المتدرب ------------------------------ */
.trainee-bar {
  background: var(--emerald-50);
  border-bottom: 1px solid var(--emerald-200);
}
.trainee-bar-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding-block: 12px;
  flex-wrap: wrap;
}
.trainee-info { display: flex; align-items: center; gap: 12px; min-width: 0; }
.trainee-avatar {
  flex: 0 0 auto;
  width: 42px; height: 42px;
  display: flex; align-items: center; justify-content: center;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--emerald-600), var(--emerald-800));
  color: #fff;
}
.trainee-avatar .msi { font-size: 22px; }
.trainee-name { font-weight: 800; font-size: 14.5px; color: var(--emerald-900); }
.trainee-meta { font-size: 12.5px; color: var(--stone-600); }
.trainee-meta b { color: var(--emerald-800); }
.trainee-meta .sep { margin-inline: 6px; color: var(--stone-400); }

.readonly-box {
  background: var(--stone-100);
  border: 1px solid var(--stone-200);
  border-radius: 10px;
  padding: 10px 14px;
  font-size: 14.5px;
  color: var(--stone-600);
  min-height: 44px;
  display: flex;
  align-items: center;
}

.hint-ok { color: var(--emerald-700); font-weight: 700; }
.hint-bad { color: var(--rose-700); font-weight: 700; }
.text-ok { color: var(--emerald-700); }
.text-bad { color: var(--rose-700); }

/* صف إعداد التحقق من الهوية (الإعدادات) */
.verify-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  padding: 6px 2px;
}
.verify-info .cell-title { font-size: 15px; font-weight: 800; color: var(--stone-800); margin-bottom: 4px; }
.verify-info .muted { font-size: 13px; line-height: 1.8; }

/* رسالة منع الخريجين */
.denied-card {
  max-width: 560px;
  margin-inline: auto;
  text-align: center;
  border-color: var(--rose-200);
  padding: 40px 30px;
}
.denied-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 64px; height: 64px;
  border-radius: 50%;
  background: var(--rose-50);
  color: var(--rose-600);
}
.denied-icon .msi { font-size: 34px; }
.denied-card h1 { margin-top: 14px; font-size: 22px; color: var(--rose-700); }
.denied-text { margin-top: 10px; color: var(--stone-700); font-size: 15px; line-height: 1.9; }
.denied-sub { margin-top: 6px; color: var(--stone-500); font-size: 13px; margin-bottom: 18px; }
.denied-box {
  background: var(--rose-50);
  border: 1px solid var(--rose-200);
  border-radius: 10px;
  padding: 14px 16px;
  color: var(--rose-700);
  font-size: 14px;
}
.denied-box b { display: flex; align-items: center; gap: 6px; }
.denied-box p { margin-top: 4px; font-size: 13px; }
.hidden { display: none !important; }
.btn-disabled { opacity: .55; cursor: not-allowed; }

/* شارات المراحل */
.badge-filled {
  background: linear-gradient(90deg, var(--emerald-50), var(--amber-50));
  color: var(--emerald-800);
  border-color: var(--emerald-200);
}
.badge-filled .msi { font-size: 13px; }
.phase-co1 { background: var(--emerald-50); color: var(--emerald-800); border-color: var(--emerald-200); }
.phase-co2 { background: var(--amber-50); color: var(--amber-800); border-color: var(--amber-200); }
.phase-grad { background: var(--stone-200); color: var(--stone-700); border-color: var(--stone-300); }
.btn-group { display: inline-flex; gap: 6px; flex-wrap: wrap; }

/* محرر هيكل النموذج */
.modal-lg { width: min(760px, calc(100vw - 32px)); }
.tpl-textarea {
  font-family: 'Consolas', 'Menlo', monospace !important;
  font-size: 13.5px !important;
  line-height: 1.9 !important;
  background: var(--stone-50) !important;
}
.tpl-help {
  background: var(--stone-50);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 12px 14px;
}
.tpl-help-title { font-size: 12.5px; font-weight: 800; color: var(--stone-700); margin-bottom: 6px; }
.tpl-help-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 6px;
  font-size: 12px;
  color: var(--stone-500);
}
.tpl-help-grid code, .tpl-chip, code.inline-code {
  background: #fff;
  border: 1px solid var(--stone-300);
  border-radius: 6px;
  padding: 2px 8px;
  font-size: 12px;
  color: var(--emerald-800);
  direction: ltr;
  display: inline-block;
}
.tpl-chips { display: flex; flex-wrap: wrap; gap: 6px; }
.tpl-chip { cursor: pointer; transition: all .15s; }
.tpl-chip:hover { border-color: var(--emerald-600); background: var(--emerald-50); }

/* أدوات تبويب المتدربين */
.head-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.trainees-toolbar { padding: 14px 24px 0; }
.bulk-bar {
  margin: 14px 24px 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  background: var(--amber-50);
  border: 1px solid var(--amber-200);
  border-radius: 10px;
  padding: 10px 16px;
  font-size: 13.5px;
  font-weight: 700;
  color: var(--amber-900);
  flex-wrap: wrap;
}
.bulk-actions { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.bulk-actions select {
  border: 1px solid var(--amber-300);
  border-radius: 8px;
  padding: 7px 12px;
  font-family: var(--font-body);
  font-size: 13.5px;
  background: #fff;
  min-height: 38px;
}
.row-check, #check-all {
  width: 17px;
  height: 17px;
  accent-color: var(--emerald-700);
  cursor: pointer;
}
.check-grid { display: flex; gap: 16px; flex-wrap: wrap; }
.check-item {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  font-size: 14px;
  color: var(--stone-700);
  cursor: pointer;
  background: var(--stone-50);
  border: 1px solid var(--stone-200);
  border-radius: 8px;
  padding: 8px 14px;
  min-height: 40px;
}
.check-item input { width: 16px; height: 16px; accent-color: var(--emerald-700); }
.import-help {
  background: var(--stone-50);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 12px 14px;
}
.import-cols { font-size: 13px; color: var(--stone-600); font-weight: 500; }
.btn-outline-danger {
  background: #fff;
  color: var(--rose-700);
  border-color: var(--rose-200);
}
.btn-outline-danger:hover { background: var(--rose-50); color: var(--rose-700); border-color: var(--rose-300); }
.btn-tpl { color: var(--emerald-700); }
.btn-tpl:hover { background: var(--emerald-50); color: var(--emerald-800); }
.btn-migrate { color: var(--amber-700); }
.btn-migrate:hover { background: var(--amber-50); color: var(--amber-800); }
.card-danger-inline { padding: 0 24px 24px; border-top: 1px dashed var(--border); padding-top: 18px; margin-top: 6px; }
.settings-form .form-actions { justify-content: flex-start; }

/* ------------------------------ تحسينات سكرولبار ------------------------------ */
.tabs::-webkit-scrollbar { height: 6px; }
.tabs::-webkit-scrollbar-thumb { background: var(--stone-300); border-radius: 6px; }
