body.rtl { direction: rtl; }
body.ltr { direction: ltr; }
.theme-color { color: #0D6EFD; }
.bg-theme { background-color: #0D6EFD !important; }
.logo { height: 48px; }

/* إزالة مقبض تكبير/تصغير الـ textarea (المربع المفتوح) داخل النوافذ المنبثقة */
.modal textarea,
.swal2-popup textarea,
.swal2-popup .swal2-textarea {
    resize: none;
}
/* WebKit: إخفاء المقبض لو ظل ظاهرًا */
.modal textarea::-webkit-resizer,
.swal2-popup textarea::-webkit-resizer,
.swal2-popup .swal2-textarea::-webkit-resizer {
    display: none;
}

/* تصغير ارتفاع الهيدر في جميع الشاشات */
.page-header,
.header {
	padding: 0.75rem 1rem !important;
}
.page-header h1,
.header h1 {
	font-size: 1.3rem !important;
	margin-bottom: 0.125rem !important;
}
.page-header h2,
.header h2 {
	font-size: 1.1rem !important;
	margin-bottom: 0.125rem !important;
}
.page-header p,
.header p {
	font-size: 0.8rem !important;
	margin-bottom: 0 !important;
}

/* تحسينات للجوال - تقليل المساحات أكثر */
@media (max-width: 768px) {
    .page-header,
    .header {
        padding: 0.5rem 0.75rem !important;
        margin-bottom: 0.75rem !important;
    }
    
    .page-header h1,
    .header h1 {
        font-size: 1.1rem !important;
        margin-bottom: 0.1rem !important;
    }
    
    .page-header h2,
    .header h2 {
        font-size: 1rem !important;
        margin-bottom: 0.1rem !important;
    }
    
    /* تحسين بطاقات الإحصائيات للجوال */
    .card.shadow-sm.border-0 .card-body {
        padding: 0.4rem 0.3rem !important;
        min-height: auto !important;
    }
    
    .display-6.fw-bold {
        font-size: 0.9rem !important;
        line-height: 1.1 !important;
        margin: 0.1rem 0 !important;
    }
    
    .card.shadow-sm.border-0 {
        margin-bottom: 0.5rem !important;
    }
    
    .card.shadow-sm.border-0 .bi {
        font-size: 0.8rem !important;
    }
    
    /* تقليل حجم الأيقونات */
    .bi {
        font-size: 0.9rem;
    }
    
    /* أزرار الإجراءات السريعة - أصغر للجوال */
    .quick-actions .btn {
        min-width: 90px !important;
        padding: 0.4rem 0.6rem !important;
        font-size: 0.8rem !important;
    }
    
    /* تحسين المساحات العامة */
    .py-4 {
        padding-top: 0.75rem !important;
        padding-bottom: 0.75rem !important;
    }
    
    .py-3 {
        padding-top: 0.5rem !important;
        padding-bottom: 0.5rem !important;
    }
    
    .py-2 {
        padding-top: 0.25rem !important;
        padding-bottom: 0.25rem !important;
    }
    
    .my-4 {
        margin-top: 0.75rem !important;
        margin-bottom: 0.75rem !important;
    }
    
    .my-3 {
        margin-top: 0.5rem !important;
        margin-bottom: 0.5rem !important;
    }
    
    /* تصغير جميع أنواع البطاقات */
    .card,
    .shadow-sm,
    .border-0 {
        box-shadow: 0 1px 4px rgba(0, 0, 0, 0.08) !important;
    }
    
    /* تصغير الأرقام الكبيرة */
    .h1, h1,
    .h2, h2,
    .h3, h3 {
        line-height: 1.1 !important;
        margin-bottom: 0.3rem !important;
    }
    
    /* تصغير المسافات بين الصفوف */
    .row {
        margin-bottom: 0.5rem;
    }
    
    .row > * {
        margin-bottom: 0.4rem;
    }
}

/* ضبط حجم مربعات الاختيار والسويتش لتكون أصغر وأكثر احترافية */
.form-check-input {
	width: 1.15rem;
	height: 1.15rem;
	border: 2px solid #d1d5db;
	background-color: #fff;
	background-repeat: no-repeat;
	background-position: center;
	background-size: contain;
	appearance: none;
	-webkit-appearance: none;
	-moz-appearance: none;
	cursor: pointer;
	transition: all 0.2s ease;
}

.form-check-input:checked {
	background-color: #667eea;
	border-color: #667eea;
}

.form-check-input[type="checkbox"]:checked {
	background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 20 20'%3e%3cpath fill='none' stroke='%23fff' stroke-linecap='round' stroke-linejoin='round' stroke-width='3' d='M6 10l3 3l6-6'/%3e%3c/svg%3e");
	background-size: 80%;
}

.form-check-input[type="radio"] {
	border-radius: 50%;
}

.form-check-input[type="radio"]:checked {
	background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='-4 -4 8 8'%3e%3ccircle r='3' fill='%23fff'/%3e%3c/svg%3e");
	background-size: 100%;
}

.form-switch .form-check-input {
	width: 2.5rem;
	height: 1.3rem;
	border-radius: 2rem;
	background-color: #e5e7eb;
	background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='-4 -4 8 8'%3e%3ccircle r='3' fill='%23fff'/%3e%3c/svg%3e");
	background-position: left center;
	background-size: contain;
	transition: all 0.2s ease;
}

.form-switch .form-check-input:checked {
	background-color: #667eea;
	background-position: right center;
}

.form-check-label {
	font-size: 0.95rem !important;
	cursor: pointer !important;
	word-wrap: break-word !important;
	overflow-wrap: break-word !important;
	hyphens: auto !important;
}

/* إصلاح شامل لمربعات الاختيار في جميع الصفحات */
.list-group-item .form-check,
.table .form-check,
.card .form-check,
.modal .form-check,
.permission-item .form-check {
    display: flex !important;
    align-items: flex-start !important;
    gap: 8px !important;
    width: 100% !important;
    margin-bottom: 8px !important;
}

.list-group-item .form-check .form-check-label,
.table .form-check .form-check-label,
.card .form-check .form-check-label,
.modal .form-check .form-check-label,
.permission-item .form-check .form-check-label {
    flex: 1 !important;
    min-width: 0 !important;
    overflow: visible !important;
    text-overflow: clip !important;
    white-space: normal !important;
    word-break: break-word !important;
    line-height: 1.4 !important;
    display: block !important;
}

/* التأكد من عدم تقطع النصوص في التصاريح */
.list-group-item {
    overflow: visible !important;
    word-wrap: break-word !important;
}

.list-group-item .form-check {
    padding: 4px 0 !important;
}

/* تحسين محاذاة نص الـ checkbox/radio */
.form-check {
    display: flex !important;
    align-items: flex-start !important;
    gap: 8px !important;
    margin-bottom: 8px !important;
    width: 100% !important;
}

.form-check .form-check-input {
    margin: 0 !important;
    margin-top: 2px !important;
    flex-shrink: 0 !important;
    position: relative !important;
}

.form-check .form-check-label {
    line-height: 1.5 !important;
    word-break: break-word !important;
    white-space: normal !important;
    flex: 1 !important;
    width: auto !important;
    overflow: visible !important;
    text-overflow: unset !important;
    display: block !important;
}

/* تحسين بطاقات الإحصائيات */
.card.shadow-sm.border-0 .card-body {
	padding: 1.25rem 1rem;
}
.display-6.fw-bold { line-height: 1.1; }

/* أزرار الإجراءات السريعة في الحضور - جعلها أصغر */
.quick-actions .btn {
    min-width: 120px;
}

/* تحسينات Dashboard الجديدة */
.dashboard-card {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    border: none;
    border-radius: 15px;
    color: white;
    transition: all 0.3s ease;
    box-shadow: 0 8px 25px rgba(0,0,0,0.15);
}

.dashboard-card:hover {
    transform: translateY(-5px);
    box-shadow: 0 12px 35px rgba(0,0,0,0.2);
}

.dashboard-card.success-card {
    background: linear-gradient(135deg, #11998e 0%, #38ef7d 100%);
}

.dashboard-card.warning-card {
    background: linear-gradient(135deg, #fcb045 0%, #fd1d1d 100%);
}

.dashboard-card.info-card {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
}

.dashboard-card.primary-card {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
}

.dashboard-card .card-body {
    padding: 1.5rem 1rem;
    text-align: center;
}

.dashboard-card .fs-1 {
    opacity: 0.9;
    margin-bottom: 0.5rem;
}

.dashboard-card .display-6 {
    font-size: 2.5rem;
    font-weight: 700;
    margin-bottom: 0.25rem;
}

.dashboard-card h6 {
    font-size: 0.9rem;
    opacity: 0.9;
    margin-bottom: 0;
    font-weight: 500;
}

/* أزرار Dashboard المحسنة */
.dashboard-btn {
    border: none;
    border-radius: 12px;
    padding: 1rem 1.5rem;
    font-weight: 600;
    text-decoration: none;
    transition: all 0.3s ease;
    box-shadow: 0 4px 15px rgba(0,0,0,0.1);
    position: relative;
    overflow: hidden;
}

.dashboard-btn::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255,255,255,0.2), transparent);
    transition: left 0.5s;
}

.dashboard-btn:hover::before {
    left: 100%;
}

.dashboard-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 25px rgba(0,0,0,0.15);
}

.dashboard-btn.bg-theme {
    background: linear-gradient(135deg, #0D6EFD 0%, #6f42c1 100%);
}

.dashboard-btn.btn-outline-primary {
    background: rgba(13, 110, 253, 0.1);
    border: 2px solid #0D6EFD;
    color: #0D6EFD;
}

.dashboard-btn.btn-outline-primary:hover {
    background: #0D6EFD;
    color: white;
}

.dashboard-btn.btn-outline-success {
    background: rgba(25, 135, 84, 0.1);
    border: 2px solid #198754;
    color: #198754;
}

.dashboard-btn.btn-outline-success:hover {
    background: #198754;
    color: white;
}

.dashboard-btn.btn-outline-warning {
    background: rgba(255, 193, 7, 0.1);
    border: 2px solid #ffc107;
    color: #ffc107;
}

.dashboard-btn.btn-outline-warning:hover {
    background: #ffc107;
    color: white;
}

.dashboard-btn.btn-outline-info {
    background: rgba(13, 202, 240, 0.1);
    border: 2px solid #0dcaf0;
    color: #0dcaf0;
}

.dashboard-btn.btn-outline-info:hover {
    background: #0dcaf0;
    color: white;
}

.dashboard-btn.btn-outline-dark {
    background: rgba(33, 37, 41, 0.1);
    border: 2px solid #212529;
    color: #212529;
}

.dashboard-btn.btn-outline-dark:hover {
    background: #212529;
    color: white;
}

.dashboard-btn.btn-outline-secondary {
    background: rgba(108, 117, 125, 0.1);
    border: 2px solid #6c757d;
    color: #6c757d;
}

.dashboard-btn.btn-outline-secondary:hover {
    background: #6c757d;
    color: white;
}

/* تحسينات قسم الحضور للموظفين */
.attendance-card {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    border: none;
    border-radius: 15px;
    color: white;
    box-shadow: 0 8px 25px rgba(0,0,0,0.15);
}

.attendance-card .card-body {
    padding: 2rem;
}

.attendance-btn {
    border: 2px solid rgba(255,255,255,0.3);
    background: rgba(255,255,255,0.1);
    color: white;
    border-radius: 12px;
    padding: 1rem 2rem;
    font-weight: 600;
    transition: all 0.3s ease;
    backdrop-filter: blur(10px);
}

.attendance-btn:hover {
    background: rgba(255,255,255,0.2);
    border-color: rgba(255,255,255,0.5);
    transform: translateY(-2px);
    box-shadow: 0 8px 25px rgba(0,0,0,0.2);
}

.attendance-btn.check-in {
    background: rgba(25, 135, 84, 0.8);
    border-color: #198754;
}

.attendance-btn.check-out {
    background: rgba(220, 53, 69, 0.8);
    border-color: #dc3545;
}

/* تحسينات البطاقات الإحصائية للموظفين */
.employee-stats-card {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    border: none;
    border-radius: 12px;
    color: white;
    transition: all 0.3s ease;
}

.employee-stats-card .card-body {
    padding: 1.5rem;
    text-align: center;
}

.employee-stats-card h3 {
    font-size: 2rem;
    font-weight: 700;
    margin-bottom: 0.25rem;
}

.employee-stats-card small {
    opacity: 0.9;
    font-weight: 500;
}

/* تحسينات عامة للـDashboard */
.dashboard-section {
    margin-bottom: 2rem;
}

.dashboard-section h5 {
    color: #495057;
    font-weight: 600;
    margin-bottom: 1.5rem;
    position: relative;
}

.dashboard-section h5::after {
    content: '';
    position: absolute;
    bottom: -5px;
    left: 0;
    width: 50px;
    height: 3px;
    background: linear-gradient(90deg, #0D6EFD, #6f42c1);
    border-radius: 2px;
}

/* تحسينات التنبيهات */
.alert-modern {
    border: none;
    border-radius: 12px;
    padding: 1.25rem 1.5rem;
    box-shadow: 0 4px 15px rgba(0,0,0,0.1);
}

.alert-modern.alert-info {
    background: linear-gradient(135deg, #d1ecf1 0%, #bee5eb 100%);
    color: #0c5460;
}

/* تحسينات الرسوم البيانية */
.chart-container {
    position: relative;
    height: 200px;
    margin: 1rem 0;
}

/* تأثيرات التحميل */
.loading-shimmer {
    background: linear-gradient(90deg, #f0f0f0 25%, #e0e0e0 50%, #f0f0f0 75%);
    background-size: 200% 100%;
    animation: shimmer 1.5s infinite;
}

@keyframes shimmer {
    0% { background-position: -200% 0; }
    100% { background-position: 200% 0; }
}

/* تحسينات الاستجابة */
@media (max-width: 768px) {
    .dashboard-card .card-body {
        padding: 1.5rem 1rem;
    }

    .dashboard-card .display-6 {
        font-size: 2rem;
    }

    .dashboard-btn {
        padding: 0.75rem 1rem;
        font-size: 0.9rem;
    }

    .attendance-card .card-body {
        padding: 1.5rem;
    }

    .attendance-btn {
        padding: 0.75rem 1.5rem;
        font-size: 0.9rem;
    }
}

/* ضبط حجم حقول الإدخال والاختيار - Form Controls Size */
.form-control,
.form-select {
    padding: 0.2rem 0.75rem;
    font-size: 0.9rem;
    height: 2.3rem;
    line-height: 2.6rem;
    color: #111827; /* نص داكن ليظهر داخل المربع */
    -webkit-text-fill-color: #111827; /* إصلاح مشكلة النص الشفاف في بعض الثيمات */
    background-color: #fff;
    border: 1px solid #d1d5db;
    border-radius: 10px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    display: flex;
    align-items: center;
}

/* إصلاح حقول القسم/الأولوية/الحالة داخل بطاقة الإعدادات لتفادي التراكب */
.settings-card .form-label {
    display: block;
}

.settings-card .form-select,
.settings-card select {
    display: flex;
    align-items: center;
    width: 100%;
    min-width: 260px;
    height: 2.6rem;
    line-height: 2.8rem;
    color: #111827;
    -webkit-text-fill-color: #111827;
    background-color: #fff;
    border: 1px solid #d1d5db;
    border-radius: 10px;
    padding: 0.15rem 0.75rem;
    margin-bottom: 0.25rem;
}

.settings-card .form-select:focus,
.settings-card select:focus {
    outline: none;
    border-color: #667eea;
    box-shadow: 0 0 0 0.25rem rgba(102,126,234,0.15);
}

/* ضمان عدم تراكب الأعمدة داخل الصف */
.settings-card .row > [class*="col-"] {
    position: relative;
}

.form-select {
    padding-top: 0.15rem;
    padding-bottom: 0.15rem;
    appearance: none;
    -webkit-appearance: none;
    -moz-appearance: none;
    background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 20 20'%3e%3cpath fill='%23667eea' d='M5.25 7.5L10 12.25 14.75 7.5z'/%3e%3c/svg%3e");
    background-repeat: no-repeat;
    background-position: left 0.5rem center; /* سيُعكس في RTL */
    background-size: 16px;
    display: flex !important;
    align-items: center !importantleft 0.5rem center; /* سيُعكس في RTL */
    background-size: 16px;
}

[dir="rtl"] .form-select {
    padding-right: 0.75rem;
    padding-left: 2rem;
    background-position: right 0.5rem center;
}

/* تأكيد ظهور النص داخل عناصر الخيارات */
select option {
    color: #111827;
    background-color: #fff;
}

/* حقول الإدخال الصغيرة */
.form-control-sm,
.form-select-sm {
    padding: 0.25rem 0.5rem;
    font-size: 0.8rem;
    height: 1.75rem;
}

/* تقليل حجم حقول البحث والمدخلات */
input[type="text"],
input[type="email"],
input[type="number"],
input[type="tel"],
input[type="date"],
input[type="time"],
textarea {
    max-width: 100%;
    padding: 0.4rem 0.75rem;
    font-size: 0.875rem;
}

/* تقليل حجم الأزرار بجانب الحقول */
.input-group .btn {
    padding: 0.4rem 0.75rem;
    font-size: 0.875rem;
}

/* تقليل حجم Labels */
.form-label {
    font-size: 0.8rem;
    margin-bottom: 0.25rem;
    font-weight: 500;
}

/* RTL Support for Checkboxes and Switches */
[dir="rtl"] .form-check {
    padding-right: 1.5em;
    padding-left: 0;
}

[dir="rtl"] .form-check-input {
    margin-right: -1.5em;
    margin-left: 0;
}

[dir="rtl"] .form-switch .form-check-input {
    background-position: right center;
}

[dir="rtl"] .form-switch .form-check-input:checked {
    background-position: left center;
}

/* إصلاح محاذاة القوائم المنسدلة والنصوص في اللغة العربية */
[dir="rtl"] .form-select,
[dir="rtl"] select.form-select,
[dir="rtl"] select.form-control {
    text-align: right !important;
    direction: rtl !important;
    padding-right: 1rem !important;
    padding-left: 2.5rem !important;
    background-position: left 0.75rem center !important;
    line-height: 1.5 !important;
    vertical-align: middle !important;
}

/* إصلاح ارتفاع وموضع النص داخل القوائم المنسدلة */
.form-select,
select.form-select,
select.form-control {
    line-height: 1.5 !important;
    padding-top: 0.75rem !important;
    padding-bottom: 0.75rem !important;
    height: auto !important;
    min-height: 48px !important;
}

.form-select-lg {
    line-height: 1.5 !important;
    padding-top: 0.875rem !important;
    padding-bottom: 0.875rem !important;
    min-height: 56px !important;
}

[dir="rtl"] .form-select option,
[dir="rtl"] select option,
[dir="rtl"] optgroup {
    text-align: right !important;
    direction: rtl !important;
}

/* إصلاح محاذاة النصوص في input و textarea */
[dir="rtl"] .form-control,
[dir="rtl"] input.form-control,
[dir="rtl"] textarea.form-control {
    text-align: right !important;
    direction: rtl !important;
}

/* إصلاح محاذاة العناوين */
[dir="rtl"] .form-label,
[dir="rtl"] label {
    text-align: right !important;
    display: block !important;
}

/* إصلاح محاذاة input-group في RTL */
[dir="rtl"] .input-group .form-select {
    border-radius: 0 10px 10px 0 !important;
}

[dir="rtl"] .input-group .btn {
    border-radius: 10px 0 0 10px !important;
}
/* ==================== إصلاحات إضافية لضمان عمل جميع الشاشات ==================== */

/* تأكيد محاذاة النصوص في جميع أنواع الـ inputs */
[dir="rtl"] input[type="text"],
[dir="rtl"] input[type="email"],
[dir="rtl"] input[type="password"],
[dir="rtl"] input[type="number"],
[dir="rtl"] input[type="tel"],
[dir="rtl"] input[type="url"],
[dir="rtl"] input[type="search"],
[dir="rtl"] input[type="date"],
[dir="rtl"] input[type="time"],
[dir="rtl"] input[type="datetime-local"],
[dir="rtl"] input[type="month"],
[dir="rtl"] input[type="week"] {
    text-align: right !important;
    direction: rtl !important;
    padding-right: 0.75rem !important;
    padding-left: 0.75rem !important;
}

/* إصلاح placeholder في جميع الحالات */
[dir="rtl"] input::placeholder,
[dir="rtl"] textarea::placeholder,
[dir="rtl"] select::placeholder {
    text-align: right !important;
    direction: rtl !important;
}

/* إصلاح الأزرار والأيقونات */
[dir="rtl"] .btn i,
[dir="rtl"] .btn svg,
[dir="rtl"] button i,
[dir="rtl"] button svg {
    margin-left: 0.5rem !important;
    margin-right: 0 !important;
}

[dir="ltr"] .btn i,
[dir="ltr"] .btn svg,
[dir="ltr"] button i,
[dir="ltr"] button svg {
    margin-right: 0.5rem !important;
    margin-left: 0 !important;
}

/* إصلاح المسافات في المودال */
[dir="rtl"] .modal-body {
    text-align: right !important;
}

[dir="rtl"] .modal-footer {
    justify-content: flex-start !important;
}

[dir="rtl"] .modal-footer .btn {
    margin-left: 0.5rem !important;
    margin-right: 0 !important;
}

/* إصلاح القوائم المنسدلة في النماذج المعقدة */
[dir="rtl"] .form-floating > .form-select,
[dir="rtl"] .form-floating > select {
    text-align: right !important;
    padding-right: 1rem !important;
    padding-left: 2.5rem !important;
}

/* إصلاح عرض التواريخ والأرقام */
[dir="rtl"] input[type="date"]::-webkit-datetime-edit,
[dir="rtl"] input[type="time"]::-webkit-datetime-edit,
[dir="rtl"] input[type="datetime-local"]::-webkit-datetime-edit {
    text-align: right !important;
}

/* تحسين عرض النصوص الطويلة */
.form-select,
select.form-select,
.form-control,
input,
textarea {
    overflow: hidden !important;
    text-overflow: ellipsis !important;
    white-space: normal !important;
}

select.form-select option,
.form-select option {
    white-space: normal !important;
    word-wrap: break-word !important;
}

/* إصلاح مشاكل الارتفاع في القوائم الكبيرة */
.form-select-lg option {
    padding: 0.5rem 1rem !important;
}

/* تحسين عرض الـ badges في RTL */
[dir="rtl"] .badge {
    text-align: center !important;
}

/* إصلاح التنسيق في الجداول */
[dir="rtl"] .table th:first-child,
[dir="rtl"] .table td:first-child {
    text-align: right !important;
}

[dir="rtl"] .table th:last-child,
[dir="rtl"] .table td:last-child {
    text-align: left !important;
}

/* تحسين Cards */
[dir="rtl"] .card-title,
[dir="rtl"] .card-text {
    text-align: right !important;
}

/* إصلاح Alerts */
[dir="rtl"] .alert {
    text-align: right !important;
}

[dir="rtl"] .alert .btn-close {
    margin-left: auto !important;
    margin-right: -0.5rem !important;
}

/* تحسين Breadcrumb */
[dir="rtl"] .breadcrumb {
    flex-direction: row-reverse !important;
}

/* إصلاح List Groups */
[dir="rtl"] .list-group-item {
    text-align: right !important;
}

/* تحسين النماذج المتجاوبة */
@media (max-width: 768px) {
    [dir="rtl"] .form-select,
    [dir="rtl"] select,
    [dir="rtl"] .form-control,
    [dir="rtl"] input,
    [dir="rtl"] textarea {
        font-size: 16px !important; /* منع الزوم التلقائي في الموبايل */
    }
}

/* إصلاح النصوص في Tooltips و Popovers */
[dir="rtl"] .tooltip-inner,
[dir="rtl"] .popover-body {
    text-align: center !important;
}

/* تحسين Spinners و Loaders */
[dir="rtl"] .spinner-border,
[dir="rtl"] .spinner-grow {
    margin: 0 auto !important;
}

/* إصلاح الأزرار المجمعة */
[dir="rtl"] .btn-group {
    flex-direction: row-reverse !important;
}

[dir="rtl"] .btn-group > .btn:not(:last-child):not(.dropdown-toggle) {
    border-top-left-radius: 0 !important;
    border-bottom-left-radius: 0 !important;
}

[dir="rtl"] .btn-group > .btn:not(:first-child) {
    border-top-right-radius: 0 !important;
    border-bottom-right-radius: 0 !important;
}

/* تحسين Navs و Tabs */
[dir="rtl"] .nav-tabs,
[dir="rtl"] .nav-pills {
    flex-direction: row-reverse !important;
}

/* إصلاح Progress Bars */
[dir="rtl"] .progress-bar {
    direction: ltr !important;
}

/* تحسين Pagination */
[dir="rtl"] .pagination {
    flex-direction: row-reverse !important;
}

/* ضمان وضوح النصوص */
* {
    -webkit-font-smoothing: antialiased !important;
    -moz-osx-font-smoothing: grayscale !important;
}

/* منع مشاكل التداخل */
.form-select,
select,
.form-control,
input,
textarea,
button {
    position: relative !important;
    z-index: 1 !important;
}

/* تحسين Focus States */
.form-select:focus,
select:focus,
.form-control:focus,
input:focus,
textarea:focus {
    border-color: #667eea !important;
    box-shadow: 0 0 0 0.25rem rgba(102, 126, 234, 0.25) !important;
    outline: none !important;
}

/* إصلاح عرض القيم المختارة بوضوح */
.form-select:not([multiple]):not([size]),
select:not([multiple]):not([size]) {
    appearance: none !important;
    -webkit-appearance: none !important;
    -moz-appearance: none !important;
    background-repeat: no-repeat !important;
}

/* ضمان عمل جميع التحديدات */
*,
*::before,
*::after {
    box-sizing: border-box !important;
}

/* ========================================
   تحسينات شاملة للموبايل - Header & Navigation
   ======================================== */

@media (max-width: 768px) {
    /* تحسين الهيدر الأساسي */
    .modern-navbar {
        height: 60px !important;
        padding: 0 8px !important;
        display: flex !important;
        align-items: center !important;
        justify-content: space-between !important;
        position: relative !important;
        overflow: visible !important;
    }
    
    /* تحسين زر القائمة */
    .sidebar-toggle-main {
        order: 1;
        position: relative !important;
        left: auto !important;
        right: auto !important;
        top: auto !important;
        transform: none !important;
        width: 36px !important;
        height: 36px !important;
        font-size: 1.2rem !important;
        flex-shrink: 0;
        z-index: 1001;
    }
    
    /* تحسين معلومات الشركة في المنتصف */
    .navbar-header-custom {
        order: 2;
        flex: 1 !important;
        display: flex !important;
        align-items: center !important;
        justify-content: center !important;
        margin: 0 8px !important;
        position: relative !important;
        overflow: hidden !important;
    }
    
    .company-info-center {
        max-width: 100% !important;
        text-align: center !important;
        overflow: hidden !important;
    }
    
    .responsive-company-name {
        font-size: 1rem !important;
        max-width: 100% !important;
        white-space: nowrap !important;
        overflow: hidden !important;
        text-overflow: ellipsis !important;
    }
    
    .company-logo-inline .company-logo {
        height: 32px !important;
        max-height: 32px !important;
        object-fit: contain !important;
    }
    
    /* تحسين إجراءات الهيدر */
    .navbar-actions {
        order: 3;
        display: flex !important;
        align-items: center !important;
        gap: 4px !important;
        flex-shrink: 0;
        position: relative !important;
        left: auto !important;
        right: auto !important;
        top: auto !important;
        transform: none !important;
    }
    
    /* تحسين أزرار الإجراءات */
    .navbar-action-btn,
    .lang-toggle,
    .user-profile-btn {
        width: 36px !important;
        height: 36px !important;
        border-radius: 10px !important;
        font-size: 0.9rem !important;
        flex-shrink: 0;
        display: flex !important;
        align-items: center !important;
        justify-content: center !important;
    }
    
    .user-avatar {
        width: 28px !important;
        height: 28px !important;
        font-size: 0.8rem !important;
    }
    
    /* إخفاء عناصر غير ضرورية */
    .navbar-search {
        display: none !important;
    }
    
    .user-info {
        display: none !important;
    }
    
    .user-profile-btn .bi-chevron-down {
        display: none !important;
    }
    
    /* تحسين شارة الإشعارات */
    #notification-badge {
        font-size: 0.6rem !important;
        width: 16px !important;
        height: 16px !important;
        top: -2px !important;
        right: -2px !important;
    }
}

/* تحسينات للشاشات الصغيرة جداً */
@media (max-width: 480px) {
    .modern-navbar {
        height: 56px !important;
        padding: 0 6px !important;
    }
    
    .sidebar-toggle-main {
        width: 32px !important;
        height: 32px !important;
        font-size: 1.1rem !important;
    }
    
    .navbar-actions {
        gap: 2px !important;
    }
    
    .navbar-action-btn,
    .lang-toggle,
    .user-profile-btn {
        width: 32px !important;
        height: 32px !important;
        font-size: 0.8rem !important;
    }
    
    .user-avatar {
        width: 24px !important;
        height: 24px !important;
        font-size: 0.7rem !important;
    }
    
    .responsive-company-name {
        font-size: 0.9rem !important;
    }
    
    .company-logo-inline .company-logo {
        height: 28px !important;
    }
    
    .navbar-header-custom {
        margin: 0 6px !important;
    }
}

/* تحسينات شاملة إضافية للمساحات على الجوال */
@media (max-width: 768px) {
    /* تحسين النافذة الرئيسية */
    .main-content {
        padding: 0.5rem !important;
    }
    
    /* تحسين البطاقات في الشبكة */
    .col-lg-3,
    .col-lg-4,
    .col-lg-6,
    .col-md-3,
    .col-md-4,
    .col-md-6 {
        margin-bottom: 0.75rem;
    }
    
    /* تحسين الإحصائيات والمؤشرات */
    .stats-card,
    .metric-card {
        padding: 0.5rem !important;
        margin-bottom: 0.5rem !important;
    }
    
    .stats-card .card-body,
    .metric-card .card-body {
        padding: 0.5rem !important;
    }
    
    .stats-value,
    .metric-value {
        font-size: 1.1rem !important;
        line-height: 1.2;
    }
    
    .stats-label,
    .metric-label {
        font-size: 0.75rem !important;
    }
    
    /* تحسين قوائم العناصر */
    .list-group-item {
        padding: 0.5rem 0.75rem !important;
        font-size: 0.85rem !important;
    }
    
    /* تحسين النماذج */
    .form-floating > label {
        font-size: 0.8rem !important;
        padding: 0.5rem 0.75rem !important;
    }
    
    .form-floating > .form-control {
        padding: 0.75rem !important;
    }
    
    /* تحسين التبويبات */
    .nav-tabs .nav-link {
        padding: 0.5rem 0.75rem !important;
        font-size: 0.85rem !important;
    }
    
    /* تحسين الباقات والمكونات الخاصة */
    .dashboard-card {
        margin-bottom: 0.75rem !important;
    }
    
    .dashboard-card .card-body {
        padding: 0.6rem 0.4rem !important;
    }
    
    .dashboard-card .fs-1 {
        font-size: 1.3rem !important;
        margin: 0.2rem 0 !important;
    }
    
    .dashboard-card .fs-4 {
        font-size: 0.8rem !important;
        margin: 0.1rem 0 !important;
    }
    
    /* تحسين الأيقونات */
    .dashboard-card .bi,
    .stats-card .bi,
    .metric-card .bi {
        font-size: 1.1rem !important;
    }
    
    /* تحسين التباعد العام */
    .container-fluid {
        padding-left: 0.5rem !important;
        padding-right: 0.5rem !important;
    }
    
    /* تحسين الأشرطة الجانبية */
    .sidebar {
        font-size: 0.85rem !important;
    }
    
    .sidebar .nav-link {
        padding: 0.5rem 0.75rem !important;
    }
    
    /* تحسين العناوين في الكاردات */
    .card-title {
        font-size: 0.95rem !important;
        margin-bottom: 0.5rem !important;
    }
    
    .card-subtitle {
        font-size: 0.8rem !important;
        margin-bottom: 0.25rem !important;
    }
    
    /* تحسين الـ alerts */
    .alert {
        padding: 0.5rem 0.75rem !important;
        font-size: 0.85rem !important;
        margin-bottom: 0.75rem !important;
    }
    
    /* تحسين الـ badges */
    .badge {
        font-size: 0.7rem !important;
        padding: 0.25rem 0.4rem !important;
    }
    
    /* تحسين أزرار التحكم الصغيرة */
    .btn-outline-primary,
    .btn-outline-secondary,
    .btn-outline-success {
        border-width: 1px !important;
        padding: 0.4rem 0.6rem !important;
    }
}

/* ================================
   Unified dropdown box appearance
   (Form dropdowns like Select2)
   ================================ */

/* When Select2 is open, merge the selection + dropdown into one visual box */
.select2-container.select2-container--open .select2-selection {
    border-bottom-left-radius: 0 !important;
    border-bottom-right-radius: 0 !important;
}

.select2-container.select2-container--open .select2-dropdown {
    border-top: 0 !important;
    border-top-left-radius: 0 !important;
    border-top-right-radius: 0 !important;
    margin-top: -1px;
}

/* Bootstrap-5 theme variant (if used) */
.select2-container--bootstrap-5.select2-container--open .select2-selection {
    border-bottom-left-radius: 0 !important;
    border-bottom-right-radius: 0 !important;
}

.select2-container--bootstrap-5.select2-container--open .select2-dropdown {
    border-top: 0 !important;
    border-top-left-radius: 0 !important;
    border-top-right-radius: 0 !important;
    margin-top: -1px;
}