<x-filament-panels::page>
    {{-- Default form fields will be rendered here by Filament --}}
    {{ $this->form }}

    {{-- Custom Order Items Section --}}
    <div class="mt-6">
        <x-filament::section>
            <x-slot name="heading">
                Order Items
            </x-slot>

            @if($this->record->items && $this->record->items->count() > 0)
                <div class="overflow-x-auto">
                    <table class="w-full text-sm">
                        <thead class="border-b">
                            <tr class="text-left">
                                <th class="px-4 py-3 font-medium">Product</th>
                                <th class="px-4 py-3 font-medium">Print Stock</th>
                                <th class="px-4 py-3 font-medium">Type</th>
                                <th class="px-4 py-3 font-medium">Specifications</th>
                                <th class="px-4 py-3 font-medium text-right">Price</th>
                            </tr>
                        </thead>
                        <tbody class="divide-y">
                            @foreach($this->record->items as $item)
                            <tr>
                                <td class="px-4 py-3">
                                    {{ $item->product->name ?? 'N/A' }}
                                </td>
                                <td class="px-4 py-3">
                                    {{ $item->printStock->name ?? 'N/A' }}
                                </td>
                                <td class="px-4 py-3">
                                    <x-filament::badge>
                                        {{ ucfirst($item->type) }}
                                    </x-filament::badge>
                                </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">
                                    R{{ number_format($item->price, 2) }}
                                </td>
                            </tr>
                            @endforeach
                        </tbody>
                        <tfoot class="border-t-2 font-bold">
                            <tr>
                                <td colspan="4" class="px-4 py-3 text-right">Total:</td>
                                <td class="px-4 py-3 text-right text-lg">
                                    R{{ number_format($this->record->items->sum('price'), 2) }}
                                </td>
                            </tr>
                        </tfoot>
                    </table>
                </div>
            @else
                <p class="text-gray-600">No items in this order.</p>
            @endif
        </x-filament::section>
    </div>
</x-filament-panels::page>
