/* Balanced layout: moderate font and spacing */
html {
  font-size: 13px;
}

@media (min-width: 768px) {
  html {
    font-size: 14px;
  }
}

/* Tables */
.table {
  font-size: 0.95rem;
}

.table th,
.table td {
  padding: 0.4rem 0.6rem;
  vertical-align: middle;
}

/* تمرير عمودي للجداول مع بقاء سطر الهيدر ظاهراً (sticky thead) */
main .table-responsive {
  max-height: min(72vh, calc(100vh - 12rem));
  overflow-x: auto;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  border-radius: 0.375rem;
}

main .table-responsive > .table {
  margin-bottom: 0;
}

main .table-responsive thead th {
  position: sticky;
  top: 0;
  z-index: 4;
  background-color: var(--bs-body-bg);
  box-shadow: 0 1px 0 rgba(0, 0, 0, 0.12);
}

main .table-responsive thead.table-light th {
  background-color: var(--bs-secondary-bg) !important;
  box-shadow: 0 1px 0 var(--bs-border-color);
}

main .table-responsive thead.table-dark th {
  background-color: var(--bs-table-bg) !important;
  color: var(--bs-table-color);
}

main .table-responsive .table-bordered thead th {
  border-bottom-width: 1px;
}

/* جداول داخل النوافذ المنبثقة: ارتفاع أقل ليتناسب مع المودال */
.modal-body .table-responsive {
  max-height: min(48vh, 320px);
}

.modal-body .table-responsive thead th {
  position: sticky;
  top: 0;
  z-index: 5;
  background-color: var(--bs-body-bg);
  box-shadow: 0 1px 0 rgba(0, 0, 0, 0.12);
}

.modal-body .table-responsive thead.table-light th {
  background-color: var(--bs-secondary-bg) !important;
}

/* Cards */
.card-body {
  padding: 0.75rem 1rem;
}

.card-header {
  padding: 0.6rem 1rem;
  font-size: 1rem;
}

/* Form controls */
.form-control,
.form-select {
  padding: 0.3rem 0.5rem;
  font-size: 0.95rem;
}

.form-label {
  font-size: 0.9rem;
  margin-bottom: 0.25rem;
}

/* Form groups in modals and cards */
.modal .form-group.mb-3,
.card .form-group.mb-3 {
  margin-bottom: 0.6rem !important;
}

/* Buttons */
.btn {
  padding: 0.3rem 0.5rem;
  font-size: 0.9rem;
}

.btn-sm {
  padding: 0.2rem 0.4rem;
  font-size: 0.85rem;
}

/* Alerts */
.alert {
  padding: 0.5rem 0.85rem;
  font-size: 0.95rem;
}

/* Headings */
h1, .h1 { font-size: 1.6rem; }
h2, .h2 { font-size: 1.4rem; }
h3, .h3 { font-size: 1.2rem; }
h4, .h4 { font-size: 1.05rem; }
h5, .h5 { font-size: 1rem; }

/* Row spacing */
.card .row.g-3 { --bs-gutter-x: 0.85rem; --bs-gutter-y: 0.6rem; }

/* Pagination */
.pagination .page-link {
  padding: 0.25rem 0.5rem;
  font-size: 0.9rem;
}

/* Badges */
.badge {
  font-size: 0.8rem;
}

.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 #258cfb;
}

html {
  position: relative;
  min-height: 100%;
}

body {
  margin-bottom: 80px;
}

/* هامش سفلي كافٍ للمحتوى لتجنب تداخل الـ footer مع الأزرار */
main {
  padding-bottom: 4rem;
  margin-bottom: 2rem;
}

.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;
}

/* Reverse pagination borders for RTL */
.pagination {
  direction: rtl;
}

.pagination .page-item .page-link {
  border-left: none !important;
  border-right: var(--bs-pagination-border-width) solid var(--bs-pagination-border-color) !important;
}

.pagination .page-item:first-child .page-link {
  border-top-right-radius: var(--bs-pagination-border-radius) !important;
  border-bottom-right-radius: var(--bs-pagination-border-radius) !important;
  border-top-left-radius: 0 !important;
  border-bottom-left-radius: 0 !important;
}

.pagination .page-item:last-child .page-link {
  border-top-left-radius: var(--bs-pagination-border-radius) !important;
  border-bottom-left-radius: var(--bs-pagination-border-radius) !important;
  border-top-right-radius: 0 !important;
  border-bottom-right-radius: 0 !important;
}

/* Active navigation link styling */
.navbar-nav .nav-link.active {
  color: #0d6efd !important;
  border-bottom: 2px solid #0d6efd;
  padding-bottom: calc(0.5rem - 2px);
}

/* Right-align text for RTL (Arabic) */
html[dir="rtl"] {
  text-align: right;
}

html[dir="rtl"] .dropdown-menu,
html[dir="rtl"] .dropdown-item,
html[dir="rtl"] .nav-link,
html[dir="rtl"] .navbar-brand,
html[dir="rtl"] .card,
html[dir="rtl"] .table,
html[dir="rtl"] .form-control,
html[dir="rtl"] .form-select {
  text-align: right;
}

html[dir="rtl"] .dropdown-item i {
  margin-left: 0.5rem;
  margin-right: 0;
}

/* User Create/Edit form - checkbox lists */
.user-assignments-list .form-check {
  padding: 0.35rem 0.5rem;
  border-radius: 0.25rem;
  transition: background-color 0.15s ease;
}
.user-assignments-list .form-check:hover {
  background-color: rgba(0, 0, 0, 0.03);
}
.user-assignments-list .form-check-input:checked + .form-check-label {
  font-weight: 500;
}

/* زر X لرسائل المستخدم على اليسار في RTL */
html[dir="rtl"] .alert-dismissible {
  padding-right: 0.85rem;
  padding-left: 3rem;
}
html[dir="rtl"] .alert-dismissible .btn-close {
  right: auto;
  left: 0;
}