<div style="margin-bottom:20px">
  <h2 style="font-size:1.2rem;font-weight:700">📋 Log Aktivitas Sistem</h2>
  <p class="text-muted text-sm">200 aktivitas terbaru tercatat dalam sistem</p>
</div>

<div class="filters-bar">
  <input type="text" id="search-akt" class="form-control" placeholder="🔍 Cari user, modul, aksi..." style="max-width:300px">
</div>

<div class="card">
  <div class="card-body no-pad">
    <div class="table-wrap">
      <table id="table-akt">
        <thead>
          <tr><th>Waktu</th><th>User</th><th>Role</th><th>Aksi</th><th>Modul</th><th>Deskripsi</th><th>IP</th></tr>
        </thead>
        <tbody>
          <?php foreach($data as $a): ?>
          <tr>
            <td class="text-xs" style="font-family:monospace;white-space:nowrap"><?= $a['created_at'] ?></td>
            <td class="text-sm font-bold"><?= e($a['nama_user']??'System') ?></td>
            <td>
              <?php $rc=['superadmin'=>'badge-purple','verifikator'=>'badge-blue','rumah_ibadah'=>'badge-green','dinsos'=>'badge-teal','walikota'=>'badge-orange']; ?>
              <span class="badge <?= $rc[$a['role']??'']??'badge-gray' ?>"><?= e($a['role']??'—') ?></span>
            </td>
            <td class="text-sm font-bold"><?= e($a['aksi']) ?></td>
            <td><span class="badge badge-gray"><?= e($a['modul']??'—') ?></span></td>
            <td class="text-sm text-muted"><?= e($a['deskripsi']??'') ?></td>
            <td class="text-xs" style="font-family:monospace"><?= e($a['ip_address']??'') ?></td>
          </tr>
          <?php endforeach; ?>
        </tbody>
      </table>
    </div>
    <?php if(empty($data)): ?>
    <div class="empty-state"><div class="empty-state-icon">📋</div><h3>Belum ada aktivitas</h3></div>
    <?php endif; ?>
  </div>
</div>

<script>document.addEventListener('DOMContentLoaded',()=>App.initTableSearch('search-akt','table-akt'));</script>
