/* ==========================================================================
   ds-components.css — Unified Design System · Shared Components
   يُحمَّل بعد CSS القسم وfonts.css ليحكم الشكل في الأقسام التسعة.
   الأولوية: `html body` + !important على الخصائص البصرية فقط
   (لا يمسّ العرض/الإظهار/الوظائف).
   ========================================================================== */

/* ---------- Base ---------- */
html body {
    font-family: var(--ds-font);
    font-size: var(--ds-fs-base);
    line-height: var(--ds-lh);
    color: var(--ds-text);
    background: var(--ds-bg) !important;
    background-image: none !important;
}
html, body { max-width: 100%; overflow-x: hidden; }
html body *, html body *::before, html body *::after { box-sizing: border-box; }
html body ::selection { background: var(--ds-primary-soft); color: var(--ds-primary-text); }

/* شريط تمرير هادئ */
html body * { scrollbar-width: thin; scrollbar-color: var(--ds-border-strong) transparent; }
html body ::-webkit-scrollbar { width: 8px; height: 8px; }
html body ::-webkit-scrollbar-thumb { background: var(--ds-border-strong); border-radius: 8px; }
html body ::-webkit-scrollbar-track { background: transparent; }

/* ==========================================================================
   1) MODAL COMPONENT  (.modal / .modal-dialog / .modal-content …)
   ========================================================================== */
html body .modal-backdrop {
    --bs-backdrop-bg: #1e293b;
    --bs-backdrop-opacity: 0.42;
    backdrop-filter: none !important;
    -webkit-backdrop-filter: none !important;
}

/* نظام الأحجام: sm / md / lg / xl / full */
html body .modal .modal-dialog {
    --bs-modal-width: var(--ds-modal-md);
    --bs-modal-margin: var(--ds-modal-gap);
    --ds-z: calc(var(--ds-modal-zoom) * var(--ds-fit, 1));   /* المقياس الفعلي للنافذة */
    zoom: var(--ds-z) !important;
    width: 100%;
    /* الأبعاد المحلية تُقسَم على المقياس كي تطابق أبعاد الشاشة الحقيقية */
    max-width: min(var(--bs-modal-width), calc((100vw - 2 * var(--ds-modal-gap)) / var(--ds-z))) !important;
    margin: calc(var(--ds-modal-gap) / var(--ds-z)) auto !important;
    display: flex;
    align-items: center;
    height: auto !important;               /* الارتفاع = المحتوى، لا ارتفاع ثابت */
    min-height: 0 !important;
}
html body .modal .modal-dialog.modal-sm,
html body .modal .modal-dialog[data-ds-size="sm"]  { --bs-modal-width: var(--ds-modal-sm); }
html body .modal .modal-dialog.modal-lg,
html body .modal .modal-dialog[data-ds-size="lg"]  { --bs-modal-width: var(--ds-modal-lg); }
html body .modal .modal-dialog.modal-xl,
html body .modal .modal-dialog.clay-merged-dialog,
html body .modal .modal-dialog[data-ds-size="xl"]  { --bs-modal-width: var(--ds-modal-xl); }
html body .modal .modal-dialog[data-ds-size="md"]  { --bs-modal-width: var(--ds-modal-md); }
html body .modal .modal-dialog.modal-fullscreen,
html body .modal .modal-dialog[data-ds-size="full"] {
    --bs-modal-width: 100vw;
    max-width: 100vw !important;
    margin: 0 auto !important;
    height: 100%;
    min-height: 100%;
}
html body .modal .modal-dialog.modal-fullscreen .modal-content,
html body .modal .modal-dialog[data-ds-size="full"] .modal-content { border-radius: 0 !important; height: 100%; }

/* ارتفاع النافذة يتبع محتواها دائماً، وسقفه ارتفاع شاشة الجهاز.
   إن تجاوز المحتوى السقف يصغّره ds.js تلقائياً ليظهر كاملاً دفعة واحدة. */
html body .modal .modal-dialog-scrollable .modal-content,
html body .modal .modal-content {
    max-height: calc((100dvh - 2 * var(--ds-modal-gap)) / var(--ds-z, 1));
}
html body .modal .modal-dialog-scrollable .modal-body { overflow-y: auto; }

html body .modal .modal-content {
    background: var(--ds-surface) !important;
    background-image: none !important;
    color: var(--ds-text);
    border: 1px solid var(--ds-border) !important;
    border-radius: var(--ds-radius-lg) !important;
    box-shadow: var(--ds-shadow-lg) !important;
    overflow: hidden;
    width: 100%;
}

/* رأس النافذة الموحّد */
html body .modal .modal-header {
    display: flex;
    align-items: center;
    gap: var(--ds-space-3);
    padding: var(--ds-space-4) var(--ds-space-5) !important;
    background: var(--ds-surface) !important;
    background-image: none !important;
    color: var(--ds-text) !important;
    border: 0 !important;
    border-bottom: 1px solid var(--ds-border) !important;
    border-radius: 0 !important;
    box-shadow: none !important;
}
html body .modal .modal-header .modal-title,
html body .modal .modal-header .modal-title.text-white,
html body .modal .modal-header .modal-title.text-primary,
html body .modal .modal-header .modal-title.text-dark,
html body .modal .modal-header h1, html body .modal .modal-header h2,
html body .modal .modal-header h3, html body .modal .modal-header h4,
html body .modal .modal-header h5, html body .modal .modal-header h6 {
    margin: 0;
    flex: 1 1 auto;
    min-width: 0;
    font-family: var(--ds-font);
    font-size: var(--ds-modal-title-fs, var(--ds-fs-lg)) !important;
    font-weight: var(--ds-fw-bold) !important;
    line-height: 1.4;
    color: var(--ds-text) !important;
    overflow-wrap: anywhere;
}
/* أيقونة النافذة: نفس اللون والحجم في كل مكان */
html body .modal .modal-header .modal-title > i,
html body .modal .modal-header .modal-title > .fas,
html body .modal .modal-header .modal-title > .fa-solid {
    color: var(--ds-primary) !important;
    font-size: 1em;
    margin-inline-end: var(--ds-space-2) !important;
    margin-inline-start: 0 !important;
}

/* زر الإغلاق الموحّد */
html body .modal .btn-close,
html body .swal2-container .swal2-close {
    position: relative;
    flex: 0 0 auto;
    width: 34px !important;
    height: 34px !important;
    padding: 0 !important;
    margin: 0 !important;
    margin-inline-start: auto !important;
    opacity: 1 !important;
    border: 0 !important;
    border-radius: var(--ds-radius-md) !important;
    background: var(--ds-surface-3) !important;
    background-image: none !important;
    filter: none !important;
    box-shadow: none !important;
    transition: background-color .15s ease;
}
html body .modal .btn-close::before {
    content: "";
    position: absolute;
    inset: 0;
    margin: auto;
    width: 12px;
    height: 12px;
    background: var(--ds-text-muted);
    -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3E%3Cpath d='M2.5 2.5l11 11M13.5 2.5l-11 11' stroke='black' stroke-width='2.2' stroke-linecap='round'/%3E%3C/svg%3E") center / contain no-repeat;
            mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3E%3Cpath d='M2.5 2.5l11 11M13.5 2.5l-11 11' stroke='black' stroke-width='2.2' stroke-linecap='round'/%3E%3C/svg%3E") center / contain no-repeat;
}
html body .modal .btn-close:hover { background: var(--ds-danger-soft) !important; }
html body .modal .btn-close:hover::before { background: var(--ds-danger-text); }
html body .modal .btn-close:focus-visible { box-shadow: var(--ds-focus-ring) !important; outline: 0; }

/* جسم النافذة */
html body .modal .modal-body {
    padding: var(--ds-space-5);
    background: var(--ds-surface) !important;
    color: var(--ds-text);
    overflow-x: auto;
}

/* تذييل النافذة: أزرار الحفظ والإلغاء والحذف */
html body .modal .modal-footer {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: flex-end;
    gap: var(--ds-space-2);
    padding: var(--ds-space-3) var(--ds-space-5) !important;
    background: var(--ds-surface-2) !important;
    background-image: none !important;
    border: 0 !important;
    border-top: 1px solid var(--ds-border) !important;
    border-radius: 0 !important;
    box-shadow: none !important;
}
html body .modal .modal-footer > * { margin: 0 !important; }
html body .modal .modal-footer.justify-content-between { justify-content: space-between; }

/* ==========================================================================
   2) BUTTON COMPONENT
   ========================================================================== */
html body .btn {
    font-family: var(--ds-font);
    font-weight: var(--ds-fw-medium);
    line-height: 1.5;
    box-shadow: none !important;
    text-shadow: none !important;
    transform: none;
    transition: background-color .15s ease, border-color .15s ease, color .15s ease;
}
html body .btn:not(.btn-group > .btn):not(.btn-group-vertical > .btn):not(.rounded-pill):not(.rounded-circle):not(.rounded-0) {
    border-radius: var(--ds-radius-md) !important;
}
html body .btn:not(.btn-sm):not(.btn-xs):not(.btn-lg) {
    min-height: var(--ds-control-h);
    padding: 0.45rem 1rem;
    font-size: var(--ds-fs-base);
}
html body .btn.btn-sm { font-size: var(--ds-fs-sm); }
html body .btn:focus-visible { outline: 0; box-shadow: var(--ds-focus-ring) !important; }
html body .btn:disabled, html body .btn.disabled { opacity: .55; }

/* Primary */
html body .btn-primary { background: var(--ds-primary) !important; border: 1px solid var(--ds-primary) !important; color: #fff !important; }
html body .btn-primary:hover, html body .btn-primary:active, html body .btn-primary:focus { background: var(--ds-primary-hover) !important; border-color: var(--ds-primary-hover) !important; color: #fff !important; }
html body .btn-outline-primary { background: transparent !important; border: 1px solid var(--ds-primary) !important; color: var(--ds-primary) !important; }
html body .btn-outline-primary:hover, html body .btn-outline-primary:active, html body .btn-outline-primary.active { background: var(--ds-primary-soft) !important; color: var(--ds-primary-text) !important; }

/* Secondary / neutral */
html body .btn-secondary { background: var(--ds-secondary-soft) !important; border: 1px solid var(--ds-border) !important; color: var(--ds-secondary-text) !important; }
html body .btn-light, html body .btn-white, html body .btn-outline-secondary, html body .btn-outline-dark, html body .btn-outline-light {
    background: var(--ds-surface) !important; border: 1px solid var(--ds-border-strong) !important; color: var(--ds-secondary-text) !important;
}
html body .btn-secondary:hover, html body .btn-light:hover, html body .btn-white:hover,
html body .btn-outline-secondary:hover, html body .btn-outline-dark:hover, html body .btn-outline-light:hover,
html body .btn-outline-secondary.active, html body .btn-light.active {
    background: var(--ds-surface-3) !important; color: var(--ds-text) !important; border-color: var(--ds-border-strong) !important;
}

/* Success */
html body .btn-success { background: var(--ds-success) !important; border: 1px solid var(--ds-success) !important; color: #fff !important; }
html body .btn-success:hover { filter: brightness(.94); }
html body .btn-outline-success { background: transparent !important; border: 1px solid var(--ds-success) !important; color: var(--ds-success-text) !important; }
html body .btn-outline-success:hover, html body .btn-outline-success.active { background: var(--ds-success-soft) !important; }

/* Warning */
html body .btn-warning { background: var(--ds-warning) !important; border: 1px solid var(--ds-warning) !important; color: #5c4208 !important; }
html body .btn-warning:hover { filter: brightness(.95); }
html body .btn-outline-warning { background: transparent !important; border: 1px solid var(--ds-warning) !important; color: var(--ds-warning-text) !important; }
html body .btn-outline-warning:hover, html body .btn-outline-warning.active { background: var(--ds-warning-soft) !important; }

/* Danger */
html body .btn-danger { background: var(--ds-danger) !important; border: 1px solid var(--ds-danger) !important; color: #fff !important; }
html body .btn-danger:hover { background: var(--ds-danger-hover) !important; border-color: var(--ds-danger-hover) !important; }
html body .btn-outline-danger { background: transparent !important; border: 1px solid var(--ds-danger) !important; color: var(--ds-danger-text) !important; }
html body .btn-outline-danger:hover, html body .btn-outline-danger.active { background: var(--ds-danger-soft) !important; }

/* Info */
html body .btn-info, html body .btn-outline-info { background: var(--ds-primary-soft) !important; border: 1px solid transparent !important; color: var(--ds-primary-text) !important; }
html body .btn-info:hover, html body .btn-outline-info:hover { filter: brightness(.97); }

/* Link */
html body .btn-link { color: var(--ds-primary) !important; background: transparent !important; border-color: transparent !important; }

/* مجموعات الأزرار */
html body .btn-group { box-shadow: none !important; }
html body .btn-check:checked + .btn { background: var(--ds-primary-soft) !important; border-color: var(--ds-primary) !important; color: var(--ds-primary-text) !important; }

/* ==========================================================================
   3) FORM / INPUT / SELECT COMPONENTS
   ========================================================================== */
html body .form-label, html body label.form-label {
    font-size: var(--ds-fs-sm);
    font-weight: var(--ds-fw-medium);
    color: var(--ds-secondary-text) !important;
    margin-bottom: var(--ds-space-1);
}
html body .form-control,
html body .form-select,
html body .input-group-text,
html body textarea.form-control,
html body .clay-select {
    font-family: var(--ds-font);
    font-size: var(--ds-fs-base);
    color: var(--ds-text) !important;
    background-color: var(--ds-surface) !important;
    border: 1px solid var(--ds-border-strong) !important;
    border-radius: var(--ds-radius-md) !important;
    box-shadow: none !important;
    transition: border-color .15s ease, box-shadow .15s ease;
}
html body .form-control:not(textarea):not(.form-control-sm):not(.form-control-lg),
html body .form-select:not(.form-select-sm):not(.form-select-lg) { min-height: var(--ds-control-h); }
html body .form-control::placeholder { color: var(--ds-text-muted); opacity: .8; }
html body .form-control:focus, html body .form-select:focus, html body .clay-select:focus {
    border-color: var(--ds-primary) !important;
    box-shadow: var(--ds-focus-ring) !important;
    outline: 0;
}
html body .form-control:disabled, html body .form-control[readonly], html body .form-select:disabled {
    background-color: var(--ds-surface-3) !important;
    color: var(--ds-text-muted) !important;
}
html body .form-control.is-invalid, html body .form-select.is-invalid { border-color: var(--ds-danger) !important; background-image: none; }
html body .form-control.is-valid, html body .form-select.is-valid { border-color: var(--ds-success) !important; background-image: none; }
html body .invalid-feedback { color: var(--ds-danger-text); font-size: var(--ds-fs-xs); }
html body .form-check-input { border-color: var(--ds-border-strong); box-shadow: none !important; }
html body .form-check-input:checked { background-color: var(--ds-primary); border-color: var(--ds-primary); }
html body .form-check-input:focus { box-shadow: var(--ds-focus-ring) !important; border-color: var(--ds-primary); }
html body .form-switch .form-check-input:checked { background-color: var(--ds-primary); }
html body .input-group > .form-control, html body .input-group > .form-select { min-height: var(--ds-control-h); }
html body .input-group-text { background: var(--ds-surface-3) !important; color: var(--ds-text-muted) !important; }

/* حقل البحث الموحّد (Search Component) */
html body .ds-search { position: relative; display: flex; align-items: center; }
html body .ds-search > i { position: absolute; inset-inline-start: .85rem; color: var(--ds-text-muted); pointer-events: none; }
html body .ds-search > .form-control { padding-inline-start: 2.4rem; }

/* ==========================================================================
   4) CARD / TOOLBAR COMPONENTS
   ========================================================================== */
html body .card,
html body .clay-card,
html body .clay-container,
html body .clay-master-container {
    background: var(--ds-surface) !important;
    background-image: none !important;
    border: 1px solid var(--ds-border) !important;
    border-radius: var(--ds-radius-lg) !important;
    box-shadow: var(--ds-shadow-sm) !important;
    color: var(--ds-text);
}
html body .card:hover, html body .clay-card:hover { box-shadow: var(--ds-shadow-md) !important; transform: none !important; }
html body .card-header { background: var(--ds-surface-2) !important; border-bottom: 1px solid var(--ds-border) !important; }
html body .card-footer { background: var(--ds-surface-2) !important; border-top: 1px solid var(--ds-border) !important; }

html body .ds-toolbar {
    display: flex; flex-wrap: wrap; align-items: center; gap: var(--ds-space-2);
    padding: var(--ds-space-3); background: var(--ds-surface);
    border: 1px solid var(--ds-border); border-radius: var(--ds-radius-lg);
}

/* ==========================================================================
   5) DATA TABLE COMPONENT
   ========================================================================== */
html body .table {
    --bs-table-bg: transparent;
    --bs-table-color: var(--ds-text);
    --bs-table-border-color: var(--ds-border);
    --bs-table-striped-bg: var(--ds-surface-2);
    --bs-table-hover-bg: var(--ds-primary-soft);
    color: var(--ds-text);
    border-color: var(--ds-border);
    margin-bottom: 0;
}
html body .table > thead > tr > th,
html body .table > thead th,
html body .clay-th-pill {
    background: var(--ds-surface-2) !important;
    color: var(--ds-secondary-text) !important;
    font-size: var(--ds-fs-sm);
    font-weight: var(--ds-fw-bold);
    border-bottom: 1px solid var(--ds-border-strong) !important;
    box-shadow: none !important;
}
html body .table > tbody > tr > td { vertical-align: middle; border-color: var(--ds-border); }
html body .table-responsive, html body .clay-table-tray {
    border: 1px solid var(--ds-border);
    border-radius: var(--ds-radius-md);
    background: var(--ds-surface);
    box-shadow: none !important;
    -webkit-overflow-scrolling: touch;
}

/* ==========================================================================
   6) NAV / TABS COMPONENT
   ========================================================================== */
html body .main-tabs-card {
    background: var(--ds-surface) !important;
    border: 1px solid var(--ds-border) !important;
    border-radius: var(--ds-radius-lg) !important;
    box-shadow: var(--ds-shadow-xs) !important;
}
html body .nav-pills .nav-link,
html body .custom-main-tabs .nav-link {
    color: var(--ds-secondary-text) !important;
    background: transparent !important;
    border: 1px solid transparent !important;
    border-radius: var(--ds-radius-md) !important;
    box-shadow: none !important;
    font-weight: var(--ds-fw-medium);
    transform: none !important;
}
html body .nav-pills .nav-link:hover,
html body .custom-main-tabs .nav-link:hover { background: var(--ds-surface-3) !important; color: var(--ds-text) !important; }
html body .nav-pills .nav-link.active,
html body .custom-main-tabs .nav-link.active,
html body .nav-pills .show > .nav-link {
    background: var(--ds-primary-soft) !important;
    color: var(--ds-primary-text) !important;
    border-color: transparent !important;
}
html body .custom-main-tabs .nav-link i { color: inherit !important; }
html body .nav-tabs .nav-link.active { color: var(--ds-primary-text); border-color: var(--ds-border) var(--ds-border) var(--ds-surface); }

/* ==========================================================================
   7) DROPDOWN COMPONENT
   ========================================================================== */
html body .dropdown-menu {
    background: var(--ds-surface) !important;
    border: 1px solid var(--ds-border) !important;
    border-radius: var(--ds-radius-md) !important;
    box-shadow: var(--ds-shadow-md) !important;
    padding: var(--ds-space-1) !important;
}
html body .dropdown-item { color: var(--ds-text); border-radius: var(--ds-radius-sm) !important; font-size: var(--ds-fs-base); }
html body .dropdown-item:hover, html body .dropdown-item:focus { background: var(--ds-primary-soft); color: var(--ds-primary-text); }
html body .dropdown-item.active, html body .dropdown-item:active { background: var(--ds-primary); color: #fff; }
html body .dropdown-divider { border-color: var(--ds-border); }

/* ==========================================================================
   8) ALERT / BADGE COMPONENTS
   ========================================================================== */
html body .alert { border-radius: var(--ds-radius-md); border: 1px solid transparent; box-shadow: none; }
html body .alert-primary, html body .alert-info    { background: var(--ds-primary-soft); color: var(--ds-primary-text); border-color: rgba(63,120,194,.18); }
html body .alert-success { background: var(--ds-success-soft); color: var(--ds-success-text); border-color: rgba(47,158,110,.2); }
html body .alert-warning { background: var(--ds-warning-soft); color: var(--ds-warning-text); border-color: rgba(240,190,77,.35); }
html body .alert-danger  { background: var(--ds-danger-soft);  color: var(--ds-danger-text);  border-color: rgba(214,95,95,.22); }
html body .badge { font-weight: var(--ds-fw-medium); box-shadow: none !important; }
html body .badge.bg-primary { background: var(--ds-primary-soft) !important; color: var(--ds-primary-text) !important; }
html body .badge.bg-success { background: var(--ds-success-soft) !important; color: var(--ds-success-text) !important; }
html body .badge.bg-warning { background: var(--ds-warning-soft) !important; color: var(--ds-warning-text) !important; }
html body .badge.bg-danger  { background: var(--ds-danger-soft)  !important; color: var(--ds-danger-text)  !important; }
html body .badge.bg-secondary, html body .badge.bg-light { background: var(--ds-secondary-soft) !important; color: var(--ds-secondary-text) !important; }

/* ==========================================================================
   9) CONFIRMATION DIALOG  (SweetAlert2 → نفس شكل Modal الموحّد)
   ========================================================================== */
html body .swal2-container:not(:has(.swal2-toast)):not(.swal2-top-start):not(.swal2-top-end):not(.swal2-top):not(.swal2-bottom-start):not(.swal2-bottom-end):not(.swal2-bottom):not(.swal2-center-start):not(.swal2-center-end) {
    padding: var(--ds-modal-gap) !important;
    background: var(--ds-overlay) !important;
}

/* SweetAlert2 Toast Container: MUST be completely transparent and non-blocking */
html body .swal2-container:has(.swal2-toast),
html body .swal2-container.swal2-top-start,
html body .swal2-container.swal2-top-end,
html body .swal2-container.swal2-top,
html body .swal2-container.swal2-bottom-start,
html body .swal2-container.swal2-bottom-end,
html body .swal2-container.swal2-bottom,
html body .swal2-container.swal2-center-start,
html body .swal2-container.swal2-center-end,
.swal2-container.swal2-top-start,
.swal2-container.swal2-top-end,
.swal2-container:has(.swal2-toast) {
    background: transparent !important;
    background-color: transparent !important;
    box-shadow: none !important;
    pointer-events: none !important;
}

html body .swal2-container .swal2-popup.swal2-toast {
    pointer-events: auto !important;
}
html body .swal2-popup {
    width: min(var(--ds-modal-sm), 100%) !important;
    max-width: 100% !important;
    padding: var(--ds-space-6) var(--ds-space-5) var(--ds-space-5) !important;
    font-family: var(--ds-font) !important;
    background: var(--ds-surface) !important;
    color: var(--ds-text) !important;
    border: 1px solid var(--ds-border) !important;
    border-radius: var(--ds-radius-lg) !important;
    box-shadow: var(--ds-shadow-lg) !important;
}
/* التنبيهات التي تحتوي نماذج/جداول (حقول، HTML مخصّص) تأخذ حجم Medium ما لم تكن كبيرة ds-swal-xl */
html body .swal2-popup.ds-swal-md,
html body .swal2-popup:not(.ds-swal-xl):not(.sup-teachers-selection-dialog):not(.sub-teachers-selection-dialog):not(.nisab-distribution-dialog):has(.swal2-html-container form),
html body .swal2-popup:not(.ds-swal-xl):not(.sup-teachers-selection-dialog):not(.sub-teachers-selection-dialog):not(.nisab-distribution-dialog):has(.swal2-html-container .form-control),
html body .swal2-popup:not(.ds-swal-xl):not(.sup-teachers-selection-dialog):not(.sub-teachers-selection-dialog):not(.nisab-distribution-dialog):has(.swal2-html-container .form-select) { width: min(var(--ds-modal-md), 100%) !important; }
html body .swal2-popup.ds-swal-lg, html body .swal2-popup:not(.ds-swal-xl):not(.sup-teachers-selection-dialog):not(.sub-teachers-selection-dialog):not(.nisab-distribution-dialog):has(.swal2-html-container table) { width: min(var(--ds-modal-lg), 100%) !important; }
html body .swal2-popup.ds-swal-xl,
html body .swal2-popup.sup-teachers-selection-dialog,
html body .swal2-popup.sub-teachers-selection-dialog,
html body .swal2-popup.ds-swal-xl:has(*),
html body .swal2-popup.sup-teachers-selection-dialog:has(*),
html body .swal2-popup.sub-teachers-selection-dialog:has(*) {
    width: min(1040px, calc(100vw - 2rem)) !important;
    max-width: min(1040px, calc(100vw - 2rem)) !important;
}
html body .swal2-popup.sup-teachers-selection-dialog .swal2-html-container,
html body .swal2-popup.sub-teachers-selection-dialog .swal2-html-container,
html body .swal2-popup.nisab-distribution-dialog .swal2-html-container {
    max-height: none !important;
    overflow: visible !important;
    padding: 0 !important;
    margin: 0 !important;
}

/* نوافذ توزيع النصاب الذكي */
html body .swal2-popup.nisab-distribution-dialog {
    width: min(660px, calc(100vw - 2rem)) !important;
    max-width: min(660px, calc(100vw - 2rem)) !important;
    padding: 1.35rem 1.5rem !important;
    border-radius: 20px !important;
}

.nisab-choice-card {
    border: 1.5px solid #e2e8f0 !important;
    border-radius: 14px !important;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1) !important;
    background: #ffffff !important;
    cursor: pointer;
}

.nisab-choice-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 20px rgba(0, 0, 0, 0.08) !important;
}

.nisab-choice-card.nisab-card-clean:hover {
    border-color: #10b981 !important;
    background: #f0fdf4 !important;
}

.nisab-choice-card.nisab-card-remaining:hover {
    border-color: #0284c7 !important;
    background: #f0f9ff !important;
}

.nisab-rules-details {
    background: #f8fafc;
    border: 1px solid #e2e8f0;
    border-radius: 12px;
    padding: 0.65rem 0.9rem;
    transition: all 0.2s ease;
}

.nisab-rules-details[open] {
    background: #ffffff;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.04);
}

.nisab-rules-details summary {
    cursor: pointer;
    user-select: none;
    font-size: 0.82rem;
    font-weight: 700;
}

/* بطاقات اختيار معلمي المراقبة والبدلاء المتجاوبة */
.sup-teacher-card,
.sub-teacher-card {
    background: #ffffff;
    border: 1.5px solid #e2e8f0 !important;
    border-radius: 12px !important;
    transition: all 0.18s cubic-bezier(0.4, 0, 0.2, 1);
    user-select: none;
    min-height: 56px;
}

.sup-teacher-card:hover,
.sub-teacher-card:hover {
    border-color: #cbd5e1 !important;
    background: #f8fafc;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.05);
}

.sub-teacher-card.sub-card-active {
    background: linear-gradient(135deg, #f5f7ff 0%, #eef2ff 100%) !important;
    border-color: #6366f1 !important;
    box-shadow: 0 4px 12px rgba(99, 102, 241, 0.15) !important;
}

.sub-teacher-card.sub-card-active .sub-teacher-avatar {
    background: linear-gradient(135deg, #6366f1, #4f46e5) !important;
    color: #ffffff !important;
    box-shadow: 0 2px 6px rgba(99, 102, 241, 0.3) !important;
}

.sub-teacher-card .form-check-input:checked {
    background-color: #6366f1 !important;
    border-color: #6366f1 !important;
}

.sub-teacher-card .form-check-input {
    cursor: pointer;
    border-width: 1.5px;
}

.sub-btn-action {
    transition: all 0.15s ease;
}

.sub-btn-action:hover {
    transform: translateY(-1px);
}
html body .swal2-title { font-family: var(--ds-font) !important; font-size: var(--ds-fs-lg) !important; font-weight: var(--ds-fw-bold) !important; color: var(--ds-text) !important; padding: 0 !important; margin: var(--ds-space-2) 0 var(--ds-space-1) !important; }
html body .swal2-html-container { font-family: var(--ds-font) !important; font-size: var(--ds-fs-base) !important; color: var(--ds-text-muted) !important; margin: var(--ds-space-2) 0 0 !important; overflow-wrap: anywhere; max-height: 60dvh; overflow-y: auto; }
html body .swal2-actions { gap: var(--ds-space-2) !important; margin-top: var(--ds-space-5) !important; flex-wrap: wrap; }
html body .swal2-styled {
    font-family: var(--ds-font) !important; font-weight: var(--ds-fw-medium) !important; font-size: var(--ds-fs-base) !important;
    min-height: var(--ds-control-h); margin: 0 !important; padding: .45rem 1.1rem !important;
    border-radius: var(--ds-radius-md) !important; border: 1px solid transparent !important; box-shadow: none !important;
}
html body .swal2-styled:focus { box-shadow: var(--ds-focus-ring) !important; }
html body .swal2-styled.swal2-confirm { background: var(--ds-primary) !important; color: #fff !important; border-color: var(--ds-primary) !important; }
html body .swal2-styled.swal2-confirm[data-ds-tone="danger"]  { background: var(--ds-danger) !important;  border-color: var(--ds-danger) !important; }
html body .swal2-styled.swal2-confirm[data-ds-tone="success"] { background: var(--ds-success) !important; border-color: var(--ds-success) !important; }
html body .swal2-styled.swal2-confirm[data-ds-tone="warning"] { background: var(--ds-warning) !important; border-color: var(--ds-warning) !important; color: #5c4208 !important; }
html body .swal2-styled.swal2-deny   { background: var(--ds-danger) !important; color: #fff !important; border-color: var(--ds-danger) !important; }
html body .swal2-styled.swal2-cancel { background: var(--ds-surface) !important; color: var(--ds-secondary-text) !important; border-color: var(--ds-border-strong) !important; }
html body .swal2-styled.swal2-cancel:hover { background: var(--ds-surface-3) !important; }
html body .swal2-input, html body .swal2-select, html body .swal2-textarea {
    font-family: var(--ds-font) !important; font-size: var(--ds-fs-base) !important; color: var(--ds-text) !important;
    background: var(--ds-surface) !important; border: 1px solid var(--ds-border-strong) !important;
    border-radius: var(--ds-radius-md) !important; box-shadow: none !important; height: var(--ds-control-h); margin: var(--ds-space-3) 0 0 !important; max-width: 100%;
}
html body .swal2-input:focus, html body .swal2-select:focus, html body .swal2-textarea:focus { border-color: var(--ds-primary) !important; box-shadow: var(--ds-focus-ring) !important; }
html body .swal2-validation-message { background: var(--ds-danger-soft) !important; color: var(--ds-danger-text) !important; border-radius: var(--ds-radius-md); }
html body .swal2-icon { transform: scale(.82); margin: var(--ds-space-2) auto 0 !important; }
html body .swal2-icon.swal2-warning  { color: var(--ds-warning-text) !important; border-color: var(--ds-warning) !important; }
html body .swal2-icon.swal2-error    { border-color: var(--ds-danger) !important; color: var(--ds-danger) !important; }
html body .swal2-icon.swal2-success  { border-color: var(--ds-success) !important; color: var(--ds-success) !important; }
html body .swal2-icon.swal2-info, html body .swal2-icon.swal2-question { border-color: var(--ds-primary) !important; color: var(--ds-primary) !important; }
html body .swal2-timer-progress-bar,
html body .swal2-timer-progress-bar-container {
    display: none !important;
    height: 0 !important;
    opacity: 0 !important;
    visibility: hidden !important;
}
/* Toast خفيف */
html body .swal2-popup.swal2-toast {
    width: auto !important;
    max-width: calc(100vw - 2rem) !important;
    padding: var(--ds-space-3) var(--ds-space-4) !important;
    box-shadow: var(--ds-shadow-md) !important;
    overflow: hidden !important;
    border: none !important;
}

/* ==========================================================================
   10) PAGINATION / LOADING / EMPTY STATE
   ========================================================================== */
html body .pagination { gap: var(--ds-space-1); }
html body .page-link {
    color: var(--ds-secondary-text); background: var(--ds-surface); border: 1px solid var(--ds-border) !important;
    border-radius: var(--ds-radius-sm) !important; min-width: var(--ds-control-h-sm); text-align: center; box-shadow: none !important;
}
html body .page-link:hover { background: var(--ds-primary-soft); color: var(--ds-primary-text); }
html body .page-item.active .page-link { background: var(--ds-primary); border-color: var(--ds-primary) !important; color: #fff; }
html body .page-item.disabled .page-link { opacity: .5; }

html body .spinner-border, html body .spinner-grow { color: var(--ds-primary); }
html body .ds-loading {
    display: flex; flex-direction: column; align-items: center; justify-content: center; gap: var(--ds-space-3);
    padding: var(--ds-space-8) var(--ds-space-4); color: var(--ds-text-muted); font-size: var(--ds-fs-sm);
}
html body .ds-loading::before {
    content: ""; width: 28px; height: 28px; border-radius: 50%;
    border: 3px solid var(--ds-primary-soft); border-top-color: var(--ds-primary); animation: ds-spin .8s linear infinite;
}
@keyframes ds-spin { to { transform: rotate(360deg); } }

html body .ds-empty {
    display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; gap: var(--ds-space-2);
    padding: var(--ds-space-8) var(--ds-space-4); color: var(--ds-text-muted);
    border: 1px dashed var(--ds-border-strong); border-radius: var(--ds-radius-lg); background: var(--ds-surface-2);
}
html body .ds-empty > i { font-size: 1.75rem; color: var(--ds-primary); opacity: .7; }
html body .ds-empty .ds-empty-title { font-weight: var(--ds-fw-bold); color: var(--ds-text); }

/* ==========================================================================
   11) Tooltips / Popovers
   ========================================================================== */
html body .tooltip { --bs-tooltip-bg: #334155; --bs-tooltip-border-radius: var(--ds-radius-sm); font-family: var(--ds-font); }
html body .popover { --bs-popover-border-color: var(--ds-border); --bs-popover-bg: var(--ds-surface); --bs-popover-border-radius: var(--ds-radius-md); font-family: var(--ds-font); box-shadow: var(--ds-shadow-md); }

/* احترام تفضيل تقليل الحركة */
@media (prefers-reduced-motion: reduce) {
    html body *, html body *::before, html body *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; }
}

/* ==========================================================================
   كثافة مدمجة داخل النوافذ على أجهزة الفأرة (لابتوب/كمبيوتر): يقلل الارتفاع الطبيعي
   للمحتوى فتتسع النافذة كاملة دفعة واحدة. أجهزة اللمس تحتفظ بالأحجام الكبيرة.
   ========================================================================== */
@media (pointer: fine) and (min-width: 768px) {
    html body .modal .modal-header { padding: var(--ds-space-3) var(--ds-space-4) !important; }
    html body .modal .modal-body   { padding: var(--ds-space-4); }
    html body .modal .modal-footer { padding: var(--ds-space-2) var(--ds-space-4) !important; }
    html body .modal .btn:not(.btn-sm):not(.btn-xs):not(.btn-lg) { min-height: 36px; padding: .3rem .9rem; }
    html body .modal .form-control:not(textarea):not(.form-control-sm):not(.form-control-lg),
    html body .modal .form-select:not(.form-select-sm):not(.form-select-lg) { min-height: 36px; padding-block: .3rem; }
    html body .modal .modal-body .mb-3 { margin-bottom: .65rem !important; }
    html body .modal .modal-body .mb-4 { margin-bottom: .9rem !important; }
    html body .modal .modal-body .form-label { margin-bottom: .2rem; }
    html body .modal .modal-body .py-4 { padding-block: 1rem !important; }
    html body .modal .modal-body .p-4 { padding: 1rem !important; }
    html body .modal .modal-body hr { margin-block: .75rem; }
}

/* ==========================================================================
   3D Slate Steel Settings Button (.header-circle-settings)
   ========================================================================== */
.header-circle-settings {
    background: linear-gradient(145deg, #cbd5e1, #64748b) !important;
    color: #ffffff !important;
    box-shadow: 0 4px 12px -2px rgba(100, 116, 139, 0.38),
        inset 2px 2px 4px rgba(255, 255, 255, 0.8),
        inset -2px -2px 4px rgba(0, 0, 0, 0.12) !important;
}

.header-circle-settings:hover {
    box-shadow: 0 6px 16px -2px rgba(100, 116, 139, 0.48),
        inset 2px 2px 4px rgba(255, 255, 255, 0.9),
        inset -2px -2px 4px rgba(0, 0, 0, 0.1) !important;
}

.header-circle-settings:active {
    box-shadow: inset 3px 3px 6px rgba(0, 0, 0, 0.25),
        inset -2px -2px 4px rgba(255, 255, 255, 0.4),
        0 2px 4px rgba(0, 0, 0, 0.08) !important;
}

[data-bs-theme="dark"] .header-circle-settings {
    background: linear-gradient(145deg, #475569, #334155) !important;
    color: #e2e8f0 !important;
    box-shadow: 0 4px 12px -2px rgba(0, 0, 0, 0.5),
        inset 1.5px 1.5px 3px rgba(255, 255, 255, 0.3),
        inset -1.5px -1.5px 3px rgba(0, 0, 0, 0.4) !important;
}
