/* ============================================================================
   Listes de la gestion commerciale d'un dossier marocain (Entrepôts, Stocks, Produits…).
   Mise en page reprise de Compta : barre de filtres horizontale au-dessus, carte avec titre et boutons à droite,
   tableau à en-tête grisé, pagination « Éléments par page ».
   ========================================================================= */

/* Sur :root : les fenêtres (modales) sont rendues hors de .ml-page et utilisent aussi ces couleurs. */
:root {
  --ml-navy: #1f3358;
  --ml-navy-hover: #172745;
  --ml-accent: #6d4cff;
  --ml-line: #e2e8f0;
  --ml-head: #f1f5fb;
  --ml-ink: #1e293b;
  --ml-muted: #64748b;
}

.ml-page {
  display: flex;
  flex-direction: column;
  gap: 10px;
  min-width: 0;
  color: var(--ml-ink);
  font-size: 13px;
}

/* --- barre de filtres --- */
.ml-filters {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 14px;
  background: #fff;
  border-left: 3px solid var(--ml-accent);
  border-radius: 4px;
  box-shadow: 0 1px 6px rgba(15, 26, 46, .10);
}
.ml-filters__fields { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 8px 10px; flex: 1 1 auto; min-width: 0; }
.ml-filters__fields > .ml-field { width: 190px; }
.ml-filters__fields > .ml-field--wide { width: 300px; }
.ml-filters__actions { display: flex; gap: 8px; flex: 0 0 auto; }

.ml-field .form-control,
.ml-field .form-select {
  height: 38px;
  border: 1px solid #cbd5e1;
  border-radius: 4px;
  font-size: 13px;
  box-shadow: none;
}
.ml-field .form-control:focus,
.ml-field .form-select:focus { border-color: var(--ml-accent); }

.ml-checks { border: 1px solid var(--ml-line); border-radius: 4px; padding: 6px 10px; max-height: 120px; overflow-y: auto; background: #fff; }
.ml-checks__title { font-size: 10.5px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; color: var(--ml-muted); }

/* --- boutons --- */
.ml-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 7px 14px;
  border: 1px solid var(--ml-navy);
  border-radius: 3px;
  background: var(--ml-navy);
  color: #fff;
  font-size: 12.5px;
  font-weight: 600;
  line-height: 1.2;
  cursor: pointer;
  white-space: nowrap;
}
.ml-btn:hover:not(:disabled) { background: var(--ml-navy-hover); border-color: var(--ml-navy-hover); color: #fff; }
.ml-btn:disabled { opacity: .55; cursor: default; }
.ml-btn.dropdown-toggle::after { margin-left: 4px; }

.ml-iconbtn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 30px;
  border: 0;
  border-radius: 3px;
  background: var(--ml-navy);
  color: #fff;
  cursor: pointer;
}
.ml-iconbtn:hover { background: var(--ml-navy-hover); }
.ml-iconbtn--ghost { background: transparent; color: var(--ml-navy); width: 28px; }
.ml-iconbtn--ghost:hover { background: rgba(15, 26, 46, .08); }
.ml-iconbtn--danger { background: #e53935; }
.ml-iconbtn--danger:hover { background: #c62828; }
.ml-iconbtn i { font-size: 16px; }

/* --- carte du tableau --- */
.ml-card {
  background: #fff;
  border-radius: 4px;
  box-shadow: 0 1px 6px rgba(15, 26, 46, .10);
  min-width: 0;
}

.ml-tabs { display: flex; border-bottom: 1px solid var(--ml-line); }
.ml-tabs button {
  padding: 14px 32px;
  border: 0;
  background: transparent;
  color: var(--ml-ink);
  font-size: 12.5px;
  font-weight: 500;
  letter-spacing: .03em;
  text-transform: uppercase;
  cursor: pointer;
  border-bottom: 2px solid transparent;
}
.ml-tabs button.is-active { color: var(--ml-accent); border-bottom-color: var(--ml-accent); }

.ml-card__toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 14px 18px;
}
.ml-card__title { margin: 0; font-size: 1.15rem; font-weight: 700; color: var(--ml-navy); }
.ml-card__actions { display: flex; gap: 8px; align-items: center; }

.ml-table-wrap { overflow: auto; }
.ml-table { width: 100%; border-collapse: collapse; }
.ml-table thead th {
  position: sticky;
  top: 0;
  padding: 14px 16px;
  background: var(--ml-head);
  border-bottom: 1px solid var(--ml-line);
  color: #475569;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: .05em;
  text-transform: uppercase;
  white-space: nowrap;
}
.ml-table thead th.is-sortable { cursor: pointer; user-select: none; }
.ml-table tbody td { padding: 10px 16px; border-bottom: 1px solid #edf1f7; vertical-align: middle; }
.ml-table tbody tr:hover { background: #f8fafd; }
.ml-table .is-num { text-align: right; font-variant-numeric: tabular-nums; }
.ml-table .ml-empty { padding: 28px; text-align: center; color: var(--ml-muted); }
.ml-table .ml-actions { display: flex; gap: 4px; justify-content: flex-end; }

.ml-thumb { width: 48px; height: 48px; object-fit: cover; border-radius: 6px; background: #1e1e1e; cursor: zoom-in; }

/* --- pagination --- */
.ml-pager {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: flex-end;
  gap: 24px;
  padding: 10px 18px;
  border-top: 1px solid var(--ml-line);
  color: #475569;
  font-size: 12.5px;
}
.ml-pager select { border: 0; border-bottom: 1px solid #94a3b8; background: transparent; padding: 2px 4px; font-size: 12.5px; }
.ml-pager button { border: 0; background: transparent; color: #475569; padding: 4px 8px; cursor: pointer; }
.ml-pager button:disabled { color: #cbd5e1; cursor: default; }
.ml-pager button i { font-size: 18px; }

.ml-table thead th.is-num { text-align: right; }
.ml-table tfoot td { padding: 10px 16px; border-top: 2px solid var(--ml-line); background: var(--ml-head); }
.ml-thumb { cursor: zoom-in; }
.ml-photo { width: 120px; height: 120px; border: 1px dashed #cbd5e1; border-radius: 8px; display: flex; align-items: center; justify-content: center; overflow: hidden; background: #f8fafc; color: #94a3b8; flex: 0 0 auto; }
.ml-photo img { width: 100%; height: 100%; object-fit: cover; }
.ml-photo i { font-size: 40px; }

/* Tiroir d'aperçu PDF (liste des documents) */
.mdl-drawer-backdrop { position: fixed; inset: 0; background: rgba(15, 26, 46, .35); z-index: 1040; }
.mdl-drawer { position: fixed; top: 0; right: 0; bottom: 0; width: min(780px, 100vw); background: #fff; z-index: 1050; display: flex; flex-direction: column; box-shadow: -4px 0 18px rgba(15, 26, 46, .25); }
.mdl-drawer__head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 12px 16px; border-bottom: 1px solid #e2e8f0; }
.mdl-drawer__body { flex: 1 1 auto; min-height: 0; }
.mdl-drawer__body iframe { width: 100%; height: 100%; border: 0; }

/* Colonne Paiement (Compta : wh-pay) */
.wh-pay-cell { display: flex; flex-direction: column; align-items: flex-end; gap: 2px; font-variant-numeric: tabular-nums; }
.wh-pay { display: inline-flex; align-items: center; justify-content: center; box-sizing: border-box; height: 18px; width: 64px; min-width: 64px; max-width: 64px; padding: 0 4px; border: 1px solid #cbd5e1; border-radius: 2px; background: #fff; font-size: 10px; font-weight: 600; line-height: 1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; color: #64748b; }
.wh-pay--done { color: #1a7a4a; border-color: #1a7a4a; background: #f0faf4; }
.wh-pay--part { color: #1e3a5f; border-color: #1e3a5f; background: #eef1f6; }
.wh-pay--due { color: #b91c1c; border-color: #b91c1c; background: #fef2f2; }
.wh-pay--ko { color: #94a3b8; border-color: #cbd5e1; background: #f8fafc; }

/* Boutons et menus partagés par la liste et ses fenêtres (le style propre à la liste ne s'applique pas aux composants enfants). */
.mdl-btn-navy { background: #1e3a5f; border-color: #1e3a5f; color: #fff; }
.mdl-btn-navy:hover, .mdl-btn-navy:focus { background: #16304f; color: #fff; }
.mdl-btn-outline { border: 1px solid #1e3a5f; color: #1e3a5f; background: #fff; }
.mdl-dropdown { position: relative; }
.mdl-dd-menu { position: absolute; top: 100%; left: 0; z-index: 30; min-width: 12rem; margin-top: .2rem; padding: .3rem 0; background: #fff; border: 1px solid #e2e8f0; border-radius: .4rem; box-shadow: 0 6px 18px rgba(15, 23, 42, .12); }
.mdl-dd-menu--right { left: auto; right: 0; }
.mdl-dd-item { display: flex; align-items: center; width: 100%; padding: .35rem .8rem; border: 0; background: none; text-align: left; cursor: pointer; margin: 0; }
.mdl-dd-item:hover:not(:disabled) { background: #f1f5f9; }
.mdl-dd-item:disabled { color: #cbd5e1; cursor: default; }

/* Pages de récupération : le tableau défile dans la carte (hauteur bornée), la pagination reste en bas.
   .accounting-shell .accounting-bounded-list > .card-body (spécificité 0,3,0) impose overflow:hidden et
   flex-direction:column — on s'appuie dessus en rendant .table-responsive flex:1 + overflow-y:auto, ce qui
   lui permet de prendre tout l'espace disponible et de défiler. La pagination (ml-pager) est l'élément
   suivant dans la colonne flex et reste visible en bas sans positionnement sticky. */
.mrec-page > .card-body > .table-responsive {
  flex: 1 !important;
  min-height: 0 !important;
  overflow-y: auto !important;
}
.mrec-page > .card-body > .ml-pager { border-top: 1px solid #e2e8f0; background: #fff; }
.mrec-page thead th { position: sticky; top: 0; background: #fff; z-index: 1; }

/* Le tableau défile dans la carte (horizontalement et verticalement) : sans ceci il garde sa hauteur
   naturelle (flex-shrink:0 du shell) et le bas de la liste est coupé. */
.accounting-shell .mrec-page.accounting-bounded-list > .card-body > .table-responsive {
  flex: 1 1 auto;
  min-height: 0;
  overflow: auto;
}
