/* ============================================================
   Eye Clinic SaaS — app.css
   نظام تصميم موحّد (design tokens) + مكوّنات مشتركة + قواعد الاستجابة
   للموبايل (375px). راجع feedback_responsive_screens في ذاكرة المشروع:
   toolbar / table-wrap / modal / form-row / hide-mobile / ارتفاع موحَّد
   لحقول الإدخال — كل صفحة جديدة يجب أن تطبّق هذه الكلاسات دون استثناء.
   ============================================================ */

:root {
  --brand: #1D4ED8;
  --brand-dark: #1E3A8A;
  --brand-light: #EFF6FF;
  --success: #22C55E;
  --danger: #EF4444;
  --warning: #F59E0B;
  --info: #3B82F6;

  --bg: #F1F5F9;
  --bg-card: #FFFFFF;
  --text: #0F172A;
  --text-muted: #64748B;
  --border: #E2E8F0;

  --radius: 14px;
  --radius-sm: 10px;
  --shadow-sm: 0 1px 3px rgba(15, 23, 42, .06);
  --shadow-md: 0 8px 24px rgba(15, 23, 42, .12);

  /* ── ارتفاع/محاذاة موحَّدة لكل حقول الإدخال (قاعدة #7 من feedback_responsive_screens) ── */
  --f-height: 42px;
  --f-font: 14.5px;
  --f-pad-x: 12px;
  --f-radius: 10px;
  --f-gap: 14px;
}

:root[data-theme="dark"] {
  --bg: #0B1220;
  --bg-card: #131B2C;
  --text: #E5E9F2;
  --text-muted: #93A0B8;
  --border: #223049;
  --brand-light: #1E293B;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0B1220;
    --bg-card: #131B2C;
    --text: #E5E9F2;
    --text-muted: #93A0B8;
    --border: #223049;
    --brand-light: #1E293B;
  }
}

* { box-sizing: border-box; }
html, body {
  margin: 0; padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Tahoma, Arial, sans-serif;
  font-size: 14px;
}
a { color: var(--brand); text-decoration: none; }
.text-muted { color: var(--text-muted); }

/* ══════════════════════════════════════════════════════════
   Layout — Sidebar + Topbar + Content
   ══════════════════════════════════════════════════════════ */
.app-shell { display: flex; min-height: 100vh; }

.app-sidebar {
  width: 250px; flex-shrink: 0;
  background: linear-gradient(180deg, #1E3A8A 0%, #0F172A 100%);
  color: #E5E7FF;
  position: fixed; inset-inline-start: 0; top: 0; bottom: 0;
  overflow-y: auto;
  transition: transform .25s ease;
  z-index: 1030;
}
[dir="rtl"] .app-sidebar { border-left: 1px solid rgba(255,255,255,.06); }
[dir="ltr"] .app-sidebar { border-right: 1px solid rgba(255,255,255,.06); }

.app-main { flex: 1; min-width: 0; margin-inline-start: 250px; display: flex; flex-direction: column; }

.sidebar-brand {
  display: flex; align-items: center; gap: 10px;
  padding: 18px 16px; color: #fff; font-weight: 700; font-size: 16px;
  border-bottom: 1px solid rgba(255,255,255,.08);
}
.sidebar-brand img { width: 32px; height: 32px; border-radius: 8px; object-fit: cover; background: #fff; }

/* بحث عن شاشة داخل القائمة الجانبية */
.sidebar-search-wrap { padding: 4px 12px 8px; }
.sidebar-search-box {
  display: flex; align-items: center; gap: 6px;
  background: rgba(255,255,255,.08); border: 1px solid rgba(255,255,255,.1);
  border-radius: 8px; padding: 0 10px; height: 34px;
}
.sidebar-search-box i.bi-search { color: #9AA0D8; font-size: 13px; }
.sidebar-search-box input {
  flex: 1; min-width: 0; border: none; outline: none; background: transparent;
  color: #fff; font-size: 12.5px;
}
.sidebar-search-box input::placeholder { color: #9AA0D8; }
.sidebar-search-clear {
  background: none; border: none; color: #9AA0D8; cursor: pointer;
  padding: 2px; display: flex; align-items: center; font-size: 11px;
}
.sidebar-search-clear:hover { color: #fff; }
.sidebar-search-empty { padding: 6px 16px 2px; font-size: 12px; color: #9AA0D8; }
/* عنصر مخفي بواسطة البحث فقط — !important تضمن الغلبة سواء طُبِّق قبل أو
   بعد إخفاء PermStore.applyToDOM() (الأخير يضبط style.display مباشرة). */
.search-hide { display: none !important; }

.sidebar-nav { padding: 10px 8px 24px; }
.sidebar-group { margin-top: 6px; }
.sidebar-group-label {
  display: flex; align-items: center; gap: 8px; width: 100%;
  padding: 10px 12px; background: transparent; border: none; color: #C7CBEF;
  font-size: 12.5px; font-weight: 600; cursor: pointer; border-radius: 8px;
}
.sidebar-group-label:hover { background: rgba(255,255,255,.06); }
.sidebar-group-label .chev { margin-inline-start: auto; transition: transform .2s; font-size: 11px; }
.sidebar-group.open .chev { transform: rotate(90deg); }
.sidebar-group-items { display: none; padding-inline-start: 8px; }
.sidebar-group.open .sidebar-group-items { display: block; }

.sidebar-link, .sidebar-group-items a {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 12px; border-radius: 8px; color: #D6D9F5; font-size: 13.5px;
  margin-bottom: 2px;
}
.sidebar-link:hover, .sidebar-group-items a:hover { background: rgba(255,255,255,.08); color: #fff; }
.sidebar-link.active, .sidebar-group-items a.active { background: var(--brand); color: #fff; }
.sidebar-link i, .sidebar-group-items a i { width: 18px; text-align: center; }

/* غلاف كل شاشة (sbRenderLink) — عادي بلا تنسيق إضافي، إلا لو لها دبوس
   تثبيت (has-pin): يصير flex فيأخذ الرابط ما تبقّى من العرض ويقف الدبوس
   بجواره. راجع project_dashboard_quick_actions في الذاكرة. */
.sidebar-item.has-pin { display: flex; align-items: center; gap: 2px; }
.sidebar-item.has-pin > a { flex: 1 1 auto; min-width: 0; }
.sb-pin {
  flex: 0 0 auto; width: 24px; height: 24px; border: none; background: transparent;
  color: #D6D9F5; opacity: .3; border-radius: 6px;
  display: flex; align-items: center; justify-content: center;
  font-size: 12px; cursor: pointer; transition: opacity .15s, background .15s, color .15s;
}
.sidebar-item:hover > .sb-pin, .sb-pin.is-pinned { opacity: 1; }
.sb-pin:hover { background: rgba(255,255,255,.15); }
.sb-pin.is-pinned { color: #93C5FD; background: rgba(147,197,253,.16); }
.sb-pin:disabled { cursor: default; opacity: .5 !important; }
/* اللمس/الموبايل: لا يوجد hover موثوق — الزر يبقى ظاهراً دائماً بدرجة أوضح */
@media (hover: none) { .sb-pin { opacity: .55; } }

.app-topbar {
  height: 58px; display: flex; align-items: center; gap: 12px;
  padding: 0 18px; background: var(--bg-card); border-bottom: 1px solid var(--border);
  position: sticky; top: 0; z-index: 1020;
}
.topbar-toggle {
  display: none; background: none; border: none; font-size: 20px; color: var(--text); cursor: pointer;
  width: 36px; height: 36px; border-radius: 8px;
}
.topbar-toggle:hover { background: var(--bg); }
.topbar-title { font-weight: 700; font-size: 16px; display: flex; align-items: center; gap: 8px; }
.topbar-spacer { flex: 1; }
.topbar-user { display: flex; align-items: center; gap: 8px; }
.topbar-avatar {
  width: 34px; height: 34px; border-radius: 50%; background: var(--brand);
  color: #fff; display: flex; align-items: center; justify-content: center; font-weight: 700; font-size: 13px;
}
.topbar-btn {
  background: none; border: none; color: var(--text-muted); font-size: 18px; cursor: pointer;
  width: 36px; height: 36px; border-radius: 8px; display: flex; align-items: center; justify-content: center;
}
.topbar-btn:hover { background: var(--bg); color: var(--text); }

.app-content { padding: 20px; flex: 1; }
.page-title { display: flex; align-items: center; gap: 10px; font-size: 19px; font-weight: 700; margin: 0 0 16px; }

.sidebar-overlay {
  display: none; position: fixed; inset: 0; background: rgba(0,0,0,.5); z-index: 1025;
}

/* ══════════════════════════════════════════════════════════
   مؤشّر التحميل العام (#globalLoader)
   ──────────────────────────────────────────────────────────
   ⚠️ كان طبقة تعتيم على الشاشة كلها (`inset:0` بخلفية
   `rgba(15,23,42,.15)`) يظهرها ApiClient مع كل نداء غير صامت —
   ومعنى ذلك أن كل صفحة تُفتح أو تُحدَّث كانت «تغمق ثم تفتح لوحدها»،
   لأن أول ما تعمله أي صفحة هو نداء تحميل بياناتها. الأثر أوضح في
   الوضع الفاتح (رمادي فوق أبيض) منه في الليلي (غامق فوق غامق).
   البديل: شريط علوي رفيع لا يعتم شيئاً ولا يحجب النقر.
   منطق التوقيت (عدّاد + تأخير الإظهار) في ApiClient._setLoading.
   ══════════════════════════════════════════════════════════ */
#globalLoader {
  position: fixed; top: 0; left: 0; right: 0;
  height: 3px; z-index: 10000;
  pointer-events: none; overflow: hidden;
  opacity: 0; transition: opacity .2s ease;
}
#globalLoader.on { opacity: 1; }
#globalLoader::before {
  content: ''; position: absolute; top: 0; bottom: 0; left: 0; width: 45%;
  background: linear-gradient(90deg, rgba(29,78,216,0), var(--brand) 40%, #60A5FA 70%, rgba(96,165,250,0));
  animation: ecLoadBar 1s ease-in-out infinite;
}
@keyframes ecLoadBar {
  0%   { transform: translateX(-110%); }
  100% { transform: translateX(320%); }
}
@media (prefers-reduced-motion: reduce) {
  #globalLoader::before { animation-duration: 2.4s; }
}

/* ══════════════════════════════════════════════════════════
   Cards / Toolbar / Stat cards
   ══════════════════════════════════════════════════════════ */
.card {
  background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
}
.card-body { padding: 18px; }

.toolbar { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 16px; width: 100%; }
.toolbar-start { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; flex: 1; }
.toolbar-end { display: flex; align-items: center; gap: 8px; }

.search-box {
  display: flex; align-items: center; gap: 8px; height: var(--f-height);
  padding: 0 var(--f-pad-x); background: var(--bg-card); border: 1px solid var(--border);
  border-radius: var(--f-radius); min-width: 220px;
}
.search-box input { border: none; outline: none; background: transparent; color: var(--text); font-size: var(--f-font); width: 100%; }
.search-box i { color: var(--text-muted); }

.stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 12px; }
/* بلا هذا السطر: `[hidden]` من الـ UA stylesheet أضعف من أي قاعدة author
   بنفس الخصوصية، فـ `display:grid` أعلاه يظل نافذاً حتى مع خاصية hidden —
   وهو بالضبط ما كان يمنع زرّي إظهار/إخفاء لوحة التحكم من العمل. */
.stat-grid[hidden] { display: none; }
.stat-card {
  background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 14px 16px; display: flex; align-items: center; gap: 12px;
}
.stat-card .stat-icon {
  width: 42px; height: 42px; border-radius: 10px; display: flex; align-items: center; justify-content: center;
  background: var(--brand-light); color: var(--brand); font-size: 18px; flex-shrink: 0;
}
.stat-card .stat-value { font-size: 20px; font-weight: 700; }
.stat-card .stat-label { font-size: 12px; color: var(--text-muted); }

/* ══════════════════════════════════════════════════════════
   Buttons / Badges
   ══════════════════════════════════════════════════════════ */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  height: var(--f-height); padding: 0 16px; border-radius: var(--f-radius); border: 1px solid transparent;
  font-size: var(--f-font); font-weight: 600; cursor: pointer; white-space: nowrap;
}
.btn-primary { background: var(--brand); color: #fff; }
.btn-primary:hover { background: var(--brand-dark); }
.btn-secondary { background: var(--bg); color: var(--text); border-color: var(--border); }
.btn-secondary:hover { background: var(--border); }
.btn-danger { background: var(--danger); color: #fff; }
.btn-outline-danger { background: transparent; color: var(--danger); border-color: var(--danger); }
.btn-sm { height: 32px; padding: 0 12px; font-size: 12.5px; }
.btn:disabled { opacity: .6; cursor: not-allowed; }

.btn-icon {
  width: 32px; height: 32px; border-radius: 8px; border: 1px solid var(--border); background: var(--bg-card);
  color: var(--text-muted); display: inline-flex; align-items: center; justify-content: center; cursor: pointer;
}
.btn-icon:hover { background: var(--bg); color: var(--text); }
.btn-icon.danger:hover { background: #FEE2E2; color: var(--danger); border-color: var(--danger); }

.badge { display: inline-flex; align-items: center; padding: 3px 9px; border-radius: 999px; font-size: 11.5px; font-weight: 600; }
.badge-success { background: #DCFCE7; color: #15803D; }
.badge-danger  { background: #FEE2E2; color: #B91C1C; }
.badge-warning { background: #FEF3C7; color: #92400E; }
.badge-info    { background: #DBEAFE; color: #1D4ED8; }
.badge-muted   { background: var(--bg); color: var(--text-muted); }

/* ══════════════════════════════════════════════════════════
   Tables — table-wrap (سكرول أفقي) + hide-mobile + tbl-cards
   ══════════════════════════════════════════════════════════ */
.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
.tbl { width: 100%; border-collapse: collapse; min-width: 640px; }
.tbl th, .tbl td { padding: 11px 14px; text-align: start; border-bottom: 1px solid var(--border); font-size: 13.5px; }
.tbl th { color: var(--text-muted); font-weight: 600; font-size: 12px; text-transform: uppercase; letter-spacing: .02em; }
.tbl tbody tr:hover { background: var(--bg); }

.tbl th.sortable-th { cursor: pointer; user-select: none; white-space: nowrap; transition: color .15s; }
.tbl th.sortable-th:hover { color: var(--text); }
.tbl th.sortable-th:hover .sort-ic { opacity: .7; }
.tbl th.sortable-th .sort-ic {
  display: inline-flex; vertical-align: -1px; font-size: 11px; opacity: .3;
  margin-inline-start: 5px; transition: opacity .15s;
}
.tbl th.sortable-th .sort-ic.active { opacity: 1; color: var(--brand); }

.tbl thead tr.tbl-filter-row { background: var(--bg); }
.tbl thead tr.tbl-filter-row th {
  padding: 8px 8px; border-bottom: 1px solid var(--border); vertical-align: middle;
}
.tbl-filter-row input, .tbl-filter-row select {
  width: 100%; box-sizing: border-box; height: 32px; padding: 0 8px;
  font-size: 12.5px; font-weight: 400; text-transform: none; letter-spacing: normal;
  border: 1px solid var(--border); border-radius: 7px; background: var(--bg-card); color: var(--text);
  font-family: inherit; transition: border-color .15s, box-shadow .15s;
}
.tbl-filter-row input::placeholder { color: var(--text-muted); opacity: .8; }
.tbl-filter-row input:focus, .tbl-filter-row select:focus {
  outline: none; border-color: var(--brand); box-shadow: 0 0 0 3px rgba(29,78,216,.12);
}
.tbl-filter-row .age-range { display: flex; align-items: center; gap: 5px; }
.tbl-filter-row .age-range input {
  width: 0; flex: 1 1 0; min-width: 0; text-align: center; padding: 0 4px;
  -moz-appearance: textfield;
}
.tbl-filter-row .age-range input::-webkit-outer-spin-button,
.tbl-filter-row .age-range input::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
.tbl-filter-row .age-range .age-sep { color: var(--text-muted); flex: none; font-size: 12px; }

@media (max-width: 768px) {
  .hide-mobile { display: none !important; }
}

body.tbl-cards .table-wrap { overflow-x: visible !important; }
body.tbl-cards .tbl { display: block; width: 100%; min-width: 0 !important; }
body.tbl-cards .tbl thead { display: none !important; }
body.tbl-cards .tbl tbody { display: block; }
body.tbl-cards .tbl tbody tr {
  display: block; border: 1px solid var(--border); border-radius: 12px; margin-bottom: 10px;
  background: var(--bg-card); box-shadow: var(--shadow-sm); overflow: hidden;
}
body.tbl-cards .tbl tbody td {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  padding: 8px 14px; border-bottom: 1px solid var(--border);
}
body.tbl-cards .tbl tbody td:last-child { border-bottom: none; }
body.tbl-cards .tbl tbody td[data-label]::before {
  content: attr(data-label); font-size: 11px; font-weight: 700; color: var(--text-muted); flex-shrink: 0;
}
body.tbl-cards .tbl .hide-mobile { display: flex !important; }

.empty-state { display: flex; flex-direction: column; align-items: center; gap: 8px; padding: 48px 16px; color: var(--text-muted); }
.empty-state i { font-size: 34px; opacity: .5; }

/* ══════════════════════════════════════════════════════════
   Forms — form-control + form-row (grid) + form-label
   ══════════════════════════════════════════════════════════ */
.form-label { display: block; font-size: 12.5px; font-weight: 600; margin-bottom: 6px; color: var(--text); }
.form-label .req { color: var(--danger); }

.form-control, select.form-control, textarea.form-control {
  width: 100%; height: var(--f-height); padding: 0 var(--f-pad-x); font-size: var(--f-font);
  border-radius: var(--f-radius); border: 1px solid var(--border); background: var(--bg-card); color: var(--text);
  font-family: inherit;
}
.form-control:focus { outline: none; border-color: var(--brand); box-shadow: 0 0 0 3px rgba(29,78,216,.12); }
textarea.form-control { height: auto; min-height: calc(var(--f-height) * 2); padding-top: 10px; padding-bottom: 10px; resize: vertical; }
select.form-control { appearance: auto; }

.form-row {
  display: grid; gap: var(--f-gap); width: 100%; margin-bottom: var(--f-gap);
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
}
.form-row > div { min-width: 0; }
.form-row.col-1 { grid-template-columns: 1fr; }
.form-row.col-2 { grid-template-columns: 1fr 1fr; }
.form-row.col-3 { grid-template-columns: 1fr 1fr 1fr; }
.span-full { grid-column: 1 / -1; }

@media (max-width: 768px) {
  .form-row.col-2, .form-row.col-3 { grid-template-columns: 1fr 1fr !important; }
}
@media (max-width: 576px) {
  .form-row, .form-row.col-2, .form-row.col-3 { grid-template-columns: 1fr !important; }
}

.filter-select { height: var(--f-height); padding: 0 var(--f-pad-x); border-radius: var(--f-radius); border: 1px solid var(--border); background: var(--bg-card); color: var(--text); font-size: var(--f-font); }

/* ══════════════════════════════════════════════════════════
   Modal
   ══════════════════════════════════════════════════════════ */
.modal-overlay {
  position: fixed; inset: 0; z-index: 1050; background: rgba(15,23,42,.55);
  display: flex; align-items: center; justify-content: center; padding: 20px;
}
.modal-box {
  background: var(--bg-card); border-radius: var(--radius); box-shadow: var(--shadow-md);
  width: 100%; max-width: 560px; max-height: 90vh; display: flex; flex-direction: column; overflow: hidden;
}
.modal-box.modal-lg { max-width: 820px; }
.modal-box.modal-sm { max-width: 400px; }
.modal-head { display: flex; align-items: center; justify-content: space-between; padding: 16px 20px; border-bottom: 1px solid var(--border); }
.modal-head h4 { margin: 0; font-size: 16px; }
.modal-close { background: none; border: none; font-size: 18px; cursor: pointer; color: var(--text-muted); width: 30px; height: 30px; border-radius: 8px; }
.modal-close:hover { background: var(--bg); }
.modal-body { padding: 20px; overflow-y: auto; flex: 1; }
.modal-foot { display: flex; align-items: center; justify-content: flex-end; gap: 10px; padding: 14px 20px; border-top: 1px solid var(--border); }

/* مودال confirmAction() — بديل حوار المتصفح الافتراضي */
.confirm-icon { color: var(--brand); font-size: 15px; }
.confirm-icon.danger { color: var(--danger); }
.confirm-body { font-size: 14px; line-height: 1.8; color: var(--text); }

@media (max-width: 576px) {
  .modal-overlay { padding: 0; align-items: flex-end; }
  .modal-box { max-width: 100% !important; width: 100%; border-radius: 16px 16px 0 0; max-height: 94vh; }
  .modal-head, .modal-body, .modal-foot { padding: 14px 16px; }
}

/* ══════════════════════════════════════════════════════════
   Tabs
   ══════════════════════════════════════════════════════════ */
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--border); margin-bottom: 16px; overflow-x: auto; }
.tab-btn { padding: 10px 16px; background: none; border: none; border-bottom: 2px solid transparent; color: var(--text-muted); font-size: 13.5px; font-weight: 600; cursor: pointer; white-space: nowrap; }
.tab-btn.active { color: var(--brand); border-bottom-color: var(--brand); }

/* ══════════════════════════════════════════════════════════
   Permission matrix grid
   ══════════════════════════════════════════════════════════ */
.perm-grid-wrap { overflow-x: auto; }
.perm-grid { border-collapse: collapse; min-width: 720px; width: 100%; }
.perm-grid th, .perm-grid td { border: 1px solid var(--border); padding: 6px 8px; text-align: center; font-size: 12px; white-space: nowrap; }
.perm-grid th.grp-head { background: var(--brand-light); color: var(--brand); font-size: 12.5px; }
.perm-grid td.mod-name { text-align: start; font-weight: 600; background: var(--bg); position: sticky; inset-inline-start: 0; }
.perm-grid input[type="checkbox"] { width: 16px; height: 16px; cursor: pointer; }

/* ══════════════════════════════════════════════════════════
   Utility
   ══════════════════════════════════════════════════════════ */
.flex { display: flex; }
.gap-1 { gap: 6px; } .gap-2 { gap: 10px; }
.items-center { align-items: center; }
.mb-2 { margin-bottom: 10px; } .mb-3 { margin-bottom: 16px; }
.w-100 { width: 100%; }

/* ══════════════════════════════════════════════════════════
   Responsive breakpoints — sidebar collapses at ≤992px
   ══════════════════════════════════════════════════════════ */
@media (max-width: 992px) {
  .app-sidebar { transform: translateX(100%); }
  [dir="ltr"] .app-sidebar { transform: translateX(-100%); }
  .app-sidebar.open { transform: translateX(0); }
  .app-main { margin-inline-start: 0; }
  .topbar-toggle { display: flex; align-items: center; justify-content: center; }
  body.sidebar-open .sidebar-overlay { display: block; }
}

@media (max-width: 768px) {
  .app-content { padding: 12px; }
  .toolbar { gap: 8px; }
  .toolbar-start { width: 100%; }
  .toolbar-end { width: 100%; justify-content: stretch; }
  .toolbar-end .btn { flex: 1; }
  .search-box { min-width: 0; flex: 1; }
  .topbar-user .topbar-userinfo { display: none; }
  .stat-grid { grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); }
}

@media (max-width: 400px) {
  .page-title { font-size: 16px; }
}

/* ─────────────────────────────────────────────────────────
   Doctor schedules — شبكة أسبوع الطبيب (doctor_schedules.php)
   ملاحظة: المتغيّرات الصحيحة هي --border و --bg-card
   (لا --border-color ولا --card-bg — غير معرَّفين في هذا الملف)
   ───────────────────────────────────────────────────────── */
.sched-doc-head {
  display: flex; align-items: center; justify-content: space-between;
  gap: 10px; flex-wrap: wrap; margin-bottom: 12px;
}
.sched-span { border: 1px solid var(--border); border-radius: 12px; padding: 10px; margin-bottom: 10px; }
.sched-span:last-child { margin-bottom: 0; }
.sched-span-head {
  display: flex; align-items: center; gap: 8px; flex-wrap: wrap;
  font-size: 12.5px; margin-bottom: 10px;
}
.sched-week { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 8px; }
.sched-day {
  background: var(--bg); border-radius: 10px; padding: 8px 6px;
  display: flex; flex-direction: column; gap: 6px; min-width: 0;
}
.sched-day-name { font-size: 11.5px; font-weight: 600; color: var(--text-muted); text-align: center; }
.sched-day-empty { text-align: center; color: var(--text-muted); font-size: 12px; }
.sched-chip {
  background: var(--bg-card); border: 1px solid var(--border); border-inline-start: 3px solid var(--brand);
  border-radius: 8px; padding: 6px 7px; display: flex; flex-direction: column; gap: 2px; min-width: 0;
}
.sched-chip.past   { opacity: .6;  border-inline-start-color: var(--text-muted); }
.sched-chip.future { border-inline-start-color: var(--warning, #D97706); }
.sched-chip.off    { opacity: .6;  border-inline-start-color: var(--danger); }
.sched-chip-time { font-size: 12px; font-weight: 600; white-space: nowrap; }
.sched-chip-meta { font-size: 10.5px; color: var(--text-muted); }
.sched-chip-acts { display: flex; gap: 2px; flex-wrap: wrap; }
.sched-chip-acts .btn-icon { width: 24px; height: 24px; font-size: 11px; }

@media (max-width: 900px) {
  .sched-week { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .sched-day { flex-direction: row; align-items: center; flex-wrap: wrap; }
  .sched-day-name { text-align: start; min-width: 60px; }
}
@media (max-width: 480px) {
  .sched-week { grid-template-columns: 1fr; }
}

/* ─────────────────────────────────────────────────────────
   Doctor schedules — تقويم الشهر (تبويب «تقويم الشهر»)
   ألوان الحالات مبنية على tokens الثيم: --border / --bg-card / --brand
   ───────────────────────────────────────────────────────── */
.cal-legend { display: flex; flex-wrap: wrap; gap: 14px; align-items: center; font-size: 12px; }
.cal-dot { display: inline-block; width: 11px; height: 11px; border-radius: 3px; vertical-align: -1px; margin-inline-end: 4px; border: 1px solid var(--border); }
.cal-dot.work    { background: #DCFCE7; border-color: #86EFAC; }
.cal-dot.extra   { background: #EFF6FF; border-color: #93C5FD; }
.cal-dot.off     { background: #FEF3C7; border-color: #FCD34D; }
.cal-dot.holiday { background: #FEE2E2; border-color: #FCA5A5; }
.cal-dot.surgery { background: #FCE7F3; border-color: #F9A8D4; }
.cal-dot.none    { background: var(--bg); }

.cal-grid { display: grid; grid-template-columns: repeat(7, minmax(96px, 1fr)); gap: 6px; min-width: 700px; }
.cal-head { margin-bottom: 6px; min-width: 700px; }
.cal-hcell { text-align: center; font-size: 11.5px; font-weight: 600; color: var(--text-muted); padding: 4px 0; }

.cal-cell {
  border: 1px solid var(--border); border-radius: 10px; padding: 6px; min-height: 88px;
  background: var(--bg); display: flex; flex-direction: column; gap: 4px; cursor: pointer;
  transition: box-shadow .12s ease, transform .12s ease;
}
.cal-cell:hover { box-shadow: var(--shadow-sm); transform: translateY(-1px); }
.cal-cell.cal-pad { background: transparent; border: 0; cursor: default; min-height: 0; }
.cal-cell.cal-pad:hover { box-shadow: none; transform: none; }
.cal-cell.is-today { outline: 2px solid var(--brand); outline-offset: -2px; }

.cal-cell.work    { background: rgba(34, 197, 94, .10);  border-color: rgba(34, 197, 94, .35); }
.cal-cell.extra   { background: rgba(29, 78, 216, .10);  border-color: rgba(29, 78, 216, .35); }
.cal-cell.off     { background: rgba(245, 158, 11, .12); border-color: rgba(245, 158, 11, .40); }
.cal-cell.holiday { background: rgba(239, 68, 68, .10);  border-color: rgba(239, 68, 68, .35); }
.cal-cell.surgery { background: rgba(219, 39, 119, .10); border-color: rgba(219, 39, 119, .35); }

.cal-daynum { font-weight: 700; font-size: 12.5px; display: flex; align-items: center; gap: 6px; }
.cal-tag { font-weight: 600; font-size: 10px; color: var(--text-muted); }
.cal-period {
  background: var(--bg-card); border: 1px solid var(--border); border-radius: 6px;
  padding: 2px 5px; font-size: 11px; white-space: nowrap;
}
.cal-period.is-extra { border-color: rgba(29, 78, 216, .55); }
.cal-period.is-surgery { border-color: rgba(219, 39, 119, .55); color: #9D174D; }
.cal-note { font-size: 10.5px; color: var(--text-muted); line-height: 1.35; }

@media (max-width: 640px) {
  .cal-cell { min-height: 74px; padding: 4px; }
  .cal-period { font-size: 10px; }
}

/* صفوف مودال «تفاصيل اليوم» في تقويم جداول الأطباء */
.day-item {
  display: flex; align-items: flex-start; justify-content: space-between; gap: 10px;
  border: 1px solid var(--border); border-radius: 10px; padding: 9px 11px; margin-bottom: 8px;
  background: var(--bg);
}
.day-item:last-child { margin-bottom: 0; }
.day-item b { font-size: 13px; }

/* صف عملية جراحية داخل جدول يوم الطبيب (شاشة المواعيد) */
.tbl tbody tr.row-surgery { background: rgba(219, 39, 119, .06); }
.tbl tbody tr.row-surgery:hover { background: rgba(219, 39, 119, .11); }
.tbl tbody tr.row-surgery td:first-child { box-shadow: inset 3px 0 0 rgba(219, 39, 119, .55); }

/* ── شارة «آخر كشف» (الاستقبال: زيارة جديدة / حجز ميعاد / مودال الطابور) ──
   لون كهرماني صريح في الثيمين حتى لا تفوت موظف الاستقبال؛ «أول كشف» أزرق. */
.last-exam-badge {
  margin: 6px 0 8px; padding: 9px 12px;
  border: 1px solid #F59E0B; border-inline-start-width: 5px; border-radius: 10px;
  background: #FEF3C7; color: #78350F;
  font-size: 14px; line-height: 1.7; overflow-wrap: anywhere;
}
.last-exam-badge b { font-weight: 800; }
.last-exam-badge .le-type {
  display: inline-block; padding: 1px 9px; margin-inline-start: 4px; border-radius: 999px;
  background: #D97706; color: #fff; font-weight: 700; font-size: 12.5px;
}
.last-exam-badge.is-first { border-color: #3B82F6; background: #DBEAFE; color: #1E3A8A; }
:root[data-theme="dark"] .last-exam-badge { background: rgba(245,158,11,.16); color: #FCD34D; }
:root[data-theme="dark"] .last-exam-badge.is-first { background: rgba(59,130,246,.18); color: #93C5FD; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .last-exam-badge { background: rgba(245,158,11,.16); color: #FCD34D; }
  :root:not([data-theme="light"]) .last-exam-badge.is-first { background: rgba(59,130,246,.18); color: #93C5FD; }
}
