/* HACCPilot — Stock page styles */

/* ── Page layout ─────────────────────────────────────────────── */
.stock-page {
  padding: 0 0 100px;
  max-width: 600px;
  margin: 0 auto;
}

/* ── Header ──────────────────────────────────────────────────── */
.stock-header {
  position: relative;
  padding: 16px 16px 12px;
  background: #fff;
  display: flex;
  align-items: center;
  gap: 12px;
}
.stock-header__title {
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  max-width: calc(100% - 190px);
  text-align: center;
  font-size: 22px;
  font-weight: 700;
  color: #111827;
  margin: 0;
}

/* ── Stats bar ───────────────────────────────────────────────── */
.stock-stats {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  padding: 0 16px 16px;
}
.stock-stat {
  background: #F9FAFB;
  border: 1px solid #E5E7EB;
  border-radius: 12px;
  padding: 12px;
  text-align: center;
}
.stock-stat--expired  { background: #FEF2F2; border-color: #FECACA; }
.stock-stat--expiring { background: #FFFBEB; border-color: #FDE68A; }
.stock-stat--ok       { background: #ECFDF5; border-color: #A7F3D0; }
.stock-stat__count {
  font-size: 22px;
  font-weight: 800;
  color: #111827;
  line-height: 1;
}
.stock-stat--expired  .stock-stat__count { color: #DC2626; }
.stock-stat--expiring .stock-stat__count { color: #D97706; }
.stock-stat--ok       .stock-stat__count { color: #059669; }
.stock-stat__label {
  font-size: 11px;
  font-weight: 600;
  color: #6B7280;
  margin-top: 4px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

/* ── Filtres : 2 dropdowns natifs habillés (titre d'axe au-dessus) ───────── */
/* CSS validé sur device (maquette select-test) — champ fermé habillé, panneau natif. */
.stock-filters { display: flex; flex-wrap: wrap; gap: 10px; align-items: flex-start; padding: 0 16px 12px; }
.filter-col { flex: 1 1 0; min-width: 0; display: flex; flex-direction: column; }
/* Categorie (Lot 5B) : pleine largeur -> passe a la ligne sous DLC+Zone (basis 100% = wrap). */
.filter-col--full { flex: 1 1 100%; }
.filter-label {
  font-size: 11px;              /* passer à 12px si trop discret au rendu */
  font-weight: 800;
  color: var(--color-primary-active);  /* bleu accent « actif » (#064CFC) — axe interactif, PAS un statut métier */
  letter-spacing: 0.06em;
  text-transform: uppercase;
  margin-bottom: 5px;           /* seul espaceur label↔champ (gap .filter-col = 0) */
  padding-left: 2px;
}
/* Champ fermé : wrapper (pastille + select), chevron custom en ::after. */
.filter-field {
  position: relative; width: 100%; min-width: 0;
  display: flex; align-items: center; gap: 8px;
  height: 38px; padding: 0 10px;
  background: #fff; border: 1px solid var(--color-border-light); border-radius: 10px;
}
/* Pastille couleur DLC EXTERNE (hors du select) — sync JS au filtre. */
.filter-dot { flex-shrink: 0; width: 10px; height: 10px; border-radius: 50%; background: #CBD5E1; transition: background .15s; }
/* <select> natif habillé : chevron système masqué, police app, transparent. */
.filter-select {
  flex: 1 1 0; min-width: 0;
  appearance: none; -webkit-appearance: none; -moz-appearance: none;
  border: none; outline: none; background: transparent;
  font-family: var(--font-family-base);
  font-size: 16px;            /* 16px = anti-zoom iOS au focus — NE PAS descendre sous 16 */
  font-weight: 600; color: var(--color-text-primary);
  height: 100%; line-height: 38px; padding: 0 18px 0 0;
  cursor: pointer;
}
.filter-select::-ms-expand { display: none; }
/* Chevron custom (le système est masqué par appearance:none). */
.filter-field::after {
  content: ''; position: absolute; right: 10px; top: 50%;
  width: 9px; height: 9px; margin-top: -6px;
  border-right: 2px solid var(--color-text-muted);
  border-bottom: 2px solid var(--color-text-muted);
  transform: rotate(45deg); pointer-events: none;
}

/* ── Search ──────────────────────────────────────────────────── */
.stock-search {
  padding: 0 16px 12px;
}
.stock-search__input {
  width: 100%;
  box-sizing: border-box;
  height: 42px;
  border: 1.5px solid #E5E7EB;
  border-radius: 10px;
  padding: 0 14px 0 38px;
  font-size: 14px;
  color: #111827;
  background: #F9FAFB url("data:image/svg+xml,%3Csvg width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%239CA3AF' stroke-width='2' stroke-linecap='round' stroke-linejoin='round' xmlns='http://www.w3.org/2000/svg'%3E%3Ccircle cx='11' cy='11' r='8'/%3E%3Cline x1='21' y1='21' x2='16.65' y2='16.65'/%3E%3C/svg%3E") no-repeat 12px center;
  outline: none;
  font-family: inherit;
}
.stock-search__input:focus { border-color: #2563EB; background-color: #fff; }

/* ── Product list ────────────────────────────────────────────── */
.stock-list {
  padding: 0 12px;
  display: flex;
  flex-direction: column;
}
/* Ligne DENSE (densification V2) : une ligne = une décision. Pastille de gravité en tête
   (remplace l'ancienne border-left), nom extensible, quantité/zone/J±N/⋮ alignés à droite. */
.stock-item {
  background: #fff;
  border-bottom: 1px solid #F1F5F9;
  padding: 10px 6px;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  display: flex;
  align-items: center;
  gap: 8px;
}
.stock-item:last-child { border-bottom: none; }
.stock-item:active { background: #F9FAFB; }

/* Pastille de gravité DLC — mêmes couleurs que l'ancienne bordure (rouge/ambre/vert/gris). */
.stock-dot { flex-shrink: 0; width: 10px; height: 10px; border-radius: 50%; }
.stock-dot--expired  { background: #DC2626; }
.stock-dot--expiring { background: #F59E0B; }
.stock-dot--ok       { background: #16A34A; }
.stock-dot--invalid  { background: #9CA3AF; }

/* Nom : occupe l'espace, tronqué sur une ligne. */
.stock-item__name {
  flex: 1; min-width: 0;
  font-size: 14px; font-weight: 600; color: #111827;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
/* Colonnes à LARGEUR FIXE → alignement vertical (lecture en colonnes). Le nom (flex:1)
   absorbe la variabilité et tronque ; quantité/zone/J±N gardent une position constante
   d'une ligne à l'autre. (Largeurs = point de départ, à affiner au rendu sur mobile.) */
/* Quantité : décisionnelle, alignée à droite (les nombres s'alignent sur le bord droit). */
.stock-item__qty { flex: 0 0 44px; text-align: right; font-size: 13px; font-weight: 700; color: #374151; }
/* Zone : chip discret. Colonne RÉSERVÉE même si vide (sinon J±N/⋮ se décalent) → :empty sans fond. */
.stock-item__zone {
  flex: 0 0 60px; text-align: center;
  font-size: 11px; font-weight: 600; color: #6B7280;
  background: #F3F4F6; border-radius: 4px; padding: 1px 6px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.stock-item__zone:empty { background: none; }
/* Mobile (Lot 5B) : la zone (tronquee/peu lisible en ligne dense) est masquee ; elle reste
   accessible via le filtre Zone. Masquage CSS uniquement (template JS inchange). */
@media (max-width: 640px) {
  .stock-item__zone { display: none; }
}
/* J±N : l'info reine, chip coloré par gravité, colonne fixe centrée. */
.stock-item__jn {
  flex: 0 0 56px; text-align: center;
  font-size: 13px; font-weight: 800; border-radius: 8px;
  padding: 2px 4px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.stock-item__jn--ok       { background: #ECFDF5; color: #059669; }
.stock-item__jn--expiring { background: #FFF7ED; color: #EA580C; }
.stock-item__jn--expired  { background: #FEF2F2; color: #DC2626; }
/* DLC aberrante/absente — gris neutre, PAS rouge « Dépassé » (garde-fou DLC). « À vérifier »
   plus long que « J+N » → police réduite pour tenir dans la colonne fixe. */
.stock-item__jn--invalid  { background: #F3F4F6; color: #6B7280; font-size: 9px; font-weight: 700; }
/* Tag « À compléter » : discret (outline ambre pâle), ne concurrence pas la pastille / le J±N. */
.stock-item__badge { flex-shrink: 0; font-size: 10px; font-weight: 700; border-radius: 999px; white-space: nowrap; }
.stock-item__badge--tocomplete { background: #FFFDF7; color: #B45309; border: 1px solid #FDE68A; padding: 1px 6px; }
.stock-item__badge--tocomplete::before { content: '📋 '; }
/* ⋮ : cible tactile ≥ 40px (marges négatives → absorbe le padding sans grossir la ligne). */
.stock-item__menu {
  flex-shrink: 0; border: none; background: none; color: #9CA3AF;
  font-size: 20px; line-height: 1; cursor: pointer;
  width: 40px; height: 40px; margin: -10px -6px -10px 0;
  display: flex; align-items: center; justify-content: center;
  -webkit-tap-highlight-color: transparent;
}
.stock-item__menu:active { color: #374151; }

/* Menu d'actions par lot (réutilise .sm-overlay/.sm-sheet) */
.sm-action-row {
  display: flex; align-items: center; gap: 12px; width: 100%;
  padding: 13px 4px; border: none; background: none; font-family: inherit;
  font-size: 15px; font-weight: 600; color: #111827; cursor: pointer; text-align: left;
  border-bottom: 1px solid #F3F4F6; -webkit-tap-highlight-color: transparent;
}
.sm-action-row:last-child { border-bottom: none; }
.sm-action-row > span:first-child { font-size: 20px; flex-shrink: 0; }
.sm-action-row__txt { display: flex; flex-direction: column; }
.sm-action-row small { font-size: 12px; font-weight: 400; color: #9CA3AF; margin-top: 2px; }

.stock-empty {
  text-align: center;
  padding: 48px 20px;
  color: #9CA3AF;
}
.stock-empty__icon { font-size: 44px; margin-bottom: 14px; }
.stock-empty__text { font-size: 15px; }

/* Pagination (STOCK-SCALABILITY-01) : compteur + bouton « Charger plus » sobre. */
.stock-footer { padding: 6px 16px 16px; display: flex; flex-direction: column; align-items: center; gap: 10px; }
.stock-footer__count { font-size: 13px; font-weight: 600; color: #6B7280; }
.stock-footer__more {
  height: 42px; padding: 0 24px; border-radius: 12px;
  border: 1px solid var(--color-border-light); background: #fff;
  font-family: var(--font-family-base); font-size: 14px; font-weight: 700; color: var(--color-text-primary);
  cursor: pointer; -webkit-tap-highlight-color: transparent;
}
.stock-footer__more:active:not(:disabled) { background: #F3F4F6; }
.stock-footer__more:disabled { opacity: 0.55; cursor: default; }

/* ── Movement modal (stock-modals) ───────────────────────────── */
.sm-overlay {
  position: fixed;
  inset: 0;
  z-index: 400;
  display: none;
  align-items: flex-end;
  justify-content: center;
}
.sm-overlay.is-open { display: flex; }
.sm-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
}
.sm-sheet {
  position: relative;
  width: 100%;
  max-width: 480px;
  background: #fff;
  border-radius: 24px 24px 0 0;
  padding: 0 20px calc(env(safe-area-inset-bottom, 0px) + 20px);
  max-height: 85dvh;
  overflow-y: auto;
}
.sm-handle {
  width: 36px; height: 4px; background: #E5E7EB; border-radius: 2px;
  margin: 10px auto 16px;
}
.sm-title { font-size: 18px; font-weight: 700; color: #111827; margin-bottom: 6px; }
.sm-subtitle { font-size: 13px; color: #6B7280; margin-bottom: 20px; }
.sm-type-grid {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 8px;
  margin-bottom: 16px;
}
.sm-type-btn {
  border: 1.5px solid #E5E7EB;
  border-radius: 12px;
  padding: 12px;
  background: #fff;
  cursor: pointer;
  text-align: center;
  -webkit-tap-highlight-color: transparent;
  font-family: inherit;
}
.sm-type-btn.active { border-color: #2563EB; background: #EFF6FF; }
.sm-type-btn__icon { font-size: 22px; margin-bottom: 4px; }
.sm-type-btn__label { font-size: 13px; font-weight: 600; color: #374151; }
.sm-type-btn.active .sm-type-btn__label { color: #1D4ED8; }

.sm-label { font-size: 13px; font-weight: 600; color: #374151; margin: 12px 0 6px; display: block; }
.sm-input {
  width: 100%; box-sizing: border-box; height: 46px;
  border: 1.5px solid #E5E7EB; border-radius: 10px; padding: 0 14px;
  font-size: 15px; color: #111827; background: #F9FAFB;
  font-family: inherit; outline: none;
}
.sm-input:focus { border-color: #2563EB; background: #fff; }
.sm-select { appearance: none; background-image: url("data:image/svg+xml,%3Csvg width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%236B7280' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round' xmlns='http://www.w3.org/2000/svg'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 14px center; padding-right: 38px; }
/* Sélecteur DLC/DDM (dateTypeToggleHtml, 3B) dans les modals stock — calqué sur .sm-input
   (la règle .date-type-select de scan.html est locale à cette page ; ici on est dans stock.css). */
.date-type-select {
  width: 100%; box-sizing: border-box; height: 46px;
  border: 1.5px solid #E5E7EB; border-radius: 10px; padding: 0 14px;
  font-size: 15px; color: #111827; background: #F9FAFB;
  font-family: inherit; outline: none;
}
.date-type-select:focus { border-color: #2563EB; background: #fff; }
.sm-qty-row { display: flex; gap: 8px; }
.sm-qty-row .sm-input { flex: 1; }
.sm-unit { height: 46px; border: 1.5px solid #E5E7EB; border-radius: 10px; padding: 0 10px; background: #F3F4F6; font-size: 13px; font-weight: 600; color: #6B7280; display: flex; align-items: center; white-space: nowrap; }
.sm-remaining { font-size: 12px; color: #9CA3AF; margin-top: 4px; }
.sm-submit {
  display: block; width: 100%; height: 50px; margin-top: 20px;
  background: #1E3A5F; color: #fff; border: none; border-radius: 14px;
  font-size: 16px; font-weight: 700; cursor: pointer; font-family: inherit;
  -webkit-tap-highlight-color: transparent;
}
.sm-submit:disabled { opacity: 0.5; }
.sm-submit:active:not(:disabled) { opacity: 0.85; }
.sm-submit--transform { background: #7C3AED; }

/* Sorties explicites des modales stock (× header + Annuler footer) — injectées par open(). */
.sm-close {
  position: absolute;
  top: 12px; right: 12px;
  width: 32px; height: 32px;
  display: flex; align-items: center; justify-content: center;
  border: none; border-radius: 50%; padding: 0;
  background: #F3F4F6; color: #6B7280;
  font-size: 22px; line-height: 1; cursor: pointer; font-family: inherit;
  -webkit-tap-highlight-color: transparent;
  z-index: 1;
}
.sm-close:active { background: #E5E7EB; }
.sm-footer { display: flex; gap: 10px; margin-top: 20px; }
.sm-footer .sm-submit { margin-top: 0; flex: 1; width: auto; }
.sm-cancel {
  flex: 1; height: 50px;
  background: #F3F4F6; color: #374151; border: none; border-radius: 14px;
  font-size: 16px; font-weight: 700; cursor: pointer; font-family: inherit;
  -webkit-tap-highlight-color: transparent;
}
.sm-cancel:active { background: #E5E7EB; }
.sm-type-btn--transform.active { border-color: #7C3AED; background: #F5F3FF; }

/* Modal « Categorie du produit » (Lot 5A) — liste de lignes selectionnables (sober active row) */
.sm-cat-loading { padding: 16px 2px; color: #6B7280; font-size: 14px; }
.sm-cat-list { display: flex; flex-direction: column; gap: 6px; max-height: 46vh; overflow-y: auto; }
.sm-cat-row {
  display: flex; align-items: center; justify-content: space-between;
  width: 100%; text-align: left; padding: 12px 14px;
  border: 1px solid #E5E7EB; border-radius: 10px; background: #fff;
  font-size: 15px; color: #111827; cursor: pointer; font-family: inherit;
  -webkit-tap-highlight-color: transparent;
}
.sm-cat-row:active { background: #F3F4F6; }
.sm-cat-row.is-active { border-color: #2563EB; background: #EFF6FF; font-weight: 700; }
.sm-cat-row.is-active::after { content: '\2713'; color: #2563EB; font-weight: 700; margin-left: 10px; }
.sm-cat-row:disabled { opacity: 0.5; cursor: default; }
/* Bloc de creation custom = section separee (separateur sobre + respiration franche). */
.sm-cat-create-section { margin-top: 18px; padding-top: 18px; border-top: 1px solid #E5E7EB; }
.sm-cat-create-title { font-size: 15px; font-weight: 700; color: #111827; margin-bottom: 4px; }
.sm-cat-field-label { display: block; font-size: 12px; font-weight: 500; color: #6B7280; margin-bottom: 8px; }
.sm-cat-create { display: flex; gap: 8px; align-items: stretch; }
.sm-cat-create .sm-input { flex: 1; margin: 0; }
.sm-cat-create .sm-submit { margin-top: 0; width: auto; flex: 0 0 auto; padding: 0 18px; }
.sm-type-btn--transform.active .sm-type-btn__label { color: #6D28D9; }
