<?= $this->extend('admin/layout') ?>

<?= $this->section('content') ?>
<div class="d-flex justify-content-between align-items-center mb-4">
    <h1 class="h3 text-gray-800">Manage Certifications</h1>
    <a href="<?= base_url('admin/certifications/create') ?>" class="btn btn-primary">Add New Certification</a>
</div>

<div class="card shadow mb-4">
    <div class="card-body">
        <div class="table-responsive">
            <table class="table table-bordered" width="100%" cellspacing="0">
                <thead>
                    <tr>
                        <th>Image</th>
                        <th>Title</th>
                        <th>Sort Order</th>
                        <th>Status</th>
                        <th>Actions</th>
                    </tr>
                </thead>
                <tbody>
                    <?php foreach ($certifications as $cert): ?>
                    <tr>
                        <td>
                            <?php if ($cert['image']): ?>
                                <img src="<?= base_url('uploads/certifications/' . $cert['image']) ?>" alt="Certification" width="100">
                            <?php endif; ?>
                        </td>
                        <td><?= $cert['title'] ?></td>
                        <td><?= $cert['sort_order'] ?></td>
                        <td>
                            <?php if ($cert['status']): ?>
                                <span class="badge bg-success">Active</span>
                            <?php else: ?>
                                <span class="badge bg-danger">Inactive</span>
                            <?php endif; ?>
                        </td>
                        <td>
                            <a href="<?= base_url('admin/certifications/edit/' . $cert['id']) ?>" class="btn btn-sm btn-info">Edit</a>
                            <a href="<?= base_url('admin/certifications/delete/' . $cert['id']) ?>" class="btn btn-sm btn-danger" onclick="return confirm('Are you sure?')">Delete</a>
                        </td>
                    </tr>
                    <?php endforeach; ?>
                </tbody>
            </table>
        </div>
    </div>
</div>
<?= $this->endSection() ?>
