<?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-services.store')); ?>" method="post">
                <?php echo csrf_field(); ?>
                <div class="row">
                    <div class="form-group width-50">
                        <label class="form-label">Service 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">Category<span class="required">*</span></label>
                        <select class="form-control" name="smm_category_id" required>
                            <option value="">Select category</option>
                            <?php $__currentLoopData = $categories; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $c): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                            <option value="<?php echo e($c->id); ?>"><?php echo e($c->name); ?></option>
                            <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
                        </select>
                    </div>
                </div>
                <div class="row">
                    <div class="form-group width-50">
                        <label class="form-label">Min quantity<span class="required">*</span></label>
                        <input type="number" class="form-control" name="min" value="1" min="0" required>
                    </div>
                    <div class="form-group width-50">
                        <label class="form-label">Max quantity<span class="required">*</span></label>
                        <input type="number" class="form-control" name="max" value="10000" min="1" required>
                    </div>
                </div>
                <div class="row">
                    <div class="form-group width-50">
                        <label class="form-label">Price per 1000<span class="required">*</span></label>
                        <input type="number" step="0.0001" class="form-control" name="price" placeholder="0.00" required>
                    </div>
                    <div class="form-group width-50">
                        <label class="form-label">Status</label>
                        <select class="form-control" name="status">
                            <option value="1">On</option>
                            <option value="0">Off</option>
                        </select>
                    </div>
                </div>
                <button type="submit" class="btn btn-primary">Add SMM service</button>
            </form>
        </div>
    </div>

    <div class="card table-card">
        <div class="table-header">
            <form method="get" action="<?php echo e(route('backend.smm-services.index')); ?>" class="table-search-form">
                <div class="table-search-form__group">
                    <div class="table-search table-search--narrow">
                        <input type="text" name="search" class="search-input" placeholder="Search services..." 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-services.index')); ?>" class="btn btn-outline">Clear</a>
                    <?php endif; ?>
                </div>
            </form>
        </div>
        <div class="table-responsive">
            <table class="table">
                <thead>
                    <tr>
                        <th>#</th>
                        <th>Name</th>
                        <th>Category</th>
                        <th>Provider</th>
                        <th>Min / Max</th>
                        <th>Price</th>
                        <th>Status</th>
                        <th>Action</th>
                    </tr>
                </thead>
                <tbody>
                    <?php $__empty_1 = true; $__currentLoopData = $services; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $svc): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); $__empty_1 = false; ?>
                    <tr>
                        <td><?php echo e($services->firstItem() + $loop->index); ?></td>
                        <td><?php echo e($svc->name); ?></td>
                        <td><?php echo e($svc->smmCategory->name ?? '-'); ?></td>
                        <td><?php echo e($svc->smmProvider->name ?? 'Manual'); ?></td>
                        <td><?php echo e($svc->min); ?> / <?php echo e($svc->max); ?></td>
                        <td><?php echo e(number_format($svc->price, 4)); ?></td>
                        <td><?php echo e($svc->status ? 'On' : 'Off'); ?></td>
                        <td>
                            <div class="table-actions">
                                <button type="button" class="table-btn edit-smm-service" data-id="<?php echo e($svc->id); ?>" data-name="<?php echo e($svc->name); ?>" data-smm-category-id="<?php echo e($svc->smm_category_id); ?>" data-min="<?php echo e($svc->min); ?>" data-max="<?php echo e($svc->max); ?>" data-price="<?php echo e($svc->price); ?>" data-status="<?php echo e($svc->status ? '1' : '0'); ?>" title="Edit"><i class="las la-pen"></i></button>
                                <form action="<?php echo e(route('backend.smm-services.destroy', $svc->id)); ?>" method="post" class="d-inline" onsubmit="return confirm('Delete this service?');">
                                    <?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="8" class="text-center">No SMM services yet.</td></tr>
                    <?php endif; ?>
                </tbody>
            </table>
        </div>
        <?php if($services instanceof \Illuminate\Pagination\LengthAwarePaginator): ?>
        <div class="pagination-wrapper">
            <?php echo e($services->links('vendor.pagination.default')); ?>

        </div>
        <?php endif; ?>
    </div>
</div>

<div class="modal" id="edit-smm-service-modal">
    <div class="modal-content">
        <div class="modal-header">
            <h3 class="modal-title">Edit SMM service</h3>
            <button class="close-modal"><i class="las la-times"></i></button>
        </div>
        <form action="<?php echo e(route('backend.smm-services.update', ['id' => '__ID__'])); ?>" method="post" id="edit-smm-service-form">
            <?php echo csrf_field(); ?>
            <?php echo method_field('PUT'); ?>
            <div class="modal-body">
                <div class="form-group mb-25">
                    <label class="form-label">Service name<span class="required">*</span></label>
                    <input type="text" class="form-control" name="name" id="edit-service-name" required>
                </div>
                <div class="form-group mb-25">
                    <label class="form-label">Category<span class="required">*</span></label>
                    <select class="form-control" name="smm_category_id" id="edit-service-smm-category-id" required>
                        <?php $__currentLoopData = $categories; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $c): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                        <option value="<?php echo e($c->id); ?>"><?php echo e($c->name); ?></option>
                        <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
                    </select>
                </div>
                <div class="form-group mb-25">
                    <label class="form-label">Min quantity<span class="required">*</span></label>
                    <input type="number" class="form-control" name="min" id="edit-service-min" min="0" required>
                </div>
                <div class="form-group mb-25">
                    <label class="form-label">Max quantity<span class="required">*</span></label>
                    <input type="number" class="form-control" name="max" id="edit-service-max" min="1" required>
                </div>
                <div class="form-group mb-25">
                    <label class="form-label">Price per 1000<span class="required">*</span></label>
                    <input type="number" step="0.0001" class="form-control" name="price" id="edit-service-price" required>
                </div>
                <div class="form-group mb-25">
                    <label class="form-label">Status</label>
                    <select class="form-control" name="status" id="edit-service-status">
                        <option value="1">On</option>
                        <option value="0">Off</option>
                    </select>
                </div>
            </div>
            <div class="modal-footer">
                <button class="btn btn-primary" type="submit">Update service</button>
            </div>
        </form>
    </div>
</div>
<?php $__env->stopSection(); ?>

<?php $__env->startPush('script'); ?>
<script>
document.querySelectorAll('.edit-smm-service').forEach(function(btn) {
    btn.addEventListener('click', function() {
        var modal = document.getElementById('edit-smm-service-modal');
        var form = document.getElementById('edit-smm-service-form');
        form.action = '<?php echo e(route("backend.smm-services.update", ["id" => "__ID__"])); ?>'.replace('__ID__', this.getAttribute('data-id'));
        document.getElementById('edit-service-name').value = this.getAttribute('data-name') || '';
        document.getElementById('edit-service-smm-category-id').value = this.getAttribute('data-smm-category-id') || '';
        document.getElementById('edit-service-min').value = this.getAttribute('data-min') || '1';
        document.getElementById('edit-service-max').value = this.getAttribute('data-max') || '10000';
        document.getElementById('edit-service-price').value = this.getAttribute('data-price') || '';
        document.getElementById('edit-service-status').value = this.getAttribute('data-status') ?? '1';
        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\social\product\core\resources\views/backend/smm/services/index.blade.php ENDPATH**/ ?>