@extends('layouts.app')

@section('title', 'Order Confirmed')

@section('content')

<div class="container py-5">
    <div class="text-center mb-5">
        <i class="bi bi-check-circle text-sage" style="font-size:3.5rem;"></i>
        <h1 class="font-serif mt-3" style="font-size:1.9rem;">Thank you, {{ $order->full_name }}!</h1>
        <p class="text-muted-soft">Your order has been placed successfully. We'll contact you shortly to confirm delivery.</p>
        <p class="fw-semibold">Order Number: <span class="text-terracotta">{{ $order->order_number }}</span></p>
    </div>

    <div class="row justify-content-center">
        <div class="col-lg-7">
            <div class="border rounded p-4 bg-white mb-4">
                <h5 class="font-serif mb-3">Order Details</h5>
                @foreach($order->items as $item)
                    <div class="d-flex justify-content-between align-items-center mb-2 small">
                        <span>{{ $item->product_name }}@if($item->variant_label) <span class="text-muted-soft">({{ $item->variant_label }})</span>@endif &times; {{ $item->quantity }}</span>
                        <span>Rs. {{ number_format($item->line_total) }}</span>
                    </div>
                @endforeach
                <hr>
                <div class="d-flex justify-content-between mb-2">
                    <span class="text-muted-soft">Subtotal</span>
                    <span>Rs. {{ number_format($order->subtotal) }}</span>
                </div>
                <div class="d-flex justify-content-between mb-2">
                    <span class="text-muted-soft">Shipping</span>
                    <span>{{ $order->shipping_fee > 0 ? 'Rs. '.number_format($order->shipping_fee) : 'FREE' }}</span>
                </div>
                <div class="d-flex justify-content-between">
                    <span class="fw-semibold">Total</span>
                    <span class="fw-semibold text-terracotta fs-5">Rs. {{ number_format($order->total) }}</span>
                </div>
            </div>

            <div class="border rounded p-4 bg-white">
                <h5 class="font-serif mb-3">Shipping To</h5>
                <p class="mb-1">{{ $order->full_name }} &middot; {{ $order->phone }}</p>
                <p class="mb-1">{{ $order->address_line1 }}{{ $order->address_line2 ? ', '.$order->address_line2 : '' }}</p>
                <p class="mb-0">{{ $order->city }}{{ $order->state ? ', '.$order->state : '' }} {{ $order->postal_code }}</p>
            </div>

            <div class="text-center mt-4">
                <a href="{{ route('shop.index') }}" class="btn btn-terracotta px-4">Continue Shopping</a>
            </div>
        </div>
    </div>
</div>

@endsection
