<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <title>Quotation — {{ $quotation->quotation_number }}</title>
    <style>
        body { font-family: DejaVu Sans, sans-serif; font-size: 11px; color: #111; margin: 24px; }
        .header { text-align: center; border-bottom: 3px solid #1e3a5f; padding-bottom: 12px; margin-bottom: 20px; }
        .header h1 { font-size: 20px; margin: 0; color: #1e3a5f; }
        .header p { margin: 4px 0 0; color: #555; }
        .meta { margin-bottom: 16px; }
        .meta-row { margin-bottom: 4px; }
        table { width: 100%; border-collapse: collapse; margin-bottom: 16px; }
        th, td { border: 1px solid #ccc; padding: 6px 8px; text-align: left; }
        th { background: #1e3a5f; color: #fff; }
        .text-right { text-align: right; }
        .totals td { border: none; padding: 4px 8px; }
    </style>
</head>
<body>
    <div class="header">
        <h1>{{ $schoolName }}</h1>
        <p>Quotation</p>
    </div>

    <div class="meta">
        <div class="meta-row"><strong>Quotation No:</strong> {{ $quotation->quotation_number }}</div>
        <div class="meta-row"><strong>Customer:</strong> {{ $quotation->student?->full_name ?? $quotation->customer_name }}</div>
        <div class="meta-row"><strong>Issue Date:</strong> {{ optional($quotation->issue_date)->format('d M Y') }}</div>
        <div class="meta-row"><strong>Valid Until:</strong> {{ optional($quotation->valid_until)->format('d M Y') ?? '—' }}</div>
        <div class="meta-row"><strong>Status:</strong> {{ ucfirst($quotation->status) }}</div>
    </div>

    <table>
        <thead>
            <tr>
                <th>Description</th>
                <th class="text-right">Qty</th>
                <th class="text-right">Unit Price</th>
                <th class="text-right">Total</th>
            </tr>
        </thead>
        <tbody>
            @foreach ($quotation->lines as $line)
                <tr>
                    <td>{{ $line->description }}</td>
                    <td class="text-right">{{ $line->quantity }}</td>
                    <td class="text-right">{{ number_format($line->unit_price, 2) }}</td>
                    <td class="text-right">{{ number_format($line->line_total, 2) }}</td>
                </tr>
            @endforeach
        </tbody>
    </table>

    <table class="totals" style="width: 280px; margin-left: auto;">
        <tr><td class="text-right">Subtotal:</td><td class="text-right">{{ number_format($quotation->subtotal, 2) }}</td></tr>
        <tr><td class="text-right">Tax:</td><td class="text-right">{{ number_format($quotation->tax_amount, 2) }}</td></tr>
        <tr><td class="text-right"><strong>Total:</strong></td><td class="text-right"><strong>{{ number_format($quotation->total_amount, 2) }}</strong></td></tr>
    </table>

    @if ($quotation->notes)
        <p style="margin-top: 16px; color: #555;">{{ $quotation->notes }}</p>
    @endif
</body>
</html>
