<?php $c = $cat ?? null; ?>
<form class="form-card" method="post" action="<?= e(url('admin/kategori/kaydet')) ?>" enctype="multipart/form-data">
    <?= csrf_field() ?>
    <input type="hidden" name="id" value="<?= (int)($c['id'] ?? 0) ?>">

    <div class="form-row">
        <div class="form-group">
            <label>Kategori Adı *</label>
            <input name="name" value="<?= e($c['name'] ?? '') ?>" required>
        </div>
        <div class="form-group">
            <label>SEO Adres (slug) <small>boş bırakılırsa otomatik</small></label>
            <input name="slug" value="<?= e($c['slug'] ?? '') ?>" placeholder="otomatik">
        </div>
    </div>

    <div class="form-group">
        <label>Açıklama</label>
        <textarea name="description" rows="2"><?= e($c['description'] ?? '') ?></textarea>
    </div>

    <div class="form-row">
        <div class="form-group">
            <label>Emoji / İkon <small>(görsel yoksa gösterilir)</small></label>
            <input name="icon" value="<?= e($c['icon'] ?? '') ?>" placeholder="☕ 🍰 🥤 ...">
        </div>
        <div class="form-group">
            <label>Sıra</label>
            <input name="sort_order" type="number" value="<?= (int)($c['sort_order'] ?? 0) ?>">
        </div>
    </div>

    <div class="form-row">
        <div class="form-group">
            <label>Kategori Görseli (poster)</label>
            <input name="image" type="file" accept="image/*">
            <?php if (!empty($c['image'])): ?>
                <div class="current-media"><img src="<?= e(media_url($c['image'])) ?>" alt=""></div>
                <label class="switch small"><input type="checkbox" name="remove_image"> Görseli kaldır</label>
            <?php endif; ?>
        </div>
        <div class="form-group">
            <label>Kategori Videosu (mp4) <small>Laos tarzı hareketli kart</small></label>
            <input name="video" type="file" accept="video/*">
            <?php if (!empty($c['video'])): ?>
                <div class="current-media"><video muted loop autoplay playsinline><source src="<?= e(media_url($c['video'])) ?>"></video></div>
                <label class="switch small"><input type="checkbox" name="remove_video"> Videoyu kaldır</label>
            <?php endif; ?>
        </div>
    </div>

    <label class="switch">
        <input type="checkbox" name="is_active" <?= (!$c || $c['is_active']) ? 'checked' : '' ?>> Aktif (sitede göster)
    </label>

    <div class="form-actions">
        <button class="btn-primary" type="submit">Kaydet</button>
        <a class="btn-ghost" href="<?= e(url('admin/kategoriler')) ?>">İptal</a>
    </div>
</form>
