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

<?= $this->section('content') ?>
<h1 class="h3 mb-4 text-gray-800">Edit Banner</h1>

<div class="card shadow mb-4">
    <div class="card-body">
        <form action="<?= base_url('admin/banners/edit/' . $banner['id']) ?>" method="post" enctype="multipart/form-data">
            <?= csrf_field() ?>
            <div class="mb-3">
                <label>Banner Image</label><br>
                <?php if ($banner['image']): ?>
                    <img src="<?= base_url('uploads/banners/' . $banner['image']) ?>" alt="Banner" width="200" class="mb-2"><br>
                <?php endif; ?>
                <input type="file" name="image" class="form-control" accept="image/*">
                <small class="text-muted">Leave empty to keep existing image</small>
            </div>
            <div class="mb-3">
                <label>Title</label>
                <input type="text" name="title" class="form-control" value="<?= esc($banner['title']) ?>">
            </div>
            <div class="mb-3">
                <label>Subtitle</label>
                <input type="text" name="subtitle" class="form-control" value="<?= esc($banner['subtitle']) ?>">
            </div>
            <div class="mb-3">
                <label>Button Text</label>
                <input type="text" name="button_text" class="form-control" value="<?= esc($banner['button_text']) ?>">
            </div>
            <div class="mb-3">
                <label>Button Link</label>
                <input type="text" name="button_link" class="form-control" value="<?= esc($banner['button_link']) ?>">
            </div>
            <div class="mb-3">
                <label>Sort Order</label>
                <input type="number" name="sort_order" class="form-control" value="<?= esc($banner['sort_order']) ?>">
            </div>
            <div class="mb-3">
                <label>Status</label>
                <select name="status" class="form-control">
                    <option value="1" <?= $banner['status'] == 1 ? 'selected' : '' ?>>Active</option>
                    <option value="0" <?= $banner['status'] == 0 ? 'selected' : '' ?>>Inactive</option>
                </select>
            </div>
            <button type="submit" class="btn btn-success">Update Banner</button>
            <a href="<?= base_url('admin/banners') ?>" class="btn btn-secondary">Cancel</a>
        </form>
    </div>
</div>
<?= $this->endSection() ?>
