<?php $__env->startSection('title', 'Үйлчилгээ'); ?>
<?php $__env->startSection('page_title', 'Үйлчилгээ'); ?>

<?php $__env->startSection('content'); ?>

<div class="flex items-center justify-between mb-6">
    <form method="GET" class="flex items-center gap-2">
        <input type="text" name="search" value="<?php echo e(request('search')); ?>" placeholder="Хайх..." class="px-4 py-2 border border-gray-200 rounded-lg outline-none focus:border-nsma-red">
        <select name="status" class="px-4 py-2 border border-gray-200 rounded-lg outline-none">
            <option value="">Бүх төлөв</option>
            <option value="active" <?php if(request('status') === 'active'): echo 'selected'; endif; ?>>Идэвхтэй</option>
            <option value="inactive" <?php if(request('status') === 'inactive'): echo 'selected'; endif; ?>>Идэвхгүй</option>
        </select>
        <button class="px-4 py-2 bg-nsma-dark text-white rounded-lg">Шүүх</button>
    </form>
    <a href="<?php echo e(route('admin.services.create')); ?>" class="bg-nsma-red text-white font-semibold px-4 py-2 rounded-lg hover:bg-red-600">+ Шинэ үйлчилгээ</a>
</div>

<div class="bg-white rounded-2xl border border-gray-100 overflow-hidden">
    <table class="w-full">
        <thead class="bg-gray-50 border-b border-gray-200">
            <tr>
                <th class="text-left px-4 py-3 text-xs font-semibold uppercase">Эрэмбэ</th>
                <th class="text-left px-4 py-3 text-xs font-semibold uppercase">Нэр</th>
                <th class="text-left px-4 py-3 text-xs font-semibold uppercase">Тайлбар</th>
                <th class="text-left px-4 py-3 text-xs font-semibold uppercase">Нүүрэнд</th>
                <th class="text-left px-4 py-3 text-xs font-semibold uppercase">Төлөв</th>
                <th class="text-right px-4 py-3 text-xs font-semibold uppercase">Үйлдэл</th>
            </tr>
        </thead>
        <tbody>
            <?php $__empty_1 = true; $__currentLoopData = $services; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $s): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); $__empty_1 = false; ?>
                <tr class="border-b border-gray-100 hover:bg-gray-50">
                    <td class="px-4 py-3 text-sm"><?php echo e($s->sort_order); ?></td>
                    <td class="px-4 py-3">
                        <div class="flex items-center gap-3">
                            <?php if($s->iconImageUrl()): ?>
                                <img src="<?php echo e($s->iconImageUrl()); ?>" class="w-10 h-10 rounded-lg object-cover">
                            <?php endif; ?>
                            <div>
                                <div class="font-semibold"><?php echo e($s->title); ?></div>
                                <div class="text-xs text-gray-500"><?php echo e($s->slug); ?></div>
                            </div>
                        </div>
                    </td>
                    <td class="px-4 py-3 text-sm text-gray-600 max-w-xs truncate"><?php echo e($s->short_description); ?></td>
                    <td class="px-4 py-3"><input type="checkbox" <?php echo e($s->show_on_home ? 'checked' : ''); ?> disabled class="rounded"></td>
                    <td class="px-4 py-3">
                        <button data-toggle="<?php echo e($s->id); ?>" class="text-xs px-3 py-1 rounded-full <?php echo e($s->is_active ? 'bg-green-100 text-green-700' : 'bg-gray-100 text-gray-600'); ?>">
                            <?php echo e($s->is_active ? 'Идэвхтэй' : 'Идэвхгүй'); ?>

                        </button>
                    </td>
                    <td class="px-4 py-3 text-right">
                        <a href="<?php echo e(route('admin.services.edit', $s)); ?>" class="inline-block px-3 py-1 text-xs bg-nsma-dark text-white rounded">Засах</a>
                        <form action="<?php echo e(route('admin.services.destroy', $s)); ?>" method="POST" class="inline" onsubmit="return confirm('Устгах уу?')">
                            <?php echo csrf_field(); ?> <?php echo method_field('DELETE'); ?>
                            <button class="px-3 py-1 text-xs bg-red-500 text-white rounded">Устгах</button>
                        </form>
                    </td>
                </tr>
            <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); if ($__empty_1): ?>
                <tr><td colspan="6" class="text-center py-12 text-gray-500">Үйлчилгээ нэмээгүй байна.</td></tr>
            <?php endif; ?>
        </tbody>
    </table>
</div>

<div class="mt-4"><?php echo e($services->links()); ?></div>

<?php $__env->startPush('scripts'); ?>
<script>
    document.querySelectorAll('[data-toggle]').forEach(btn => {
        btn.addEventListener('click', async () => {
            const id = btn.dataset.toggle;
            const r = await window.ajaxJson(`/admin/services/${id}/toggle`, { method: 'POST' });
            if (r.ok) { window.showToast(r.data.message); location.reload(); }
        });
    });
</script>
<?php $__env->stopPush(); ?>

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

<?php echo $__env->make('admin.layouts.app', array_diff_key(get_defined_vars(), ['__data' => 1, '__path' => 1]))->render(); ?><?php /**PATH C:\xampp\htdocs\uninsma.mn\resources\views/admin/services/index.blade.php ENDPATH**/ ?>