<x-app-layout>
    <x-slot name="header">
        <h2 class="h4 mb-0">Audit Log</h2>
    </x-slot>

    <div class="card">
        <div class="table-responsive">
            <table class="table table-sm mb-0">
                <thead>
                    <tr>
                        <th>Waktu</th>
                        <th>User</th>
                        <th>Desa</th>
                        <th>Event</th>
                        <th>Entitas</th>
                    </tr>
                </thead>
                <tbody>
                    @forelse ($logs as $log)
                        <tr>
                            <td>{{ $log->created_at->format('Y-m-d H:i') }}</td>
                            <td>{{ $log->user?->name ?? '-' }}</td>
                            <td>{{ $log->desa?->nama ?? '-' }}</td>
                            <td><span class="badge bg-info text-dark">{{ $log->event }}</span></td>
                            <td>{{ class_basename($log->auditable_type) }}</td>
                        </tr>
                    @empty
                        <tr><td colspan="5" class="text-center text-muted py-4">Belum ada data audit.</td></tr>
                    @endforelse
                </tbody>
            </table>
        </div>
    </div>

    <div class="mt-3">{{ $logs->links() }}</div>
</x-app-layout>
