/* ===== App Styles ===== */
body { font-family: 'Segoe UI', sans-serif; }

.navbar-brand { font-weight: 700; letter-spacing: 1px; }

.table-hover tbody tr:hover { cursor: pointer; background: #f0f7ff; }

.badge-code128 { background: #0d6efd; }
.badge-qrcode  { background: #6f42c1; }

/* ===== Label Preview Area ===== */
#print-area {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
    padding: 8px;
    background: #e9ecef;
    border-radius: 6px;
    min-height: 100px;
}

/* ===== Base Label ===== */
.label-wrap {
    display: inline-flex;
    box-sizing: border-box;
    background: #fff;
    border: 1px solid #999;
    overflow: hidden;
    page-break-inside: avoid;
    break-inside: avoid;
}

/* Small: 3cm × 2cm */
.label-small {
    width:  3cm;
    height: 2cm;
}

/* Large: 10.16cm × 10.16cm */
.label-large {
    width:  10.16cm;
    height: 10.16cm;
}

/* ===== Design 1 — Standard ===== */
.design-1 {
    flex-direction: column;
    align-items: center;
    justify-content: space-between;
    padding: 1mm;
    text-align: center;
}
.design-1 .lbl-shop   { font-size: 5pt; font-weight: 700; text-transform: uppercase; line-height: 1; }
.design-1 .lbl-name   { font-size: 5pt; line-height: 1.1; word-break: break-word; }
.design-1 .lbl-bc     { width: 100%; flex: 1; display: flex; align-items: center; justify-content: center; }
.design-1 .lbl-bc svg,
.design-1 .lbl-bc canvas,
.design-1 .lbl-bc img { max-width: 100%; max-height: 100%; }
.design-1 .lbl-footer { font-size: 4.5pt; display: flex; justify-content: space-between; width: 100%; }
.design-1 .lbl-price  { font-weight: 700; }

/* Large variant adjustments */
.label-large.design-1 .lbl-shop  { font-size: 14pt; }
.label-large.design-1 .lbl-name  { font-size: 12pt; }
.label-large.design-1 .lbl-footer{ font-size: 11pt; }

/* ===== Design 2 — Price Tag ===== */
.design-2 {
    flex-direction: column;
    align-items: center;
    justify-content: space-between;
    padding: 1mm;
    text-align: center;
}
.design-2 .lbl-name   { font-size: 5pt; font-weight: 600; line-height: 1; }
.design-2 .lbl-bc     { width: 100%; flex: 1; display: flex; align-items: center; justify-content: center; }
.design-2 .lbl-bc svg,
.design-2 .lbl-bc canvas,
.design-2 .lbl-bc img { max-width: 100%; max-height: 100%; }
.design-2 .lbl-shop   { font-size: 3.5pt; color: #555; }
.design-2 .lbl-price  { font-size: 8pt; font-weight: 800; align-self: flex-end; }

.label-large.design-2 .lbl-name  { font-size: 14pt; }
.label-large.design-2 .lbl-shop  { font-size: 10pt; }
.label-large.design-2 .lbl-price { font-size: 28pt; }

/* ===== Design 3 — Name Only (no price) ===== */
.design-3 {
    flex-direction: column;
    align-items: center;
    justify-content: space-between;
    padding: 1mm;
    text-align: center;
}
.design-3 .lbl-shop   { font-size: 5pt; font-weight: 700; text-transform: uppercase; }
.design-3 .lbl-name   { font-size: 5pt; line-height: 1.1; word-break: break-word; }
.design-3 .lbl-bc     { width: 100%; flex: 1; display: flex; align-items: center; justify-content: center; }
.design-3 .lbl-bc svg,
.design-3 .lbl-bc canvas,
.design-3 .lbl-bc img { max-width: 100%; max-height: 100%; }
.design-3 .lbl-code   { font-size: 4pt; }

.label-large.design-3 .lbl-shop  { font-size: 14pt; }
.label-large.design-3 .lbl-name  { font-size: 12pt; }
.label-large.design-3 .lbl-code  { font-size: 11pt; }

/* ===== Design 4 — With Logo ===== */
.design-4 {
    flex-direction: row;
    align-items: stretch;
}
.design-4 .lbl-logo-col {
    width: 25%;
    display: flex;
    align-items: center;
    justify-content: center;
    border-right: 0.5pt solid #ccc;
    padding: 1mm;
}
.design-4 .lbl-logo-col img { max-width: 100%; max-height: 100%; object-fit: contain; }
.design-4 .lbl-logo-col .lbl-logo-placeholder { font-size: 4pt; color: #aaa; text-align: center; }
.design-4 .lbl-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: space-between;
    padding: 1mm;
    text-align: center;
}
.design-4 .lbl-shop   { font-size: 5pt; font-weight: 700; text-transform: uppercase; line-height: 1; }
.design-4 .lbl-name   { font-size: 4.5pt; line-height: 1.1; word-break: break-word; }
.design-4 .lbl-bc     { width: 100%; flex: 1; display: flex; align-items: center; justify-content: center; }
.design-4 .lbl-bc svg,
.design-4 .lbl-bc canvas,
.design-4 .lbl-bc img { max-width: 100%; max-height: 100%; }
.design-4 .lbl-footer { font-size: 4pt; display: flex; justify-content: space-between; width: 100%; }
.design-4 .lbl-price  { font-weight: 700; }

.label-large.design-4 .lbl-shop  { font-size: 14pt; }
.label-large.design-4 .lbl-name  { font-size: 12pt; }
.label-large.design-4 .lbl-footer{ font-size: 10pt; }

/* ===== Design 5 — Minimal (barcode only) ===== */
.design-5 {
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 0.5mm;
}
.design-5 .lbl-bc     { width: 100%; flex: 1; display: flex; align-items: center; justify-content: center; }
.design-5 .lbl-bc svg,
.design-5 .lbl-bc canvas,
.design-5 .lbl-bc img { max-width: 100%; max-height: 100%; }
.design-5 .lbl-code   { font-size: 4pt; text-align: center; }

.label-large.design-5 .lbl-code  { font-size: 12pt; }

/* ===== Multi-barcode Grid Label ===== */
/* Reset all inherited colors inside grid cells so nothing goes orange/blue */
.label-grid * { color: #000 !important; font-family: Arial, Helvetica, sans-serif; }

.label-grid {
    display: grid !important;
    flex-direction: unset;
    padding: 1.5mm;
    gap: 1mm;
    box-sizing: border-box;
}

/* Each cell — CSS Grid so each row gets an exact slice of height */
.grid-cell {
    display: grid;
    grid-template-rows: auto auto 1fr auto;
    /* rows: shop-name | product-name | barcode (fills remaining) | footer */
    border: 0.5pt solid #aaa;
    border-radius: 0.5mm;
    padding: 1mm 0.8mm 0.5mm;
    overflow: hidden;
    box-sizing: border-box;
    text-align: center;
    background: #fff;
}
.grid-cell-empty {
    background: #f8f8f8;
    border: 0.5pt dashed #ccc !important;
}

/* Shop name */
.gc-shop {
    font-size: 4.5pt;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 0.4pt;
    color: #000 !important;
    line-height: 1.3;
    padding-bottom: 0.3mm;
    border-bottom: 0.4pt solid #333;
    margin-bottom: 0.3mm;
}

/* Product name */
.gc-name {
    font-size: 4pt;
    font-weight: 600;
    line-height: 1.2;
    word-break: break-word;
    color: #111 !important;
    padding: 0.2mm 0;
}

/* Barcode area — gets 1fr, SVG stretches to fill with no gaps */
.gc-bc {
    width: 100%;
    height: 100%;
    min-height: 0;
    overflow: hidden;
    display: flex;
    align-items: stretch;
}
.gc-bc svg {
    width:  100% !important;
    height: 100% !important;
    display: block;
    /* none = stretch to fill; bars scale uniformly, still scannable */
    preserveAspectRatio: none;
}
.gc-bc img {
    width: 100% !important;
    height: 100% !important;
    display: block;
    object-fit: fill;
}

/* Footer */
.gc-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding-top: 0.3mm;
    border-top: 0.3pt solid #ddd;
    margin-top: 0.2mm;
}
.gc-code  { font-size: 3.5pt; color: #444 !important; font-family: monospace; }
.gc-price { font-size: 4.5pt; font-weight: 800; color: #000 !important; }

/* ===== Design thumbnails on print page ===== */
.design-thumb {
    cursor: pointer;
    border: 2px solid #dee2e6;
    border-radius: 6px;
    padding: 6px;
    text-align: center;
    transition: border-color .15s;
}
.design-thumb:hover   { border-color: #0d6efd; }
.design-thumb.active  { border-color: #0d6efd; background: #e7f0ff; }
.design-thumb svg     { width: 100%; height: auto; }

/* ===== PRINT MEDIA ===== */
@media print {
    /* Hide everything that is NOT the print area */
    nav,
    .no-print {
        display: none !important;
    }

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

    /* Remove container padding so labels sit at page edge */
    .container-fluid {
        padding: 0 !important;
        margin: 0 !important;
        max-width: 100% !important;
    }

    #print-wrapper {
        display: block !important;
        margin: 0;
        padding: 0;
    }

    #print-area {
        display: flex !important;
        flex-wrap: wrap !important;
        background: none !important;
        border: none !important;
        border-radius: 0 !important;
        padding: 0 !important;
        gap: 0 !important;
        align-content: flex-start;
        min-height: unset !important;
    }

    .label-wrap {
        border: 0.3pt solid #aaa !important;
        margin: 0 !important;
        page-break-inside: avoid;
        break-inside: avoid;
        overflow: hidden;
    }

    /* Ensure barcode SVGs and images render in print */
    .lbl-bc svg { display: block !important; }
    .lbl-bc img { display: block !important; }
    .lbl-bc canvas { display: none !important; } /* hide canvas; use img copy instead */
}
