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

<x-ui.layout.page
    :title="__('inventory.categories.title')"
    :subtitle="__('inventory.categories.subtitle')"
    page-icon="fe fe-folder"
    :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('inventory.categories.create')"
                        :label="__('inventory.categories.actions.add')"
                        permission="inventory.catalog.manage"
                    />
                </x-slot:primary>
            </x-ui.operational.action-bar>
        </x-slot:toolbar>

        <x-ui.table.table :columns="[
            ['label' => __('inventory.categories.columns.code')],
            ['label' => __('inventory.categories.columns.name')],
            ['label' => __('inventory.categories.columns.parent')],
            ['label' => __('common.active')],
        ]">
            @forelse ($categories as $category)
                <x-ui.table.row>
                    <td>{{ $category->code }}</td>
                    <td>{{ $category->name }}</td>
                    <td>{{ $category->parent?->code ?? '—' }}</td>
                    <td>
                        <x-ui.operational.status-badge
                            :label="$category->is_active ? __('common.active') : __('common.inactive')"
                            :variant="$category->is_active ? 'success' : 'neutral'"
                        />
                    </td>
                </x-ui.table.row>
            @empty
                <x-ui.table.row>
                    <td colspan="4" class="p-0">
                        <x-ui.operational.empty-state :title="__('operational_ui.index.empty_default')" />
                    </td>
                </x-ui.table.row>
            @endforelse
        </x-ui.table.table>

        <x-slot:pagination>
            {{ $categories->links() }}
        </x-slot:pagination>
    </x-ui.operational.index-shell>
</x-ui.layout.page>
