@extends('layouts.public-document')
@section('title', ($purchaseBillTitle ?? 'Purchase Bill') . ' ' . $purchaseBill->bill_number)

@section('content')
<div class="billing-public-invoice">
    <div class="billing-public-invoice__toolbar no-print">
        <div class="billing-public-invoice__brand">
            <strong>{{ $company->name ?? 'Company' }}</strong>
        </div>
        <div class="d-flex gap-2">
            <a href="{{ route('public.purchase-bills.pdf', ['token' => $shareToken]) }}" class="btn billing-public-invoice__btn-export">
                <i class="ri-download-2-line me-1"></i> Download PDF
            </a>
            <a href="{{ route('public.purchase-bills.print', ['token' => $shareToken, 'autoprint' => 1]) }}"
               class="btn btn-light border" target="_blank" rel="noopener">
                <i class="ri-printer-line me-1"></i> Print
            </a>
        </div>
    </div>

    <div class="billing-public-invoice__meta card border-0 shadow-sm mb-3 no-print">
        <div class="card-body py-3 d-flex flex-wrap gap-4 small">
            <div><span class="label">Purchase Bill #</span> <strong>{{ $purchaseBill->bill_number }}</strong></div>
            <div><span class="label">Issue Date</span> <strong>{{ $purchaseBill->bill_date?->format('d - M - Y') ?? '—' }}</strong></div>
            <div><span class="label">Amount</span> <strong>₹ {{ number_format((float) $purchaseBill->grand_total, 2) }}</strong></div>
        </div>
    </div>

    <div class="billing-public-invoice__document">
        <div class="billing-invoice-preview__canvas p-3 p-lg-4">
            @include('admin.purchase-bills.partials._document', [
                'forPublic' => true,
                'documentCopyLabel' => $documentCopyLabel ?? 'Original Copy',
            ])
        </div>
    </div>
</div>
@endsection

@push('styles')
<link href="{{ asset('css/billing-invoice-document.css') }}" rel="stylesheet">
<link href="{{ asset('css/billing-invoice-preview.css') }}" rel="stylesheet">
@endpush
