@props([
    'items' => [],
])

@php
    $items = collect($items);
@endphp

<nav aria-label="Fil d'Ariane" {{ $attributes->merge(['class' => 'min-w-0']) }}>
    <ol class="flex min-w-0 flex-wrap items-center gap-1.5 text-sm text-brand-muted">
        <li class="flex items-center gap-1.5">
            <a href="{{ route('admin.dashboard') }}" class="transition-colors hover:text-brand-primary">Tableau de bord</a>
        </li>

        @foreach ($items as $index => $item)
            <li class="flex items-center gap-1.5 truncate">
                <x-icon name="chevron-right" class="h-3.5 w-3.5 shrink-0 text-brand-border" />

                @if (!empty($item['route']) && $index < $items->count() - 1)
                    <a href="{{ route($item['route']) }}" class="truncate transition-colors hover:text-brand-primary">
                        {{ $item['label'] }}
                    </a>
                @else
                    <span class="truncate font-semibold text-brand-ink" aria-current="page">{{ $item['label'] }}</span>
                @endif
            </li>
        @endforeach
    </ol>
</nav>
