/**
 * MELODI ERP — Central Design System Common Stylesheet
 * Framework UI inspiré de Bootstrap 5 — 100% Natif & Design Tokens
 * Contient : Box-sizing, Grille 12 colonnes responsive, Breakpoints, Utilitaires universels.
 */

/* ── 1. Box-Sizing & Reset de base ────────────────────────────────────────── */
*, *::before, *::after {
  box-sizing: border-box;
}

html {
  font-family: var(--ds-font-sans);
  line-height: 1.5;
  -webkit-text-size-adjust: 100%;
  -webkit-tap-highlight-color: transparent;
}

body {
  margin: 0;
  font-family: var(--ds-font-sans);
  font-size: var(--ds-font-size-base);
  font-weight: var(--ds-font-weight-regular);
  line-height: 1.5;
  color: var(--ds-color-text);
  background-color: var(--ds-color-bg);
}

/* ── 2. Système de Conteneurs (Containers) ────────────────────────────────── */
.container,
.container-fluid,
.container-sm,
.container-md,
.container-lg,
.container-xl,
.container-xxl {
  --ds-gutter-x: var(--ds-space-4);
  --ds-gutter-y: 0;
  width: 100%;
  padding-right: calc(var(--ds-gutter-x) * 0.5);
  padding-left: calc(var(--ds-gutter-x) * 0.5);
  margin-right: auto;
  margin-left: auto;
}

@media (min-width: 576px) {
  .container, .container-sm { max-width: 540px; }
}
@media (min-width: 768px) {
  .container, .container-sm, .container-md { max-width: 720px; }
}
@media (min-width: 992px) {
  .container, .container-sm, .container-md, .container-lg { max-width: 960px; }
}
@media (min-width: 1200px) {
  .container, .container-sm, .container-md, .container-lg, .container-xl { max-width: 1140px; }
}
@media (min-width: 1400px) {
  .container, .container-sm, .container-md, .container-lg, .container-xl, .container-xxl { max-width: 1320px; }
}

/* ── 3. Système de Grille Responsive 12 Colonnes (Grid & Rows) ────────────── */
.row {
  --ds-gutter-x: var(--ds-space-4);
  --ds-gutter-y: 0;
  display: flex;
  flex-wrap: wrap;
  margin-top: calc(-1 * var(--ds-gutter-y));
  margin-right: calc(-0.5 * var(--ds-gutter-x));
  margin-left: calc(-0.5 * var(--ds-gutter-x));
}

.row > * {
  box-sizing: border-box;
  flex-shrink: 0;
  width: 100%;
  max-width: 100%;
  padding-right: calc(var(--ds-gutter-x) * 0.5);
  padding-left: calc(var(--ds-gutter-x) * 0.5);
  margin-top: var(--ds-gutter-y);
}

.col { flex: 1 0 0%; }
.col-auto { flex: 0 0 auto; width: auto; }
.col-1  { flex: 0 0 auto; width: 8.33333333%; }
.col-2  { flex: 0 0 auto; width: 16.66666667%; }
.col-3  { flex: 0 0 auto; width: 25%; }
.col-4  { flex: 0 0 auto; width: 33.33333333%; }
.col-5  { flex: 0 0 auto; width: 41.66666667%; }
.col-6  { flex: 0 0 auto; width: 50%; }
.col-7  { flex: 0 0 auto; width: 58.33333333%; }
.col-8  { flex: 0 0 auto; width: 66.66666667%; }
.col-9  { flex: 0 0 auto; width: 75%; }
.col-10 { flex: 0 0 auto; width: 83.33333333%; }
.col-11 { flex: 0 0 auto; width: 91.66666667%; }
.col-12 { flex: 0 0 auto; width: 100%; }

/* Colonnes Responsive : sm (>=576px) */
@media (min-width: 576px) {
  .col-sm { flex: 1 0 0%; }
  .col-sm-auto { flex: 0 0 auto; width: auto; }
  .col-sm-1  { flex: 0 0 auto; width: 8.33333333%; }
  .col-sm-2  { flex: 0 0 auto; width: 16.66666667%; }
  .col-sm-3  { flex: 0 0 auto; width: 25%; }
  .col-sm-4  { flex: 0 0 auto; width: 33.33333333%; }
  .col-sm-5  { flex: 0 0 auto; width: 41.66666667%; }
  .col-sm-6  { flex: 0 0 auto; width: 50%; }
  .col-sm-7  { flex: 0 0 auto; width: 58.33333333%; }
  .col-sm-8  { flex: 0 0 auto; width: 66.66666667%; }
  .col-sm-9  { flex: 0 0 auto; width: 75%; }
  .col-sm-10 { flex: 0 0 auto; width: 83.33333333%; }
  .col-sm-11 { flex: 0 0 auto; width: 91.66666667%; }
  .col-sm-12 { flex: 0 0 auto; width: 100%; }
}

/* Colonnes Responsive : md (>=768px) */
@media (min-width: 768px) {
  .col-md { flex: 1 0 0%; }
  .col-md-auto { flex: 0 0 auto; width: auto; }
  .col-md-1  { flex: 0 0 auto; width: 8.33333333%; }
  .col-md-2  { flex: 0 0 auto; width: 16.66666667%; }
  .col-md-3  { flex: 0 0 auto; width: 25%; }
  .col-md-4  { flex: 0 0 auto; width: 33.33333333%; }
  .col-md-5  { flex: 0 0 auto; width: 41.66666667%; }
  .col-md-6  { flex: 0 0 auto; width: 50%; }
  .col-md-7  { flex: 0 0 auto; width: 58.33333333%; }
  .col-md-8  { flex: 0 0 auto; width: 66.66666667%; }
  .col-md-9  { flex: 0 0 auto; width: 75%; }
  .col-md-10 { flex: 0 0 auto; width: 83.33333333%; }
  .col-md-11 { flex: 0 0 auto; width: 91.66666667%; }
  .col-md-12 { flex: 0 0 auto; width: 100%; }
}

/* Colonnes Responsive : lg (>=992px) */
@media (min-width: 992px) {
  .col-lg { flex: 1 0 0%; }
  .col-lg-auto { flex: 0 0 auto; width: auto; }
  .col-lg-1  { flex: 0 0 auto; width: 8.33333333%; }
  .col-lg-2  { flex: 0 0 auto; width: 16.66666667%; }
  .col-lg-3  { flex: 0 0 auto; width: 25%; }
  .col-lg-4  { flex: 0 0 auto; width: 33.33333333%; }
  .col-lg-5  { flex: 0 0 auto; width: 41.66666667%; }
  .col-lg-6  { flex: 0 0 auto; width: 50%; }
  .col-lg-7  { flex: 0 0 auto; width: 58.33333333%; }
  .col-lg-8  { flex: 0 0 auto; width: 66.66666667%; }
  .col-lg-9  { flex: 0 0 auto; width: 75%; }
  .col-lg-10 { flex: 0 0 auto; width: 83.33333333%; }
  .col-lg-11 { flex: 0 0 auto; width: 91.66666667%; }
  .col-lg-12 { flex: 0 0 auto; width: 100%; }
}

/* Colonnes Responsive : xl (>=1200px) */
@media (min-width: 1200px) {
  .col-xl { flex: 1 0 0%; }
  .col-xl-auto { flex: 0 0 auto; width: auto; }
  .col-xl-1  { flex: 0 0 auto; width: 8.33333333%; }
  .col-xl-2  { flex: 0 0 auto; width: 16.66666667%; }
  .col-xl-3  { flex: 0 0 auto; width: 25%; }
  .col-xl-4  { flex: 0 0 auto; width: 33.33333333%; }
  .col-xl-5  { flex: 0 0 auto; width: 41.66666667%; }
  .col-xl-6  { flex: 0 0 auto; width: 50%; }
  .col-xl-7  { flex: 0 0 auto; width: 58.33333333%; }
  .col-xl-8  { flex: 0 0 auto; width: 66.66666667%; }
  .col-xl-9  { flex: 0 0 auto; width: 75%; }
  .col-xl-10 { flex: 0 0 auto; width: 83.33333333%; }
  .col-xl-11 { flex: 0 0 auto; width: 91.66666667%; }
  .col-xl-12 { flex: 0 0 auto; width: 100%; }
}

/* ── 4. Gutters (g-*, gx-*, gy-*) ─────────────────────────────────────────── */
.g-0, .gx-0 { --ds-gutter-x: 0px; }
.g-0, .gy-0 { --ds-gutter-y: 0px; }
.g-1, .gx-1 { --ds-gutter-x: var(--ds-space-1); }
.g-1, .gy-1 { --ds-gutter-y: var(--ds-space-1); }
.g-2, .gx-2 { --ds-gutter-x: var(--ds-space-2); }
.g-2, .gy-2 { --ds-gutter-y: var(--ds-space-2); }
.g-3, .gx-3 { --ds-gutter-x: var(--ds-space-3); }
.g-3, .gy-3 { --ds-gutter-y: var(--ds-space-3); }
.g-4, .gx-4 { --ds-gutter-x: var(--ds-space-4); }
.g-4, .gy-4 { --ds-gutter-y: var(--ds-space-4); }
.g-5, .gx-5 { --ds-gutter-x: var(--ds-space-6); }
.g-5, .gy-5 { --ds-gutter-y: var(--ds-space-6); }

/* ── 5. Utilitaires Flexbox & Alignment ───────────────────────────────────── */
.d-flex { display: flex !important; }
.d-inline-flex { display: inline-flex !important; }
.d-none { display: none !important; }
.d-block { display: block !important; }
.d-inline { display: inline !important; }
.d-inline-block { display: inline-block !important; }
.d-grid { display: grid !important; }

@media (min-width: 576px) {
  .d-sm-none { display: none !important; }
  .d-sm-block { display: block !important; }
  .d-sm-flex { display: flex !important; }
  .d-sm-inline-flex { display: inline-flex !important; }
}
@media (min-width: 768px) {
  .d-md-none { display: none !important; }
  .d-md-block { display: block !important; }
  .d-md-flex { display: flex !important; }
  .d-md-inline-flex { display: inline-flex !important; }
}
@media (min-width: 992px) {
  .d-lg-none { display: none !important; }
  .d-lg-block { display: block !important; }
  .d-lg-flex { display: flex !important; }
  .d-lg-inline-flex { display: inline-flex !important; }
}
@media (min-width: 1200px) {
  .d-xl-none { display: none !important; }
  .d-xl-block { display: block !important; }
  .d-xl-flex { display: flex !important; }
}

.flex-row { flex-direction: row !important; }
.flex-column { flex-direction: column !important; }
.flex-row-reverse { flex-direction: row-reverse !important; }
.flex-column-reverse { flex-direction: column-reverse !important; }
.flex-wrap { flex-wrap: wrap !important; }
.flex-nowrap { flex-wrap: nowrap !important; }
.flex-fill { flex: 1 1 auto !important; }
.flex-grow-0 { flex-grow: 0 !important; }
.flex-grow-1 { flex-grow: 1 !important; }
.flex-shrink-0 { flex-shrink: 0 !important; }
.flex-shrink-1 { flex-shrink: 1 !important; }

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

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

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

.gap-0 { gap: 0 !important; }
.gap-1 { gap: var(--ds-space-1) !important; }
.gap-2 { gap: var(--ds-space-2) !important; }
.gap-3 { gap: var(--ds-space-3) !important; }
.gap-4 { gap: var(--ds-space-4) !important; }
.gap-5 { gap: var(--ds-space-6) !important; }

/* ── 6. Utilitaires d'Espacement (Margin & Padding) ───────────────────────── */
.m-0 { margin: 0 !important; }
.m-1 { margin: var(--ds-space-1) !important; }
.m-2 { margin: var(--ds-space-2) !important; }
.m-3 { margin: var(--ds-space-3) !important; }
.m-4 { margin: var(--ds-space-4) !important; }
.m-5 { margin: var(--ds-space-6) !important; }
.m-auto { margin: auto !important; }

.mt-0 { margin-top: 0 !important; }
.mt-1 { margin-top: var(--ds-space-1) !important; }
.mt-2 { margin-top: var(--ds-space-2) !important; }
.mt-3 { margin-top: var(--ds-space-3) !important; }
.mt-4 { margin-top: var(--ds-space-4) !important; }
.mt-5 { margin-top: var(--ds-space-6) !important; }
.mt-auto { margin-top: auto !important; }

.mb-0 { margin-bottom: 0 !important; }
.mb-1 { margin-bottom: var(--ds-space-1) !important; }
.mb-2 { margin-bottom: var(--ds-space-2) !important; }
.mb-3 { margin-bottom: var(--ds-space-3) !important; }
.mb-4 { margin-bottom: var(--ds-space-4) !important; }
.mb-5 { margin-bottom: var(--ds-space-6) !important; }
.mb-auto { margin-bottom: auto !important; }

.ms-0 { margin-left: 0 !important; }
.ms-1 { margin-left: var(--ds-space-1) !important; }
.ms-2 { margin-left: var(--ds-space-2) !important; }
.ms-3 { margin-left: var(--ds-space-3) !important; }
.ms-4 { margin-left: var(--ds-space-4) !important; }
.ms-5 { margin-left: var(--ds-space-6) !important; }
.ms-auto { margin-left: auto !important; }

.me-0 { margin-right: 0 !important; }
.me-1 { margin-right: var(--ds-space-1) !important; }
.me-2 { margin-right: var(--ds-space-2) !important; }
.me-3 { margin-right: var(--ds-space-3) !important; }
.me-4 { margin-right: var(--ds-space-4) !important; }
.me-5 { margin-right: var(--ds-space-6) !important; }
.me-auto { margin-right: auto !important; }

.mx-0 { margin-left: 0 !important; margin-right: 0 !important; }
.mx-1 { margin-left: var(--ds-space-1) !important; margin-right: var(--ds-space-1) !important; }
.mx-2 { margin-left: var(--ds-space-2) !important; margin-right: var(--ds-space-2) !important; }
.mx-3 { margin-left: var(--ds-space-3) !important; margin-right: var(--ds-space-3) !important; }
.mx-4 { margin-left: var(--ds-space-4) !important; margin-right: var(--ds-space-4) !important; }
.mx-5 { margin-left: var(--ds-space-6) !important; margin-right: var(--ds-space-6) !important; }
.mx-auto { margin-left: auto !important; margin-right: auto !important; }

.my-0 { margin-top: 0 !important; margin-bottom: 0 !important; }
.my-1 { margin-top: var(--ds-space-1) !important; margin-bottom: var(--ds-space-1) !important; }
.my-2 { margin-top: var(--ds-space-2) !important; margin-bottom: var(--ds-space-2) !important; }
.my-3 { margin-top: var(--ds-space-3) !important; margin-bottom: var(--ds-space-3) !important; }
.my-4 { margin-top: var(--ds-space-4) !important; margin-bottom: var(--ds-space-4) !important; }
.my-5 { margin-top: var(--ds-space-6) !important; margin-bottom: var(--ds-space-6) !important; }
.my-auto { margin-top: auto !important; margin-bottom: auto !important; }

.p-0 { padding: 0 !important; }
.p-1 { padding: var(--ds-space-1) !important; }
.p-2 { padding: var(--ds-space-2) !important; }
.p-3 { padding: var(--ds-space-3) !important; }
.p-4 { padding: var(--ds-space-4) !important; }
.p-5 { padding: var(--ds-space-6) !important; }

.pt-0 { padding-top: 0 !important; }
.pt-1 { padding-top: var(--ds-space-1) !important; }
.pt-2 { padding-top: var(--ds-space-2) !important; }
.pt-3 { padding-top: var(--ds-space-3) !important; }
.pt-4 { padding-top: var(--ds-space-4) !important; }
.pt-5 { padding-top: var(--ds-space-6) !important; }

.pb-0 { padding-bottom: 0 !important; }
.pb-1 { padding-bottom: var(--ds-space-1) !important; }
.pb-2 { padding-bottom: var(--ds-space-2) !important; }
.pb-3 { padding-bottom: var(--ds-space-3) !important; }
.pb-4 { padding-bottom: var(--ds-space-4) !important; }
.pb-5 { padding-bottom: var(--ds-space-6) !important; }

.ps-0 { padding-left: 0 !important; }
.ps-1 { padding-left: var(--ds-space-1) !important; }
.ps-2 { padding-left: var(--ds-space-2) !important; }
.ps-3 { padding-left: var(--ds-space-3) !important; }
.ps-4 { padding-left: var(--ds-space-4) !important; }
.ps-5 { padding-left: var(--ds-space-6) !important; }

.pe-0 { padding-right: 0 !important; }
.pe-1 { padding-right: var(--ds-space-1) !important; }
.pe-2 { padding-right: var(--ds-space-2) !important; }
.pe-3 { padding-right: var(--ds-space-3) !important; }
.pe-4 { padding-right: var(--ds-space-4) !important; }
.pe-5 { padding-right: var(--ds-space-6) !important; }

.px-0 { padding-left: 0 !important; padding-right: 0 !important; }
.px-1 { padding-left: var(--ds-space-1) !important; padding-right: var(--ds-space-1) !important; }
.px-2 { padding-left: var(--ds-space-2) !important; padding-right: var(--ds-space-2) !important; }
.px-3 { padding-left: var(--ds-space-3) !important; padding-right: var(--ds-space-3) !important; }
.px-4 { padding-left: var(--ds-space-4) !important; padding-right: var(--ds-space-4) !important; }
.px-5 { padding-left: var(--ds-space-6) !important; padding-right: var(--ds-space-6) !important; }

.py-0 { padding-top: 0 !important; padding-bottom: 0 !important; }
.py-1 { padding-top: var(--ds-space-1) !important; padding-bottom: var(--ds-space-1) !important; }
.py-2 { padding-top: var(--ds-space-2) !important; padding-bottom: var(--ds-space-2) !important; }
.py-3 { padding-top: var(--ds-space-3) !important; padding-bottom: var(--ds-space-3) !important; }
.py-4 { padding-top: var(--ds-space-4) !important; padding-bottom: var(--ds-space-4) !important; }
.py-5 { padding-top: var(--ds-space-6) !important; padding-bottom: var(--ds-space-6) !important; }

/* ── 7. Typographie & Alignement Texte ────────────────────────────────────── */
.text-start { text-align: left !important; }
.text-end { text-align: right !important; }
.text-center { text-align: center !important; }
.text-nowrap { white-space: nowrap !important; }
.text-truncate {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.fw-bold { font-weight: var(--ds-font-weight-bold) !important; }
.fw-semibold { font-weight: var(--ds-font-weight-semibold) !important; }
.fw-medium { font-weight: var(--ds-font-weight-medium) !important; }
.fw-normal { font-weight: var(--ds-font-weight-regular) !important; }

.fs-1 { font-size: var(--ds-font-size-3xl) !important; }
.fs-2 { font-size: var(--ds-font-size-2xl) !important; }
.fs-3 { font-size: var(--ds-font-size-xl) !important; }
.fs-4 { font-size: var(--ds-font-size-lg) !important; }
.fs-5 { font-size: var(--ds-font-size-base) !important; }
.fs-6 { font-size: var(--ds-font-size-sm) !important; }
.small { font-size: var(--ds-font-size-xs) !important; }

.text-primary { color: var(--ds-color-primary) !important; }
.text-secondary, .text-muted { color: var(--ds-color-text-subtle) !important; }
.text-success { color: var(--ds-color-success) !important; }
.text-danger { color: var(--ds-color-danger) !important; }
.text-warning { color: var(--ds-color-warning) !important; }
.text-info { color: var(--ds-color-info) !important; }
.text-dark { color: var(--ds-color-text) !important; }
.text-white { color: #ffffff !important; }

/* ── 8. Bordures, Arrondis & Ombres (Borders, Radii, Shadows) ─────────────── */
.border { border: 1px solid var(--ds-color-border) !important; }
.border-0 { border: 0 !important; }
.border-top { border-top: 1px solid var(--ds-color-border) !important; }
.border-bottom { border-bottom: 1px solid var(--ds-color-border) !important; }
.border-start { border-left: 1px solid var(--ds-color-border) !important; }
.border-end { border-right: 1px solid var(--ds-color-border) !important; }

.rounded { border-radius: var(--ds-radius-md) !important; }
.rounded-0 { border-radius: 0 !important; }
.rounded-1 { border-radius: var(--ds-radius-xs) !important; }
.rounded-2 { border-radius: var(--ds-radius-sm) !important; }
.rounded-3 { border-radius: var(--ds-radius-lg) !important; }
.rounded-4 { border-radius: var(--ds-radius-xl) !important; }
.rounded-pill { border-radius: var(--ds-radius-full) !important; }
.rounded-circle { border-radius: 50% !important; }

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

/* ── 9. Tailles & Positions (Sizing & Positions) ───────────────────────────── */
.w-100 { width: 100% !important; }
.w-auto { width: auto !important; }
.h-100 { height: 100% !important; }
.h-auto { height: auto !important; }
.mw-100 { max-width: 100% !important; }
.mh-100 { max-height: 100% !important; }
.min-vh-100 { min-height: 100vh !important; }

.position-relative { position: relative !important; }
.position-absolute { position: absolute !important; }
.position-fixed { position: fixed !important; }
.position-sticky { position: sticky !important; }

.top-0 { top: 0 !important; }
.bottom-0 { bottom: 0 !important; }
.start-0 { left: 0 !important; }
.end-0 { right: 0 !important; }

.overflow-hidden { overflow: hidden !important; }
.overflow-auto { overflow: auto !important; }

/* Arrière-plans utilitaires */
.bg-white { background-color: var(--ds-color-surface) !important; }
.bg-light { background-color: var(--ds-color-surface-subtle) !important; }
.bg-dark { background-color: var(--ds-primitive-slate-900) !important; }
.bg-primary { background-color: var(--ds-color-primary) !important; color: #fff !important; }
.bg-success { background-color: var(--ds-color-success) !important; color: #fff !important; }
.bg-danger { background-color: var(--ds-color-danger) !important; color: #fff !important; }
.bg-warning { background-color: var(--ds-color-warning) !important; color: #000 !important; }
.bg-info { background-color: var(--ds-color-info) !important; color: #fff !important; }
