@import url('https://fonts.googleapis.com/css2?family=Cairo:wght@400;500;600;700&display=swap');

/* ---- Alert design foundation: premium bilingual typography (EN + AR) ---- */
:root {
  --alert-font: 'Cairo', 'Segoe UI', system-ui, -apple-system, sans-serif;
}
body {
  font-family: var(--alert-font);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  letter-spacing: 0.1px;
}
h1, h2, h3, h4, h5, h6, .h1, .h2, .h3, .h4, .h5, .h6 {
  font-family: var(--alert-font);
  font-weight: 700;
  letter-spacing: -0.01em;
}
.btn { font-family: var(--alert-font); font-weight: 600; }
/* Tabular, aligned numbers for money/metrics tables */
.table td, .table th, .fw-tabular { font-variant-numeric: tabular-nums; }

/* Professional, Compact Font Sizing - Enterprise Application */
html {
  font-size: 13px; /* Reduced from 14px for more compact appearance */
  line-height: 1.4; /* Tighter line spacing */
}

@media (min-width: 768px) {
  html {
    font-size: 13px; /* Keep consistent across devices - was 16px, now 13px */
  }
}

@media (min-width: 1200px) {
  html {
    font-size: 14px; /* Slightly larger only on very large screens */
  }
}

body {
  margin-bottom: 60px;
  font-size: 0.875rem; /* 12-13px - professional business application size */
  line-height: 1.5;
  color: #212529;
}

/* Headings - More compact and professional */
h1, h2, h3, h4, h5, h6,
.h1, .h2, .h3, .h4, .h5, .h6 {
  margin-bottom: 0.5rem; /* Reduced from default 0.75rem */
  font-weight: 600;
  line-height: 1.3; /* Tighter line height */
}

h1, .h1 { font-size: 1.75rem; } /* ~24px instead of 32px */
h2, .h2 { font-size: 1.5rem; }  /* ~20px instead of 28px */
h3, .h3 { font-size: 1.25rem; } /* ~17px instead of 24px */
h4, .h4 { font-size: 1.1rem; }  /* ~15px instead of 20px */
h5, .h5 { font-size: 1rem; }    /* ~14px instead of 18px */
h6, .h6 { font-size: 0.9rem; }  /* ~12px instead of 16px */

/* Paragraphs and text */
p {
  margin-bottom: 0.75rem; /* Reduced from 1rem */
}

small, .small {
  font-size: 0.8rem; /* ~11px */
}

/* Cards - More compact padding */
.card {
  margin-bottom: 1rem; /* Reduced from 1.5rem */
}

.card-body {
  padding: 0.75rem 1rem; /* Reduced from 1.25rem */
}

.card-header {
  padding: 0.5rem 1rem; /* Reduced from 0.75rem 1.25rem */
  font-size: 0.95rem;
  font-weight: 600;
}

.card-footer {
  padding: 0.5rem 1rem;
}

.card-title {
  margin-bottom: 0.5rem;
  font-size: 1.05rem;
}

/* Tables - More compact */
.table {
  font-size: 0.875rem; /* Keep same as body */
  margin-bottom: 0.75rem;
}

.table th,
.table td {
  padding: 0.5rem; /* Reduced from 0.75rem */
  vertical-align: middle;
}

.table-sm th,
.table-sm td {
  padding: 0.3rem; /* Reduced from 0.5rem */
}

.table thead th {
  font-size: 0.85rem;
  font-weight: 600;
  border-bottom-width: 1px;
}

/* Forms - Professional compact sizing */
.form-label {
  margin-bottom: 0.3rem; /* Reduced from 0.5rem */
  font-size: 0.875rem;
  font-weight: 500;
}

.form-control,
.form-select {
  padding: 0.4rem 0.75rem; /* Reduced from 0.5rem 0.75rem */
  font-size: 0.875rem;
  line-height: 1.4;
  border-radius: 0.25rem;
}

.form-control-sm,
.form-select-sm {
  padding: 0.25rem 0.5rem;
  font-size: 0.8rem;
}

.form-control-lg,
.form-select-lg {
  padding: 0.5rem 1rem;
  font-size: 0.95rem;
}

.form-check {
  margin-bottom: 0.4rem;
  padding-left: 1.25rem;
}

.form-check-input {
  margin-top: 0.2rem;
}

.form-check-label {
  font-size: 0.875rem;
}

.form-text {
  font-size: 0.8rem;
  margin-top: 0.2rem;
}

.input-group-text {
  padding: 0.4rem 0.75rem;
  font-size: 0.875rem;
}

/* Buttons - Professional sizing */
.btn {
  padding: 0.4rem 0.9rem; /* Reduced from 0.5rem 1rem */
  font-size: 0.875rem;
  line-height: 1.4;
  border-radius: 0.25rem;
  font-weight: 500;
}

.btn-sm {
  padding: 0.25rem 0.6rem;
  font-size: 0.8rem;
}

.btn-lg {
  padding: 0.5rem 1.2rem;
  font-size: 0.95rem;
}

.btn i {
  font-size: 0.9em; /* Icons slightly smaller than text */
}

/* Badges - Compact */
.badge {
  padding: 0.3em 0.6em; /* Reduced from 0.35em 0.65em */
  font-size: 0.75rem;
  font-weight: 600;
  line-height: 1.2;
}

/* Alerts - Less padding */
.alert {
  padding: 0.75rem 1rem; /* Reduced from 1rem 1.25rem */
  margin-bottom: 0.75rem;
  font-size: 0.875rem;
}

.alert-heading {
  font-size: 1.1rem;
}

/* Breadcrumbs - Compact */
.breadcrumb {
  padding: 0.5rem 0.75rem;
  font-size: 0.85rem;
  margin-bottom: 0.75rem;
}

.breadcrumb-item + .breadcrumb-item {
  padding-left: 0.4rem;
}

/* Modals - Professional sizing */
.modal-header {
  padding: 0.75rem 1rem; /* Reduced from 1rem */
  background-color: var(--alert-primary, var(--bs-primary, #2545ff));
  color: #fff;
}

.modal-header .modal-title {
  color: inherit;
}

.modal-header .btn-close {
  filter: invert(1) grayscale(100%) brightness(200%);
  opacity: 0.9;
}

.modal-header.bg-warning,
.modal-header.bg-light,
.modal-header.text-dark {
  color: #111827;
}

.modal-header.bg-warning .btn-close,
.modal-header.bg-light .btn-close,
.modal-header.text-dark .btn-close {
  filter: none;
}

.modal-body {
  padding: 0.75rem 1rem; /* Reduced from 1rem */
}

.modal-footer {
  padding: 0.5rem 1rem; /* Reduced from 0.75rem */
}

.modal-title {
  font-size: 1.15rem;
  line-height: 1.3;
}

/* Dropdowns - Compact */
.dropdown-menu {
  font-size: 0.875rem;
  padding: 0.3rem 0;
}

.dropdown-item {
  padding: 0.4rem 1rem; /* Reduced from 0.5rem 1.5rem */
}

.dropdown-header {
  font-size: 0.8rem;
  padding: 0.3rem 1rem;
}

/* Navigation tabs - Professional */
.nav-tabs .nav-link {
  padding: 0.4rem 0.9rem; /* Reduced from 0.5rem 1rem */
  font-size: 0.875rem;
  color: #495057 !important;
  background-color: transparent !important;
  font-weight: 500;
}

.nav-tabs .nav-link:hover {
  color: #000 !important;
  background-color: #f8f9fa !important;
}

.nav-tabs .nav-link.active {
  color: #00838f !important;
  background-color: #fff !important;
  border-bottom-color: #fff !important;
  font-weight: 600;
}

.nav-tabs .nav-link .badge {
  position: relative;
  margin-left: 0.25rem;
  font-size: 0.7rem;
  padding: 0.25em 0.5em;
  vertical-align: middle;
}

/* RTL DataTables alignment */
html[dir="rtl"] table.dataTable thead th,
html[dir="rtl"] table.dataTable tbody td,
html[dir="rtl"] .table thead th,
html[dir="rtl"] .table tbody td {
  text-align: right;
}

html[dir="rtl"] table.dataTable thead > tr > th.sorting,
html[dir="rtl"] table.dataTable thead > tr > th.sorting_asc,
html[dir="rtl"] table.dataTable thead > tr > th.sorting_desc {
  padding-right: 0.5rem;
  padding-left: 1.75rem;
}

html[dir="rtl"] table.dataTable thead .sorting:before,
html[dir="rtl"] table.dataTable thead .sorting:after,
html[dir="rtl"] table.dataTable thead .sorting_asc:before,
html[dir="rtl"] table.dataTable thead .sorting_asc:after,
html[dir="rtl"] table.dataTable thead .sorting_desc:before,
html[dir="rtl"] table.dataTable thead .sorting_desc:after {
  right: auto;
  left: 0.5rem;
}

html[dir="rtl"] .dataTables_wrapper .dataTables_length,
html[dir="rtl"] .dataTables_wrapper .dataTables_filter,
html[dir="rtl"] .dataTables_wrapper .dataTables_info,
html[dir="rtl"] .dataTables_wrapper .dataTables_paginate {
  text-align: right;
}

html[dir="rtl"] .dataTables_wrapper .dataTables_filter input {
  margin-left: 0;
  margin-right: 0.5rem;
}

.nav-tabs .nav-link i {
  opacity: 0.8;
  font-size: 0.9em;
}

.nav-tabs .nav-link.active i {
  opacity: 1;
}

/* Pagination - Compact */
.pagination {
  font-size: 0.875rem;
}

.page-link {
  padding: 0.4rem 0.65rem; /* Reduced from 0.5rem 0.75rem */
}

/* List groups - Compact */
.list-group-item {
  padding: 0.6rem 0.9rem; /* Reduced from 0.75rem 1.25rem */
  font-size: 0.875rem;
}

/* Tooltips and Popovers */
.tooltip {
  font-size: 0.8rem;
}

.popover {
  font-size: 0.85rem;
}

/* Spinners - Smaller */
.spinner-border,
.spinner-grow {
  width: 1.5rem;
  height: 1.5rem;
}

.spinner-border-sm,
.spinner-grow-sm {
  width: 0.9rem;
  height: 0.9rem;
}

/* Container spacing */
.container,
.container-fluid {
  padding-right: 0.75rem;
  padding-left: 0.75rem;
}

/* Row and column spacing */
.row {
  margin-right: -0.5rem;
  margin-left: -0.5rem;
}

.row > * {
  padding-right: 0.5rem;
  padding-left: 0.5rem;
}

/* Utility spacing adjustments */
.mb-1 { margin-bottom: 0.25rem !important; }
.mb-2 { margin-bottom: 0.5rem !important; }
.mb-3 { margin-bottom: 0.75rem !important; }
.mb-4 { margin-bottom: 1rem !important; }
.mb-5 { margin-bottom: 1.5rem !important; }

.mt-1 { margin-top: 0.25rem !important; }
.mt-2 { margin-top: 0.5rem !important; }
.mt-3 { margin-top: 0.75rem !important; }
.mt-4 { margin-top: 1rem !important; }
.mt-5 { margin-top: 1.5rem !important; }

.pb-1 { padding-bottom: 0.25rem !important; }
.pb-2 { padding-bottom: 0.5rem !important; }
.pb-3 { padding-bottom: 0.75rem !important; }
.pb-4 { padding-bottom: 1rem !important; }
.pb-5 { padding-bottom: 1.5rem !important; }

.pt-1 { padding-top: 0.25rem !important; }
.pt-2 { padding-top: 0.5rem !important; }
.pt-3 { padding-top: 0.75rem !important; }
.pt-4 { padding-top: 1rem !important; }
.pt-5 { padding-top: 1.5rem !important; }

/* Focus states - Keep accessible */
.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.2rem #258cfb;
}

/* Professional link styling - NO UNDERLINES on hover */
a {
  text-decoration: none;
}

a:hover {
  text-decoration: none;
}

/* Ensure no underlines on any clickable elements */
a,
a:hover,
a:focus,
a:active,
.btn,
.btn:hover,
.btn:focus,
.btn:active,
.nav-link,
.nav-link:hover,
.nav-link:focus,
.nav-link:active,
.dropdown-item,
.dropdown-item:hover,
.dropdown-item:focus,
.dropdown-item:active,
.list-group-item,
.list-group-item:hover,
.list-group-item:focus,
.list-group-item:active,
.page-link,
.page-link:hover,
.page-link:focus,
.page-link:active,
button,
button:hover,
button:focus,
button:active,
[role="button"],
[role="button"]:hover,
[role="button"]:focus,
[role="button"]:active {
  text-decoration: none !important;
}

/* Status indicators - Compact */
.text-muted {
  color: #6c757d !important;
  font-size: 0.85rem;
}

/* Icon sizing consistency
   Don't override Font Awesome sizing utility classes (e.g. .fa-2x, .fa-3x, .fa-8x).
   Ensure we only set inheritance for plain <i> elements that are NOT Font Awesome icons. */
i:not([class*="fa-"]):not([class*="fa"]) {
  font-size: inherit;
}

/* Responsive adjustments for mobile */
@media (max-width: 767.98px) {
  html {
    font-size: 12px; /* Even more compact on mobile */
  }
  
  .card-body {
    padding: 0.6rem 0.8rem;
  }
  
  .btn {
    padding: 0.35rem 0.75rem;
  }
  
  .table th,
  .table td {
    padding: 0.4rem;
  }
}

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

/* =================================================================== */
/* NESTED MODAL Z-INDEX MANAGEMENT - Multiple Modal Support */
/* =================================================================== */

/* Professional backdrops for all modals and custom slide-ins */
.modal-backdrop {
  background: rgba(0, 0, 0, 0.45) !important;
  opacity: 0.9 !important;
  transition: opacity 0.25s ease-in-out;
}

.modal-backdrop.show {
  opacity: 0.9 !important;
}

/* Custom slide-in overlays share the same professional shadow */
.slide-in-overlay,
.slide-in-backdrop {
  background: rgba(0, 0, 0, 0.45) !important;
  opacity: 0.9 !important;
  transition: opacity 0.25s ease-in-out;
}

/* Primary modals (ManPower, Equipment, Vehicle, Item) */
.modal {
  z-index: 1055 !important;
}

/* Add depth to modal content instead of blurring backdrop */
.modal-content {
  box-shadow: 0 20px 45px rgba(0, 0, 0, 0.35), 0 8px 20px rgba(0, 0, 0, 0.25);
}

.modal-backdrop {
  z-index: 1050 !important;
}

/* Nested modals (Salary Scale inside ManPower, etc.) */
.modal.modal-nested {
  z-index: 1085 !important;
}

.modal.modal-nested + .modal-backdrop {
  z-index: 1080 !important;
}

/* Double-nested modals (Class/Position inside Salary Scale) */
.modal.modal-double-nested {
  z-index: 1115 !important;
}

.modal.modal-double-nested + .modal-backdrop {
  z-index: 1110 !important;
}

/* Slide-in forms (full-page forms from right) */
.slide-in-form {
  z-index: 1060 !important;
  position: fixed;
  right: 0;
  top: 0;
  width: 100%;
  height: 100%;
  background: white;
  box-shadow: -2px 0 8px rgba(0, 0, 0, 0.15);
}

.slide-in-form.nested {
  z-index: 1090 !important;
}

.slide-in-form.double-nested {
  z-index: 1120 !important;
}

/* Slide-in form backdrops/overlays */
.slide-in-overlay {
  position: fixed;
  left: 0;
  top: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.5);
  z-index: 1055 !important;
}

.slide-in-overlay.nested {
  z-index: 1085 !important;
}

.slide-in-overlay.double-nested {
  z-index: 1115 !important;
}

/* Inline select + add buttons - forces single line with proper height matching */
.dropdown-with-action-btn {
  display: flex !important;
  gap: 0.5rem !important;
  align-items: stretch !important;
  flex-wrap: nowrap !important;
  width: 100% !important;
}

.dropdown-with-action-btn select.form-select,
.dropdown-with-action-btn .form-select,
.dropdown-with-action-btn .form-select-lg {
  flex: 1 1 1% !important;
  min-width: 1px !important;
}

.dropdown-with-action-btn .dropdown-action-btn {
  flex-shrink: 0 !important;
  padding: 0.4rem 0.5rem !important;
  white-space: nowrap !important;
  align-self: stretch !important;
  display: inline-flex !important;
  align-items: center !important;
  justify-content: center !important;
}

/* Compact section styling */
.compact-section {
  background: #f8fafc;
  border: 1px solid #e9ecef;
  border-radius: 0.5rem;
  padding: 0.75rem 1rem;
}

.compact-section h5 {
  margin-bottom: 0.75rem;
}

.compact-section .form-label {
  margin-bottom: 0.25rem;
}
