/* ============================================
   Bootstrap CSS Variables Override
   تخصيص متغيرات Bootstrap
   ============================================ */
:root {
    --bs-primary: #8b7a5a;
    --bs-primary-rgb: 139, 122, 90;
    --bs-primary-hover: #7a6a4a;
    --bs-primary-dark: #6a5a3a;
    --bs-body-bg: #fafafa;
    /* تعطيل hover من Bootstrap CSS variables بشكل كامل */
    --bs-table-hover-bg: transparent !important;
    --bs-table-hover-color: inherit !important;
    --bs-table-bg-state: transparent !important;
    --bs-table-color-state: inherit !important;
}

/* ============================================
   Base Styles - الأنماط الأساسية
   ============================================ */
html {
  font-size: 14px;
    position: relative;
    min-height: 100%;
}

@media (min-width: 768px) {
  html {
    font-size: 16px;
  }
}

body {
    margin-bottom: 60px;
    visibility: hidden;
}

body.translation-ready,
body.login-page {
    visibility: visible;
}

/* ============================================
   Form Controls - عناصر النماذج
   استخدام Bootstrap utilities
   ============================================ */
.form-control:not(.form-control-lg):not(.form-control-sm) {
  font-size: 0.875rem;
    padding: 0.25rem 0.5rem;
}

.form-select:not(.form-select-lg):not(.form-select-sm) {
  font-size: 0.875rem;
    padding-top: 0.25rem;
    padding-bottom: 0.25rem;
    padding-left: 0.5rem;
    padding-right: 2.25rem;
}

/* إصلاح موضع السهم في قوائم الاختيار - RTL */
[dir="rtl"] .form-select {
    background-position: left 0.75rem center;
    padding-right: 0.75rem;
    padding-left: 2.25rem;
}

[dir="rtl"] .form-select:not(.form-select-lg):not(.form-select-sm) {
    padding-right: 0.5rem;
    padding-left: 2.25rem;
}

.form-label:not(.form-label-lg) {
  font-size: 0.875rem;
    font-weight: 600;
    margin-bottom: 0.25rem;
}

.form-floating > .form-control-plaintext::placeholder,
.form-floating > .form-control::placeholder {
    color: var(--bs-secondary-color);
    text-align: end;
}

.form-floating > .form-control-plaintext:focus::placeholder,
.form-floating > .form-control:focus::placeholder {
    text-align: start;
}

/* ============================================
   Buttons - الأزرار
   استخدام Bootstrap primary color
   ============================================ */
.btn-primary {
    --bs-btn-bg: var(--bs-primary);
    --bs-btn-border-color: var(--bs-primary);
    --bs-btn-hover-bg: var(--bs-primary-hover);
    --bs-btn-hover-border-color: var(--bs-primary-dark);
    --bs-btn-active-bg: var(--bs-primary-hover);
    --bs-btn-active-border-color: var(--bs-primary-dark);
    --bs-btn-focus-shadow-rgb: var(--bs-primary-rgb);
}

/* ============================================
   Navbar - شريط التنقل
   استخدام Bootstrap classes
   ============================================ */
.navbar {
    background-color: var(--bs-primary) !important;
}

.navbar-nav .nav-link {
    color: #fff !important;
    padding: 0.4rem 0.8rem;
    transition: all 0.2s ease;
    font-size: 0.8rem;
}

.navbar-nav .nav-link.active {
    background-color: rgba(255, 255, 255, 0.2);
    border-radius: var(--bs-border-radius);
    font-weight: 600;
}

.navbar-nav .nav-link:hover {
    background-color: rgba(255, 255, 255, 0.1);
    border-radius: var(--bs-border-radius);
}

.navbar-brand {
    color: #fff !important;
    font-size: 0.9rem;
}

.navbar-nav .nav-link i {
    font-size: 0.85rem;
}

.navbar .btn-outline-light:hover {
    color: var(--bs-primary);
}

/* ============================================
   Tables - الجداول
   استخدام Bootstrap table classes
   ============================================ */
.table-responsive table {
    table-layout: auto;
    width: 100%;
}

.table-responsive table th,
.table-responsive table td {
    white-space: nowrap;
    padding: 0.5rem;
}

/* Bootstrap utility class */
.text-truncate-cell {
    max-width: 150px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.table-dark,
thead.table-dark,
thead.table-dark th {
    --bs-table-bg: var(--bs-primary);
    --bs-table-color: #fff;
    --bs-table-border-color: rgba(0, 0, 0, 0.1);
}

.table-dark th {
    font-weight: 600;
}

/* إزالة تأثير hover من جميع الجداول - قواعد شاملة وقوية */
.table > tbody > tr:hover > *,
.table tbody tr:hover > *,
table.table tbody tr:hover > *,
.table > tbody > tr:hover,
.table tbody tr:hover,
table.table tbody tr:hover,
.table > tbody > tr:hover td,
.table > tbody > tr:hover th,
.table tbody tr:hover td,
.table tbody tr:hover th,
table.table tbody tr:hover td,
table.table tbody tr:hover th,
.table-bordered > tbody > tr:hover > *,
.table-bordered tbody tr:hover > *,
table.table-bordered tbody tr:hover > *,
.table-bordered > tbody > tr:hover,
.table-bordered tbody tr:hover,
table.table-bordered tbody tr:hover,
.table-hover > tbody > tr:hover > *,
.table-hover tbody tr:hover > *,
table.table-hover tbody tr:hover > *,
.table-hover > tbody > tr:hover,
.table-hover tbody tr:hover,
table.table-hover tbody tr:hover,
.table-hover > tbody > tr:hover td,
.table-hover > tbody > tr:hover th,
.table-hover tbody tr:hover td,
.table-hover tbody tr:hover th,
table.table-hover tbody tr:hover td,
table.table-hover tbody tr:hover th,
table tbody tr:hover,
table tbody tr:hover > *,
table tbody tr:hover td,
table tbody tr:hover th {
    --bs-table-hover-bg: transparent !important;
    --bs-table-hover-color: inherit !important;
    --bs-table-color-state: inherit !important;
    --bs-table-bg-state: transparent !important;
    background-color: inherit !important;
    background: inherit !important;
    color: inherit !important;
}

/* إزالة تأثير hover من الجداول المخططة - قواعد خاصة وقوية */
.table-striped > tbody > tr:hover > *,
.table-striped tbody tr:hover > *,
table.table-striped tbody tr:hover > *,
.table-striped > tbody > tr:hover,
.table-striped tbody tr:hover,
table.table-striped tbody tr:hover,
.table-striped > tbody > tr:hover td,
.table-striped > tbody > tr:hover th,
.table-striped tbody tr:hover td,
.table-striped tbody tr:hover th,
table.table-striped tbody tr:hover td,
table.table-striped tbody tr:hover th {
    --bs-table-hover-bg: transparent !important;
    --bs-table-hover-color: inherit !important;
    /* منع أي تغيير في state variables - استخدام اللون الأصلي للصف */
    --bs-table-color-state: var(--bs-table-color-type, var(--bs-table-color, inherit)) !important;
    --bs-table-bg-state: var(--bs-table-bg-type, var(--bs-table-bg, transparent)) !important;
    /* استخدام اللون الأصلي للصف مباشرة - لا inherit */
    background-color: var(--bs-table-bg-type, var(--bs-table-bg, transparent)) !important;
    background: var(--bs-table-bg-type, var(--bs-table-bg, transparent)) !important;
    color: var(--bs-table-color-type, var(--bs-table-color, inherit)) !important;
    /* منع أي تأثيرات إضافية */
    box-shadow: none !important;
    opacity: 1 !important;
}

/* قاعدة إضافية للجداول المخططة - تغطية شاملة للصفوف الفردية والزوجية */
.table-striped > tbody > tr:nth-of-type(odd):hover > *,
.table-striped > tbody > tr:nth-of-type(odd):hover,
.table-striped > tbody > tr:nth-of-type(odd):hover td,
.table-striped > tbody > tr:nth-of-type(odd):hover th,
.table-striped tbody tr:nth-of-type(odd):hover > *,
.table-striped tbody tr:nth-of-type(odd):hover,
.table-striped tbody tr:nth-of-type(odd):hover td,
.table-striped tbody tr:nth-of-type(odd):hover th,
table.table-striped tbody tr:nth-of-type(odd):hover > *,
table.table-striped tbody tr:nth-of-type(odd):hover,
table.table-striped tbody tr:nth-of-type(odd):hover td,
table.table-striped tbody tr:nth-of-type(odd):hover th,
.table-striped > tbody > tr:nth-of-type(even):hover > *,
.table-striped > tbody > tr:nth-of-type(even):hover,
.table-striped > tbody > tr:nth-of-type(even):hover td,
.table-striped > tbody > tr:nth-of-type(even):hover th,
.table-striped tbody tr:nth-of-type(even):hover > *,
.table-striped tbody tr:nth-of-type(even):hover,
.table-striped tbody tr:nth-of-type(even):hover td,
.table-striped tbody tr:nth-of-type(even):hover th,
table.table-striped tbody tr:nth-of-type(even):hover > *,
table.table-striped tbody tr:nth-of-type(even):hover,
table.table-striped tbody tr:nth-of-type(even):hover td,
table.table-striped tbody tr:nth-of-type(even):hover th {
    /* منع أي تغيير في state variables - استخدام اللون الأصلي للصف */
    --bs-table-color-state: var(--bs-table-color-type, var(--bs-table-color, inherit)) !important;
    --bs-table-bg-state: var(--bs-table-bg-type, var(--bs-table-bg, transparent)) !important;
    --bs-table-hover-bg: transparent !important;
    --bs-table-hover-color: inherit !important;
    /* استخدام اللون الأصلي للصف مباشرة - لا inherit */
    background-color: var(--bs-table-bg-type, var(--bs-table-bg, transparent)) !important;
    background: var(--bs-table-bg-type, var(--bs-table-bg, transparent)) !important;
    color: var(--bs-table-color-type, var(--bs-table-color, inherit)) !important;
    /* منع أي تأثيرات إضافية */
    box-shadow: none !important;
    opacity: 1 !important;
    filter: none !important;
}

/* قاعدة إضافية قوية - تغطي جميع الجداول بأي كلاس */
*[class*="table"] tbody tr:hover,
*[class*="table"] tbody tr:hover > *,
*[class*="table"] tbody tr:hover td,
*[class*="table"] tbody tr:hover th {
    --bs-table-hover-bg: transparent !important;
    --bs-table-hover-color: inherit !important;
    --bs-table-color-state: inherit !important;
    --bs-table-bg-state: transparent !important;
    background-color: inherit !important;
    background: inherit !important;
    color: inherit !important;
}

/* قاعدة نهائية - تغطي جميع الجداول بدون استثناء */
tbody tr:hover,
tbody tr:hover > *,
tbody tr:hover td,
tbody tr:hover th {
    --bs-table-hover-bg: transparent !important;
    --bs-table-hover-color: inherit !important;
    --bs-table-color-state: inherit !important;
    --bs-table-bg-state: transparent !important;
    background-color: inherit !important;
    background: inherit !important;
    color: inherit !important;
}

/* ============================================
   Cards - البطاقات
   استخدام Bootstrap card classes
   ============================================ */
.card-header.bg-primary,
.card-header.bg-info,
.card-header.bg-success,
.card-header.bg-warning,
.card-header.bg-secondary,
.card-header.bg-light {
    background-color: var(--bs-primary) !important;
    color: #fff !important;
    border-bottom: 1px solid rgba(0, 0, 0, 0.1);
}

/* بطاقات الإحصائيات - الحفاظ على ألوان Bootstrap الأصلية */
.card.border-success .card-header.bg-success {
    background-color: var(--bs-success) !important;
}

.card.border-info .card-header.bg-info {
    background-color: var(--bs-info) !important;
}

.card.border-warning .card-header.bg-warning {
    background-color: var(--bs-warning) !important;
}

.card.border-danger .card-header.bg-danger {
    background-color: var(--bs-danger) !important;
}

.card.border-secondary .card-header.bg-secondary {
    background-color: var(--bs-secondary) !important;
}

/* بطاقات أخرى - استخدام لون النافبار */
.card-header.bg-success:not(.card.border-success .card-header),
.card-header.bg-info:not(.card.border-info .card-header),
.card-header.bg-warning:not(.card.border-warning .card-header) {
    background-color: var(--bs-primary) !important;
}

.card.bg-light .card-header,
.card .card-header.bg-light {
    background-color: var(--bs-primary) !important;
    color: #fff !important;
}

/* ============================================
   Primary Color Elements - عناصر اللون الأساسي
   استخدام Bootstrap text utilities
   ============================================ */
.text-primary {
    --bs-text-opacity: 1;
    color: var(--bs-primary) !important;
}

a.text-primary:hover {
    color: var(--bs-primary-hover) !important;
}

.badge.bg-primary {
    --bs-bg-opacity: 1;
    background-color: var(--bs-primary) !important;
}

/* ============================================
   Pagination - التصفح
   استخدام Bootstrap pagination
   ============================================ */
.pagination .page-link {
    color: var(--bs-primary);
    border-color: rgba(0, 0, 0, 0.1);
}

.pagination .page-link:hover {
    background-color: var(--bs-primary);
    border-color: var(--bs-primary);
    color: #fff !important;
}

.pagination .page-item.active .page-link {
    background-color: var(--bs-primary);
    border-color: var(--bs-primary);
    color: #fff;
}

.pagination .page-link:focus {
    box-shadow: 0 0 0 0.25rem rgba(var(--bs-primary-rgb), 0.25);
}

/* ============================================
   Login Page - صفحة تسجيل الدخول
   استخدام Bootstrap utilities
   ============================================ */
body.login-page {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background-color: #fafafa;
}

.login-container {
    background: white;
    border-radius: 1rem;
    box-shadow: 0 10px 40px rgba(0,0,0,0.1);
    padding: 2.5rem;
    max-width: 400px;
    width: 100%;
    border: 1px solid rgba(0,0,0,0.1);
}

.login-header {
    text-align: center;
    margin-bottom: 2rem;
}

.login-logo {
    display: block;
    margin: 0 auto;
    max-width: 200px;
    width: 100%;
    height: auto;
}

.btn-login {
    width: 100%;
    padding: 0.75rem;
    font-weight: bold;
    border-radius: 0.5rem;
    background-color: var(--bs-primary) !important;
    border-color: var(--bs-primary) !important;
    color: white !important;
}

.btn-login:hover {
    background-color: var(--bs-primary-hover) !important;
    border-color: var(--bs-primary-dark) !important;
    color: white !important;
}

.login-container .alert {
    border-radius: 0.5rem;
}

/* Password Input Wrapper - حاوية إدخال كلمة المرور */
.password-input-wrapper {
    position: relative;
}

.password-input-wrapper .form-control {
    padding-right: 45px;
}

[dir="rtl"] .password-input-wrapper .form-control {
    padding-right: 45px !important;
    padding-left: 0.75rem;
}

[dir="ltr"] .password-input-wrapper .form-control {
    padding-right: 0.75rem;
    padding-left: 45px !important;
}

.password-toggle {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    background: none;
    border: none;
    color: var(--bs-secondary);
    cursor: pointer;
    padding: 0.5rem;
    z-index: 10;
    display: flex;
    align-items: center;
    justify-content: center;
}

.password-toggle:hover {
    color: var(--bs-primary);
}

[dir="rtl"] .password-toggle {
    right: 0.5rem;
    left: auto;
}

[dir="ltr"] .password-toggle {
    left: 0.5rem;
    right: auto;
}

/* ============================================
   Input Groups - مجموعات الإدخال
   ============================================ */
.input-group:not(.input-group-lg):not(.input-group-sm) {
  font-size: 0.875rem;
}

.input-group:not(.input-group-lg):not(.input-group-sm) > .form-control,
.input-group:not(.input-group-lg):not(.input-group-sm) > .form-select,
.input-group:not(.input-group-lg):not(.input-group-sm) > .form-floating,
.input-group:not(.input-group-lg):not(.input-group-sm) > .btn {
  font-size: 0.875rem;
  padding: 0.25rem 0.5rem;
}

/* ============================================
   RTL Border Radius Fixes - إصلاحات انحناء الحواف للواجهة العربية
   ============================================ */
[dir="rtl"] .input-group:not(.has-validation) > :not(:last-child):not(.dropdown-toggle):not(.dropdown-menu):not(.form-floating) {
    border-top-left-radius: 0 !important;
    border-bottom-left-radius: 0 !important;
    border-top-right-radius: var(--bs-border-radius) !important;
    border-bottom-right-radius: var(--bs-border-radius) !important;
}

[dir="rtl"] .input-group:not(.has-validation) > .form-floating:not(:last-child) > .form-control,
[dir="rtl"] .input-group:not(.has-validation) > .form-floating:not(:last-child) > .form-select {
    border-top-left-radius: 0 !important;
    border-bottom-left-radius: 0 !important;
    border-top-right-radius: var(--bs-border-radius) !important;
    border-bottom-right-radius: var(--bs-border-radius) !important;
}

[dir="rtl"] .input-group > :not(:first-child):not(.dropdown-menu):not(.valid-tooltip):not(.valid-feedback):not(.invalid-tooltip):not(.invalid-feedback) {
    border-top-right-radius: 0 !important;
    border-bottom-right-radius: 0 !important;
    border-top-left-radius: var(--bs-border-radius) !important;
    border-bottom-left-radius: var(--bs-border-radius) !important;
}

[dir="rtl"] .input-group > .form-floating:not(:first-child) > .form-control,
[dir="rtl"] .input-group > .form-floating:not(:first-child) > .form-select {
    border-top-right-radius: 0 !important;
    border-bottom-right-radius: 0 !important;
    border-top-left-radius: var(--bs-border-radius) !important;
    border-bottom-left-radius: var(--bs-border-radius) !important;
}

[dir="rtl"] .btn-group > .btn:first-child:not(:last-child):not(.dropdown-toggle) {
    border-top-left-radius: 0 !important;
    border-bottom-left-radius: 0 !important;
    border-top-right-radius: var(--bs-border-radius) !important;
    border-bottom-right-radius: var(--bs-border-radius) !important;
}

[dir="rtl"] .btn-group > .btn:last-child:not(:first-child),
[dir="rtl"] .btn-group > .dropdown-toggle:not(:first-child) {
    border-top-right-radius: 0 !important;
    border-bottom-right-radius: 0 !important;
    border-top-left-radius: var(--bs-border-radius) !important;
    border-bottom-left-radius: var(--bs-border-radius) !important;
}

[dir="rtl"] .btn-group > .btn:not(:first-child):not(:last-child):not(.dropdown-toggle) {
    border-radius: 0 !important;
}

[dir="rtl"] .btn-group > .btn:only-child {
    border-radius: var(--bs-border-radius) !important;
}
