<x-filament::page>
    <div class="space-y-6">
        <!-- Order Header -->
        <div class="bg-white rounded-lg shadow p-6">
            <h1 class="text-3xl font-bold mb-4">Order #{{ $record->order_number }}</h1>
            
            <div class="grid grid-cols-2 gap-4 md:grid-cols-4">
                <div>
                    <p class="text-gray-600 text-sm">Status</p>
                    <p class="text-lg font-semibold">{{ ucfirst($record->status) }}</p>
                </div>
                <div>
                    <p class="text-gray-600 text-sm">Payment Status</p>
                    <p class="text-lg font-semibold">{{ ucfirst($record->payment_status) }}</p>
                </div>
                <div>
                    <p class="text-gray-600 text-sm">Total</p>
                    <p class="text-lg font-semibold">R{{ number_format($record->total, 2) }}</p>
                </div>
                <div>
                    <p class="text-gray-600 text-sm">Order Date</p>
                    <p class="text-lg font-semibold">{{ $record->created_at->format('M d, Y') }}</p>
                </div>
            </div>
        </div>

        <!-- Order Items -->
        <div class="bg-white rounded-lg shadow p-6">
            <h2 class="text-2xl font-bold mb-4">Order Items</h2>
            
            @if($record->items->count() > 0)
                <div class="overflow-x-auto">
                    <table class="w-full text-sm text-left text-gray-600">
                        <thead class="text-xs text-gray-700 uppercase bg-gray-100">
                            <tr>
                                <th class="px-4 py-3">Product</th>
                                <th class="px-4 py-3">Print Stock</th>
                                <th class="px-4 py-3">Type</th>
                                <th class="px-4 py-3">Specifications</th>
                                <th class="px-4 py-3 text-right">Price</th>
                            </tr>
                        </thead>
                        <tbody>
                            @foreach($record->items as $item)
                            <tr class="border-b hover:bg-gray-50">
                                <td class="px-4 py-3 font-medium text-gray-900">
                                    {{ $item->product->name }}
                                </td>
                                <td class="px-4 py-3">
                                    {{ $item->printStock->name ?? 'N/A' }}
                                </td>
                                <td class="px-4 py-3">
                                    <span class="bg-blue-100 text-blue-800 px-2 py-1 rounded text-xs">
                                        {{ ucfirst($item->type) }}
                                    </span>
                                </td>
                                <td class="px-4 py-3 text-sm">
                                    @if($item->type === 'wallpaper')
                                        Length: {{ $item->length }}m
                                    @elseif($item->type === 'mural')
                                        {{ $item->width }}m × {{ $item->height }}m ({{ number_format($item->width * $item->height, 2) }}m²)
                                    @endif
                                </td>
                                <td class="px-4 py-3 text-right font-semibold text-gray-900">
                                    R{{ number_format($item->price, 2) }}
                                </td>
                            </tr>
                            @endforeach
                        </tbody>
                        <tfoot class="border-t-2 border-gray-300">
                            <tr>
                                <td colspan="4" class="px-4 py-3 text-right font-bold">Total:</td>
                                <td class="px-4 py-3 text-right font-bold text-lg text-gray-900">
                                    R{{ number_format($record->items->sum('price'), 2) }}
                                </td>
                            </tr>
                        </tfoot>
                    </table>
                </div>
            @else
                <p class="text-gray-600">No items in this order.</p>
            @endif
        </div>

        <!-- Customer Information -->
        <div class="bg-white rounded-lg shadow p-6">
            <h2 class="text-2xl font-bold mb-4">Customer Information</h2>
            
            <div class="grid grid-cols-1 md:grid-cols-2 gap-6">
                <div>
                    <p class="text-gray-600 text-sm mb-1">Name</p>
                    <p class="text-lg font-semibold">{{ $record->customer_name }}</p>
                </div>
                <div>
                    <p class="text-gray-600 text-sm mb-1">Email</p>
                    <p class="text-lg">{{ $record->customer_email }}</p>
                </div>
                <div>
                    <p class="text-gray-600 text-sm mb-1">Phone</p>
                    <p class="text-lg">{{ $record->customer_phone ?? 'N/A' }}</p>
                </div>
                <div>
                    <p class="text-gray-600 text-sm mb-1">Payment Method</p>
                    <p class="text-lg">{{ $record->payment_method ?? 'N/A' }}</p>
                </div>
                <div class="md:col-span-2">
                    <p class="text-gray-600 text-sm mb-1">Shipping Address</p>
                    <p class="text-lg whitespace-pre-wrap">{{ $record->shipping_address }}</p>
                </div>
                @if($record->notes)
                <div class="md:col-span-2">
                    <p class="text-gray-600 text-sm mb-1">Notes</p>
                    <p class="text-lg whitespace-pre-wrap">{{ $record->notes }}</p>
                </div>
                @endif
            </div>
        </div>
    </div>
</x-filament::page>
