/* ============================================================
   etiquettes.css — Styles spécifiques au module Étiquettes
   Copie chirurgicale du prototype Etiquettes v0.16, ré-namespacée
   `et-*` pour ne pas heurter les styles du plan de tir (`pt-*`).
   Charte ERP (variables CSS, btn-*, modal-*) reste fournie par
   style.css + style-erp.css + conception.css.
   ============================================================ */

/* ── Police Oswald : portée au module étiquettes uniquement ── */
#s-etiquettes { font-family: 'Oswald', 'DM Sans', Arial, sans-serif; }

/* ── BARRE D'OPTIONS (filtres / tri / cache) ──────────────── */
.et-optbar {
  padding: 9px 24px;
  display: flex;
  align-items: center;
  gap: 16px;
  flex-wrap: wrap;
  background: #f4f5f7;
  border-bottom: 1px solid var(--border, #d6d9e0);
  flex-shrink: 0;
  margin-bottom: 12px;
  border-radius: 8px;
}
.et-opt-grp { display: flex; align-items: center; gap: 11px; flex-wrap: wrap; }
.et-opt-grp.right { margin-left: auto; }
.et-opt-dd { position: relative; }
.et-opt-dd > summary {
  list-style: none; cursor: pointer; font-size: 12px; color: #2b2f38;
  border: 1.5px solid var(--border, #c4c8d0); border-radius: 7px;
  padding: 7px 12px; background: #fff; user-select: none; white-space: nowrap;
}
.et-opt-dd > summary::-webkit-details-marker { display: none; }
.et-opt-dd[open] > summary { border-color: var(--navy, #33485f); background: #eef0f3; }
.et-opt-dd > summary b { font-weight: 700; }
.et-opt-pop {
  position: absolute; top: calc(100% + 4px); left: 0; z-index: 30;
  background: #fff; border: 1.5px solid var(--border, #c4c8d0);
  border-radius: 8px; padding: 8px;
  box-shadow: 0 6px 20px rgba(0, 0, 0, .18);
  min-width: 170px; max-height: 300px; overflow: auto;
}
.et-opt-pop label {
  display: flex; align-items: center; gap: 7px;
  font-size: 12px; color: #333;
  padding: 3px 4px; cursor: pointer; white-space: nowrap; border-radius: 4px;
}
.et-opt-pop label:hover { background: #f0f1f4; }
.et-opt-pop-act {
  display: flex; gap: 12px;
  border-bottom: 1px solid #e3e5ea;
  padding: 0 4px 6px; margin-bottom: 4px;
}
.et-opt-pop-act a {
  font-size: 11px; color: var(--navy, #33485f);
  cursor: pointer; text-decoration: underline; font-weight: 600;
}
.et-opt-sort { font-size: 12px; color: #2b2f38; display: flex; align-items: center; gap: 6px; white-space: nowrap; }
.et-opt-sort select {
  font-family: inherit; font-size: 12px; padding: 6px 8px;
  border: 1.5px solid var(--border, #c4c8d0); border-radius: 7px;
  background: #fff; color: #2b2f38; cursor: pointer;
}
.et-opt-count { font-size: 12px; color: #444; font-weight: 700; white-space: nowrap; }
.et-opt-hist { font-size: 11.5px; color: #888; white-space: nowrap; }
.et-opt-clear { padding: 5px 10px; font-size: 10px; }

/* ── PREVIEW : planche A4 + bandeau ───────────────────────── */
.et-preview {
  flex: 1; overflow: auto;
  background: #5b6273; padding: 24px;
  display: flex; flex-direction: column; align-items: center; gap: 20px;
  border-radius: 12px;
}
.et-empty {
  margin: auto; color: #cfd3dc; font-size: 14px;
  text-transform: uppercase; letter-spacing: 1px; font-weight: 500;
}

/* ── BANDEAU DE CONTRÔLE DE COHÉRENCE (écran seulement) ───── */
.et-ctrl {
  width: 205mm; max-width: 100%;
  background: #fff; border-radius: 8px; flex-shrink: 0;
  padding: 13px 18px;
  box-shadow: 0 2px 12px rgba(0, 0, 0, .22);
  border-left: 5px solid #188038;
}
.et-ctrl.warn { border-left-color: #d93025; }
.et-ctrl-verdict { font-weight: 700; font-size: 14px; color: #188038; }
.et-ctrl.warn .et-ctrl-verdict { color: #d93025; }
.et-ctrl-line { font-size: 12.5px; color: #333; margin-top: 5px; }
.et-ctrl-line b { font-weight: 700; }
.et-ctrl-sec { margin-top: 9px; }
.et-ctrl-sec-t {
  font-size: 11px; font-weight: 600; color: #666;
  text-transform: uppercase; letter-spacing: .5px; margin-bottom: 3px;
}
.et-ctrl-list { list-style: none; font-size: 11.5px; color: #555; max-height: 150px; overflow: auto; }
.et-ctrl-list li { padding: 1.5px 0; border-bottom: 1px solid #f0f0f2; }
.et-ctrl-list li b { color: #d93025; font-weight: 700; }

/* ── PLANCHE A4 — gabarit Agipa 119015 ──────────────────────
   A4 portrait 210×297 ; marges Ricoh 3/3/2/2 mm ;
   zone imprimable 205×292 → grille 3×8 (68.333 × 36.5 mm). ── */
.et-page {
  width: 210mm; height: 297mm; background: #fff; flex-shrink: 0;
  box-shadow: 0 4px 22px rgba(0, 0, 0, .35);
  padding: 3mm 3mm 2mm 2mm;
}
.et-grid {
  width: 205mm; height: 292mm;
  display: grid;
  grid-template-columns: repeat(3, 68.333mm);
  grid-template-rows: repeat(8, 36.5mm);
}

/* ── ÉTIQUETTE — grille 6 lignes × 5 colonnes (etiquette_spec_v4) ──
   colonnes : cc+0 6.13 / cc+1..4 8.43 (unités Sheets)
   lignes   : rr+0..3 15.75pt / rr+4 13.5pt / rr+5 10.5pt        */
.etq { padding: 1.5mm; }
.etq-in {
  height: 100%; display: grid; background: #fff; overflow: hidden;
  grid-template-columns: 6.13fr 8.43fr 8.43fr 8.43fr 8.43fr;
  grid-template-rows: 15.75fr 15.75fr 15.75fr 15.75fr 13.5fr 10.5fr;
}
.etq-in > div { background: #fff; overflow: hidden; display: flex; align-items: center; }
.etq-in.qc { outline: .5mm solid #d93025; outline-offset: -.5mm; }

/* rr+0 SpecBB (cc+0..2) — bleu clair, rouge si Batterie EVT */
.c-bb {
  grid-column: 1/4; grid-row: 1/2; background: #cfe2f3 !important;
  padding: 0 1.3mm; font-size: 11pt; font-weight: 400; color: #000;
  white-space: nowrap; text-overflow: ellipsis;
}
.c-bb.evt { color: #d93025; }
/* rr+1 SpecFinal (cc+0..2) */
.c-sf {
  grid-column: 1/4; grid-row: 2/3; background: #cfe2f3 !important;
  padding: 0 1.3mm; font-size: 11pt; font-weight: 400; color: #000;
  white-space: nowrap; text-overflow: ellipsis;
}
.c-sf .sf-g { color: #d93025; }
.c-sf .sf-d { color: #188038; }
.c-sf.alert { color: #d93025; }
/* rr+0..1 Angle (cc+3..4 fusionné 2L×2C) */
.c-ang {
  grid-column: 4/6; grid-row: 1/3;
  justify-content: center; text-align: center;
  padding: 0 1mm; font-size: 12pt; font-weight: 700; color: #000; line-height: 1.2;
}
.c-ang.multi { font-size: 9pt; }
.ang-neg { color: #d93025; }
.ang-pos { color: #188038; }

/* rr+2..3 — NUMÉRO PRINCIPAL (cc+0 Module / cc+1 Rail / cc+2 Pin / cc+3..4 Poste) */
.c-mod {
  grid-column: 1/2; grid-row: 3/5;
  justify-content: center; font-size: 26pt; font-weight: 700; color: #9bbb59; line-height: 1;
}
.c-rail {
  grid-column: 2/3; grid-row: 3/5;
  justify-content: center; font-size: 28pt; font-weight: 700; color: #ff0000; line-height: 1;
}
.c-pin {
  grid-column: 3/4; grid-row: 3/5;
  justify-content: flex-start; padding: 0 0 0 1.5mm;
  font-size: 28pt; font-weight: 700; color: #000; line-height: 1;
}
.c-poste {
  grid-column: 4/6; grid-row: 3/5;
  justify-content: center; background: #cfe2f3 !important;
  font-size: 28pt; font-weight: 700; color: #000; line-height: 1;
}
.c-mod.pont, .c-rail.pont, .c-pin.pont { background: #f9ab00 !important; }

/* rr+4 — Désignation (cc+0..2) + Effet/Réf (cc+3..4) */
.c-des { grid-column: 1/4; grid-row: 5/6; padding: 0 1.3mm; font-size: 6pt; font-weight: 400; color: #000; }
.c-eff { grid-column: 4/6; grid-row: 5/6; padding: 0 1.3mm; font-size: 6pt; font-style: italic; font-weight: 400; color: #000; }
.c-des .txt, .c-eff .txt {
  width: 100%; line-height: 1.2; max-height: 2.4em;
  display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 2;
  overflow: hidden; overflow-wrap: anywhere;
}
.c-des b { color: #d93025; font-weight: 700; }

/* rr+5 — Ville (cc+0..1) + Date (cc+2) + InflLabel (cc+3..4) */
.c-ville {
  grid-column: 1/3; grid-row: 6/7; background: #d9d9d9 !important;
  padding: 0 1.3mm; font-size: 6pt; font-weight: 400; color: #000;
  white-space: nowrap; text-overflow: ellipsis;
}
.c-date {
  grid-column: 3/4; grid-row: 6/7; background: #d9d9d9 !important;
  justify-content: flex-end; padding: 0 1.3mm; font-size: 6pt; font-weight: 700; color: #000;
  white-space: nowrap;
}
.c-infl {
  grid-column: 4/6; grid-row: 6/7; background: #d9d9d9 !important;
  justify-content: flex-end; padding: 0 1.3mm; font-size: 8pt; font-weight: 700; color: #ff0000;
  white-space: nowrap;
}

/* ── Impression A4 portrait ───────────────────────────────── */
@media print {
  @page { size: A4 portrait; margin: 0; }
  html, body { background: #fff; height: auto; }
  /* Masquer tout sauf la planche */
  .topbar, .sidebar, .et-optbar, .page-header, .et-ctrl,
  #et-actions, .nav-item, .modal-ov { display: none !important; }
  .content, #mainContent, #s-etiquettes { padding: 0 !important; margin: 0 !important; }
  .et-preview { overflow: visible; background: #fff; padding: 0; display: block; }
  .et-page { box-shadow: none; page-break-after: always; }
  .et-page:last-child { page-break-after: auto; }
  .etq-in.qc { outline: none; }
  .etq-in > div { -webkit-print-color-adjust: exact; print-color-adjust: exact; }
  /* Recalage d'impression — remontée par rangée (mesuré sur tirage réel v0.16).
     Les rangées 3 à 7 ne sont pas touchées. */
  .etq.etq-row1 { transform: translateY(-2mm); }
  .etq.etq-row2 { transform: translateY(-1mm); }
  .etq.etq-row8 { transform: translateY(-1mm); }
}
