<?php $__env->startSection('content'); ?>
<div class="container">
    <div class="container-header">
        <h1><?php echo e($title); ?></h1>
    </div>

    <div class="card mb-25">
        <div class="card-body">
            <form action="<?php echo e(route('backend.smm-categories.store')); ?>" method="post">
                <?php echo csrf_field(); ?>
                <div class="row">
                    <div class="form-group width-50">
                        <label class="form-label">Category name<span class="required">*</span></label>
                        <input type="text" class="form-control" name="name" placeholder="e.g. Instagram Followers" required>
                    </div>
                    <div class="form-group width-50">
                        <label class="form-label">Sort order</label>
                        <input type="number" class="form-control" name="sort" value="0" min="0" placeholder="0">
                    </div>
                </div>
                <button type="submit" class="btn btn-primary">Add category</button>
            </form>
        </div>
    </div>

    <div class="card table-card">
        <div class="table-header">
            <form method="GET" action="<?php echo e(route('backend.smm-categories.index')); ?>" class="table-search-form">
                <div class="table-search">
                    <input type="text" name="search" class="search-input" placeholder="Search categories..." value="<?php echo e($search ?? ''); ?>">
                    <i class="las la-search"></i>
                </div>
                <button type="submit" class="btn btn-secondary search-btn">Search</button>
                <?php if(!empty($search)): ?>
                    <a href="<?php echo e(route('backend.smm-categories.index')); ?>" class="btn btn-outline">Clear</a>
                <?php endif; ?>
            </form>
        </div>
        <div class="table-responsive">
            <table class="table">
                <thead>
                    <tr>
                        <th>#</th>
                        <th>Name</th>
                        <th>Sort</th>
                        <th>Services</th>
                        <th>Action</th>
                    </tr>
                </thead>
                <tbody>
                    <?php $__empty_1 = true; $__currentLoopData = $categories; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $c): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); $__empty_1 = false; ?>
                    <tr>
                        <td><?php echo e($categories->firstItem() + $loop->index); ?></td>
                        <td><?php echo e($c->name); ?></td>
                        <td><?php echo e($c->sort); ?></td>
                        <td><?php echo e($c->smm_services_count ?? 0); ?></td>
                        <td>
                            <div class="table-actions">
                                <button type="button" class="table-btn edit-smm-category" data-id="<?php echo e($c->id); ?>" data-name="<?php echo e($c->name); ?>" data-sort="<?php echo e($c->sort); ?>" title="Edit"><i class="las la-pen"></i></button>
                                <form action="<?php echo e(route('backend.smm-categories.destroy', $c->id)); ?>" method="post" class="d-inline" onsubmit="return confirm('Delete this category?');">
                                    <?php echo csrf_field(); ?>
                                    <?php echo method_field('DELETE'); ?>
                                    <button type="submit" class="table-btn" title="Delete"><i class="las la-trash"></i></button>
                                </form>
                            </div>
                        </td>
                    </tr>
                    <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); if ($__empty_1): ?>
                    <tr><td colspan="5" class="text-center">No categories yet.</td></tr>
                    <?php endif; ?>
                </tbody>
            </table>
        </div>
        <?php echo e($categories->links('vendor.pagination.default')); ?>

    </div>
</div>

<div class="modal" id="edit-smm-category-modal">
    <div class="modal-content">
        <div class="modal-header">
            <h3 class="modal-title">Edit category</h3>
            <button class="close-modal"><i class="las la-times"></i></button>
        </div>
        <form action="<?php echo e(route('backend.smm-categories.update', ['id' => '__ID__'])); ?>" method="post" id="edit-smm-category-form">
            <?php echo csrf_field(); ?>
            <?php echo method_field('PUT'); ?>
            <div class="modal-body">
                <div class="form-group mb-25">
                    <label class="form-label">Category name<span class="required">*</span></label>
                    <input type="text" class="form-control" name="name" id="edit-category-name" required>
                </div>
                <div class="form-group mb-25">
                    <label class="form-label">Sort order</label>
                    <input type="number" class="form-control" name="sort" id="edit-category-sort" value="0" min="0">
                </div>
            </div>
            <div class="modal-footer">
                <button class="btn btn-primary" type="submit">Update category</button>
            </div>
        </form>
    </div>
</div>
<?php $__env->stopSection(); ?>

<?php $__env->startPush('script'); ?>
<script>
document.querySelectorAll('.edit-smm-category').forEach(function(btn) {
    btn.addEventListener('click', function() {
        var modal = document.getElementById('edit-smm-category-modal');
        var form = document.getElementById('edit-smm-category-form');
        form.action = '<?php echo e(route("backend.smm-categories.update", ["id" => "__ID__"])); ?>'.replace('__ID__', this.getAttribute('data-id'));
        document.getElementById('edit-category-name').value = this.getAttribute('data-name') || '';
        document.getElementById('edit-category-sort').value = this.getAttribute('data-sort') || '0';
        modal.classList.add('active');
    });
});
</script>
<?php $__env->stopPush(); ?>

<?php echo $__env->make('backend.layout.app', array_diff_key(get_defined_vars(), ['__data' => 1, '__path' => 1]))->render(); ?><?php /**PATH C:\Users\HP\Desktop\upgraded\mine\core\resources\views/backend/smm/categories/index.blade.php ENDPATH**/ ?>