/* ══════════════════════════════════════════════════════════════════════════
   HexDefender — نظام تصميم لوحة التحكم
   داكن، زجاجي، بحركة هادئة. كل الألوان من المتغيرات أدناه فقط.
   ══════════════════════════════════════════════════════════════════════════ */

:root {
  --bg:            #05080f;
  --bg-2:          #0a1020;
  --surface:       rgba(15, 23, 41, .72);
  --surface-solid: #0f1729;
  --surface-2:     #141e35;
  --surface-3:     #1a2642;
  --border:        rgba(148, 163, 184, .10);
  --border-strong: rgba(148, 163, 184, .20);

  --text:   #e7eef8;
  --muted:  #8a99b4;
  --faint:  #5d6d8a;

  --accent:      #2fe0a4;          /* واجهة: أزرار، توهّج، مؤشرات */
  --accent-2:    #3bb8ff;
  --accent-ink:  #03140e;          /* نص فوق الأزرار المتدرجة */
  --accent-grad: linear-gradient(135deg, #2fe0a4 0%, #34c9d6 55%, #3bb8ff 100%);
  --accent-soft: rgba(47, 224, 164, .12);

  --chart-fill:  #1fa877;          /* بيانات: مُتحقَّق منه على الخلفية الداكنة */
  --chart-track: #133a30;

  --ok:     #34d399;  --ok-soft:     rgba(52, 211, 153, .13);
  --warn:   #fbbf24;  --warn-soft:   rgba(251, 191, 36, .13);
  --danger: #fb6a84;  --danger-soft: rgba(251, 106, 132, .13);
  --info:   #60a5fa;  --info-soft:   rgba(96, 165, 250, .13);
  --violet: #a78bfa;  --violet-soft: rgba(167, 139, 250, .14);

  --radius:    18px;
  --radius-sm: 12px;
  --shadow:    0 10px 40px -12px rgba(0, 0, 0, .55);
  --glow:      0 0 0 1px rgba(47, 224, 164, .35), 0 8px 30px -8px rgba(47, 224, 164, .35);

  --ease:     cubic-bezier(.22, 1, .36, 1);
  --ease-out: cubic-bezier(.16, 1, .3, 1);

  --sidebar-w: 264px;
  --font: 'IBM Plex Sans Arabic', 'Segoe UI', Tahoma, sans-serif;
  --mono: 'JetBrains Mono', ui-monospace, Consolas, monospace;
}

/* ─── الأساس ──────────────────────────────────────────────────────────────── */

*, *::before, *::after { box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.65;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}

/* خلفية حيّة: توهّجان يتنفّسان ببطء فوق شبكة سداسية باهتة */
.bg-layer {
  position: fixed; inset: 0; z-index: -1; pointer-events: none; overflow: hidden;
}
.bg-layer::before, .bg-layer::after {
  content: ''; position: absolute; border-radius: 50%; filter: blur(90px); opacity: .55;
}
.bg-layer::before {
  width: 620px; height: 620px; top: -220px; right: -160px;
  background: radial-gradient(circle, rgba(47, 224, 164, .22), transparent 65%);
  animation: drift-a 22s var(--ease) infinite alternate;
}
.bg-layer::after {
  width: 700px; height: 700px; bottom: -300px; left: -200px;
  background: radial-gradient(circle, rgba(59, 184, 255, .18), transparent 65%);
  animation: drift-b 26s var(--ease) infinite alternate;
}
.bg-hex {
  position: absolute; inset: 0; opacity: .5;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='56' height='96' viewBox='0 0 56 96'%3E%3Cpath d='M28 0 56 16v32L28 64 0 48V16zM28 64v32' fill='none' stroke='%2394a3b8' stroke-opacity='.07' stroke-width='1'/%3E%3C/svg%3E");
  mask-image: radial-gradient(ellipse at 70% 20%, #000 10%, transparent 75%);
}

a { color: var(--accent); text-decoration: none; transition: color .2s; }
a:hover { color: #7ff0c8; }

::selection { background: rgba(47, 224, 164, .3); color: #fff; }

::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--surface-3); border-radius: 10px; border: 2px solid var(--bg); }
::-webkit-scrollbar-thumb:hover { background: #26345a; }

code, .mono { font-family: var(--mono); font-size: .86em; }
code { color: #9fe8cf; background: var(--accent-soft); padding: .12em .45em; border-radius: 6px; }

.text-muted { color: var(--muted) !important; }
.text-faint { color: var(--faint) !important; }
.nums { font-variant-numeric: tabular-nums; }

/* ─── الشريط الجانبي ──────────────────────────────────────────────────────── */

.sidebar {
  position: fixed; top: 0; right: 0; bottom: 0; width: var(--sidebar-w); z-index: 100;
  display: flex; flex-direction: column;
  padding: 22px 14px;
  background: linear-gradient(180deg, rgba(12, 19, 35, .92), rgba(8, 13, 25, .92));
  border-left: 1px solid var(--border);
  backdrop-filter: blur(18px);
}

.brand {
  display: flex; align-items: center; gap: 12px;
  padding: 4px 10px 22px; margin-bottom: 10px;
  border-bottom: 1px solid var(--border);
  color: var(--text);
}
.brand:hover { color: var(--text); }
.brand-mark { width: 42px; height: 42px; flex-shrink: 0; filter: drop-shadow(0 0 12px rgba(47, 224, 164, .35)); }
.brand-mark .ring { transform-origin: center; animation: spin 18s linear infinite; }
.brand-name { font-weight: 700; font-size: 1.06rem; letter-spacing: .2px; line-height: 1.2; }
.brand-sub  { font-size: .72rem; color: var(--muted); font-weight: 500; }

.nav-group { font-size: .7rem; color: var(--faint); font-weight: 600; letter-spacing: .6px;
             padding: 16px 12px 6px; text-transform: uppercase; }

.side-link {
  position: relative; display: flex; align-items: center; gap: 12px;
  padding: 10px 12px; margin: 2px 0; border-radius: 12px;
  color: var(--muted); font-weight: 500; font-size: .93rem;
  transition: background .25s var(--ease), color .25s var(--ease), transform .25s var(--ease);
}
.side-link i {
  width: 34px; height: 34px; display: grid; place-items: center; flex-shrink: 0;
  border-radius: 10px; font-size: 1.05rem;
  background: rgba(148, 163, 184, .06);
  transition: background .25s var(--ease), color .25s var(--ease), box-shadow .25s var(--ease);
}
.side-link:hover { color: var(--text); background: rgba(148, 163, 184, .06); transform: translateX(-3px); }
.side-link.active { color: var(--text); background: linear-gradient(90deg, transparent, rgba(47, 224, 164, .10)); }
.side-link.active i { background: var(--accent-grad); color: var(--accent-ink); box-shadow: 0 6px 18px -6px rgba(47, 224, 164, .6); }
.side-link.active::after {
  content: ''; position: absolute; right: -14px; top: 22%; bottom: 22%; width: 3px;
  border-radius: 3px 0 0 3px; background: var(--accent-grad);
  animation: grow-y .4s var(--ease-out);
}
.side-link .count {
  margin-inline-start: auto; min-width: 22px; height: 22px; padding: 0 7px;
  display: grid; place-items: center; border-radius: 11px;
  font-size: .72rem; font-weight: 700; color: #1a1300; background: var(--warn);
  animation: pulse-warn 2.2s ease-in-out infinite;
}

.sidebar-foot { margin-top: auto; padding-top: 14px; border-top: 1px solid var(--border); }
.side-link.logout:hover { color: var(--danger); }
.side-link.logout:hover i { background: var(--danger-soft); color: var(--danger); }

/* ─── المحتوى ─────────────────────────────────────────────────────────────── */

.main { margin-right: var(--sidebar-w); padding: 34px 38px 60px; min-height: 100vh; }
.container-narrow { max-width: 1320px; margin: 0 auto; }

.page-head {
  display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between;
  gap: 16px; margin-bottom: 26px;
}
.page-title { font-size: 1.65rem; font-weight: 700; margin: 0; line-height: 1.25; }
.page-title .ico {
  display: inline-grid; place-items: center; width: 44px; height: 44px; margin-inline-end: 10px;
  border-radius: 13px; background: var(--accent-soft); color: var(--accent);
  font-size: 1.25rem; vertical-align: middle; border: 1px solid rgba(47, 224, 164, .18);
}
.page-sub { color: var(--muted); margin: 6px 0 0; font-size: .92rem; }
.page-actions { display: flex; flex-wrap: wrap; gap: 10px; }

/* ─── البطاقات ────────────────────────────────────────────────────────────── */

.panel {
  position: relative;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  backdrop-filter: blur(16px);
}
.panel::before {           /* لمعة علوية رفيعة تعطي عمق الزجاج */
  content: ''; position: absolute; inset: 0; border-radius: inherit; pointer-events: none;
  background: linear-gradient(180deg, rgba(255, 255, 255, .045), transparent 40%);
}
.panel-head {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 18px 22px; border-bottom: 1px solid var(--border);
}
.panel-title { font-weight: 600; font-size: 1rem; margin: 0; display: flex; align-items: center; gap: 10px; }
.panel-title i { color: var(--accent); }
.panel-body { padding: 22px; }
.panel-body.flush { padding: 0; }
.panel.lift { transition: transform .35s var(--ease), border-color .35s var(--ease), box-shadow .35s var(--ease); }
.panel.lift:hover { transform: translateY(-3px); border-color: var(--border-strong); }

/* ─── بطاقات الأرقام ─────────────────────────────────────────────────────── */

.stat {
  position: relative; overflow: hidden; height: 100%;
  padding: 20px 20px 18px;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  backdrop-filter: blur(16px);
  transition: transform .35s var(--ease), border-color .35s var(--ease);
}
.stat:hover { transform: translateY(-4px); border-color: var(--border-strong); }
.stat::after {
  content: ''; position: absolute; inset-inline: 20px; bottom: 0; height: 2px;
  background: var(--tone, var(--accent)); opacity: .55; border-radius: 2px;
  transform: scaleX(0); transform-origin: right; transition: transform .8s var(--ease-out);
}
.stat.is-in::after { transform: scaleX(1); }
.stat-ico {
  width: 42px; height: 42px; display: grid; place-items: center; border-radius: 12px;
  font-size: 1.2rem; color: var(--tone, var(--accent));
  background: color-mix(in srgb, var(--tone, var(--accent)) 14%, transparent);
  margin-bottom: 14px;
}
.stat-value { font-size: 2rem; font-weight: 700; line-height: 1.1; }
.stat-label { color: var(--muted); font-size: .86rem; margin-top: 4px; }
.stat a.stretched { position: absolute; inset: 0; }

.hero {
  display: flex; align-items: center; justify-content: space-between; gap: 20px; flex-wrap: wrap;
  padding: 26px 28px; overflow: hidden;
}
.hero-figure { font-size: 3.4rem; font-weight: 700; line-height: 1; }
.hero-label  { color: var(--muted); font-size: .95rem; margin-top: 8px; }
.hero-orb {
  position: absolute; width: 260px; height: 260px; left: -60px; top: -80px; border-radius: 50%;
  background: radial-gradient(circle, rgba(251, 191, 36, .16), transparent 70%); pointer-events: none;
}

/* ─── الأزرار ─────────────────────────────────────────────────────────────── */

.btn {
  --bs-btn-font-weight: 600;
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  border-radius: 11px; padding: .55rem 1.05rem; font-size: .9rem; font-family: var(--font);
  border: 1px solid transparent;
  transition: transform .2s var(--ease), box-shadow .3s var(--ease), background .3s var(--ease),
              border-color .3s var(--ease), color .3s var(--ease), opacity .2s;
}
.btn:active { transform: scale(.97); }
.btn:focus-visible { outline: none; box-shadow: 0 0 0 3px rgba(47, 224, 164, .35); }
.btn-sm { padding: .36rem .75rem; font-size: .82rem; border-radius: 9px; }
.btn-lg { padding: .75rem 1.4rem; font-size: 1rem; border-radius: 13px; }

.btn-primary, .btn-primary:focus {
  background: var(--accent-grad); color: var(--accent-ink); border-color: transparent;
  box-shadow: 0 8px 22px -10px rgba(47, 224, 164, .7);
}
.btn-primary:hover, .btn-primary:active, .btn-primary.active {
  background: var(--accent-grad); color: var(--accent-ink) !important; border-color: transparent !important;
  box-shadow: 0 10px 30px -8px rgba(47, 224, 164, .8); filter: brightness(1.06);
}

.btn-ghost, .btn-outline-light, .btn-outline-secondary {
  background: rgba(148, 163, 184, .06); color: var(--text); border-color: var(--border-strong);
}
.btn-ghost:hover, .btn-outline-light:hover, .btn-outline-secondary:hover {
  background: rgba(148, 163, 184, .12); color: var(--text); border-color: rgba(148, 163, 184, .32);
}

.btn-danger, .btn-soft-danger {
  background: var(--danger-soft); color: var(--danger); border-color: rgba(251, 106, 132, .22);
}
.btn-danger:hover, .btn-soft-danger:hover {
  background: var(--danger); color: #22040a !important; border-color: var(--danger) !important;
  box-shadow: 0 8px 22px -10px rgba(251, 106, 132, .8);
}
.btn-success, .btn-soft-ok { background: var(--ok-soft); color: var(--ok); border-color: rgba(52, 211, 153, .24); }
.btn-success:hover, .btn-soft-ok:hover { background: var(--ok); color: #032015 !important; border-color: var(--ok) !important; }
.btn-warning, .btn-soft-warn { background: var(--warn-soft); color: var(--warn); border-color: rgba(251, 191, 36, .24); }
.btn-warning:hover, .btn-soft-warn:hover { background: var(--warn); color: #1f1500 !important; border-color: var(--warn) !important; }

.btn-icon { width: 36px; height: 36px; padding: 0; border-radius: 10px; }
.btn-icon.btn-sm { width: 32px; height: 32px; }

.btn.is-loading { pointer-events: none; opacity: .75; }
.btn.is-loading::before {
  content: ''; width: 14px; height: 14px; border-radius: 50%;
  border: 2px solid currentColor; border-top-color: transparent; animation: spin .7s linear infinite;
}

/* ─── النماذج ─────────────────────────────────────────────────────────────── */

.form-label { color: var(--muted); font-size: .84rem; font-weight: 500; margin-bottom: 6px; }
.form-control, .form-select {
  background-color: rgba(5, 8, 15, .6); border: 1px solid var(--border-strong); color: var(--text);
  border-radius: 11px; padding: .6rem .85rem; font-size: .93rem; font-family: var(--font);
  transition: border-color .25s var(--ease), box-shadow .25s var(--ease), background-color .25s;
}
.form-control::placeholder { color: var(--faint); }
.form-control:focus, .form-select:focus {
  background-color: rgba(5, 8, 15, .85); color: var(--text); border-color: rgba(47, 224, 164, .6);
  box-shadow: 0 0 0 4px rgba(47, 224, 164, .12);
}
.form-select {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3E%3Cpath fill='none' stroke='%238a99b4' stroke-linecap='round' stroke-linejoin='round' stroke-width='2' d='m2 5 6 6 6-6'/%3E%3C/svg%3E");
}
.form-select option { background: var(--surface-solid); color: var(--text); }
textarea.form-control { min-height: 110px; line-height: 1.7; }
.form-text { color: var(--faint) !important; font-size: .78rem; }
.input-group-text { background: var(--surface-2); border-color: var(--border-strong); color: var(--muted); border-radius: 11px; }
.form-control[type=file]::file-selector-button {
  background: var(--surface-3); color: var(--text); border: 0; margin-inline-end: 12px;
  padding: .6rem .9rem; font-family: var(--font);
}

/* ─── الجداول ─────────────────────────────────────────────────────────────── */

.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
.table {
  --bs-table-bg: transparent; --bs-table-color: var(--text); --bs-table-hover-bg: transparent;
  --bs-table-border-color: var(--border);
  margin: 0; color: var(--text); font-size: .9rem;
}
.table thead th {
  background: rgba(10, 16, 32, .55); color: var(--faint); font-weight: 600; font-size: .74rem;
  letter-spacing: .4px; text-transform: uppercase; white-space: nowrap;
  padding: 13px 16px; border-bottom: 1px solid var(--border);
}
.table td { padding: 14px 16px; vertical-align: middle; border-color: var(--border); }
.table tbody tr { position: relative; transition: background .25s var(--ease); }
.table tbody tr:hover { background: rgba(148, 163, 184, .045); }
.table tbody tr:hover td:first-child { box-shadow: inset -3px 0 0 var(--accent); }
.table tbody tr:last-child td { border-bottom: 0; }

.person { display: flex; align-items: center; gap: 12px; min-width: 0; }
.avatar {
  width: 38px; height: 38px; flex-shrink: 0; border-radius: 12px; display: grid; place-items: center;
  font-weight: 700; font-size: .95rem; color: var(--accent-ink);
  background: hsl(var(--h, 160) 70% 62%);
}
.person-name { font-weight: 600; line-height: 1.3; }
.person-meta { color: var(--faint); font-size: .78rem; }

/* ─── الشارات ─────────────────────────────────────────────────────────────── */

.pill {
  display: inline-flex; align-items: center; gap: 6px; white-space: nowrap;
  padding: .26rem .7rem; border-radius: 999px; font-size: .76rem; font-weight: 600;
  background: rgba(148, 163, 184, .1); color: var(--muted); border: 1px solid rgba(148, 163, 184, .16);
}
.pill .dot { width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.pill-ok     { background: var(--ok-soft);     color: var(--ok);     border-color: rgba(52, 211, 153, .25); }
.pill-warn   { background: var(--warn-soft);   color: var(--warn);   border-color: rgba(251, 191, 36, .25); }
.pill-danger { background: var(--danger-soft); color: var(--danger); border-color: rgba(251, 106, 132, .25); }
.pill-info   { background: var(--info-soft);   color: var(--info);   border-color: rgba(96, 165, 250, .25); }
.pill-violet { background: var(--violet-soft); color: var(--violet); border-color: rgba(167, 139, 250, .25); }
.pill-accent { background: var(--accent-soft); color: var(--accent); border-color: rgba(47, 224, 164, .25); }
.pill-warn .dot { animation: blink 1.6s ease-in-out infinite; }

/* شارات Bootstrap القديمة تتبع النظام نفسه */
.badge { font-weight: 600; border-radius: 999px; padding: .34em .75em; }
.badge.bg-secondary { background: rgba(148, 163, 184, .14) !important; color: var(--muted); }

/* ─── مقياس التقدّم ───────────────────────────────────────────────────────── */

.meter { position: relative; height: 8px; border-radius: 8px; background: var(--chart-track); overflow: hidden; }
.meter-fill {
  height: 100%; width: 0; border-radius: 8px; background: var(--chart-fill);
  transition: width 1.2s var(--ease-out);
}
.meter.warn   .meter-fill { background: var(--warn); }
.meter.warn   { background: rgba(251, 191, 36, .14); }
.meter-row { display: flex; align-items: center; gap: 12px; min-width: 170px; }
.meter-row .meter { flex: 1; }
.meter-row .val { font-size: .78rem; color: var(--muted); min-width: 64px; }

/* ─── رسم توزيع الطلاب ────────────────────────────────────────────────────── */

.bars { display: flex; flex-direction: column; gap: 10px; }
.bar-row {
  display: grid; grid-template-columns: minmax(120px, 34%) 1fr; align-items: center; gap: 14px;
  padding: 2px 0; border-radius: 8px; outline: none; cursor: default;
}
.bar-label { font-size: .84rem; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.bar-label b { color: var(--text); font-weight: 600; margin-inline-end: 6px; }
.bar-track { position: relative; display: flex; align-items: center; gap: 10px; height: 22px; }
.bar {
  height: 22px; width: 0; min-width: 0; background: var(--chart-fill);
  border-radius: 0 4px 4px 0;                     /* RTL: الطرف المستدير عند نهاية القيمة */
  transition: width 1.1s var(--ease-out), filter .2s;
}
[dir=rtl] .bar { border-radius: 4px 0 0 4px; }
.bar-row:hover .bar, .bar-row:focus-visible .bar { filter: brightness(1.25); }
.bar-row:focus-visible { box-shadow: 0 0 0 2px rgba(47, 224, 164, .4); }
.bar-val { font-size: .8rem; color: var(--text); font-weight: 600; opacity: 0; transition: opacity .4s .6s; }
.bars.is-in .bar-val { opacity: 1; }
.bar-zero .bar-val { color: var(--faint); font-weight: 500; }

.chart-tip {
  position: fixed; z-index: 2000; pointer-events: none;
  padding: 8px 12px; border-radius: 10px; font-size: .8rem;
  background: rgba(8, 13, 25, .96); border: 1px solid var(--border-strong); box-shadow: var(--shadow);
  opacity: 0; transform: translateY(4px); transition: opacity .15s, transform .15s;
}
.chart-tip.show { opacity: 1; transform: translateY(0); }
.chart-tip strong { display: block; font-size: 1rem; color: var(--text); }
.chart-tip span { color: var(--muted); }

/* ─── النوافذ المنبثقة ────────────────────────────────────────────────────── */

.modal-content {
  background: linear-gradient(180deg, rgba(20, 30, 53, .97), rgba(12, 19, 35, .97));
  border: 1px solid var(--border-strong); border-radius: 22px; color: var(--text);
  box-shadow: 0 30px 80px -20px rgba(0, 0, 0, .8);
}
.modal-header, .modal-footer { border-color: var(--border); padding: 18px 22px; }
.modal-body { padding: 22px; }
.modal-title { font-weight: 700; font-size: 1.08rem; }
.modal-backdrop.show { opacity: .7; backdrop-filter: blur(4px); }
.modal.fade .modal-dialog { transform: translateY(18px) scale(.96); transition: transform .4s var(--ease-out), opacity .3s; }
.modal.show .modal-dialog { transform: none; }
.btn-close { filter: invert(1) grayscale(1) brightness(1.4); opacity: .6; }

/* نص رسالة الترحيب القابل للنسخ */
.copy-box {
  position: relative; max-height: 52vh; overflow: auto;
  padding: 18px 20px; border-radius: 14px; white-space: pre-wrap; word-break: break-word;
  background: rgba(5, 8, 15, .7); border: 1px solid var(--border-strong);
  font-size: .9rem; line-height: 1.85; color: var(--text);
}
.copy-box.flash { animation: copied .9s var(--ease); }

/* ─── الإشعارات المنبثقة ──────────────────────────────────────────────────── */

.toasts {
  position: fixed; top: 22px; left: 22px; z-index: 3000;
  display: flex; flex-direction: column; gap: 10px; width: min(420px, calc(100vw - 32px));
}
.toast-x {
  position: relative; overflow: hidden; display: flex; align-items: flex-start; gap: 12px;
  padding: 14px 16px 16px; border-radius: 14px;
  background: rgba(12, 19, 35, .96); border: 1px solid var(--border-strong);
  box-shadow: 0 18px 50px -12px rgba(0, 0, 0, .7); backdrop-filter: blur(14px);
  animation: toast-in .5s var(--ease-out) both;
}
.toast-x.out { animation: toast-out .35s var(--ease) forwards; }
.toast-x .t-ico { width: 30px; height: 30px; flex-shrink: 0; display: grid; place-items: center; border-radius: 9px; }
.toast-x .t-msg { flex: 1; font-size: .88rem; line-height: 1.6; padding-top: 3px; }
.toast-x .t-close { background: none; border: 0; color: var(--faint); font-size: 1.1rem; line-height: 1; padding: 4px; cursor: pointer; }
.toast-x .t-close:hover { color: var(--text); }
.toast-x .t-bar { position: absolute; bottom: 0; right: 0; height: 3px; width: 100%; transform-origin: right; }
.toast-x.success .t-ico { background: var(--ok-soft); color: var(--ok); }
.toast-x.success .t-bar { background: var(--ok); }
.toast-x.danger  .t-ico { background: var(--danger-soft); color: var(--danger); }
.toast-x.danger  .t-bar { background: var(--danger); }
.toast-x.warning .t-ico { background: var(--warn-soft); color: var(--warn); }
.toast-x.warning .t-bar { background: var(--warn); }

/* ─── التنبيهات داخل الصفحة ───────────────────────────────────────────────── */

.callout {
  display: flex; gap: 14px; align-items: flex-start; flex-wrap: wrap;
  padding: 16px 18px; border-radius: 14px; border: 1px solid; margin-bottom: 22px;
}
.callout .c-ico { font-size: 1.3rem; line-height: 1; }
.callout.warn   { background: var(--warn-soft);   border-color: rgba(251, 191, 36, .25); }
.callout.warn .c-ico { color: var(--warn); }
.callout.info   { background: var(--info-soft);   border-color: rgba(96, 165, 250, .25); }
.callout.info .c-ico { color: var(--info); }

/* ─── الحالة الفارغة ──────────────────────────────────────────────────────── */

.empty { text-align: center; padding: 48px 20px; color: var(--muted); }
.empty i {
  display: inline-grid; place-items: center; width: 64px; height: 64px; margin-bottom: 14px;
  border-radius: 20px; font-size: 1.7rem; color: var(--faint);
  background: rgba(148, 163, 184, .06); border: 1px dashed var(--border-strong);
  animation: float 4s ease-in-out infinite;
}
.empty p { margin: 0; }

/* ─── فلاتر وأزرار تبويب ─────────────────────────────────────────────────── */

.segmented {
  display: inline-flex; gap: 4px; padding: 4px; border-radius: 13px;
  background: rgba(5, 8, 15, .6); border: 1px solid var(--border);
}
.segmented a {
  padding: .42rem .95rem; border-radius: 10px; color: var(--muted); font-size: .85rem; font-weight: 500;
  transition: background .25s var(--ease), color .25s var(--ease);
}
.segmented a:hover { color: var(--text); }
.segmented a.on { background: var(--surface-3); color: var(--text); box-shadow: 0 4px 14px -6px rgba(0, 0, 0, .6); }
.segmented a .n { font-size: .72rem; color: var(--faint); margin-inline-start: 4px; }

.search {
  position: relative; min-width: 240px;
}
.search i { position: absolute; top: 50%; right: 13px; transform: translateY(-50%); color: var(--faint); }
.search input { padding-right: 38px; }

/* ─── قائمة المحاضرات القابلة للترتيب ─────────────────────────────────────── */

.lec-list { display: flex; flex-direction: column; gap: 10px; padding: 16px; }
.lec {
  position: relative; display: grid;
  grid-template-columns: auto auto 1fr auto; align-items: center; gap: 14px;
  padding: 14px 16px; border-radius: 15px;
  background: rgba(10, 16, 32, .55); border: 1px solid var(--border);
  transition: border-color .25s var(--ease), background .25s var(--ease), box-shadow .25s var(--ease), transform .25s var(--ease);
}
.lec:hover { border-color: var(--border-strong); background: rgba(20, 30, 53, .6); }
.lec.is-hidden { opacity: .6; }
.lec.moved { border-color: rgba(251, 191, 36, .45); box-shadow: 0 0 0 1px rgba(251, 191, 36, .2); }
.lec-grip {
  width: 30px; height: 44px; display: grid; place-items: center; border-radius: 9px;
  color: var(--faint); cursor: grab; font-size: 1.15rem; touch-action: none;
}
.lec-grip:hover { color: var(--text); background: rgba(148, 163, 184, .08); }
.lec-grip:active { cursor: grabbing; }
.lec-num {
  width: 46px; height: 46px; display: grid; place-items: center; border-radius: 14px;
  font-weight: 700; font-size: 1.1rem; color: var(--accent);
  background: var(--accent-soft); border: 1px solid rgba(47, 224, 164, .2);
  transition: transform .3s var(--ease);
}
.lec.moved .lec-num { color: var(--warn); background: var(--warn-soft); border-color: rgba(251, 191, 36, .3); }
.lec-title { font-weight: 600; font-size: .98rem; line-height: 1.4; }
.lec-meta { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 7px; }
.lec-actions { display: flex; align-items: center; gap: 6px; }
.lec-move { display: flex; flex-direction: column; gap: 3px; }
.lec-move .btn { width: 30px; height: 22px; padding: 0; border-radius: 7px; font-size: .75rem; }
.sortable-ghost  { opacity: .35; }
.sortable-chosen { box-shadow: var(--glow); border-color: rgba(47, 224, 164, .55) !important; }
.sortable-drag   { transform: rotate(1deg); }

.save-bar {
  position: sticky; bottom: 18px; z-index: 50; margin-top: 16px;
  display: flex; align-items: center; justify-content: space-between; gap: 14px; flex-wrap: wrap;
  padding: 14px 18px; border-radius: 16px;
  background: rgba(20, 30, 53, .95); border: 1px solid rgba(251, 191, 36, .35);
  box-shadow: 0 18px 50px -12px rgba(0, 0, 0, .8); backdrop-filter: blur(14px);
  animation: rise .45s var(--ease-out);
}

/* ─── ملفات التاسك ────────────────────────────────────────────────────────── */

.file-item {
  display: flex; align-items: center; gap: 12px; padding: 12px 14px; border-radius: 12px;
  background: rgba(10, 16, 32, .5); border: 1px solid var(--border); margin-bottom: 8px;
  transition: border-color .25s var(--ease), transform .25s var(--ease);
}
.file-item:hover { border-color: var(--border-strong); transform: translateX(-3px); }
.file-item .f-ico { width: 36px; height: 36px; display: grid; place-items: center; border-radius: 10px;
                    background: var(--info-soft); color: var(--info); flex-shrink: 0; }
.file-item .f-name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: .9rem; }

.dropzone {
  position: relative; display: block; padding: 26px 18px; text-align: center; cursor: pointer;
  border: 1.5px dashed var(--border-strong); border-radius: 14px; background: rgba(5, 8, 15, .45);
  transition: border-color .25s var(--ease), background .25s var(--ease);
}
.dropzone:hover, .dropzone.over { border-color: rgba(47, 224, 164, .6); background: var(--accent-soft); }
.dropzone i { font-size: 1.8rem; color: var(--accent); display: block; margin-bottom: 6px; }
.dropzone input { position: absolute; inset: 0; opacity: 0; cursor: pointer; }
.dropzone .dz-files { margin-top: 8px; font-size: .8rem; color: var(--text); }

/* ─── الجوال ─────────────────────────────────────────────────────────────── */

.mobile-head, .bottom-nav { display: none; }

.mobile-head {
  position: fixed; top: 0; right: 0; left: 0; height: 58px; z-index: 200;
  align-items: center; justify-content: space-between; padding: 0 16px;
  background: rgba(8, 13, 25, .88); border-bottom: 1px solid var(--border); backdrop-filter: blur(16px);
}
.mobile-head .brand { padding: 0; margin: 0; border: 0; gap: 9px; }
.mobile-head .brand-mark { width: 32px; height: 32px; }

.bottom-nav {
  position: fixed; bottom: 10px; right: 10px; left: 10px; z-index: 200;
  justify-content: space-around; padding: 6px;
  background: rgba(12, 19, 35, .9); border: 1px solid var(--border-strong); border-radius: 20px;
  box-shadow: 0 18px 40px -12px rgba(0, 0, 0, .8); backdrop-filter: blur(18px);
}
.bottom-nav a {
  position: relative; flex: 1; display: flex; flex-direction: column; align-items: center; gap: 2px;
  padding: 7px 0; border-radius: 14px; color: var(--faint); font-size: .62rem; font-weight: 500;
  transition: color .25s var(--ease), background .25s var(--ease);
}
.bottom-nav a i { font-size: 1.25rem; transition: transform .3s var(--ease); }
.bottom-nav a.active { color: var(--accent); background: var(--accent-soft); }
.bottom-nav a.active i { transform: translateY(-2px); }
.bottom-nav a .count {
  position: absolute; top: 2px; left: calc(50% - 18px); min-width: 16px; height: 16px; padding: 0 4px;
  border-radius: 8px; background: var(--warn); color: #1a1300; font-size: .6rem; font-weight: 700;
  display: grid; place-items: center;
}

@media (max-width: 991.98px) {
  .sidebar { display: none; }
  .mobile-head, .bottom-nav { display: flex; }
  .main { margin-right: 0; padding: 78px 14px 104px; }
  .toasts { top: 70px; left: 50%; transform: translateX(-50%); }
  .page-title { font-size: 1.3rem; }
  .page-title .ico { width: 38px; height: 38px; font-size: 1.05rem; }
  .stat-value { font-size: 1.6rem; }
  .hero-figure { font-size: 2.8rem; }
  .panel-body { padding: 16px; }
  .table { font-size: .84rem; }
  .table td, .table thead th { padding: 11px 12px; white-space: nowrap; }
  .lec { grid-template-columns: auto 1fr; gap: 10px; }
  .lec-grip { display: none; }
  .lec-actions { grid-column: 1 / -1; justify-content: flex-end; border-top: 1px solid var(--border); padding-top: 10px; }
  .lec-move { flex-direction: row; margin-inline-end: auto; }
  .lec-move .btn { width: 36px; height: 30px; }
  .bar-row { grid-template-columns: 1fr; gap: 4px; }
}

/* ─── الحركة ─────────────────────────────────────────────────────────────── */

[data-reveal] {
  opacity: 0; transform: translateY(16px);
  transition: opacity .55s var(--ease-out), transform .55s var(--ease-out);
  transition-delay: var(--d, 0s);
}
[data-reveal].is-in { opacity: 1; transform: none; }

.table tbody tr.row-in { animation: row-in .55s var(--ease-out) both; animation-delay: var(--d, 0s); }

@keyframes drift-a { to { transform: translate(-80px, 60px) scale(1.12); } }
@keyframes drift-b { to { transform: translate(90px, -50px) scale(1.08); } }
@keyframes spin    { to { transform: rotate(360deg); } }
@keyframes grow-y  { from { transform: scaleY(0); } }
@keyframes rise    { from { opacity: 0; transform: translateY(20px); } }
@keyframes float   { 50% { transform: translateY(-6px); } }
@keyframes blink   { 50% { opacity: .35; } }
@keyframes row-in  { from { opacity: 0; transform: translateX(-10px); } }
@keyframes toast-in  { from { opacity: 0; transform: translateX(-30px) scale(.96); } }
@keyframes toast-out { to   { opacity: 0; transform: translateX(-30px) scale(.96); } }
@keyframes toast-bar { from { transform: scaleX(1); } to { transform: scaleX(0); } }
@keyframes copied {
  0%   { box-shadow: 0 0 0 0 rgba(47, 224, 164, .5); border-color: rgba(47, 224, 164, .8); }
  100% { box-shadow: 0 0 0 14px rgba(47, 224, 164, 0); }
}
@keyframes pulse-warn {
  0%, 100% { box-shadow: 0 0 0 0 rgba(251, 191, 36, .5); }
  50%      { box-shadow: 0 0 0 6px rgba(251, 191, 36, 0); }
}

/* من يطلب تقليل الحركة من نظامه يحصل على واجهة ثابتة تماماً */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: .01ms !important; animation-iteration-count: 1 !important;
    transition-duration: .01ms !important; scroll-behavior: auto !important;
  }
  [data-reveal] { opacity: 1; transform: none; }
}

/* ─── إضافات القالب الأساسي ─────────────────────────────────────────────── */

.js [data-flash] { display: none; }          /* السكربت يحوّلها لإشعارات؛ بدونه تبقى ظاهرة */

.confirm-ico {
  width: 58px; height: 58px; margin: 0 auto; display: grid; place-items: center;
  border-radius: 18px; font-size: 1.6rem; color: var(--warn);
  background: var(--warn-soft); border: 1px solid rgba(251, 191, 36, .25);
  animation: float 3s ease-in-out infinite;
}
.confirm-msg { font-size: .98rem; line-height: 1.8; }
.min-w-0 { min-width: 0; }
.callout > :not(.c-ico) { flex: 1 1 240px; min-width: 0; }

/* الجداول تنزلق أفقياً بدل أن تكسر الأسماء والمبالغ على سطرين */
.table td { white-space: nowrap; }
.trunc {
  display: inline-block; max-width: 230px; vertical-align: middle;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.trunc-sm { max-width: 150px; }
