<div class="d-flex justify-content-between mb-4">
    <h4 class="mb-0">Audit Entry #<?= $entry['id'] ?></h4>
    <a href="/admin/audit-log" class="btn btn-secondary">Back</a>
</div>
<div class="row g-4">
    <div class="col-md-6"><div class="card"><div class="card-header">Details</div><div class="card-body">
        <table class="table table-sm table-borderless">
            <tr><td class="text-muted" width="35%">User</td><td><?= e($entry['user_name'] ?? 'System') ?></td></tr>
            <tr><td class="text-muted">Action</td><td><?= e($entry['action_type']) ?></td></tr>
            <tr><td class="text-muted">Module</td><td><?= e($entry['module']) ?></td></tr>
            <tr><td class="text-muted">Entity</td><td><?= e($entry['entity_type']) ?> #<?= $entry['entity_id'] ?></td></tr>
            <tr><td class="text-muted">Description</td><td><?= e($entry['description']) ?></td></tr>
            <tr><td class="text-muted">IP</td><td><?= e($entry['ip_address'] ?? '-') ?></td></tr>
            <tr><td class="text-muted">Time</td><td><?= format_datetime($entry['created_at']) ?></td></tr>
            <tr><td class="text-muted">Severity</td><td><?= status_badge($entry['severity'] ?? 'info') ?></td></tr>
        </table>
    </div></div></div>
    <div class="col-md-6">
        <?php if ($entry['old_values']): ?><div class="card mb-3"><div class="card-header">Old Values</div><div class="card-body"><pre class="mb-0" style="max-height:300px;overflow:auto"><?= e(json_encode(json_decode($entry['old_values']), JSON_PRETTY_PRINT | JSON_UNESCAPED_UNICODE)) ?></pre></div></div><?php endif; ?>
        <?php if ($entry['new_values']): ?><div class="card"><div class="card-header">New Values</div><div class="card-body"><pre class="mb-0" style="max-height:300px;overflow:auto"><?= e(json_encode(json_decode($entry['new_values']), JSON_PRETTY_PRINT | JSON_UNESCAPED_UNICODE)) ?></pre></div></div><?php endif; ?>
    </div>
</div>