/* ===== Global Font & Responsive Typography ===== */
:root {
  --app-font: 'Cairo', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  --primary-color: #0d6efd;
  --primary-hover: #0b5ed7;
  --bg-gradient: linear-gradient(180deg, #f8faff 0%, #f4f6fb 100%);
}

html {
  font-family: var(--app-font);
  font-size: clamp(14px, 2vw, 16px);
  position: relative;
  min-height: 100%;
}

body {
  font-family: var(--app-font);
  font-size: clamp(0.875rem, 1.5vw, 1rem);
  line-height: 1.6;
  background: var(--bg-gradient);
  color: #2b303a;
}

/* ===== RTL Form Select Arrow Fix ===== */
[dir="rtl"] .form-select,
html[dir="rtl"] .form-select {
  background-position: left 0.75rem center;
  padding-left: 2.25rem;
  padding-right: 0.75rem;
}

[dir="rtl"] .form-select-sm,
html[dir="rtl"] .form-select-sm {
  background-position: left 0.5rem center;
  padding-left: 2rem;
  padding-right: 0.5rem;
}


/* ===== Responsive Font Sizes ===== */
h1 {
  font-size: clamp(1.5rem, 4vw, 2.5rem);
}

h2 {
  font-size: clamp(1.3rem, 3.5vw, 2rem);
}

h3 {
  font-size: clamp(1.1rem, 3vw, 1.75rem);
}

h4 {
  font-size: clamp(1rem, 2.5vw, 1.5rem);
}

h5 {
  font-size: clamp(0.95rem, 2vw, 1.25rem);
}

h6 {
  font-size: clamp(0.9rem, 1.5vw, 1.1rem);
}

small {
  font-size: clamp(0.75rem, 1.2vw, 0.875rem);
}

/* ===== Tablet Breakpoint (576px - 768px) ===== */
@media (min-width: 576px) {
  html {
    font-size: 15px;
  }

  body {
    font-size: 0.9375rem;
  }
}

/* ===== Tablet / Desktop Breakpoint (768px+) ===== */
@media (min-width: 768px) {
  html {
    font-size: 16px;
  }

  body {
    font-size: 1rem;
  }
}

/* ===== Desktop Breakpoint (992px+) ===== */
@media (min-width: 992px) {
  html {
    font-size: 16px;
  }

  body {
    font-size: 1rem;
  }
}

/* ===== Large Desktop (1200px+) ===== */
@media (min-width: 1200px) {
  html {
    font-size: 16px;
  }
}

/* ===== Focus & Accessibility States ===== */
.btn:focus,
.btn:active:focus,
.btn-link.nav-link:focus,
.form-control:focus,
.form-check-input:focus,
a:focus {
  box-shadow: 0 0 0 0.1rem white, 0 0 0 0.25rem #258cfb;
  outline: 2px solid #0d6efd;
  outline-offset: 2px;
}

/* ===== Form Floating Labels Responsiveness ===== */
.form-floating>.form-control-plaintext::placeholder,
.form-floating>.form-control::placeholder {
  color: var(--bs-secondary-color);
  text-align: end;
  font-size: clamp(0.875rem, 1.5vw, 1rem);
}

.form-floating>.form-control-plaintext:focus::placeholder,
.form-floating>.form-control:focus::placeholder {
  text-align: start;
}

/* ===== Form Controls Responsiveness ===== */
.form-control,
.form-select {
  min-height: 44px;
  /* Better touch target for mobile */
  font-size: clamp(0.875rem, 1.5vw, 1rem);
  padding: clamp(0.375rem, 1vw, 0.5rem) clamp(0.75rem, 2vw, 1rem);
}

@media (max-width: 576px) {

  .form-control,
  .form-select {
    min-height: 48px;
    /* Optimal touch size for mobile */
  }
}

.form-label {
  font-size: clamp(0.875rem, 1.5vw, 0.95rem);
  font-weight: 500;
  margin-bottom: clamp(0.25rem, 1vw, 0.5rem);
}

/* ===== Button Responsiveness ===== */
.btn {
  min-height: 40px;
  padding: clamp(0.375rem, 1vw, 0.5rem) clamp(0.75rem, 2vw, 1.5rem);
  font-size: clamp(0.875rem, 1.5vw, 0.95rem);
  font-weight: 500;
  white-space: nowrap;
  transition: all 0.2s ease;
}

@media (max-width: 576px) {
  .btn {
    min-height: 48px;
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
  }

  .btn-group {
    display: flex;
    flex-direction: column;
  }

  .btn-group .btn {
    width: 100%;
    border-radius: 0.375rem;
    margin-bottom: 0.5rem;
  }

  .btn-group .btn:last-child {
    margin-bottom: 0;
  }
}

.btn-sm {
  min-height: 36px;
  padding: clamp(0.25rem, 0.8vw, 0.35rem) clamp(0.5rem, 1.5vw, 0.75rem);
  font-size: clamp(0.8rem, 1.2vw, 0.875rem);
}

/* ===== Card Responsiveness ===== */
.card {
  margin-bottom: clamp(1rem, 3vw, 1.5rem);
  box-shadow: 0 0.125rem 0.25rem rgba(0, 0, 0, 0.075);
  overflow: hidden;
}

.card-body {
  padding: clamp(1rem, 3vw, 1.5rem);
}

.card-title {
  font-size: clamp(1rem, 2.5vw, 1.25rem);
  font-weight: 600;
  margin-bottom: clamp(0.75rem, 2vw, 1rem);
}

@media (max-width: 576px) {
  .card {
    margin-bottom: 1rem;
  }

  .card-body {
    padding: 1rem;
  }
}

/* ===== Table Responsiveness ===== */
.table {
  font-size: clamp(0.8rem, 1.2vw, 0.95rem);
  margin-bottom: 1rem;
}

@media (max-width: 768px) {
  .table-responsive {
    display: block;
    width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }

  .table-responsive>.table {
    margin-bottom: 0;
  }

  /* Stack tables on very small screens */
  .table-responsive-stack thead {
    display: none;
  }

  .table-responsive-stack tbody,
  .table-responsive-stack tr,
  .table-responsive-stack td {
    display: block;
    width: 100%;
  }

  .table-responsive-stack tr {
    margin-bottom: 1rem;
    border: 1px solid #e5e5e5;
    border-radius: 0.375rem;
  }

  .table-responsive-stack td {
    padding: 0.75rem 1rem !important;
    text-align: start;
  }

  .table-responsive-stack td::before {
    content: attr(data-label);
    font-weight: 600;
    text-transform: uppercase;
    font-size: 0.75rem;
    color: #6c757d;
    display: block;
    margin-bottom: 0.25rem;
  }
}

/* ===== Badge & Badge Responsiveness ===== */
.badge {
  font-size: clamp(0.7rem, 1vw, 0.8rem);
  padding: clamp(0.25rem, 0.8vw, 0.35rem) clamp(0.5rem, 1.5vw, 0.75rem);
  word-break: break-word;
}

/* ===== Container Responsiveness ===== */
.container,
.container-sm,
.container-md,
.container-lg,
.container-xl,
.container-xxl,
.container-fluid {
  padding-left: clamp(0.75rem, 2vw, 1.5rem);
  padding-right: clamp(0.75rem, 2vw, 1.5rem);
}

@media (max-width: 576px) {

  .container,
  .container-sm,
  .container-md,
  .container-lg,
  .container-xl,
  .container-xxl,
  .container-fluid {
    padding-left: 0.75rem;
    padding-right: 0.75rem;
  }
}

/* ===== Row & Column Responsiveness ===== */
.row {
  gap: clamp(0.75rem, 2vw, 1.5rem);
}

.col-12,
.col-sm-12,
.col-md-6,
.col-lg-4,
.col-xl-3 {
  margin-bottom: clamp(0.5rem, 1.5vw, 1rem);
}

/* ===== Alert Responsiveness ===== */
.alert {
  font-size: clamp(0.875rem, 1.2vw, 0.95rem);
  padding: clamp(0.75rem, 2vw, 1rem) clamp(1rem, 2.5vw, 1.5rem);
}

@media (max-width: 576px) {
  .alert {
    padding: 0.75rem 1rem;
  }

  .alert-dismissible .btn-close {
    padding: 0.5rem;
    right: 0.5rem;
  }
}

/* ===== Dropdown & Menu Responsiveness ===== */
.dropdown-menu {
  font-size: clamp(0.875rem, 1.2vw, 0.95rem);
  max-width: 95vw;
  overflow-y: auto;
}

.dropdown-item {
  padding: clamp(0.5rem, 1.2vw, 0.75rem) clamp(1rem, 2vw, 1.5rem);
  min-height: 40px;
  display: flex;
  align-items: center;
}

/* ===== Modal Responsiveness ===== */
@media (max-width: 576px) {
  .modal-dialog {
    margin: 0.5rem;
    max-width: calc(100% - 1rem);
  }

  .modal-body {
    padding: 1rem;
  }
}

/* ===== Utility Classes for Responsiveness ===== */
.gap-responsive-sm {
  gap: 0.5rem;
}

.gap-responsive-md {
  gap: 1rem;
}

.gap-responsive-lg {
  gap: 1.5rem;
}

@media (max-width: 576px) {
  .gap-responsive-lg {
    gap: 1rem;
  }
}

/* ===== Spacing Utilities ===== */
@media (max-width: 576px) {
  .p-lg-4 {
    padding: 1rem !important;
  }

  .p-md-4 {
    padding: 1rem !important;
  }

  .pt-lg-4 {
    padding-top: 1rem !important;
  }

  .px-md-4 {
    padding-left: 1rem !important;
    padding-right: 1rem !important;
  }

  .mb-lg-4 {
    margin-bottom: 1rem !important;
  }
}

/* ===== Link & Text Responsiveness ===== */
a {
  color: #0077cc;
  text-decoration: none;
  transition: color 0.2s ease;
}

a:hover,
a:focus {
  color: #0056a3;
  text-decoration: underline;
}

/* ===== Print Styles ===== */
@media print {
  body {
    background-color: white;
  }

  .navbar,
  .footer,
  .btn-group {
    display: none;
  }

  .card {
    border: 1px solid #ddd;
    page-break-inside: avoid;
  }
}