<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Invoice {{ $invoice->invoice_number ?? '' }}</title>
    @include('invoices.templates.partials._pdf-head-compact')
</head>
<body>
<div class="pdf-wrap" style="max-width:100%;">
<table style="width:100%; border-collapse:collapse; font-family:DejaVu Sans, sans-serif; font-size:14px;">
    @if(!empty($showWatermark))
    <tr>
        <td style="padding:10px 12px; text-align:center; background-color:#fef2f2; color:#dc2626; font-weight:bold; font-size:14px;">UNLICENSED COPY</td>
    </tr>
    @endif

    <tr>
        <td style="padding:0 0 14px 0;" class="pdf-section">
            <table style="width:100%; border-collapse:collapse; background-color:#137fec; color:#ffffff;">
                <tr>
                    <td style="width:62%; vertical-align:top; padding:14px 16px;">
                        @if($logoDataUri)
                            <img src="{{ $logoDataUri }}" alt="" style="max-width:190px; max-height:60px;">
                        @endif
                        <div style="font-size:18px; font-weight:bold; padding-top:8px;">{{ $companySettings->company_name ?? config('app.name') }}</div>
                        <div style="font-size:12px; line-height:1.45; opacity:0.95;">
                            @if($companySettings->company_address){{ $companySettings->company_address }}@endif
                            @if($companySettings->company_phone)@if($companySettings->company_address) — @endif{{ $companySettings->company_phone }}@endif
                            @if($companySettings->company_email)@if($companySettings->company_address || $companySettings->company_phone) — @endif{{ $companySettings->company_email }}@endif
                        </div>
                    </td>
                    <td style="width:38%; vertical-align:top; padding:14px 16px;">
                        <table style="width:100%; border-collapse:collapse; background-color:#ffffff; color:#111827;">
                            <tr>
                                <td style="padding:10px 12px; font-size:11px; text-transform:uppercase; color:#6b7280;">Invoice Details</td>
                            </tr>
                            <tr>
                                <td style="padding:0 12px 6px 12px; font-size:13px; color:#6b7280; line-height:1.55;">
                                    <div><strong>Status:</strong> {{ ucfirst($invoice->status ?? 'Draft') }}</div>
                                    <div><strong>Currency:</strong> {{ $invoice->currency ?? 'USD' }}</div>
                                </td>
                            </tr>
                        </table>
                    </td>
                </tr>
            </table>
        </td>
    </tr>

    <tr>
        <td style="padding:0 0 14px 0;" class="pdf-section">
            <table style="width:100%; border-collapse:collapse;">
                <tr>
                    <td style="width:50%; vertical-align:top; padding:8px;">
                        <table style="width:100%; border-collapse:collapse; border:1px solid #e5e7eb;">
                            <tr><td style="padding:10px 12px; font-size:11px; font-weight:bold; text-transform:uppercase; color:#137fec;">Bill to</td></tr>
                            <tr><td style="padding:0 12px 12px 12px;">
                                @if($invoice->customer)
                                    <div style="font-size:15px; font-weight:600;">{{ $invoice->customer->name }}</div>
                                    <div style="font-size:13px; color:#111827; line-height:1.45;">
                                        @if($invoice->customer->email)
                                            {{ $invoice->customer->email }}@if($invoice->customer->phone || $invoice->customer->address), @endif
                                        @endif
                                        @if($invoice->customer->phone)
                                            {{ $invoice->customer->phone }}@if($invoice->customer->address), @endif
                                        @endif
                                        @if($invoice->customer->address){{ $invoice->customer->address }}@endif
                                    </div>
                                @else
                                    <span style="color:#9ca3af;">—</span>
                                @endif
                            </td></tr>
                        </table>
                    </td>
                    <td style="width:50%; vertical-align:top; padding:8px;">
                        <table style="width:100%; border-collapse:collapse; border:1px solid #e5e7eb;">
                            <tr><td style="padding:10px 12px; font-size:11px; font-weight:bold; text-transform:uppercase; color:#137fec;">Invoice Number</td></tr>
                            <tr><td style="padding:0 12px 12px 12px; font-size:13px; line-height:1.6; color:#111827;">
                                <div style="font-size:15px; font-weight:600; margin-bottom:6px;">{{ $invoice->invoice_number ?? '—' }}</div>
                                <div><strong>Issue:</strong> {{ $issueDate->format('M d, Y') }}</div>
                                <div><strong>Due:</strong> {{ $dueDate->format('M d, Y') }}</div>
                            </td></tr>
                        </table>
                    </td>
                </tr>
            </table>
        </td>
    </tr>

    @include('invoices.templates.partials._pdf-items-totals-footer', [
        'thBg' => '#f0f7ff',
        'thText' => '#111827',
        'thBorderBottom' => '#dbeafe',
        'accent' => '#137fec',
        'totalsStyle' => 'bluebox',
        'paymentBg' => '#eff6ff',
        'paymentBorder' => '#bfdbfe',
        'paymentTitle' => '#1d4ed8',
        'paymentText' => '#1e3a8a',
    ])
</table>
</div>
</body>
</html>
