<div>
    @if($client->claim()->exists())
        <div class="row g-4">
            <!-- Main Info Column (Left) -->
            <div class="col-md-12">
                <div class="row g-4">
                    <!-- Case Details -->
                    <div class="col-md-6">
                        <div class="card shadow-sm h-100 border-0">
                            <div class="card-body">
                                <div class="d-flex align-items-center justify-content-between mb-3">
                                    <h5 class="text-muted fw-bold mb-0">Case Details</h5>

                                    @can('claims.edit')
                                        <a wire:navigate href="{{ route('claims.edit', $client) }}" class="btn btn-primary btn-sm">
                                            <i class="mdi mdi-pencil"></i>
                                        </a>
                                    @endcan
                                </div>

                                <div class="mb-2">
                                    <label class="text-muted extra-small d-block mb-0">APP Number</label>
                                    <span class="fw-bold text-dark">{{ $client->claim->case_number ?? 'Not Assigned' }}</span>
                                </div>
                                <div class="mb-2">
                                    <label class="text-muted extra-small d-block mb-0">Case Worker</label>
                                    <span class="fw-medium text-dark">{{ $client->claim->redress_case_worker ?? 'Unassigned' }}</span>
                                    @if($client->claim->redress_case_worker_email)
                                        <a href="mailto:{{ $client->claim->redress_case_worker_email }}" class="d-block extra-small text-muted">{{ $client->claim->redress_case_worker_email }}</a>
                                    @endif
                                </div>
                                <div>
                                    <label class="text-muted extra-small d-block mb-0">Redress Type</label>
                                    <span class="text-dark small">{{ $client->claim->redress_type ?? 'N/A' }}</span>
                                </div>

                                <livewire:tag.tag-assigner :model="$client->claim"/>

                                <x-client.handler-list :client="$client"/>

                                <hr>

                                <div>
                                    <label class="text-muted extra-small d-block mb-0">Existing Criminal Record</label>
                                    <span class="text-dark small">{{ $client->claim?->impactDetail?->has_criminal_conviction ? 'Yes' : 'No' }}</span>
                                </div>
                            </div>
                        </div>
                    </div>

                    <!-- Care Settings -->
                    <div class="col-md-6">
                        <div class="card shadow-sm h-100 border-0">
                            <div class="card-body">
                                <div class="d-flex align-items-center justify-content-between mb-3">
                                    <h5 class="text-muted fw-bold mb-0">Care Settings</h5>
                                </div>

                                <div class="care-settings-list" style="overflow-y: auto;">
                                    @forelse($client->claim->careSettings as $setting)
                                        <a wire:navigate href="{{ route('institutions.show', $setting->institution) }}" class="mb-2 pb-1 border-bottom border-light last-child-border-0">
                                            <div class="fw-bold text-dark extra-small">{{ $setting->institution->display_name }}</div>
                                            @if($setting->area)
                                                <div class="text-muted extra-small">
                                                    {{ $setting->area->name }}@if($setting->area->council) &middot; {{ $setting->area->council->name }}@endif
                                                </div>
                                            @endif
                                            <div class="text-muted extra-small italic">
                                                {{ $setting->dates }}
                                            </div>
                                        </a>
                                    @empty
                                        <p class="text-muted small italic">No care settings recorded.</p>
                                    @endforelse
                                </div>
                            </div>
                        </div>
                    </div>
                </div>
                <!-- Secondary Management Modules -->
                <div class="row mt-4">
                    <div class="col-4">
                        <livewire:client.previous-name-manager :client="$client"/>
                    </div>
                    <div class="col-4">
                        <livewire:address-book :owner="$client"/>
                    </div>
                    <div class="col-4">
                        <livewire:client.relation-manager :client="$client"/>
                    </div>
                    </div>
                <div class="row mt-4">
                    <div class="col-12">
                        <livewire:note-manager :owner="$client" primary="true"/>
                    </div>
                </div>
            </div>
        </div>
    @else
        <div class="card shadow-sm border-0">
            <div class="card-body text-center py-5">
                <i class="mdi mdi-account-details-outline text-muted" style="font-size: 48px;"></i>
                <h5 class="text-dark">No Active Claim</h5>
                <p class="text-muted">A claim has not been initialized for this client yet.</p>
                @can('claims.create')
                    <a wire:navigate href="{{ route('claims.create', $client) }}" class="btn btn-primary mt-2">
                        Initialize Claim
                    </a>
                @endcan
            </div>
        </div>
    @endif


</div>