

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

<?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">✏️ <?php echo e($libraryCategory->name); ?></h1>
        <p class="page-subtitle">Kategori bilgilerini düzenleyin</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.update', $libraryCategory)); ?>" method="POST" id="editForm">
                <?php echo csrf_field(); ?>
                <?php echo method_field('PUT'); ?>

                <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', $libraryCategory->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', $libraryCategory->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', $libraryCategory->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', $libraryCategory->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', $libraryCategory->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', $libraryCategory->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', $libraryCategory->color)); ?>" 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>
                        Güncelle
                    </button>
                    <a href="<?php echo e(route('admin.library-categories.index')); ?>" class="btn btn-secondary">İptal</a>
                    
                    <button type="button" class="btn btn-danger" style="margin-left:auto;"
                        onclick="if(confirm('Bu kategoriyi silmek istediğinizden emin misiniz?')) document.getElementById('deleteForm').submit();">
                        <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="M19 7l-.867 12.142A2 2 0 0116.138 21H7.862a2 2 0 01-1.995-1.858L5 7m5 4v6m4-6v6m1-10V6a2 2 0 012-2h2a2 2 0 012 2v4a2 2 0 002 2m-6 0h6"/></svg>
                        Sil
                    </button>
                </div>
            </form>

            
            <form id="deleteForm" action="<?php echo e(route('admin.library-categories.destroy', $libraryCategory)); ?>" method="POST" style="display:none;">
                <?php echo csrf_field(); ?>
                <?php echo method_field('DELETE'); ?>
            </form>
        </div>
    </div>

    
    <div>
        <div class="card">
            <div class="card-header"><h3 class="card-title">📊 Kategori Bilgileri</h3></div>
            <div class="card-body">
                <table style="width:100%;font-size:13px;">
                    <tr>
                        <td style="color:#64748b;padding:8px 0;">Slug:</td>
                        <td style="text-align:right;"><code style="font-size:11px;color:#0f172a;background:#f1f5f9;padding:4px 8px;border-radius:4px;"><?php echo e($libraryCategory->slug); ?></code></td>
                    </tr>
                    <tr>
                        <td style="color:#64748b;padding:8px 0;">İçerik Sayısı:</td>
                        <td style="text-align:right;"><strong><?php echo e($libraryCategory->contents_count ?? 0); ?></strong></td>
                    </tr>
                    <tr>
                        <td style="color:#64748b;padding:8px 0;">Alt Kategoriler:</td>
                        <td style="text-align:right;"><strong><?php echo e($libraryCategory->children_count ?? 0); ?></strong></td>
                    </tr>
                    <tr>
                        <td style="color:#64748b;padding:8px 0;">Oluşturulma:</td>
                        <td style="text-align:right;"><?php echo e($libraryCategory->created_at->format('d.m.Y H:i')); ?></td>
                    </tr>
                </table>
            </div>
        </div>
        <?php if($libraryCategory->children && $libraryCategory->children->count() > 0): ?>
        <div class="card" style="margin-top:16px;">
            <div class="card-header"><h3 class="card-title">📂 Alt Kategoriler</h3></div>
            <div class="card-body" style="padding:0;">
                <?php $__currentLoopData = $libraryCategory->children; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $child): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                <a href="<?php echo e(route('admin.library-categories.edit', $child)); ?>" style="display:flex;justify-content:space-between;align-items:center;padding:12px 16px;border-bottom:1px solid #f1f5f9;text-decoration:none;color:inherit;">
                    <span style="font-size:14px;"><?php echo e($child->icon); ?> <?php echo e($child->name); ?></span>
                    <span class="badge badge-blue"><?php echo e($child->contents_count ?? 0); ?></span>
                </a>
                <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
            </div>
        </div>
        <?php endif; ?>
    </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\edit.blade.php ENDPATH**/ ?>