<?php $__env->startSection('title', 'Order #' . $order->id); ?>

<?php $__env->startSection('content'); ?>
<div class="max-w-[1100px] mx-auto">
    <!-- Elite Header -->
    <div class="flex flex-col md:flex-row md:items-center justify-between gap-8 mb-12">
        <div class="flex items-center gap-6">
            <a href="<?php echo e(route('admin.orders.index')); ?>" class="w-14 h-14 flex items-center justify-center bg-white border border-gray-100 rounded-2xl text-gray-400 hover:text-brand hover:border-brand/20 transition-all duration-300 shadow-sm group">
                <i class="fas fa-chevron-left text-xs group-hover:-translate-x-1 transition-transform"></i>
            </a>
            <div>
                <h1 class="text-3xl font-bold text-gray-900 leading-tight">Order #<?php echo e(str_pad($order->id, 6, '0', STR_PAD_LEFT)); ?></h1>
                <p class="text-gray-500 text-sm mt-1">Placed on <?php echo e($order->created_at->format('d F Y \\a\\t h:i A')); ?></p>
            </div>
        </div>
        <div class="flex items-center gap-3">
            <button onclick="window.print()" class="inline-flex items-center gap-2 bg-white border border-gray-200 text-gray-700 px-4 py-2.5 rounded-xl text-sm font-medium hover:border-gray-300 hover:text-gray-900 transition">
                <i class="fas fa-print text-xs"></i>
                Print
            </button>
            <form action="<?php echo e(route('admin.orders.update_status', $order->id)); ?>" method="POST" class="relative group">
                <?php echo csrf_field(); ?>
                <?php echo method_field('PATCH'); ?>
                <select name="status" onchange="this.form.submit()" class="appearance-none bg-white border border-gray-300 text-gray-900 px-10 py-2.5 rounded-xl text-sm font-medium hover:border-brand/50 focus:outline-none focus:ring-2 focus:ring-brand/30 pr-12">
                    <option value="pending" <?php echo e($order->status == 'pending' ? 'selected' : ''); ?>>Pending</option>
                    <option value="processing" <?php echo e($order->status == 'processing' ? 'selected' : ''); ?>>Processing</option>
                    <option value="shipped" <?php echo e($order->status == 'shipped' ? 'selected' : ''); ?>>Shipped</option>
                    <option value="delivered" <?php echo e($order->status == 'delivered' ? 'selected' : ''); ?>>Delivered</option>
                    <option value="cancelled" <?php echo e($order->status == 'cancelled' ? 'selected' : ''); ?>>Cancelled</option>
                </select>
                <i class="fas fa-chevron-down absolute right-5 top-1/2 -translate-y-1/2 text-xs text-gray-400 pointer-events-none"></i>
            </form>
        </div>
    </div>

    <!-- Acquisition Flow Stepper -->
    <?php if($order->status != 'cancelled'): ?>
    <div class="bg-white p-12 rounded-[2.5rem] border border-gray-100 shadow-sm mb-12 relative overflow-hidden">
        <div class="absolute top-0 left-0 w-full h-1 bg-gray-50"></div>
        <div class="absolute top-0 left-0 h-1 bg-brand transition-all duration-1000" style="width: <?php echo e($order->status == 'pending' ? '12.5%' : ($order->status == 'processing' ? '37.5%' : ($order->status == 'shipped' ? '62.5%' : '100%'))); ?>"></div>
        
        <div class="flex items-center justify-between relative z-10">
            <!-- Step 1 -->
            <div class="flex flex-col items-center gap-4 group">
                <div class="w-16 h-16 rounded-2xl flex items-center justify-center border-4 transition-all duration-500 <?php echo e(in_array($order->status, ['pending', 'processing', 'shipped', 'delivered']) ? 'bg-emerald-600 !bg-brand border-emerald-100 !border-brand/10 text-white shadow-xl shadow-emerald-200' : 'bg-white border-gray-50 text-gray-300'); ?>">
                    <i class="fas fa-clipboard-check text-xl"></i>
                </div>
                <div class="text-center">
                    <p class="text-xs font-medium <?php echo e(in_array($order->status, ['pending', 'processing', 'shipped', 'delivered']) ? 'text-brand' : 'text-gray-400'); ?>">Order placed</p>
                    <p class="text-xs font-medium text-gray-500 mt-1">Pending</p>
                </div>
            </div>

            <div class="flex-1 h-px bg-gray-100 mx-4"></div>

            <!-- Step 2 -->
            <div class="flex flex-col items-center gap-4 group">
                <div class="w-16 h-16 rounded-2xl flex items-center justify-center border-4 transition-all duration-500 <?php echo e(in_array($order->status, ['processing', 'shipped', 'delivered']) ? 'bg-emerald-600 !bg-brand border-emerald-100 !border-brand/10 text-white shadow-xl shadow-emerald-200' : 'bg-white border-gray-50 text-gray-300'); ?>">
                    <i class="fas fa-box-open text-xl"></i>
                </div>
                <div class="text-center">
                    <p class="text-xs font-medium <?php echo e(in_array($order->status, ['processing', 'shipped', 'delivered']) ? 'text-brand' : 'text-gray-400'); ?>">Processing</p>
                    <p class="text-xs font-medium text-gray-500 mt-1">Processing</p>
                </div>
            </div>

            <div class="flex-1 h-px bg-gray-100 mx-4"></div>

            <!-- Step 3 -->
            <div class="flex flex-col items-center gap-4 group">
                <div class="w-16 h-16 rounded-2xl flex items-center justify-center border-4 transition-all duration-500 <?php echo e(in_array($order->status, ['shipped', 'delivered']) ? 'bg-emerald-600 !bg-brand border-emerald-100 !border-brand/10 text-white shadow-xl shadow-emerald-200' : 'bg-white border-gray-50 text-gray-300'); ?>">
                    <i class="fas fa-shipping-fast text-xl"></i>
                </div>
                <div class="text-center">
                    <p class="text-xs font-medium <?php echo e(in_array($order->status, ['shipped', 'delivered']) ? 'text-brand' : 'text-gray-400'); ?>">Shipped</p>
                    <p class="text-xs font-medium text-gray-500 mt-1">Shipped</p>
                </div>
            </div>

            <div class="flex-1 h-px bg-gray-100 mx-4"></div>

            <!-- Step 4 -->
            <div class="flex flex-col items-center gap-4 group">
                <div class="w-16 h-16 rounded-2xl flex items-center justify-center border-4 transition-all duration-500 <?php echo e($order->status == 'delivered' ? 'bg-emerald-600 !bg-brand border-emerald-100 !border-brand/10 text-white shadow-xl shadow-emerald-200' : 'bg-white border-gray-50 text-gray-300'); ?>">
                    <i class="fas fa-check-circle text-xl"></i>
                </div>
                <div class="text-center">
                    <p class="text-xs font-medium <?php echo e($order->status == 'delivered' ? 'text-brand' : 'text-gray-400'); ?>">Delivered</p>
                    <p class="text-xs font-medium text-gray-500 mt-1">Delivered</p>
                </div>
            </div>
        </div>
        
        <?php if($order->items && $order->items->count()): ?>
        <div class="mt-10">
            <p class="text-xs text-gray-500 mb-3">Products</p>
            <div class="flex items-center gap-3 overflow-x-auto pb-1">
                <?php $__currentLoopData = $order->items; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $thumbItem): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                    <div class="w-12 h-12 rounded-xl overflow-hidden border border-gray-100 bg-white shrink-0">
                        <?php if($thumbItem->product && $thumbItem->product->image): ?>
                            <img 
                                src="<?php echo e(Str::startsWith($thumbItem->product->image, ['http://','https://']) ? $thumbItem->product->image : Storage::url($thumbItem->product->image)); ?>" 
                                alt="<?php echo e($thumbItem->product->name); ?>" 
                                class="w-full h-full object-cover">
                        <?php else: ?>
                            <div class="w-full h-full bg-gray-50 flex items-center justify-center text-gray-300">
                                <i class="fas fa-image text-sm"></i>
                            </div>
                        <?php endif; ?>
                    </div>
                <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
            </div>
        </div>
        <?php endif; ?>
    </div>
    <?php else: ?>
    <div class="bg-red-50 p-12 rounded-[2.5rem] border border-red-100 mb-12 flex flex-col items-center justify-center text-center">
        <div class="w-20 h-20 bg-red-100 rounded-[2rem] flex items-center justify-center text-red-500 mb-6">
            <i class="fas fa-ban text-3xl"></i>
        </div>
        <h3 class="text-lg font-semibold text-red-900">Order cancelled</h3>
        <p class="text-red-500 text-sm mt-1">This order has been cancelled.</p>
    </div>
    <?php endif; ?>

    <div class="grid grid-cols-1 lg:grid-cols-12 gap-8">
        <!-- Asset Inventory Column -->
        <div class="lg:col-span-8 space-y-8">
            <div class="bg-white rounded-2xl border border-gray-200 shadow-sm overflow-hidden">
                <div class="px-10 py-8 border-b border-gray-50 bg-gray-50/30 flex items-center justify-between">
                    <div>
                        <h3 class="text-base font-semibold text-gray-900">Items</h3>
                        <p class="text-xs text-gray-500 mt-1"><?php echo e($order->items->count()); ?> items</p>
                    </div>
                </div>
                <div class="overflow-x-auto">
                    <table class="w-full text-left">
                        <thead>
                            <tr class="border-b border-gray-50">
                                <th class="px-10 py-6 text-xs font-medium text-gray-500">Product</th>
                                <th class="px-10 py-6 text-xs font-medium text-gray-500 text-center">Quantity</th>
                                <th class="px-10 py-6 text-xs font-medium text-gray-500 text-right">Unit price</th>
                                <th class="px-10 py-6 text-xs font-medium text-gray-500 text-right">Total</th>
                            </tr>
                        </thead>
                        <tbody class="divide-y divide-gray-50">
                            <?php $__currentLoopData = $order->items; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $item): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                            <tr class="hover:bg-gray-50/50 transition-colors group">
                                <td class="px-10 py-6">
                                    <div class="flex items-center gap-5">
                                        <div class="w-20 h-20 rounded-[1.5rem] overflow-hidden border border-gray-100 group-hover:border-brand/20 transition-all duration-500">
                                            <?php if($item->product && $item->product->image): ?>
                                                <img src="<?php echo e(Str::startsWith($item->product->image, 'http') ? $item->product->image : Storage::url($item->product->image)); ?>" 
                                                     alt="<?php echo e($item->product->name); ?>" 
                                                     class="w-full h-full object-cover group-hover:scale-110 transition-transform duration-700">
                                            <?php else: ?>
                                <div class="w-full h-full bg-gray-50 flex items-center justify-center text-gray-300">
                                                    <i class="fas fa-image text-xl"></i>
                                                </div>
                                            <?php endif; ?>
                                        </div>
                                        <div>
                                            <p class="font-semibold text-gray-900 group-hover:text-brand transition-colors duration-300"><?php echo e($item->product->name ?? 'Unknown product'); ?></p>
                                            <p class="text-xs text-gray-500 mt-1">Variant: <?php echo e($item->variant ?? 'Standard'); ?></p>
                                        </div>
                                    </div>
                                </td>
                                <td class="px-10 py-6 text-center">
                                    <span class="inline-flex items-center justify-center w-10 h-10 rounded-2xl bg-gray-50 text-gray-900 font-medium text-sm group-hover:bg-brand/10 group-hover:text-brand transition-all duration-300">
                                        <?php echo e($item->quantity); ?>

                                    </span>
                                </td>
                                <td class="px-10 py-6 text-right font-medium text-gray-600">
                                    <?php echo e($currencySymbol ?? '$'); ?><?php echo e(number_format($item->price, 2)); ?>

                                </td>
                                <td class="px-10 py-6 text-right font-semibold text-gray-900">
                                    <?php echo e($currencySymbol ?? '$'); ?><?php echo e(number_format($item->price * $item->quantity, 2)); ?>

                                </td>
                            </tr>
                            <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
                        </tbody>
                    </table>
                </div>
                
                <!-- Financial Matrix Summary -->
                <div class="bg-gray-50/30 px-10 py-10 border-t border-gray-50">
                    <div class="flex flex-col gap-4 ml-auto max-w-sm">
                        <div class="flex justify-between items-center text-sm text-gray-600">
                            <span>Subtotal</span>
                            <span class="text-gray-900"><?php echo e($currencySymbol ?? '$'); ?><?php echo e(number_format($order->subtotal, 2)); ?></span>
                        </div>
                        
                        <?php if($order->discount > 0): ?>
                        <div class="flex justify-between items-center text-sm text-brand">
                            <span>Discount</span>
                            <span>-<?php echo e($currencySymbol ?? '$'); ?><?php echo e(number_format($order->discount, 2)); ?></span>
                        </div>
                        <?php endif; ?>
                        
                        <div class="flex justify-between items-center text-sm text-gray-600">
                            <span>Shipping</span>
                            <span class="text-gray-900"><?php echo e($currencySymbol ?? '$'); ?><?php echo e(number_format($order->delivery_fee, 2)); ?></span>
                        </div>
                        
                        <div class="h-px bg-gray-100 my-2"></div>
                        
                        <div class="flex justify-between items-center">
                            <span class="text-sm font-medium text-gray-900">Total</span>
                            <span class="text-2xl font-bold text-gray-900"><?php echo e($currencySymbol ?? '$'); ?><?php echo e(number_format($order->total, 2)); ?></span>
                        </div>
                    </div>
                </div>
            </div>
        </div>

        <!-- Intelligence Matrix Column -->
        <div class="lg:col-span-4 space-y-8">
            <!-- Constituent Details -->
            <div class="bg-white rounded-[2.5rem] border border-gray-100 shadow-sm overflow-hidden">
                <div class="px-10 py-6 border-b border-gray-50 bg-gray-50/30">
                    <h3 class="text-sm font-semibold text-gray-900">Customer</h3>
                </div>
                <div class="p-10">
                    <div class="flex items-center gap-5 mb-10">
                        <div class="w-16 h-16 rounded-[1.5rem] bg-gradient-to-br from-gray-50 to-gray-100 flex items-center justify-center text-gray-400 text-xl font-black border border-gray-100 shadow-sm">
                            <?php echo e(substr($order->user->name ?? 'G', 0, 1)); ?>

                        </div>
                        <div>
                            <p class="text-base font-semibold text-gray-900"><?php echo e($order->user->name ?? 'Guest'); ?></p>
                            <p class="text-xs text-gray-500 mt-0.5">Customer ID: CRN-<?php echo e(str_pad($order->user->id ?? 0, 6, '0', STR_PAD_LEFT)); ?></p>
                        </div>
                    </div>
                    
                    <div class="space-y-6">
                        <div class="flex items-start gap-5">
                            <div class="w-10 h-10 rounded-xl bg-gray-50 flex items-center justify-center text-gray-400 shrink-0">
                                <i class="far fa-envelope text-xs"></i>
                            </div>
                            <div class="pt-1 overflow-hidden">
                                <span class="block text-xs text-gray-500 mb-1">Email</span>
                                <a href="mailto:<?php echo e($order->user->email ?? ''); ?>" class="text-sm font-medium text-gray-900 hover:text-brand transition-colors break-all">
                                    <?php echo e($order->user->email ?? 'No email protocol linked'); ?>

                                </a>
                            </div>
                        </div>
                        
                        <div class="flex items-start gap-5">
                            <div class="w-10 h-10 rounded-xl bg-gray-50 flex items-center justify-center text-gray-400 shrink-0">
                                <i class="fas fa-phone text-xs"></i>
                            </div>
                            <div class="pt-1">
                                <span class="block text-xs text-gray-500 mb-1">Phone</span>
                                <a href="tel:<?php echo e($order->user->phone ?? ''); ?>" class="text-sm font-medium text-gray-900 hover:text-brand transition-colors">
                                    <?php echo e($order->user->phone ?? 'Unlinked protocol'); ?>

                                </a>
                            </div>
                        </div>
                    </div>
                    
                    <?php if($order->user): ?>
                    <div class="mt-10 pt-10 border-t border-gray-50">
                        <a href="<?php echo e(route('admin.customers.show', $order->user->id)); ?>" class="flex items-center justify-center gap-2 bg-gray-50 text-gray-700 py-3 rounded-xl text-sm font-medium hover:bg-gray-100 transition-colors border border-gray-200">
                            View customer
                        </a>
                    </div>
                    <?php endif; ?>
                </div>
            </div>

            <!-- Logistical Matrix -->
            <div class="bg-white rounded-[2.5rem] border border-gray-100 shadow-sm overflow-hidden">
                <div class="px-10 py-6 border-b border-gray-50 bg-gray-50/30">
                    <h3 class="text-sm font-semibold text-gray-900">Shipping</h3>
                </div>
                <div class="p-10">
                    <div class="flex items-center gap-5 mb-8">
                        <div class="w-12 h-12 rounded-2xl bg-orange-50 flex items-center justify-center text-orange-500 shrink-0 border border-orange-100">
                            <i class="fas fa-truck text-sm"></i>
                        </div>
                        <div>
                            <p class="font-medium text-gray-900"><?php echo e($order->deliveryType->name ?? 'Standard shipping'); ?></p>
                            <p class="text-xs text-gray-500 mt-0.5">Method</p>
                        </div>
                    </div>
                    
                    <div class="bg-gray-50 rounded-[2rem] p-8 border border-gray-100">
                        <span class="text-xs text-gray-500 mb-2 block">Shipping address</span>
                        <?php
                            $address = is_string($order->shipping_address) ? json_decode($order->shipping_address, true) : $order->shipping_address;
                        ?>
                        <div class="text-sm font-medium text-gray-900 leading-relaxed">
                        <?php if($address): ?>
                            <span class="block mb-2 text-brand text-sm font-semibold"><?php echo e($address['name'] ?? ($order->user->name ?? 'Guest')); ?></span>
                            <p class="text-gray-700"><?php echo e($address['address_line_1'] ?? ''); ?></p>
                            <?php if(!empty($address['address_line_2'])): ?> <p class="text-gray-700"><?php echo e($address['address_line_2']); ?></p> <?php endif; ?>
                            <p class="text-gray-700"><?php echo e($address['city'] ?? ''); ?>, <?php echo e($address['state'] ?? ''); ?> <?php echo e($address['zip_code'] ?? ''); ?></p>
                            <p class="text-gray-700 mt-2 text-xs"><?php echo e($address['country'] ?? ''); ?></p>
                        <?php else: ?>
                            <span class="italic text-gray-400 text-xs">Destination protocols not defined.</span>
                        <?php endif; ?>
                        </div>
                    </div>
                </div>
            </div>

            <!-- Payment -->
            <div class="bg-white rounded-[2.5rem] border border-gray-100 shadow-sm overflow-hidden">
                <div class="px-10 py-6 border-b border-gray-50 bg-gray-50/30">
                    <h3 class="text-sm font-semibold text-gray-900">Payment</h3>
                </div>
                <div class="p-10 space-y-6">
                    <div class="flex justify-between items-center">
                        <span class="text-xs text-gray-500">Payment method</span>
                        <div class="flex items-center gap-3 bg-gray-50 px-4 py-2 rounded-xl border border-gray-100">
                            <?php if(Str::contains(strtolower($order->paymentMethod->name ?? ''), 'stripe')): ?>
                                <i class="fab fa-stripe text-indigo-500 text-lg"></i>
                            <?php elseif(Str::contains(strtolower($order->paymentMethod->name ?? ''), 'paypal')): ?>
                                <i class="fab fa-paypal text-blue-500 text-lg"></i>
                            <?php else: ?>
                                <i class="fas fa-credit-card text-gray-400 text-sm"></i>
                            <?php endif; ?>
                            <span class="text-sm font-medium text-gray-900"><?php echo e($order->paymentMethod->name ?? 'N/A'); ?></span>
                        </div>
                    </div>
                    
                    <div class="flex justify-between items-center">
                        <span class="text-xs text-gray-500">Payment status</span>
                        <span class="px-3 py-1 bg-emerald-50 text-emerald-600 rounded-full text-[11px] font-medium inline-flex items-center gap-2">
                            <span class="w-1 h-1 rounded-full bg-emerald-500 animate-pulse"></span>
                            Settled
                        </span>
                    </div>

                    <div class="flex justify-between items-center">
                        <span class="text-xs text-gray-500">Transaction ID</span>
                        <span class="text-xs font-medium text-gray-900">TXN-<?php echo e(strtoupper(Str::random(10))); ?></span>
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>
<?php $__env->stopSection(); ?>

<?php echo $__env->make('layouts.admin', array_diff_key(get_defined_vars(), ['__data' => 1, '__path' => 1]))->render(); ?><?php /**PATH /home/burhjijr/adminprovendorx.burhanstore.online/resources/views/admin/orders/show.blade.php ENDPATH**/ ?>