@extends('themes.saijana.layouts.app')

@section('title', 'Commande confirmée - '.($site_name ?? 'Mon Site'))

@section('content')
<div class="max-w-2xl mx-auto px-6 py-16 text-center">
    <div class="inline-flex items-center justify-center w-16 h-16 rounded-full bg-emerald-100 text-emerald-600 mb-6">
        <svg class="w-8 h-8" fill="none" stroke="currentColor" viewBox="0 0 24 24"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M5 13l4 4L19 7"/></svg>
    </div>
    <h1 class="text-3xl font-bold text-slate-900 mb-4">Commande confirmée</h1>
    <p class="text-xl text-slate-600 mb-2">Merci pour votre commande !</p>
    <p class="text-slate-500 mb-8">Numéro de commande : <strong class="font-mono text-slate-800">{{ $order->number }}</strong></p>

    <div class="bg-white rounded-2xl border border-slate-200 p-8 text-left mb-8">
        <h3 class="font-semibold text-slate-800 mb-4">Récapitulatif</h3>
        @foreach($order->items ?? [] as $item)
        <div class="flex justify-between py-2">
            <span>{{ $item['name'] ?? '—' }} × {{ $item['qty'] ?? 0 }}</span>
            <span class="font-medium">{{ number_format(($item['price'] ?? 0) * ($item['qty'] ?? 0), 2, ',', ' ') }} €</span>
        </div>
        @endforeach
        @if($order->discount_amount > 0)
        <div class="flex justify-between py-2 text-emerald-600">
            <span>Réduction @if($order->coupon_code)({{ $order->coupon_code }})@endif</span>
            <span class="font-medium">−{{ number_format($order->discount_amount, 2, ',', ' ') }} €</span>
        </div>
        @endif
        @if($order->shipping_cost > 0)
        <div class="flex justify-between py-2 text-slate-600">
            <span>Livraison ({{ $order->shippingMethod?->name ?? '—' }})</span>
            <span>{{ number_format($order->shipping_cost, 2, ',', ' ') }} €</span>
        </div>
        @endif
        <div class="flex justify-between pt-4 mt-4 border-t border-slate-200 font-bold">
            <span>Total</span>
            <span>{{ number_format($order->total, 2, ',', ' ') }} €</span>
        </div>
    </div>

    <a href="{{ route('ecommerce.index') }}" class="inline-block px-8 py-3 bg-primary-500 text-white rounded-xl font-semibold hover:bg-primary-600 transition">Retour à la boutique</a>
</div>
@endsection
