<div>
    <x-title :breadcrumbs="[
        ['link' => route('ha-claims.index'), 'title' => 'HA Claims'],
    ]">
        HA Claims
    </x-title>

    <div class="card">
        <div class="card-body">

            {{-- Filters --}}
            <div class="row g-2 mb-3">
                <div class="col-12 col-md-5">
                    <input type="text"
                           class="form-control"
                           placeholder="Search case number or client name…"
                           wire:model.live.debounce.300ms="search" />
                </div>
                <div class="col-6 col-md-3">
                    <select class="form-select" wire:model.live="statusId">
                        <option value="">All Statuses</option>
                        @foreach($statuses as $status)
                            <option value="{{ $status->id }}">{{ $status->display_name }}</option>
                        @endforeach
                    </select>
                </div>
                <div class="col-6 col-md-2">
                    <select class="form-select" wire:model.live="redressType">
                        <option value="">All Types</option>
                        <option value="FIXED">Fixed</option>
                        <option value="INDIVIDUAL">Individual</option>
                    </select>
                </div>
                <div class="col-6 col-md-2">
                    <select class="form-select" wire:model.live="perPage">
                        <option value="25">25 per page</option>
                        <option value="50">50 per page</option>
                        <option value="100">100 per page</option>
                    </select>
                </div>
            </div>

            {{-- Table --}}
            <div class="table-responsive">
                <table class="table table-sm table-centered table-striped table-nowrap mb-0">
                    <thead class="table-light">
                    <tr>
                        <th>Case Number</th>
                        <th>Client</th>
                        <th>Type</th>
                        <th>Status</th>
                        <th>Created</th>
                        <th class="text-end"></th>
                    </tr>
                    </thead>
                    <tbody>
                    @forelse($claims as $claim)
                        <tr>
                            <td>
                                <strong>{{ $claim->case_number ?: '—' }}</strong>
                            </td>
                            <td>
                                @if($claim->client)
                                    <a href="{{ route('clients.show', $claim->client) }}" class="text-body">
                                        {{ $claim->client->name_first }} {{ $claim->client->name_last }}
                                    </a>
                                @else
                                    <span class="text-muted">—</span>
                                @endif
                            </td>
                            <td>
                                @if($claim->redress_type === 'FIXED')
                                    <span class="badge bg-primary">Fixed</span>
                                @elseif($claim->redress_type === 'INDIVIDUAL')
                                    <span class="badge bg-info text-dark">Individual</span>
                                @else
                                    <span class="text-muted">—</span>
                                @endif
                            </td>
                            <td>
                                @if($claim->status)
                                    <span class="badge" style="background-color: {{ $claim->status->color ?? '#6c757d' }}">
                                        {{ $claim->status->display_name }}
                                    </span>
                                @else
                                    <span class="text-muted">—</span>
                                @endif
                            </td>
                            <td class="text-muted small">{{ $claim->created_at?->format('d/m/Y') }}</td>
                            <td class="text-end">
                                <a href="{{ route('ha-claims.view', $claim) }}" class="text-secondary me-2" title="View HA Claim">
                                    <i class="mdi mdi-eye"></i>
                                </a>
                            </td>
                        </tr>
                    @empty
                        <tr>
                            <td colspan="6" class="text-center text-muted py-4">No HA claims found.</td>
                        </tr>
                    @endforelse
                    </tbody>
                </table>
            </div>

            {{-- Pagination --}}
            <div class="mt-3">
                {{ $claims->links() }}
            </div>

        </div>
    </div>
</div>
