<!DOCTYPE html>
<html>
<head>
    <meta charset="UTF-8">
    <title>Etichete piese</title>
    <style>
        @page { size: A4; margin: 10mm; }
        * { box-sizing: border-box; }
        body { font-family: system-ui, -apple-system, sans-serif; margin: 0; padding: 12px; }

        .toolbar {
            display: flex; justify-content: space-between; align-items: center;
            margin-bottom: 16px; padding: 12px;
            background: #f3f4f6; border-radius: 8px;
        }
        @media print { .toolbar { display: none; } }
        .btn {
            padding: 8px 16px; background: #3b82f6; color: #fff;
            border: 0; border-radius: 6px; cursor: pointer; font-size: 14px;
        }

        .grid {
            display: grid;
            grid-template-columns: repeat(3, 1fr);
            gap: 6mm;
        }
        .label {
            border: 1px dashed #cbd5e1; padding: 6mm;
            text-align: center; page-break-inside: avoid;
            min-height: 60mm; display: flex; flex-direction: column;
            align-items: center; justify-content: space-between;
        }
        .label .qr { width: 80%; max-width: 35mm; }
        .label .name { font-size: 10pt; font-weight: 600; margin: 4mm 0 1mm; line-height: 1.2; }
        .label .code { font-family: 'Menlo', 'Consolas', monospace; font-size: 9pt; color: #475569; }
        .label .brand { font-size: 8pt; color: #94a3b8; }
        @media print {
            .label { border-style: solid; border-color: #e2e8f0; }
        }
    </style>
</head>
<body>
    <div class="toolbar">
        <strong>{{ $labels->count() }} etichete</strong>
        <button class="btn" onclick="window.print()">🖨 Tipărește</button>
    </div>

    <div class="grid">
        @foreach ($labels as $lbl)
            <div class="label">
                <div class="qr">{!! $lbl['svg'] !!}</div>
                <div>
                    <div class="name">{{ $lbl['part']->name }}</div>
                    @if ($lbl['part']->article)
                        <div class="code">{{ $lbl['part']->article }}</div>
                    @endif
                    @if ($lbl['part']->brand)
                        <div class="brand">{{ $lbl['part']->brand }}</div>
                    @endif
                </div>
            </div>
        @endforeach
    </div>
</body>
</html>
