@php
    $breadcrumbs = [
        ['label' => __('common.home'), 'url' => route('dashboard.index')],
        ['label' => __('common.hr')],
        ['label' => __('recruitment.onboarding.title')],
    ];
@endphp

<x-ui.layout.page
    :title="__('recruitment.onboarding.title')"
    :subtitle="__('recruitment.onboarding.subtitle')"
    page-icon="fe fe-user-check"
    :breadcrumbs="$breadcrumbs"
>
    <div class="row g-3 mb-4">
        <div class="col-lg-8">
            <div class="card border-0 shadow-sm">
                <div class="card-body">
                    <form method="GET" class="row g-2 align-items-end">
                        <div class="col-md-5">
                            <label class="form-label">{{ __('recruitment.filters.search') }}</label>
                            <input type="text" name="q" value="{{ request('q') }}" class="form-control" placeholder="{{ __('recruitment.onboarding.search_placeholder') }}">
                        </div>
                        <div class="col-md-4">
                            <label class="form-label">{{ __('recruitment.filters.status') }}</label>
                            <select name="status" class="form-select">
                                <option value="">{{ __('recruitment.filters.all') }}</option>
                                @foreach (['in_progress', 'completed', 'cancelled'] as $st)
                                    <option value="{{ $st }}" @selected(request('status') === $st)>{{ __('recruitment.onboarding.case_status.'.$st) }}</option>
                                @endforeach
                            </select>
                        </div>
                        <div class="col-md-3">
                            <x-ui.buttons.primary type="submit">{{ __('recruitment.filters.apply') }}</x-ui.buttons.primary>
                        </div>
                    </form>
                </div>
            </div>
        </div>
        @can('create', \App\Modules\HR\Recruitment\Models\RecruitmentOnboardingCase::class)
            <div class="col-lg-4">
                <div class="card border-0 shadow-sm h-100">
                    <div class="card-body">
                        <h6 class="mb-3">{{ __('recruitment.onboarding.start_for_employee') }}</h6>
                        <form method="POST" action="{{ route('hr.recruitment.onboarding.store') }}">
                            @csrf
                            <select name="employee_id" class="form-select mb-2" required>
                                <option value="">{{ __('recruitment.onboarding.select_employee') }}</option>
                                @foreach ($employees as $employee)
                                    <option value="{{ $employee->id }}">{{ $employee->employee_code }} — {{ $employee->full_name }}</option>
                                @endforeach
                            </select>
                            <x-ui.buttons.primary type="submit" icon="fe fe-play">{{ __('recruitment.onboarding.actions.start') }}</x-ui.buttons.primary>
                        </form>
                    </div>
                </div>
            </div>
        @endcan
    </div>

    <div class="row g-3">
        @forelse ($cases as $case)
            <div class="col-md-6 col-xl-4">
                @include('pages.hr.recruitment.onboarding._case_card', ['case' => $case])
            </div>
        @empty
            <div class="col-12">
                <div class="card border-0 shadow-sm">
                    <div class="card-body text-center text-muted py-5">
                        {{ __('recruitment.onboarding.empty') }}
                    </div>
                </div>
            </div>
        @endforelse
    </div>

    <div class="mt-3">{{ $cases->links() }}</div>
</x-ui.layout.page>
