<x-app-layout>
    <div class="py-12 bg-slate-50 min-h-screen">
        <div class="max-w-7xl mx-auto px-4">
            <header class="mb-10 flex justify-between items-center">
                <div>
                    <h2 class="text-2xl font-black text-slate-900 tracking-tight">Log Audit Sistem</h2>
                    <p class="text-slate-400 text-sm font-medium">Rekaman jejak aktivitas pengguna di seluruh platform.</p>
                </div>
            </header>

            <div class="bg-white rounded-3xl shadow-sm border border-slate-100 overflow-hidden">
                <table class="w-full text-left text-sm">
                    <thead class="bg-slate-900 text-slate-400 text-[10px] font-black uppercase tracking-widest">
                        <tr>
                            <th class="px-8 py-5">Pengguna</th>
                            <th class="px-8 py-5">Aktivitas</th>
                            <th class="px-8 py-5">Entitas</th>
                            <th class="px-8 py-5">Waktu</th>
                            <th class="px-8 py-5">Detail</th>
                        </tr>
                    </thead>
                    <tbody class="divide-y divide-slate-50">
                        @foreach($logs as $log)
                            <tr class="hover:bg-slate-50 transition">
                                <td class="px-8 py-6">
                                    <div class="font-bold text-slate-900">{{ $log->user->name ?? 'System' }}</div>
                                    <div class="text-[10px] font-bold text-slate-400 uppercase tracking-widest">{{ $log->user->email ?? '-' }}</div>
                                </td>
                                <td class="px-8 py-6">
                                    <span class="px-3 py-1 bg-indigo-50 text-indigo-700 rounded-full text-[10px] font-black uppercase tracking-tight italic">
                                        {{ $log->action }}
                                    </span>
                                </td>
                                <td class="px-8 py-6 text-slate-500 font-mono text-[10px]">
                                    @if($log->entity_type)
                                        {{ class_basename($log->entity_type) }} #{{ $log->entity_id }}
                                    @else
                                        -
                                    @endif
                                </td>
                                <td class="px-8 py-6 text-slate-400 text-xs font-bold">
                                    {{ $log->created_at->format('d/m/Y H:i:s') }}
                                </td>
                                <td class="px-8 py-6">
                                    @if($log->new_values)
                                        <button class="text-indigo-600 font-bold text-[10px] uppercase hover:underline" onclick="alert(JSON.stringify(@json($log->new_values), null, 2))">
                                            Lihat JSON
                                        </button>
                                    @endif
                                </td>
                            </tr>
                        @endforeach
                    </tbody>
                </table>
                <div class="p-6">
                    {{ $logs->links() }}
                </div>
            </div>
        </div>
    </div>
</x-app-layout>
