<?php
$admin = \App\Core\Auth::currentUser();
$active = 'audit';
$pageTitle = 'Audit Logs';
require __DIR__ . '/../layout/admin_header.php';
?>
<div class="topbar">
  <div>
    <h1>Reports &amp; Audit Logs</h1>
    <div class="crumbs">Workspace → Admin → Audit Logs</div>
  </div>
  <div class="user-chip"><span class="dot"></span> <?= htmlspecialchars($admin['name']) ?></div>
</div>

<div class="card">
  <h3>Recent Admin Activity (last 200)</h3>
  <table>
    <thead>
      <tr><th>Date/Time</th><th>Actor</th><th>Action</th><th>Entity</th><th>IP</th></tr>
    </thead>
    <tbody>
      <?php foreach ($logs as $l): ?>
        <tr>
          <td><?= htmlspecialchars($l['created_at']) ?></td>
          <td><?= htmlspecialchars($l['actor_name']) ?> <span class="badge badge-manager"><?= htmlspecialchars($l['actor_type']) ?></span></td>
          <td><?= htmlspecialchars($l['action']) ?></td>
          <td><?= htmlspecialchars($l['entity_type']) ?> #<?= htmlspecialchars($l['entity_id']) ?></td>
          <td><?= htmlspecialchars($l['ip']) ?></td>
        </tr>
      <?php endforeach; ?>
    </tbody>
  </table>
</div>

<?php require __DIR__ . '/../layout/admin_footer.php'; ?>
