<x-filament-panels::page>
    <div class="space-y-6">
        <div class="rounded-lg border border-gray-200 bg-white p-4">
            <div class="text-sm text-gray-600">Redespacho para Orden Universal</div>
            <div class="mt-1 text-lg font-semibold">
                #{{ $this->remoteOrder->id_order }} &middot; Ref: {{ $this->remoteOrder->order_reference }}
            </div>
        </div>

        <form wire:submit.prevent="create" class="space-y-6">
            <div class="rounded-lg border border-gray-200 bg-white p-4">
                {{ $this->form }}
            </div>

            <div class="flex justify-end">
                <x-filament::button type="submit">
                    Crear redespacho
                </x-filament::button>
            </div>
        </form>

        <div class="rounded-lg border border-gray-200 bg-white p-4">
            <div class="text-base font-semibold mb-3">Detalle de compra (Orden padre)</div>

            @php
                $fake = new \App\Models\OrderFlow();
                $fake->order_reference = (string) ($this->remoteOrder->order_reference ?? '');
                $fake->setRelation('details', $this->parentDetails);
            @endphp

            @include('filament.orders.modals.purchase-details', ['record' => $fake])
        </div>

        <div class="rounded-lg border border-gray-200 bg-white p-4">
            <div class="text-base font-semibold mb-3">Datos del cliente (Orden padre)</div>

            @include('filament.orders.modals.remote-client-details', [
                'clientId' => (int) ($this->remoteOrder->idClient ?? 0) ?: null,
                'client' => $this->client,
            ])
        </div>
    </div>
</x-filament-panels::page>
