/* ============================================================
   نظام إدارة الطلاب — نظام تصميم احترافي (Design System)
   Indigo / Slate / Teal · RTL · Light + Dark
   يُحمَّل بعد Bootstrap RTL ليتجاوز أنماطه الافتراضية.
   ============================================================ */

/* ----------------------------------------------------------------
   1) الرموز التصميمية (Design Tokens)
   ---------------------------------------------------------------- */
:root {
  /* الألوان الأساسية */
  --brand-50:  #eef2ff;
  --brand-100: #e0e7ff;
  --brand-200: #c7d2fe;
  --brand-400: #818cf8;
  --brand-500: #6366f1;
  --brand-600: #4f46e5;
  --brand-700: #4338ca;
  --brand-800: #3730a3;

  --accent-500: #14b8a6;  /* teal */
  --accent-600: #0d9488;

  /* دلالات */
  --success: #16a34a;  --success-bg: #dcfce7;
  --warning: #d97706;  --warning-bg: #fef3c7;
  --danger:  #dc2626;  --danger-bg:  #fee2e2;
  --info:    #0891b2;  --info-bg:    #cffafe;

  /* المحايدة (light) */
  --bg:         #f4f6fb;
  --surface:    #ffffff;
  --surface-2:  #f8fafc;
  --surface-3:  #f1f5f9;
  --border:     #e6e9f0;
  --border-2:   #eef1f6;
  --text:       #0f172a;
  --text-soft:  #334155;
  --text-muted: #64748b;
  --text-faint: #94a3b8;

  /* الشريط الجانبي */
  --sidebar-bg-1: #111827;
  --sidebar-bg-2: #1e293b;
  --sidebar-text: #cbd5e1;
  --sidebar-text-strong: #f8fafc;
  --sidebar-muted: #94a3b8;
  --sidebar-active-bg: rgba(99, 102, 241, 0.16);
  --sidebar-active-bar: var(--brand-500);
  --sidebar-hover-bg: rgba(255, 255, 255, 0.05);

  /* القياسات */
  --sidebar-w: 268px;
  --topbar-h: 66px;
  --radius:    16px;
  --radius-sm: 11px;
  --radius-xs: 8px;

  /* الظلال */
  --shadow-xs: 0 1px 2px rgba(15, 23, 42, 0.05);
  --shadow-sm: 0 1px 3px rgba(15, 23, 42, 0.06), 0 1px 2px rgba(15, 23, 42, 0.04);
  --shadow:    0 4px 12px rgba(15, 23, 42, 0.07), 0 2px 4px rgba(15, 23, 42, 0.04);
  --shadow-lg: 0 12px 32px rgba(15, 23, 42, 0.12), 0 4px 10px rgba(15, 23, 42, 0.05);
  --ring: 0 0 0 3px rgba(99, 102, 241, 0.28);

  --ease: cubic-bezier(0.4, 0, 0.2, 1);

  /* ربط متغيّرات Bootstrap بلوحتنا */
  --bs-primary: var(--brand-600);
  --bs-primary-rgb: 79, 70, 229;
  --bs-body-bg: var(--bg);
  --bs-body-color: var(--text);
  --bs-border-color: var(--border);
  --bs-link-color: var(--brand-600);
  --bs-link-hover-color: var(--brand-700);
  --bs-font-sans-serif: 'Tajawal', system-ui, sans-serif;
}

[data-bs-theme="dark"] {
  --bg:         #0b1120;
  --surface:    #131c2e;
  --surface-2:  #172136;
  --surface-3:  #1e293b;
  --border:     #263349;
  --border-2:   #1f2a3d;
  --text:       #e8edf6;
  --text-soft:  #cbd5e1;
  --text-muted: #94a3b8;
  --text-faint: #64748b;

  --sidebar-bg-1: #0a0f1c;
  --sidebar-bg-2: #111b2e;

  --shadow-xs: 0 1px 2px rgba(0, 0, 0, 0.3);
  --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.4);
  --shadow:    0 4px 14px rgba(0, 0, 0, 0.45);
  --shadow-lg: 0 14px 40px rgba(0, 0, 0, 0.55);

  --bs-body-bg: var(--bg);
  --bs-body-color: var(--text);
  --success-bg: rgba(22,163,74,.18);
  --warning-bg: rgba(217,119,6,.18);
  --danger-bg:  rgba(220,38,38,.18);
  --info-bg:    rgba(8,145,178,.18);
}

/* ----------------------------------------------------------------
   2) أساسيات
   ---------------------------------------------------------------- */
* { scrollbar-width: thin; scrollbar-color: var(--text-faint) transparent; }
*::-webkit-scrollbar { width: 9px; height: 9px; }
*::-webkit-scrollbar-thumb { background: color-mix(in srgb, var(--text-faint) 55%, transparent); border-radius: 20px; }
*::-webkit-scrollbar-thumb:hover { background: var(--text-faint); }

html { scroll-behavior: smooth; }

body {
  font-family: 'Tajawal', system-ui, sans-serif;
  background: var(--bg);
  color: var(--text);
  text-align: right;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  letter-spacing: -0.01em;
  transition: background-color .25s var(--ease), color .25s var(--ease);
}

h1,h2,h3,h4,h5,h6,
.h1,.h2,.h3,.h4,.h5 { font-family: 'Cairo', 'Tajawal', sans-serif; font-weight: 700; color: var(--text); letter-spacing: -0.02em; }

a { text-decoration: none; }
::selection { background: var(--brand-200); color: var(--brand-800); }

/* ----------------------------------------------------------------
   3) هيكل التطبيق: شريط جانبي + شريط علوي
   ---------------------------------------------------------------- */
.app-sidebar {
  position: fixed;
  top: 0; right: 0;
  width: var(--sidebar-w);
  height: 100vh;
  background: linear-gradient(185deg, var(--sidebar-bg-1), var(--sidebar-bg-2));
  color: var(--sidebar-text);
  display: flex;
  flex-direction: column;
  z-index: 1045;
  border-left: 1px solid rgba(255,255,255,0.06);
  transition: transform .3s var(--ease);
}

.sidebar-brand {
  display: flex; align-items: center; gap: .7rem;
  padding: 1.15rem 1.25rem;
  border-bottom: 1px solid rgba(255,255,255,0.07);
  min-height: var(--topbar-h);
}
.sidebar-brand img { height: 40px; width: 40px; object-fit: contain; border-radius: 9px; background: #fff; padding: 3px; }
.sidebar-brand .brand-name { color: var(--sidebar-text-strong); font-family:'Cairo',sans-serif; font-weight: 700; font-size: 1rem; line-height: 1.25; }
.sidebar-brand .brand-sub { color: var(--sidebar-muted); font-size: .72rem; font-weight: 500; }

.sidebar-nav {
  flex: 1; overflow-y: auto;
  padding: .85rem .75rem 1.5rem;
}
.sidebar-nav::-webkit-scrollbar-thumb { background: rgba(255,255,255,.14); }

.nav-section-title {
  color: var(--sidebar-muted);
  font-size: .7rem; font-weight: 700;
  letter-spacing: .06em;
  padding: 1rem .75rem .4rem;
  text-transform: uppercase;
}

.side-link {
  display: flex; align-items: center; gap: .75rem;
  padding: .62rem .8rem;
  margin: .12rem 0;
  border-radius: 11px;
  color: var(--sidebar-text);
  font-weight: 500; font-size: .93rem;
  position: relative;
  transition: background-color .18s var(--ease), color .18s var(--ease);
}
.side-link:hover { background: var(--sidebar-hover-bg); color: var(--sidebar-text-strong); }
.side-link svg { width: 20px; height: 20px; flex-shrink: 0; stroke-width: 2; opacity: .9; }
.side-link.active {
  background: var(--sidebar-active-bg);
  color: #fff;
  font-weight: 700;
}
.side-link.active::before {
  content: ""; position: absolute; right: -0.75rem; top: 50%; transform: translateY(-50%);
  width: 4px; height: 22px; border-radius: 4px; background: var(--sidebar-active-bar);
}
.side-link.active svg { opacity: 1; color: var(--brand-400); }

/* قائمة قابلة للطي داخل الشريط الجانبي */
.side-group > .side-link .chev { margin-inline-start: auto; transition: transform .2s var(--ease); width:16px;height:16px; }
.side-group.open > .side-link .chev { transform: rotate(-180deg); }
.side-sub { display: grid; grid-template-rows: 0fr; transition: grid-template-rows .25s var(--ease); }
.side-group.open .side-sub { grid-template-rows: 1fr; }
.side-sub > div { overflow: hidden; }
.side-sub .side-link {
  font-size: .875rem; padding: .5rem .8rem .5rem 2.6rem;
  color: var(--sidebar-muted);
}
.side-sub .side-link::after { content:""; position:absolute; right:1.4rem; top:50%; width:6px;height:6px;border-radius:50%; background: currentColor; opacity:.4; transform:translateY(-50%); }
.side-sub .side-link:hover, .side-sub .side-link.active { color: var(--sidebar-text-strong); background: var(--sidebar-hover-bg); }

.sidebar-foot { padding: .85rem; border-top: 1px solid rgba(255,255,255,.07); }
.sidebar-user {
  display:flex; align-items:center; gap:.65rem;
  padding:.5rem .6rem; border-radius: 12px;
}
.sidebar-user .avatar {
  width: 38px; height: 38px; border-radius: 50%;
  background: linear-gradient(135deg, var(--brand-500), var(--accent-600));
  color:#fff; display:grid; place-items:center; font-weight:700; font-family:'Cairo';
  flex-shrink: 0;
}
.sidebar-user .u-name { color: var(--sidebar-text-strong); font-weight:600; font-size:.9rem; }
.sidebar-user .u-role { color: var(--sidebar-muted); font-size:.72rem; }

/* المنطقة الرئيسية */
.app-main {
  margin-right: var(--sidebar-w);
  min-height: 100vh;
  display: flex; flex-direction: column;
  transition: margin .3s var(--ease);
}

.app-topbar {
  position: sticky; top: 0; z-index: 1030;
  height: var(--topbar-h);
  background: color-mix(in srgb, var(--surface) 88%, transparent);
  backdrop-filter: saturate(180%) blur(12px);
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center; gap: 1rem;
  padding: 0 1.5rem;
}
.topbar-title { font-family:'Cairo',sans-serif; font-weight:700; font-size:1.12rem; color: var(--text); }
.topbar-title small { display:block; font-family:'Tajawal'; font-weight:500; font-size:.75rem; color: var(--text-muted); letter-spacing:0; }

.icon-btn {
  width: 42px; height: 42px; border-radius: 12px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text-soft);
  display: grid; place-items: center;
  transition: all .18s var(--ease);
  cursor: pointer;
}
.icon-btn:hover { background: var(--surface-3); color: var(--brand-600); border-color: var(--brand-200); }
.icon-btn svg { width: 20px; height: 20px; }
.icon-btn.is-active { color: var(--warning); }

#sidebarToggle { display: none; }

.app-content { flex: 1; padding: 1.75rem; max-width: 1400px; width: 100%; margin: 0 auto; }

/* خلفية عند فتح الشريط على الجوال */
.sidebar-backdrop {
  position: fixed; inset: 0; background: rgba(15,23,42,.5);
  z-index: 1040; opacity: 0; visibility: hidden; transition: opacity .3s var(--ease);
  backdrop-filter: blur(2px);
}
.sidebar-backdrop.show { opacity: 1; visibility: visible; }

/* ----------------------------------------------------------------
   4) البطاقات (Cards)
   ---------------------------------------------------------------- */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  margin-bottom: 1.25rem;
  transition: box-shadow .2s var(--ease), border-color .2s var(--ease), transform .2s var(--ease);
}
.card.shadow-sm { box-shadow: var(--shadow-sm) !important; }
.card-header {
  background: transparent;
  border-bottom: 1px solid var(--border);
  padding: 1rem 1.35rem;
  font-family: 'Cairo', sans-serif;
  font-weight: 700; font-size: 1rem; color: var(--text);
}
.card-body { padding: 1.35rem; }
.card.border-primary,.card.border-info,.card.border-warning,.card.border-pink,.card.border-success { border-width: 1px !important; }

/* بطاقات الإحصاءات في لوحة التحكم */
.stat-card {
  position: relative; overflow: hidden;
  padding: 1.35rem 1.4rem;
  display: flex; align-items: center; gap: 1.1rem;
}
.stat-card .stat-ico {
  width: 54px; height: 54px; border-radius: 15px;
  display: grid; place-items: center; flex-shrink: 0;
}
.stat-card .stat-ico svg { width: 26px; height: 26px; }
.stat-card .stat-val { font-family:'Cairo',sans-serif; font-weight: 800; font-size: 1.9rem; line-height: 1; color: var(--text); }
.stat-card .stat-lbl { color: var(--text-muted); font-size: .85rem; font-weight: 500; margin-top: .3rem; }
.stat-card::after {
  content:""; position:absolute; inset-inline-start: -30px; top:-30px;
  width: 110px; height: 110px; border-radius: 50%;
  background: var(--_glow, var(--brand-100)); opacity: .35; z-index: 0;
}
.stat-card > * { position: relative; z-index: 1; }
.stat--brand  { --_glow: var(--brand-100); } .stat--brand  .stat-ico { background: var(--brand-50);  color: var(--brand-600); }
.stat--info   { --_glow: var(--info-bg);   } .stat--info   .stat-ico { background: var(--info-bg);   color: var(--info); }
.stat--pink   { --_glow: #fce7f3;          } .stat--pink   .stat-ico { background: #fce7f3;          color: #db2777; }
.stat--warn   { --_glow: var(--warning-bg);} .stat--warn   .stat-ico { background: var(--warning-bg);color: var(--warning); }
[data-bs-theme="dark"] .stat--brand .stat-ico { background: rgba(99,102,241,.18); color: var(--brand-400); }
[data-bs-theme="dark"] .stat--pink  .stat-ico { background: rgba(219,39,119,.18); color:#f472b6; }

/* ----------------------------------------------------------------
   5) الأزرار
   ---------------------------------------------------------------- */
.btn {
  --bs-btn-border-radius: var(--radius-xs);
  border-radius: var(--radius-xs);
  font-weight: 600;
  padding: .55rem 1.1rem;
  transition: all .18s var(--ease);
  border-width: 1px;
}
.btn:focus-visible { box-shadow: var(--ring); }
.btn-sm { padding: .35rem .7rem; border-radius: 7px; }
.btn-lg { padding: .7rem 1.4rem; }

.btn-primary {
  --bs-btn-bg: var(--brand-600); --bs-btn-border-color: var(--brand-600);
  --bs-btn-hover-bg: var(--brand-700); --bs-btn-hover-border-color: var(--brand-700);
  --bs-btn-active-bg: var(--brand-800);
  box-shadow: 0 2px 8px rgba(79,70,229,.28);
}
.btn-primary:hover { box-shadow: 0 4px 14px rgba(79,70,229,.36); transform: translateY(-1px); }
.btn-secondary {
  --bs-btn-bg: var(--surface); --bs-btn-color: var(--text-soft); --bs-btn-border-color: var(--border);
  --bs-btn-hover-bg: var(--surface-3); --bs-btn-hover-color: var(--text); --bs-btn-hover-border-color: var(--text-faint);
}
.btn-outline-primary {
  --bs-btn-color: var(--brand-600); --bs-btn-border-color: var(--brand-200);
  --bs-btn-hover-bg: var(--brand-600); --bs-btn-hover-border-color: var(--brand-600);
}
.btn-outline-secondary {
  --bs-btn-color: var(--text-soft); --bs-btn-border-color: var(--border);
  --bs-btn-hover-bg: var(--surface-3); --bs-btn-hover-color: var(--text); --bs-btn-hover-border-color: var(--text-faint);
}
.btn-light { --bs-btn-bg: var(--surface-3); --bs-btn-border-color: var(--border); --bs-btn-color: var(--text-soft); }
.btn-danger { box-shadow: 0 2px 8px rgba(220,38,38,.22); }
.btn-outline-danger { --bs-btn-color: var(--danger); --bs-btn-border-color: var(--danger-bg); }

/* ----------------------------------------------------------------
   6) النماذج
   ---------------------------------------------------------------- */
.form-control, .form-select {
  border-radius: var(--radius-xs);
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  padding: .6rem .85rem;
  transition: border-color .15s var(--ease), box-shadow .15s var(--ease);
  text-align: right;
}
.form-control::placeholder { color: var(--text-faint); }
.form-control:focus, .form-select:focus {
  border-color: var(--brand-500);
  box-shadow: var(--ring);
  background: var(--surface);
  color: var(--text);
}
.form-label { font-weight: 600; color: var(--text-soft); margin-bottom: .4rem; font-size: .9rem; }
.input-group-text { background: var(--surface-3); border-color: var(--border); color: var(--text-muted); border-radius: var(--radius-xs); }

/* ----------------------------------------------------------------
   7) الجداول
   ---------------------------------------------------------------- */
.table {
  --bs-table-bg: transparent;
  color: var(--text);
  margin-bottom: 0;
  border-color: var(--border);
  vertical-align: middle;
}
.table thead th {
  background: var(--surface-2);
  color: var(--text-muted);
  font-family: 'Cairo', sans-serif;
  font-weight: 700; font-size: .82rem;
  text-transform: none; letter-spacing: 0;
  border-bottom: 1px solid var(--border);
  padding: .85rem 1rem; white-space: nowrap;
}
.table tbody td { padding: .8rem 1rem; border-bottom: 1px solid var(--border-2); color: var(--text-soft); }
.table tbody tr { transition: background-color .13s var(--ease); }
.table-striped > tbody > tr:nth-of-type(odd) > * { --bs-table-accent-bg: var(--surface-2); background: var(--surface-2); }
.table-hover tbody tr:hover, .table tbody tr:hover { background: var(--brand-50); }
[data-bs-theme="dark"] .table tbody tr:hover { background: var(--surface-3); }
.table-bordered, .table-bordered td, .table-bordered th { border-color: var(--border); }
.table > :not(caption) > * > * { box-shadow: none; }
.table img, .table .img-thumbnail { border-radius: 9px; border: 1px solid var(--border); object-fit: cover; }
.table-responsive { border-radius: var(--radius); }

/* ----------------------------------------------------------------
   8) الشارات، التبويبات، القوائم المنسدلة، الأكورديون
   ---------------------------------------------------------------- */
.badge { font-weight: 600; padding: .38em .7em; border-radius: 7px; letter-spacing: 0; }

.nav-tabs {
  border-bottom: 1px solid var(--border); gap: .2rem;
  padding: 0 .4rem;
}
.nav-tabs .nav-link {
  border: none; border-radius: 0;
  color: var(--text-muted); font-weight: 600;
  padding: .85rem 1rem; position: relative;
  background: transparent;
}
.nav-tabs .nav-link:hover { color: var(--brand-600); background: transparent; border: none; }
.nav-tabs .nav-link.active {
  color: var(--brand-700); background: transparent; border: none;
}
.nav-tabs .nav-link.active::after {
  content:""; position:absolute; bottom:-1px; inset-inline:.6rem;
  height: 3px; border-radius: 3px 3px 0 0; background: var(--brand-600);
}

.dropdown-menu {
  border: 1px solid var(--border);
  border-radius: 14px;
  box-shadow: var(--shadow-lg);
  padding: .4rem;
  background: var(--surface);
}
.dropdown-item { border-radius: 9px; padding: .55rem .8rem; color: var(--text-soft); font-weight: 500; }
.dropdown-item:hover { background: var(--surface-3); color: var(--brand-700); }
.dropdown-header { color: var(--text-faint); font-weight: 700; font-size: .72rem; text-transform: uppercase; letter-spacing: .05em; }
.dropdown-divider { border-color: var(--border); }

.accordion {
  --bs-accordion-border-color: var(--border);
  --bs-accordion-bg: var(--surface);
  border-radius: var(--radius) !important; overflow: hidden;
  box-shadow: var(--shadow-sm);
}
.accordion-item { background: var(--surface); border-color: var(--border); }
.accordion-button {
  background: var(--surface); color: var(--text);
  font-family:'Cairo',sans-serif; font-weight: 700; font-size: .95rem;
  padding: .95rem 1.15rem;
}
.accordion-button:not(.collapsed) {
  color: #fff !important;
  background: linear-gradient(90deg, var(--brand-600), var(--brand-700)) !important;
  box-shadow: none;
}
.accordion-button::after { margin-left: 0; margin-right: auto; }
.accordion-button:not(.collapsed)::after { filter: brightness(0) invert(1); }
.accordion-button:focus { box-shadow: none; border-color: var(--border); }

/* قوائم الإجراءات داخل الأكورديون (صفحة الطالب) */
.action-list { list-style: none; padding: .4rem; margin: 0; }
.action-list li a {
  display: flex; align-items: center; gap: .6rem;
  padding: .6rem .8rem; color: var(--text-soft);
  border-radius: 10px; font-weight: 500; font-size: .9rem;
  transition: background-color .15s var(--ease), color .15s var(--ease);
}
.action-list li a:hover { background: var(--brand-50); color: var(--brand-700); }
[data-bs-theme="dark"] .action-list li a:hover { background: var(--surface-3); }
.action-list li a i { margin-left: 4px; width: 20px; text-align: center; }

/* ----------------------------------------------------------------
   9) التنبيهات، صفحة تفاصيل الطالب، مكوّنات متنوعة
   ---------------------------------------------------------------- */
.alert { border-radius: var(--radius-sm); border: 1px solid transparent; padding: .9rem 1.1rem; font-weight: 500; }
.alert-secondary { background: var(--surface-3); color: var(--text-muted); border-color: var(--border); }
.alert-danger { background: var(--danger-bg); color: var(--danger); border-color: transparent; }

.breadcrumb { margin-bottom: 0; font-size: .875rem; }
.breadcrumb-item a { color: var(--text-muted); }
.breadcrumb-item a:hover { color: var(--brand-600); }
.breadcrumb-item.active { color: var(--text-soft); font-weight: 600; }

.page-head { display:flex; align-items:center; justify-content:space-between; flex-wrap:wrap; gap:1rem; margin-bottom:1.4rem; }
.page-head h2, .page-head h1 { margin: 0; font-size: 1.5rem; }

/* بطاقة ملف الطالب */
.profile-card { text-align: center; }
.avatar-xl {
  width: 116px; height: 116px; border-radius: 50%;
  object-fit: cover; border: 4px solid var(--surface);
  box-shadow: 0 0 0 1px var(--border), var(--shadow); margin: 0 auto;
  display: block;
}
.p-name { font-size: 1.15rem; margin-top: .9rem; }
.ref-chip {
  display: inline-flex; align-items:center; gap:.35rem;
  background: var(--brand-50); color: var(--brand-700);
  font-family:'Cairo'; font-weight:700; font-size:.8rem;
  padding: .3rem .7rem; border-radius: 8px; margin-top:.6rem;
}
[data-bs-theme="dark"] .ref-chip { background: rgba(99,102,241,.16); color: var(--brand-400); }
.nat-line { display:inline-flex; align-items:center; gap:.4rem; color: var(--text-muted); font-size:.9rem; }
.nat-line img { border-radius: 3px; box-shadow: var(--shadow-xs); }

/* صفوف تفاصيل (label/value) */
.detail-card .row { padding: .65rem .2rem; border-bottom: 1px solid var(--border-2); margin: 0; align-items:center; }
.detail-card .row:last-child { border-bottom: none; }
.detail-label { font-weight: 600; color: var(--text-muted); font-size: .88rem; }
.detail-value { color: var(--text); font-weight: 500; }
.detail-card .card-header { background: var(--surface-2); font-size: .92rem; }

/* سطر إجراءات لاصق */
.action-bar {
  position: sticky; top: calc(var(--topbar-h) + 8px); z-index: 20;
  background: var(--surface); padding: .7rem .9rem;
  border: 1px solid var(--border); border-radius: var(--radius-sm);
  box-shadow: var(--shadow-sm); display: flex; flex-wrap: wrap; gap: .5rem; align-items: center;
}

/* الترقيم */
.pagination { --bs-pagination-color: var(--text-soft); gap: .3rem; }
.page-link {
  border: 1px solid var(--border); border-radius: 10px !important;
  color: var(--text-soft); background: var(--surface); padding: .45rem .8rem; font-weight:600;
}
.page-link:hover { background: var(--surface-3); color: var(--brand-700); border-color: var(--brand-200); }
.page-item.active .page-link { background: var(--brand-600); border-color: var(--brand-600); color:#fff; box-shadow: 0 2px 8px rgba(79,70,229,.3); }

/* حالة فارغة */
.empty-state { text-align:center; padding: 3rem 1rem; color: var(--text-muted); }
.empty-state svg { width: 54px; height: 54px; color: var(--text-faint); margin-bottom: 1rem; }

/* شبكة بيانات مضغوطة بديلة للجداول الطويلة */
.chart-wrap { position: relative; height: 320px; }

/* بطاقة الترحيب في لوحة التحكم */
.welcome-card {
  background: linear-gradient(110deg, var(--brand-600), var(--brand-800) 70%, var(--accent-600));
  border: none; color: #fff; overflow: hidden; position: relative;
}
.welcome-card::after {
  content:""; position:absolute; inset-inline-start:-40px; top:-60px;
  width: 220px; height: 220px; border-radius:50%;
  background: rgba(255,255,255,.08);
}
.welcome-card .card-body { position: relative; z-index: 1; }
.welcome-card h2 { color:#fff; }
.welcome-card .text-muted { color: rgba(255,255,255,.8) !important; }
.welcome-logo { height: 62px; width: 62px; object-fit: contain; background:#fff; border-radius: 14px; padding: 6px; box-shadow: var(--shadow); }

/* معاينة الشعار في الإعدادات */
.logo-preview { height: 84px; width: 84px; object-fit: contain; border-radius: 14px; border: 1px solid var(--border); background: var(--surface-2); padding: 8px; flex-shrink: 0; }
.logo-preview--empty { display: grid; place-items: center; color: var(--text-faint); font-size: .72rem; text-align: center; }

/* ----------------------------------------------------------------
   10) الاستجابة (Responsive)
   ---------------------------------------------------------------- */
@media (max-width: 991.98px) {
  .app-sidebar { transform: translateX(100%); box-shadow: var(--shadow-lg); }
  .app-sidebar.show { transform: translateX(0); }
  .app-main { margin-right: 0; }
  #sidebarToggle { display: grid; }
  .app-content { padding: 1.1rem; }
}
@media (max-width: 575.98px) {
  .app-topbar { padding: 0 1rem; }
  .topbar-title { font-size: 1rem; }
  .stat-card { padding: 1.1rem; }
}

/* حركة دخول ناعمة للبطاقات */
@keyframes riseIn { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }
.app-content > * { animation: riseIn .4s var(--ease) both; }
@media (prefers-reduced-motion: reduce) { .app-content > * { animation: none; } * { scroll-behavior: auto; } }

/* ----------------------------------------------------------------
   صفحة تسجيل الدخول
   ---------------------------------------------------------------- */
.auth-body {
  min-height: 100vh; margin: 0;
  background:
    radial-gradient(1000px 500px at 90% -10%, rgba(99,102,241,.16), transparent 60%),
    radial-gradient(900px 500px at 0% 110%, rgba(13,148,136,.14), transparent 55%),
    var(--bg);
  display: grid; place-items: center; padding: 1.5rem;
}
.auth-wrap { width: 100%; max-width: 940px; }
.auth-card {
  display: grid; grid-template-columns: 1.05fr 1fr;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 24px; overflow: hidden; box-shadow: var(--shadow-lg);
}
.auth-brand {
  background: linear-gradient(150deg, var(--brand-700), var(--brand-800) 55%, #0f172a);
  color: #fff; position: relative; overflow: hidden;
}
.auth-brand::before {
  content:""; position:absolute; width:280px;height:280px;border-radius:50%;
  background: rgba(255,255,255,.07); top:-90px; inset-inline-start:-70px;
}
.auth-brand::after {
  content:""; position:absolute; width:200px;height:200px;border-radius:50%;
  background: rgba(20,184,166,.18); bottom:-70px; inset-inline-end:-50px;
}
.auth-brand-inner { position: relative; z-index:1; padding: 2.6rem 2.4rem; height:100%; display:flex; flex-direction:column; }
.auth-logo img { height: 60px; width:60px; object-fit:contain; background:#fff; border-radius:16px; padding:8px; box-shadow: var(--shadow); }
.auth-brand h1 { color:#fff; font-size: 1.5rem; margin-top: 1.3rem; line-height:1.3; }
.auth-brand p { color: rgba(255,255,255,.82); margin-top:.6rem; font-size:.95rem; }
.auth-features { list-style:none; padding:0; margin: 1.6rem 0 0; }
.auth-features li { display:flex; align-items:center; gap:.6rem; color: rgba(255,255,255,.9); padding:.4rem 0; font-size:.9rem; font-weight:500; }
.auth-features .dot { width:8px;height:8px;border-radius:50%; background: var(--accent-500); box-shadow:0 0 0 4px rgba(20,184,166,.2); flex-shrink:0; }

.auth-form { display:grid; place-items:center; padding: 2.6rem 2.4rem; }
.auth-form-inner { width:100%; max-width: 340px; }
.auth-form h2 { font-size: 1.6rem; }
.auth-copy { text-align:center; color: var(--text-muted); font-size:.82rem; margin-top:1.2rem; }

@media (max-width: 767.98px) {
  .auth-card { grid-template-columns: 1fr; }
  .auth-brand { display: none; }
}

/* أيقونات زر الوضع الليلي (شمس/قمر) عبر CSS */
.theme-sun { display: none; }
[data-bs-theme="dark"] .theme-sun { display: block; }
[data-bs-theme="dark"] .theme-moon { display: none; }

/* ----------------------------------------------------------------
   صفحات الأخطاء (403 / 404)
   ---------------------------------------------------------------- */
.error-page { display: flex; justify-content: center; padding: 1.5rem 0 2.5rem; }
.error-card {
  max-width: 620px; width: 100%; text-align: center;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); box-shadow: var(--shadow-sm);
  padding: 2.6rem 2.2rem;
}
.error-icon {
  width: 78px; height: 78px; border-radius: 50%; margin: 0 auto 1.2rem;
  display: grid; place-items: center;
}
.error-icon svg { width: 36px; height: 36px; }
.error-icon--warn { background: var(--warning-bg); color: var(--warning); }
.error-icon--info { background: var(--info-bg); color: var(--info); }
.error-code {
  font-family: 'Cairo', sans-serif; font-weight: 800; font-size: 3rem;
  color: var(--brand-600); line-height: 1;
}
.error-title { font-size: 1.4rem; margin: .5rem 0 .35rem; }
.error-lead { color: var(--text-muted); margin-bottom: 1.4rem; }
.error-hints {
  text-align: right; display: inline-block; color: var(--text-soft);
  margin: 0 auto 1.6rem; font-size: .9rem; line-height: 2;
}
.error-actions { display: flex; gap: .6rem; justify-content: center; flex-wrap: wrap; margin-bottom: .5rem; }
.error-meta { text-align: right; color: var(--text-muted); font-size: .82rem; line-height: 1.9; }
.error-meta code { background: var(--surface-3); padding: .1rem .4rem; border-radius: 5px; }

/* ----------------------------------------------------------------
   شرائح الاختيار المتعدد (Chips) — بديل أفقي عصري لقوائم Checkbox الطويلة
   ---------------------------------------------------------------- */
.service-chips,
.service-chips > div {
  display: flex;
  flex-wrap: wrap;
  gap: .55rem;
  margin: 0;
}
.service-chips label {
  display: inline-flex;
  align-items: center;
  gap: .45rem;
  padding: .5rem 1rem;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--surface);
  color: var(--text-soft);
  font-size: .85rem;
  font-weight: 600;
  cursor: pointer;
  user-select: none;
  transition: background-color .15s var(--ease), border-color .15s var(--ease),
              color .15s var(--ease), box-shadow .15s var(--ease);
}
.service-chips label:hover {
  border-color: var(--brand-400);
  background: var(--brand-50);
}
[data-bs-theme="dark"] .service-chips label:hover { background: var(--surface-3); }
.service-chips input[type="checkbox"] {
  /* نُبقيه فعّالاً وقابلاً للنقر (داخل label) لكن نُخفي مربّعه الافتراضي */
  position: absolute;
  width: 1px; height: 1px;
  opacity: 0;
  margin: 0;
}
.service-chips label:has(input:checked) {
  background: var(--brand-600);
  border-color: var(--brand-600);
  color: #fff;
  box-shadow: 0 2px 8px rgba(79, 70, 229, .28);
}
.service-chips label:has(input:focus-visible) {
  box-shadow: var(--ring);
}

/* ----------------------------------------------------------------
   نموذج الطالب: شبكة حقول، شارات تبويبات، بطاقة حيّة، قائمة جاهزية
   ---------------------------------------------------------------- */

/* شبكة الحقول — عمودان/ثلاثة بدل عمود واحد، وتنهار تلقائياً على الجوال */
.field-grid {
  display: grid;
  gap: .35rem 1rem;
  grid-template-columns: repeat(auto-fit, minmax(215px, 1fr));
}
.field-grid.wide { grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); }
/* crispy يضيف mb-3 لكل حقل؛ نُلغيه لأن التباعد صار مسؤولية الشبكة */
.field-grid > * { margin-bottom: .6rem !important; min-width: 0; }
.field-grid textarea { min-height: 90px; }

/* عنوان قسم داخل التبويب */
.form-sec {
  display: flex; align-items: center; gap: .6rem;
  margin: 1.4rem 0 .75rem;
  font-family: 'Cairo', sans-serif;
  font-size: .76rem; font-weight: 700; letter-spacing: .06em;
  color: var(--text-faint);
}
.form-sec::after { content: ""; flex: 1; height: 1px; background: var(--border); }
.tab-pane > .form-sec:first-child { margin-top: 0; }

/* شريط أزرار أسفل كل تبويب */
.tab-foot {
  display: flex; gap: .6rem; flex-wrap: wrap; align-items: center;
  margin-top: 1.5rem; padding-top: 1.1rem;
  border-top: 1px solid var(--border);
}
.btn-next {
  margin-inline-start: auto;
  background: transparent; color: var(--brand-600);
  border: 1px solid var(--brand-200); font-weight: 600;
}
.btn-next:hover { background: var(--brand-50); color: var(--brand-700); }

/* شارات اكتمال على التبويبات */
.nav-tabs .nav-link { display: inline-flex; align-items: center; gap: .45rem; }
.tab-badge {
  font-size: .68rem; font-weight: 700; font-variant-numeric: tabular-nums;
  padding: .08rem .4rem; border-radius: 999px; line-height: 1.5;
  background: var(--surface-3); color: var(--text-faint);
  border: 1px solid var(--border);
}
.tab-badge:empty { display: none; }
.tab-badge.is-part { background: var(--warning-bg); color: var(--warning); border-color: transparent; }
.tab-badge.is-done { background: var(--success-bg); color: var(--success); border-color: transparent; }
.nav-tabs .nav-link.has-error { color: var(--danger); }
.nav-tabs .nav-link.has-error .tab-badge { background: var(--danger-bg); color: var(--danger); border-color: transparent; }

/* مفتاح تبديل (قسم المرافق) */
.toggle-row {
  display: flex; align-items: center; gap: .85rem;
  padding: .85rem 1rem;
  background: var(--surface-2); border: 1px solid var(--border);
  border-radius: var(--radius-sm);
}
.switch { position: relative; display: inline-block; width: 44px; height: 25px; flex-shrink: 0; }
.switch input { opacity: 0; width: 0; height: 0; }
.switch-slider {
  position: absolute; inset: 0; cursor: pointer;
  background: var(--text-faint); border-radius: 999px;
  transition: background-color .2s var(--ease);
}
.switch-slider::before {
  content: ""; position: absolute; height: 19px; width: 19px; right: 3px; top: 3px;
  background: #fff; border-radius: 50%; transition: transform .2s var(--ease);
}
.switch input:checked + .switch-slider { background: var(--brand-600); }
.switch input:checked + .switch-slider::before { transform: translateX(-19px); }
.switch input:focus-visible + .switch-slider { box-shadow: var(--ring); }
.toggle-label { font-weight: 600; font-size: .92rem; color: var(--text); }
.toggle-label small { display: block; color: var(--text-muted); font-weight: 500; font-size: .78rem; }

/* صف مستند */
.document-row {
  border: 1px solid var(--border); border-radius: var(--radius-sm);
  padding: 1rem 1.1rem .4rem; margin-bottom: 1rem; background: var(--surface-2);
}

/* ---------- بطاقة الطالب الحيّة ---------- */
.sc-head { padding: 1.4rem 1.15rem 1.2rem; text-align: center; border-bottom: 1px solid var(--border); }
.sc-avatar {
  width: 82px; height: 82px; border-radius: 50%; margin: 0 auto .8rem;
  display: grid; place-items: center;
  font-family: 'Cairo', sans-serif; font-size: 1.9rem; font-weight: 700; color: #fff;
  background: linear-gradient(135deg, var(--brand-500), var(--accent-600));
  background-size: cover; background-position: center;
  box-shadow: 0 0 0 4px var(--surface), 0 0 0 5px var(--border);
}
.sc-avatar.has-photo { color: transparent; }
.sc-name { font-family: 'Cairo', sans-serif; font-size: 1.05rem; font-weight: 700; line-height: 1.4; word-break: break-word; }
.sc-name-en {
  font-size: .78rem; color: var(--text-muted); direction: ltr;
  letter-spacing: .04em; margin-top: .15rem; min-height: 1.1em;
}
.sc-nat { display: inline-flex; align-items: center; gap: .4rem; margin-top: .55rem; color: var(--text-muted); font-size: .85rem; }
.sc-iso {
  font-size: .66rem; font-weight: 700; letter-spacing: .06em; direction: ltr;
  background: var(--surface-3); border: 1px solid var(--border);
  padding: .08rem .35rem; border-radius: 5px; color: var(--text-soft);
}
.sc-chips { display: flex; flex-wrap: wrap; gap: .35rem; justify-content: center; margin-top: .8rem; }
.sc-chip {
  font-size: .73rem; font-weight: 600; padding: .2rem .62rem; border-radius: 999px;
  background: var(--brand-50); color: var(--brand-700);
}
[data-bs-theme="dark"] .sc-chip { background: rgba(99,102,241,.16); color: var(--brand-400); }

.sc-alerts { display: flex; flex-direction: column; gap: .45rem; }
.sc-alerts:not(:empty) { padding: .8rem 1.15rem; border-bottom: 1px solid var(--border); }
.sc-alert {
  display: flex; align-items: flex-start; gap: .5rem;
  font-size: .79rem; font-weight: 600; line-height: 1.5;
  padding: .5rem .65rem; border-radius: var(--radius-xs);
}
.sc-alert svg { width: 13px; height: 13px; flex-shrink: 0; margin-top: .15rem; }
.sc-alert.is-warn { background: var(--warning-bg); color: var(--warning); }
.sc-alert.is-danger { background: var(--danger-bg); color: var(--danger); }

/* قائمة "جاهز للحفظ" */
.sc-ready { padding: 1rem 1.15rem 1.2rem; }
.sc-ready-top { display: flex; align-items: baseline; justify-content: space-between; margin-bottom: .7rem; }
.sc-ready-top .t { font-family: 'Cairo', sans-serif; font-size: .88rem; font-weight: 700; }
.sc-ready-top .n { font-size: .78rem; color: var(--text-muted); font-weight: 600; font-variant-numeric: tabular-nums; }
.ready-bar { height: 5px; border-radius: 999px; background: var(--surface-3); overflow: hidden; margin-bottom: .85rem; }
.ready-bar > i {
  display: block; height: 100%; width: 0; border-radius: 999px;
  background: var(--brand-600); transition: width .3s var(--ease), background-color .3s var(--ease);
}
.ready-bar.is-full > i { background: var(--success); }
.ready-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: .1rem; }
.ready-list button {
  width: 100%; display: flex; align-items: center; gap: .55rem;
  border: 0; background: transparent; font: inherit; font-size: .85rem; font-weight: 500;
  color: var(--text-muted); padding: .35rem .4rem; border-radius: var(--radius-xs);
  cursor: pointer; text-align: right;
  transition: background-color .15s var(--ease), color .15s var(--ease);
}
.ready-list button:hover { background: var(--surface-3); color: var(--text); }
.ready-list button:focus-visible { outline: none; box-shadow: var(--ring); }
.ready-list li.is-ok button { color: var(--text-soft); cursor: default; }
.ready-list li.is-ok button:hover { background: transparent; }
.ready-box {
  width: 17px; height: 17px; border-radius: 5px; flex-shrink: 0;
  border: 1.5px solid var(--border); display: grid; place-items: center;
  transition: background-color .18s var(--ease), border-color .18s var(--ease);
}
.ready-box svg { display: none; width: 10px; height: 10px; }
.ready-list li.is-ok .ready-box { background: var(--success); border-color: var(--success); }
.ready-list li.is-ok .ready-box svg { display: block; }
.ready-state {
  margin-top: .9rem; padding: .6rem; border-radius: var(--radius-xs); text-align: center;
  font-size: .83rem; font-weight: 700;
  background: var(--surface-3); color: var(--text-faint);
}
.ready-state.is-go { background: var(--success-bg); color: var(--success); }

/* ---------- الإضافة السريعة ---------- */
.quick-wrap { max-width: 680px; margin: 0 auto; }
.quick-head { padding: 1.6rem 1.4rem .4rem; text-align: center; }
.quick-head h2 { font-size: 1.2rem; margin-bottom: .3rem; }
.quick-note {
  margin-top: 1.1rem; padding: .9rem 1rem; border-radius: var(--radius-sm);
  background: var(--brand-50); border: 1px solid var(--brand-100);
  font-size: .85rem; color: var(--brand-700); line-height: 1.7;
}
[data-bs-theme="dark"] .quick-note { background: rgba(99,102,241,.12); border-color: transparent; color: var(--brand-400); }
.quick-foot {
  display: flex; gap: .6rem; flex-wrap: wrap;
  padding: 1rem 1.35rem; border-top: 1px solid var(--border); background: var(--surface-2);
}

/* أدوات مساعدة */
.text-muted { color: var(--text-muted) !important; }
.text-primary { color: var(--brand-600) !important; }
.fw-cairo { font-family: 'Cairo', sans-serif; }
.soft-divider { height:1px; background: var(--border); border:0; margin: 1.25rem 0; }

/* ----------------------------------------------------------------
   لوحة التحكم — بطاقات الحالة، الخريطة التفاعلية، الودجات الجديدة
   ---------------------------------------------------------------- */
.group-label { font-size:.78rem; font-weight:700; color:var(--text-muted); margin:0 0 .6rem .1rem; }

.stat-top { display:flex; align-items:baseline; gap:.5rem; flex-wrap:wrap; }
.stat-chip { font-size:.68rem; font-weight:700; border-radius:99px; padding:.1rem .5rem; white-space:nowrap; }
.chip-danger { background:var(--danger-bg); color:var(--danger); }
.chip-warn   { background:var(--warning-bg); color:var(--warning); }
.chip-success{ background:var(--success-bg); color:var(--success); }
.stat--danger { --_glow: var(--danger-bg); } .stat--danger .stat-ico { background:var(--danger-bg); color:var(--danger); }
.stat--teal   { --_glow: rgba(20,184,166,.18); } .stat--teal .stat-ico { background:rgba(20,184,166,.14); color:var(--accent-600); }
a.stat-card { text-decoration:none; color:inherit; }
a.stat-card:hover { box-shadow:var(--shadow); transform:translateY(-2px); }

.pill-select {
  background:var(--surface); border:1px solid var(--border); border-radius:99px;
  padding:.4rem 1rem; font-size:.8rem; font-weight:600; color:var(--text-soft);
}

/* بطاقة الخريطة التفاعلية */
.map-card { padding:0; }
.map-body { display:grid; grid-template-columns:230px 1fr; gap:0; }
@media (max-width:760px) { .map-body { grid-template-columns:1fr; } }
.map-rank { padding:1.1rem 1.2rem; border-inline-end:1px solid var(--border); }
.map-total { font-family:'Cairo',sans-serif; font-weight:800; font-size:2.1rem; line-height:1; }
.map-total-lbl { color:var(--text-muted); font-size:.8rem; margin-top:.35rem; margin-bottom:1rem; }
.rank-row { display:flex; align-items:center; gap:.5rem; padding:.4rem 0; font-size:.86rem; }
.rank-row img { width:18px; flex-shrink:0; }
.rank-name { flex:1; color:var(--text-soft); font-weight:500; white-space:nowrap; overflow:hidden; text-overflow:ellipsis; }
.rank-count { font-weight:700; font-family:'Cairo',sans-serif; color:var(--text); }
.map-canvas-wrap { position:relative; padding:.5rem .8rem .8rem; }
#worldmap { width:100%; height:auto; display:block; }
#worldmap path { stroke:var(--surface); stroke-width:.6; cursor:default; transition:fill .15s var(--ease); }
#worldmap path.has-data { cursor:pointer; }
#worldmap path.has-data:hover { filter:brightness(1.08); }
.map-tooltip {
  position:absolute; pointer-events:none; z-index:5; opacity:0; transition:opacity .1s;
  background:var(--text); color:var(--surface); font-size:.78rem; font-weight:600;
  padding:.4rem .65rem; border-radius:var(--radius-xs); box-shadow:var(--shadow); white-space:nowrap;
}
[data-bs-theme="dark"] .map-tooltip { background:var(--surface-3); color:var(--text); }
.map-legend { display:flex; align-items:center; gap:.4rem; padding:0 1.2rem 1rem; font-size:.72rem; color:var(--text-muted); }
.map-legend .sw { width:14px; height:9px; border-radius:2px; }

/* بطاقة الجنس */
.gender-body { padding:1.1rem 1.3rem; display:flex; flex-direction:column; align-items:center; gap:.9rem; }
.donut-wrap { position:relative; width:160px; height:160px; flex-shrink:0; overflow:hidden; }
.donut-center { position:absolute; inset:0; display:flex; flex-direction:column; align-items:center; justify-content:center; }
.donut-center .n { font-family:'Cairo',sans-serif; font-weight:800; font-size:1.5rem; }
.donut-center .l { font-size:.72rem; color:var(--text-muted); }
.gender-legend { display:flex; gap:1.4rem; }
.gender-legend .item { display:flex; align-items:center; gap:.4rem; font-size:.82rem; color:var(--text-soft); font-weight:600; }
.gender-legend .dot { width:9px; height:9px; border-radius:50%; }

/* ودجت أحدث الخطابات */
.letter-row { display:flex; align-items:center; gap:.7rem; padding:.75rem 1.3rem; border-bottom:1px solid var(--border-2); font-size:.85rem; }
.letter-row:last-child { border-bottom:none; }
.letter-code {
  font-family:'Cairo',sans-serif; font-weight:700; font-size:.7rem; color:var(--brand-600);
  background:var(--brand-50); border-radius:6px; padding:.15rem .45rem; flex-shrink:0;
}
[data-bs-theme="dark"] .letter-code { background:rgba(99,102,241,.16); color:var(--brand-400); }
.letter-info { flex:1; min-width:0; }
.letter-type { font-weight:600; color:var(--text-soft); white-space:nowrap; overflow:hidden; text-overflow:ellipsis; }
.letter-meta { font-size:.74rem; color:var(--text-faint); margin-top:.1rem; }
.letter-ref { font-size:.72rem; color:var(--text-muted); font-family:'Cairo',sans-serif; font-weight:700; flex-shrink:0; }

.link-more { font-size:.8rem; font-weight:700; color:var(--brand-600); text-decoration:none; display:flex; align-items:center; gap:.25rem; }
.link-more:hover { color:var(--brand-700); }

.mini-avatar {
  width:34px; height:34px; border-radius:50%; background:var(--brand-50); color:var(--brand-600);
  display:flex; align-items:center; justify-content:center; font-weight:700; font-size:.78rem; font-family:'Cairo',sans-serif;
}
[data-bs-theme="dark"] .mini-avatar { background:rgba(99,102,241,.16); color:var(--brand-400); }

/* صف زر "تجديد الجواز" داخل تبويب الجواز */
.renew-row {
  display:flex; align-items:center; gap:.7rem; flex-wrap:wrap;
  margin:.2rem 0 .4rem; padding:.7rem .9rem;
  background:var(--surface-2); border:1px dashed var(--border); border-radius:var(--radius-sm);
}
.renew-row small { font-size:.78rem; }

/* ----------------------------------------------------------------
   قوائم اختيار الدولة القابلة للبحث (Select2) — مواءمة مع نظام التصميم
   ---------------------------------------------------------------- */
.select2-container { width: 100% !important; }

/* الحقل المغلق: يطابق شكل .form-control تماماً */
.select2-container--default .select2-selection--single {
  height: auto;
  min-height: calc(1.5em + 1.1rem + 2px);
  padding: .55rem .85rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-xs);
  transition: border-color .15s var(--ease), box-shadow .15s var(--ease);
}
.select2-container--default .select2-selection--single .select2-selection__rendered {
  color: var(--text);
  line-height: 1.5;
  padding: 0;
  padding-inline-end: 1.2rem;
}
.select2-container--default .select2-selection--single .select2-selection__placeholder { color: var(--text-faint); }
.select2-container--default .select2-selection--single .select2-selection__arrow {
  height: 100%; top: 0; inset-inline-start: 8px; inset-inline-end: auto;
}
.select2-container--default.select2-container--focus .select2-selection--single,
.select2-container--default.select2-container--open .select2-selection--single {
  border-color: var(--brand-500);
  box-shadow: var(--ring);
}

/* زر المسح (×) */
.select2-container--default .select2-selection__clear {
  color: var(--text-faint); font-weight: 700; margin-inline-start: .4rem;
}
.select2-container--default .select2-selection__clear:hover { color: var(--danger); }

/* القائمة المنسدلة */
.select2-container--default .select2-dropdown {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow-lg);
  overflow: hidden;
}
.select2-container--default .select2-search--dropdown { padding: .6rem; background: var(--surface-2); }
.select2-container--default .select2-search--dropdown .select2-search__field {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-xs);
  color: var(--text);
  padding: .5rem .7rem;
  font-family: 'Tajawal', sans-serif;
}
.select2-container--default .select2-search--dropdown .select2-search__field:focus {
  outline: none; border-color: var(--brand-500); box-shadow: var(--ring);
}
.select2-container--default .select2-results > .select2-results__options { max-height: 260px; }
.select2-container--default .select2-results__option {
  padding: .5rem .85rem; color: var(--text-soft); font-size: .9rem;
}
.select2-container--default .select2-results__option--highlighted[aria-selected],
.select2-container--default .select2-results__option--highlighted {
  background: var(--brand-50); color: var(--brand-700);
}
.select2-container--default .select2-results__option[aria-selected="true"] {
  background: var(--surface-3); color: var(--text); font-weight: 600;
}
.select2-container--default .select2-results__message { color: var(--text-muted); font-size: .85rem; }

[data-bs-theme="dark"] .select2-container--default .select2-results__option--highlighted[aria-selected],
[data-bs-theme="dark"] .select2-container--default .select2-results__option--highlighted {
  background: rgba(99,102,241,.18); color: var(--brand-400);
}

/* حالة الخطأ من crispy/Bootstrap */
.is-invalid + .select2-container--default .select2-selection--single { border-color: var(--danger); }
