/* ==========================================================================
   ESLM MEMBERSHIP SYSTEM - MASTER RESPONSIVE & PROFESSIONAL STYLING ENGINE
   نظام حركة تحرير شرق السودان - المحرك الشامل للتجاوب والتصميم العصري المتقدم
   متوافق مع: Django Admin + Jazzmin 3.0.5 (AdminLTE v4 + Bootstrap 5 + RTL)
   ========================================================================== */

/* --------------------------------------------------------------------------
   1. الخطوط والتهيئة العامة وتوجيه RTL
   -------------------------------------------------------------------------- */
:root {
    --eslm-navy-dark: #0f172a;
    --eslm-navy-light: #1e293b;
    --eslm-red: #dc2626;
    --eslm-red-dark: #b91c1c;
    --eslm-red-light: #ef4444;
    --eslm-bg-page: #f8fafc;
    --eslm-bg-card: #ffffff;
    --eslm-border: #e2e8f0;
    --eslm-border-dark: #cbd5e1;
    --eslm-text-main: #0f172a;
    --eslm-text-muted: #64748b;
    --eslm-font: 'Cairo', system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    --lte-sidebar-width: 280px;
}

html, body {
    max-width: 100vw !important;
    overflow-x: hidden !important;
    font-family: var(--eslm-font) !important;
    background-color: var(--eslm-bg-page) !important;
    color: var(--eslm-text-main) !important;
    direction: rtl !important;
    text-align: right !important;
    -webkit-text-size-adjust: 100%;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

*, *::before, *::after {
    font-family: inherit;
    box-sizing: border-box;
}

/* شريط تمرير المتصفح أنيق وناعم */
::-webkit-scrollbar {
    width: 6px;
    height: 6px;
}
::-webkit-scrollbar-track {
    background: #f1f5f9;
}
::-webkit-scrollbar-thumb {
    background: #cbd5e1;
    border-radius: 4px;
}
::-webkit-scrollbar-thumb:hover {
    background: #94a3b8;
}

/* --------------------------------------------------------------------------
   2. بنية لوحة الإدارة الرئيسية (AdminLTE 4 Wrapper & Main)
   -------------------------------------------------------------------------- */
.app-wrapper {
    min-height: 100vh !important;
    max-width: 100vw !important;
    background-color: var(--eslm-bg-page) !important;
}

.app-main {
    background-color: var(--eslm-bg-page) !important;
    min-height: calc(100vh - 60px) !important;
}

.app-content {
    padding: 12px 14px 40px 14px !important;
}

/* --------------------------------------------------------------------------
   3. شريط التنقل العلوي (Navbar / Header)
   -------------------------------------------------------------------------- */
.app-header.navbar {
    background: var(--eslm-navy-dark) !important;
    border-bottom: 2px solid rgba(220, 38, 38, 0.4) !important;
    box-shadow: 0 2px 12px rgba(0, 0, 0, 0.15) !important;
    min-height: 56px !important;
    padding: 0 12px !important;
}

.app-header .navbar-nav .nav-link {
    color: #e2e8f0 !important;
    font-weight: 700 !important;
    font-size: 14px !important;
    padding: 8px 14px !important;
    border-radius: 8px !important;
    transition: all 0.2s ease !important;
}

.app-header .navbar-nav .nav-link:hover {
    color: #ffffff !important;
    background-color: rgba(255, 255, 255, 0.08) !important;
}

/* زر إظهار القائمة (Hamburger) */
[data-lte-toggle="sidebar"],
[data-widget="pushmenu"] {
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    min-width: 42px !important;
    min-height: 42px !important;
    font-size: 18px !important;
    color: #ffffff !important;
    border-radius: 8px !important;
    background: rgba(255, 255, 255, 0.08) !important;
    margin-inline-end: 8px !important;
}

[data-lte-toggle="sidebar"]:hover {
    background: rgba(220, 38, 38, 0.3) !important;
    color: #ffffff !important;
}

/* حقول البحث في الشريط العلوي (على الكمبيوتر فقط) */
.app-header form.d-flex {
    margin: 0 6px !important;
}

.app-header .form-control-navbar {
    background-color: rgba(255, 255, 255, 0.1) !important;
    border: 1px solid rgba(255, 255, 255, 0.2) !important;
    color: #ffffff !important;
    border-radius: 0 8px 8px 0 !important;
    font-size: 13px !important;
    font-weight: 600 !important;
    min-width: 190px !important;
    height: 36px !important;
    transition: all 0.2s ease !important;
}

.app-header .form-control-navbar::placeholder {
    color: #94a3b8 !important;
}

.app-header .form-control-navbar:focus {
    background-color: #0f172a !important;
    border-color: var(--eslm-red) !important;
    box-shadow: 0 0 0 3px rgba(220, 38, 38, 0.25) !important;
    min-width: 220px !important;
}

.app-header .btn-navbar {
    background-color: rgba(255, 255, 255, 0.1) !important;
    border: 1px solid rgba(255, 255, 255, 0.2) !important;
    border-right: none !important;
    color: #cbd5e1 !important;
    border-radius: 8px 0 0 8px !important;
    height: 36px !important;
    padding: 0 12px !important;
}

.app-header .btn-navbar:hover {
    background-color: var(--eslm-red) !important;
    color: #ffffff !important;
}

/* قائمة المستخدم المنسدلة */
#jazzy-usermenu {
    border-radius: 12px !important;
    border: 1px solid var(--eslm-border) !important;
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.15) !important;
    overflow: hidden !important;
    min-width: 230px !important;
    padding: 6px !important;
}

#jazzy-usermenu .dropdown-header {
    font-weight: 800 !important;
    color: var(--eslm-navy-dark) !important;
    padding: 8px 12px !important;
    font-size: 13px !important;
}

#jazzy-usermenu .dropdown-item {
    font-weight: 700 !important;
    padding: 9px 12px !important;
    border-radius: 6px !important;
    font-size: 13.5px !important;
    display: flex !important;
    align-items: center !important;
    transition: background 0.15s ease !important;
}

#jazzy-usermenu .dropdown-item:hover {
    background-color: #f1f5f9 !important;
    color: var(--eslm-red) !important;
}

/* --------------------------------------------------------------------------
   4. القائمة الجانبية (Sidebar) والمظهر الاحترافي
   -------------------------------------------------------------------------- */
.app-sidebar {
    background-color: var(--eslm-navy-dark) !important;
    border-left: 1px solid rgba(255, 255, 255, 0.08) !important;
    box-shadow: -2px 0 15px rgba(0, 0, 0, 0.2) !important;
}

/* ترويسة القائمة الجانبية والعلامة التجارية */
.sidebar-brand {
    height: auto !important;
    min-height: 68px !important;
    padding: 12px 14px !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    background: #090d16 !important;
    border-bottom: 2px solid var(--eslm-red) !important;
}

.sidebar-brand .brand-link {
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    text-decoration: none !important;
    width: 100% !important;
    padding: 0 !important;
    border: none !important;
}

.sidebar-brand .brand-link img[src="None"],
.sidebar-brand .brand-link img[src=""],
.sidebar-brand .brand-link img:not([src]) {
    display: none !important;
}

.sidebar-brand .brand-text {
    font-size: 15px !important;
    font-weight: 900 !important;
    color: #ffffff !important;
    text-align: center !important;
    line-height: 1.35 !important;
    white-space: normal !important;
}

/* لوحة المستخدم داخل القائمة الجانبية */
.sidebar-wrapper .user-panel {
    padding: 12px 16px !important;
    margin: 8px 10px 14px 10px !important;
    border-radius: 10px !important;
    background: rgba(255, 255, 255, 0.04) !important;
    border: 1px solid rgba(255, 255, 255, 0.08) !important;
    display: flex !important;
    align-items: center !important;
}

.sidebar-wrapper .user-panel .image i,
.sidebar-wrapper .user-panel .image img {
    color: #ef4444 !important;
    font-size: 26px !important;
    margin-left: 10px !important;
}

.sidebar-wrapper .user-panel .info a,
.sidebar-wrapper .user-panel .info span {
    font-weight: 800 !important;
    font-size: 14px !important;
    color: #ffffff !important;
    text-decoration: none !important;
}

/* بنود وروابط القائمة */
.sidebar-menu .nav-header {
    color: #94a3b8 !important;
    font-size: 11.5px !important;
    font-weight: 800 !important;
    text-transform: uppercase !important;
    letter-spacing: 0.5px !important;
    padding: 12px 16px 4px 16px !important;
}

.sidebar-menu .nav-item {
    margin: 2px 8px !important;
}

.sidebar-menu .nav-link {
    border-radius: 8px !important;
    padding: 10px 14px !important;
    font-size: 13.5px !important;
    font-weight: 600 !important;
    color: #cbd5e1 !important;
    display: flex !important;
    align-items: center !important;
    transition: all 0.2s ease !important;
}

.sidebar-menu .nav-link i.nav-icon {
    font-size: 16px !important;
    width: 24px !important;
    min-width: 24px !important;
    margin-left: 8px !important;
    text-align: center !important;
    color: #94a3b8 !important;
    transition: color 0.2s ease !important;
}

.sidebar-menu .nav-link p {
    margin: 0 !important;
    line-height: 1.4 !important;
    white-space: normal !important;
    overflow: visible !important;
    text-overflow: unset !important;
    word-break: normal !important;
    flex: 1 !important;
}

.sidebar-menu .nav-link:hover {
    background-color: rgba(255, 255, 255, 0.08) !important;
    color: #ffffff !important;
}

.sidebar-menu .nav-link:hover i.nav-icon {
    color: #ef4444 !important;
}

.sidebar-menu .nav-link.active {
    background: linear-gradient(135deg, var(--eslm-red) 0%, var(--eslm-red-dark) 100%) !important;
    color: #ffffff !important;
    font-weight: 800 !important;
    box-shadow: 0 4px 12px rgba(220, 38, 38, 0.35) !important;
}

.sidebar-menu .nav-link.active i.nav-icon {
    color: #ffffff !important;
}

/* --------------------------------------------------------------------------
   5. لوحة التحكم والبنر المؤسسي (Dashboard & Welcome Banner)
   -------------------------------------------------------------------------- */
.eslm-welcome-banner {
    background: linear-gradient(135deg, #0f172a 0%, #1e293b 60%, #0f172a 100%) !important;
    border-radius: 14px !important;
    border: 1px solid rgba(220, 38, 38, 0.35) !important;
    box-shadow: 0 6px 20px rgba(15, 23, 42, 0.1) !important;
    overflow: hidden !important;
    position: relative !important;
}

.eslm-welcome-banner::before {
    content: '' !important;
    position: absolute !important;
    top: 0 !important;
    right: 0 !important;
    left: 0 !important;
    height: 3px !important;
    background: linear-gradient(90deg, #dc2626, #ef4444, #dc2626) !important;
}

/* شعارات البنر المؤسسي في لوحة التحكم */
.banner-logo-wrapper {
    min-width: 140px;
    flex-shrink: 0;
}

.banner-emblem {
    width: 80px !important;
    height: 80px !important;
    max-width: 80px !important;
    max-height: 80px !important;
    border-radius: 50% !important;
    border: 3px solid #ef4444 !important;
    box-shadow: 0 4px 16px rgba(239, 68, 68, 0.45), 0 2px 8px rgba(0, 0, 0, 0.4) !important;
    object-fit: cover !important;
    background-color: #ffffff !important;
    transition: transform 0.25s ease, box-shadow 0.25s ease;
}

.banner-emblem:hover {
    transform: scale(1.06);
    box-shadow: 0 6px 24px rgba(239, 68, 68, 0.65);
}

.banner-logo-caption {
    font-size: 11.5px;
    font-weight: 800;
    color: #e2e8f0;
    margin-top: 6px;
    line-height: 1.25;
    text-shadow: 0 1px 3px rgba(0,0,0,0.6);
}

/* شعارات الموبايل المدمجة في البنر */
.mobile-logos-container {
    padding-bottom: 4px;
}

.banner-emblem-mobile {
    width: 48px !important;
    height: 48px !important;
    max-width: 48px !important;
    max-height: 48px !important;
    border-radius: 50% !important;
    border: 2px solid #ef4444 !important;
    box-shadow: 0 3px 12px rgba(239, 68, 68, 0.45) !important;
    object-fit: cover !important;
    background-color: #ffffff !important;
}

.eslm-welcome-banner img {
    max-width: 80px !important;
    max-height: 80px !important;
    object-fit: cover !important;
}

.eslm-main-title {
    font-size: 22px !important;
    font-weight: 900 !important;
    color: #ffffff !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    flex-wrap: wrap !important;
    gap: 8px !important;
    margin: 0 !important;
}

.eslm-abbr-pill {
    background: var(--eslm-red) !important;
    color: #ffffff !important;
    font-size: 13px !important;
    font-weight: 800 !important;
    padding: 3px 10px !important;
    border-radius: 6px !important;
    letter-spacing: 0.5px !important;
    box-shadow: 0 2px 8px rgba(220, 38, 38, 0.4) !important;
}

.eslm-sub-title {
    color: #94a3b8 !important;
    font-size: 14px !important;
    font-weight: 600 !important;
    margin: 4px 0 0 0 !important;
}

.eslm-slogan-badge {
    display: inline-block !important;
    background: rgba(220, 38, 38, 0.15) !important;
    border: 1px solid var(--eslm-red) !important;
    color: #fca5a5 !important;
    font-weight: 800 !important;
    font-size: 13px !important;
    padding: 4px 18px !important;
    border-radius: 20px !important;
    margin-top: 6px !important;
}

/* بطاقات الإحصاءات الأربع */
.stat-card-eslm {
    border-radius: 12px !important;
    overflow: hidden !important;
    box-shadow: 0 4px 14px rgba(0, 0, 0, 0.08) !important;
    transition: transform 0.2s ease, box-shadow 0.2s ease !important;
    border: 1px solid var(--eslm-border) !important;
    margin-bottom: 0 !important;
}

.stat-card-eslm:hover {
    transform: translateY(-3px) !important;
    box-shadow: 0 8px 22px rgba(0, 0, 0, 0.12) !important;
}

.stat-card-info { background: linear-gradient(135deg, #0284c7 0%, #0369a1 100%) !important; }
.stat-card-success { background: linear-gradient(135deg, #16a34a 0%, #15803d 100%) !important; }
.stat-card-danger { background: linear-gradient(135deg, #dc2626 0%, #b91c1c 100%) !important; }
.stat-card-warning { background: linear-gradient(135deg, #d97706 0%, #b45309 100%) !important; }

.stat-card-eslm .inner {
    padding: 16px 18px !important;
    color: #ffffff !important;
}

.stat-card-eslm .inner h3 {
    font-size: 30px !important;
    font-weight: 900 !important;
    margin-bottom: 4px !important;
}

.stat-card-eslm .inner p {
    font-size: 13.5px !important;
    font-weight: 700 !important;
    margin: 0 !important;
    opacity: 0.95 !important;
}

.stat-card-eslm .icon {
    color: rgba(255, 255, 255, 0.25) !important;
    font-size: 48px !important;
    top: 14px !important;
    left: 18px !important;
    right: auto !important;
}

.stat-card-eslm .small-box-footer {
    background: rgba(0, 0, 0, 0.15) !important;
    color: #ffffff !important;
    font-weight: 800 !important;
    font-size: 12.5px !important;
    padding: 6px 14px !important;
    text-decoration: none !important;
    display: block !important;
    text-align: center !important;
    transition: background 0.2s ease !important;
}

.stat-card-eslm .small-box-footer:hover {
    background: rgba(0, 0, 0, 0.28) !important;
}

/* --------------------------------------------------------------------------
   6. جداول البيانات وسجلات الأعضاء (Changelist Tables)
   -------------------------------------------------------------------------- */
#changelist {
    width: 100% !important;
}

#change-list-filters {
    padding-bottom: 16px !important;
}

#changelist-search {
    gap: 8px !important;
}

#changelist-search .form-control {
    border-radius: 8px !important;
    border: 1.5px solid var(--eslm-border-dark) !important;
    padding: 8px 12px !important;
    font-size: 13.5px !important;
    font-weight: 600 !important;
}

#changelist-search .form-control:focus {
    border-color: var(--eslm-red) !important;
    box-shadow: 0 0 0 3px rgba(220, 38, 38, 0.15) !important;
}

/* بطاقة نتائج الجدول */
#changelist .card {
    border-radius: 12px !important;
    border: 1px solid var(--eslm-border) !important;
    box-shadow: 0 4px 14px rgba(0, 0, 0, 0.04) !important;
    overflow: hidden !important;
}

#changelist .table-responsive {
    border-radius: 0 !important;
    margin: 0 !important;
    overflow-x: auto !important;
    -webkit-overflow-scrolling: touch !important;
}

#result_list {
    margin: 0 !important;
    border-collapse: collapse !important;
    width: 100% !important;
}

#result_list thead th {
    background: var(--eslm-navy-dark) !important;
    color: #ffffff !important;
    font-weight: 800 !important;
    font-size: 13px !important;
    padding: 12px 10px !important;
    border: none !important;
    vertical-align: middle !important;
    white-space: nowrap !important;
}

#result_list thead th a {
    color: #ffffff !important;
    text-decoration: none !important;
}

#result_list tbody td,
#result_list tbody th {
    padding: 10px 12px !important;
    font-size: 13px !important;
    vertical-align: middle !important;
    border-top: 1px solid var(--eslm-border) !important;
    color: var(--eslm-text-main) !important;
}

#result_list tbody tr:hover {
    background-color: #f1f5f9 !important;
}

/* شريط الإجراءات الجماعية */
.actions {
    background: #ffffff !important;
    padding: 10px 14px !important;
    border-radius: 8px !important;
    border: 1px solid var(--eslm-border) !important;
    margin-bottom: 12px !important;
}

.actions select {
    border-radius: 6px !important;
    border: 1px solid var(--eslm-border-dark) !important;
    padding: 6px 12px !important;
    font-weight: 600 !important;
    font-size: 13px !important;
}

/* --------------------------------------------------------------------------
   7. استمارات الإضافة والتعديل (Forms & Changeform)
   -------------------------------------------------------------------------- */
.change-form .col-lg-9 > .card {
    background: transparent !important;
    border: none !important;
    box-shadow: none !important;
    padding: 0 !important;
    margin-bottom: 0 !important;
}

.change-form .col-lg-9 > .card > .card-body {
    padding: 0 !important;
}

.change-form .card {
    border-radius: 12px !important;
    border: 1px solid var(--eslm-border) !important;
    box-shadow: 0 4px 14px rgba(0, 0, 0, 0.04) !important;
    margin-bottom: 24px !important;
    overflow: hidden !important;
}

.change-form .form-group,
.change-form .form-row {
    margin-bottom: 16px !important;
}

.change-form label {
    font-weight: 800 !important;
    font-size: 13px !important;
    color: var(--eslm-navy-dark) !important;
    margin-bottom: 6px !important;
    display: inline-block !important;
    line-height: 1.4 !important;
    word-break: break-word !important;
}

.change-form .form-control,
.change-form select,
.change-form input[type="text"],
.change-form input[type="password"],
.change-form input[type="email"],
.change-form input[type="number"],
.change-form input[type="tel"],
.change-form input[type="date"],
.change-form .vTextField,
.change-form .vIntegerField,
.change-form .vDateField,
.change-form .vLargeTextField {
    border-radius: 8px !important;
    border: 1.5px solid var(--eslm-border-dark) !important;
    padding: 8px 12px !important;
    font-size: 14px !important;
    color: var(--eslm-text-main) !important;
    transition: all 0.2s ease !important;
    width: 100% !important;
    max-width: 100% !important;
    box-sizing: border-box !important;
}

.change-form .form-control:focus,
.change-form select:focus,
.change-form input:focus,
.change-form textarea:focus {
    border-color: var(--eslm-red) !important;
    box-shadow: 0 0 0 3px rgba(220, 38, 38, 0.15) !important;
    outline: none !important;
}

.change-form textarea {
    border-radius: 8px !important;
    border: 1.5px solid var(--eslm-border-dark) !important;
    padding: 10px 12px !important;
    font-size: 13.5px !important;
    width: 100% !important;
    max-width: 100% !important;
    box-sizing: border-box !important;
    min-height: 90px !important;
    line-height: 1.5 !important;
    resize: vertical !important;
}

.change-form .fieldBox {
    max-width: 100% !important;
}

.change-form .date {
    margin: 0 !important;
    width: 100% !important;
}

.change-form .date input {
    width: 100% !important;
}

.change-form .form-text,
.change-form .help-block {
    word-break: break-word !important;
    white-space: normal !important;
    line-height: 1.4 !important;
}

/* روابط النماذج المرتبطة (Related Widget Wrapper) */
.related-widget-wrapper {
    display: flex !important;
    flex-wrap: wrap !important;
    align-items: center !important;
    gap: 8px !important;
    width: 100% !important;
    max-width: 100% !important;
}

.related-widget-wrapper select {
    flex: 1 1 200px !important;
    width: auto !important;
    min-width: 0 !important;
}

.related-widget-wrapper .related-widget-wrapper-link {
    margin: 0 !important;
    display: inline-flex !important;
    align-items: center !important;
    justify-content: center !important;
    padding: 6px 8px !important;
    background: #f1f5f9 !important;
    border-radius: 6px !important;
    border: 1px solid var(--eslm-border-dark) !important;
    transition: all 0.2s ease !important;
}

.related-widget-wrapper .related-widget-wrapper-link:hover {
    background: #e2e8f0 !important;
    border-color: var(--eslm-red) !important;
}

[data-bs-theme="dark"] .related-widget-wrapper .related-widget-wrapper-link,
.dark-mode .related-widget-wrapper .related-widget-wrapper-link {
    background: #0f172a !important;
    border-color: #475569 !important;
}

/* ==========================================================================
   صندوق اختيار الحضور والأعضاء المتجاوب (Django filter_horizontal / .selector)
   ========================================================================== */
.selector {
    display: flex !important;
    flex-direction: row !important;
    align-items: stretch !important;
    justify-content: space-between !important;
    gap: 12px !important;
    width: 100% !important;
    max-width: 100% !important;
    box-sizing: border-box !important;
    margin-top: 8px !important;
}

/* الصندوقان: المتوفر والمختار - يتشاركان المساحة بنسبة متساوية 50% */
.selector-available,
.selector-chosen {
    flex: 1 1 0 !important;
    width: 0 !important;
    min-width: 0 !important;
    display: flex !important;
    flex-direction: column !important;
    border: 1.5px solid var(--eslm-border-dark) !important;
    border-radius: 10px !important;
    overflow: hidden !important;
    background: #ffffff !important;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.04) !important;
}

[data-bs-theme="dark"] .selector-available,
[data-bs-theme="dark"] .selector-chosen,
.dark-mode .selector-available,
.dark-mode .selector-chosen {
    background: #1e293b !important;
    border-color: #475569 !important;
}

/* عناوين الصناديق */
.selector-available-title,
.selector-chosen-title {
    padding: 10px 14px !important;
    background: var(--eslm-navy-dark) !important;
    color: #ffffff !important;
    border-bottom: 2px solid var(--eslm-red) !important;
}

.selector-available-title label,
.selector-chosen-title label {
    font-size: 13.5px !important;
    font-weight: 800 !important;
    color: #ffffff !important;
    margin: 0 !important;
    display: block !important;
    text-align: center !important;
}

/* إخفاء النص الإرشادي الطويل جداً الذي يكرر اسم الحقل داخل الصندوق */
.selector .helptext {
    display: none !important;
}

/* شريط تصفية وبحث الأسماء */
.selector .selector-filter {
    padding: 8px 12px !important;
    border-bottom: 1px solid var(--eslm-border) !important;
    display: flex !important;
    align-items: center !important;
    gap: 8px !important;
    background: #f8fafc !important;
    margin: 0 !important;
}

[data-bs-theme="dark"] .selector .selector-filter,
.dark-mode .selector .selector-filter {
    background: #0f172a !important;
    border-color: #334155 !important;
}

.selector .selector-filter label {
    display: none !important;
}

.selector .selector-filter input {
    width: 100% !important;
    height: 38px !important;
    border-radius: 6px !important;
    border: 1.5px solid var(--eslm-border-dark) !important;
    padding: 6px 12px !important;
    font-size: 13px !important;
    font-weight: 600 !important;
    background: #ffffff !important;
}

[data-bs-theme="dark"] .selector .selector-filter input,
.dark-mode .selector .selector-filter input {
    background: #1e293b !important;
    color: #f8fafc !important;
    border-color: #475569 !important;
}

/* قائمة الأسماء القابلة للتمرير */
.selector select {
    border: none !important;
    padding: 8px !important;
    font-size: 13.5px !important;
    font-weight: 700 !important;
    min-height: 240px !important;
    height: 240px !important;
    width: 100% !important;
    outline: none !important;
    background: transparent !important;
}

[data-bs-theme="dark"] .selector select,
.dark-mode .selector select {
    color: #f8fafc !important;
}

.selector select option {
    padding: 8px 12px !important;
    border-radius: 6px !important;
    margin-bottom: 3px !important;
    word-break: break-word !important;
    white-space: normal !important;
    line-height: 1.4 !important;
}

.selector select option:checked {
    background-color: var(--eslm-red) !important;
    color: #ffffff !important;
}

/* عمود أزرار الاختيار في المنتصف (.selector-chooser) - تم تثبيت عرضه بـ 50px لمنع تمدده */
.selector ul.selector-chooser {
    display: flex !important;
    flex-direction: column !important;
    justify-content: center !important;
    align-items: center !important;
    gap: 12px !important;
    width: 50px !important;
    min-width: 50px !important;
    max-width: 50px !important;
    flex: 0 0 50px !important;
    padding: 0 !important;
    margin: 0 !important;
    list-style: none !important;
    background: transparent !important;
    align-self: center !important;
    transform: none !important;
}

.selector-chooser li {
    margin: 0 !important;
    padding: 0 !important;
    width: 42px !important;
    height: 42px !important;
    list-style: none !important;
}

/* أزرار الإضافة والإزالة الدائرية مع إخفاء النص الطويل واستبداله بأيقونات أسهم أنيقة */
.selector-add,
.selector-remove {
    width: 42px !important;
    height: 42px !important;
    border-radius: 50% !important;
    background-color: var(--eslm-navy-dark) !important;
    border: 2px solid var(--eslm-red) !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    cursor: pointer !important;
    box-shadow: 0 3px 10px rgba(0, 0, 0, 0.15) !important;
    text-indent: 0 !important;
    font-size: 0 !important;
    line-height: 0 !important;
    color: transparent !important;
    overflow: hidden !important;
    transition: all 0.2s ease !important;
    position: relative !important;
    background-image: none !important;
}

.selector-add:hover,
.selector-remove:hover {
    background-color: var(--eslm-red) !important;
    transform: scale(1.1) !important;
    box-shadow: 0 4px 14px rgba(220, 38, 38, 0.35) !important;
}

/* في اتجاه RTL: إضافة تعني النقل من اليمين (المتوفر) إلى اليسار (المختار) -> السهم يشير لليسار */
.selector-add::after {
    content: "\f053" !important; /* fa-chevron-left */
    font-family: "Font Awesome 5 Free" !important;
    font-weight: 900 !important;
    font-size: 15px !important;
    color: #ffffff !important;
    display: block !important;
}

/* إزالة تعني النقل من اليسار (المختار) إلى اليمين (المتوفر) -> السهم يشير لليمين */
.selector-remove::after {
    content: "\f054" !important; /* fa-chevron-right */
    font-family: "Font Awesome 5 Free" !important;
    font-weight: 900 !important;
    font-size: 15px !important;
    color: #ffffff !important;
    display: block !important;
}

/* أزرار اختيار الكل وإزالة الكل في أسفل كل صندوق */
.selector-chooseall,
.selector-clearall {
    display: block !important;
    text-align: center !important;
    font-size: 12.5px !important;
    font-weight: 800 !important;
    padding: 9px 12px !important;
    background: #f1f5f9 !important;
    color: var(--eslm-navy-dark) !important;
    border-top: 1px solid var(--eslm-border) !important;
    text-decoration: none !important;
    transition: background 0.2s ease !important;
    white-space: nowrap !important;
    overflow: hidden !important;
    text-overflow: ellipsis !important;
    max-width: 100% !important;
}

.selector-chooseall:hover,
.selector-clearall:hover {
    background: #e2e8f0 !important;
    color: var(--eslm-red) !important;
}

[data-bs-theme="dark"] .selector-chooseall,
[data-bs-theme="dark"] .selector-clearall,
.dark-mode .selector-chooseall,
.dark-mode .selector-clearall {
    background: #0f172a !important;
    color: #f8fafc !important;
    border-color: #334155 !important;
}

/* في الشاشات الصغيرة والمتوسطة: تحويل الصناديق لتصبح عمودية بدلاً من الضغط الأفقي */
@media (max-width: 900px) {
    .selector {
        flex-direction: column !important;
    }

    .selector-available,
    .selector-chosen {
        width: 100% !important;
        flex: none !important;
    }

    .selector ul.selector-chooser {
        flex-direction: row !important;
        width: 100% !important;
        min-width: 0 !important;
        max-width: 100% !important;
        flex: none !important;
        margin: 10px auto !important;
        justify-content: center !important;
    }

    .selector-add::after {
        content: "\f078" !important; /* fa-chevron-down */
    }

    .selector-remove::after {
        content: "\f077" !important; /* fa-chevron-up */
    }

    .selector select {
        min-height: 160px !important;
        height: 160px !important;
    }
}

/* جداول الإدخال التابعة (Tabular Inlines) */
.js-inline-admin-formset,
.inline-group {
    overflow-x: auto !important;
    -webkit-overflow-scrolling: touch !important;
    border-radius: 8px !important;
    border: 1px solid var(--eslm-border) !important;
    margin-bottom: 20px !important;
}

.inline-group .tabular table {
    width: 100% !important;
    min-width: 550px !important;
}

/* شريط أزرار الحفظ (Jazzy Actions) */
#jazzy-actions {
    background: #ffffff !important;
    border-radius: 10px !important;
    border: 1px solid var(--eslm-border) !important;
    padding: 14px !important;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.05) !important;
}

#jazzy-actions .btn {
    font-weight: 800 !important;
    font-size: 13.5px !important;
    border-radius: 8px !important;
    padding: 8px 16px !important;
}

/* --------------------------------------------------------------------------
   8. أزرار التمرير السريع الذكية (Floating Scroll Nav)
   -------------------------------------------------------------------------- */
.scroll-nav-container {
    position: fixed !important;
    bottom: 24px !important;
    left: 20px !important;
    right: auto !important;
    z-index: 1030 !important;
    display: flex !important;
    flex-direction: column !important;
    gap: 8px !important;
}

.btn-floating-scroll {
    width: 40px !important;
    height: 40px !important;
    border-radius: 50% !important;
    background: var(--eslm-navy-dark) !important;
    color: #ffffff !important;
    border: 2px solid var(--eslm-red) !important;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.25) !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    font-size: 15px !important;
    cursor: pointer !important;
    transition: all 0.2s ease !important;
}

.btn-floating-scroll:hover {
    background: var(--eslm-red) !important;
    transform: scale(1.08) !important;
}

/* خلفية تظليل الشاشة للقائمة في الموبايل */
.sidebar-backdrop {
    position: fixed !important;
    top: 0 !important;
    left: 0 !important;
    right: 0 !important;
    bottom: 0 !important;
    background: rgba(15, 23, 42, 0.65) !important;
    backdrop-filter: blur(3px) !important;
    -webkit-backdrop-filter: blur(3px) !important;
    z-index: 1045 !important;
    transition: opacity 0.25s ease !important;
}

/* --------------------------------------------------------------------------
   9. قواعد شاشات الهواتف والأجهزة اللوحية (الشاشات بعرض 991.98px فما دون)
   وخاصة شاشات 320px إلى 430px
   -------------------------------------------------------------------------- */
@media (max-width: 991.98px) {

    /* تحويل الهيكل من CSS Grid ثنائي الأعمدة إلى عمود مفرد متجاوب */
    .app-wrapper {
        display: block !important;
        width: 100% !important;
        max-width: 100vw !important;
        overflow-x: hidden !important;
    }

    .app-main {
        width: 100% !important;
        max-width: 100vw !important;
        margin: 0 !important;
        padding: 0 !important;
    }

    .app-header {
        width: 100% !important;
        max-width: 100vw !important;
        margin: 0 !important;
    }

    .app-footer {
        width: 100% !important;
        max-width: 100vw !important;
        margin: 0 !important;
        padding: 12px !important;
        font-size: 12px !important;
        text-align: center !important;
    }

    /* إخفاء حقول البحث في الشريط العلوي لتجنب كسر عرض 320px–430px */
    .app-header form.d-flex,
    .app-header .form-control-navbar,
    .app-header .btn-navbar {
        display: none !important;
    }

    /* تحويل القائمة الجانبية إلى Drawer منزلق ذكي من اليمين (RTL Off-Canvas) */
    .app-sidebar,
    body:not(.sidebar-open) .app-sidebar,
    body.sidebar-collapse .app-sidebar {
        position: fixed !important;
        top: 0 !important;
        bottom: 0 !important;
        right: 0 !important;
        left: auto !important;
        width: 290px !important;
        max-width: 84vw !important;
        min-width: 260px !important;
        height: 100vh !important;
        z-index: 1050 !important;
        background-color: var(--eslm-navy-dark) !important;
        transform: translateX(105%) !important;
        transition: transform 0.28s cubic-bezier(0.4, 0, 0.2, 1) !important;
        box-shadow: none !important;
        visibility: hidden !important;
        margin-left: 0 !important;
    }

    /* ظهور القائمة بسلاسة عند الضغط على زر القائمة */
    body.sidebar-open .app-sidebar {
        transform: translateX(0) !important;
        box-shadow: -8px 0 35px rgba(0, 0, 0, 0.55) !important;
        visibility: visible !important;
    }

    /* بنود القائمة كاملة النصوص بدون اقتصاص */
    .sidebar-menu .nav-link {
        padding: 11px 14px !important;
        min-height: 46px !important;
    }

    .sidebar-menu .nav-link p {
        font-size: 13.5px !important;
        line-height: 1.4 !important;
    }

    /* بنر الترحيب على الموبايل */
    .eslm-welcome-banner .banner-inner {
        padding: 16px 12px !important;
    }

    .eslm-main-title {
        font-size: 18px !important;
    }

    .eslm-abbr-pill {
        font-size: 11.5px !important;
        padding: 2px 7px !important;
    }

    .eslm-sub-title {
        font-size: 12.5px !important;
    }

    .eslm-slogan-badge {
        font-size: 11.5px !important;
        padding: 3px 12px !important;
    }

    /* بطاقات الإحصاءات على الموبايل */
    .stat-boxes-row > div {
        margin-bottom: 8px !important;
    }

    .stat-card-eslm .inner h3 {
        font-size: 24px !important;
    }

    .stat-card-eslm .inner p {
        font-size: 12.5px !important;
    }

    /* حقول البحث والتصفية في صفحات السجلات */
    #change-list-filters > div {
        flex-direction: column !important;
        align-items: stretch !important;
    }

    #changelist-search {
        width: 100% !important;
        flex-direction: column !important;
        align-items: stretch !important;
    }

    #changelist-search .form-control {
        width: 100% !important;
        min-width: 0 !important;
        height: 44px !important;
    }

    #changelist-search button[type="submit"] {
        width: 100% !important;
        height: 44px !important;
        font-weight: 800 !important;
    }

    #changelist-search .select2-container {
        width: 100% !important;
    }

    /* شريط الإجراءات الجماعية على الموبايل */
    .actions {
        display: flex !important;
        flex-direction: column !important;
        gap: 8px !important;
    }

    .actions select {
        width: 100% !important;
        height: 44px !important;
    }

    .actions button {
        width: 100% !important;
        height: 44px !important;
        margin: 0 !important;
    }

    /* استمارات الإدخال والتعديل على الموبايل */
    .change-form .form-control,
    .change-form select,
    .change-form input[type="text"],
    .change-form input[type="password"],
    .change-form input[type="email"],
    .change-form input[type="number"],
    .change-form input[type="tel"],
    .change-form input[type="date"] {
        height: 46px !important;
        font-size: 14.5px !important;
    }

    /* جعل شريط أزرار الحفظ عائماً في أسفل شاشة الهاتف لسهولة الاستخدام باليد الواحدة */
    #jazzy-actions {
        position: sticky !important;
        bottom: 0 !important;
        background: #ffffff !important;
        border-radius: 14px 14px 0 0 !important;
        border: 1px solid var(--eslm-border-dark) !important;
        border-bottom: none !important;
        box-shadow: 0 -4px 18px rgba(0, 0, 0, 0.1) !important;
        z-index: 1025 !important;
        padding: 10px 12px !important;
    }

    #jazzy-actions .d-flex {
        flex-direction: column !important;
        width: 100% !important;
        gap: 8px !important;
    }

    #jazzy-actions .btn {
        width: 100% !important;
        height: 46px !important;
        display: flex !important;
        align-items: center !important;
        justify-content: center !important;
        font-size: 15px !important;
    }

    /* إخفاء أزرار التمرير العائمة نهائياً على الهواتف والأجهزة اللوحية لمنع حجب القوائم والإجراءات */
    .scroll-nav-container {
        display: none !important;
    }
}

/* --------------------------------------------------------------------------
   10. قواعد أجهزة الكمبيوتر والشاشات الكبيرة (992px فما فوق)
   -------------------------------------------------------------------------- */
@media (min-width: 992px) {
    .app-sidebar {
        width: var(--lte-sidebar-width) !important;
        min-width: var(--lte-sidebar-width) !important;
    }

    .app-main {
        padding: 16px 20px 40px 20px !important;
    }

    .stat-card-eslm .inner h3 {
        font-size: 32px !important;
    }

    /* إخفاء خلفية التظليل على الكمبيوتر */
    .sidebar-backdrop {
        display: none !important;
    }
}

/* --------------------------------------------------------------------------
   11. دعم الوضع الليلي والتباين العالي (Dark Mode & High Contrast)
   -------------------------------------------------------------------------- */
[data-bs-theme="dark"],
.dark-mode {
    --eslm-text-main: #f8fafc;
    --eslm-text-muted: #94a3b8;
    --eslm-border: #334155;
    --eslm-border-dark: #475569;
}

/* جداول البيانات في الوضع الليلي */
[data-bs-theme="dark"] #result_list,
.dark-mode #result_list {
    background-color: #1e293b !important;
}

[data-bs-theme="dark"] #result_list thead th,
.dark-mode #result_list thead th {
    background-color: #0f172a !important;
    color: #ffffff !important;
    border-bottom: 2px solid #dc2626 !important;
}

[data-bs-theme="dark"] #result_list tbody td,
[data-bs-theme="dark"] #result_list tbody th,
.dark-mode #result_list tbody td,
.dark-mode #result_list tbody th {
    color: #f8fafc !important;
    border-top: 1px solid #334155 !important;
    background-color: transparent !important;
}

[data-bs-theme="dark"] #result_list tbody td a,
[data-bs-theme="dark"] #result_list tbody th a,
.dark-mode #result_list tbody td a,
.dark-mode #result_list tbody th a {
    color: #38bdf8 !important;
    font-weight: 700 !important;
}

[data-bs-theme="dark"] #result_list tbody tr:hover,
.dark-mode #result_list tbody tr:hover {
    background-color: rgba(51, 65, 85, 0.7) !important;
}

/* شريط البحث والتصفية في الوضع الليلي */
[data-bs-theme="dark"] #changelist-search .form-control,
.dark-mode #changelist-search .form-control {
    background-color: #1e293b !important;
    color: #f8fafc !important;
    border: 1.5px solid #475569 !important;
}

[data-bs-theme="dark"] #changelist-search .form-control::placeholder,
.dark-mode #changelist-search .form-control::placeholder {
    color: #94a3b8 !important;
}

[data-bs-theme="dark"] #changelist-search .form-control:focus,
.dark-mode #changelist-search .form-control:focus {
    border-color: #ef4444 !important;
    box-shadow: 0 0 0 3px rgba(239, 68, 68, 0.25) !important;
}

/* شريط الإجراءات الجماعية في الوضع الليلي */
[data-bs-theme="dark"] .actions,
.dark-mode .actions {
    background-color: #1e293b !important;
    border: 1px solid #334155 !important;
    color: #f8fafc !important;
}

[data-bs-theme="dark"] .actions select,
.dark-mode .actions select {
    background-color: #0f172a !important;
    color: #f8fafc !important;
    border: 1.5px solid #475569 !important;
}

[data-bs-theme="dark"] .actions .action-counter,
.dark-mode .actions .action-counter {
    color: #94a3b8 !important;
}

/* شريط أزرار الحفظ العائم في الوضع الليلي */
[data-bs-theme="dark"] #jazzy-actions,
.dark-mode #jazzy-actions {
    background-color: #1e293b !important;
    border-color: #334155 !important;
    box-shadow: 0 -4px 18px rgba(0, 0, 0, 0.4) !important;
}

/* البطاقات واستمارات التعديل في الوضع الليلي */
[data-bs-theme="dark"] .card,
.dark-mode .card {
    background-color: #1e293b !important;
    border-color: #334155 !important;
}

[data-bs-theme="dark"] .card-header,
.dark-mode .card-header {
    border-bottom-color: #334155 !important;
}

[data-bs-theme="dark"] .change-form label,
.dark-mode .change-form label {
    color: #f1f5f9 !important;
}

[data-bs-theme="dark"] .form-control,
[data-bs-theme="dark"] select,
[data-bs-theme="dark"] textarea,
.dark-mode .form-control,
.dark-mode select,
.dark-mode textarea {
    background-color: #0f172a !important;
    color: #f8fafc !important;
    border: 1.5px solid #334155 !important;
}

[data-bs-theme="dark"] .form-control:focus,
.dark-mode .form-control:focus {
    border-color: #ef4444 !important;
    color: #ffffff !important;
}

[data-bs-theme="dark"] .readonly,
.dark-mode .readonly {
    background-color: #0f172a !important;
    color: #f8fafc !important;
    border-color: #334155 !important;
}

[data-bs-theme="dark"] .field-inner-wrapper label,
.dark-mode .field-inner-wrapper label {
    color: #f1f5f9 !important;
}

[data-bs-theme="dark"] .bg-navy,
.dark-mode .bg-navy {
    background-color: #0f172a !important;
}

/* ==============================================================================
   تحسينات شاملة لواجهات الهواتف المحمولة (320px - 430px) وسهولة اللمس والاستخدام
   ============================================================================== */

/* تحسين شكل أزرار الإجراءات السريعة (تعديل وبطاقة) في الجداول */
.btn-xs,
a.btn.btn-xs {
    display: inline-flex !important;
    align-items: center !important;
    justify-content: center !important;
    gap: 4px !important;
    border-radius: 6px !important;
    transition: all 0.2s ease !important;
    text-decoration: none !important;
}

.btn-outline-primary {
    color: #0284c7 !important;
    border-color: #0284c7 !important;
    background-color: transparent !important;
}

.btn-outline-primary:hover,
.btn-outline-primary:active {
    color: #ffffff !important;
    background-color: #0284c7 !important;
    transform: translateY(-1px);
    box-shadow: 0 2px 6px rgba(2, 132, 199, 0.3) !important;
}

@media (max-width: 576px) {
    /* شريط البحث وتصفية الجداول على الهواتف */
    #changelist-search {
        flex-direction: column !important;
        align-items: stretch !important;
        width: 100% !important;
        gap: 8px !important;
    }

    #changelist-search .form-control {
        width: 100% !important;
        height: 44px !important;
        font-size: 15px !important;
    }

    #changelist-search .btn,
    #changelist-search button {
        height: 42px !important;
        font-weight: 700 !important;
        width: 100% !important;
    }

    /* شريط الإجراءات الجماعية على الموبايل */
    .actions {
        flex-direction: column !important;
        align-items: stretch !important;
        gap: 10px !important;
        padding: 12px 10px !important;
    }

    .actions select {
        width: 100% !important;
        height: 44px !important;
        font-size: 14px !important;
    }

    .actions .button {
        width: 100% !important;
        height: 44px !important;
    }

    /* حماية الجداول من التكسر والسماح بالتمرير الأفقي السلس للمس */
    #changelist .table-responsive {
        border: 1px solid #e2e8f0 !important;
        border-radius: 8px !important;
        box-shadow: inset 0 0 6px rgba(0, 0, 0, 0.03) !important;
    }

    #result_list td,
    #result_list th {
        padding: 9px 8px !important;
        font-size: 12.5px !important;
    }

    /* شريط حفظ الاستمارات في الأسفل */
    .submit-row {
        flex-direction: column !important;
        align-items: stretch !important;
        gap: 8px !important;
        padding: 14px 10px !important;
        position: sticky !important;
        bottom: 0 !important;
        z-index: 1020 !important;
        background: #ffffff !important;
        box-shadow: 0 -4px 15px rgba(0, 0, 0, 0.1) !important;
    }

    .submit-row input,
    .submit-row a,
    .submit-row button {
        width: 100% !important;
        height: 46px !important;
        margin: 0 !important;
        font-size: 14px !important;
        font-weight: 800 !important;
        display: flex !important;
        align-items: center !important;
        justify-content: center !important;
    }

    /* حقول الإدخال لتكون مريحة للمس وتمنع الـ Zoom التلقائي */
    .form-control,
    select.form-control,
    input[type="text"],
    input[type="password"],
    input[type="email"],
    input[type="tel"] {
        font-size: 16px !important;
        min-height: 44px !important;
    }
}

/* ==========================================================================
   16. تحسينات التصفية الزمنية (Date Hierarchy) والأقسام المطوية (Collapse) وAutocomplete
   ========================================================================== */

/* شريط التصفية الزمني للسنوات والشهور في جداول السجلات */
.xfull,
ul.date-hierarchy,
.date-hierarchy,
.toplinks {
    display: flex !important;
    flex-wrap: wrap !important;
    gap: 6px !important;
    padding: 8px 14px !important;
    background: #ffffff !important;
    border: 1px solid var(--eslm-border) !important;
    border-radius: 8px !important;
    margin-bottom: 15px !important;
    font-size: 13px !important;
    align-items: center !important;
    list-style: none !important;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.04) !important;
}

.xfull a,
ul.date-hierarchy a,
.toplinks a {
    color: #0284c7 !important;
    font-weight: 700 !important;
    text-decoration: none !important;
    padding: 3px 9px !important;
    border-radius: 6px !important;
    background: #f1f5f9 !important;
    transition: all 0.2s ease !important;
}

.xfull a:hover,
ul.date-hierarchy a:hover,
.toplinks a:hover {
    background: #e0f2fe !important;
    color: #0369a1 !important;
}

/* تنسيق الأقسام القابلة للطي (Collapsible Fieldsets) */
fieldset.collapse {
    border: 1.5px dashed #cbd5e1 !important;
    border-radius: 10px !important;
    margin-bottom: 16px !important;
    background-color: #f8fafc !important;
    overflow: hidden !important;
}

fieldset.collapse h2,
fieldset.collapse .card-header {
    cursor: pointer !important;
    background-color: #f1f5f9 !important;
    color: #334155 !important;
    font-weight: 800 !important;
    padding: 10px 15px !important;
    border-radius: 8px !important;
    display: flex !important;
    justify-content: space-between !important;
    align-items: center !important;
}

fieldset.collapse h2 a.collapse-toggle,
fieldset.collapse .card-header a {
    color: #dc2626 !important;
    font-size: 13px !important;
    font-weight: 800 !important;
    text-decoration: none !important;
}

/* حقول البحث الذكي السريع Select2 / Autocomplete */
.select2-container {
    width: 100% !important;
    direction: rtl !important;
    text-align: right !important;
}

.select2-container--admin-autocomplete .select2-selection--single,
.select2-container--default .select2-selection--single {
    height: 42px !important;
    border: 1.5px solid #cbd5e1 !important;
    border-radius: 8px !important;
    padding: 6px 12px !important;
    background-color: #ffffff !important;
}

.select2-container--admin-autocomplete .select2-selection--multiple,
.select2-container--default .select2-selection--multiple {
    min-height: 42px !important;
    border: 1.5px solid #cbd5e1 !important;
    border-radius: 8px !important;
    padding: 4px 8px !important;
    background-color: #ffffff !important;
}

.select2-dropdown {
    border: 1.5px solid #cbd5e1 !important;
    border-radius: 8px !important;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.1) !important;
    direction: rtl !important;
    text-align: right !important;
}