<?= $this->extend('layouts/main') ?>
<?= $this->section('content') ?>
<div class="page-header"><div><h1><i class="bi bi-activity me-2"></i>Activity Log</h1></div></div>
<?php $q = $logs ?? []; ?>
<div class="fm-card"><div class="fm-card-body p-0">
  <table class="fm-table">
    <thead><tr><th>Date / Time</th><th>User</th><th>Action</th><th>Module</th><th>Description</th><th>IP</th></tr></thead>
    <tbody>
    <?php foreach($q as $l): ?>
    <tr>
      <td class="small text-muted"><?= date('d M Y H:i',strtotime($l['created_at'])) ?></td>
      <td class="small fw-semibold"><?= esc($l['user_name']??'System') ?></td>
      <td><span class="fm-badge badge-status-<?= $l['action']==='create'?'active':($l['action']==='delete'?'overdue':($l['action']==='approve'?'new':'in_progress')) ?>"><?= esc(ucfirst($l['action'])) ?></span></td>
      <td class="small"><?= esc(ucfirst(str_replace('_',' ',$l['module']))) ?></td>
      <td class="small text-muted"><?= esc($l['description']??'') ?></td>
      <td class="x-small text-muted"><?= esc($l['ip_address']??'') ?></td>
    </tr>
    <?php endforeach; ?>
    <?php if(empty($q)): ?><tr><td colspan="6" class="text-center py-4 text-muted">No activity logged yet.</td></tr><?php endif; ?>
    </tbody>
  </table>
</div></div>
<?= $this->endSection() ?>
