/* الوضع الداكن — يُحمَّل آخراً. لا يغيّر الوضع الفاتح.
   يُظلم السطوح فقط. هوية الجمعية (--app-primary) والشعارات والتدرجات تبقى كما هي. */

html[data-bs-theme="dark"] {
  color-scheme: dark;
  --dm-card: #1e293b;
  --dm-well: #111827;
  --dm-fade: #1e293b;
  --dm-line: #0f172a;
  --dm-border: rgba(148, 163, 184, 0.28);
  --dm-ink: #e2e8f0;
  --dm-muted: #94a3b8;
  --dm-info: rgba(2, 132, 199, 0.16);
  --dm-info-deep: rgba(2, 132, 199, 0.28);
  --dm-info-ink: #7dd3fc;
  --dm-ok: rgba(5, 150, 105, 0.16);
  --dm-ok-deep: rgba(5, 150, 105, 0.28);
  --dm-ok-ink: #6ee7b7;
  --dm-violet: rgba(124, 58, 237, 0.16);
  --dm-violet-deep: rgba(124, 58, 237, 0.28);
  --dm-violet-ink: #c4b5fd;
  --dm-indigo: rgba(99, 102, 241, 0.16);
  --dm-indigo-ink: #a5b4fc;
  --dm-teal: rgba(13, 148, 136, 0.16);
  --dm-warn: rgba(217, 119, 6, 0.18);
  --dm-warn-deep: rgba(217, 119, 6, 0.28);
  --dm-warn-ink: #fbbf24;
  --dm-danger: rgba(220, 38, 38, 0.16);
  --dm-danger-deep: rgba(220, 38, 38, 0.28);
  --dm-danger-ink: #fca5a5;
  --dm-pink: rgba(190, 24, 93, 0.16);
  --dm-pink-ink: #f9a8d4;
  --dm-orange-ink: #fdba74;
  --dm-cyan-ink: #67e8f9;
  --bs-body-bg: #0b1120;
  --bs-body-color: #e2e8f0;
  --bs-secondary-bg: #111827;
  --bs-tertiary-bg: #1e293b;
  --bs-secondary-color: #94a3b8;
  --bs-tertiary-color: #cbd5e1;
  --bs-border-color: rgba(148, 163, 184, 0.18);
  --bs-link-color: var(--app-primary-on-dark, var(--app-primary)) !important;
  --bs-link-hover-color: var(--app-primary-on-dark, var(--app-primary)) !important;
  --ws-surface: #0f172a;
  --mob-nav-bg: rgba(17, 24, 39, 0.94);
  --mob-nav-border: rgba(148, 163, 184, 0.18);
  --mob-nav-shadow: 0 -4px 24px rgba(0, 0, 0, 0.35);
}

html[data-bs-theme="dark"] body {
  background: #0b1120;
  color: #e2e8f0;
}

/* ── الهيكل ── */
html[data-bs-theme="dark"] .app-wrapper { background: #0b1120; }
html[data-bs-theme="dark"] .sidebar {
  background: #111827;
  border-color: rgba(148, 163, 184, 0.18);
}
html[data-bs-theme="dark"] .sidebar-header {
  background: #111827;
  border-bottom-color: rgba(148, 163, 184, 0.18);
}
html[data-bs-theme="dark"] .dm-accent-ink,
html[data-bs-theme="dark"] .wom-def-card-icon,
html[data-bs-theme="dark"] .cap-card-icon {
  color: color-mix(in srgb, currentColor 58%, #f8fafc) !important;
}

html[data-bs-theme="dark"] .sidebar-logo {
  background: #fff;
  border-radius: 8px;
  padding: 3px 6px;
}
html[data-bs-theme="dark"] .sidebar-nav .nav-link { color: #e2e8f0; }
html[data-bs-theme="dark"] .sidebar-nav .nav-link:hover,
html[data-bs-theme="dark"] .sidebar-nav .nav-link.active,
html[data-bs-theme="dark"] .sidebar-nav .nav-link.active i,
html[data-bs-theme="dark"] .sidebar-brand,
html[data-bs-theme="dark"] .sidebar-brand:hover,
html[data-bs-theme="dark"] .sidebar-nav .submenu .sidebar-group-toggle:hover {
  color: var(--app-primary-on-dark, var(--app-primary));
}
html[data-bs-theme="dark"] .sidebar-nav .nav-link.active i {
  background: color-mix(in srgb, var(--app-primary) 24%, transparent);
  border: 1px solid color-mix(in srgb, var(--app-primary) 38%, transparent);
  color: color-mix(in srgb, var(--app-primary-on-dark, var(--app-primary)) 72%, #f8fafc);
}
html[data-bs-theme="dark"] .sidebar-nav .submenu .sidebar-group-toggle,
html[data-bs-theme="dark"] .sidebar-nav .submenu .sidebar-group-label {
  color: #94a3b8;
}
html[data-bs-theme="dark"] .main-wrapper { background: #0b1120; }
html[data-bs-theme="dark"] .topbar {
  background: #111827;
  border-bottom-color: rgba(148, 163, 184, 0.18);
  box-shadow: none;
}
html[data-bs-theme="dark"] .sidebar-toggle { color: #cbd5e1; }
html[data-bs-theme="dark"] .topbar-theme-toggle {
  background: #0f172a;
  color: #e2e8f0;
  border-color: rgba(148, 163, 184, 0.28);
}
html[data-bs-theme="dark"] .topbar-theme-toggle:hover,
html[data-bs-theme="dark"] .topbar-theme-toggle:focus {
  background: #0f172a;
  color: var(--app-primary-on-dark, var(--app-primary));
  border-color: var(--app-primary-on-dark, var(--app-primary));
}
html[data-bs-theme="dark"] .topbar-back {
  background: #0f172a;
  color: #e2e8f0;
  border-color: rgba(148, 163, 184, 0.28);
}
html[data-bs-theme="dark"] .topbar-back:hover,
html[data-bs-theme="dark"] .topbar-back:focus {
  background: #0f172a;
  color: var(--app-primary-on-dark, var(--app-primary));
  border-color: var(--app-primary-on-dark, var(--app-primary));
}
html[data-bs-theme="dark"] .page-place .breadcrumb-item,
html[data-bs-theme="dark"] .page-place .breadcrumb-item a {
  color: var(--app-primary-on-dark, var(--app-primary));
}
html[data-bs-theme="dark"] .page-place .breadcrumb-item.active {
  color: var(--bs-body-color);
}
html[data-bs-theme="dark"] .main-footer {
  background: #111827;
  border-top-color: rgba(148, 163, 184, 0.18);
  color: #94a3b8;
}

/* ── أسطح Bootstrap المشتركة ── */
html[data-bs-theme="dark"] .card,
html[data-bs-theme="dark"] .card-header,
html[data-bs-theme="dark"] .card-footer,
html[data-bs-theme="dark"] .modal-content,
html[data-bs-theme="dark"] .dropdown-menu,
html[data-bs-theme="dark"] .list-group-item,
html[data-bs-theme="dark"] .accordion-item,
html[data-bs-theme="dark"] .accordion-button,
html[data-bs-theme="dark"] .offcanvas,
html[data-bs-theme="dark"] .popover,
html[data-bs-theme="dark"] .toast,
html[data-bs-theme="dark"] .page-link {
  background-color: #1e293b;
  color: #e2e8f0;
  border-color: rgba(148, 163, 184, 0.18);
}
html[data-bs-theme="dark"] .card-header,
html[data-bs-theme="dark"] .card-footer,
html[data-bs-theme="dark"] .modal-header,
html[data-bs-theme="dark"] .modal-footer {
  border-color: rgba(148, 163, 184, 0.18);
}
html[data-bs-theme="dark"] .accordion-button:not(.collapsed) {
  background-color: #0f172a;
  color: var(--app-primary-on-dark, var(--app-primary));
}
html[data-bs-theme="dark"] .dropdown-item { color: #e2e8f0; }
html[data-bs-theme="dark"] .dropdown-item:hover,
html[data-bs-theme="dark"] .dropdown-item:focus {
  background-color: rgba(148, 163, 184, 0.12);
  color: #f8fafc;
}
html[data-bs-theme="dark"] .dropdown-item.text-danger,
html[data-bs-theme="dark"] .dropdown-item.text-danger:hover { color: #fca5a5 !important; }
html[data-bs-theme="dark"] .dropdown-divider { border-color: rgba(148, 163, 184, 0.18); }
html[data-bs-theme="dark"] .text-dark,
html[data-bs-theme="dark"] .text-body { color: #e2e8f0 !important; }
html[data-bs-theme="dark"] .text-muted,
html[data-bs-theme="dark"] .text-body-secondary { color: #94a3b8 !important; }
html[data-bs-theme="dark"] .bg-white { background-color: #1e293b !important; }
html[data-bs-theme="dark"] .bg-light { background-color: #111827 !important; }
html[data-bs-theme="dark"] .border,
html[data-bs-theme="dark"] .border-top,
html[data-bs-theme="dark"] .border-bottom { border-color: rgba(148, 163, 184, 0.18) !important; }

html[data-bs-theme="dark"] .table {
  --bs-table-bg: transparent;
  --bs-table-color: #e2e8f0;
  --bs-table-border-color: rgba(148, 163, 184, 0.18);
  --bs-table-striped-bg: rgba(148, 163, 184, 0.06);
  --bs-table-striped-color: #e2e8f0;
  --bs-table-hover-bg: rgba(var(--app-primary-rgb, 15, 118, 110), 0.12);
  --bs-table-hover-color: #e2e8f0;
  color: #e2e8f0;
}
html[data-bs-theme="dark"] .table-light {
  --bs-table-bg: #111827;
  --bs-table-color: #e2e8f0;
}

html[data-bs-theme="dark"] .form-control,
html[data-bs-theme="dark"] .form-select,
html[data-bs-theme="dark"] .input-group-text {
  background-color: #0f172a;
  color: #e2e8f0;
  border-color: rgba(148, 163, 184, 0.28);
}
html[data-bs-theme="dark"] .form-control:focus,
html[data-bs-theme="dark"] .form-select:focus {
  background-color: #0f172a;
  color: #e2e8f0;
  border-color: var(--app-primary-on-dark, var(--app-primary));
}
html[data-bs-theme="dark"] .form-control:disabled,
html[data-bs-theme="dark"] .form-control[readonly],
html[data-bs-theme="dark"] .form-select:disabled {
  background-color: #111827;
  color: #94a3b8;
}
html[data-bs-theme="dark"] .form-control::placeholder { color: #94a3b8; }
html[data-bs-theme="dark"] .btn:focus,
html[data-bs-theme="dark"] .btn:active:focus,
html[data-bs-theme="dark"] .form-control:focus,
html[data-bs-theme="dark"] .form-check-input:focus {
  box-shadow: 0 0 0 0.1rem #0f172a, 0 0 0 0.25rem var(--app-primary-on-dark, var(--app-primary));
}

html[data-bs-theme="dark"] .btn-primary {
  --bs-btn-bg: var(--app-button-on-dark, var(--app-button-color)) !important;
  --bs-btn-border-color: var(--app-button-on-dark, var(--app-button-color)) !important;
  --bs-btn-hover-bg: color-mix(in srgb, var(--app-button-on-dark, var(--app-button-color)) 86%, #020617) !important;
  --bs-btn-hover-border-color: color-mix(in srgb, var(--app-button-on-dark, var(--app-button-color)) 86%, #020617) !important;
  background-color: var(--app-button-on-dark, var(--app-button-color)) !important;
  border-color: var(--app-button-on-dark, var(--app-button-color)) !important;
  color: #fff !important;
}
html[data-bs-theme="dark"] .btn-primary:hover,
html[data-bs-theme="dark"] .btn-primary:focus {
  background-color: color-mix(in srgb, var(--app-button-on-dark, var(--app-button-color)) 86%, #020617) !important;
  border-color: color-mix(in srgb, var(--app-button-on-dark, var(--app-button-color)) 86%, #020617) !important;
  color: #fff !important;
}
html[data-bs-theme="dark"] .btn-outline-primary {
  color: var(--app-primary-on-dark, var(--app-primary));
  border-color: var(--app-primary-on-dark, var(--app-primary));
}
html[data-bs-theme="dark"] .btn-outline-primary:hover {
  background: var(--app-primary-on-dark, var(--app-primary));
  color: #0f172a;
}
html[data-bs-theme="dark"] .btn-light,
html[data-bs-theme="dark"] .btn-outline-secondary {
  background-color: #1e293b;
  color: #e2e8f0;
  border-color: rgba(148, 163, 184, 0.28);
}
html[data-bs-theme="dark"] .btn-outline-secondary:hover,
html[data-bs-theme="dark"] .btn-light:hover {
  background-color: #0f172a;
  color: #f8fafc;
}
html[data-bs-theme="dark"] .btn-link { color: var(--app-primary-on-dark, var(--app-primary)); }
html[data-bs-theme="dark"] .nav-tabs { border-color: rgba(148, 163, 184, 0.18); }
html[data-bs-theme="dark"] .nav-tabs .nav-link { color: #cbd5e1; }
html[data-bs-theme="dark"] .nav-tabs .nav-link.active {
  background: #1e293b;
  color: var(--app-primary-on-dark, var(--app-primary));
  border-color: rgba(148, 163, 184, 0.18) rgba(148, 163, 184, 0.18) #1e293b;
}
html[data-bs-theme="dark"] .breadcrumb { background: transparent; }
html[data-bs-theme="dark"] .alert-light {
  background: #1e293b;
  color: #e2e8f0;
  border-color: rgba(148, 163, 184, 0.18);
}

/* ── البحث في الشريط العلوي ── */
html[data-bs-theme="dark"] .ws-topbar-search input,
html[data-bs-theme="dark"] .ws-search-mobile-header input {
  background: #0f172a;
  border-color: rgba(148, 163, 184, 0.28);
  color: #e2e8f0;
}
html[data-bs-theme="dark"] .ws-search-dropdown,
html[data-bs-theme="dark"] .ws-search-mobile-panel,
html[data-bs-theme="dark"] .ws-search-group-label {
  background: #1e293b;
  border-color: rgba(148, 163, 184, 0.18);
  color: #e2e8f0;
}
html[data-bs-theme="dark"] .ws-search-result { border-bottom-color: rgba(148, 163, 184, 0.12); }
html[data-bs-theme="dark"] .ws-search-result-sub,
html[data-bs-theme="dark"] .ws-topbar-search > i { color: #94a3b8; }

/* ── الصفحة الرئيسية ── */
html[data-bs-theme="dark"] .hd {
  --bg: #0b1120;
  --card: #1e293b;
  --ink: #e2e8f0;
  --ink2: #cbd5e1;
  --muted: #94a3b8;
  --line: rgba(148, 163, 184, 0.18);
  --sh: 0 1px 2px rgba(0, 0, 0, 0.3), 0 8px 24px rgba(0, 0, 0, 0.28);
  --ok: #4ade80;
  --ok-l: rgba(22, 163, 74, 0.18);
  --warn: #fbbf24;
  --warn-l: rgba(217, 119, 6, 0.18);
  --bad: #f87171;
  --bad-l: rgba(220, 38, 38, 0.18);
  --info: #60a5fa;
  --info-l: rgba(37, 99, 235, 0.18);
  --vio: #c4b5fd;
  --vio-l: rgba(124, 58, 237, 0.18);
  --pink: #f9a8d4;
  --pink-l: rgba(219, 39, 119, 0.18);
}
html[data-bs-theme="dark"] .hd-card {
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.04), transparent 42%) padding-box,
    linear-gradient(var(--card), var(--card)) padding-box,
    var(--edge) border-box;
}
html[data-bs-theme="dark"] .hd-link,
html[data-bs-theme="dark"] .hd-card-h h3 > i,
html[data-bs-theme="dark"] .hd-cmd > i,
html[data-bs-theme="dark"] .hd-cmd-res a i,
html[data-bs-theme="dark"] .hd-pill.p,
html[data-bs-theme="dark"] .hd-ov h2 i {
  color: var(--app-primary-on-dark, var(--p)) !important;
}
html[data-bs-theme="dark"] .hd-btn:not(.pr):not(.ok) {
  background: #0f172a;
  color: #e2e8f0;
}
html[data-bs-theme="dark"] .hd-btn.pr {
  background: var(--app-button-on-dark, var(--p));
  border-color: var(--app-button-on-dark, var(--p));
}
html[data-bs-theme="dark"] .hd-glass .hd-btn {
  background: #fff;
  color: var(--p-d) !important;
}
html[data-bs-theme="dark"] .hd-cmd,
html[data-bs-theme="dark"] .hd-fav {
  background: linear-gradient(var(--card), var(--card)) padding-box, var(--edge) border-box;
}
html[data-bs-theme="dark"] .hd-cmd-res,
html[data-bs-theme="dark"] .hd-punch-card { background: #1e293b; }
html[data-bs-theme="dark"] .hd-punch-x { background: #0f172a; color: #e2e8f0; }
html[data-bs-theme="dark"] .hd-prog,
html[data-bs-theme="dark"] .hd-stackbar { background: #0f172a; }
html[data-bs-theme="dark"] .hd-pill.gray,
html[data-bs-theme="dark"] .hd-ic.gray,
html[data-bs-theme="dark"] .hd-av.out { background: #0f172a; color: #cbd5e1; }
html[data-bs-theme="dark"] .hd-av { box-shadow: 0 0 0 2px var(--card), 0 0 0 4px var(--ok); }
html[data-bs-theme="dark"] .hd-av.leave { box-shadow: 0 0 0 2px var(--card), 0 0 0 4px var(--warn); }
html[data-bs-theme="dark"] .hd-av.out { box-shadow: 0 0 0 2px var(--card), 0 0 0 4px #475569; }
html[data-bs-theme="dark"] .hd-tl-i::before { background: var(--card); }
html[data-bs-theme="dark"] .hd-week tr.t0 td { background: rgba(22, 163, 74, 0.18); color: #86efac; }
html[data-bs-theme="dark"] .hd-week tr.t1 td { background: rgba(37, 99, 235, 0.18); color: #93c5fd; }
html[data-bs-theme="dark"] .hd-week tr.t2 td { background: rgba(217, 119, 6, 0.18); color: #fcd34d; }
html[data-bs-theme="dark"] .hd-week tr.t3 td { background: rgba(124, 58, 237, 0.18); color: #c4b5fd; }
html[data-bs-theme="dark"] .hd-week tr.t4 td { background: rgba(219, 39, 119, 0.18); color: #f9a8d4; }

/* ── تسجيل الدخول: عمود النموذج فقط. لوحة الهوية والشعار يبقيان ── */
html[data-bs-theme="dark"] body.login-page { background: #0b1120; }
html[data-bs-theme="dark"] .login-form-panel {
  background:
    radial-gradient(ellipse at 20% 0%, rgba(var(--app-primary-rgb, 13, 110, 253), 0.16) 0%, transparent 55%),
    #0b1120;
}
html[data-bs-theme="dark"] .login-card,
html[data-bs-theme="dark"] .login-mobile-brand {
  background: #1e293b;
  border-color: rgba(148, 163, 184, 0.18);
  color: #e2e8f0;
}
html[data-bs-theme="dark"] .login-card-title { color: #e2e8f0; }
html[data-bs-theme="dark"] .login-card-desc,
html[data-bs-theme="dark"] .login-field label { color: #94a3b8; }
html[data-bs-theme="dark"] .login-mobile-tagline { color: var(--app-primary-on-dark, var(--app-primary)); }
html[data-bs-theme="dark"] .login-input-wrap .form-control,
html[data-bs-theme="dark"] .login-input-wrap .form-control:focus {
  background: #0f172a;
  border-color: rgba(148, 163, 184, 0.28);
  color: #e2e8f0;
}

/* ── تفضيلات العرض ── */
html[data-bs-theme="dark"] .dp-section,
html[data-bs-theme="dark"] .dp-scale-card,
html[data-bs-theme="dark"] .dp-density-card,
html[data-bs-theme="dark"] .dp-access-card,
html[data-bs-theme="dark"] .dp-preview-panel,
html[data-bs-theme="dark"] .dp-pin {
  background: #1e293b;
  border-color: rgba(148, 163, 184, 0.18);
  color: #e2e8f0;
}
html[data-bs-theme="dark"] .dp-preview-panel__head {
  background: #111827;
  color: #e2e8f0;
  border-bottom-color: rgba(148, 163, 184, 0.18);
}
html[data-bs-theme="dark"] .dp-preview-panel__body { background: #0f172a; }
html[data-bs-theme="dark"] .dp-preview-title,
html[data-bs-theme="dark"] .dp-scale-card__title,
html[data-bs-theme="dark"] .dp-density-card__title,
html[data-bs-theme="dark"] .dp-access-card__title { color: #e2e8f0; }
html[data-bs-theme="dark"] .dp-preview-body,
html[data-bs-theme="dark"] .dp-section__hint,
html[data-bs-theme="dark"] .dp-scale-card__desc,
html[data-bs-theme="dark"] .dp-density-card__desc { color: #94a3b8; }

/* الطباعة تبقى فاتحة */
@media print {
  html[data-bs-theme="dark"] { color-scheme: light; }
  html[data-bs-theme="dark"] body,
  html[data-bs-theme="dark"] .app-wrapper,
  html[data-bs-theme="dark"] .main-wrapper,
  html[data-bs-theme="dark"] .main-content,
  html[data-bs-theme="dark"] .card,
  html[data-bs-theme="dark"] .hd-card,
  html[data-bs-theme="dark"] .hd-fav,
  html[data-bs-theme="dark"] .hd-cmd {
    background: #fff !important;
    color: #0f172a !important;
  }
}
