/**
 * ملف CSS بسيط لتعديل النصوص والمدخلات من اليمين إلى اليسار
 * Sidebar, Navbar, Header, Footer تبقى كما هي
 * الجداول: الوسط كما هو، البحث والفرز كما هو
 * يجب تحميل هذا الملف بعد styles.css
 */

/* استثناءات: Sidebar, Navbar, Header, Footer, Page Title Area تبقى كما هي */
/* .sidebar-menu removed */
.sidebar-header,
.main-menu,
.menu-inner,
.header-area,
.notification-area,
.user-profile,
.page-title-area,
.page-title-area *,
.breadcrumbs-area,
.page-title {
    direction: ltr !important;
    text-align: left !important;
}

/* استثناءات: عناصر البحث والفرز في الجداول تبقى كما هي (LTR) */
/* الجدول نفسه يبقى RTL */
.dataTables_wrapper table.dataTable,
.dataTables_wrapper table.table {
    direction: rtl !important;
}

.dataTables_wrapper table.dataTable thead th,
.dataTables_wrapper table.dataTable tbody td,
.dataTables_wrapper table.table thead th,
.dataTables_wrapper table.table tbody td {
    direction: rtl !important;
    text-align: right !important;
}

/* تعديلات على عناصر البحث والفرز فقط - أعلى الجدول */
div.dataTables_wrapper>div.row:first-of-type {
    margin-left: 0 !important;
    margin-right: 0 !important;
    margin-bottom: 1rem !important;
    overflow: hidden !important;
}

div.dataTables_wrapper>div.row:first-of-type>div.col-sm-12,
div.dataTables_wrapper>div.row:first-of-type>div.col-md-6 {
    width: auto !important;
    padding-left: 15px !important;
    padding-right: 15px !important;
    float: none !important;
    display: inline-block !important;
}

/* Show entries في اليمين */
div.dataTables_wrapper>div.row:first-of-type>div.col-sm-12:first-child,
div.dataTables_wrapper>div.row:first-of-type>div.col-md-6:first-child {
    float: right !important;
    margin-left: 20px !important;
    margin-right: 0 !important;
}

/* Search في اليسار */
div.dataTables_wrapper>div.row:first-of-type>div.col-sm-12:last-child,
div.dataTables_wrapper>div.row:first-of-type>div.col-md-6:last-child {
    float: left !important;
    margin-right: 20px !important;
    margin-left: 0 !important;
}

div.dataTables_wrapper div.dataTables_length {
    direction: ltr !important;
    text-align: left !important;
    float: none !important;
    display: inline-block !important;
}

div.dataTables_wrapper div.dataTables_length label,
div.dataTables_wrapper div.dataTables_length select {
    direction: ltr !important;
    text-align: left !important;
}

div.dataTables_wrapper div.dataTables_filter {
    direction: ltr !important;
    text-align: left !important;
    float: none !important;
    display: inline-block !important;
}

div.dataTables_wrapper div.dataTables_filter label {
    direction: ltr !important;
    text-align: right !important;
}

div.dataTables_wrapper div.dataTables_filter input {
    direction: ltr !important;
    text-align: left !important;
}

/* أسفل الجدول */
div.dataTables_wrapper>div.row:last-of-type {
    margin-left: 0 !important;
    margin-right: 0 !important;
    margin-top: 1rem !important;
    overflow: hidden !important;
}

div.dataTables_wrapper>div.row:last-of-type>div.col-sm-12,
div.dataTables_wrapper>div.row:last-of-type>div.col-md-6 {
    width: auto !important;
    padding-left: 15px !important;
    padding-right: 15px !important;
    float: none !important;
    display: inline-block !important;
}

/* Showing info في اليمين */
div.dataTables_wrapper>div.row:last-of-type>div.col-sm-12:first-child,
div.dataTables_wrapper>div.row:last-of-type>div.col-md-6:first-child {
    float: right !important;
    margin-left: 20px !important;
    margin-right: 0 !important;
}

/* Pagination في اليسار */
div.dataTables_wrapper>div.row:last-of-type>div.col-sm-12:last-child,
div.dataTables_wrapper>div.row:last-of-type>div.col-md-6:last-child {
    float: left !important;
    margin-right: 20px !important;
    margin-left: 0 !important;
}

div.dataTables_wrapper div.dataTables_info {
    direction: ltr !important;
    text-align: left !important;
    float: none !important;
    display: inline-block !important;
}

div.dataTables_wrapper div.dataTables_paginate {
    direction: ltr !important;
    text-align: left !important;
    float: none !important;
    display: inline-block !important;
}

div.dataTables_wrapper div.dataTables_paginate .paginate_button {
    direction: ltr !important;
    text-align: center !important;
}

/* Footer في الوسط */
footer,
footer *,
.footer-area,
.footer-area *,
.footer-area p,
.footer-area a {
    direction: ltr !important;
    text-align: center !important;
}

/* توجيه النصوص والمدخلات */
body {
    direction: ltr;
    text-align: right;
}

.main-content {
    direction: rtl;
}

/* النماذج والمدخلات */
.form-control,
input[type="text"],
input[type="email"],
input[type="password"],
input[type="number"],
input[type="date"],
input[type="tel"],
textarea,
select {
    direction: rtl;
    text-align: right;
}

/* التسميات */
label,
.col-form-label {
    text-align: right;
}

/* النصوص في الكروت والعناصر */
.card-body,
.card-title,
.card-text,
p,
h1,
h2,
h3,
h4,
h5,
h6 {
    text-align: right;
    direction: rtl;
}

/* الرسائل والتذكيرات */
.alert {
    direction: rtl;
    text-align: right;
}

/* الأزرار - النصوص فقط */
.btn {
    direction: rtl;
}

/* القوائم المنسدلة في الجداول (البحث والفرز) - تبقى LTR كما هي */

/* القوائم المنسدلة في النماذج */
.custom-select,
select.form-control {
    direction: rtl;
    text-align: right;
    padding-right: 12px;
    padding-left: 30px;
}

/* أيقونات القوائم المنسدلة - تعديل الموضع */
select.custom-select,
select.form-control {
    background-position: left 0.75rem center;
    background-size: 16px 12px;
}

/* إلغاء الارتفاع الثابت من Bootstrap لـ select في حقول البحث والفلترة */
/* جعل select يأخذ الحجم تلقائياً حسب المحتوى */
select.form-control:not([size]):not([multiple]) {
    height: auto !important;
    min-height: calc(2.25rem + 2px);
    padding-top: 0.375rem;
    padding-bottom: 0.375rem;
}

/* النصوص في الجداول - الأعمدة فقط (ليس البحث والفرز) */
/* تعطيل text-center على الجداول لتفعيل المحاذاة المخصصة */
table.dataTable.text-center thead th,
table.dataTable.text-center tbody td {
    text-align: right;
    direction: rtl;
}

table.table.text-center thead th,
table.table.text-center tbody td {
    text-align: right;
    direction: rtl;
}

/* الحقول في النماذج */
.form-group {
    text-align: right;
}

/* Checkbox و Radio - النصوص فقط */
.custom-control-label {
    text-align: right;
    padding-right: 1.5rem;
    padding-left: 0;
}

.custom-control-input:checked~.custom-control-label::before {
    right: 0;
    left: auto;
}

/* Breadcrumbs - تبقى LTR */
.breadcrumbs {
    direction: ltr !important;
}

.breadcrumbs li {
    float: left !important;
}

/* Badges و Labels */
.badge,
.label {
    direction: rtl;
}

/* Modal */
.modal-header,
.modal-body,
.modal-footer {
    direction: rtl;
    text-align: right;
}

/* List groups */
.list-group-item {
    text-align: right;
    direction: rtl;
}

/* Nav tabs */
.nav-tabs .nav-link {
    text-align: right;
}

/* Tooltips */
.tooltip {
    direction: rtl;
}

/* Dropdown menus - النصوص فقط */
.dropdown-menu {
    direction: rtl;
    text-align: right;
}

.dropdown-item {
    text-align: right;
}

/* Pagination */
.pagination {
    direction: ltr;
    /* Pagination يبقى من اليسار لليمين */
}

/* Input groups */
.input-group-prepend,
.input-group-append {
    direction: rtl;
}

.input-group>.form-control:not(:last-child),
.input-group>.custom-select:not(:last-child) {
    border-top-left-radius: 0;
    border-bottom-left-radius: 0;
    border-top-right-radius: 0.25rem;
    border-bottom-right-radius: 0.25rem;
}

.input-group>.input-group-prepend>.btn,
.input-group>.input-group-prepend>.input-group-text {
    border-top-right-radius: 0;
    border-bottom-right-radius: 0;
    border-top-left-radius: 0.25rem;
    border-bottom-left-radius: 0.25rem;
}

/* Text muted */
.text-muted {
    text-align: right;
}

/* Small text */
small,
.small {
    text-align: right;
}

/* Help text */
.form-text {
    text-align: right;
}

/* محاذاة بعض أعمدة الجداول في الوسط */
/* جدول الأقسام: عمود "اختصار القسم" في الوسط (العمود 3) */
.dataTables_wrapper table.dataTable tbody tr td:nth-child(3),
.dataTables_wrapper table.table tbody tr td:nth-child(3) {
    text-align: center !important;
}

.dataTables_wrapper table.dataTable thead tr th:nth-child(3),
.dataTables_wrapper table.table thead tr th:nth-child(3) {
    text-align: center !important;
}

/* جدول الأقسام: عمود "كود القسم" في الوسط (العمود 4) */
.dataTables_wrapper table.dataTable tbody tr td:nth-child(4),
.dataTables_wrapper table.table tbody tr td:nth-child(4) {
    text-align: center !important;
}

.dataTables_wrapper table.dataTable thead tr th:nth-child(4),
.dataTables_wrapper table.table thead tr th:nth-child(4) {
    text-align: center !important;
}

/* جدول الأقسام: عمود "نوع القسم" في الوسط (العمود 5) */
.dataTables_wrapper table.dataTable tbody tr td:nth-child(5),
.dataTables_wrapper table.table tbody tr td:nth-child(5) {
    text-align: center !important;
}

.dataTables_wrapper table.dataTable thead tr th:nth-child(5),
.dataTables_wrapper table.table thead tr th:nth-child(5) {
    text-align: center !important;
}

/* جدول الموظفين: عمود "حالة الموظف" في الوسط (العمود 6) */
.dataTables_wrapper table.dataTable tbody tr td:nth-child(6),
.dataTables_wrapper table.table tbody tr td:nth-child(6) {
    text-align: center !important;
}

.dataTables_wrapper table.dataTable thead tr th:nth-child(6),
.dataTables_wrapper table.table thead tr th:nth-child(6) {
    text-align: center !important;
}

/* جدول الموظفين: عمود "كود التحقق" في الوسط (العمود 7) */
.dataTables_wrapper table.dataTable tbody tr td:nth-child(7),
.dataTables_wrapper table.table tbody tr td:nth-child(7) {
    text-align: center !important;
}

.dataTables_wrapper table.dataTable thead tr th:nth-child(7),
.dataTables_wrapper table.table thead tr th:nth-child(7) {
    text-align: center !important;
}

/* جدول الإجازات: عمود "الملاحظة" في الوسط (العمود 3 في leave-section.php) */
table.table tbody tr td:nth-child(3):has-content,
table.dataTable tbody tr td:nth-child(3) {
    text-align: center !important;
}

table.table thead tr th:nth-child(3),
table.dataTable thead tr th:nth-child(3) {
    text-align: center !important;
}

/* جدول الإجازات - عمود الملاحظة في leave-section.php (العمود 3) */
#dataTable3 tbody tr td:nth-child(3),
#leaveTable tbody tr td:nth-child(3) {
    text-align: center !important;
}

#dataTable3 thead tr th:nth-child(3),
#leaveTable thead tr th:nth-child(3) {
    text-align: center !important;
}

/* تحسين العرض المتجاوب للجداول */
.dataTables_wrapper .table-responsive {
    overflow-x: visible !important;
    margin-bottom: 0;
}

/* تحسين عرض الجداول على الشاشات الصغيرة */
@media screen and (max-width: 992px) {
    .dataTables_wrapper .table {
        font-size: 0.875rem;
    }

    .dataTables_wrapper .table td,
    .dataTables_wrapper .table th {
        padding: 0.5rem 0.25rem;
        white-space: nowrap;
    }

    /* تحسين عرض الأزرار في الجداول */
    .dataTables_wrapper .table .btn {
        padding: 0.25rem 0.5rem;
        font-size: 0.75rem;
    }
}

/* تحسين عرض Responsive child rows في DataTables */
table.dataTable.dtr-inline.collapsed>tbody>tr>td.child,
table.dataTable.dtr-inline.collapsed>tbody>tr>th.child,
table.dataTable.dtr-inline.collapsed>tbody>tr>td.dataTables_empty {
    cursor: default !important;
}

table.dataTable.dtr-inline.collapsed>tbody>tr>td.control:before,
table.dataTable.dtr-inline.collapsed>tbody>tr>th.control:before {
    background-color: #007bff !important;
    border: 2px solid white !important;
    box-shadow: 0 0 3px rgba(0, 0, 0, 0.3) !important;
}

table.dataTable.dtr-inline.collapsed>tbody>tr.parent>td.control:before,
table.dataTable.dtr-inline.collapsed>tbody>tr.parent>th.control:before {
    background-color: #28a745 !important;
}

/* جعل التاريخ والوقت في سطر واحد */
/* جدول أنواع الإجازات في leave-section.php (#dataTable3) - عمود تاريخ الإنشاء (العمود 4) */
#dataTable3 tbody tr td:nth-child(4),
#dataTable3 thead tr th:nth-child(4) {
    white-space: nowrap !important;
    word-wrap: normal !important;
    word-break: keep-all !important;
}

/* جدول قيود الطلبات في leave-section.php (#dataTable4) - عمود تاريخ التحديث (العمود 6) */
#dataTable4 tbody tr td:nth-child(6),
#dataTable4 thead tr th:nth-child(6) {
    white-space: nowrap !important;
    word-wrap: normal !important;
    word-break: keep-all !important;
}

/* جدول الموظفين في employees.php (#dataTable3) - عمود تاريخ التسجيل (العمود 5) */
#dataTable3 tbody tr td:nth-child(5),
#dataTable3 thead tr th:nth-child(5) {
    white-space: nowrap !important;
    word-wrap: normal !important;
    word-break: keep-all !important;
}

/* تحسين مظهر checkbox في leave-section.php */
.form-check {
    display: flex;
    align-items: center;
    direction: rtl;
    padding-top: 0.25rem;
}

.form-check-input {
    margin-right: 0 !important;
    margin-left: 0.75rem !important;
    margin-top: 0.1rem !important;
    cursor: pointer;
    position: relative;
    top: 0.05rem;
}

.form-check-label {
    margin-right: 0 !important;
    margin-left: 0 !important;
    padding-right: 0.25rem;
    cursor: pointer;
    user-select: none;
    font-weight: 500;
}

/* تحسين عرض جداول الإجازات على الهاتف فقط */
@media screen and (max-width: 768px) {

    /* تحسين table-responsive للهاتف */
    #leaveTable_wrapper .table-responsive,
    .single-table .table-responsive {
        display: block !important;
        width: 100% !important;
        overflow-x: auto !important;
        -webkit-overflow-scrolling: touch !important;
        position: relative !important;
    }

    /* تحسين عرض الجدول على الهاتف */
    #leaveTable_wrapper table#leaveTable,
    table#leaveTable {
        width: 100% !important;
        display: table !important;
        min-width: 900px !important;
    }

    /* تحسين عرض الخلايا على الهاتف */
    #leaveTable_wrapper table#leaveTable td,
    #leaveTable_wrapper table#leaveTable th,
    table#leaveTable td,
    table#leaveTable th {
        white-space: nowrap !important;
        padding: 0.5rem 0.5rem !important;
        font-size: 0.875rem !important;
    }

    /* تحسين عرض الأزرار على الهاتف */
    #leaveTable_wrapper table#leaveTable .btn,
    table#leaveTable .btn {
        padding: 0.25rem 0.5rem !important;
        font-size: 0.75rem !important;
        white-space: nowrap !important;
    }

    /* تحسين عرض عناصر البحث والفرز على الموبايل */
    #leaveTable_wrapper .dataTables_length,
    #leaveTable_wrapper .dataTables_filter {
        margin-bottom: 0.5rem;
        width: 100%;
        text-align: center;
    }

    #leaveTable_wrapper .dataTables_length label,
    #leaveTable_wrapper .dataTables_filter label {
        display: block;
        margin-bottom: 0.25rem;
    }
}