/* Module Approvisionnements (PO, livraisons, fournisseurs, besoins) — classes préfixées « pr- », variables du socle uniquement. */

/* Vue d'ensemble : grilles qui s'élargissent sur grand écran, une colonne sur téléphone */
.pr-overview { gap: var(--gap-page, 1rem); }
.pr-grid { display: grid; gap: var(--gap-page, 1rem); align-items: stretch; min-width: 0; }
.pr-grid > * { min-width: 0; }
.pr-grid-3 { grid-template-columns: repeat(auto-fit, minmax(min(100%, 330px), 1fr)); }
.pr-grid-2 { grid-template-columns: repeat(auto-fit, minmax(min(100%, 420px), 1fr)); }
.pr-grid > .panel { display: flex; flex-direction: column; margin: 0; }
.pr-grid > .xchart { margin: 0; }
.pr-overview .panel-title { display: flex; align-items: center; gap: .5rem; }
.pr-overview .panel-title > .ph { color: var(--text-3); font-size: 1.1rem; }

/* Cartes de la vue d'ensemble : 8 cartes = 2 rangées de 4 (ordinateur), 1 rangée (très grand écran), 2 colonnes (téléphone : grille du socle) */
@media (min-width: 1024px) { .stat-links.pr-stats { grid-template-columns: repeat(4, minmax(0, 1fr)); } }
@media (min-width: 2200px) { .stat-links.pr-stats { grid-template-columns: repeat(8, minmax(0, 1fr)); } }

/* Chiffres clés d'un panneau */
.pr-figures { display: grid; grid-template-columns: repeat(auto-fit, minmax(120px, 1fr)); gap: .6rem; }
.pr-figure { display: flex; flex-direction: column; gap: .15rem; padding: .7rem .8rem; border-radius: var(--r-control, 9px); background: var(--bg-sunken); color: var(--text); text-decoration: none; min-width: 0; }
a.pr-figure { transition: background .15s, box-shadow .15s; }
a.pr-figure:hover { background: var(--bg-hover); box-shadow: inset 0 0 0 1px var(--line-strong); text-decoration: none; }
.pr-figure-label { font-size: .76rem; color: var(--text-2); line-height: 1.25; }
.pr-figure-value { font-size: 1.35rem; font-weight: 750; line-height: 1.15; letter-spacing: -.01em; }
.pr-figure-value small { font-size: .78rem; font-weight: 600; color: var(--text-2); }
.pr-figure-value.is-empty { color: var(--text-3); }
.pr-figure-foot { font-size: .74rem; color: var(--text-3); line-height: 1.3; }

/* Barres horizontales cliquables (volumes par fournisseur, famille, lieu) */
.pr-bars { display: flex; flex-direction: column; padding: .35rem .5rem .6rem; overflow: auto; max-height: 21rem; scrollbar-width: thin; }
.pr-bar { display: grid; grid-template-columns: minmax(0, 1fr) auto auto; align-items: center; column-gap: .75rem; row-gap: .3rem; padding: .5rem .6rem; border-radius: var(--r-control, 9px); color: var(--text); text-decoration: none; min-height: var(--tap, 44px); }
.pr-bar:hover { background: var(--bg-hover); text-decoration: none; }
.pr-bar-label { display: flex; align-items: center; gap: .45rem; font-weight: 620; font-size: .9rem; min-width: 0; }
.pr-bar-label > .ph { color: var(--text-3); font-size: 1.05rem; flex-shrink: 0; }
.pr-bar-label > b { font-weight: 700; }
.pr-bar-meta { font-size: .76rem; color: var(--text-3); white-space: nowrap; }
.pr-bar-value { font-weight: 750; font-size: .95rem; white-space: nowrap; text-align: right; min-width: 3.2rem; }
.pr-bar-value small { font-weight: 600; font-size: .7rem; color: var(--text-3); }
.pr-bar-track { grid-column: 1 / -1; height: 5px; border-radius: 99px; background: var(--bg-sunken); overflow: hidden; }
.pr-bar-track > i { display: block; height: 100%; width: var(--w, 0%); min-width: 3px; border-radius: inherit; background: var(--brand); }
.pr-bar.is-muted .pr-bar-track > i { background: var(--text-3); }
.pr-bar.is-muted .pr-bar-label { color: var(--text-2); font-weight: 560; }

.pr-rows { display: flex; flex-direction: column; padding: .25rem .4rem .5rem; min-width: 0; }
.pr-rows .list-row { border-radius: var(--r-control, 9px); min-width: 0; }
.pr-rows .list-row > .grow { min-width: 0; overflow: hidden; }
.pr-rows .list-row-title, .pr-rows .list-row-sub { display: block; max-width: 100%; }
.pr-rows .list-row > .badge { flex-shrink: 0; }

/* Mention « historique repris » */
.pr-legacy { max-width: none; width: 100%; font-size: .87rem; color: var(--text-2); background: var(--bg-sunken); border-style: dashed; }
.pr-legacy > .ph { color: var(--text-3); }
.pr-legacy b, .pr-legacy .notice-title { color: var(--text); }
.pr-legacy ul { display: grid; gap: .25rem; }
.pr-legacy.is-inline { padding: .6rem .85rem; }

/* Listes */
.pr-cell-title { max-width: 30rem; min-width: 12rem; }
.pr-ratio { display: inline-flex; align-items: baseline; gap: .3rem; }
.pr-mini-progress { display: block; height: 4px; border-radius: 99px; background: var(--bg-sunken); overflow: hidden; margin-top: .3rem; min-width: 5rem; }
.pr-mini-progress > i { display: block; height: 100%; width: var(--w, 0%); background: var(--success-strong, var(--success)); border-radius: inherit; }
.pr-mini-progress.is-partial > i { background: var(--c-amber-strong, var(--warning)); }

/* Fiche : résumé en tête */
.pr-summary { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: .6rem; }
.pr-fact { display: flex; flex-direction: column; gap: .15rem; padding: .65rem .8rem; border: 1px solid var(--line); border-radius: var(--r-control, 9px); background: var(--bg-elev); min-width: 0; color: var(--text); text-decoration: none; }
a.pr-fact:hover { border-color: var(--line-strong); background: var(--bg-hover); text-decoration: none; }
.pr-fact-label { display: flex; align-items: center; gap: .35rem; font-size: .74rem; color: var(--text-2); }
.pr-fact-label > .ph { font-size: .95rem; color: var(--text-3); }
.pr-fact-value { font-weight: 700; font-size: .98rem; line-height: 1.25; overflow-wrap: anywhere; }
.pr-fact-value.is-empty { color: var(--text-3); font-weight: 560; }
.pr-fact-sub { font-size: .76rem; color: var(--text-3); }

.pr-notes { white-space: pre-line; font-size: .88rem; color: var(--text-2); overflow-wrap: anywhere; }
.pr-doc { display: flex; align-items: center; gap: .7rem; padding: .6rem .75rem; border: 1px solid var(--line); border-radius: var(--r-control, 9px); min-width: 0; }
.pr-doc > .icon-box { flex-shrink: 0; }
.pr-doc-name { font-weight: 620; font-size: .88rem; overflow-wrap: anywhere; }
.pr-doc-sub { display: block; font-size: .76rem; color: var(--text-3); }
.pr-doc-name { display: block; }
.table tr.pr-row-off > td { opacity: .55; }
.pr-nowrap { white-space: nowrap; }
.pr-docs { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 280px), 1fr)); gap: .6rem; }

/* Formulaire de PO : lignes */
.pr-lines { display: flex; flex-direction: column; gap: .6rem; }
.pr-line { display: grid; grid-template-columns: minmax(0, 2.4fr) minmax(0, 1.6fr) 7rem 8rem 2.75rem; gap: .6rem; align-items: start; padding: .7rem; border: 1px solid var(--line); border-radius: var(--r-control, 9px); background: var(--bg-elev); }
.pr-line.is-locked { background: var(--bg-sunken); }
.pr-line .field { margin: 0; }
.pr-line > * { min-width: 0; }
.pr-line .input { min-width: 0; width: 100%; }
.pr-lines { min-width: 0; max-width: 100%; }
.pr-line-head { display: grid; grid-template-columns: minmax(0, 2.4fr) minmax(0, 1.6fr) 7rem 8rem 2.75rem; gap: .6rem; padding: 0 .7rem; font-size: .74rem; font-weight: 650; color: var(--text-2); text-transform: uppercase; letter-spacing: .03em; }
.pr-line-label { display: none; font-size: .74rem; font-weight: 650; color: var(--text-2); margin-bottom: .2rem; }
.pr-line-hint { font-size: .74rem; color: var(--text-3); margin-top: .25rem; display: flex; align-items: center; gap: .3rem; }
@media (max-width: 900px) {
  .pr-line-head { display: none; }
  .pr-line { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) 2.75rem; }
  .pr-line > .pr-line-item, .pr-line > .pr-line-desc { grid-column: 1 / -1; }
  .pr-line-label { display: block; }
}

/* Recherche d'article (autocomplétion) */
.pr-pick { position: relative; }
.pr-pick-menu { position: absolute; z-index: 40; left: 0; right: 0; top: calc(100% + 4px); max-height: 17rem; overflow: auto; padding: .3rem; border: 1px solid var(--line-strong); border-radius: var(--r-control, 9px); background: var(--bg-elev); box-shadow: var(--shadow-3, 0 12px 32px rgb(0 0 0 / .18)); }
.pr-pick-option { display: flex; flex-direction: column; gap: .1rem; width: 100%; padding: .5rem .6rem; border: 0; border-radius: 7px; background: transparent; color: var(--text); text-align: left; cursor: pointer; min-height: var(--tap, 44px); justify-content: center; }
.pr-pick-option:hover, .pr-pick-option.is-active { background: var(--bg-hover); }
.pr-pick-option b { font-weight: 650; font-size: .88rem; }
.pr-pick-option span { font-size: .76rem; color: var(--text-3); }
.pr-pick-empty { padding: .7rem; font-size: .84rem; color: var(--text-3); }
.pr-pick-chosen { display: flex; align-items: center; gap: .5rem; padding: .45rem .55rem .45rem .7rem; border: 1px solid var(--line); border-radius: var(--r-control, 9px); background: var(--bg-sunken); min-height: 2.6rem; }
.pr-pick-chosen > span { flex: 1; min-width: 0; font-weight: 620; font-size: .88rem; overflow-wrap: anywhere; }

/* Réception d'une livraison : une carte par ligne */
.pr-rx { display: flex; flex-direction: column; gap: .7rem; }
.pr-rx-line { border: 1px solid var(--line); border-radius: var(--r-panel, 14px); background: var(--bg-elev); overflow: hidden; }
.pr-rx-line.is-done { background: var(--bg-sunken); }
.pr-rx-head { display: flex; align-items: center; gap: .75rem; padding: .7rem .9rem; flex-wrap: wrap; }
.pr-rx-title { flex: 1 1 14rem; min-width: 0; }
.pr-rx-title b { display: block; font-weight: 680; font-size: .93rem; overflow-wrap: anywhere; }
.pr-rx-title span { font-size: .78rem; color: var(--text-3); }
.pr-rx-nums { display: flex; gap: 1.1rem; align-items: center; flex-wrap: wrap; }
.pr-rx-num { display: flex; flex-direction: column; align-items: flex-end; gap: .05rem; min-width: 3.4rem; }
.pr-rx-num small { font-size: .68rem; color: var(--text-3); text-transform: uppercase; letter-spacing: .04em; }
.pr-rx-num b { font-size: 1.05rem; font-weight: 750; }
.pr-rx-body { display: grid; grid-template-columns: 9rem 12rem minmax(0, 1fr); gap: .7rem; padding: .75rem .9rem .85rem; border-top: 1px solid var(--line); align-items: start; }
.pr-rx-body .field { margin: 0; }
.pr-rx-serials textarea { font-family: var(--font-mono, ui-monospace, SFMono-Regular, Menlo, monospace); font-size: .84rem; min-height: 5.2rem; }
.pr-rx-count { display: inline-flex; align-items: center; gap: .3rem; font-size: .76rem; font-weight: 650; }
.pr-rx-count.is-ok { color: var(--success); }
.pr-rx-count.is-bad { color: var(--danger); }
@media (max-width: 820px) {
  .pr-rx-body { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }
  .pr-rx-body > .pr-rx-wide { grid-column: 1 / -1; }
  .pr-rx-nums { width: 100%; justify-content: space-between; }
  .pr-rx-num { align-items: flex-start; }
}

/* Besoins : quantité à commander dans la liste des suggestions */
.pr-qty-input { width: 5.5rem; text-align: right; }
.pr-cover { display: inline-flex; align-items: center; gap: .45rem; min-width: 7.5rem; }
.pr-cover > .pr-mini-progress { flex: 1; margin: 0; }
.pr-cover.is-low > .pr-mini-progress > i { background: var(--danger); }
.pr-cover.is-mid > .pr-mini-progress > i { background: var(--c-amber-strong, var(--warning)); }

.pr-nav .count { font-variant-numeric: tabular-nums; }
.pr-actions-form { display: inline-flex; }
@media (max-width: 767px) {
  .pr-bars { max-height: none; }
  .pr-fact-value { font-size: .92rem; }
  .pr-summary { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

/* Formulaires pleine page sur téléphone : la barre d'actions collante ne doit pas élargir la page */
@media (max-width: 767px) { .pr-form { max-width: 100%; overflow-x: clip; } }
