@extends('layouts.app')

@section('title', 'QR Label Preview')

@section('content')
    <x-page-header
        title="Label Preview"
        :subtitle="trans_choice(':count label|:count labels', count($assetIds), ['count' => count($assetIds)]).' · '.$template->label()">
        <x-slot:breadcrumbs>
            <li class="breadcrumb-item"><a href="{{ route('assets.qr.bulk') }}">QR Labels</a></li>
            <li class="breadcrumb-item active" aria-current="page">Preview</li>
        </x-slot:breadcrumbs>

        <a href="{{ route('assets.qr.bulk') }}" class="btn btn-outline-secondary">
            <i class="bi bi-arrow-left" aria-hidden="true"></i>Back to Selection
        </a>

        <button type="button" class="btn btn-outline-secondary" data-ams-print>
            <i class="bi bi-printer" aria-hidden="true"></i>Print
        </button>

        <form method="POST" action="{{ route('assets.qr.bulk.pdf') }}" class="d-inline">
            @csrf
            <input type="hidden" name="template" value="{{ $template->value }}">
            @foreach ($assetIds as $id)
                <input type="hidden" name="asset_ids[]" value="{{ $id }}">
            @endforeach
            <button type="submit" class="btn btn-primary">
                <i class="bi bi-download" aria-hidden="true"></i>Download PDF
            </button>
        </form>
    </x-page-header>

    <div class="card ams-no-print mb-3">
        <div class="card-body">
            <p class="ams-text-xs text-secondary mb-0">
                This is exactly what the downloaded PDF will contain. Use your browser's print dialog
                for a quick print, or download the PDF for the sharpest, most reliable print quality
                on your label stationery.
            </p>
        </div>
    </div>

    <div class="ams-label-sheet-wrapper" style="overflow-x: auto;">
        @include('assets.qr._label-grid', ['labels' => $labels, 'template' => $template])
    </div>
@endsection
