<?= $this->extend('layouts/main') ?>
<?= $this->section('content') ?>

<div class="d-flex align-items-center justify-content-between mb-4">
    <h4 class="page-title mb-0"><i class="bi bi-journal-text me-2 text-primary"></i><?= lang('Admin.activity_logs') ?></h4>
</div>

<div class="card border-0 shadow-sm">
    <div class="card-body p-0">
        <div class="table-responsive">
            <table class="table table-hover align-middle mb-0">
                <thead class="table-light">
                    <tr>
                        <th class="ps-3"><?= lang('Admin.log_time') ?></th>
                        <th><?= lang('Admin.log_admin') ?></th>
                        <th><?= lang('Admin.log_action') ?></th>
                        <th><?= lang('Admin.log_module') ?></th>
                        <th><?= lang('Admin.log_description') ?></th>
                        <th class="pe-3"><?= lang('Admin.log_ip') ?></th>
                    </tr>
                </thead>
                <tbody>
                    <?php if (empty($logs)): ?>
                    <tr><td colspan="6" class="text-center text-muted py-5"><?= lang('Admin.no_records') ?></td></tr>
                    <?php else: foreach ($logs as $log): ?>
                    <tr>
                        <td class="ps-3 small text-muted text-nowrap"><?= date('d M Y H:i', strtotime($log['created_at'])) ?></td>
                        <td class="small fw-medium"><?= esc($log['admin_name'] ?? 'System') ?></td>
                        <td>
                            <span class="badge <?= log_badge_class($log['action']) ?>">
                                <?= esc(ucfirst($log['action'])) ?>
                            </span>
                        </td>
                        <td class="small text-muted"><?= esc($log['module']) ?></td>
                        <td class="small"><?= esc($log['description']) ?></td>
                        <td class="pe-3 small font-monospace text-muted"><?= esc($log['ip_address']) ?></td>
                    </tr>
                    <?php endforeach; endif; ?>
                </tbody>
            </table>
        </div>
    </div>
</div>

<?= $this->endSection() ?>
