/* Page « Bon de livraison » (chargée après style.css, uniquement sur cette page).
   Écran : mise en page empilée sur mobile ; impression : portrait Lettre, cadres proches du gabarit papier. */

[hidden]{display:none!important}
.bon-page{padding:28px 0 56px;background:var(--bg-alt)}
.bon-wrap{max-width:920px}
.bon-intro{margin-bottom:18px}
.bon-lead{font-size:1.15rem;font-weight:600;color:var(--navy);margin:0 0 .5em}
.bon-privacy{background:#fff;border-left:4px solid var(--blue-strong);padding:.7em 1em;border-radius:8px;margin:0 0 1em}
.bon-actions{display:flex;flex-direction:column;gap:10px;margin:0}
.bon-actions .btn{width:100%}
.bon-actions-end{margin-top:18px}
.bon-hint{margin:.8em 0 0;color:var(--muted);font-size:.95rem}
.bon-result{margin:12px 0 0;padding:.8em 1em;background:#fff;border:1px solid var(--line);border-left:4px solid var(--blue-strong);border-radius:8px}
.bon-result p{margin:0}
.bon-result.is-ok{border-left-color:#1b7f3b}
.bon-result.is-error{border-left-color:#b3261e;color:#7a1712}
.bon-result-actions{display:flex;flex-direction:column;gap:10px;margin-top:10px!important}
.bon-result-actions .btn{width:100%}
.btn-ghost-dark{background:#fff;color:var(--blue-strong);border-color:var(--blue-strong)}
.btn-ghost-dark:hover{background:var(--blue-strong);color:#fff}
.btn:disabled{opacity:.5;cursor:not-allowed}

/* Feuille */
.bon-sheet{background:#fff;border:1px solid var(--line);border-radius:var(--radius);box-shadow:0 14px 40px rgba(11,31,58,.1);padding:20px 16px}
.bon-head{display:grid;gap:12px;padding-bottom:16px;border-bottom:2px solid var(--navy);margin-bottom:18px}
.bon-logo{display:block;line-height:0}
.bon-logo img{width:210px;max-width:100%;height:auto}
.bon-name{font:italic 800 1.5rem/1.1 var(--display);text-transform:uppercase;color:var(--navy);margin:0 0 .25em}
.bon-contact,.bon-nir{margin:0;font-size:.95rem}
.bon-contact a{white-space:nowrap}
.bon-contact>span:not(.sep){white-space:nowrap}
.bon-title{margin:0;font-size:clamp(2.1rem,7vw,2.8rem);text-transform:uppercase}

.bon-block{margin-bottom:18px}
.bon-block h2{font-size:1.3rem;letter-spacing:.03em;margin:0 0 .6em;padding:.3em .7em;background:var(--navy);color:#fff;border-radius:6px}
.bon-block h2::after{display:none}
.bon-ident{display:grid;gap:0 18px;margin-bottom:4px}
.fld{margin-bottom:14px;min-width:0}
.pv{display:none}

/* Date : Safari/iOS dessine son propre contrôle sans ces réglages */
input[type=date]{-webkit-appearance:none;appearance:none;display:block;width:100%;min-width:0;font:inherit;font-size:max(16px,1rem);color:var(--ink);background:#fff;border:1.5px solid #8a9bb3;border-radius:10px;padding:.7em .85em;min-height:50px}
input[type=date]::-webkit-date-and-time-value{text-align:left;min-height:1.4em}
input[type=date]:focus{border-color:var(--blue-strong);box-shadow:0 0 0 3px rgba(30,115,232,.25);outline:none}

/* Tableau des marchandises : empilé sur mobile (une carte par ligne) */
.bon-lines{width:100%;border-collapse:collapse}
.bon-lines .ctl{min-height:44px}
.bon-lines textarea.ctl{min-height:64px}
.bon-lines .fld{margin:0}
.row-del{font-weight:700;font-size:.95rem;color:#b3261e;text-decoration:underline;min-height:44px;padding:0 .5em;white-space:nowrap}
.row-del:disabled{color:#6b7a90;text-decoration:none;cursor:not-allowed}
.bon-add{margin:12px 0 0}

/* Réception : lignes vides, à remplir à la main */
.bon-recv-note{margin:0 0 .6em;color:var(--muted);font-size:.95rem}
.recv-grid{display:grid;gap:6px}
.recv-line{display:flex;align-items:flex-end;gap:10px;margin:0;min-height:52px}
.recv-label{font-weight:700;color:var(--navy);flex:0 0 auto}
.recv-blank{flex:1 1 auto;min-width:40px;border-bottom:1.5px solid #8a9bb3;height:1.6em}

/* ---------- Écran : mobile (< 720 px), tableau en cartes ---------- */
@media screen and (max-width:719px){
  .bon-lines thead{position:absolute;width:1px;height:1px;overflow:hidden;clip:rect(0 0 0 0)}
  .bon-lines,.bon-lines tbody,.bon-lines tr,.bon-lines td{display:block}
  .bon-lines tr{border:1px solid var(--line);border-radius:10px;padding:10px 12px;margin-bottom:12px;background:#fafcff}
  .bon-lines td{padding:0 0 8px}
  .bon-lines td[data-label]::before{content:attr(data-label);display:block;font-weight:600;color:var(--navy);margin:0 0 .25em}
  .bon-lines td.n{font-weight:800;color:var(--navy)}
  .bon-lines td.n::before{display:inline;margin:0 .35em 0 0}
  .bon-lines td.act{padding-bottom:0}
}

/* ---------- Écran : tablette et bureau ---------- */
@media screen and (min-width:640px){
  .bon-sheet{padding:28px 28px}
  .bon-actions{flex-direction:row;flex-wrap:wrap}
  .bon-actions .btn,.bon-result-actions .btn{width:auto}
  .bon-result-actions{flex-direction:row;flex-wrap:wrap}
  .bon-ident{grid-template-columns:1fr 1fr}
  .f-wide{grid-column:1/-1}
}
@media screen and (min-width:720px){
  .bon-head{grid-template-columns:auto 1fr auto;align-items:center;gap:18px}
  .bon-cols{display:grid;grid-template-columns:1fr 1fr;gap:0 22px}
  .bon-lines th{background:var(--bg-alt);color:var(--navy);text-align:left;padding:.5em .6em;border:1px solid var(--line);font-size:.95rem}
  .bon-lines td{padding:6px;border:1px solid var(--line);vertical-align:top}
  .bon-lines th.n,.bon-lines td.n{width:48px;text-align:center;font-weight:800;color:var(--navy)}
  .bon-lines td.act{width:1%;white-space:nowrap}
}
@media screen and (min-width:900px){
  .bon-ident{grid-template-columns:repeat(4,1fr)}
}

/* ---------- Impression : portrait Lettre ---------- */
@page{size:letter portrait;margin:.5in}
@media print{
  html,body{background:#fff!important;color:#000;font-size:10pt;line-height:1.3}
  .no-print,.site-header,.site-footer,.skip,.fab-call,.sprite{display:none!important}
  .bon-page{padding:0;background:#fff}
  .wrap,.bon-wrap{max-width:none;padding:0}
  .bon-sheet{border:0;box-shadow:none;border-radius:0;padding:0;margin:0}
  a{color:#000;text-decoration:none}
  h1,h2{color:#000}

  .bon-head{display:grid;grid-template-columns:auto 1fr auto;gap:12pt;align-items:center;border:1.2pt solid #000;padding:8pt 10pt;margin:0 0 8pt}
  .bon-logo img{width:1.55in}
  .bon-name{font-size:14pt;color:#000;margin:0 0 2pt}
  .bon-contact,.bon-nir{font-size:9.5pt}
  .bon-title{font-size:21pt;color:#000;text-align:right}

  .bon-block{margin:0 0 8pt;break-inside:avoid;page-break-inside:avoid}
  .bon-block h2{background:none;color:#000;border:0;border-bottom:1pt solid #000;border-radius:0;padding:0 0 1pt;margin:0 0 4pt;font-size:10.5pt;letter-spacing:.03em}

  .bon-ident{display:grid;grid-template-columns:repeat(4,1fr);gap:0;border:1pt solid #000;margin:0 0 8pt}
  .bon-ident .fld{margin:0;padding:3pt 5pt;border-right:1pt solid #000;min-height:.5in}
  .bon-ident .fld:nth-child(5){border-right:0}
  .bon-ident .f-wide{grid-column:1/-1;border-right:0;border-bottom:1pt solid #000;min-height:.9in}
  .bon-ident .fld:last-child{border-right:0}

  .bon-cols{display:grid;grid-template-columns:1fr 1fr;gap:8pt;margin:0 0 8pt}
  .bon-cols .bon-block{border:1pt solid #000;padding:4pt 6pt;margin:0}
  .bon-cols .fld{margin:0 0 4pt}

  .fld label{display:block;margin:0;font-size:7.5pt;font-weight:700;text-transform:uppercase;letter-spacing:.03em;color:#000}
  html.js .fld .ctl{display:none!important}
  html.js .fld .pv{display:block;white-space:pre-wrap;overflow-wrap:anywhere;min-height:1.3em;font-size:10pt;color:#000}
  .bon-cols .fld .pv{min-height:.55in}
  .bon-cols .bon-block:nth-of-type(1) .fld:first-of-type .pv{min-height:.7in}

  .bon-lines{display:table;width:100%;border-collapse:collapse;table-layout:fixed}
  .bon-lines thead{display:table-header-group}
  .bon-lines tbody{display:table-row-group}
  .bon-lines tr{display:table-row;break-inside:avoid;page-break-inside:avoid}
  .bon-lines th,.bon-lines td{display:table-cell;border:1pt solid #000;padding:2pt 4pt;vertical-align:top;text-align:left;font-size:9.5pt}
  .bon-lines th{font-size:8.5pt;text-transform:uppercase;background:#eee;-webkit-print-color-adjust:exact;print-color-adjust:exact}
  .bon-lines td{height:.34in}
  .bon-lines th.n,.bon-lines td.n{width:.35in;text-align:center;font-weight:700}
  .bon-lines th:nth-child(2){width:.9in}
  .bon-lines th:nth-child(4),.bon-lines th:nth-child(5){width:1in}
  .bon-lines td::before{display:none!important}
  .bon-lines .fld{margin:0;padding:0;border:0;min-height:0}
  .bon-lines .pv{min-height:0;font-size:9.5pt}
  .bon-lines tr{background:none;border:0;padding:0;margin:0}

  .bon-recv{border:1pt solid #000;padding:6pt 8pt;margin:0;break-inside:avoid;page-break-inside:avoid}
  .recv-grid{display:grid;grid-template-columns:1fr;gap:0}
  .recv-line{display:flex;align-items:flex-end;gap:6pt;margin:0;min-height:.45in}
  .recv-label{color:#000;font-size:10pt}
  .recv-blank{flex:1;border-bottom:1pt solid #000;height:1.2em}
}

.bon-send{margin-top:28px;padding:1.1em 1.2em;background:#fff;border:1px solid var(--line);border-left:4px solid var(--blue-strong);border-radius:8px}
.bon-send h2{margin:0 0 .4em;font-size:1.2rem}
.bon-send p{margin:0 0 .9em}
.bon-send .consent{margin-bottom:1em}
.bon-send .btn{width:100%}
.bon-send-status{margin:.9em 0 0!important;font-weight:600}
.bon-send-status.is-ok{color:#1b7f3b}
.bon-send-status.is-error{color:#7a1712}
@media (min-width:640px){.bon-send .btn{width:auto}}
@media print{.bon-send{display:none!important}}
