<!doctype html>
<html lang="en">
<head>
    <meta charset="utf-8">
    <title>Quotation — {{ $quotation->quote_no }}</title>
    <style>
        body { font-family: 'Segoe UI', Arial, sans-serif; margin: 40px; color: #111; font-size: 13px; line-height: 1.5; }
        h1 { margin: 0 0 4px 0; font-size: 24px; }
        .top { display: flex; justify-content: space-between; align-items: flex-start; }
        table { width: 100%; border-collapse: collapse; margin-top: 24px; }
        th, td { border-bottom: 1px solid #ddd; padding: 10px 8px; text-align: left; }
        th { background: #f8fafc; font-size: 11px; text-transform: uppercase; letter-spacing: 0.5px; color: #475569; }
        .total-box { text-align: right; margin-top: 24px; }
        .total-box p { margin: 4px 0; }
        .total-box h2 { margin: 8px 0 0; font-size: 18px; color: #0f766e; }
        .actions { margin-bottom: 24px; }
        .btn-print { background: #4f46e5; color: #fff; border: 0; padding: 8px 16px; border-radius: 6px; cursor: pointer; font-weight: 600; }
        @media print { .actions { display: none; } body { margin: 20px; } }
    </style>
</head>
<body>
    <div class="actions">
        <button class="btn-print" onclick="window.print()">🖨️ Print / Save as PDF</button>
    </div>

    <div class="top">
        <div>
            <h1>HIGHRA CRM</h1>
            <p style="margin: 2px 0; color: #64748b;">Quotation Reference: <strong>{{ $quotation->quote_no }}</strong></p>
        </div>
        <div style="text-align: right;">
            <div><strong>Date:</strong> {{ $quotation->created_at->format('d M Y') }}</div>
            <div><strong>Status:</strong> {{ strtoupper($quotation->status) }}</div>
        </div>
    </div>

    <hr style="border: 0; border-top: 1px solid #e2e8f0; margin: 18px 0;">

    <div style="display: flex; justify-content: space-between;">
        <div>
            <h3 style="margin: 0 0 6px 0; font-size: 13px; text-transform: uppercase; color: #64748b;">Bill To</h3>
            <strong>{{ $quotation->customer?->name ?? 'Customer' }}</strong><br>
            {{ $quotation->customer?->company }}<br>
            {{ $quotation->customer?->phone }}<br>
            {{ $quotation->customer?->email }}
        </div>
    </div>

    <table>
        <thead>
            <tr>
                <th>Description</th>
                <th>Qty</th>
                <th>Unit Price</th>
                <th>Discount</th>
                <th style="text-align: right;">Line Total</th>
            </tr>
        </thead>
        <tbody>
            @foreach($quotation->items as $i)
                <tr>
                    <td><strong>{{ $i->description }}</strong></td>
                    <td>{{ $i->quantity }}</td>
                    <td>{{ format_inr($i->unit_price) }}</td>
                    <td>{{ format_inr($i->discount) }}</td>
                    <td style="text-align: right;"><strong>{{ format_inr($i->line_total) }}</strong></td>
                </tr>
            @endforeach
        </tbody>
    </table>

    <div class="total-box">
        <p>Subtotal: <strong>{{ format_inr($quotation->subtotal) }}</strong></p>
        <p>Tax / GST: <strong>{{ format_inr($quotation->tax) }}</strong></p>
        <h2>Total Amount: {{ format_inr($quotation->total) }}</h2>
    </div>

    @if($quotation->notes)
        <div style="margin-top: 30px; padding: 14px; background: #f8fafc; border-radius: 6px; border: 1px solid #e2e8f0;">
            <strong style="display: block; margin-bottom: 4px; font-size: 11px; text-transform: uppercase; color: #64748b;">Terms & Notes</strong>
            <div style="color: #334155; white-space: pre-wrap;">{{ $quotation->notes }}</div>
        </div>
    @endif
</body>
</html>
