<div>
    <div class="card shadow-sm mb-3">
        <div class="card-body">
            <div class="d-flex justify-content-between align-items-center mb-3">
                <h5 class="card-title mb-0">
                    <span class="badge bg-warning text-dark me-2">CPF</span> CPF Cases
                </h5>
                @can('pension-cases.create')
                    <a href="{{ route('clients.pension-cases.create', $client) }}"
                       class="btn btn-sm btn-outline-warning">
                        <i class="mdi mdi-plus me-1"></i> New
                    </a>
                @endcan
            </div>

            @if($cases->isNotEmpty())
                <div class="table-responsive">
                    <table class="table table-sm table-centered mb-0">
                        <thead class="table-light">
                            <tr>
                                <th>Case #</th>
                                <th>Type</th>
                                <th>Owner</th>
                                <th>Case Status</th>
                                <th>Status</th>
                                <th class="text-end"></th>
                            </tr>
                        </thead>
                        <tbody>
                            @foreach($cases as $case)
                                <tr>
                                    <td>
                                        <strong>{{ $case->case_number ?? $case->displayId }}</strong>
                                        @if($case->sf_case_id)
                                            <div class="text-muted extra-small">{{ $case->sf_case_id }}</div>
                                        @endif
                                        @if($case->vulnerable_client_flag)
                                            <span class="badge bg-danger ms-1" title="Vulnerable">V</span>
                                        @endif
                                    </td>
                                    <td>
                                        @if($case->claim_type)
                                            <span class="badge bg-info text-dark">{{ strtoupper($case->claim_type) }}</span>
                                        @else
                                            —
                                        @endif
                                    </td>
                                    <td>{{ $case->case_owner ?? '—' }}</td>
                                    <td>{{ $case->status?->display_name ?? '—' }}</td>
                                    <td>
                                        @if($case->is_open)
                                            <span class="badge bg-success">Open</span>
                                        @else
                                            <span class="badge bg-secondary">Closed</span>
                                        @endif
                                    </td>
                                    <td class="text-end">
                                        <a href="{{ route('pension-cases.view', $case) }}"
                                           class="text-secondary me-2" title="View">
                                            <i class="mdi mdi-eye"></i>
                                        </a>
                                        @can('edit', $case)
                                            <a href="{{ route('pension-cases.edit', $case) }}"
                                               class="text-primary" title="Edit">
                                                <i class="mdi mdi-pencil"></i>
                                            </a>
                                        @endcan
                                    </td>
                                </tr>
                            @endforeach
                        </tbody>
                    </table>
                </div>
            @else
                <p class="text-muted small mb-0">No CPF cases on record.</p>
            @endif
        </div>
    </div>
</div>
