/* ==========================================================================
   barcodes_print.css — Pour fenêtre impression dédiée
   ========================================================================== */

@media print {
  @page { size: A4; margin: 0mm; }

  body {
    margin: 0 !important;
    padding: 0 !important;
    background: #fff !important;
  }

  .lg-sheet-page {
    display: grid !important;
    grid-template-columns: repeat(var(--lg-cols), var(--lg-wmm));
    grid-auto-rows: var(--lg-hmm);
    gap: var(--lg-gapmm);
    width: calc(var(--lg-cols) * var(--lg-wmm) + (var(--lg-cols) - 1) * var(--lg-gapmm));
    margin: 0 auto !important;
    page-break-after: always;
    page-break-inside: avoid;
  }

  .lg-sheet-page:last-child {
    page-break-after: auto !important;
  }

  .lg-sheet-label {
    position: relative;
    padding: 2mm;
    background: #fff;
    break-inside: avoid;
  }

  /* Repères découpe */
  .lg-sheet-label::before {
    content: "";
    position: absolute;
    inset: -1mm;
    pointer-events: none;
    background:
      linear-gradient(#000,#000) left top / 3mm 0.3pt no-repeat,
      linear-gradient(#000,#000) left top / 0.3pt 3mm no-repeat,
      linear-gradient(#000,#000) right top / 3mm 0.3pt no-repeat,
      linear-gradient(#000,#000) right top / 0.3pt 3mm no-repeat,
      linear-gradient(#000,#000) left bottom / 3mm 0.3pt no-repeat,
      linear-gradient(#000,#000) left bottom / 0.3pt 3mm no-repeat,
      linear-gradient(#000,#000) right bottom / 3mm 0.3pt no-repeat,
      linear-gradient(#000,#000) right bottom / 0.3pt 3mm no-repeat;
  }

  .lg-sheet-label::after {
    content: "";
    position: absolute;
    inset: 0.5mm;
    border: 0.5pt dashed #ccc;
    pointer-events: none;
  }

  /* Layout image + code */
  .lg-label-row {
    display: flex !important;
    align-items: flex-start !important;
    gap: 2mm;
    height: 100%;
  }

  .lg-label-img {
    width: 16mm !important;
    height: 16mm !important;
    flex-shrink: 0;
    object-fit: contain;
    border: 0.3pt solid #ddd;
    border-radius: 1mm;
  }

  .lg-label-body {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 0.5mm;
  }

  .lg-label-name {
    font-size: 7pt !important;
    font-weight: 700;
    line-height: 1.1;
    margin: 0 0 0.5mm 0;
    order: 1;
  }

  .lg-label-sku {
    font-family: 'Courier New', monospace !important;
    font-size: 6pt !important;
    color: #666;
    margin: 0 0 0.5mm 0;
    order: 2;
  }

  .lg-bc-wrap {
    width: 100%;
    order: 3;
  }

  .lg-bc-wrap canvas {
    width: 100% !important;
    height: auto !important;
    max-height: 10mm !important;
    display: block !important;
  }

  .lg-label-code {
    font-family: 'Courier New', monospace !important;
    font-size: 6pt !important;
    color: #333;
    text-align: center;
    margin: 0.5mm 0 0 0;
    order: 4;
  }

  /* Autres styles */
  .lg-label-barcode-only {
    display: flex !important;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 100%;
  }

  .lg-label-qr {
    display: flex !important;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 100%;
  }

  .lg-label-qr img {
    width: 18mm !important;
    height: 18mm !important;
  }

  .lg-label-full {
    display: flex !important;
    flex-direction: column;
    height: 100%;
  }


/* Nouvelle structure iframe: .lg-page + .lg-plabel */
.lg-page{
  display: grid !important;
  grid-template-columns: repeat(var(--lg-cols), var(--lg-wmm));
  grid-auto-rows: var(--lg-hmm);
  gap: var(--lg-gapmm);
  justify-content: center;
  align-content: start;
  width: 210mm;
  min-height: 297mm;
  margin: 0 auto !important;
  padding: 0 !important;
  break-after: page;
}
.lg-page:last-child{ break-after: auto; }

.lg-plabel{
  position: relative;
  padding: 2mm;
  background: #fff;
  box-sizing: border-box;
  overflow: hidden;
  break-inside: avoid;
}

/* Repères découpe sur la nouvelle structure */
.lg-plabel::before{
  content:"";
  position:absolute;
  inset:-1mm;
  pointer-events:none;
  background:
    linear-gradient(#000,#000) left top / 3mm 0.3pt no-repeat,
    linear-gradient(#000,#000) left top / 0.3pt 3mm no-repeat,
    linear-gradient(#000,#000) right top / 3mm 0.3pt no-repeat,
    linear-gradient(#000,#000) right top / 0.3pt 3mm no-repeat,
    linear-gradient(#000,#000) left bottom / 3mm 0.3pt no-repeat,
    linear-gradient(#000,#000) left bottom / 0.3pt 3mm no-repeat,
    linear-gradient(#000,#000) right bottom / 3mm 0.3pt no-repeat,
    linear-gradient(#000,#000) right bottom / 0.3pt 3mm no-repeat;
}

.lg-plabel::after{
  content:"";
  position:absolute;
  inset:0.5mm;
  border:0.5pt dashed #ccc;
  pointer-events:none;
}

.lg-row{
  display:flex !important;
  align-items:flex-start;
  gap:2mm;
  height:100%;
}
.lg-imgbox{ width:16mm; height:16mm; flex:0 0 16mm; }
.lg-img, .lg-noimg{
  width:16mm; height:16mm;
  object-fit:contain;
  border:0.3pt solid #ddd;
  border-radius:1mm;
  display:block;
}
.lg-noimg{ background:#f4f4f4; }

.lg-bcbox{ flex:1; min-width:0; }
.lg-bc svg{ width:100% !important; height:10mm !important; display:block; }
.lg-bctxt{
  font-family:'Courier New', monospace !important;
  font-size:6pt !important;
  text-align:center;
  margin-top:0.8mm;
}
.lg-meta{ margin-top:1mm; }
.lg-name{ font-size:7pt; font-weight:700; line-height:1.1; }
.lg-sku{ font-size:6pt; color:#666; }

}

/* Écran */
@media screen {
  body {
    background: #f5f5f5;
    padding: 20px;
  }
  
  .lg-sheet-page {
    background: #fff;
    box-shadow: 0 4px 12px rgba(0,0,0,0.1);
    margin: 0 auto 20px;
    padding: 10mm;
    max-width: 210mm;
  }
}
