
<?php $__env->startSection('title', 'List Service'); ?>

<?php $__env->startSection('content'); ?>
<div class="py-4 space-y-4">
    <div class="flex items-center justify-between gap-3">
        <div>
            <h1 class="text-lg font-bold text-gray-800">List Service</h1>
            <p class="text-xs text-gray-500">Daftar tiket aktif untuk fallback jika kamera bermasalah.</p>
        </div>
        <a href="<?php echo e(route('technician.scanner')); ?>"
           class="inline-flex items-center gap-1.5 rounded-lg border border-emerald-200 bg-emerald-50 text-emerald-700 px-3 py-2 text-[11px] font-semibold hover:bg-emerald-100 transition">
            Buka Scanner
        </a>
    </div>

    <form method="GET" action="<?php echo e(route('technician.tickets.index')); ?>" class="grid grid-cols-1 sm:grid-cols-3 gap-2">
        <input type="text" name="search" value="<?php echo e($search); ?>" placeholder="Cari kode, pelanggan, perangkat"
               class="sm:col-span-2 rounded-xl border border-gray-300 px-4 py-2.5 text-sm focus:outline-none focus:ring-2 focus:ring-emerald-500 focus:border-transparent">
        <select name="status" class="rounded-xl border border-gray-300 px-3 py-2.5 text-sm focus:outline-none focus:ring-2 focus:ring-emerald-500 focus:border-transparent">
            <option value="">Semua status aktif</option>
            <option value="Pending" <?php if($status === 'Pending'): echo 'selected'; endif; ?>>Menunggu</option>
            <option value="Checking" <?php if($status === 'Checking'): echo 'selected'; endif; ?>>Sedang Diperiksa</option>
            <option value="Repairing" <?php if($status === 'Repairing'): echo 'selected'; endif; ?>>Sedang Dalam Perbaikan</option>
            <option value="Ready" <?php if($status === 'Ready'): echo 'selected'; endif; ?>>Siap Diambil</option>
        </select>
        <div class="sm:col-span-3 flex gap-2">
            <button type="submit" class="rounded-xl bg-emerald-600 text-white text-sm font-semibold px-4 py-2.5 hover:bg-emerald-700 transition">Filter</button>
            <a href="<?php echo e(route('technician.tickets.index')); ?>" class="rounded-xl border border-gray-300 text-gray-700 text-sm font-medium px-4 py-2.5 hover:bg-gray-50 transition">Reset</a>
        </div>
    </form>

    <?php
        $statusMap = [
            'Pending' => ['Menunggu', 'bg-yellow-100 text-yellow-700 border-yellow-200'],
            'Checking' => ['Sedang Diperiksa', 'bg-sky-100 text-sky-700 border-sky-200'],
            'Repairing' => ['Sedang Dalam Perbaikan', 'bg-blue-100 text-blue-700 border-blue-200'],
            'Ready' => ['Siap Diambil', 'bg-green-100 text-green-700 border-green-200'],
        ];
    ?>

    <?php if($tickets->isEmpty()): ?>
    <div class="rounded-xl bg-white border border-gray-200 p-6 text-center text-sm text-gray-500">
        Tidak ada tiket aktif sesuai filter.
    </div>
    <?php else: ?>
    <div class="space-y-2.5">
        <?php $__currentLoopData = $tickets; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $ticket): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
        <?php
            [$statusLabel, $statusClass] = $statusMap[$ticket->status] ?? [$ticket->status, 'bg-gray-100 text-gray-700 border-gray-200'];
        ?>
        <a href="<?php echo e(route('technician.book', $ticket)); ?>" class="block rounded-xl border border-gray-200 bg-white p-4 shadow-sm hover:border-emerald-300 hover:shadow transition">
            <div class="flex items-start justify-between gap-3">
                <div class="min-w-0">
                    <p class="font-mono font-semibold text-emerald-700 text-xs"><?php echo e($ticket->ticket_code); ?></p>
                    <p class="text-xs font-semibold text-gray-800 truncate"><?php echo e($ticket->customer->name); ?></p>
                    <p class="text-[11px] text-gray-500 truncate"><?php echo e($ticket->brand); ?> <?php echo e($ticket->model); ?> • <?php echo e($ticket->device_type); ?></p>
                    <div class="mt-2 flex gap-1.5 flex-wrap">
                        <span class="inline-flex items-center rounded-full border px-2 py-0.5 text-[10px] font-semibold <?php echo e($ticket->diagnosis_completed_at ? 'bg-sky-50 text-sky-700 border-sky-200' : 'bg-gray-50 text-gray-500 border-gray-200'); ?>">
                            <?php echo e($ticket->diagnosis_completed_at ? 'Diagnosa OK' : 'Diagnosa -'); ?>

                        </span>
                        <span class="inline-flex items-center rounded-full border px-2 py-0.5 text-[10px] font-semibold <?php echo e($ticket->final_check_passed_at ? 'bg-emerald-50 text-emerald-700 border-emerald-200' : 'bg-gray-50 text-gray-500 border-gray-200'); ?>">
                            <?php echo e($ticket->final_check_passed_at ? 'Final QC PASS' : 'Final QC -'); ?>

                        </span>
                    </div>
                </div>
                <span class="inline-flex items-center rounded-full border px-2.5 py-1 text-[11px] font-semibold <?php echo e($statusClass); ?>">
                    <?php echo e($statusLabel); ?>

                </span>
            </div>
            <?php if($ticket->repair_approved_at): ?>
            <p class="mt-2 text-[10px] text-emerald-700">Perbaikan disetujui admin: <?php echo e($ticket->repair_approved_at->format('d M Y H:i')); ?></p>
            <?php endif; ?>
        </a>
        <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
    </div>

    <div>
        <?php echo e($tickets->links()); ?>

    </div>
    <?php endif; ?>
</div>
<?php $__env->stopSection(); ?>

<?php echo $__env->make('layouts.technician', array_diff_key(get_defined_vars(), ['__data' => 1, '__path' => 1]))->render(); ?><?php /**PATH C:\laragon\www\Service-sistem\resources\views/technician/index.blade.php ENDPATH**/ ?>