

<?php $__env->startSection('content'); ?>
<div class="container mx-auto px-4 py-10">

    
    <div class="flex flex-col md:flex-row md:items-center justify-between gap-6 mb-10">
        <div class="flex items-center gap-5">
            <div class="w-14 h-14 bg-gradient-to-br from-pink-400 to-pink-600 text-white rounded-[20px] flex items-center justify-center shadow-xl shadow-pink-200 rotate-3">
                <i data-lucide="shopping-bag" class="w-7 h-7"></i>
            </div>
            <div>
                <h2 class="text-3xl font-black text-slate-800 italic leading-tight tracking-tighter">Manajemen Pesanan</h2>
                <div class="flex items-center gap-2 mt-1">
                    <span class="w-2 h-2 bg-green-500 rounded-full animate-pulse"></span>
                    <p class="text-[11px] text-slate-400 font-bold uppercase tracking-[0.2em]">Panel Manajemen Antrean</p>
                </div>
            </div>
        </div>

        <div class="bg-white/50 backdrop-blur-md border border-pink-100 rounded-2xl px-6 py-3 flex items-center gap-4">
            <div class="text-right">
                <p class="text-[10px] font-black text-slate-400 uppercase tracking-widest">Total Pesanan</p>
                <p class="text-xl font-black text-pink-500 italic"><?php echo e(count($orders)); ?></p>
            </div>
            <div class="w-[1px] h-8 bg-pink-100"></div>
            <i data-lucide="bar-chart-3" class="text-pink-300 w-5 h-5"></i>
        </div>
    </div>

    
    
    
    <div class="mb-8">
        <form method="GET" action="<?php echo e(route('admin.orders.index')); ?>"
              class="bg-white rounded-[32px] p-6 shadow-sm border border-pink-50 flex flex-col md:flex-row gap-4 items-stretch md:items-center flex-wrap">

            
            <div class="flex-1 min-w-[180px] relative">
                <div class="absolute inset-y-0 left-4 flex items-center pointer-events-none">
                    <i data-lucide="user-search" class="w-4 h-4 text-pink-400"></i>
                </div>
                <input type="text"
                       name="search"
                       value="<?php echo e(request('search')); ?>"
                       placeholder="Cari nama pelanggan..."
                       class="w-full pl-11 pr-4 py-3.5 bg-slate-50 border-2 border-slate-100 focus:border-pink-400 rounded-2xl text-sm font-medium outline-none transition-all placeholder:text-slate-300">
            </div>

            
            <div class="relative md:w-52">
                <div class="absolute inset-y-0 left-4 flex items-center pointer-events-none">
                    <i data-lucide="activity" class="w-4 h-4 text-pink-400"></i>
                </div>
                <select name="status"
                        class="w-full pl-11 pr-4 py-3.5 bg-slate-50 border-2 border-slate-100 focus:border-pink-400 rounded-2xl text-sm font-medium outline-none transition-all appearance-none cursor-pointer">
                    <option value="">Semua Status</option>
                    <option value="pending"    <?php echo e(request('status') == 'pending'    ? 'selected' : ''); ?>>Belum Bayar</option>
                    <option value="paid"       <?php echo e(request('status') == 'paid'       ? 'selected' : ''); ?>>Sudah Dibayar</option>
                    <option value="packaging"  <?php echo e(request('status') == 'packaging'  ? 'selected' : ''); ?>>Dikemas</option>
                    <option value="picking_up" <?php echo e(request('status') == 'picking_up' ? 'selected' : ''); ?>>Kurir ke Toko</option>
                    <option value="shipping"   <?php echo e(request('status') == 'shipping'   ? 'selected' : ''); ?>>Dikirim</option>
                    <option value="completed"  <?php echo e(request('status') == 'completed'  ? 'selected' : ''); ?>>Selesai</option>
                    <option value="cancelled"  <?php echo e(request('status') == 'cancelled'  ? 'selected' : ''); ?>>Dibatalkan</option>
                </select>
                <div class="absolute inset-y-0 right-4 flex items-center pointer-events-none">
                    <i data-lucide="chevron-down" class="w-4 h-4 text-slate-400"></i>
                </div>
            </div>

            
            <div class="relative md:w-52">
                <div class="absolute inset-y-0 left-4 flex items-center pointer-events-none">
                    <i data-lucide="calendar" class="w-4 h-4 text-pink-400"></i>
                </div>
                <input type="date"
                       name="date"
                       value="<?php echo e(request('date')); ?>"
                       class="w-full pl-11 pr-4 py-3.5 bg-slate-50 border-2 border-slate-100 focus:border-pink-400 rounded-2xl text-sm font-medium outline-none transition-all cursor-pointer">
            </div>

            
            <button type="submit"
                    class="px-8 py-3.5 bg-slate-900 hover:bg-pink-500 text-white font-black text-xs uppercase tracking-widest rounded-2xl transition-all shadow-lg shadow-slate-200 hover:shadow-pink-200 flex items-center gap-2 justify-center whitespace-nowrap">
                <i data-lucide="search" class="w-4 h-4"></i>
                Cari
            </button>

            
            <?php if(request('search') || request('status') || request('date')): ?>
            <a href="<?php echo e(route('admin.orders.index')); ?>"
               class="px-6 py-3.5 bg-pink-50 hover:bg-pink-100 text-pink-500 font-black text-xs uppercase tracking-widest rounded-2xl transition-all flex items-center gap-2 justify-center whitespace-nowrap">
                <i data-lucide="x" class="w-4 h-4"></i>
                Reset
            </a>
            <?php endif; ?>

        </form>

        
        <?php if(request('search') || request('status') || request('date')): ?>
        <div class="mt-4 flex items-center gap-3 flex-wrap px-2">
            <span class="text-xs text-slate-400 font-bold uppercase tracking-widest">Filter aktif:</span>

            <?php if(request('search')): ?>
            <span class="inline-flex items-center gap-1.5 px-3 py-1.5 bg-pink-50 text-pink-600 rounded-full text-[10px] font-black uppercase">
                <i data-lucide="user" class="w-3 h-3"></i>
                "<?php echo e(request('search')); ?>"
            </span>
            <?php endif; ?>

            <?php if(request('status')): ?>
            <?php
                $statusLabel = match(request('status')) {
                    'pending'    => 'Belum Bayar',
                    'paid'       => 'Sudah Dibayar',
                    'packaging'  => 'Dikemas',
                    'picking_up' => 'Kurir ke Toko',
                    'shipping'   => 'Dikirim',
                    'completed'  => 'Selesai',
                    'cancelled'  => 'Dibatalkan',
                    default      => request('status'),
                };
            ?>
            <span class="inline-flex items-center gap-1.5 px-3 py-1.5 bg-slate-100 text-slate-600 rounded-full text-[10px] font-black uppercase">
                <i data-lucide="activity" class="w-3 h-3"></i>
                <?php echo e($statusLabel); ?>

            </span>
            <?php endif; ?>

            <?php if(request('date')): ?>
            <span class="inline-flex items-center gap-1.5 px-3 py-1.5 bg-slate-100 text-slate-600 rounded-full text-[10px] font-black uppercase">
                <i data-lucide="calendar" class="w-3 h-3"></i>
                <?php echo e(\Carbon\Carbon::parse(request('date'))->format('d M Y')); ?>

            </span>
            <?php endif; ?>

            <span class="text-[10px] text-slate-400 font-bold italic">— <?php echo e($orders->count()); ?> pesanan ditemukan</span>
        </div>
        <?php endif; ?>
    </div>
    

    
    <?php if(session('success')): ?>
    <div class="mb-6 flex items-center gap-3 px-5 py-4 bg-emerald-50 border border-emerald-100 text-emerald-600 rounded-2xl text-sm font-bold">
        <i data-lucide="check-circle" class="w-4 h-4 flex-shrink-0"></i>
        <?php echo e(session('success')); ?>

    </div>
    <?php endif; ?>
    <?php if(session('error')): ?>
    <div class="mb-6 flex items-center gap-3 px-5 py-4 bg-red-50 border border-red-100 text-red-500 rounded-2xl text-sm font-bold">
        <i data-lucide="alert-circle" class="w-4 h-4 flex-shrink-0"></i>
        <?php echo e(session('error')); ?>

    </div>
    <?php endif; ?>

    
    <div class="bg-white/70 backdrop-blur-2xl rounded-[45px] shadow-2xl shadow-pink-100/50 border border-white overflow-hidden">
        <div class="overflow-x-auto">
            <table class="w-full text-left border-collapse">
                <thead>
                    <tr class="bg-gradient-to-r from-pink-50/50 to-transparent text-pink-600">
                        <th class="px-6 py-6 text-[11px] font-black uppercase tracking-[0.2em]">Order</th>
                        <th class="px-6 py-6 text-[11px] font-black uppercase tracking-[0.2em]">Pelanggan</th>
                        <th class="px-6 py-6 text-[11px] font-black uppercase tracking-[0.2em]">Total</th>
                        <th class="px-6 py-6 text-[11px] font-black uppercase tracking-[0.2em]">Status</th>
                        <th class="px-6 py-6 text-[11px] font-black uppercase tracking-[0.2em]">Kurir</th>
                        <th class="px-6 py-6 text-[11px] font-black uppercase tracking-[0.2em]">Bukti Foto</th>
                        <th class="px-6 py-6 text-[11px] font-black uppercase tracking-[0.2em] text-right">Aksi</th>
                    </tr>
                </thead>
                <tbody class="divide-y divide-pink-50/50">
                    <?php $__empty_1 = true; $__currentLoopData = $orders; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $order): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); $__empty_1 = false; ?>
                    <tr class="hover:bg-white/50 transition-all duration-300 group">
                        <td class="px-6 py-5">
                            <span class="w-10 h-10 rounded-xl bg-slate-900 text-white flex items-center justify-center text-[10px] font-black shadow-lg">
                                #<?php echo e($order->id); ?>

                            </span>
                            <p class="text-[9px] text-slate-400 font-bold mt-1 italic"><?php echo e($order->created_at->format('d M, H:i')); ?></p>
                        </td>

                        <td class="px-6 py-5">
                            <div class="text-sm font-black text-slate-800 group-hover:text-pink-600 transition-colors"><?php echo e($order->user->name); ?></div>
                            <div class="flex items-center gap-1.5 text-[10px] text-slate-400 font-bold mt-0.5">
                                <i data-lucide="phone" class="w-3 h-3 text-pink-300"></i> <?php echo e($order->phone); ?>

                            </div>
                        </td>

                        <td class="px-6 py-5">
                            <div class="text-sm font-black text-slate-900 italic">Rp <?php echo e(number_format($order->total_price, 0, ',', '.')); ?></div>
                            <span class="text-[9px] font-bold text-slate-400 uppercase tracking-tighter"><?php echo e($order->payment_method); ?></span>
                        </td>

                        <td class="px-6 py-5">
                            <?php
                                $statusBadge = match($order->status) {
                                    'pending'    => ['class' => 'bg-rose-50 text-rose-600 border-rose-100',          'label' => 'Belum Bayar'],
                                    'paid'       => ['class' => 'bg-green-50 text-green-600 border-green-100',        'label' => 'Sudah Dibayar'],
                                    'packaging'  => ['class' => 'bg-blue-50 text-blue-600 border-blue-100',          'label' => '📦 Dikemas'],
                                    'picking_up' => ['class' => 'bg-amber-50 text-amber-600 border-amber-100',       'label' => '🏪 Kurir ke Toko'],
                                    'shipping'   => ['class' => 'bg-pink-50 text-pink-600 border-pink-100',          'label' => '🚚 Dikirim'],
                                    'completed'  => ['class' => 'bg-emerald-50 text-emerald-600 border-emerald-100', 'label' => '✅ Selesai'],
                                    'cancelled'  => ['class' => 'bg-slate-50 text-slate-400 border-slate-100',       'label' => 'Dibatalkan'],
                                    default      => ['class' => 'bg-slate-50 text-slate-400 border-slate-100',       'label' => $order->status],
                                };
                            ?>
                            <span class="inline-flex items-center text-[9px] font-black <?php echo e($statusBadge['class']); ?> px-3 py-1.5 rounded-full uppercase tracking-widest border">
                                <?php echo e($statusBadge['label']); ?>

                            </span>
                            <div class="mt-1">
                                <span class="text-[8px] font-bold <?php echo e($order->payment_status === 'paid' ? 'text-emerald-500' : 'text-amber-500'); ?> uppercase">
                                    <?php echo e($order->payment_status === 'paid' ? '💰 Lunas' : '⏳ Belum Bayar'); ?>

                                </span>
                            </div>
                        </td>

                        <td class="px-6 py-5">
                            <?php if($order->courier): ?>
                                <div class="text-xs font-bold text-slate-700"><?php echo e($order->courier->name); ?></div>
                                <?php if($order->status === 'picking_up'): ?>
                                    <span class="text-[8px] font-black text-amber-500 uppercase">Menuju Toko</span>
                                <?php elseif($order->status === 'shipping'): ?>
                                    <span class="text-[8px] font-black text-pink-500 uppercase">Sedang Antar</span>
                                <?php endif; ?>
                            <?php else: ?>
                                <span class="text-[9px] text-slate-400 italic">Belum ada kurir</span>
                            <?php endif; ?>
                        </td>

                        <td class="px-6 py-5">
                            <?php if($order->proof_image): ?>
                                <div class="w-14 h-14 rounded-2xl overflow-hidden border-2 border-emerald-100 shadow-sm cursor-pointer hover:scale-110 transition-transform"
                                     onclick="window.open('<?php echo e(asset('storage/' . $order->proof_image)); ?>')">
                                    <img src="<?php echo e(asset('storage/' . $order->proof_image)); ?>" class="w-full h-full object-cover">
                                </div>
                                <p class="text-[8px] text-emerald-500 font-bold mt-1">
                                    <?php echo e($order->delivered_at ? \Carbon\Carbon::parse($order->delivered_at)->format('d M, H:i') : '-'); ?>

                                </p>
                            <?php else: ?>
                                <span class="text-[9px] text-slate-300 italic">-</span>
                            <?php endif; ?>
                        </td>

                        
                        <td class="px-6 py-5 text-right">
                            <div class="flex flex-col items-end gap-2">

                                
                                <?php if($order->status === 'packaging'): ?>
                                    <span class="text-[9px] font-black text-blue-500 italic">Sedang Dikemas...</span>
                                <?php elseif($order->status === 'picking_up'): ?>
                                    <span class="text-[9px] font-black text-amber-500 italic">Kurir Menuju Toko</span>
                                <?php elseif($order->status === 'shipping'): ?>
                                    <span class="text-[9px] font-black text-pink-500 italic">Dalam Perjalanan</span>
                                <?php elseif($order->status === 'completed'): ?>
                                    <div class="inline-flex items-center gap-2 text-emerald-500 bg-emerald-50 px-4 py-2 rounded-2xl border border-emerald-100">
                                        <i data-lucide="check" class="w-4 h-4"></i>
                                        <span class="text-[10px] font-black italic uppercase">Selesai</span>
                                    </div>
                                <?php elseif($order->status === 'cancelled'): ?>
                                    <span class="text-[9px] font-black text-slate-400 italic">Pesanan Dibatalkan</span>
                                <?php elseif($order->status === 'pending'): ?>
                                    <span class="text-[9px] font-black text-slate-400 italic">Menunggu Pembayaran...</span>
                                <?php else: ?>
                                    <span class="text-[9px] font-black text-slate-400 italic"><?php echo e($order->status); ?></span>
                                <?php endif; ?>

                                
                                <?php if(!in_array($order->status, ['completed', 'cancelled', 'shipping'])): ?>
                                <form action="<?php echo e(route('admin.orders.cancel', $order)); ?>" method="POST"
                                      onsubmit="return confirm('Batalkan pesanan #<?php echo e($order->id); ?> dari <?php echo e($order->user->name); ?>?')">
                                    <?php echo csrf_field(); ?> <?php echo method_field('PATCH'); ?>
                                    <button type="submit"
                                            class="inline-flex items-center gap-1.5 px-4 py-2 bg-red-50 hover:bg-red-500 text-red-500 hover:text-white border border-red-100 hover:border-red-500 text-[10px] font-black uppercase tracking-widest rounded-2xl transition-all duration-300">
                                        <i data-lucide="x-circle" class="w-3.5 h-3.5"></i>
                                        Batalkan
                                    </button>
                                </form>
                                <?php endif; ?>

                            </div>
                        </td>
                        
                    </tr>
                    <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); if ($__empty_1): ?>
                    <tr>
                        <td colspan="7" class="text-center py-20">
                            <div class="flex flex-col items-center gap-3">
                                <div class="w-16 h-16 bg-pink-50 text-pink-300 rounded-full flex items-center justify-center">
                                    <i data-lucide="inbox" class="w-8 h-8"></i>
                                </div>
                                <p class="font-black text-slate-700">Pesanan tidak ditemukan</p>
                                <?php if(request('search') || request('status') || request('date')): ?>
                                <p class="text-slate-400 text-sm">Coba ubah filter pencarian</p>
                                <a href="<?php echo e(route('admin.orders.index')); ?>"
                                   class="inline-block mt-2 px-6 py-2.5 bg-slate-900 text-white font-black text-xs uppercase tracking-widest rounded-2xl hover:bg-pink-500 transition-all">
                                    Lihat Semua Pesanan
                                </a>
                                <?php endif; ?>
                            </div>
                        </td>
                    </tr>
                    <?php endif; ?>
                </tbody>
            </table>
        </div>
    </div>
</div>

<script>lucide.createIcons();</script>
<?php $__env->stopSection(); ?>
<?php echo $__env->make('layouts.app', array_diff_key(get_defined_vars(), ['__data' => 1, '__path' => 1]))->render(); ?><?php /**PATH C:\laragon\www\SwiftCart\resources\views/admin/orders/index.blade.php ENDPATH**/ ?>