<!DOCTYPE html>
<html>
<head>
    <meta charset="UTF-8">
    <title>Claim {{ $claim->reference_number }}</title>
    <link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.2/dist/css/bootstrap.min.css" rel="stylesheet">
</head>
<body class="bg-light">

<div class="container my-4">

<div class="card shadow-sm">

    {{-- HEADER --}}
    <div class="card-header bg-white">
        <h5 class="mb-0">Approved Claim – Underwriter Review</h5>
        <small class="text-muted">
            Reference: {{ $claim->reference_number }}
        </small>
    </div>

    <div class="card-body small">

        {{-- STATUS --}}
        <p>
            <strong>Status:</strong>
            <span class="badge bg-success">Approved</span>
        </p>

        <hr>

        {{-- POLICY HOLDER --}}
        <h6 class="text-primary">Policy Holder</h6>
        <p><strong>Name:</strong> {{ $claim->policyHolder->name }} {{ $claim->policyHolder->surname }}</p>
        <p><strong>National ID:</strong> {{ $claim->policyHolder->national_id }}</p>
        <p><strong>Phone:</strong> {{ $claim->policyHolder->cell_number }}</p>

        <hr>

        {{-- CLAIMANT --}}
        <h6 class="text-primary">Claimant</h6>
        <p><strong>Name:</strong> {{ $claim->claimant_full_name }}</p>
        <p><strong>National ID:</strong> {{ $claim->claimant_national_id ?? 'N/A' }}</p>
        <p><strong>Phone:</strong> {{ $claim->claimant_phone ?? 'N/A' }}</p>
        <p><strong>Relationship:</strong> {{ $claim->relationship_to_policyholder }}</p>

        <hr>

        {{-- DECEASED --}}
        <h6 class="text-primary">Deceased Details</h6>
        <p><strong>Name:</strong> {{ $claim->deceased_full_name }}</p>
        <p><strong>National ID:</strong> {{ $claim->deceased_national_id }}</p>
        <p><strong>Gender:</strong> {{ $claim->deceased_gender }}</p>
        <p><strong>Date of Birth:</strong> {{ $claim->deceased_date_of_birth }}</p>
        <p><strong>Type:</strong> {{ $claim->deceased_type }}</p>

        <hr>

        {{-- CLAIM INFO --}}
        <h6 class="text-primary">Claim Information</h6>
        <p><strong>Date of Death:</strong> {{ $claim->date_of_death }}</p>
        <p><strong>Cause of Death:</strong> {{ $claim->cause_of_death }}</p>
        <p><strong>Remarks:</strong> {{ $claim->remarks ?? 'N/A' }}</p>

        <hr>

        {{-- PAYOUT --}}
        <h6 class="text-primary">Payout Summary</h6>
        <p><strong>Sum Assured:</strong> {{ number_format($sumAssured, 2) }}</p>
        <p><strong>Percentage Applied:</strong> {{ $percentageApplied }}%</p>
        <p class="fw-bold text-success">
            <strong>Amount Payable:</strong> {{ number_format($amountPayable, 2) }}
        </p>

        <hr>

        {{-- DOCUMENTS --}}
        <h6 class="text-primary">Documents</h6>

        @if($claim->documents->isEmpty())
            <p class="text-muted">No documents uploaded.</p>
        @else
            <ul class="list-group list-group-sm">
                @foreach($claim->documents as $doc)
                    <li class="list-group-item d-flex justify-content-between">
                        {{ $doc->document_type }}
                        <a href="{{ asset($doc->document_path) }}" target="_blank">
                            View
                        </a>
                    </li>
                @endforeach
            </ul>
        @endif

        <hr>

        {{-- APPROVAL INFO --}}
        @if($claim->action_at)
            <p class="small text-muted">
                Approved on {{ $claim->action_at }} <br>
                Approved by {{ optional($claim->actionBy)->name ?? 'System' }}
            </p>
        @endif

    </div>
</div>

<p class="text-center mt-3 text-muted" style="font-size:12px">
    Secure read-only access for underwriting purposes.
</p>

</div>
</body>
</html>
