/* ================================================================
   MAGESTOCK v2.3.26 — addons.css
   Styles complémentaires : pagination, validation, impression et UX produit
   ================================================================ */

/* ── PAGINATION ── */
.pagination {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    padding: 16px 0;
    margin-top: 16px;
    border-top: 1px solid var(--border);
}

.btn-page {
    padding: 8px 16px;
    border-radius: var(--r);
    border: 1px solid var(--border);
    background: var(--bg-card);
    color: var(--text-primary);
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    transition: all var(--tr);
    font-family: inherit;
}

.btn-page:hover:not(:disabled) {
    background: var(--bg-card-hover);
    border-color: var(--blue);
    color: var(--blue);
}

.btn-page:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

.page-info {
    font-size: 14px;
    font-weight: 600;
    color: var(--text-primary);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2px;
}

.page-info small {
    font-size: 11px;
    font-weight: 400;
    color: var(--text-muted);
}

/* ── FORM VALIDATION ERRORS ── */
.inp-error {
    border-color: var(--red) !important;
    box-shadow: 0 0 0 3px var(--red-pale) !important;
}

.field-error {
    display: block;
    color: var(--red);
    font-size: 11px;
    font-weight: 600;
    margin-top: 4px;
}

/* ── STOCK LIMIT WARNINGS ── */
.stock-limit-warning {
    background: var(--orange-pale);
    border: 1px solid rgba(255,123,46,0.3);
    border-radius: var(--r);
    padding: 10px 12px;
    margin: 12px 0;
    font-size: 12px;
    color: var(--orange);
    display: flex;
    align-items: center;
    gap: 8px;
}

.stock-limit-warning svg {
    width: 16px;
    height: 16px;
    flex-shrink: 0;
}

.stock-info-badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 4px 8px;
    border-radius: 12px;
    font-size: 11px;
    font-weight: 600;
    background: var(--blue-pale);
    color: var(--blue);
}

.stock-info-badge.limit-reached {
    background: var(--red-pale);
    color: var(--red);
}

.stock-info-badge.limit-near {
    background: var(--orange-pale);
    color: var(--orange);
}

/* ── PRODUCT CARDS WAREHOUSE BADGES ── */
.prod-warehouse-badges {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
    margin-top: 8px;
}

.wh-badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 3px 7px;
    border-radius: 10px;
    font-size: 10px;
    font-weight: 700;
    background: var(--blue-pale);
    color: var(--blue);
    border: 1px solid rgba(0,180,216,0.2);
}

.wh-badge-main {
    background: var(--green-pale);
    color: var(--green);
    border-color: rgba(0,212,170,0.2);
}

.wh-badge-count {
    background: var(--bg-card-hover);
    color: var(--text-muted);
    cursor: help;
}

.wh-badge svg {
    width: 10px;
    height: 10px;
}

/* ── ENTRY VS ADD BUTTONS ── */
.btn-entry {
    background: var(--green);
    color: #fff;
    border-color: var(--green);
}

.btn-entry:active {
    background: var(--green-dim);
    transform: scale(0.97);
}

.btn-entry svg {
    width: 15px;
    height: 15px;
}

/* ── PRINT BUTTON IN TOOLBAR ── */
.btn-print {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 9px 14px;
    border-radius: var(--r);
    border: 1px solid var(--border);
    background: var(--bg-card);
    color: var(--text-secondary);
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    transition: all var(--tr);
}

.btn-print:hover {
    background: var(--bg-card-hover);
    border-color: var(--blue);
    color: var(--blue);
}

.btn-print svg {
    width: 15px;
    height: 15px;
}

/* ── ADVANCED FILTERS ── */
.filters-advanced {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
    gap: 10px;
    padding: 12px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--r-md);
    margin-bottom: 12px;
}

.filters-advanced.collapsed {
    display: none;
}

.btn-toggle-filters {
    font-size: 12px;
    padding: 6px 10px;
    color: var(--text-muted);
    display: inline-flex;
    align-items: center;
    gap: 4px;
}

.btn-toggle-filters:hover {
    color: var(--blue);
}

.btn-toggle-filters svg {
    width: 12px;
    height: 12px;
    transition: transform var(--tr);
}

.btn-toggle-filters.active svg {
    transform: rotate(180deg);
}

/* ── SUPPLIER BRANDS MANAGEMENT ── */
.brands-list {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    padding: 8px 0;
}

.brand-tag {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 4px 8px;
    border-radius: 12px;
    background: var(--blue-pale);
    color: var(--blue);
    font-size: 11px;
    font-weight: 600;
}

.brand-tag button {
    background: none;
    border: none;
    color: inherit;
    padding: 0;
    width: 14px;
    height: 14px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    opacity: 0.6;
    transition: opacity var(--tr);
}

.brand-tag button:hover {
    opacity: 1;
}

.brand-tag button svg {
    width: 10px;
    height: 10px;
}

.brand-input-group {
    display: flex;
    gap: 6px;
}

.brand-input-group input {
    flex: 1;
}

.brand-input-group button {
    flex-shrink: 0;
}

/* ── MOBILE RESPONSIVE ADJUSTMENTS ── */
@media (max-width: 768px) {
    .pagination {
        padding: 12px 0;
    }
    
    .btn-page {
        padding: 6px 12px;
        font-size: 12px;
    }
    
    .page-info {
        font-size: 12px;
    }
    
    .page-info small {
        font-size: 10px;
    }
    
    .filters-advanced {
        grid-template-columns: 1fr;
    }
    
    .prod-warehouse-badges {
        margin-top: 6px;
    }
}

/* ── PRINT IMPROVEMENTS ── */
@media print {
    .pagination,
    .btn-print,
    .btn-toggle-filters,
    .filters-advanced,
    .sect-toolbar,
    .page-titlebar {
        display: none !important;
    }
    
    .page-body {
        padding: 0 !important;
    }
    
    table {
        page-break-inside: auto;
    }
    
    thead {
        display: table-header-group;
    }
    
    tr {
        page-break-inside: avoid;
        page-break-after: auto;
    }
    
    .card {
        page-break-inside: avoid;
        border: 1px solid #ddd !important;
        margin-bottom: 12px;
    }
    
    /* Hide interactive elements */
    button,
    .btn,
    .hdr-btn,
    .app-footer {
        display: none !important;
    }
}

/* ── FOOTER COPYRIGHT (PC UNIQUEMENT) ── */
.app-footer {
    display: none; /* Masqué par défaut (mobile/tablette) */
}

@media (min-width: 1024px) {
    .app-footer {
        display: block;
        background: var(--bg-card);
        border-top: 1px solid var(--border);
        padding: 14px 24px;
        text-align: center;
        font-size: 12px;
        color: var(--text-muted);
        position: fixed;
        bottom: 0;
        left: 0;
        right: 0;
        z-index: 5;
    }
    
    .footer-content p {
        margin: 0;
    }
    
    .app-footer strong {
        color: var(--text-primary);
        font-weight: 600;
    }
    
    /* Compenser hauteur footer dans le contenu */
    #appContent {
        padding-bottom: 50px !important;
    }
}

/* ── ESPACEMENT BOUTONS TOOLBAR ── */
.sect-toolbar-right {
    gap: 16px !important;
}

.sect-toolbar-right > button {
    margin: 0 !important;
}

/* ── GESTION MARQUES (TAGS) ── */
.brands-manager {
    background: var(--bg-hover);
    border: 1px solid var(--border);
    border-radius: var(--r);
    padding: 12px;
}

.brands-list {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    min-height: 40px;
    margin-bottom: 8px;
}

.brands-list:empty::before {
    content: "Aucune marque ajoutée";
    color: var(--text-muted);
    font-size: 12px;
    font-style: italic;
}

.brand-tag {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 4px 10px 4px 12px;
    background: var(--blue);
    color: #fff;
    border-radius: 16px;
    font-size: 12px;
    font-weight: 600;
}

.brand-tag button {
    background: rgba(255,255,255,0.2);
    border: none;
    color: #fff;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    font-size: 14px;
    line-height: 1;
    padding: 0;
    transition: all var(--tr);
}

.brand-tag button:hover {
    background: rgba(255,255,255,0.4);
}

.brand-input-group {
    display: flex;
    gap: 8px;
    align-items: center;
}

.brand-input-group .inp {
    flex: 1;
    margin: 0;
}



/* ── BADGE FOR BRANDS ──────────────────────────────────────────── */
.badge {
    display: inline-block;
    padding: 4px 10px;
    background: var(--blue-pale);
    color: var(--blue);
    border: 1px solid rgba(0, 180, 216, 0.2);
    border-radius: 12px;
    font-size: 11px;
    font-weight: 600;
    margin: 2px;
}

/* ── REPORTS PAGE STYLES ────────────────────────────────────── */

/* Tabs Navigation */
.report-tabs {
    display: flex;
    gap: 8px;
    margin-bottom: 24px;
    border-bottom: 2px solid var(--border);
}

.report-tab {
    padding: 12px 24px;
    background: transparent;
    border: none;
    border-bottom: 3px solid transparent;
    color: var(--text-muted);
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
}

.report-tab:hover {
    color: var(--text);
    background: var(--bg-card);
}

.report-tab.active {
    color: var(--blue);
    border-bottom-color: var(--blue);
}

/* Tab Content */
.report-tab-content {
    display: none;
}

.report-tab-content.active {
    display: block;
}

/* Filters */
.report-filters {
    display: grid;
    grid-template-columns: 2fr repeat(4, 1fr) auto;
    gap: 12px;
    margin-bottom: 24px;
    padding: 16px;
    background: var(--bg-card);
    border-radius: var(--r);
    border: 1px solid var(--border);
}

@media (max-width: 1200px) {
    .report-filters {
        grid-template-columns: 1fr 1fr;
    }
}

/* Summary Cards */
.report-summary {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 16px;
    margin-bottom: 24px;
}

.summary-card {
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 20px;
    background: var(--bg-card);
    border-radius: var(--r);
    border: 1px solid var(--border);
    transition: all 0.2s;
}

.summary-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

.summary-card.alert {
    border-color: var(--red);
    background: rgba(244, 67, 54, 0.05);
}

.summary-icon {
    font-size: 32px;
    line-height: 1;
}

.summary-data {
    flex: 1;
}

.summary-value {
    font-size: 24px;
    font-weight: 700;
    color: var(--text);
    margin-bottom: 4px;
}

.summary-label {
    font-size: 12px;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

/* Print Styles — Rapports : seul l'onglet actif est imprimé */
@media print {
    .report-tabs,
    .sect-toolbar button,
    .report-filters,
    nav,
    .page-sidebar {
        display: none !important;
    }
    
    /* NE PAS forcer tous les onglets visibles — seul .active s'affiche */
    .report-tab-content {
        display: none !important;
    }
    .report-tab-content.active {
        display: block !important;
    }
    
    .tbl-wrap {
        max-height: none !important;
        overflow: visible !important;
    }
    
    table {
        page-break-inside: auto;
    }
    
    tr {
        page-break-inside: avoid;
        page-break-after: auto;
    }
}


/* ================================================================
   GLOBAL — Scroll-to-top button with progress ring (footer anchored)
   - Appears after scroll
   - Progress ring indicates scroll position (top -> bottom)
   ================================================================ */
.footer-inner{
    display:flex;
    align-items:center;
    justify-content:space-between;
    gap:12px;
}
.footer-text{flex:1; min-width:0;}
.scrolltop{
    position:fixed;
    right:16px;
    bottom:calc(16px + env(safe-area-inset-bottom, 0px));
    width:46px;
    height:46px;
    border-radius:999px;
    border:1px solid rgba(15,23,42,.12);
    background:rgba(255,255,255,.92);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    box-shadow:0 10px 25px rgba(15,23,42,.12);
    display:grid;
    place-items:center;
    z-index:1100;
    opacity:0;
    transform:translateY(10px);
    pointer-events:none;
    transition:opacity .18s ease, transform .18s ease, box-shadow .18s ease;
}
html[data-theme="dark"] .scrolltop{
    border-color: rgba(255,255,255,.12);
    background: rgba(2,6,23,.72);
    box-shadow:0 12px 30px rgba(0,0,0,.35);
}
.scrolltop.is-visible{
    opacity:1;
    transform:translateY(0);
    pointer-events:auto;
}
.scrolltop:active{ transform:translateY(1px); }
.scrolltop-ring{
    position:absolute;
    inset:0;
    width:46px;
    height:46px;
}
.scrolltop-ring-bg{
    fill:none;
    stroke:rgba(15,23,42,.10);
    stroke-width:4;
}
html[data-theme="dark"] .scrolltop-ring-bg{ stroke:rgba(255,255,255,.10); }
.scrolltop-ring-progress{
    fill:none;
    stroke:rgba(37,99,235,.95);
    stroke-width:4;
    stroke-linecap:round;
    transform:rotate(-90deg);
    transform-origin:50% 50%;
}
.scrolltop-arrow{
    width:18px;
    height:18px;
    fill:rgba(15,23,42,.86);
}
html[data-theme="dark"] .scrolltop-arrow{ fill:rgba(255,255,255,.86); }

/* On mobile, keep it above bottom navigation */
@media (max-width: 1024px){
    .scrolltop{
        bottom:calc(86px + env(safe-area-inset-bottom, 0px));
        right:14px;
    }
}


/* ================================================================
   Scanner — html5-qrcode injected video/canvas sizing + frame alignment
   (keeps existing app.css intact; overrides with higher specificity)
   ================================================================ */
#pgScanner #scannerPreview{ position:relative; overflow:hidden; }
#pgScanner #scannerH5{ position:absolute; inset:0; z-index:1; }
#pgScanner #scannerH5 video,
#pgScanner #scannerH5 canvas,
#pgScanner #scannerH5 img{
  width:100% !important;
  height:100% !important;
  object-fit:cover !important;
  border-radius:14px;
}

/* Ensure html5-qrcode internal wrappers fill the host */
#pgScanner #scannerH5 > div,
#pgScanner #scannerH5 .html5-qrcode-element{
  width:100% !important;
  height:100% !important;
}

/* Frame matches ScannerService qrbox (vars set by JS) */
#pgScanner .scanner-preview .scanner-frame{
  top: var(--scanner-frame-inset-y, 20%) !important;
  bottom: var(--scanner-frame-inset-y, 20%) !important;
  left: var(--scanner-frame-inset-x, 20%) !important;
  right: var(--scanner-frame-inset-x, 20%) !important;
}

/* Stop button should always be tappable */
#pgScanner #btnStopScan{
  touch-action: manipulation;
}


/* ================================================================
   Scanner (mobile/HTML5) — ensure injected video fills container
   Prevents "camera active but invisible" on some mobile browsers.
   ================================================================ */
#scannerH5, #scannerH5 > div {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
}
#scannerH5 video, #scannerH5 canvas {
  width: 100% !important;
  height: 100% !important;
  object-fit: cover !important;
}

/* ═══════════════════════════════════════════════════════════════
   PRODUCT CARDS v3 — Style « carte produit » inspiré carte à collectionner
   Image dominante en haut (~55%), infos structurées en bas, responsive
   ═══════════════════════════════════════════════════════════════ */

/* ── Grille ── */
.products-grid, .prod-grid {
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)) !important;
    gap: 16px !important;
}

/* ── Carte ── */
.pc2 {
    background: var(--bg-card, #fff);
    border: 2px solid var(--border, #e2e8f0);
    border-radius: 14px;
    cursor: pointer;
    position: relative;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    transition: transform 0.22s ease, box-shadow 0.22s ease, border-color 0.22s ease;
}
.pc2:hover {
    transform: translateY(-4px);
    border-color: var(--blue, #3b82f6);
    box-shadow: 0 14px 32px rgba(0, 0, 0, 0.10), 0 0 0 1px var(--blue, #3b82f6);
}
.pc2:active { transform: translateY(-1px); }

/* ── HERO IMAGE ── */
.pc2-hero {
    position: relative;
    width: 100%;
    aspect-ratio: 1 / 1;
    background: var(--bg-elevated, #f8fafc);
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    border-bottom: 1px solid var(--border-light, rgba(0,0,0,0.04));
}
.pc2-hero-img {
    width: 100%;
    height: 100%;
    object-fit: contain;
    padding: 12px;
    transition: transform 0.3s ease;
}
.pc2:hover .pc2-hero-img {
    transform: scale(1.06);
}
.pc2-hero--empty {
    background: var(--bg-elevated, #f8fafc);
}
.pc2-hero-svg {
    width: 52px;
    height: 52px;
    fill: none;
    stroke: var(--text-muted, #94a3b8);
    stroke-width: 1;
    opacity: 0.2;
}

/* ── Bouton mouvement rapide (overlay) ── */
.pc2-qa {
    position: absolute;
    top: 8px;
    right: 8px;
    width: 34px;
    height: 34px;
    border-radius: 10px;
    background: var(--bg-card, #fff);
    border: 1px solid var(--border, #e2e8f0);
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-muted, #94a3b8);
    cursor: pointer;
    opacity: 0;
    transition: all 0.15s ease;
    box-shadow: 0 2px 8px rgba(0,0,0,0.08);
    z-index: 2;
}
.pc2:hover .pc2-qa { opacity: 1; }
.pc2-qa:hover { background: var(--blue-pale, #dbeafe); border-color: var(--blue); color: var(--blue); }
.pc2-qa svg { width: 16px; height: 16px; }

/* ── Flag statut (overlay image coin gauche) ── */
.pc2-flag {
    position: absolute;
    top: 8px;
    left: 8px;
    padding: 3px 10px;
    border-radius: 6px;
    font-size: 10px;
    font-weight: 700;
    letter-spacing: 0.5px;
    text-transform: uppercase;
    z-index: 2;
}
.pc2-flag--crit { background: var(--red, #ef4444); color: #fff; }
.pc2-flag--low { background: var(--orange, #f59e0b); color: #fff; }

/* ── Identité (nom + sku) ── */
.pc2-identity {
    padding: 12px 14px 4px;
}
.pc2-name {
    font-size: 14px;
    font-weight: 700;
    color: var(--text-primary, #0f172a);
    line-height: 1.25;
    margin: 0 0 3px;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}
.pc2-sku {
    font-family: var(--font-mono, 'DM Mono', monospace);
    font-size: 11px;
    color: var(--text-muted, #94a3b8);
    letter-spacing: 0.3px;
}

/* ── Chips (marque, catégorie, emplacement) ── */
.pc2-chips {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
    padding: 6px 14px 2px;
}
.pc2-chip {
    display: inline-flex;
    align-items: center;
    padding: 2px 8px;
    border-radius: 6px;
    font-size: 10.5px;
    font-weight: 600;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 140px;
    line-height: 1.5;
}
.pc2-chip--brand { background: var(--blue-pale, #dbeafe); color: var(--blue, #3b82f6); }
.pc2-chip--cat { background: var(--bg-elevated, #f1f5f9); color: var(--text-secondary, #64748b); border: 1px solid var(--border-light, rgba(0,0,0,0.06)); }
.pc2-chip--loc { background: var(--green-pale, #dcfce7); color: var(--green, #16a34a); }

/* ── Magasins ── */
.pc2-wh {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
    padding: 4px 14px 0;
}

/* ── Stock (barre + stats) ── */
.pc2-bottom {
    padding: 10px 14px 12px;
    margin-top: auto;
}
.pc2-bar {
    height: 5px;
    background: var(--bg-elevated, #f1f5f9);
    border-radius: 99px;
    overflow: hidden;
    margin-bottom: 8px;
}
.pc2-bar-fill {
    height: 100%;
    border-radius: 99px;
    transition: width 0.3s ease;
}
.pc2-bar--ok { background: var(--green, #22c55e); }
.pc2-bar--low { background: var(--orange, #f59e0b); }
.pc2-bar--crit { background: var(--red, #ef4444); }

.pc2-stats {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 6px;
}
.pc2-qty {
    font-size: 16px;
    font-weight: 800;
    color: var(--text-primary, #0f172a);
    letter-spacing: -0.5px;
}
.pc2-qty--crit { color: var(--red, #ef4444); }
.pc2-qty--low { color: var(--orange, #f59e0b); }
.pc2-qty--ok { color: var(--text-primary, #0f172a); }
.pc2-val {
    font-size: 12px;
    color: var(--text-muted, #94a3b8);
    font-weight: 500;
}

/* ── Documents ── */
.pc2-docs {
    display: flex;
    gap: 6px;
    padding: 0 14px 10px;
    border-top: 1px solid var(--border-light, rgba(0,0,0,0.04));
    padding-top: 8px;
    margin-top: 0;
}
.pc2-doc {
    font-size: 10.5px;
    padding: 3px 8px;
    border-radius: 6px;
    background: var(--bg-elevated, #f1f5f9);
    color: var(--text-secondary, #64748b);
    text-decoration: none;
    font-weight: 500;
    border: 1px solid transparent;
    transition: all 0.12s;
}
.pc2-doc:hover { background: var(--blue-pale); border-color: var(--blue); color: var(--blue); }

/* ═══ RESPONSIVE ═══ */

/* Tablette */
@media (max-width: 1024px) {
    .products-grid, .prod-grid {
        grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)) !important;
        gap: 12px !important;
    }
    .pc2-hero { aspect-ratio: 1 / 1; }
    .pc2-hero-img { padding: 8px; }
    .pc2-identity { padding: 10px 12px 3px; }
    .pc2-name { font-size: 13px; }
    .pc2-chips { padding: 4px 12px 2px; }
    .pc2-wh { padding: 3px 12px 0; }
    .pc2-bottom { padding: 8px 12px 10px; }
    .pc2-qty { font-size: 14px; }
}

/* Mobile */
@media (max-width: 640px) {
    .products-grid, .prod-grid {
        grid-template-columns: repeat(2, 1fr) !important;
        gap: 8px !important;
    }
    .pc2 { border-radius: 12px; border-width: 1px; }
    .pc2-hero { aspect-ratio: 1 / 1; }
    .pc2-hero-img { padding: 6px; }
    .pc2-hero-svg { width: 36px; height: 36px; }
    .pc2-identity { padding: 8px 10px 2px; }
    .pc2-name { font-size: 12px; }
    .pc2-sku { font-size: 9.5px; }
    .pc2-chips { padding: 4px 10px 0; gap: 3px; }
    .pc2-chip { font-size: 9px; padding: 1px 5px; max-width: 110px; }
    .pc2-wh { padding: 2px 10px 0; }
    .pc2-bottom { padding: 6px 10px 8px; }
    .pc2-bar { height: 4px; margin-bottom: 6px; }
    .pc2-qty { font-size: 13px; }
    .pc2-val { font-size: 10px; }
    .pc2-docs { padding: 0 10px 8px; padding-top: 6px; }
    .pc2-doc { font-size: 9.5px; }
    .pc2-qa { opacity: 1; width: 28px; height: 28px; top: 5px; right: 5px; border-radius: 8px; }
    .pc2-qa svg { width: 14px; height: 14px; }
    .pc2-flag { font-size: 8px; padding: 2px 6px; top: 5px; left: 5px; }
}

/* Très petit */
@media (max-width: 380px) {
    .products-grid, .prod-grid { grid-template-columns: 1fr !important; }
    .pc2-hero { aspect-ratio: 16 / 10; }
}

/* ════════════════════════════════════════════════════════════════
   PRODUCT MODAL — FULLSCREEN 2 COLONNES (PC)
   ════════════════════════════════════════════════════════════════ */
@media (min-width: 1025px) {
    body[data-page="products"] .modal-overlay .modal {
        max-width: calc(100vw - 80px) !important;
        max-height: calc(100vh - 40px) !important;
        width: calc(100vw - 80px) !important;
        border-radius: 16px !important;
    }
    body[data-page="products"] .modal-body { overflow-y: auto; flex: 1; }
}
.pm-fullgrid { display: grid; grid-template-columns: 1fr 1fr; gap: 0; min-height: 100%; }
.pm-fullgrid .pm-col { padding: 4px 0; }
.pm-fullgrid .pm-col-left { padding-right: 28px; border-right: 1.5px solid var(--border, #e2e8f0); }
.pm-fullgrid .pm-col-right { padding-left: 28px; }
.pm-fullgrid .pm-col h4 { margin: 16px 0 8px; font-size: 14px; font-weight: 700; display: flex; align-items: center; gap: 6px; }
.pm-fullgrid .pm-col h4:first-child { margin-top: 0; }
.pm-fullgrid .pm-sep { height: 1px; background: var(--border, #e2e8f0); margin: 14px 0 10px; }
@media (max-width: 1024px) {
    .pm-fullgrid { grid-template-columns: 1fr; }
    .pm-fullgrid .pm-col-left { padding-right: 0; border-right: none; border-bottom: 1.5px solid var(--border); padding-bottom: 20px; margin-bottom: 16px; }
    .pm-fullgrid .pm-col-right { padding-left: 0; }
}
/* Bloc conditionnel dynamique */
#pmCondBlock .pm-cond-box { background: var(--bg-elevated, #f8fafc); border: 1.5px solid var(--blue, #3b82f6); border-radius: 12px; padding: 16px; margin: 10px 0 4px; animation: _pmCondIn .2s ease; }
#pmCondBlock .pm-cond-box h5 { font-size: 14px; font-weight: 700; margin: 0 0 12px; color: var(--text-primary); }
#pmCondBlock .pm-cond-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
#pmCondBlock .pm-cond-row label { font-size: 13px; font-weight: 600; color: var(--text-secondary, #475569); display: block; margin-bottom: 5px; }
@media (max-width: 500px) { #pmCondBlock .pm-cond-row { grid-template-columns: 1fr; } }
@keyframes _pmCondIn { from { opacity: 0; transform: translateY(-6px); } to { opacity: 1; transform: translateY(0); } }
/* EAN tags */
.pm-ean-tags { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 6px; }
.pm-ean-tag { display: inline-flex; align-items: center; gap: 4px; padding: 3px 10px; background: var(--bg-elevated); border: 1px solid var(--border); border-radius: 8px; font-family: monospace; font-size: 12px; }
.pm-ean-tag button { background: none; border: none; color: var(--red, #ef4444); cursor: pointer; font-size: 14px; padding: 0; line-height: 1; }
/* CUMP readonly */
.pm-cump-display { background: var(--bg-elevated); border: 1px solid var(--border); border-radius: var(--r, 8px); padding: 10px 14px; font-size: 15px; font-weight: 700; color: var(--blue, #3b82f6); font-family: monospace; }

/* ════════════════════════════════════════════════════════════════
   EPI / TAILLES — Déclinaisons produit
   ════════════════════════════════════════════════════════════════ */
.pm-sizes-grid { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.pm-size-chip { display: inline-flex; align-items: center; padding: 5px 12px; border-radius: 8px; font-size: 13px; font-weight: 600; border: 1.5px solid var(--border); background: var(--bg-card); cursor: pointer; transition: all .15s; user-select: none; }
.pm-size-chip:hover { border-color: var(--blue); background: var(--blue-pale); }
.pm-size-chip.selected { border-color: var(--blue); background: var(--blue); color: #fff; }
.pm-size-chip input { display: none; }
/* Dupliquer bouton */
.pm-dup-btn { display: inline-flex; align-items: center; gap: 5px; }
/* Produits enfants (sous-lignes groupées) */
.prod-child-row td { background: var(--bg-elevated, #f8fafc) !important; padding-left: 32px !important; font-size: 13px; }
.prod-child-row td:first-child { position: relative; }
.prod-child-row td:first-child::before { content: '↳'; position: absolute; left: 12px; color: var(--text-muted); font-size: 14px; }
.prod-parent-toggle { cursor: pointer; user-select: none; }
.prod-parent-toggle::before { content: '▸'; display: inline-block; width: 16px; transition: transform .2s; }
.prod-parent-toggle.open::before { transform: rotate(90deg); }
/* Card badge taille */
.pc2-chip--size { background: var(--orange-pale, #fff7ed) !important; color: var(--orange, #ea580c) !important; border: 1px solid rgba(234,88,12,.2) !important; }
.pc2-sizes-row { display: flex; flex-wrap: wrap; gap: 4px; padding: 4px 14px 2px; }
.pc2-size-mini { font-size: 10px; padding: 2px 6px; border-radius: 4px; background: var(--bg-elevated); border: 1px solid var(--border); font-weight: 600; }

/* ════════════════════════════════════════════════════════════════
   MAGESTOCK v2.3.26 — PRODUCT MODAL UX / ACCESSIBILITÉ
   Ergonomie création-modification produit : panneaux, aides, détails avancés.
   ════════════════════════════════════════════════════════════════ */
body[data-page="products"] .modal-body {
    background: linear-gradient(180deg, rgba(148,163,184,.06), transparent 180px);
}

.pm-form-guide {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    padding: 12px 14px;
    margin: 0 0 14px;
    border: 1px solid var(--border, #e2e8f0);
    border-radius: 14px;
    background: var(--bg-elevated, #f8fafc);
    color: var(--text-secondary, #475569);
    font-size: 13px;
    line-height: 1.35;
}
.pm-form-guide strong {
    color: var(--text-primary, #0f172a);
    white-space: nowrap;
}
.pm-form-guide span { display: block; }

.pm-stock-summary {
    margin: 0 0 14px;
}
.pm-stock-summary h4,
.pm-panel h4,
.pm-advanced h4 {
    margin: 0 0 10px !important;
    font-size: 14px !important;
    font-weight: 800 !important;
    letter-spacing: -.01em;
    color: var(--text-primary, #0f172a);
}
.pm-stock-card,
.pm-panel {
    border: 1px solid var(--border, #e2e8f0);
    border-radius: 14px;
    background: var(--bg-card, #fff);
    box-shadow: 0 1px 2px rgba(15,23,42,.04);
}
.pm-stock-card { padding: 10px 12px; }
.pm-stock-card--empty {
    color: var(--text-muted, #64748b);
    font-size: 13px;
}
.pm-stock-line,
.pm-stock-total {
    display: flex;
    justify-content: space-between;
    gap: 12px;
    padding: 6px 0;
    border-bottom: 1px solid var(--border, #e2e8f0);
}
.pm-stock-line:last-child { border-bottom: 0; }
.pm-stock-total {
    margin-top: 8px;
    padding-top: 10px;
    border-top: 2px solid var(--border, #e2e8f0);
    border-bottom: 0;
}
.pm-help {
    margin: 6px 0 0;
    color: var(--text-muted, #64748b);
    font-size: 12px;
    line-height: 1.35;
}

.pm-fullgrid {
    gap: 16px !important;
    align-items: start;
}
.pm-fullgrid .pm-col { padding: 0 !important; }
.pm-fullgrid .pm-col-left {
    padding-right: 0 !important;
    border-right: 0 !important;
}
.pm-fullgrid .pm-col-right { padding-left: 0 !important; }
.pm-panel {
    padding: 14px;
    margin-bottom: 14px;
}
.pm-panel--essential {
    border-color: color-mix(in srgb, var(--blue, #3b82f6) 32%, var(--border, #e2e8f0));
    background: color-mix(in srgb, var(--bg-card, #fff) 88%, var(--blue-pale, #dbeafe));
}
.pm-fullgrid .pm-sep { display: none !important; }
.pm-panel .lbl,
.pm-advanced .lbl {
    display: block;
    margin: 10px 0 5px;
    font-size: 12.5px;
    font-weight: 700;
    color: var(--text-secondary, #475569);
}
.pm-panel .inp,
.pm-panel .sel,
.pm-advanced .inp,
.pm-advanced .sel {
    min-height: 44px;
    font-size: 16px;
}
.pm-panel textarea.inp { min-height: 92px; }
.pm-inline-add {
    display: flex;
    gap: 8px;
    align-items: stretch;
}
.pm-inline-add .inp { flex: 1; margin: 0; }
.pm-touch-btn,
.pm-img-btn,
.pm-panel .btn,
.pm-advanced .btn {
    min-width: 44px;
    min-height: 44px;
}
.pm-manual-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
    margin-top: 10px;
}
.pm-subdetails,
.pm-advanced {
    border: 1px solid var(--border, #e2e8f0);
    border-radius: 12px;
    background: var(--bg-elevated, #f8fafc);
    margin-top: 10px;
    overflow: hidden;
}
.pm-subdetails > summary,
.pm-advanced > summary {
    cursor: pointer;
    min-height: 44px;
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 12px;
    color: var(--text-primary, #0f172a);
    font-weight: 800;
    list-style-position: inside;
}
.pm-advanced > summary {
    flex-direction: column;
    align-items: flex-start;
    gap: 2px;
}
.pm-advanced > summary small {
    display: block;
    font-size: 12px;
    font-weight: 500;
    color: var(--text-muted, #64748b);
}
.pm-subdetails[open] > summary,
.pm-advanced[open] > summary {
    border-bottom: 1px solid var(--border, #e2e8f0);
}
.pm-subdetails > .pm-help { padding: 0 12px; }
.pm-subdetails .pm-manual-grid { padding: 0 12px 12px; }
.pm-advanced-body { padding: 12px; }
.pm-advanced-body .pm-panel {
    background: var(--bg-card, #fff);
    margin-bottom: 12px;
}
.pm-advanced-body .pm-panel:last-child { margin-bottom: 0; }

.pm-ean-tag {
    min-height: 32px;
    padding: 4px 8px;
    border-radius: 999px;
}
.pm-ean-tag button {
    min-width: 28px;
    min-height: 28px;
    border-radius: 999px;
}

body[data-page="products"] .modal-footer {
    gap: 10px;
    padding: 14px 18px;
    border-top: 1px solid var(--border, #e2e8f0);
    background: color-mix(in srgb, var(--bg-card, #fff) 94%, var(--bg-elevated, #f8fafc));
}
body[data-page="products"] .modal-footer .btn {
    min-height: 48px;
    padding-inline: 18px;
}
body[data-page="products"] .modal-close {
    min-width: 44px;
    min-height: 44px;
}
body[data-page="products"] .modal :focus-visible {
    outline: 3px solid color-mix(in srgb, var(--blue, #3b82f6) 60%, transparent);
    outline-offset: 2px;
}

@media (max-width: 900px) {
    .pm-fullgrid { grid-template-columns: 1fr !important; }
    .pm-form-guide { flex-direction: column; }
    .pm-manual-grid { grid-template-columns: 1fr; }
    body[data-page="products"] .modal-footer {
        display: grid;
        grid-template-columns: 1fr;
    }
    body[data-page="products"] .modal-footer .btn { width: 100%; }
}

@media (max-width: 600px) {
    body[data-page="products"] .modal-overlay .modal {
        width: 100vw !important;
        max-width: 100vw !important;
        height: 100dvh !important;
        max-height: 100dvh !important;
        border-radius: 0 !important;
    }
    body[data-page="products"] .modal-hdr,
    body[data-page="products"] .modal-footer {
        padding-left: max(14px, env(safe-area-inset-left));
        padding-right: max(14px, env(safe-area-inset-right));
    }
    body[data-page="products"] .modal-body {
        padding-left: max(12px, env(safe-area-inset-left));
        padding-right: max(12px, env(safe-area-inset-right));
    }
    .pm-panel { padding: 12px; border-radius: 12px; }
}
