<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <title>Receipt {{ $receipt->receipt_number }}</title>
    <style>
        * {
            margin: 0;
            padding: 0;
            box-sizing: border-box;
        }
        body {
            font-family: 'DejaVu Sans', Arial, sans-serif;
            font-size: 12px;
            color: #333;
            line-height: 1.6;
        }
        .container {
            max-width: 800px;
            margin: 0 auto;
            padding: 40px;
        }
        .header {
            display: flex;
            justify-content: space-between;
            align-items: flex-start;
            margin-bottom: 40px;
            padding-bottom: 20px;
            border-bottom: 2px solid #e5e7eb;
        }
        .company-info h1 {
            font-size: 24px;
            font-weight: bold;
            color: #111418;
            margin-bottom: 10px;
        }
        .company-info p {
            color: #617589;
            font-size: 11px;
        }
        .receipt-title {
            text-align: right;
        }
        .receipt-title h2 {
            font-size: 32px;
            font-weight: bold;
            color: #137fec;
            margin-bottom: 10px;
        }
        .receipt-title p {
            color: #617589;
            font-size: 11px;
            margin: 3px 0;
        }
        .details {
            display: table;
            width: 100%;
            margin-bottom: 40px;
        }
        .details-row {
            display: table-row;
        }
        .details-cell {
            display: table-cell;
            width: 50%;
            vertical-align: top;
            padding: 0 20px 0 0;
        }
        .details-cell:last-child {
            padding: 0 0 0 20px;
        }
        .section-title {
            font-size: 10px;
            font-weight: bold;
            color: #617589;
            text-transform: uppercase;
            letter-spacing: 1px;
            margin-bottom: 15px;
        }
        .customer-name {
            font-size: 16px;
            font-weight: bold;
            color: #111418;
            margin-bottom: 8px;
        }
        .customer-info {
            color: #617589;
            font-size: 11px;
            line-height: 1.8;
        }
        .amount-section {
            background-color: #f3f4f6;
            padding: 30px;
            border-radius: 8px;
            margin-bottom: 40px;
            text-align: center;
        }
        .amount-label {
            font-size: 11px;
            color: #617589;
            margin-bottom: 10px;
        }
        .amount-value {
            font-size: 48px;
            font-weight: bold;
            color: #137fec;
        }
        .payment-details {
            margin-bottom: 30px;
        }
        .payment-details p {
            margin: 5px 0;
            font-size: 11px;
        }
        .payment-details strong {
            color: #111418;
        }
        .notes {
            margin-top: 30px;
            padding-top: 20px;
            border-top: 1px solid #e5e7eb;
        }
        .notes-title {
            font-size: 10px;
            font-weight: bold;
            color: #617589;
            text-transform: uppercase;
            margin-bottom: 10px;
        }
        .notes-content {
            color: #333;
            font-size: 11px;
            line-height: 1.8;
        }
        .footer {
            margin-top: 40px;
            padding-top: 20px;
            border-top: 1px solid #e5e7eb;
            text-align: center;
            color: #617589;
            font-size: 11px;
        }
    </style>
</head>
<body>
    <div class="container">
        @php
            $companySettings = \App\Models\CompanySetting::getSettings();
        @endphp

        <!-- Header -->
        <div class="header">
            <div class="company-info">
                <h1>{{ $companySettings->company_name ?? 'Company Name' }}</h1>
                @if($companySettings->company_address)
                    <p>{{ $companySettings->company_address }}</p>
                @endif
                @if($companySettings->company_city || $companySettings->company_state || $companySettings->company_zip)
                    <p>
                        {{ $companySettings->company_city }}{{ $companySettings->company_city && $companySettings->company_state ? ', ' : '' }}
                        {{ $companySettings->company_state }} {{ $companySettings->company_zip }}
                    </p>
                @endif
                @if($companySettings->company_country)
                    <p>{{ $companySettings->company_country }}</p>
                @endif
            </div>
            <div class="receipt-title">
                <h2>RECEIPT</h2>
                <p><strong>Receipt #:</strong> {{ $receipt->receipt_number }}</p>
                <p><strong>Date:</strong> {{ $receipt->created_at->format('M d, Y') }}</p>
            </div>
        </div>

        <!-- Details -->
        <div class="details">
            <div class="details-row">
                <div class="details-cell">
                    <div class="section-title">Received From</div>
                    <div class="customer-name">{{ $receipt->customer->name }}</div>
                    <div class="customer-info">
                        @if($receipt->customer->email)
                            {{ $receipt->customer->email }}<br>
                        @endif
                        @if($receipt->customer->phone)
                            {{ $receipt->customer->phone }}<br>
                        @endif
                        @if($receipt->customer->address)
                            {{ $receipt->customer->address }}<br>
                        @endif
                        @if($receipt->customer->city || $receipt->customer->state || $receipt->customer->zip)
                            {{ $receipt->customer->city }}{{ $receipt->customer->city && $receipt->customer->state ? ', ' : '' }}{{ $receipt->customer->state }} {{ $receipt->customer->zip }}<br>
                        @endif
                        @if($receipt->customer->country)
                            {{ $receipt->customer->country }}
                        @endif
                    </div>
                </div>
                <div class="details-cell">
                    <div class="section-title">Payment Details</div>
                    <div class="payment-details">
                        <p><strong>Invoice Number:</strong> {{ $receipt->invoice->invoice_number }}</p>
                        <p><strong>Payment Method:</strong> {{ ucfirst(str_replace('_', ' ', $receipt->payment_method)) }}</p>
                        @if($receipt->transaction_reference)
                            <p><strong>Transaction Reference:</strong> {{ $receipt->transaction_reference }}</p>
                        @endif
                    </div>
                </div>
            </div>
        </div>

        <!-- Amount Section -->
        <div class="amount-section">
            <div class="amount-label">Amount Received</div>
            <div class="amount-value">${{ number_format($receipt->amount, 2) }}</div>
        </div>

        <!-- Notes -->
        @if($receipt->notes)
            <div class="notes">
                <div class="notes-title">Notes</div>
                <div class="notes-content">{{ $receipt->notes }}</div>
            </div>
        @endif

        <!-- Footer -->
        <div class="footer">
            <p>Thank you for your payment!</p>
            @if($companySettings->company_email)
                <p style="margin-top: 10px;">For inquiries, contact: {{ $companySettings->company_email }}</p>
            @endif
        </div>
    </div>
</body>
</html>
