<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <title>{{ $specimen->specimen_no }}</title>
    <style>
        body { font-family: DejaVu Sans, Arial, sans-serif; text-align: center; margin: 0; padding: 12px; }
        .label { border: 1px solid #000; display: inline-block; padding: 10px 16px; }
        .no { font-size: 16px; font-weight: bold; letter-spacing: 1px; margin-top: 4px; }
        .meta { font-size: 11px; color: #333; }
        @media print { .noprint { display: none; } }
    </style>
</head>
<body onload="if(!window.location.hash){window.print();}">
    <div class="label">
        @php
            // Render a real CODE128 barcode when the ERP's milon/barcode facade is
            // available; otherwise fall back to a styled specimen number.
            $barcode = null;
            try {
                if (class_exists(\Milon\Barcode\Facades\DNS1DFacade::class)) {
                    $barcode = \Milon\Barcode\Facades\DNS1DFacade::getBarcodeHTML($specimen->specimen_no, 'C128', 1.6, 55);
                }
            } catch (\Throwable $e) { $barcode = null; }
        @endphp

        @if($barcode)
            {!! $barcode !!}
        @else
            <div style="font-family:monospace;font-size:28px;letter-spacing:6px;border-top:2px solid #000;border-bottom:2px solid #000;padding:6px 0;">||| {{ $specimen->specimen_no }} |||</div>
        @endif

        <div class="no">{{ $specimen->specimen_no }}</div>
        <div class="meta">{{ ucfirst($specimen->specimen_type) }}
            @if($specimen->catalog) · {{ $specimen->catalog->name }} @endif</div>
    </div>
    <p class="noprint" style="margin-top:12px;">
        <button onclick="window.print()">Print</button>
        <a href="{{ url()->previous() }}">Back</a>
    </p>
</body>
</html>
