<div class="d-flex align-items-center mb-3">
    <a href="<?= url('/SuperAdmin') ?>" class="btn btn-sm btn-outline-secondary me-2"><i class="fas fa-arrow-left"></i></a>
    <h5 class="fw-bold mb-0"><i class="fas fa-clipboard-list me-2 text-success"></i>Default Checklists</h5>
    <a href="<?= url('/SuperAdmin/createChecklist') ?>" class="btn btn-sm btn-primary ms-auto"><i class="fas fa-plus me-1"></i>New Checklist</a>
</div>

<?php if (!empty($flash)): ?><div class="alert alert-info py-2 small"><?= e($flash) ?></div><?php endif; ?>

<div class="rs-card p-3">
<?php if (empty($checklists)): ?>
    <p class="text-muted small mb-0">No default checklists yet.</p>
<?php else: ?>
    <table class="table table-sm table-hover mb-0">
        <thead><tr><th>Name</th><th>Interval</th><th>Tasks</th><th>Active</th><th class="text-end">Actions</th></tr></thead>
        <tbody>
            <?php foreach ($checklists as $c): ?>
                <tr>
                    <td class="fw-semibold"><?= e($c['name']) ?></td>
                    <td class="small"><?= (int) $c['interval_days'] ?> days</td>
                    <td class="small"><?= (int) ($c['task_count'] ?? 0) ?></td>
                    <td><?= $c['is_active'] ? '<span class="badge bg-success">Active</span>' : '<span class="badge bg-secondary">Inactive</span>' ?></td>
                    <td class="text-end">
                        <a href="<?= url('/SuperAdmin/editChecklist/' . (int) $c['default_checklist_id']) ?>" class="btn btn-sm btn-outline-secondary"><i class="fas fa-edit"></i></a>
                        <a href="<?= url('/SuperAdmin/deleteChecklist/' . (int) $c['default_checklist_id']) ?>" class="btn btn-sm btn-outline-danger" onclick="return confirm('Delete this checklist?')"><i class="fas fa-trash"></i></a>
                    </td>
                </tr>
            <?php endforeach; ?>
        </tbody>
    </table>
<?php endif; ?>
</div>