@extends('layouts.app')

@section('title', 'Order '.$order->order_number)

@section('content')
<div class="container py-5">
    <div class="row g-4">
        <div class="col-lg-3">
            @include('partials.account-sidebar')
        </div>
        <div class="col-lg-9">
            <div class="border rounded p-4 bg-white mb-4">
                <div class="d-flex justify-content-between align-items-center mb-3">
                    <h5 class="font-serif mb-0">Order {{ $order->order_number }}</h5>
                    <span class="badge bg-{{ $order->statusBadgeColor() }}">{{ ucfirst($order->status) }}</span>
                </div>
                <p class="text-muted-soft small mb-4">Placed on {{ $order->created_at->format('d M, Y \a\t h:i A') }}</p>

                @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 Address</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>
    </div>
</div>
@endsection
