<?php $__env->startSection('title', "Order #{$order->order_number}"); ?>

<?php $__env->startSection('content'); ?>
    <div class="flex flex-wrap justify-between items-center gap-4 mb-6">
        <div>
            <h1 class="text-2xl font-bold">Order #<?php echo e($order->order_number); ?></h1>
            <p class="text-gray-500 text-sm"><?php echo e($order->created_at->format('d M Y H:i')); ?></p>
        </div>
        <div class="flex gap-2">
            <a href="<?php echo e(route('admin.orders.edit', $order->id)); ?>" class="bg-indigo-600 text-white px-4 py-2 rounded hover:bg-indigo-700 text-sm">Full Edit</a>
            <a href="<?php echo e(route('admin.orders.index')); ?>" class="bg-gray-500 text-white px-4 py-2 rounded hover:bg-gray-600 text-sm">Back</a>
        </div>
    </div>

    <?php
        $statusFlow = ['pending', 'confirmed', 'processing', 'shipped', 'delivered'];
        $currentIdx = array_search($order->status, $statusFlow);
        $isCancelled = $order->status === 'cancelled';
    ?>

    <div class="bg-white rounded-lg shadow p-6 mb-6">
        <div class="flex items-center justify-between mb-2">
            <h3 class="font-bold text-lg">Order Progress</h3>
            <?php if($isCancelled): ?>
                <span class="px-3 py-1 rounded-full text-sm font-medium bg-red-100 text-red-800">Cancelled</span>
            <?php elseif($currentIdx === count($statusFlow) - 1): ?>
                <span class="px-3 py-1 rounded-full text-sm font-medium bg-green-100 text-green-800">Delivered</span>
            <?php endif; ?>
        </div>
        <?php if(!$isCancelled): ?>
            <div class="flex items-center justify-between mt-4">
                <?php $__currentLoopData = $statusFlow; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $i => $st): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                    <div class="flex flex-col items-center flex-1 relative">
                        <?php if($i > 0): ?>
                            <div class="absolute top-4 left-0 w-full h-0.5 -translate-y-1/2 <?php echo e($i <= $currentIdx ? 'bg-green-500' : 'bg-gray-200'); ?>"></div>
                        <?php endif; ?>
                        <div class="w-8 h-8 rounded-full flex items-center justify-center text-sm font-bold z-10 <?php echo e($i < $currentIdx ? 'bg-green-500 text-white' : ($i === $currentIdx ? 'bg-blue-600 text-white ring-4 ring-blue-100' : 'bg-gray-200 text-gray-500')); ?>">
                            <?php echo e($i < $currentIdx ? '✓' : ($i + 1)); ?>

                        </div>
                        <span class="text-xs mt-1 <?php echo e($i <= $currentIdx ? 'font-semibold text-gray-800' : 'text-gray-400'); ?>"><?php echo e(ucfirst($st)); ?></span>
                    </div>
                <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
            </div>
        <?php endif; ?>
    </div>

    <div class="grid grid-cols-1 lg:grid-cols-3 gap-6 mb-6">
        <div class="lg:col-span-2 space-y-6">
            <div class="bg-white rounded-lg shadow p-6">
                <h3 class="font-bold text-lg mb-4">Order Items</h3>
                <div class="overflow-x-auto">
                    <table class="w-full">
                        <thead class="bg-gray-50">
                            <tr>
                                <th class="px-4 py-2 text-left text-xs font-medium text-gray-500 uppercase">Product</th>
                                <th class="px-4 py-2 text-left text-xs font-medium text-gray-500 uppercase">Unit</th>
                                <th class="px-4 py-2 text-right text-xs font-medium text-gray-500 uppercase">Price</th>
                                <th class="px-4 py-2 text-right text-xs font-medium text-gray-500 uppercase">Qty</th>
                                <th class="px-4 py-2 text-right text-xs font-medium text-gray-500 uppercase">Subtotal</th>
                            </tr>
                        </thead>
                        <tbody class="divide-y">
                            <?php $__currentLoopData = $order->orderItems; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $item): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                                <tr>
                                    <td class="px-4 py-3">
                                        <p class="font-medium"><?php echo e($item->product_name); ?></p>
                                        <?php if($item->product_id): ?>
                                            <p class="text-xs text-gray-500">ID: <?php echo e($item->product_id); ?></p>
                                        <?php endif; ?>
                                    </td>
                                    <td class="px-4 py-3 text-sm"><?php echo e($item->unit ?? '-'); ?></td>
                                    <td class="px-4 py-3 text-right">&euro;<?php echo e(number_format($item->price, 2)); ?></td>
                                    <td class="px-4 py-3 text-right"><?php echo e($item->quantity); ?></td>
                                    <td class="px-4 py-3 text-right font-medium">&euro;<?php echo e(number_format($item->subtotal, 2)); ?></td>
                                </tr>
                            <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
                        </tbody>
                    </table>
                </div>
            </div>

            <div class="bg-white rounded-lg shadow p-6">
                <h3 class="font-bold text-lg mb-4">Notes</h3>
                <p class="text-gray-700"><?php echo e($order->notes ?? 'No notes.'); ?></p>
            </div>
        </div>

        <div class="space-y-6">
            <div class="bg-white rounded-lg shadow p-6">
                <h3 class="font-bold text-lg mb-4">Financial Summary</h3>
                <div class="space-y-3">
                    <div class="flex justify-between text-sm">
                        <span class="text-gray-600">Subtotal</span>
                        <span>&euro;<?php echo e(number_format($order->subtotal, 2)); ?></span>
                    </div>
                    <div class="flex justify-between text-sm">
                        <span class="text-gray-600">Delivery Fee</span>
                        <span>&euro;<?php echo e(number_format($order->delivery_fee, 2)); ?></span>
                    </div>
                    <div class="flex justify-between text-sm">
                        <span class="text-gray-600">Service Fee</span>
                        <span>&euro;<?php echo e(number_format($order->service_fee, 2)); ?></span>
                    </div>
                    <div class="flex justify-between text-sm">
                        <span class="text-gray-600">VAT</span>
                        <span>&euro;<?php echo e(number_format($order->vat_amount, 2)); ?></span>
                    </div>
                    <hr>
                    <div class="flex justify-between font-bold text-lg">
                        <span>Total</span>
                        <span>&euro;<?php echo e(number_format($order->total, 2)); ?></span>
                    </div>
                </div>
            </div>

            <div class="bg-white rounded-lg shadow p-6">
                <h3 class="font-bold text-lg mb-4">Order Info</h3>
                <div class="space-y-3 text-sm">
                    <div class="flex justify-between">
                        <span class="text-gray-600">Session</span>
                        <span class="text-xs font-mono"><?php echo e($order->session_id); ?></span>
                    </div>
                    <div class="flex justify-between items-center">
                        <span class="text-gray-600">Status</span>
                        <?php
                            $sc = ['pending' => 'yellow', 'confirmed' => 'blue', 'processing' => 'indigo', 'shipped' => 'purple', 'delivered' => 'green', 'cancelled' => 'red'];
                            $c = $sc[$order->status] ?? 'gray';
                        ?>
                        <span class="px-2.5 py-0.5 rounded-full text-xs font-medium bg-<?php echo e($c); ?>-100 text-<?php echo e($c); ?>-800"><?php echo e(ucfirst($order->status)); ?></span>
                    </div>
                    <div class="flex justify-between items-center">
                        <span class="text-gray-600">Payment</span>
                        <?php
                            $pc = ['paid' => 'green', 'pending' => 'yellow', 'failed' => 'red', 'refunded' => 'gray'];
                            $p = $pc[$order->payment_status] ?? 'gray';
                        ?>
                        <span class="px-2.5 py-0.5 rounded-full text-xs font-medium bg-<?php echo e($p); ?>-100 text-<?php echo e($p); ?>-800"><?php echo e(ucfirst($order->payment_status)); ?></span>
                    </div>
                    <div class="flex justify-between">
                        <span class="text-gray-600">Payment Method</span>
                        <span><?php echo e($order->payment_method ?? '-'); ?></span>
                    </div>
                    <div class="flex justify-between">
                        <span class="text-gray-600">Created</span>
                        <span><?php echo e($order->created_at->format('d M Y H:i')); ?></span>
                    </div>
                    <div class="flex justify-between">
                        <span class="text-gray-600">Updated</span>
                        <span><?php echo e($order->updated_at->format('d M Y H:i')); ?></span>
                    </div>
                </div>
            </div>

            <div class="bg-white rounded-lg shadow p-6">
                <h3 class="font-bold text-lg mb-4">Quick Update</h3>
                <form method="POST" action="<?php echo e(route('admin.orders.update', $order->id)); ?>">
                    <?php echo csrf_field(); ?>
                    <?php echo method_field('PUT'); ?>
                    <div class="space-y-3">
                        <div>
                            <label class="block text-xs font-medium text-gray-600 mb-1">Status</label>
                            <select name="status" class="w-full border border-gray-300 rounded px-3 py-2 text-sm focus:outline-none focus:ring-2 focus:ring-blue-500">
                                <?php $__currentLoopData = $statuses; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $st): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                                    <option value="<?php echo e($st); ?>" <?php echo e($order->status === $st ? 'selected' : ''); ?>><?php echo e(ucfirst($st)); ?></option>
                                <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
                            </select>
                        </div>
                        <div>
                            <label class="block text-xs font-medium text-gray-600 mb-1">Payment</label>
                            <select name="payment_status" class="w-full border border-gray-300 rounded px-3 py-2 text-sm focus:outline-none focus:ring-2 focus:ring-blue-500">
                                <?php $__currentLoopData = $paymentStatuses; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $ps): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                                    <option value="<?php echo e($ps); ?>" <?php echo e($order->payment_status === $ps ? 'selected' : ''); ?>><?php echo e(ucfirst($ps)); ?></option>
                                <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
                            </select>
                        </div>
                        <div>
                            <label class="block text-xs font-medium text-gray-600 mb-1">Notes</label>
                            <textarea name="notes" rows="2" class="w-full border border-gray-300 rounded px-3 py-2 text-sm focus:outline-none focus:ring-2 focus:ring-blue-500"><?php echo e($order->notes); ?></textarea>
                        </div>
                        <button type="submit" class="w-full bg-blue-600 text-white py-2 rounded text-sm hover:bg-blue-700">Update Order</button>
                    </div>
                </form>
            </div>
        </div>
    </div>
<?php $__env->stopSection(); ?>

<?php echo $__env->make('admin::layouts.master', array_diff_key(get_defined_vars(), ['__data' => 1, '__path' => 1]))->render(); ?><?php /**PATH G:\abo bilal nuisan\bernie_store\bernie-backend\Modules/Admin\resources/views/orders/show.blade.php ENDPATH**/ ?>