

<?php $__env->startSection('header-title', 'Yeni Kütüphane Kategorisi'); ?>

<?php $__env->startSection('header-actions'); ?>
<a href="<?php echo e(route('admin.library-categories.index')); ?>" class="header-action-btn">
    <svg fill="none" viewBox="0 0 24 24" stroke="currentColor" stroke-width="2"><path stroke-linecap="round" stroke-linejoin="round" d="M10 19l-7-7m0 0l7-7m-7 7h18"/></svg>
    Geri
</a>
<?php $__env->stopSection(); ?>

<?php $__env->startSection('content'); ?>
<div class="page-header">
    <div>
        <h1 class="page-title">📁 Yeni Kütüphane Kategorisi</h1>
        <p class="page-subtitle">Kütüphane için yeni bir kategori oluşturun</p>
    </div>
</div>

<?php if($errors->any()): ?>
    <div class="flash-msg flash-error">
        <svg style="width:16px;height:16px;flex-shrink:0;" fill="none" viewBox="0 0 24 24" stroke="currentColor" stroke-width="2"><path stroke-linecap="round" stroke-linejoin="round" d="M12 8v4m0 4h.01M21 12a9 9 0 11-18 0 9 9 0 0118 0z"/></svg>
        <div><?php $__currentLoopData = $errors->all(); $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $error): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?><div><?php echo e($error); ?></div><?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?></div>
    </div>
<?php endif; ?>

<div style="display:grid;grid-template-columns:1fr 280px;gap:20px;align-items:start;">

    
    <div class="card">
        <div class="card-header">
            <h3 class="card-title">📂 Kategori Bilgileri</h3>
        </div>
        <div class="card-body">
            <form action="<?php echo e(route('admin.library-categories.store')); ?>" method="POST" id="createForm">
                <?php echo csrf_field(); ?>

                <div class="form-group">
                    <label class="form-label">Kategori Adı <span class="required">*</span></label>
                    <input type="text" name="name" id="nameInput" value="<?php echo e(old('name')); ?>"
                        class="form-control" placeholder="Örn: KPSS Genel Kültür, Askeri Tarih" required autofocus>
                </div>

                <div class="form-group">
                    <label class="form-label">Slug</label>
                    <input type="text" name="slug" id="slugInput" value="<?php echo e(old('slug')); ?>"
                        class="form-control" placeholder="Otomatik oluşturulur">
                    <div class="form-hint">Boş bırakılırsa isimden otomatik oluşturulur.</div>
                </div>

                <div class="form-group">
                    <label class="form-label">Açıklama</label>
                    <textarea name="description" rows="3" class="form-control" placeholder="Kategori hakkında kısa açıklama"><?php echo e(old('description')); ?></textarea>
                </div>

                <div class="form-row">
                    <div class="form-group">
                        <label class="form-label">Üst Kategori</label>
                        <select name="parent_id" class="form-control form-select">
                            <option value="">— Ana Kategori —</option>
                            <?php $__currentLoopData = $parentCategories; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $id => $name): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                                <option value="<?php echo e($id); ?>" <?php echo e(old('parent_id') == $id ? 'selected' : ''); ?>><?php echo e($name); ?></option>
                            <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
                        </select>
                    </div>
                    <div class="form-group">
                        <label class="form-label">Sıra</label>
                        <input type="number" name="order" value="<?php echo e(old('order', 0)); ?>" min="0" class="form-control">
                        <div class="form-hint">Küçük sayı önce görünür (0 = en önce)</div>
                    </div>
                </div>

                <div class="form-row">
                    <div class="form-group">
                        <label class="form-label">İkon (Emoji)</label>
                        <input type="text" name="icon" value="<?php echo e(old('icon', '📁')); ?>" class="form-control" placeholder="📁">
                    </div>
                    <div class="form-group">
                        <label class="form-label">Renk (Hex)</label>
                        <input type="text" name="color" value="<?php echo e(old('color', '#059669')); ?>" class="form-control" placeholder="#059669">
                    </div>
                </div>

                <div style="display:flex;gap:10px;">
                    <button type="submit" class="btn btn-primary">
                        <svg fill="none" viewBox="0 0 24 24" stroke="currentColor" stroke-width="2.5" style="width:15px;height:15px;"><path stroke-linecap="round" stroke-linejoin="round" d="M5 13l4 4L19 7"/></svg>
                        Kaydet
                    </button>
                    <a href="<?php echo e(route('admin.library-categories.index')); ?>" class="btn btn-secondary">İptal</a>
                </div>
            </form>
        </div>
    </div>

    
    <div>
        <div class="card">
            <div class="card-header"><h3 class="card-title">💡 İpuçları</h3></div>
            <div class="card-body" style="font-size:13px;color:#64748b;display:flex;flex-direction:column;gap:8px;">
                <div>• Ana kategoriler Üst Kategori seçilmeden oluşturulur.</div>
                <div>• Alt kategoriler bir ana kategoriye bağlıdır.</div>
                <div>• Sıra küçük sayılar önce görünür (0 en önce).</div>
                <div>• İkon alanına emoji girerek görsellik katabilirsiniz.</div>
                <div>• Renk alanına hex kodu girin (örn: #059669).</div>
            </div>
        </div>
    </div>

</div>

<script>
document.getElementById('nameInput').addEventListener('input', function() {
    const slugInput = document.getElementById('slugInput');
    if (!slugInput.dataset.manual) {
        slugInput.value = this.value
            .toLowerCase()
            .replace(/ğ/g,'g').replace(/ü/g,'u').replace(/ş/g,'s')
            .replace(/ı/g,'i').replace(/ö/g,'o').replace(/ç/g,'c')
            .replace(/[^a-z0-9\s-]/g,'')
            .trim()
            .replace(/\s+/g,'-')
            .replace(/-+/g,'-');
    }
});
document.getElementById('slugInput').addEventListener('input', function() {
    this.dataset.manual = 'true';
});
</script>

<?php $__env->stopSection(); ?>

<?php echo $__env->make('admin.layout', array_diff_key(get_defined_vars(), ['__data' => 1, '__path' => 1]))->render(); ?><?php /**PATH C:\xampp\htdocs\askeribilgiler\resources\views\admin\library-categories\create.blade.php ENDPATH**/ ?>