<?= $this->extend('admin/layout/main') ?>
<?= $this->section('content') ?>
<h3 class="mb-3"><?= $slide ? lang('App.edit') : lang('App.add_new') ?> - سلايد</h3>
<div class="card p-4" style="max-width:500px;">
<form method="post" action="<?= $slide ? '/admin/site-slides/' . $slide['id'] : '/admin/site-slides' ?>" enctype="multipart/form-data">
    <?= csrf_field() ?>
    <div class="mb-3">
        <label class="form-label">الصورة</label><br>
        <?php if (!empty($slide['image'])): ?>
            <img src="<?= base_url('uploads/slides/' . $slide['image']) ?>" style="max-height:100px;border-radius:8px;margin-bottom:10px;display:block;">
        <?php endif; ?>
        <input type="file" name="image" accept="image/*" class="form-control" <?= $slide ? '' : 'required' ?>>
        <div class="form-text">يفضّل مقاس عريض (1600×600 تقريباً) لأفضل ظهور.</div>
    </div>
    <div class="mb-3">
        <label class="form-label">العنوان</label>
        <input type="text" name="title" class="form-control" value="<?= esc($slide['title'] ?? '') ?>">
    </div>
    <div class="mb-3">
        <label class="form-label">وصف مختصر</label>
        <input type="text" name="subtitle" class="form-control" value="<?= esc($slide['subtitle'] ?? '') ?>">
    </div>
    <div class="mb-3">
        <label class="form-label">ترتيب الظهور</label>
        <input type="number" name="sort_order" class="form-control" value="<?= esc($slide['sort_order'] ?? 0) ?>">
    </div>
    <div class="form-check mb-3">
        <input type="checkbox" name="is_active" class="form-check-input" value="1" <?= ($slide['is_active'] ?? 1) ? 'checked' : '' ?>>
        <label class="form-check-label"><?= lang('App.status') ?></label>
    </div>
    <button class="btn btn-dark"><?= lang('App.save') ?></button>
    <a href="/admin/site-slides" class="btn btn-light"><?= lang('App.cancel') ?></a>
</form>
</div>
<?= $this->endSection() ?>
