@php
    $url = $wo->trackingUrl();
    $qrSvg = (new \chillerlan\QRCode\QRCode(new \chillerlan\QRCode\QROptions([
        'outputType' => \chillerlan\QRCode\QRCode::OUTPUT_MARKUP_SVG,
        'eccLevel' => \chillerlan\QRCode\QRCode::ECC_M,
        'scale' => 8,
        'imageBase64' => false,
        'addQuietzone' => true,
    ])))->render($url);
@endphp
<div class="space-y-4">
    <p class="text-sm text-gray-600 dark:text-gray-300">
        Trimite acest link clientului — vede statusul fișei, ETA și fotografiile fără să se logheze.
    </p>

    <div class="flex justify-center bg-white rounded-lg p-4 border border-gray-200 dark:border-gray-700">
        <div style="max-width: 240px;">{!! $qrSvg !!}</div>
    </div>

    <div class="space-y-2">
        <label class="block text-xs font-medium text-gray-500 dark:text-gray-400 uppercase tracking-wide">Link</label>
        <div class="flex gap-2">
            <input
                type="text"
                value="{{ $url }}"
                readonly
                onclick="this.select()"
                class="flex-1 text-sm rounded-md border-gray-300 dark:border-gray-600 dark:bg-gray-800 dark:text-gray-100 font-mono px-3 py-2"
            >
            <a
                href="{{ $url }}"
                target="_blank"
                rel="noopener"
                class="inline-flex items-center px-3 py-2 text-sm rounded-md bg-primary-600 text-white hover:bg-primary-700"
            >
                Deschide →
            </a>
        </div>
    </div>

    <div class="flex gap-2">
        <a
            href="{{ route('tracking.qr', $wo->tracking_token) }}"
            download="WO-{{ $wo->number }}-qr.svg"
            class="text-xs text-primary-600 hover:underline"
        >Descarcă QR (SVG)</a>
    </div>
</div>
