@extends('layouts.store')

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

@push('styles')
    <style>
        .success-card {
            margin-top: 32px;
            padding: 34px;
            background: var(--card);
            border: 1px solid rgba(123, 91, 47, 0.16);
            border-radius: 28px;
            box-shadow: var(--shadow);
        }

        .success-card h2 {
            margin: 0 0 10px;
            font-size: 2rem;
            color: var(--gold-deep);
        }

        .success-meta {
            display: grid;
            grid-template-columns: repeat(3, minmax(0, 1fr));
            gap: 18px;
            margin: 24px 0;
        }

        .success-box {
            padding: 18px;
            border-radius: 20px;
            background: rgba(255, 255, 255, 0.45);
            border: 1px solid rgba(123, 91, 47, 0.12);
        }

        .item-list {
            display: grid;
            gap: 14px;
            margin-top: 20px;
        }

        .item-row {
            display: flex;
            justify-content: space-between;
            gap: 12px;
            padding: 16px 0;
            border-bottom: 1px solid rgba(123, 91, 47, 0.12);
        }

        @media (max-width: 760px) {
            .success-meta {
                grid-template-columns: 1fr;
            }
        }
    </style>
@endpush

@section('content')
    <section class="success-card">
        <h2>Order confirmed</h2>
        <p class="meta-text">Your curated pieces are reserved. This demo stores the order in MySQL and clears the session cart after checkout.</p>

        <div class="success-meta">
            <div class="success-box">
                <strong>Order Number</strong>
                <div>{{ $order->order_number }}</div>
            </div>
            <div class="success-box">
                <strong>Collector</strong>
                <div>{{ $order->customer_name }}</div>
            </div>
            <div class="success-box">
                <strong>Total</strong>
                <div>${{ number_format((float) $order->total_amount, 2) }}</div>
            </div>
        </div>

        <div class="item-list">
            @foreach ($order->items as $item)
                <div class="item-row">
                    <div>
                        <strong>{{ $item->product_name }}</strong>
                        <div class="meta-text">Qty {{ $item->quantity }}</div>
                    </div>
                    <span>${{ number_format((float) $item->subtotal, 2) }}</span>
                </div>
            @endforeach
        </div>

        <p><a class="button" href="{{ route('home') }}">Continue shopping</a></p>
    </section>
@endsection
