<x-app-layout>
    <x-ui.page-header :title="'Soumissions — ' . $filiale->name" :description="'Code : ' . $filiale->code . ' · ' . ($filiale->user?->email ?? '')">
        <x-slot name="actions">
            <a href="{{ route('admin.submissions.overview') }}" class="btn-secondary btn-sm">← Toutes les filiales</a>
            <a href="{{ route('admin.filiales.edit', $filiale) }}" class="btn-secondary btn-sm">Modifier filiale</a>
        </x-slot>
    </x-ui.page-header>

    <x-alert />

    <div class="card overflow-hidden">
        <div class="overflow-x-auto">
            <table class="min-w-full table-modern">
                <thead>
                    <tr>
                        <th>Formulaire</th>
                        <th>Soumis par</th>
                        <th>Date</th>
                        <th>Statut formulaire</th>
                        <th class="text-right">Actions</th>
                    </tr>
                </thead>
                <tbody>
                    @forelse($submissions as $submission)
                        <tr>
                            <td class="font-medium text-slate-800">{{ $submission->form->title }}</td>
                            <td>{{ $submission->user->name }}</td>
                            <td>{{ $submission->submitted_at?->format('d/m/Y à H:i') ?? '—' }}</td>
                            <td>
                                @if($submission->form->is_active)
                                    <span class="badge-info">Actif</span>
                                @else
                                    <span class="badge-warning">Verrouillé</span>
                                @endif
                            </td>
                            <td>
                                <x-ui.crud-actions :view="route('admin.submissions.show', $submission)" />
                            </td>
                        </tr>
                    @empty
                        <tr>
                            <td colspan="5" class="text-center py-12 text-slate-400">
                                Cette filiale n'a soumis aucun formulaire pour le moment.
                            </td>
                        </tr>
                    @endforelse
                </tbody>
            </table>
        </div>
        @if($submissions->hasPages())
            <div class="px-6 py-4 border-t border-slate-100">{{ $submissions->links() }}</div>
        @endif
    </div>
</x-app-layout>
