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

<x-ui.layout.page
    :title="__('leave.types.title')"
    :subtitle="__('leave.types.subtitle')"
    page-icon="fe fe-calendar"
    :breadcrumbs="$breadcrumbs"
>
    <x-ui.operational.index-shell>
        <x-slot:toolbar>
            <x-ui.operational.action-bar>
                <x-slot:primary>
                    <x-ui.operational.create-button
                        :href="route('hr.leave.types.create')"
                        :label="__('leave.types.actions.add')"
                        permission="leave_types.create"
                    />
                </x-slot:primary>
            </x-ui.operational.action-bar>
        </x-slot:toolbar>

        <x-ui.table.table :columns="[
            ['label' => __('leave.types.fields.name')],
            ['label' => __('leave.types.fields.annual_limit')],
            ['label' => __('leave.types.fields.paid')],
            ['label' => __('leave.fields.status')],
            ['label' => __('common.actions'), 'align' => 'end', 'width' => '120px'],
        ]">
            @forelse ($types as $type)
                <x-ui.table.row>
                    <td><strong>{{ $type->name }}</strong></td>
                    <td>{{ $type->annual_limit ?? '—' }}</td>
                    <td>{{ $type->is_paid ? __('common.yes') : __('common.no') }}</td>
                    <td>
                        <x-ui.operational.status-badge
                            :label="$type->is_active ? __('leave.types.status.active') : __('leave.types.status.inactive')"
                            :variant="$type->is_active ? 'success' : 'neutral'"
                        />
                    </td>
                    <td class="text-end">
                        <x-ui.table.actions-trigger
                            :type="__('leave.types.singular')"
                            :id="$type->id"
                            :view-href="auth()->user()?->can('update', $type) ? route('hr.leave.types.edit', $type) : null"
                        />
                    </td>
                </x-ui.table.row>
            @empty
                <x-ui.table.row>
                    <td colspan="5" class="p-0">
                        <x-ui.operational.empty-state :title="__('leave.types.empty')" />
                    </td>
                </x-ui.table.row>
            @endforelse
        </x-ui.table.table>
    </x-ui.operational.index-shell>

    <x-ui.modal.actions />
</x-ui.layout.page>
