<!DOCTYPE html>
<html>
<head>
    <meta charset="UTF-8">
    <title>{{ __('Customer Receive') }} — {{ $customerReceive->reference_no }}</title>
    <script src="https://cdn.tailwindcss.com"></script>
    <link href="https://fonts.googleapis.com/css2?family=DM+Sans:ital,opsz,wght@0,9..40,400;0,9..40,500;0,9..40,600;0,9..40,700&display=swap" rel="stylesheet">
    <link rel="stylesheet" href="{{ asset('public/backend_assets/css/invoice-all.css') }}?v={{ @filemtime(public_path('backend_assets/css/invoice-all.css')) ?: time() }}" />   
    <style>
        body { font-family: DejaVu Sans, sans-serif; font-size: 11pt; color: #222; }
        h2 { font-size: 16pt; margin: 0 0 6px; }
        h3 { font-size: 13pt; margin: 14px 0 8px; border-bottom: 1px solid #ccc; padding-bottom: 4px; }
        .muted { color: #555; font-size: 10pt; }
        table.layout { width: 100%; border-collapse: collapse; }
        table.layout td { vertical-align: top; padding: 4px 8px 4px 0; }
        table.info { width: 100%; border-collapse: collapse; margin-top: 6px; }
        table.info td { padding: 3px 6px 3px 0; font-size: 10pt; }
        table.info td:first-child { width: 32%; color: #444; }
        .amount { font-weight: bold; font-size: 12pt; }
    </style>
</head>
<body>
    @php $invoice_logo = session('company.invoice_logo'); @endphp

    <table>
        <tr>
            <td width="50%" class="company-info">
                <h2>{{ session('company.business_name', '') }}</h2>
                @if($customerReceive->outlet)
                    <p class="muted">{{ __('Outlet') }}: {{ $customerReceive->outlet->outlet_name ?? '' }}
                        @if($customerReceive->outlet->phone) | {{ __('Phone') }}: {{ $customerReceive->outlet->phone }} @endif
                    </p>
                    @if($customerReceive->outlet->address)
                        <p class="muted">{{ __('Address') }}: {{ $customerReceive->outlet->address }}</p>
                    @endif
                @endif
            </td>
            <td width="50%" class="invoice-info" style="text-align:center; vertical-align:middle;">
                <div>
                    <img src="{{ asset('public/uploads/site_settings/' . $invoice_logo) }}" alt="Logo" class="logo">
                </div>
            </td>
        </tr>
    </table>
    
    <h3>{{ __('Customer Receive') }}</h3>

    <table class="layout">
        <tr>
            <td width="50%">
                <strong>{{ __('Customer') }}</strong>
                <table class="info">
                    @if($customerReceive->customer)
                        @if($customerReceive->customer->name)
                            <tr><td>{{ __('Name') }}</td><td>{{ $customerReceive->customer->name }}</td></tr>
                        @endif
                        @if($customerReceive->customer->phone ?? null)
                            <tr><td>{{ __('Phone') }}</td><td>{{ $customerReceive->customer->phone }}</td></tr>
                        @endif
                        @if($customerReceive->customer->email ?? null)
                            <tr><td>{{ __('Email') }}</td><td>{{ $customerReceive->customer->email }}</td></tr>
                        @endif
                        @if($customerReceive->customer->address ?? null)
                            <tr><td>{{ __('Address') }}</td><td>{{ $customerReceive->customer->address }}</td></tr>
                        @endif
                    @endif
                </table>
            </td>
            <td width="50%">
                <strong>{{ __('Details') }}</strong>
                <table class="info">
                    <tr><td>{{ __('reference_no') }}</td><td>{{ $customerReceive->reference_no }}</td></tr>
                    <tr><td>{{ __('Date') }}</td><td>{{ formatDate($customerReceive->date) }}</td></tr>
                    @if($customerReceive->payment)
                        <tr><td>{{ __('Account') }}</td><td>{{ $customerReceive->payment->name }}</td></tr>
                    @endif
                    <tr><td>{{ __('Amount') }}</td><td class="amount">{{ formatAmount($customerReceive->amount) }}</td></tr>
                    @if($customerReceive->user)
                        <tr><td>{{ __('Received By') }}</td><td>{{ $customerReceive->user->name ?? '' }}</td></tr>
                    @endif
                </table>
            </td>
        </tr>
    </table>

    @if($customerReceive->note)
        <h3>{{ __('Note') }}</h3>
        <p>{{ $customerReceive->note }}</p>
    @endif
</body>
</html>
