<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Invoice {{ $order->order_number }}</title>
    <style>
        body { font-family: "DejaVu Sans", sans-serif; font-size: 12px; color: #111; }
        h1 { font-size: 18px; margin-bottom: 10px; }
        table { width: 100%; border-collapse: collapse; margin-top: 12px; }
        th, td { border: 1px solid #e2e8f0; padding: 6px; text-align: left; }
        th { background: #f8fafc; }
    </style>
</head>
<body>
    <h1>Invoice {{ $order->order_number }}</h1>
    <div>Member: {{ $order->user?->member_code }} - {{ $order->user?->name }}</div>
    <div>Status: {{ ucfirst($order->status) }}</div>
    <div>Approved: {{ optional($order->approved_at)->format('Y-m-d H:i') }}</div>

    <table>
        <thead>
            <tr>
                <th>Product</th>
                <th>Qty</th>
                <th>Unit Price</th>
                <th>BV</th>
                <th>Total</th>
            </tr>
        </thead>
        <tbody>
            @foreach($order->items as $item)
                <tr>
                    <td>{{ $item->product_name }}</td>
                    <td>{{ $item->quantity }}</td>
                    <td>{{ number_format((float) $item->unit_price, 2) }}</td>
                    <td>{{ number_format((float) $item->line_bv, 2) }}</td>
                    <td>{{ number_format((float) $item->line_total, 2) }}</td>
                </tr>
            @endforeach
        </tbody>
    </table>

    <table>
        <tr>
            <th>Subtotal</th>
            <td>{{ number_format((float) $order->subtotal, 2) }}</td>
        </tr>
        <tr>
            <th>Tax</th>
            <td>{{ number_format((float) $order->tax, 2) }}</td>
        </tr>
        <tr>
            <th>Shipping</th>
            <td>{{ number_format((float) $order->shipping, 2) }}</td>
        </tr>
        <tr>
            <th>Total</th>
            <td>{{ number_format((float) $order->total, 2) }}</td>
        </tr>
    </table>
</body>
</html>
