/* متغيرات الألوان الأساسية */
:root {
  --primary-color: #4A6E9E;
  --secondary-color: #FDD006;
  --primary-dark: #3A5A7E;
  --primary-light: #6B8DBE;
  --secondary-dark: #E5C005;
  --accent-color: #2C3E50;
  --success-color: #28a745;
  --info-color: #17a2b8;
  --warning-color: #ffc107;
  --danger-color: #dc3545;
}

html {
  font-size: 14px;
}

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

.btn:focus, .btn:active:focus, .btn-link.nav-link:focus, .form-control:focus, .form-check-input:focus {
  box-shadow: 0 0 0 0.1rem white, 0 0 0 0.25rem var(--primary-color);
}

html {
  position: relative;
  min-height: 100%;
}

body {
  margin-bottom: 60px;
}

.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;
}

/* جعل الحقول غير القابلة للكتابة باللون الرمادي */
input[readonly],
textarea[readonly],
input.form-control[readonly] {
  background-color: #e9ecef !important;
  cursor: not-allowed;
  opacity: 0.8;
}

/* السكرول الأفقي للجداول */
.table-responsive {
  display: block !important;
  width: 100% !important;
  overflow-x: auto !important;
  overflow-y: hidden !important;
  -webkit-overflow-scrolling: touch;
  max-width: 100%;
  position: relative;
  margin-bottom: 1rem;
  -ms-overflow-style: -ms-autohiding-scrollbar;
}

.table-responsive::-webkit-scrollbar {
  height: 8px;
}

.table-responsive::-webkit-scrollbar-track {
  background: #f1f1f1;
  border-radius: 4px;
}

.table-responsive::-webkit-scrollbar-thumb {
  background: var(--primary-color);
  border-radius: 4px;
}

.table-responsive::-webkit-scrollbar-thumb:hover {
  background: var(--primary-dark);
}

.table-responsive table {
  width: auto !important;
  min-width: 100% !important;
  margin-bottom: 0 !important;
  table-layout: auto !important;
}

/* منع التفاف النص في جميع الجداول */
.table-responsive th,
.table-responsive td,
.table th,
.table td {
  white-space: nowrap !important;
  word-wrap: normal !important;
  overflow: visible !important;
  text-overflow: clip !important;
  min-width: 100px !important;
  max-width: none !important;
  padding: 0.75rem !important;
}

/* عرض أقصى محدد للأعمدة الشائعة */
.table-responsive th:first-child,
.table-responsive td:first-child {
  min-width: 120px !important;
}

.table-responsive th:nth-child(2),
.table-responsive td:nth-child(2) {
  min-width: 150px !important;
}

/* عمود الإجراءات */
.table-responsive th:has(+ th:last-child),
.table-responsive td:has(+ td:last-child),
.table-responsive th:last-child,
.table-responsive td:last-child {
  min-width: 200px !important;
  white-space: nowrap !important;
}

/* السماح بتقصير النص في الخلايا التي تحتوي على نصوص طويلة مع tooltip */
.table-responsive td span[title],
.table td span[title] {
  white-space: nowrap !important;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 200px;
  display: inline-block;
  vertical-align: middle;
}

/* ضمان عدم التفاف النص في أزرار الإجراءات */
.table-responsive .btn,
.table .btn {
  white-space: nowrap !important;
  flex-shrink: 0 !important;
  min-width: auto !important;
}

/* ضمان عدم التفاف أزرار الإجراءات - كلها في صف واحد */
.table-responsive .d-flex.gap-1,
.table .d-flex.gap-1 {
  white-space: nowrap !important;
  flex-wrap: nowrap !important;
  display: flex !important;
  align-items: center !important;
  justify-content: flex-start !important;
}

/* عمود الإجراءات - عرض كافٍ لجميع الأزرار */
.table-responsive td:has(.d-flex.gap-1),
.table td:has(.d-flex.gap-1) {
  min-width: 280px !important;
  max-width: none !important;
  white-space: nowrap !important;
}

/* عكس انحناء الحواف في pagination ليتناسب مع RTL */
.pagination .page-item:first-child .page-link {
  border-top-left-radius: 0 !important;
  border-top-right-radius: 0.375rem !important;
  border-bottom-left-radius: 0 !important;
  border-bottom-right-radius: 0.375rem !important;
}

.pagination .page-item:last-child .page-link {
  border-top-left-radius: 0.375rem !important;
  border-top-right-radius: 0 !important;
  border-bottom-left-radius: 0.375rem !important;
  border-bottom-right-radius: 0 !important;
}

.pagination .page-item:only-child .page-link {
  border-radius: 0.375rem !important;
}

/* الألوان الأساسية للموقع */
.btn-primary {
  background-color: var(--primary-color) !important;
  border-color: var(--primary-color) !important;
  box-shadow: 0 2px 8px rgba(74, 110, 158, 0.3);
  transition: all 0.3s ease;
}

.btn-primary:hover {
  background-color: var(--primary-dark) !important;
  border-color: var(--primary-dark) !important;
  box-shadow: 0 4px 12px rgba(74, 110, 158, 0.4);
}

.btn-secondary {
  background-color: #6c757d !important;
  border-color: #6c757d !important;
  box-shadow: 0 2px 8px rgba(108, 117, 125, 0.3);
  transition: all 0.3s ease;
}

.btn-secondary:hover {
  background-color: #5a6268 !important;
  border-color: #5a6268 !important;
  box-shadow: 0 4px 12px rgba(108, 117, 125, 0.4);
}

.btn-success {
  background-color: var(--success-color) !important;
  border-color: var(--success-color) !important;
  box-shadow: 0 2px 8px rgba(40, 167, 69, 0.3);
  transition: all 0.3s ease;
}

.btn-success:hover {
  background-color: #218838 !important;
  border-color: #218838 !important;
  box-shadow: 0 4px 12px rgba(40, 167, 69, 0.4);
}

.btn-warning {
  background-color: var(--warning-color) !important;
  border-color: var(--warning-color) !important;
  box-shadow: 0 2px 8px rgba(255, 193, 7, 0.3);
  transition: all 0.3s ease;
}

.btn-warning:hover {
  background-color: #e0a800 !important;
  border-color: #e0a800 !important;
  box-shadow: 0 4px 12px rgba(255, 193, 7, 0.4);
}

.btn-info {
  background-color: var(--info-color) !important;
  border-color: var(--info-color) !important;
  box-shadow: 0 2px 8px rgba(23, 162, 184, 0.3);
  transition: all 0.3s ease;
}

.btn-info:hover {
  background-color: #138496 !important;
  border-color: #138496 !important;
  box-shadow: 0 4px 12px rgba(23, 162, 184, 0.4);
}

.btn-danger {
  background-color: var(--danger-color) !important;
  border-color: var(--danger-color) !important;
  box-shadow: 0 2px 8px rgba(220, 53, 69, 0.3);
  transition: all 0.3s ease;
}

.btn-danger:hover {
  background-color: #c82333 !important;
  border-color: #c82333 !important;
  box-shadow: 0 4px 12px rgba(220, 53, 69, 0.4);
}

/* Navbar styling */
.navbar {
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.08), 0 1px 3px rgba(0, 0, 0, 0.05);
  background: linear-gradient(135deg, #ffffff 0%, #f8f9fa 50%, #ffffff 100%) !important;
  padding: 1rem 0;
  border-bottom: 2px solid rgba(74, 110, 158, 0.1);
  position: relative;
}

.navbar::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 3px;
  background: linear-gradient(90deg, var(--primary-color) 0%, var(--primary-light) 50%, var(--primary-color) 100%);
}

.navbar-brand {
  font-size: 1.5rem;
  font-weight: 700;
  letter-spacing: -0.5px;
  padding: 0.5rem 1rem;
  border-radius: 8px;
  transition: all 0.3s ease;
  position: relative;
  background: linear-gradient(135deg, var(--primary-color) 0%, var(--primary-light) 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.navbar-brand:hover {
  transform: scale(1.05);
  text-shadow: 0 2px 10px rgba(74, 110, 158, 0.3);
}

.nav-link {
  transition: all 0.3s ease;
  color: var(--accent-color) !important;
  font-weight: 500;
  padding: 0.5rem 1.2rem !important;
  margin: 0 0.2rem;
  border-radius: 6px;
  position: relative;
}

.nav-link::before {
  content: '';
  position: absolute;
  bottom: 0;
  left: 50%;
  transform: translateX(-50%);
  width: 0;
  height: 2px;
  background: linear-gradient(90deg, var(--primary-color) 0%, var(--primary-light) 100%);
  transition: width 0.3s ease;
}

.nav-link:hover {
  color: var(--primary-color) !important;
  background-color: rgba(74, 110, 158, 0.05);
}

.nav-link:hover::before {
  width: 80%;
}

.nav-link.active,
.nav-item.active .nav-link {
  color: var(--primary-color) !important;
  background-color: rgba(74, 110, 158, 0.1) !important;
  font-weight: 600;
}

.nav-link.active::before,
.nav-item.active .nav-link::before {
  width: 80%;
}

.navbar-toggler {
  border: 2px solid rgba(74, 110, 158, 0.2);
  border-radius: 6px;
  padding: 0.4rem 0.6rem;
  transition: all 0.3s ease;
}

.navbar-toggler:hover {
  border-color: var(--primary-color);
  background-color: rgba(74, 110, 158, 0.05);
}

.navbar-toggler:focus {
  box-shadow: 0 0 0 0.2rem rgba(74, 110, 158, 0.25);
}

/* Cards styling */
.card {
  box-shadow: 0 4px 15px rgba(0, 0, 0, 0.1);
  border: none;
  transition: all 0.3s ease;
  border-radius: 10px;
}

.card:hover {
  box-shadow: 0 8px 25px rgba(0, 0, 0, 0.15);
}

.card-header {
  background: linear-gradient(135deg, var(--primary-color) 0%, var(--primary-light) 100%);
  color: white;
  font-weight: 600;
  border-radius: 10px 10px 0 0 !important;
  box-shadow: 0 2px 8px rgba(74, 110, 158, 0.2);
}

/* Tables styling */
.table {
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.05);
}

.table-striped > tbody > tr:nth-of-type(odd) > td {
  background-color: rgba(74, 110, 158, 0.05);
}

.table-hover > tbody > tr:hover {
  background-color: transparent;
}

/* Badges styling */
.badge {
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.15);
}

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

.badge.bg-secondary {
  background-color: #6c757d !important;
}

/* Pagination styling */
.pagination .page-link {
  color: var(--primary-color);
  transition: all 0.3s ease;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

.pagination .page-link:hover {
  background-color: var(--primary-light);
  color: white;
  box-shadow: 0 2px 6px rgba(74, 110, 158, 0.3);
}

.pagination .page-item.active .page-link {
  background-color: var(--primary-color) !important;
  border-color: var(--primary-color) !important;
  color: white !important;
  box-shadow: 0 2px 8px rgba(74, 110, 158, 0.4);
  font-weight: 600;
}

/* Form controls styling */
.form-control:focus {
  border-color: var(--primary-color);
  box-shadow: 0 0 0 0.2rem rgba(74, 110, 158, 0.25);
}

.form-select:focus {
  border-color: var(--primary-color);
  box-shadow: 0 0 0 0.2rem rgba(74, 110, 158, 0.25);
}

/* Info box styling (عدد النتائج) */
.bg-light.rounded-3 {
  background: linear-gradient(135deg, #f8f9fa 0%, #e9ecef 100%) !important;
  box-shadow: 0 3px 10px rgba(0, 0, 0, 0.1);
  border: 1px solid rgba(74, 110, 158, 0.2) !important;
}

/* Footer styling */
.footer {
  background: linear-gradient(135deg, #ffffff 0%, #f8f9fa 100%);
  color: var(--accent-color);
  box-shadow: 0 -2px 10px rgba(0, 0, 0, 0.1);
}

.footer a {
  color: var(--accent-color);
  transition: all 0.3s ease;
}

.footer a:hover {
  color: var(--primary-color);
}