<!-- Path: app/Views/admin/audit_logs.view.php -->
<div class="bg-slate-50 min-h-[calc(100vh-64px)] py-8">
    <div class="max-w-7xl mx-auto px-4 sm:px-6 lg:px-8">
        <div class="mb-6">
            <h1 class="text-2xl font-bold text-navy-900">Framework Audit Logs</h1>
            <p class="text-slate-500 text-sm">Raw JSON database changes tracked securely by Coreflux.</p>
        </div>

        <div class="bg-white rounded-xl shadow-sm border border-slate-200 overflow-hidden">
            <div class="overflow-x-auto">
                <table class="w-full text-left border-collapse">
                    <thead>
                        <tr class="bg-navy-900 text-white text-xs uppercase tracking-wider border-b border-slate-200">
                            <th class="p-3 font-semibold">Time</th>
                            <th class="p-3 font-semibold">User</th>
                            <th class="p-3 font-semibold">Action</th>
                            <th class="p-3 font-semibold">Table (ID)</th>
                            <th class="p-3 font-semibold">New Data Dump</th>
                        </tr>
                    </thead>
                    <tbody class="divide-y divide-slate-200 text-xs font-mono">
                        @if(empty($logs))
                            <tr><td colspan="5" class="p-8 text-center text-slate-500">No logs found.</td></tr>
                        @else
                            @foreach($logs as $log)
                                <tr class="hover:bg-slate-100">
                                    <td class="p-3 text-slate-600 whitespace-nowrap">{{ $log['created_at'] }}</td>
                                    <td class="p-3 font-bold text-brandBlue-600">{{ $log['full_name'] ?? 'System' }}</td>
                                    <td class="p-3">
                                        <span class="px-2 py-1 rounded bg-slate-200 text-slate-800 font-bold">{{ $log['action_type'] }}</span>
                                    </td>
                                    <td class="p-3 text-slate-800">{{ $log['table_name'] }} (#{{ $log['record_id'] }})</td>
                                    <td class="p-3">
                                        <div class="max-h-20 overflow-y-auto bg-slate-800 text-green-400 p-2 rounded">
                                            {{ $log['new_data'] ?? 'N/A' }}
                                        </div>
                                    </td>
                                </tr>
                            @endforeach
                        @endif
                    </tbody>
                </table>
            </div>
        </div>
    </div>
</div>