@extends('admin.layout')

@section('title', 'Commandes')
@section('header', 'Commandes')

@section('content')
<div class="bg-white rounded-2xl border border-slate-200 overflow-hidden">
    <div class="overflow-x-auto">
    <table class="w-full min-w-[600px]">
        <thead class="bg-slate-50 text-left text-sm text-slate-500">
            <tr>
                <th class="px-6 py-3 font-medium">N°</th>
                <th class="px-6 py-3 font-medium">Client</th>
                <th class="px-6 py-3 font-medium">Total</th>
                <th class="px-6 py-3 font-medium">Statut</th>
                <th class="px-6 py-3 font-medium">Date</th>
                <th class="px-6 py-3 font-medium"></th>
            </tr>
        </thead>
        <tbody class="divide-y divide-slate-100">
            @forelse($orders as $order)
            <tr class="hover:bg-slate-50/50">
                <td class="px-6 py-4 font-mono text-sm">{{ $order->number }}</td>
                <td class="px-6 py-4">{{ $order->customer_name }}<br><span class="text-sm text-slate-500">{{ $order->customer_email }}</span></td>
                <td class="px-6 py-4 font-semibold">{{ number_format($order->total, 2, ',', ' ') }} €</td>
                <td class="px-6 py-4"><span class="px-2 py-1 rounded-lg text-xs font-medium {{ $order->status === 'paid' ? 'bg-emerald-100 text-emerald-700' : ($order->status === 'shipped' ? 'bg-blue-100 text-blue-700' : ($order->status === 'cancelled' ? 'bg-red-100 text-red-700' : 'bg-amber-100 text-amber-700')) }}">{{ $order->status }}</span></td>
                <td class="px-6 py-4 text-sm text-slate-500">{{ $order->created_at->format('d/m/Y H:i') }}</td>
                <td class="px-6 py-4"><a href="{{ route('admin.ecommerce.orders.show', $order) }}" class="text-primary-500 hover:underline text-sm">Voir</a></td>
            </tr>
            @empty
            <tr><td colspan="6" class="px-6 py-12 text-center text-slate-500">Aucune commande.</td></tr>
            @endforelse
        </tbody>
    </table>
    </div>
</div>

<div class="mt-4">{{ $orders->links() }}</div>
@endsection
