/* =============================================================================
   Articles, référentiels, tarifs, base externe (cahier §11, §15, §17-§19) — compléments de app.css.
   Chargé par Response::view(..., ['styles' => ['css/articles.css']]).
   Gabarit commun de l'ancien programme (fenêtre, cadres, Accès, barre) : app.css (lot S).
   ============================================================================= */

/* Références saisies en majuscules (la validation convertit aussi côté serveur) */
input.up { text-transform: uppercase; }

/* Boutons-formulaires (Bloquer, Supprimer) dans une barre d'actions */
.pagehead .actions form { margin: 0; }

/* Libellés longs : retour à la ligne dans les tableaux */
.tbl td.cell-libelle { white-space: normal; min-width: 220px; }
.liste-note { margin: 0; padding: 10px 18px; }

/* PV saisi à la main : gardé quand le brut ou une remise change */
.pv-manuel-legende { font-style: italic; }

/* Champ de recherche d'article (articles automatiques, lignes de tarif) avec suggestions */
.lookup-cell { min-width: 150px; }
.lookup-cell .suggestions { min-width: 320px; }

/* Onglets en liens (base externe : Recherche / Importer) */
.tabs a.tab { text-decoration: none; }

/* Ligne de la base externe : bouton compact */
.tbl .btn-ligne { margin: 0; min-height: 32px; }

/* Valeur en lecture dans une grille (stocks, TVAC, articles automatiques) : même aspect qu'un champ grisé */
.art-val { display: block; min-height: 30px; padding: 5px 8px; border: 1px solid var(--line); border-radius: 6px; background: var(--surface-2); color: var(--ink);
  font: 400 13.5px/18px var(--mono); text-align: right; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
a.art-val-lien { text-align: left; color: var(--blue-ink); text-decoration: none; }
a.art-val-lien:hover { border-color: var(--primary); }

/* =============================================================================
   Fiche « Gestion des articles » (captures 140-159)
   ============================================================================= */

/* Cadre d'en-tête : Référence article (libellé au-dessus) | Famille / Sous famille [code ▼] [libellé] */
.art-entete { display: grid; grid-template-columns: minmax(140px, 220px) minmax(0, 1fr); gap: 6px 28px; align-items: center; }
.art-entete .art-ref > label { color: var(--blue-ink); font-weight: 600; }
.art-familles { display: flex; flex-direction: column; gap: 6px; min-width: 0; }

/* Code [▼] + libellé en lecture (Famille, Article remplacement, Fournisseur, Réf fournisseur) */
.art-paire { display: flex; gap: 6px; min-width: 0; }
.art-paire > .art-code, .art-paire > .combo-champ { flex: 0 0 130px; width: 130px; min-width: 0; }
.art-paire > .art-lib, .art-paire > .art-lib-saisi { flex: 1 1 auto; min-width: 0; }
a.art-lien { display: flex; align-items: center; flex: 1 1 auto; min-width: 0; min-height: 34px; padding: 0 10px; border: 1px solid var(--line); border-radius: 7px;
  background: var(--surface-2); color: var(--blue-ink); text-decoration: none; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
a.art-lien:hover { border-color: var(--primary); }

/* Même hauteur de fenêtre sous chaque onglet (la barre de boutons ne bouge pas, comme l'ancien) */
@media (min-width: 900px) { .fiche-article .fiche-corps { min-height: 490px; } }

/* Onglet Article : deux colonnes (libellés à gauche des champs), stocks par dépôt en bas */
.art-colonnes { display: grid; grid-template-columns: minmax(0, 1.8fr) minmax(250px, 1fr); gap: 6px 36px; align-items: start; }
.art-gauche, .art-droite { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.art-droite { gap: 3px; }
.art-trois { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 6px; }
.art-ligne { display: flex; align-items: center; gap: 6px 18px; min-width: 0; }
.art-ligne > .art-court { flex: 0 1 340px; }
.art-ligne > .art-genre { flex: 0 1 300px; --lbl: 52px; }
.art-droite .fld input, .art-droite .fld select { max-width: 220px; }
.art-controle { padding-top: 3px; border-top: 1px dashed var(--line); }
.art-controle .art-case-c { gap: 8px; }
.fenetre .art-controle .art-case-c > input:not([type="checkbox"]) { flex: 1 1 auto; min-width: 0; max-width: none; }

/* Case de l'ancien programme : libellé, puis la case */
.art-case .art-case-c { display: flex; align-items: center; min-height: 24px; }
.fenetre .art-case input[type="checkbox"] { width: 18px; height: 18px; min-height: 0; padding: 0; margin: 0; accent-color: var(--primary); cursor: pointer; }
.fenetre .art-case input[type="checkbox"]:disabled { cursor: default; }

/* Grille des stocks (Physique … Localisation), lignes Delcourt et Cete */
.art-stocks-zone { margin-top: 8px; }
.art-stocks { table-layout: fixed; min-width: 780px; border-collapse: separate; border-spacing: 5px 3px; }
.art-stocks th, .art-stocks td { padding: 0; border: 0; background: transparent; }
.art-stocks thead th, .art-stocks thead th.num { color: var(--blue-ink); font: 600 12.5px var(--font); text-align: center; white-space: nowrap; }
.art-stocks thead td:first-child { width: 72px; }
.art-stocks tbody th { padding-right: 2px; color: var(--blue-ink); font-weight: 600; font-size: 13px; text-align: right; }
.art-stocks thead th:last-child { width: 24%; text-align: left; }
.art-stocks .art-loc input { width: 100%; min-height: 30px; padding: 0 8px; border: 1px solid var(--field); border-radius: 6px; background: var(--surface); font: 400 13.5px var(--font); color: var(--ink); }
.art-stocks .art-loc input:focus { border-color: var(--primary); background: #F2FBF4; outline: none; }
.art-stocks .art-loc input:disabled { background: var(--surface-2); border-color: var(--line); color: var(--ink); -webkit-text-fill-color: var(--ink); opacity: 1; }
.art-stocks .art-loc input[aria-invalid="true"] { border-color: #D9A400; background: #FFFBEA; }
.art-stocks .art-dispo { font-weight: 600; }
.art-note { margin: 4px 0 0; }

/* Onglet Prix : TVA à gauche, cases à droite, cadre « Prix en Euro » */
.art-prix-haut { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 6px 24px; margin-bottom: 10px; }
.art-prix-haut .art-tva select { max-width: 150px; }
.art-prix-cases { display: flex; flex-wrap: wrap; gap: 2px 28px; }
.art-prix-cases .art-case { grid-template-columns: auto auto; }
.art-cadre-prix { padding: 4px 8px 8px; }
.art-cadre-prix + .art-cadre-prix { margin-top: 12px; }
.grille-prix { width: 100%; min-width: 880px; table-layout: fixed; border-collapse: separate; border-spacing: 6px 5px; }
.grille-prix col.gp-achat { width: 112px; }
.grille-prix col.gp-titre { width: 118px; }
.grille-prix th, .grille-prix td { padding: 0; border: 0; background: transparent; }
.grille-prix thead th { color: var(--blue-ink); font-weight: 600; font-size: 12.5px; text-align: right; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.grille-prix thead th.gp-achat-t { text-align: center; }
.grille-prix tbody th { color: var(--blue-ink); font-weight: 600; font-size: 13px; text-align: right; white-space: nowrap; }
.grille-prix .gp-base > * { vertical-align: middle; }
.grille-prix .gp-achat-c { vertical-align: middle; text-align: center; }
.grille-prix input { width: 100%; min-height: 32px; padding: 0 8px; border: 1px solid var(--field); border-radius: 6px; background: var(--surface); color: var(--ink);
  font: 400 13.5px var(--mono); text-align: right; }
.grille-prix input:focus { border-color: var(--primary); background: #F2FBF4; outline: none; }
.grille-prix input[aria-invalid="true"] { border-color: #D9A400; background: #FFFBEA; }
.grille-prix input:disabled { background: var(--surface-2); color: var(--ink); -webkit-text-fill-color: var(--ink); border-color: var(--line); opacity: 1; }
.grille-prix input.gp-pct { display: block; width: 66px; margin-left: auto; }
.grille-prix input.gp-emb { display: inline-block; width: 46px; min-height: 28px; margin-left: 4px; padding: 0 5px; }
/* Case « par 1 / par 100 / par emb » : bouton radio (une seule base) dessiné en case carrée, comme l'ancien */
.grille-prix input.gp-case { -webkit-appearance: none; appearance: none; display: inline-block; width: 16px; height: 16px; min-height: 0; margin: 0 0 0 5px; padding: 0;
  border: 1.5px solid #9AA3B2; border-radius: 3px; background: var(--surface); cursor: pointer; }
.grille-prix input.gp-case:checked { border-color: var(--primary); background: var(--primary); box-shadow: inset 0 0 0 3px var(--surface); }
.grille-prix input.gp-case:disabled { cursor: default; }
.grille-prix input.gp-case:disabled:checked { border-color: #6B7280; background: #6B7280; }
.grille-prix input.gp-case:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; }
.grille-prix input.pv-manuel { font-style: italic; border-color: #D9A400; }
.art-cadre-tvac .grille-prix tbody th { font-weight: 500; color: var(--ink-2); }

/* Onglet Commentaire : 4 articles automatiques toujours visibles, mémo dessous */
.art-autos { border-collapse: separate; border-spacing: 6px 5px; }
.art-autos th[scope="row"] { padding: 0 6px 0 0; color: var(--blue-ink); font-weight: 600; font-size: 13px; text-align: right; white-space: nowrap; }
.art-autos td { padding: 0; border: 0; }
.art-autos .lookup-cell { width: 170px; }
.art-autos .art-auto-lib { width: 340px; }
.art-autos .art-auto-lib .art-val { text-align: left; font-family: var(--font); }
.art-autos input.num { width: 110px; min-width: 0; }
.art-autos input[type="checkbox"] { width: 18px; height: 18px; min-width: 0; min-height: 0; padding: 0; accent-color: var(--primary); }
.art-autos td.small { padding-left: 6px; }
.art-memo { margin-top: 10px; }
.fenetre .art-memo textarea { min-height: 220px; }

/* Onglet Stock : cases en haut, titre bleu au centre, grille, types de documents en bas */
.art-histo-tete { display: grid; grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr); align-items: center; gap: 6px 16px; margin-bottom: 8px; }
.art-histo-titre { margin: 0; font-size: 18px; font-weight: 700; color: #1D3FD8; text-align: center; }
.art-histo-case { display: inline-flex; align-items: center; gap: 8px; min-height: 32px; justify-self: start; color: var(--ink); font-size: 13.5px; text-decoration: none; }
.art-histo-case:last-child { justify-self: end; }
.art-histo-case:hover { color: var(--blue-ink); }
.art-case-b { flex: none; width: 16px; height: 16px; border: 1.5px solid #9AA3B2; border-radius: 3px; background: var(--surface); }
.art-histo-case[aria-checked="true"] .art-case-b { border-color: var(--primary); background: var(--primary); box-shadow: inset 0 0 0 3px var(--surface); }
.art-histo-vide { min-height: 120px; margin: 0; padding: 40px 0; text-align: center; }
/* Grille avec ascenseur, en-tête fixe : les types de documents restent visibles en bas (capture 151) */
.art-histo-defile { max-height: max(250px, calc(100vh - 560px)); overflow: auto; border: 1px solid var(--line-2); border-radius: 6px; }
.art-histo-defile .tbl thead th { position: sticky; top: 0; z-index: 1; }
.tbl.art-histo th, .tbl.art-histo td { padding: 6px 8px; }
.tbl.art-histo td.cell-libelle { min-width: 0; max-width: 230px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.art-radios { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 2px 14px; margin-top: 12px; padding-top: 8px; border-top: 1px solid var(--line-2); }
.art-radios .acces-r { color: var(--ink); font-weight: 500; }
.art-radios .art-radio-ajout { margin-left: 12px; }
.art-mesure { justify-content: center; gap: 2px 48px; border-top: 0; }

/* Onglet Statistique (capture 154) : disposition côte à côte du partiel commun (listes-tiers.css, lot B) ;
   radios Quantités / Chiffre d'affaire sous le graphique. */
.art-stats .art-mesure { margin-top: 10px; padding-top: 0; }

/* Fiche vide d'Efface (F1) : valeurs en lecture masquées comme les champs vidés */
.fenetre-vide .fiche-corps :is(.art-val, .art-histo-titre, .art-histo-case, .art-radios), .fenetre-vide a.art-lien { visibility: hidden; }

/* Colonne annexe : résumé de l'article (ajout web) */
.art-resume .kpi { gap: 4px; padding: 12px 14px; }
.art-resume .kpi .v { font-size: 20px; }
.art-resume .art-etat { margin: 0; display: flex; flex-wrap: wrap; gap: 6px; }
@media (max-width: 1727px) {
  .fenetre-annexe.art-resume { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(200px, 100%), 1fr)); gap: 12px; }
}

/* =============================================================================
   Consultation des articles (liste, F9 ; captures 142-143, 147) : fenêtre, cadres, bande et barre du bas dans
   consultation.css (commun aux fenêtres « Consultation des … ») ; ici, l'Accès en 8 radios et la grille.
   ============================================================================= */
.cons-acces .acces-r { min-height: 28px; font-size: 13px; }
.tbl.cons-grille th, .tbl.cons-grille td { padding-left: 6px; padding-right: 6px; }
.tbl.cons-grille td.cell-libelle { min-width: 170px; max-width: 280px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tbl.cons-grille td.cons-reff { max-width: 130px; overflow: hidden; text-overflow: ellipsis; }
.tbl.cons-grille td.cons-etat { white-space: normal; min-width: 80px; }

/* =============================================================================
   Fiche « Gestion base externe » (captures 170-171)
   ============================================================================= */
.fenetre-zone:has(.fiche-base-externe) { grid-template-columns: minmax(0, 1000px); }
.fiche-entete.be-entete { grid-template-columns: minmax(0, 1fr) minmax(300px, 540px); }
.be-cle { display: flex; align-items: center; gap: 8px; min-height: 52px; }
.be-cle .be-id { width: 110px; min-height: 30px; padding: 0 8px; border: 1px solid var(--line); border-radius: 6px; background: var(--surface-2); color: var(--ink-2); font: 400 13px var(--mono); }
.be-cle .be-id:not(:disabled) { background: var(--surface); border-color: var(--field); color: var(--ink); }
.be-grille { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 6px 28px; max-width: 960px; }
.be-grille > .span-2 { grid-column: 1 / -1; }
.be-grille > .be-demi, .be-grille > .be-g { grid-column: 1; }
.be-grille > .be-court input { max-width: 140px; }
.be-grille > .be-fournisseur select { max-width: 520px; }
.be-paire { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 6px; }
.be-trois { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 6px; }
.be-net { display: flex; align-items: center; min-height: 34px; font-family: var(--mono); font-weight: 600; }
.fiche-base-externe .fldl { color: var(--blue-ink); font-weight: 600; text-align: right; }

/* Import : compte rendu et format (écrans d'importation) */
.compte-rendu { display: flex; flex-direction: column; gap: 12px; padding-top: 8px; border-top: 1px solid var(--line-2); }
.compte-rendu .tile { cursor: default; }
.compte-rendu .tile:hover { border-color: var(--line); }
.exemple-csv { margin: 0; padding: 12px 14px; background: var(--surface-2); border: 1px solid var(--line); border-radius: var(--radius); font: 12.5px/1.6 var(--mono); overflow-x: auto; white-space: pre; }

/* Fiche en lecture (listes de définitions) */
.fiche-lecture { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(240px, 100%), 1fr)); gap: 14px 24px; margin: 0 0 16px; }
.fiche-lecture dt { font-size: 12.5px; color: var(--muted); }
.fiche-lecture dd { margin: 2px 0 0; font-weight: 500; overflow-wrap: anywhere; }

/* Moins de 900 px : cadres et colonnes empilés (libellés au-dessus : app.css) */
@media (max-width: 899px) {
  .art-entete, .art-colonnes, .be-grille, .fiche-entete.be-entete { grid-template-columns: minmax(0, 1fr); }
  .be-grille > .be-vide { display: none; }
  .be-trois { grid-template-columns: minmax(0, 1fr); }
  .fiche-base-externe .fldl { text-align: left; }
  .cons-acces .cs-acces { grid-template-rows: none; grid-auto-flow: row; grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .art-paire > .art-code, .art-paire > .combo-champ { flex: 0 0 112px; width: 112px; }
  .fld-l.art-case { flex-direction: row; align-items: center; justify-content: flex-start; gap: 12px; }
  .fld-l.art-case > label { flex: 0 0 150px; }
  .fld-l.art-controle .art-case-c { flex: 1 1 auto; }
  .art-trois { grid-template-columns: minmax(0, 1fr); }
  .art-ligne { flex-direction: column; align-items: stretch; }
  .art-ligne > .art-court, .art-ligne > .art-genre { flex: none; }
  .art-droite .fld input, .art-droite .fld select { max-width: none; }
  .art-prix-haut { flex-direction: column; align-items: stretch; }
  .art-histo-tete { grid-template-columns: minmax(0, 1fr); }
  .art-histo-titre { text-align: left; }
  .art-histo-case:last-child { justify-self: start; }
  .art-radios { justify-content: flex-start; }
  .art-histo-defile { max-height: none; }
  .art-autos .art-auto-lib { width: 220px; }
}
@media (max-width: 599px) {
  .tbl td.cell-libelle { min-width: 160px; }
  .lookup-cell .suggestions { min-width: 0; }
}
