/* ================================================================
   barcodes.css v3.1.0 — Réécriture complète pro
   Préfixe bc- pour isolation totale
   ================================================================ */

/* ═══════════════════════════════════════════════════════
   SECTION CARD
   ═══════════════════════════════════════════════════════ */
.bc-section {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--r-xl, 16px);
    box-shadow: var(--shadow);
    margin-bottom: 20px;
    overflow: hidden;
}
.bc-section-hdr {
    display: flex; align-items: center; justify-content: space-between;
    gap: 16px; flex-wrap: wrap;
    padding: 20px 24px 16px;
}
.bc-title { font-size: 18px; font-weight: 800; color: var(--text-primary); margin: 0; }
.bc-subtitle { font-size: 13px; color: var(--text-muted); margin: 4px 0 0; }
.bc-actions { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }

/* ═══════════════════════════════════════════════════════
   GENERATOR — 2 colonnes
   ═══════════════════════════════════════════════════════ */
.bc-generator {
    display: grid;
    grid-template-columns: 380px 1fr;
    border-top: 1px solid var(--border);
}
.bc-controls {
    padding: 16px 20px;
    border-right: 1px solid var(--border);
}
.bc-preview {
    display: flex; flex-direction: column;
    background: var(--bg-elevated);
}

/* ═══════════════════════════════════════════════════════
   TABS
   ═══════════════════════════════════════════════════════ */
.lg-tabs {
    display: flex; gap: 4px; padding: 4px;
    background: var(--bg-elevated);
    border-radius: 12px; border: 1px solid var(--border);
    margin-bottom: 16px;
}
[data-theme="dark"] .lg-tabs { background: rgba(255,255,255,0.04); }
.lg-tab {
    flex: 1; appearance: none; border: none; background: transparent;
    color: var(--text-muted); font-weight: 700; font-size: 13px;
    padding: 9px 8px; border-radius: 10px; cursor: pointer;
    text-align: center; transition: all .2s;
}
.lg-tab:hover { color: var(--text-primary); background: var(--bg-card); }
.lg-tab.active {
    background: var(--bg-card); color: var(--text-primary);
    box-shadow: 0 1px 3px rgba(0,0,0,.08); font-weight: 800;
}

/* CRITICAL: hide inactive tabs, show active */
.lg-tabpane { display: none !important; }
.lg-tabpane.active { display: block !important; }

/* ═══════════════════════════════════════════════════════
   CHOICE CARDS (radio)
   ═══════════════════════════════════════════════════════ */
.bc-choices {
    display: grid; grid-template-columns: 1fr 1fr; gap: 8px;
    margin-bottom: 14px;
}
.bc-choice {
    display: flex; gap: 10px; align-items: flex-start;
    padding: 10px 12px; border-radius: 12px;
    border: 1.5px solid var(--border); background: var(--bg-card);
    cursor: pointer; transition: border-color .2s, background .2s;
}
.bc-choice:hover { border-color: var(--blue); }
.bc-choice input[type="radio"] { margin-top: 4px; flex-shrink: 0; }
.bc-choice input[type="radio"]:checked ~ div { color: var(--blue); }
.bc-choice div { min-width: 0; }
.bc-choice strong { display: block; font-size: 12px; font-weight: 800; color: var(--text-primary); line-height: 1.3; }
.bc-choice small { display: block; font-size: 11px; color: var(--text-muted); margin-top: 2px; }
.bc-choice--full { grid-column: 1 / -1; }

/* ═══════════════════════════════════════════════════════
   FIELDS
   ═══════════════════════════════════════════════════════ */
.bc-field-group { margin-top: 12px; }
.bc-lbl { display: block; font-size: 12px; font-weight: 700; color: var(--text-secondary); margin: 10px 0 5px; }
.bc-lbl:first-child { margin-top: 0; }
.bc-hint-warn { font-size: 11px; color: var(--orange, #f59e0b); margin-top: 4px; }

.bc-custom-fmt { margin-top: 12px; padding: 14px; background: var(--bg-elevated); border-radius: 12px; border: 1px solid var(--border); }
.bc-fmt-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }

/* ═══════════════════════════════════════════════════════
   TOGGLES (options checkboxes)
   ═══════════════════════════════════════════════════════ */
.bc-toggles { display: flex; flex-wrap: wrap; gap: 6px; }
.bc-tog {
    display: inline-flex; align-items: center; gap: 6px;
    padding: 7px 12px; border-radius: 20px;
    border: 1px solid var(--border); background: var(--bg-card);
    cursor: pointer; font-size: 12px; font-weight: 700;
    color: var(--text-primary); transition: all .15s;
}
.bc-tog:has(input:checked) {
    border-color: var(--blue); background: var(--blue-pale);
}
.bc-tog input { width: 14px; height: 14px; }

/* ═══════════════════════════════════════════════════════
   PREVIEW
   ═══════════════════════════════════════════════════════ */
.bc-preview-hdr {
    display: flex; align-items: center; justify-content: space-between;
    padding: 14px 20px; border-bottom: 1px solid var(--border);
    background: var(--bg-card);
}
.bc-preview-title { font-size: 14px; font-weight: 800; color: var(--text-primary); margin: 0; }
.bc-preview-sub { font-size: 12px; color: var(--text-muted); }
.bc-preview-meta { font-size: 12px; color: var(--text-secondary); white-space: nowrap; }
.bc-preview-body { padding: 20px; flex: 1; overflow: auto; }

.lg-sample {
    background: var(--bg-card);
    border: 1.5px dashed var(--border);
    border-radius: 12px;
    min-height: 300px;
    max-height: 580px;
    padding: 20px;
    display: flex; align-items: center; justify-content: center;
    color: var(--text-muted);
    overflow-y: auto; overflow-x: hidden;
}
.lg-sample.has-items { display: block; overflow-y: auto; }

/* Preview grid — pilotée par JS via custom properties */
.lg-sample-grid {
    display: grid;
    grid-template-columns: repeat(var(--lg-cols, 3), var(--lg-pw, 200px));
    gap: 8px;
    justify-content: center;
}
.lg-preview-label {
    width: var(--lg-pw, 200px);
    height: var(--lg-ph, 110px);
    box-sizing: border-box;
    background: #fff; border: 1px solid #ddd; border-radius: 4px;
    padding: 8px; overflow: hidden;
}
[data-theme="dark"] .lg-preview-label { background: var(--bg-elevated); border-color: var(--border); }

/* ── Label internals ── */
.lg-label-row { display: flex; align-items: center; gap: 8px; height: 100%; }
.lg-label-center { display: flex; flex-direction: column; align-items: center; justify-content: center; height: 100%; gap: 3px; text-align: center; }
.lg-label-full { display: flex; flex-direction: column; align-items: center; justify-content: center; height: 100%; gap: 3px; }
.lg-label-img { width: 42px; height: 42px; flex: 0 0 42px; object-fit: contain; border-radius: 4px; border: 1px solid #e2e8f0; }
.lg-label-img-full { width: 100%; max-height: 32px; object-fit: contain; border: 1px solid #e2e8f0; border-radius: 4px; margin-bottom: 3px; }
[data-theme="dark"] .lg-label-img, [data-theme="dark"] .lg-label-img-full { border-color: var(--border); }
.lg-label-body { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.lg-label-name { font-weight: 800; font-size: 11px; line-height: 1.2; color: #111; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
[data-theme="dark"] .lg-label-name { color: var(--text-primary); }
.lg-bc-wrap { width: 100%; text-align: center; }
.lg-bc-wrap canvas { display: block; width: 100% !important; height: auto !important; max-height: 32px; }
.lg-label-sku { font-family: var(--font-mono, 'Courier New', monospace); font-size: 9px; color: #555; text-align: center; }
[data-theme="dark"] .lg-label-sku { color: var(--text-muted); }
.lg-label-code { font-family: var(--font-mono, 'Courier New', monospace); font-size: 9px; color: #888; text-align: center; }
.lg-label-size { font-size: 9px; font-weight: 800; color: var(--blue, #2563eb); text-align: center; }
.lg-qr-wrap { text-align: center; }
.lg-qr-wrap img { display: inline-block; max-width: 56px; max-height: 56px; }
.lg-empty { padding: 32px; color: var(--text-muted); font-weight: 700; text-align: center; font-size: 14px; }

/* ═══════════════════════════════════════════════════════
   SÉLECTION PRODUITS
   ═══════════════════════════════════════════════════════ */
.bc-badge {
    display: inline-flex; align-items: center; padding: 3px 12px;
    border-radius: 20px; font-size: 12px; font-weight: 700;
    background: var(--blue-pale, #dbeafe); color: var(--blue, #3b82f6);
    border: 1px solid rgba(59,130,246,0.2);
}

/* Filtres — TOUJOURS en ligne horizontale */
.bc-filters {
    display: flex; align-items: center; gap: 10px;
    padding: 0 24px 16px; flex-wrap: wrap;
}
.bc-search { flex: 1; min-width: 220px; max-width: 400px; }
.bc-filter-sel { width: 180px; }
.bc-filter-btns { display: flex; gap: 6px; margin-left: auto; }

/* ═══════════════════════════════════════════════════════
   CARTES PRODUITS — Layout propre horizontal
   ═══════════════════════════════════════════════════════ */
.bc-prod-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
    gap: 10px;
    padding: 0 24px 24px;
}

.lg-prod-card {
    position: relative;
    display: grid;
    grid-template-columns: 48px 1fr auto;
    grid-template-rows: auto auto;
    align-items: center;
    gap: 0 12px;
    padding: 12px 14px;
    border: 1.5px solid var(--border);
    border-radius: 14px;
    background: var(--bg-card);
    cursor: pointer;
    user-select: none;
    transition: border-color .2s, background .2s, box-shadow .2s, transform .15s;
    outline: none;
}
.lg-prod-card:hover {
    border-color: rgba(59,130,246,.4);
    box-shadow: 0 4px 12px rgba(59,130,246,.08);
    transform: translateY(-1px);
}
.lg-prod-card:active { transform: translateY(0); }
.lg-prod-card:focus-visible { outline: 2px solid var(--blue); outline-offset: 2px; }

/* Sélectionné */
.lg-prod-card.selected {
    border-color: var(--blue);
    background: var(--blue-pale, #eff6ff);
    box-shadow: 0 0 0 3px rgba(59,130,246,.12);
}

/* Image — col 1, span 2 rows */
.lg-prod-img {
    grid-row: 1 / 3; grid-column: 1;
    width: 48px; height: 48px;
    display: flex; align-items: center; justify-content: center;
    border-radius: 10px; border: 1px solid var(--border);
    background: var(--bg-elevated); overflow: hidden;
    font-size: 22px; flex-shrink: 0;
}
.lg-prod-img img { width: 100%; height: 100%; object-fit: contain; }

/* Info — col 2 row 1 */
.lg-prod-info {
    grid-row: 1; grid-column: 2;
    min-width: 0;
}
.lg-prod-name {
    font-weight: 800; font-size: 13px; color: var(--text-primary);
    line-height: 1.3; overflow: hidden; text-overflow: ellipsis;
    display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 2;
    word-break: break-word;
}
.lg-prod-sku {
    font-size: 11px; color: var(--text-muted);
    font-family: var(--font-mono, 'Courier New', monospace);
    margin-top: 2px;
}

/* Badge taille */
.lg-prod-size {
    display: inline-block; padding: 1px 7px; border-radius: 4px;
    font-size: 10px; font-weight: 700;
    background: var(--orange-pale, #fff7ed); color: var(--orange, #ea580c);
    margin-left: 4px; vertical-align: middle;
}
.lg-prod-child { border-left: 3px solid var(--orange, #f59e0b); }

/* Checkbox — col 3 row 1 */
.lg-prod-check {
    grid-row: 1; grid-column: 3;
    width: 24px; height: 24px; border-radius: 7px;
    border: 2px solid var(--border); background: var(--bg-card);
    display: flex; align-items: center; justify-content: center;
    font-size: 14px; font-weight: 900; color: transparent;
    transition: all .15s; pointer-events: none; flex-shrink: 0;
}
.lg-prod-card:hover .lg-prod-check { border-color: rgba(59,130,246,.5); }
.lg-prod-card.selected .lg-prod-check {
    border-color: var(--blue); background: var(--blue); color: #fff;
}

/* Quantité — col 2-3 row 2 (seulement quand sélectionné) */
.lg-prod-qty {
    grid-row: 2; grid-column: 2 / 4;
    display: flex; align-items: center; gap: 2px;
    margin-top: 8px;
    background: var(--bg-elevated); border: 1px solid var(--border);
    border-radius: 10px; padding: 3px 6px; width: fit-content;
}
.lg-qty-btn {
    appearance: none; border: none; background: transparent;
    font-size: 18px; font-weight: 900; color: var(--text-primary);
    cursor: pointer; width: 30px; height: 30px;
    display: flex; align-items: center; justify-content: center;
    border-radius: 8px; transition: background .15s;
}
.lg-qty-btn:hover { background: var(--bg-hover, rgba(0,0,0,.05)); }
.lg-qty-inp {
    width: 40px; text-align: center; border: none; background: transparent;
    font-size: 15px; font-weight: 800; color: var(--text-primary);
    -moz-appearance: textfield;
}
.lg-qty-inp::-webkit-inner-spin-button,
.lg-qty-inp::-webkit-outer-spin-button { -webkit-appearance: none; }

/* ═══════════════════════════════════════════════════════
   RESPONSIVE
   ═══════════════════════════════════════════════════════ */
@media (max-width: 1100px) {
    .bc-generator { grid-template-columns: 1fr; }
    .bc-controls { border-right: none; border-bottom: 1px solid var(--border); }
}
@media (max-width: 900px) {
    .bc-choices { grid-template-columns: 1fr; }
    .bc-filters { flex-direction: column; align-items: stretch; }
    .bc-search { max-width: none; }
    .bc-filter-sel { width: 100%; }
    .bc-filter-btns { margin-left: 0; }
}
@media (max-width: 600px) {
    .bc-section-hdr { padding: 16px; }
    .bc-filters { padding: 0 16px 16px; }
    .bc-prod-grid { grid-template-columns: 1fr; padding: 0 16px 16px; }
    .bc-fmt-grid { grid-template-columns: 1fr; }
}
@media print { body > * { display: none !important; } }

/* ═══════════════════════════════════════════════════════
   PAGINATION PREVIEW
   ═══════════════════════════════════════════════════════ */
.lg-pagination {
    display: flex; align-items: center; justify-content: center;
    gap: 10px; margin-top: 14px; padding: 10px 0;
    border-top: 1px solid var(--border);
}
.lg-pg-btn {
    appearance: none; border: 1.5px solid var(--border); background: var(--bg-card);
    color: var(--text-primary); font-size: 14px; font-weight: 800;
    width: 34px; height: 34px; border-radius: 10px; cursor: pointer;
    display: flex; align-items: center; justify-content: center;
    transition: all .15s;
}
.lg-pg-btn:hover:not(:disabled) { border-color: var(--blue); background: var(--blue-pale); }
.lg-pg-btn:disabled { opacity: 0.35; cursor: default; }
.lg-pg-info { font-size: 13px; font-weight: 700; color: var(--text-primary); }
.lg-pg-total { font-size: 11px; color: var(--text-muted); margin-left: 8px; }


/* ================================================================
   MageStock — Code-barres v3.4.0
   Correctifs : stock réel, codes longs, impression plus lisible
   ================================================================ */
.bc-hint-info{
    margin-top:6px;
    font-size:12px;
    line-height:1.35;
    color:var(--text-muted,#64748b);
}
.bc-hint-warn{
    margin-top:8px;
    padding:8px 10px;
    border-radius:10px;
    border:1px solid rgba(245,158,11,.35);
    background:rgba(245,158,11,.10);
    color:#b45309;
    font-weight:700;
    font-size:12px;
    line-height:1.35;
}
[data-theme="dark"] .bc-hint-warn{
    color:#fbbf24;
    background:rgba(245,158,11,.12);
}
.lg-prod-stock{
    margin-top:3px;
    font-size:11px;
    font-weight:700;
    color:var(--blue,#3b82f6);
}
.lg-label-code{
    white-space:normal!important;
    word-break:break-all;
    line-height:1.05;
}
.lg-bc-wrap{
    overflow:hidden;
}
.lg-bc-wrap canvas{
    image-rendering:auto;
}
@media print{
    .cut{display:block!important}
    .lbl,
    .lg-sheet-label,
    .lg-sheet-empty{
        border-color:#000!important;
        border-width:0.95pt!important;
        -webkit-print-color-adjust:exact!important;
        print-color-adjust:exact!important;
    }
    .cut-tl-h,.cut-tr-h{border-top-color:#000!important;border-top-width:1.15pt!important}
    .cut-bl-h,.cut-br-h{border-bottom-color:#000!important;border-bottom-width:1.15pt!important}
    .cut-tl-v,.cut-tr-v,.cut-bl-v,.cut-br-v{border-left-color:#000!important;border-left-width:1.15pt!important}
}
