/**
 * HAI UAE — Lightweight Modern Utility System (utilities.css)
 * High-performance, zero-dependency flexbox, grid, spacing, and typography utilities.
 * Replaces heavy external frameworks on public directory pages.
 *
 * Version: 1.0.0 (2026.09.12 — DESIGN_MASTER_PLAN)
 */

/* ==========================================================================
   1. Containers
   ========================================================================== */
.container,
.hai-container {
  width: 100%;
  max-width: var(--dir-container-max, 1240px);
  margin-inline: auto;
  padding-inline: var(--dir-space-md, 1rem);
  box-sizing: border-box;
}

.container-narrow {
  width: 100%;
  max-width: var(--dir-container-narrow, 1120px);
  margin-inline: auto;
  padding-inline: var(--dir-space-md, 1rem);
  box-sizing: border-box;
}

.container-fluid {
  width: 100%;
  padding-inline: var(--dir-space-md, 1rem);
  box-sizing: border-box;
}

/* ==========================================================================
   2. Responsive Grid & Row System
   ========================================================================== */
.row,
.hai-row {
  display: flex;
  flex-wrap: wrap;
  margin-inline: calc(var(--dir-space-sm, 0.75rem) * -0.5);
}

.row > *,
.hai-row > * {
  box-sizing: border-box;
  padding-inline: calc(var(--dir-space-sm, 0.75rem) * 0.5);
  width: 100%;
  max-width: 100%;
}

.col { flex: 1 0 0%; }
.col-auto { flex: 0 0 auto; width: auto; }
.col-12 { width: 100%; flex: 0 0 100%; }
.col-11 { width: 91.666667%; flex: 0 0 91.666667%; }
.col-10 { width: 83.333333%; flex: 0 0 83.333333%; }
.col-9  { width: 75%; flex: 0 0 75%; }
.col-8  { width: 66.666667%; flex: 0 0 66.666667%; }
.col-7  { width: 58.333333%; flex: 0 0 58.333333%; }
.col-6  { width: 50%; flex: 0 0 50%; }
.col-5  { width: 41.666667%; flex: 0 0 41.666667%; }
.col-4  { width: 33.333333%; flex: 0 0 33.333333%; }
.col-3  { width: 25%; flex: 0 0 25%; }
.col-2  { width: 16.666667%; flex: 0 0 16.666667%; }
.col-1  { width: 8.333333%; flex: 0 0 8.333333%; }

@media (min-width: 576px) {
  .col-sm-auto { flex: 0 0 auto; width: auto; }
  .col-sm-12 { width: 100%; flex: 0 0 100%; }
  .col-sm-6  { width: 50%; flex: 0 0 50%; }
  .col-sm-4  { width: 33.333333%; flex: 0 0 33.333333%; }
  .col-sm-3  { width: 25%; flex: 0 0 25%; }
}

@media (min-width: 768px) {
  .col-md-auto { flex: 0 0 auto; width: auto; }
  .col-md-12 { width: 100%; flex: 0 0 100%; }
  .col-md-10 { width: 83.333333%; flex: 0 0 83.333333%; }
  .col-md-9  { width: 75%; flex: 0 0 75%; }
  .col-md-8  { width: 66.666667%; flex: 0 0 66.666667%; }
  .col-md-7  { width: 58.333333%; flex: 0 0 58.333333%; }
  .col-md-6  { width: 50%; flex: 0 0 50%; }
  .col-md-5  { width: 41.666667%; flex: 0 0 41.666667%; }
  .col-md-4  { width: 33.333333%; flex: 0 0 33.333333%; }
  .col-md-3  { width: 25%; flex: 0 0 25%; }
}

@media (min-width: 992px) {
  .col-lg-auto { flex: 0 0 auto; width: auto; }
  .col-lg-12 { width: 100%; flex: 0 0 100%; }
  .col-lg-10 { width: 83.333333%; flex: 0 0 83.333333%; }
  .col-lg-9  { width: 75%; flex: 0 0 75%; }
  .col-lg-8  { width: 66.666667%; flex: 0 0 66.666667%; }
  .col-lg-7  { width: 58.333333%; flex: 0 0 58.333333%; }
  .col-lg-6  { width: 50%; flex: 0 0 50%; }
  .col-lg-5  { width: 41.666667%; flex: 0 0 41.666667%; }
  .col-lg-4  { width: 33.333333%; flex: 0 0 33.333333%; }
  .col-lg-3  { width: 25%; flex: 0 0 25%; }
}

/* Modern CSS Grids */
.grid { display: grid; gap: var(--dir-space-md, 1rem); }
.grid-2 { display: grid; grid-template-columns: repeat(2, 1fr); gap: var(--dir-space-md, 1rem); }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: var(--dir-space-md, 1rem); }
.grid-4 { display: grid; grid-template-columns: repeat(4, 1fr); gap: var(--dir-space-md, 1rem); }
.grid-auto-fit { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(280px, 100%), 1fr)); gap: var(--dir-space-md, 1rem); }
.grid-auto-fill { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(240px, 100%), 1fr)); gap: var(--dir-space-md, 1rem); }

@media (max-width: 991.98px) {
  .grid-4 { grid-template-columns: repeat(2, 1fr); }
  .grid-3 { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 575.98px) {
  .grid-4, .grid-3, .grid-2 { grid-template-columns: 1fr; }
}

/* ==========================================================================
   3. Flexbox Helpers
   ========================================================================== */
.d-flex { display: flex !important; }
.d-inline-flex { display: inline-flex !important; }
.d-none { display: none !important; }
.d-block { display: block !important; }
.d-inline-block { display: inline-block !important; }
.d-grid { display: grid !important; }

.flex-column { flex-direction: column !important; }
.flex-row { flex-direction: row !important; }
.flex-wrap { flex-wrap: wrap !important; }
.flex-nowrap { flex-wrap: nowrap !important; }

.justify-content-start { justify-content: flex-start !important; }
.justify-content-center { justify-content: center !important; }
.justify-content-end { justify-content: flex-end !important; }
.justify-content-between { justify-content: space-between !important; }
.justify-content-around { justify-content: space-around !important; }

.align-items-start { align-items: flex-start !important; }
.align-items-center { align-items: center !important; }
.align-items-end { align-items: flex-end !important; }
.align-items-stretch { align-items: stretch !important; }

.align-self-center { align-self: center !important; }
.align-self-start { align-self: flex-start !important; }
.align-self-end { align-self: flex-end !important; }

.flex-grow-1 { flex-grow: 1 !important; }
.flex-shrink-0 { flex-shrink: 0 !important; }

/* Gaps */
.gap-0 { gap: 0 !important; }
.gap-1 { gap: 0.25rem !important; }
.gap-2 { gap: 0.5rem !important; }
.gap-3 { gap: 1rem !important; }
.gap-4 { gap: 1.5rem !important; }
.gap-5 { gap: 2rem !important; }

/* ==========================================================================
   4. Spacing Utilities
   ========================================================================== */
.m-0 { margin: 0 !important; }
.m-1 { margin: 0.25rem !important; }
.m-2 { margin: 0.5rem !important; }
.m-3 { margin: 1rem !important; }
.m-4 { margin: 1.5rem !important; }
.m-5 { margin: 2rem !important; }
.m-auto { margin: auto !important; }

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

.mb-0 { margin-bottom: 0 !important; }
.mb-1 { margin-bottom: 0.25rem !important; }
.mb-2 { margin-bottom: 0.5rem !important; }
.mb-3 { margin-bottom: 1rem !important; }
.mb-4 { margin-bottom: 1.5rem !important; }
.mb-5 { margin-bottom: 2rem !important; }
.mb-auto { margin-bottom: auto !important; }

.ms-0 { margin-left: 0 !important; }
.ms-1 { margin-left: 0.25rem !important; }
.ms-2 { margin-left: 0.5rem !important; }
.ms-3 { margin-left: 1rem !important; }
.ms-4 { margin-left: 1.5rem !important; }
.ms-auto { margin-left: auto !important; }

.me-0 { margin-right: 0 !important; }
.me-1 { margin-right: 0.25rem !important; }
.me-2 { margin-right: 0.5rem !important; }
.me-3 { margin-right: 1rem !important; }
.me-4 { margin-right: 1.5rem !important; }
.me-auto { margin-right: auto !important; }

.mx-auto { margin-inline: auto !important; }
.mx-0 { margin-inline: 0 !important; }
.mx-1 { margin-inline: 0.25rem !important; }
.mx-2 { margin-inline: 0.5rem !important; }
.mx-3 { margin-inline: 1rem !important; }

.my-0 { margin-block: 0 !important; }
.my-1 { margin-block: 0.25rem !important; }
.my-2 { margin-block: 0.5rem !important; }
.my-3 { margin-block: 1rem !important; }
.my-4 { margin-block: 1.5rem !important; }
.my-5 { margin-block: 2rem !important; }

.p-0 { padding: 0 !important; }
.p-1 { padding: 0.25rem !important; }
.p-2 { padding: 0.5rem !important; }
.p-3 { padding: 1rem !important; }
.p-4 { padding: 1.5rem !important; }
.p-5 { padding: 2rem !important; }

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

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

.ps-0 { padding-left: 0 !important; }
.ps-1 { padding-left: 0.25rem !important; }
.ps-2 { padding-left: 0.5rem !important; }
.ps-3 { padding-left: 1rem !important; }

.pe-0 { padding-right: 0 !important; }
.pe-1 { padding-right: 0.25rem !important; }
.pe-2 { padding-right: 0.5rem !important; }
.pe-3 { padding-right: 1rem !important; }

.px-0 { padding-inline: 0 !important; }
.px-1 { padding-inline: 0.25rem !important; }
.px-2 { padding-inline: 0.5rem !important; }
.px-3 { padding-inline: 1rem !important; }
.px-4 { padding-inline: 1.5rem !important; }

.py-0 { padding-block: 0 !important; }
.py-1 { padding-block: 0.25rem !important; }
.py-2 { padding-block: 0.5rem !important; }
.py-3 { padding-block: 1rem !important; }
.py-4 { padding-block: 1.5rem !important; }
.py-5 { padding-block: 2rem !important; }

/* ==========================================================================
   5. Typography Helpers
   ========================================================================== */
.text-center { text-align: center !important; }
.text-start { text-align: left !important; }
.text-end { text-align: right !important; }

.text-dark { color: var(--text, #0f172a) !important; }
.text-body { color: var(--text, #0f172a) !important; }
.text-muted { color: var(--muted, #475569) !important; }
.text-subtle { color: var(--subtle, #64748b) !important; }
.text-white { color: #ffffff !important; }
.text-white-50 { color: rgba(255, 255, 255, 0.75) !important; }
.text-primary { color: var(--link, #1d4ed8) !important; }
.text-success { color: var(--success, #047857) !important; }
.text-danger { color: var(--danger, #b91c1c) !important; }
.text-warning { color: var(--accent, #d97706) !important; }
.text-gold { color: var(--accent-text, #b45309) !important; }

.fw-normal { font-weight: 400 !important; }
.fw-medium { font-weight: 500 !important; }
.fw-semibold { font-weight: 600 !important; }
.fw-bold { font-weight: 700 !important; }
.fw-extrabold { font-weight: 800 !important; }

.fs-xs { font-size: 0.75rem !important; }
.fs-sm { font-size: 0.875rem !important; }
.fs-base { font-size: 1rem !important; }
.fs-lg { font-size: 1.125rem !important; }
.fs-xl { font-size: 1.25rem !important; }
.fs-2xl { font-size: 1.5rem !important; }

.lh-1 { line-height: 1 !important; }
.lh-sm { line-height: 1.25 !important; }
.lh-base { line-height: 1.5 !important; }
.lh-lg { line-height: 1.75 !important; }

.text-truncate {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.text-uppercase { text-transform: uppercase !important; }
.text-decoration-none { text-decoration: none !important; }

/* ==========================================================================
   6. Responsive Display Helpers
   ========================================================================== */
@media (max-width: 575.98px) {
  .d-sm-none { display: none !important; }
}

@media (min-width: 576px) {
  .d-sm-block { display: block !important; }
  .d-sm-flex { display: flex !important; }
}

@media (max-width: 767.98px) {
  .d-md-none { display: none !important; }
}

@media (min-width: 768px) {
  .d-md-block { display: block !important; }
  .d-md-flex { display: flex !important; }
  .d-md-grid { display: grid !important; }
  .d-md-none-inline { display: none !important; }
}

@media (max-width: 991.98px) {
  .d-lg-none { display: none !important; }
}

@media (min-width: 992px) {
  .d-lg-block { display: block !important; }
  .d-lg-flex { display: flex !important; }
  .d-lg-grid { display: grid !important; }
}

/* ==========================================================================
   7. Surfaces, Borders & Sizing
   ========================================================================== */
.bg-white { background-color: #ffffff !important; }
.bg-light { background-color: var(--surface-subtle, #f8fafc) !important; }
.bg-dark { background-color: var(--ink-deep, #0a192f) !important; }
.bg-brand { background-color: var(--brand, #ffcb05) !important; }

.border { border: 1px solid var(--dir-border, #cbd5e1) !important; }
.border-subtle { border: 1px solid var(--dir-border-subtle, #e2e8f0) !important; }
.border-0 { border: 0 !important; }
.border-top { border-top: 1px solid var(--dir-border-subtle, #e2e8f0) !important; }
.border-bottom { border-bottom: 1px solid var(--dir-border-subtle, #e2e8f0) !important; }

.rounded { border-radius: var(--dir-radius-md, 10px) !important; }
.rounded-sm { border-radius: var(--dir-radius-sm, 6px) !important; }
.rounded-lg { border-radius: var(--dir-radius-lg, 16px) !important; }
.rounded-xl { border-radius: var(--dir-radius-xl, 24px) !important; }
.rounded-pill { border-radius: 9999px !important; }
.rounded-circle { border-radius: 50% !important; }

.shadow-none { box-shadow: none !important; }
.shadow-xs { box-shadow: var(--dir-shadow-xs) !important; }
.shadow-sm { box-shadow: var(--dir-shadow-sm) !important; }
.shadow-md { box-shadow: var(--dir-shadow-md) !important; }
.shadow-lg { box-shadow: var(--dir-shadow-lg) !important; }

.w-100 { width: 100% !important; }
.h-100 { height: 100% !important; }
.mw-100 { max-width: 100% !important; }
.position-relative { position: relative !important; }
.position-absolute { position: absolute !important; }
.overflow-hidden { overflow: hidden !important; }

/* Responsive Tables */
.table-responsive {
  width: 100%;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}
