<div class="row">
    <div class="col-12">
        <div class="card glass-card">
            <div class="card-header"><h5 class="card-title">Audit Report</h5></div>
            <div class="card-body">
                <?php $this->include('Reports/partials/filter_date') ?>
                <div class="table-responsive mt-3">
                    <table class="table table-hover">
                        <thead>
                            <tr><th>Date</th><th>User</th><th>Action</th><th>Description</th><th>IP Address</th></tr>
                        </thead>
                        <tbody>
                            <?php if (empty($data)): ?>
                            <tr><td colspan="5" class="text-center py-4 text-muted">No audit logs found.</td></tr>
                            <?php else: ?>
                                <?php foreach ($data as $row): ?>
                                <tr>
                                    <td><?= date('d M Y H:i', strtotime($row->created_at)) ?></td>
                                    <td><?= e($row->user_name ?? 'System') ?></td>
                                    <td><span class="badge bg-<?= str_starts_with($row->action, 'delete') ? 'danger' : (str_starts_with($row->action, 'create') ? 'success' : 'info') ?>"><?= e($row->action) ?></span></td>
                                    <td><?= e($row->description) ?></td>
                                    <td><code><?= e($row->ip_address ?? '-') ?></code></td>
                                </tr>
                                <?php endforeach; ?>
                            <?php endif; ?>
                        </tbody>
                    </table>
                </div>
            </div>
        </div>
    </div>
</div>
