<?= $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 Gallery</h1>
    <a href="<?= base_url('admin/gallery/create') ?>" class="btn btn-primary">Upload Images</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>Category</th>
                        <th>Title</th>
                        <th>Actions</th>
                    </tr>
                </thead>
                <tbody>
                    <?php foreach ($images as $img): ?>
                    <tr>
                        <td>
                            <?php if ($img['image']): ?>
                                <img src="<?= base_url('uploads/gallery/' . $img['image']) ?>" alt="Gallery" width="100">
                            <?php endif; ?>
                        </td>
                        <td><?= $img['category_name'] ?></td>
                        <td><?= $img['title'] ?></td>
                        <td>
                            <a href="<?= base_url('admin/gallery/delete/' . $img['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() ?>
