<?php $__env->startSection('title', 'Захиалгууд'); ?>
<?php $__env->startSection('page_title', 'Захиалгууд'); ?>

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

<div class="flex flex-wrap items-center gap-2 mb-6">
    <?php
        $tabs = ['' => 'Бүгд', 'submitted' => 'Илгээгдсэн', 'reviewing' => 'Хянагдаж буй', 'in_progress' => 'Хийгдэж буй', 'completed' => 'Дууссан', 'cancelled' => 'Цуцлагдсан'];
        $countMap = ['' => 'all', 'submitted' => 'submitted', 'reviewing' => 'reviewing', 'in_progress' => 'in_progress', 'completed' => 'completed', 'cancelled' => 'cancelled'];
    ?>
    <?php $__currentLoopData = $tabs; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $key => $label): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
        <a href="<?php echo e(route('admin.orders.index', array_filter(['status' => $key]))); ?>"
           class="px-4 py-2 rounded-lg text-sm font-semibold transition <?php echo e(request('status', '') === $key ? 'bg-nsma-red text-white' : 'bg-white border border-gray-200'); ?>">
            <?php echo e($label); ?> (<?php echo e($statusCounts[$countMap[$key]] ?? 0); ?>)
        </a>
    <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
</div>

<form method="GET" class="flex items-center gap-2 mb-6">
    <input type="hidden" name="status" value="<?php echo e(request('status')); ?>">
    <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 w-72">
    <select name="priority" class="px-4 py-2 border border-gray-200 rounded-lg outline-none">
        <option value="">Бүх ач холбогдол</option>
        <option value="urgent" <?php if(request('priority') === 'urgent'): echo 'selected'; endif; ?>>Яаралтай</option>
        <option value="high" <?php if(request('priority') === 'high'): echo 'selected'; endif; ?>>Өндөр</option>
        <option value="normal" <?php if(request('priority') === 'normal'): echo 'selected'; endif; ?>>Хэвийн</option>
        <option value="low" <?php if(request('priority') === 'low'): echo 'selected'; endif; ?>>Бага</option>
    </select>
    <button class="px-4 py-2 bg-nsma-dark text-white rounded-lg">Шүүх</button>
</form>

<div class="bg-white rounded-2xl border border-gray-100 overflow-hidden">
    <table class="w-full">
        <thead class="bg-gray-50 border-b">
            <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-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 = $orders; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $o): $__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-xs font-mono"><?php echo e($o->order_number); ?></td>
                    <td class="px-4 py-3">
                        <div class="font-semibold text-sm truncate max-w-xs"><?php echo e($o->title); ?></div>
                        <div class="text-xs text-gray-500"><?php echo e($o->created_at->format('Y-m-d')); ?></div>
                    </td>
                    <td class="px-4 py-3 text-sm"><?php echo e($o->client->name ?? '-'); ?></td>
                    <td class="px-4 py-3 text-sm"><?php echo e($o->service->title ?? '-'); ?></td>
                    <td class="px-4 py-3 text-sm"><?php echo e($o->deadline?->format('Y-m-d') ?? '-'); ?></td>
                    <td class="px-4 py-3 text-xs">
                        <?php $pColors = ['urgent' => 'red', 'high' => 'orange', 'normal' => 'gray', 'low' => 'gray']; ?>
                        <span class="px-2 py-1 rounded bg-<?php echo e($pColors[$o->priority] ?? 'gray'); ?>-100 text-<?php echo e($pColors[$o->priority] ?? 'gray'); ?>-700"><?php echo e(ucfirst($o->priority)); ?></span>
                    </td>
                    <td class="px-4 py-3"><span class="text-xs px-2 py-1 rounded-full bg-<?php echo e($o->statusColor()); ?>-100 text-<?php echo e($o->statusColor()); ?>-700"><?php echo e($o->statusLabel()); ?></span></td>
                    <td class="px-4 py-3 text-right">
                        <a href="<?php echo e(route('admin.orders.show', $o)); ?>" class="px-3 py-1 text-xs bg-nsma-red text-white rounded">Үзэх</a>
                    </td>
                </tr>
            <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); if ($__empty_1): ?>
                <tr><td colspan="8" class="text-center py-12 text-gray-500">Захиалга байхгүй байна.</td></tr>
            <?php endif; ?>
        </tbody>
    </table>
</div>

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

<?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/orders/index.blade.php ENDPATH**/ ?>