<?= $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 Banners</h1>
    <a href="<?= base_url('admin/banners/create') ?>" class="btn btn-primary">Add New Banner</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 ($banners as $banner): ?>
                    <tr>
                        <td>
                            <?php if ($banner['image']): ?>
                                <img src="<?= base_url('uploads/banners/' . $banner['image']) ?>" alt="Banner" width="100">
                            <?php endif; ?>
                        </td>
                        <td><?= $banner['title'] ?></td>
                        <td><?= $banner['sort_order'] ?></td>
                        <td>
                            <?php if ($banner['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/banners/edit/' . $banner['id']) ?>" class="btn btn-sm btn-info">Edit</a>
                            <a href="<?= base_url('admin/banners/delete/' . $banner['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() ?>
