/* ==========================================================================
   v2.8 — تجربة الاستخدام: الوضع الداكن، شريط الجوال السفلي، الهياكل التحميلية،
   الاختصارات، التراجع، حدود الحقول
   ========================================================================== */

/* ---------- الوضع الداكن ---------- */
[data-bs-theme="dark"] {
  color-scheme: dark;
  --surface-white: #111c2e;
  --surface-ground: #0b1220;
  --text-main: #e5edf7;
  --text-muted: #94a3b8;
  --border-light: #24324a;
  --slate-900: #e5edf7; --slate-800: #dbe6f3; --slate-700: #c3d0e0; --slate-600: #a9b9cd;
  --slate-500: #8a9bb3; --slate-400: #6b7d96; --slate-200: #24324a; --slate-100: #17233a; --slate-50: #0f1829;
  --primary-subtle: #0c2740; --primary-border: #164e7a;
  --gold-subtle: #2a1f08; --gold-border: #6b4a0f;
  --emerald-subtle: #08281d; --emerald-border: #0f5a40;
  --rose-subtle: #2c0f17; --rose-border: #6f1f33;
  --purple-subtle: #1b1433; --purple-border: #43308a;
  --shadow-xs: 0 1px 2px rgba(0,0,0,.4); --shadow-sm: 0 2px 6px rgba(0,0,0,.4); --shadow-md: 0 4px 16px rgba(0,0,0,.45);
  --shadow-lg: 0 10px 28px rgba(0,0,0,.5); --shadow-xl: 0 20px 40px rgba(0,0,0,.55);
  --bs-body-bg: #0b1220; --bs-body-color: #e5edf7; --bs-border-color: #24324a;
}
[data-bs-theme="dark"] body { background: #0b1220; background-image: none; color: #e5edf7; }
[data-bs-theme="dark"] html, [data-bs-theme="dark"] body { background-color: #0b1220; }
[data-bs-theme="dark"] .bg-white, [data-bs-theme="dark"] .bg-light { background-color: #111c2e !important; }
[data-bs-theme="dark"] .text-dark { color: #e5edf7 !important; }
[data-bs-theme="dark"] .text-muted, [data-bs-theme="dark"] .text-secondary { color: #94a3b8 !important; }
[data-bs-theme="dark"] .border, [data-bs-theme="dark"] .border-bottom, [data-bs-theme="dark"] .border-top { border-color: #24324a !important; }
/* الأسطح الرئيسية */
[data-bs-theme="dark"] :is(.executive-card, .metric-card, .presidential-next-hub, .nav-executive-pills, .live-clock-badge, .notification-bell-btn,
  .countdown-digit-box, #activeMeetingProgressBox, .quick-filter-btn, .table-executive tbody tr, .notif-item, .cal-toolbar, .cal-icon-btn, .cal-today-btn,
  .cal-picker, .cal-views, .cal-search input, .cal-stat, .cal-dow, .cal-cell, .cal-grid-wrap, .cal-week-head, .cal-agenda, .cal-agenda-item, .cal-pop,
  .ap-chip, .ap-pg, .usr-stat, .usr-meter, .calendar-day-header, .calendar-day-cell, .icon-picker-item, .executive-navbar) {
  background-color: #111c2e; border-color: #24324a; color: #e5edf7;
}
[data-bs-theme="dark"] .nav-executive-pills { background: #0f1829; }
[data-bs-theme="dark"] .nav-executive-pills .nav-link.active, [data-bs-theme="dark"] .cal-view-btn.active, [data-bs-theme="dark"] .notif-tab.active { background: #1a2a45; color: #7dd3fc; }
[data-bs-theme="dark"] .table-executive thead th, [data-bs-theme="dark"] .table > :not(caption) > * > * { background-color: transparent; color: inherit; border-color: #24324a; }
[data-bs-theme="dark"] .table-light, [data-bs-theme="dark"] .table-light > th, [data-bs-theme="dark"] .table-light > td { --bs-table-bg: #17233a; --bs-table-color: #c3d0e0; color: #c3d0e0; }
[data-bs-theme="dark"] .table-hover > tbody > tr:hover > * { background-color: #17233a; color: #e5edf7; }
[data-bs-theme="dark"] .cal-cell.is-weekend { background: #131f33; }
[data-bs-theme="dark"] .cal-cell.is-other { background: #0e1626; }
[data-bs-theme="dark"] .cal-cell.is-today { background: #0b2a22; }
[data-bs-theme="dark"] .usr-table tr.usr-off td { background: #0f1829; }
[data-bs-theme="dark"] .usr-role-card:has(input:checked) { background: #0c2740; }
[data-bs-theme="dark"] .usr-temp { background: #2a1f08; color: #fde68a; }
[data-bs-theme="dark"] .modal-content { background: #111c2e; border-color: #24324a; }
[data-bs-theme="dark"] .modal-header, [data-bs-theme="dark"] .modal-footer { background: #0f1829 !important; border-color: #24324a; }
[data-bs-theme="dark"] .dropdown-menu { background: #111c2e; border-color: #24324a; }
[data-bs-theme="dark"] .form-control, [data-bs-theme="dark"] .form-select, [data-bs-theme="dark"] .input-group-text { background-color: #0f1829; border-color: #2a3b57; color: #e5edf7; }
[data-bs-theme="dark"] .form-control::placeholder { color: #6b7d96; }
[data-bs-theme="dark"] .btn-light { background: #1a2a45; border-color: #2a3b57 !important; color: #dbe6f3; }
[data-bs-theme="dark"] .alert { border-color: #24324a; }
[data-bs-theme="dark"] .badge.bg-light { background: #1a2a45 !important; color: #dbe6f3 !important; }
[data-bs-theme="dark"] .app-footer { color: #6b7d96 !important; }
[data-bs-theme="dark"] .official-report-card { background: #111c2e; }
/* البطاقة الرسمية والتقرير المطبوع تبقى فاتحة دائماً (للطباعة والمشاركة) */
[data-bs-theme="dark"] .vip-pass, [data-bs-theme="dark"] .vip-pass * { color-scheme: light; }
[data-bs-theme="dark"] .vip-pass { background: #fff; }
[data-bs-theme="dark"] .vip-pass .vip-title, [data-bs-theme="dark"] .vip-pass .vip-org, [data-bs-theme="dark"] .vip-pass .vip-sign-title, [data-bs-theme="dark"] .vip-pass .vip-day, [data-bs-theme="dark"] .vip-pass .vip-info b { color: #0f172a; }
[data-bs-theme="dark"] .vip-modal-body { background: #0b1220; }
[data-bs-theme="dark"] .vip-modal-header { background: #0f1829; }
[data-bs-theme="dark"] .vip-modal-footer { background: #0f1829; }
[data-bs-theme="dark"] .vip-tear i { background: #0b1220; }
@media print { [data-bs-theme="dark"] body { background: #fff !important; color: #000 !important; } }

/* زر تبديل المظهر */
.theme-toggle-item .bi-sun-fill { display: none; }
[data-bs-theme="dark"] .theme-toggle-item .bi-moon-stars-fill { display: none; }
[data-bs-theme="dark"] .theme-toggle-item .bi-sun-fill { display: inline-block; }

/* ---------- هياكل التحميل (Skeleton) ---------- */
.skel { position: relative; overflow: hidden; background: #e8edf4; border-radius: 8px; min-height: 14px; }
[data-bs-theme="dark"] .skel { background: #1a2740; }
.skel::after { content: ""; position: absolute; inset: 0; transform: translateX(-100%); background: linear-gradient(90deg, transparent, rgba(255,255,255,.55), transparent); animation: skel 1.3s infinite; }
[data-bs-theme="dark"] .skel::after { background: linear-gradient(90deg, transparent, rgba(255,255,255,.07), transparent); }
@keyframes skel { 100% { transform: translateX(100%); } }
.skel-row td { padding: .9rem 1rem !important; }
@media (prefers-reduced-motion: reduce) { .skel::after { animation: none; } }

/* ---------- شريط التنقل السفلي للجوال ---------- */
.bottom-nav { display: none; }
@media (max-width: 767.98px) {
  .bottom-nav { display: flex; position: fixed; inset-inline: 0; bottom: 0; z-index: 1030; background: rgba(255,255,255,.96); backdrop-filter: blur(10px);
    border-top: 1px solid var(--border-light, #e2e8f0); padding: .35rem .4rem calc(.35rem + env(safe-area-inset-bottom)); box-shadow: 0 -6px 20px rgba(15,23,42,.08); justify-content: space-around; align-items: flex-end; }
  [data-bs-theme="dark"] .bottom-nav { background: rgba(15,24,41,.96); }
  .bn-item { flex: 1; border: 0; background: transparent; display: flex; flex-direction: column; align-items: center; gap: 2px; padding: .3rem 0; color: #64748b; font-size: .66rem; font-weight: 700; border-radius: 12px; min-height: 48px; }
  .bn-item i { font-size: 1.3rem; line-height: 1; }
  .bn-item.active { color: var(--primary, #0284c7); }
  .bn-item.active i { transform: translateY(-1px); }
  .bn-fab { flex: 0 0 auto; width: 54px; height: 54px; margin-top: -22px; border-radius: 50%; border: 0; color: #fff; font-size: 1.6rem; background: linear-gradient(135deg, #f59e0b, #d97706); box-shadow: 0 8px 20px rgba(217,119,6,.45); display: flex; align-items: center; justify-content: center; }
  body { padding-bottom: calc(76px + env(safe-area-inset-bottom)); }
  .nav-pills-scroll-container { display: none !important; }
  #toast-container { bottom: calc(80px + env(safe-area-inset-bottom)) !important; }
  .app-footer { padding-bottom: 1rem; }
  /* النوافذ كأوراق سفلية على الجوال */
  .modal.fade .modal-dialog { transition: transform .3s ease-out; }
  .modal:not(.vip-modal) .modal-dialog:not(.modal-fullscreen) { margin: 0; min-height: 100%; display: flex; align-items: flex-end; max-width: 100%; }
  .modal:not(.vip-modal) .modal-content { border-radius: 22px 22px 0 0; max-height: 92vh; width: 100%; }
  .modal-dialog-scrollable .modal-content { max-height: 92vh; }
  .modal:not(.show) .modal-dialog { transform: translateY(40px); }
}

/* ---------- تراجع (Undo) داخل التنبيه ---------- */
.toast .toast-undo { border: 1px solid rgba(255,255,255,.55); background: rgba(255,255,255,.18); color: #fff; font-weight: 800; border-radius: 999px; padding: .1rem .8rem; margin-inline-start: .6rem; font-size: .82rem; }
.toast .toast-undo:hover { background: rgba(255,255,255,.3); }

/* ---------- أخطاء الحقول ---------- */
.field-error-msg { color: #dc2626; font-size: .78rem; font-weight: 600; margin-top: .25rem; display: flex; gap: .3rem; align-items: center; }
[data-bs-theme="dark"] .field-error-msg { color: #fca5a5; }
.form-control.is-invalid, .form-select.is-invalid { background-image: none; }

/* ---------- نافذة الاختصارات ---------- */
.kbd-grid { display: grid; grid-template-columns: 1fr 1fr; gap: .5rem 1.2rem; }
.kbd-row { display: flex; justify-content: space-between; align-items: center; gap: .6rem; padding: .35rem 0; border-bottom: 1px dashed var(--border-light, #e2e8f0); font-size: .9rem; }
kbd.k { background: #eef2f7; color: #0f172a; border: 1px solid #cbd5e1; border-bottom-width: 2px; border-radius: 6px; padding: .05rem .45rem; font-size: .78rem; font-family: ui-monospace, Consolas, monospace; direction: ltr; display: inline-block; }
[data-bs-theme="dark"] kbd.k { background: #1a2a45; color: #e5edf7; border-color: #2f4468; }
@media (max-width: 575.98px) { .kbd-grid { grid-template-columns: 1fr; } }

/* ---------- لمسات عامة ---------- */
:focus-visible { outline: 3px solid rgba(2,132,199,.45); outline-offset: 2px; }
.btn:active:not(:disabled) { transform: translateY(1px); }
@media (prefers-reduced-motion: reduce) { * { animation-duration: .01ms !important; transition-duration: .01ms !important; } }

/* ---- إصلاحات الوضع الداكن (v2.8) ---- */
[data-bs-theme="dark"] :is(.presidential-next-hub, .executive-card, .metric-card, .cal-stat, .cal-toolbar, .cal-grid-wrap) { background-image: none; }
[data-bs-theme="dark"] .presidential-next-hub { background-color: #111c2e; }
[data-bs-theme="dark"] .presidential-next-hub :is(h1,h2,h3,h4,h5,h6,.fw-bold,.next-title,#nextAppointmentTitle) { color: #f1f5f9 !important; }
[data-bs-theme="dark"] .presidential-next-hub :is(.text-muted,small,.small) { color: #94a3b8 !important; }
[data-bs-theme="dark"] .presidential-next-hub :is(.badge.bg-dark, .bg-dark) { background: #0b1220 !important; color: #e5edf7 !important; }
[data-bs-theme="dark"] .cal-stat .v, [data-bs-theme="dark"] .cal-stat .l { color: #e5edf7; }
[data-bs-theme="dark"] .cal-stat .l { color: #94a3b8; }
[data-bs-theme="dark"] .cal-stat i { background: #0c2740; color: #7dd3fc; }
[data-bs-theme="dark"] .cal-views { background: #0b1220; }
[data-bs-theme="dark"] .cal-view-btn { color: #94a3b8; }
[data-bs-theme="dark"] .cal-dow, [data-bs-theme="dark"] .cal-week-head { color: #cbd5e1; }
[data-bs-theme="dark"] .cal-cell .cal-date, [data-bs-theme="dark"] .cal-cell .cal-num { color: #94a3b8; }

/* ---- البحث الشامل والمؤشرات (v2.9) ---- */
.gs-modal .modal-content { border-radius: 18px; overflow: hidden; }
.gs-head { display: flex; align-items: center; gap: .6rem; padding: .5rem 1rem; border-bottom: 1px solid var(--bs-border-color, #e2e8f0); font-size: 1.1rem; color: #64748b; }
.gs-head .form-control { box-shadow: none; background: transparent; font-size: 1rem; }
.gs-results { max-height: 60vh; overflow-y: auto; padding: .5rem; }
.gs-hint { text-align: center; color: #94a3b8; padding: 2rem 1rem; font-size: .9rem; }
.gs-sec { font-size: .72rem; font-weight: 800; color: #94a3b8; padding: .6rem .75rem .2rem; letter-spacing: .02em; }
.gs-item { display: flex; align-items: center; gap: .75rem; width: 100%; text-align: start; border: 0; background: transparent; padding: .6rem .75rem; border-radius: 12px; color: inherit; }
.gs-item:hover, .gs-item:focus-visible { background: rgba(14,165,233,.1); outline: 0; }
.gs-item > i { font-size: 1.2rem; color: #0284c7; flex: none; }
.gs-t { flex: 1; min-width: 0; font-weight: 700; display: flex; flex-direction: column; }
.gs-t small, .gs-d small { font-weight: 500; color: #64748b; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.gs-d { display: flex; flex-direction: column; align-items: flex-end; font-size: .82rem; flex: none; }
.ins-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: .75rem; }
.ins-box { padding: .75rem .9rem; border-radius: 14px; background: rgba(148,163,184,.1); min-width: 0; }
.ins-l { font-size: .76rem; color: #64748b; margin-bottom: .2rem; }
.ins-v { font-size: 1.7rem; font-weight: 800; line-height: 1.1; }
.ins-v.ins-sm { font-size: 1.05rem; padding: .35rem 0; }
.ins-s { font-size: .78rem; margin-top: .15rem; }
.ins-row { display: flex; justify-content: space-between; gap: .5rem; font-size: .85rem; padding: .12rem 0; }
.ins-row span { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
@media (max-width: 991.98px) { .ins-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); } .ins-wide { grid-column: 1 / -1; } }
[data-bs-theme="dark"] .ins-box { background: #0f1829; }
[data-bs-theme="dark"] .gs-t small, [data-bs-theme="dark"] .gs-d small, [data-bs-theme="dark"] .ins-l { color: #94a3b8; }
[data-bs-theme="dark"] .gs-head { border-color: #24324a; }

/* ---- المرفقات (v2.10) ---- */
.att-list { display: flex; flex-direction: column; gap: .35rem; }
.att-item { display: flex; align-items: center; gap: .6rem; padding: .4rem .7rem; border: 1px solid #e2e8f0; border-radius: 10px; background: #f8fafc; min-width: 0; }
.att-item > i { color: #0284c7; font-size: 1.15rem; flex: none; }
.att-name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 600; text-decoration: none; color: inherit; }
.att-name:hover { color: #0284c7; }
[data-bs-theme="dark"] .att-item { background: #0f1829; border-color: #24324a; }

/* ---- القوالب (v2.11) ---- */
.tpl-bar { display: flex; align-items: center; gap: .5rem; padding: .5rem .7rem; border: 1px dashed #cbd5e1; border-radius: 12px; background: rgba(245,158,11,.06); }
.tpl-bar .form-select { flex: 1; min-width: 0; }
[data-bs-theme="dark"] .tpl-bar { border-color: #2a3b57; background: rgba(245,158,11,.08); }

/* ---- واجهة المواعيد المنجزة (v2.13) ---- */
#section-agenda.ap-mode-done .ap-only-active { display: none !important; }
.ap-seg { display: flex; gap: .25rem; padding: .25rem; margin-bottom: .9rem; background: rgba(148,163,184,.16); border-radius: 14px; }
.ap-seg button { flex: 1; border: 0; background: transparent; padding: .55rem .5rem; border-radius: 11px; font-weight: 700; color: #475569; }
.ap-seg button.active { background: #fff; color: #0369a1; box-shadow: 0 2px 8px rgba(15,23,42,.12); }
[data-bs-theme="dark"] .ap-seg { background: #0f1829; }
[data-bs-theme="dark"] .ap-seg button { color: #94a3b8; }
[data-bs-theme="dark"] .ap-seg button.active { background: #1a2a45; color: #7dd3fc; }

/* اسم الجهة الطويل في الشريط العلوي: يُخفى في الجوال (الشعار يحمل الاسم) ويُرتّب في الشاشات الأكبر */
.executive-navbar .container-fluid > div:first-child { min-width: 0; flex: 1 1 auto; margin-inline-end: .5rem; }
.executive-navbar .container-fluid > div:first-child > div { min-width: 0; }
.executive-navbar .dynamic-site-title { line-height: 1.4; text-wrap: balance; }
