@foreach($fields as $field)
    @if($field->type === 'group')
        <li class="rounded-xl border border-indigo-200 bg-indigo-50/40 p-3">
            <div class="flex items-center gap-2 mb-2">
                <span class="text-xs font-semibold uppercase tracking-wide text-indigo-700 bg-indigo-100 px-2 py-0.5 rounded">Groupe</span>
                <span class="font-semibold text-slate-800">{{ $field->label }}</span>
            </div>
            @if(!empty($field->description))
                <p class="text-xs text-slate-500 italic mb-2">{{ $field->description }}</p>
            @endif
            @if($field->children->isNotEmpty())
                <ul class="space-y-2 ml-3 mt-2 pl-3 border-l-2 border-indigo-200">
                    @include('partials.admin-field-tree', ['fields' => $field->children])
                </ul>
            @else
                <p class="text-xs text-slate-400 italic ml-3">Aucun champ.</p>
            @endif
        </li>
    @else
        <li class="p-3 rounded-lg bg-slate-50">
            <div class="flex justify-between items-start gap-2">
                <span class="font-medium text-slate-700">{{ $field->label }}</span>
                <span class="text-xs text-slate-500 shrink-0">
                    {{ $field->type }}
                    @if($field->required)<span class="text-red-500">*</span>@endif
                </span>
            </div>
            @if(!empty($field->description))
                <p class="text-xs text-slate-500 italic mt-1">{{ $field->description }}</p>
            @endif
            @if($field->type === 'table' && $field->tableColumns())
                <p class="text-xs text-slate-500 mt-2">
                    Tableau : {{ count($field->tableColumns()) }} colonne(s) —
                    @foreach($field->tableColumns() as $col)
                        <span class="inline-block bg-white border border-slate-200 rounded px-1.5 py-0.5 mr-1 mt-1">{{ $col['label'] }} ({{ $col['type'] }})</span>
                    @endforeach
                </p>
            @endif
        </li>
    @endif
@endforeach
