<?php $__env->startSection('title', 'Commandes'); ?>
<?php $__env->startSection('page-title', 'Gestion des Commandes'); ?>

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


<div class="flex flex-wrap gap-2 mb-6">
    <?php $__currentLoopData = [null => 'Toutes', 'pending' => 'En attente', 'confirmed' => 'Confirmées', 'processing' => 'En traitement', 'shipped' => 'Expédiées', 'delivered' => 'Livrées', 'cancelled' => 'Annulées']; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $status => $label): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
    <a href="<?php echo e(route('admin.orders.index', $status ? ['status' => $status] : [])); ?>"
       class="px-4 py-2 rounded-xl text-xs font-medium transition-all <?php echo e($statusFilter === $status || ($status === null && !$statusFilter) ? 'bg-primary text-white shadow-sm' : 'bg-white text-gray-600 hover:bg-gray-50 border border-gray-200'); ?>">
        <?php echo e($label); ?>

    </a>
    <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
</div>

<div class="bg-white rounded-2xl shadow-sm border border-gray-100 overflow-hidden">
    <div class="overflow-x-auto">
        <table class="w-full text-sm">
            <thead>
                <tr class="bg-gray-50 border-b border-gray-100">
                    <th class="text-left px-5 py-3.5 font-semibold text-gray-600">N° Commande</th>
                    <th class="text-left px-5 py-3.5 font-semibold text-gray-600 hidden sm:table-cell">Client</th>
                    <th class="text-left px-5 py-3.5 font-semibold text-gray-600 hidden md:table-cell">Montant</th>
                    <th class="text-left px-5 py-3.5 font-semibold text-gray-600">Statut</th>
                    <th class="text-left px-5 py-3.5 font-semibold text-gray-600 hidden lg:table-cell">Date</th>
                    <th class="text-right px-5 py-3.5 font-semibold text-gray-600">Actions</th>
                </tr>
            </thead>
            <tbody class="divide-y divide-gray-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-gray-50 transition-colors">
                    <td class="px-5 py-3.5">
                        <span class="font-mono text-xs font-semibold text-gray-700"><?php echo e($order->order_number); ?></span>
                        <p class="text-xs text-gray-400"><?php echo e($order->items->count()); ?> article(s)</p>
                    </td>
                    <td class="px-5 py-3.5 hidden sm:table-cell">
                        <div class="font-medium text-gray-800"><?php echo e($order->customer_name); ?></div>
                        <div class="text-xs text-gray-400"><?php echo e($order->customer_phone); ?></div>
                    </td>
                    <td class="px-5 py-3.5 hidden md:table-cell font-bold text-gray-800">
                        <?php echo e(number_format($order->total_amount, 0, ',', ' ')); ?> FCFA
                    </td>
                    <td class="px-5 py-3.5">
                        <span class="inline-block px-2.5 py-0.5 rounded-full text-xs font-medium
                            <?php if($order->status === 'pending'): ?> bg-yellow-100 text-yellow-700
                            <?php elseif($order->status === 'confirmed'): ?> bg-blue-100 text-blue-700
                            <?php elseif($order->status === 'processing'): ?> bg-indigo-100 text-indigo-700
                            <?php elseif($order->status === 'shipped'): ?> bg-purple-100 text-purple-700
                            <?php elseif($order->status === 'delivered'): ?> bg-green-100 text-green-700
                            <?php elseif($order->status === 'cancelled'): ?> bg-red-100 text-red-700
                            <?php else: ?> bg-gray-100 text-gray-700 <?php endif; ?>">
                            <?php echo e($order->status_label); ?>

                        </span>
                    </td>
                    <td class="px-5 py-3.5 hidden lg:table-cell text-gray-400 text-xs">
                        <?php echo e($order->created_at->format('d/m/Y H:i')); ?>

                    </td>
                    <td class="px-5 py-3.5 text-right">
                        <div class="flex items-center justify-end gap-2">
                            <a href="<?php echo e(route('admin.orders.show', $order)); ?>"
                               class="p-2 text-blue-600 hover:bg-blue-50 rounded-lg transition-colors" title="Voir">
                                <i class="fas fa-eye"></i>
                            </a>
                            <form action="<?php echo e(route('admin.orders.destroy', $order)); ?>" method="POST"
                                  onsubmit="return confirm('Supprimer cette commande ?')">
                                <?php echo csrf_field(); ?> <?php echo method_field('DELETE'); ?>
                                <button type="submit" class="p-2 text-red-500 hover:bg-red-50 rounded-lg transition-colors">
                                    <i class="fas fa-trash"></i>
                                </button>
                            </form>
                        </div>
                    </td>
                </tr>
                <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); if ($__empty_1): ?>
                <tr>
                    <td colspan="6" class="px-5 py-12 text-center text-gray-400">
                        <i class="fas fa-inbox text-3xl mb-2 block"></i>
                        Aucune commande trouvée.
                    </td>
                </tr>
                <?php endif; ?>
            </tbody>
        </table>
    </div>

    <?php if($orders->hasPages()): ?>
    <div class="px-5 py-4 border-t border-gray-100">
        <?php echo e($orders->links()); ?>

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

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

<?php echo $__env->make('layouts.admin', array_diff_key(get_defined_vars(), ['__data' => 1, '__path' => 1]))->render(); ?><?php /**PATH /home/astechc1/public_html/artisanal/resources/views/admin/orders/index.blade.php ENDPATH**/ ?>