<!DOCTYPE html>
<html>
<head>
    <title>{{ $incoming->receipt_number }} - Print</title>
    <style>
        body { font-family: Arial, sans-serif; font-size: 12px; margin: 20px; }
        .header { text-align: center; margin-bottom: 20px; border-bottom: 2px solid #333; padding-bottom: 10px; }
        .header h2 { margin: 0; }
        .details { margin-bottom: 20px; }
        .details table { width: 100%; }
        .details td { padding: 4px 8px; vertical-align: top; }
        .details .label { font-weight: bold; color: #555; width: 30%; }
        .items-table { width: 100%; border-collapse: collapse; margin-bottom: 20px; }
        .items-table th, .items-table td { border: 1px solid #ddd; padding: 6px 8px; text-align: left; }
        .items-table th { background-color: #f5f5f5; font-weight: bold; }
        .totals { text-align: right; margin-top: 10px; }
        .footer { margin-top: 40px; display: flex; justify-content: space-between; }
        .signature { width: 30%; text-align: center; border-top: 1px solid #333; padding-top: 5px; }
        @media print { body { margin: 0; } }
    </style>
</head>
<body onload="window.print()">
    <div class="header">
        <h2>Fixed Asset Receipt</h2>
        <p>{{ $incoming->receipt_number }}</p>
    </div>

    <div class="details">
        <table>
            <tr><td class="label">Supplier:</td><td>{{ $incoming->supplier ? $incoming->supplier->name : '-' }}</td><td class="label">Receipt Date:</td><td>{{ $incoming->receipt_date ? $incoming->receipt_date->format('M d, Y') : '-' }}</td></tr>
            <tr><td class="label">Invoice #:</td><td>{{ $incoming->invoice_number ?? '-' }}</td><td class="label">Invoice Date:</td><td>{{ $incoming->invoice_date ? $incoming->invoice_date->format('M d, Y') : '-' }}</td></tr>
            <tr><td class="label">Status:</td><td>{{ ucfirst($incoming->status) }}</td><td class="label">Received By:</td><td>{{ $incoming->receiver ? $incoming->receiver->name : '-' }}</td></tr>
        </table>
    </div>

    <table class="items-table">
        <thead>
            <tr><th>#</th><th>Asset Name</th><th>Category</th><th>Serial #</th><th>Qty</th><th>Unit Price</th><th>Total</th></tr>
        </thead>
        <tbody>
            @foreach($incoming->items as $i => $item)
            <tr>
                <td>{{ $i + 1 }}</td>
                <td>{{ $item->asset_name }}</td>
                <td>{{ $item->category ? $item->category->category_name : '-' }}</td>
                <td>{{ $item->serial_number ?? '-' }}</td>
                <td>{{ $item->quantity }}</td>
                <td>AED {{ number_format($item->unit_price, 2) }}</td>
                <td>AED {{ number_format($item->total_price, 2) }}</td>
            </tr>
            @endforeach
        </tbody>
    </table>

    <div class="totals">
        <p><strong>Subtotal:</strong> AED {{ number_format($incoming->total_amount - ($incoming->vat_amount ?? 0), 2) }}</p>
        <p><strong>VAT ({{ $incoming->vat_rate ?? 0 }}%):</strong> AED {{ number_format($incoming->vat_amount ?? 0, 2) }}</p>
        <p style="font-size: 14px;"><strong>Total:</strong> AED {{ number_format($incoming->total_amount, 2) }}</p>
    </div>

    <div class="footer" style="display: flex; justify-content: space-between; margin-top: 60px;">
        <div class="signature">Received By</div>
        <div class="signature">Approved By</div>
        <div class="signature">Store Manager</div>
    </div>
</body>
</html>
