<?php include __DIR__ . '/../layout/header.php'; ?>

<div class="admin-card-header" style="padding:0 0 20px;border-bottom:none;">
    <div>
        <h2 style="font-size:18px;font-weight:800;color:var(--text-1);margin:0;">Yeni Kategori Ekle</h2>
    </div>
    <a href="<?php echo $baseUrl; ?>/admin/categories" class="admin-btn">
        <i class="fa fa-arrow-left"></i> Listeye Dön
    </a>
</div>

<div class="admin-card" style="max-width:600px;">
    <form action="<?php echo $baseUrl; ?>/admin/categories/store" method="POST">

        <div class="admin-form-group">
            <label for="name">Kategori Adı *</label>
            <input type="text" id="name" name="name" required class="admin-input" placeholder="Örn: Lazer Yazıcılar" autofocus>
        </div>

        <div class="admin-form-group">
            <label for="slug">SEO URL (Slug)</label>
            <input type="text" id="slug" name="slug" class="admin-input" placeholder="Boş bırakırsanız otomatik oluşturulur">
            <small class="form-hint">Boş bırakırsanız kategori adından otomatik oluşturulur.</small>
        </div>

        <div class="admin-form-group">
            <label for="parent_slug">Üst Kategori</label>
            <select id="parent_slug" name="parent_slug" class="admin-select">
                <option value="">— Ana Kategori (Üst yok) —</option>
                <?php foreach ($categories as $cat): ?>
                <?php if (!$cat->parent_slug): ?>
                <option value="<?php echo htmlspecialchars($cat->slug); ?>"><?php echo htmlspecialchars($cat->name); ?></option>
                <?php endif; ?>
                <?php endforeach; ?>
            </select>
        </div>

        <div style="display:flex;gap:12px;justify-content:flex-end;padding-top:16px;border-top:1px solid var(--border);margin-top:8px;">
            <a href="<?php echo $baseUrl; ?>/admin/categories" class="admin-btn">İptal</a>
            <button type="submit" class="admin-btn admin-btn-primary">
                <i class="fa fa-save"></i> Kaydet
            </button>
        </div>
    </form>
</div>

<?php include __DIR__ . '/../layout/footer.php'; ?>
