<?php require __DIR__ . '/settings_nav.php'; ?>
<div class="mb-3">
    <h2 class="mb-1"><?= h(t('audit.heading')) ?></h2>
    <div class="text-muted"><?= h(t('audit.intro')) ?></div>
</div>
<div class="card">
    <div class="table-responsive">
        <table class="table table-vcenter card-table">
            <thead>
                <tr>
                    <th><?= h(t('common.date')) ?></th>
                    <th><?= h(t('audit.user')) ?></th>
                    <th><?= h(t('audit.action')) ?></th>
                    <th><?= h(t('audit.item')) ?></th>
                    <th><?= h(t('audit.path')) ?></th>
                </tr>
            </thead>
            <tbody><?php foreach ($rows as $row): ?><tr>
                    <td class="text-nowrap"><?= h($row['created_at']) ?></td>
                    <td><strong><?= h($row['actor'] ?: t('audit.deleted_account')) ?></strong></td>
                    <td><?= h($row['summary'] ?: $row['action']) ?></td>
                    <td><?= h(trim((string)$row['entity_type'] . ' ' . (string)$row['entity_id'])) ?></td>
                    <td class="small text-muted"><?= h($row['method'] . ' ' . $row['path']) ?></td>
                </tr><?php endforeach; ?><?php if (!$rows): ?><tr>
                    <td colspan="5" class="text-center text-muted py-4"><?= h(t('audit.none')) ?></td>
                </tr><?php endif; ?></tbody>
        </table>
    </div>
</div>
