@extends('layouts.app') @section('title', 'Detalle del Pedido #' . $pedido->id . ' - Corpo Agrícola') @section('content')
{{-- CABECERA STICKY (Navegación) --}}
{{-- ENCABEZADO: Título, Fecha y Estado --}}

Detalles de la Orden

calendar_month Realizado el {{ \Carbon\Carbon::parse($pedido->creado_at)->format('d F Y, h:i A') }}

@php $estadoStyles = match($pedido->estado) { 'pendiente' => ['bg' => 'bg-amber-50', 'text' => 'text-amber-700', 'border' => 'border-amber-200', 'icon' => 'hourglass_empty'], 'pagado', 'aprobado', 'completado_caja' => ['bg' => 'bg-green-50', 'text' => 'text-green-700', 'border' => 'border-green-200', 'icon' => 'verified'], 'revision' => ['bg' => 'bg-blue-50', 'text' => 'text-blue-700', 'border' => 'border-blue-200', 'icon' => 'search'], 'rechazado', 'cancelado', 'devuelto' => ['bg' => 'bg-red-50', 'text' => 'text-red-700', 'border' => 'border-red-200', 'icon' => 'cancel'], 'en_ruta', 'preparacion' => ['bg' => 'bg-purple-50', 'text' => 'text-purple-700', 'border' => 'border-purple-200', 'icon' => 'local_shipping'], 'entregado' => ['bg' => 'bg-gray-100', 'text' => 'text-gray-800', 'border' => 'border-gray-300', 'icon' => 'package_2'], default => ['bg' => 'bg-gray-50', 'text' => 'text-gray-600', 'border' => 'border-gray-200', 'icon' => 'info'] }; @endphp
{{ $estadoStyles['icon'] }} {{ ucfirst(str_replace('_', ' ', $pedido->estado)) }}
{{-- ALERTA: Motivo Devolución / Cancelación --}} @if(in_array($pedido->estado, ['rechazado', 'cancelado', 'devuelto']) && $pedido->motivo_devolucion)
error

Motivo de la cancelación / devolución

{{ $pedido->motivo_devolucion }}

support_agent ¿Crees que es un error? Contáctanos.

@endif {{-- GRID PRINCIPAL (Misma proporción que Checkout: 7/5 o 8/4) --}}
{{-- COLUMNA IZQUIERDA: Productos y Entrega --}}
{{-- Tarjeta de Productos --}}

shopping_cart Artículos del Pedido ({{ $pedido->detalles->count() }})

@foreach($pedido->detalles as $detalle)
{{-- Imagen --}}
@if($detalle->producto && $detalle->producto->imagen_url) {{ $detalle->producto->nombre ?? 'Producto' }} @else
image_not_supported Sin Imagen
@endif
{{-- Info Principal --}}

{{ $detalle->producto ? $detalle->producto->nombre : 'Producto no disponible' }}

${{ number_format($detalle->precio_historico_usd, 2) }} c/u

Cant: {{ (int)$detalle->cantidad_solicitada }}
{{-- Observación del producto --}} @if($detalle->observaciones)
speaker_notes

Nota: {{ $detalle->observaciones }}

@endif
{{-- Total del Item --}}
Subtotal

${{ number_format($detalle->cantidad_solicitada * $detalle->precio_historico_usd, 2) }}

@endforeach
{{-- Tarjeta de Entrega / Notas --}}

local_shipping Información de Entrega

location_on Dirección de Destino

{{ $pedido->direccion_texto }}

@if($pedido->instrucciones_entrega)

comment Notas del Pedido

"{{ $pedido->instrucciones_entrega }}"

@endif
{{-- COLUMNA DERECHA: Resumen Financiero (STICKY) --}}
{{-- Tarjeta Resumen --}}

receipt_long Resumen de Pago

Subtotal ${{ number_format($pedido->subtotal_usd, 2) }}
Envío {{ $pedido->costo_delivery_usd > 0 ? '$'.number_format($pedido->costo_delivery_usd, 2) : 'Gratis' }}
Impuestos (IVA 16%) ${{ number_format($pedido->total_usd - $pedido->subtotal_usd - $pedido->costo_delivery_usd, 2) }}
Total Pagado
${{ number_format($pedido->total_usd, 2) }} USD
Total Equivalente Bs {{ number_format($pedido->total_ves_calculado, 2) }}
{{-- Tarjeta de Pago Registrado --}} @if($pedido->pago)

payments Pago Registrado

Método @php $iconoPago = match($pedido->pago->metodo) { 'pago_movil' => 'phone_iphone', 'zelle' => 'attach_money', 'efectivo_usd', 'efectivo_bs' => 'payments', 'transferencia' => 'account_balance', default => 'credit_card' }; @endphp {{ $iconoPago }} {{ ucfirst(str_replace('_', ' ', $pedido->pago->metodo)) }}
@if($pedido->pago->referencia_bancaria)
Referencia {{ $pedido->pago->referencia_bancaria }}
@endif @if($pedido->pago->captura_pago_url)
@endif
@endif {{-- Botón de Soporte --}} support_agent ¿Necesitas ayuda con esta orden?
{{-- MODAL PARA VER IMAGEN (CAPTURE) --}} @endsection @push('scripts') @endpush