@php
    $next = ['draft'=>'submit','submitted'=>'approve','approved'=>'clearance','clearance'=>'final-settlement','final_settlement'=>'complete'][$case->status] ?? null;
@endphp
<x-ui.layout.page :title="__('offboarding.details', ['id'=>$case->id])" page-icon="fe fe-log-out">
    <x-slot:actions><x-ui.buttons.secondary :href="route('hr.offboarding.index')">{{ __('common.back') }}</x-ui.buttons.secondary></x-slot:actions>
    <div class="card mb-3"><div class="card-body row g-3">
        <div class="col-md-4"><strong>{{ __('offboarding.fields.employee') }}</strong><div>{{ $case->employee?->full_name }}</div></div>
        <div class="col-md-4"><strong>{{ __('offboarding.fields.last_working_date') }}</strong><div>{{ $case->last_working_date?->format('Y-m-d') }}</div></div>
        <div class="col-md-4"><strong>{{ __('offboarding.fields.status') }}</strong><div>{{ __('offboarding.status.'.$case->status) }}</div></div>
        <div class="col-12"><strong>{{ __('offboarding.fields.reason') }}</strong><div>{{ $case->reason }}</div></div>
        @if($next) @can('manage',$case)
            <div class="col-12"><form method="POST" action="{{ route('hr.offboarding.'.$next,$case) }}">@csrf<x-ui.buttons.primary type="submit">{{ __('offboarding.actions.'.$next) }}</x-ui.buttons.primary></form></div>
        @endcan @endif
    </div></div>
    @can('manage',$case)
        <div class="card mb-3"><div class="card-body">
            <form method="POST" action="{{ route('hr.offboarding.checklist.store',$case) }}" class="row g-3">@csrf
                <div class="col-md-3"><x-ui.form.select name="section" :label="__('offboarding.fields.section')" :options="collect(['assets','accounts','documents','other'])->mapWithKeys(fn($v)=>[$v=>__('offboarding.sections.'.$v)])->all()" required /></div>
                <div class="col-md-7"><x-ui.form.input name="title" :label="__('offboarding.fields.item')" required /></div>
                <div class="col-md-2 d-flex align-items-end"><x-ui.buttons.primary type="submit">{{ __('offboarding.actions.add_item') }}</x-ui.buttons.primary></div>
            </form>
        </div></div>
    @endcan
    <x-ui.table.table :columns="[['label'=>__('offboarding.fields.section')],['label'=>__('offboarding.fields.item')],['label'=>__('offboarding.fields.status')]]">
        @forelse($case->checklistItems as $item)
            <x-ui.table.row><td>{{ __('offboarding.sections.'.$item->section) }}</td><td>{{ $item->title }}</td><td>{{ $item->is_done ? __('common.done') : __('common.pending') }}</td></x-ui.table.row>
        @empty<x-ui.table.row><td colspan="3"><x-ui.operational.empty-state :title="__('offboarding.empty_checklist')" /></td></x-ui.table.row>@endforelse
    </x-ui.table.table>
</x-ui.layout.page>
