<?php $__env->startSection('content'); ?>
    <div class="bg-white">
        <div class="container mx-auto px-4 py-8">
            <h1 class="text-2xl font-bold text-gray-900 mb-8">Order Details</h1>

            <div class="grid grid-cols-1 lg:grid-cols-3 gap-8">
                <!-- Order Items -->
                <div class="lg:col-span-2">
                    <div class="bg-white shadow overflow-hidden sm:rounded-md">
                        <div class="px-4 py-5 sm:px-6 border-b border-gray-200">
                            <h3 class="text-lg font-medium leading-6 text-gray-900">Order #<?php echo e($order->order_number); ?></h3>
                            <p class="mt-1 text-sm text-gray-500">Order placed on
                                <?php echo e($order->created_at->format('M d, Y \a\t g:i A')); ?></p>
                        </div>

                        <ul class="divide-y divide-gray-200">
                            <?php $__currentLoopData = $order->orderItems; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $item): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                                <li class="py-6 px-4">
                                    <div class="flex items-center">
                                        <!-- Product Image -->
                                        <div class="flex-shrink-0 w-24 h-24 bg-gray-200 rounded-md overflow-hidden">
                                            <?php if($item->product->image): ?>
                                                <img src="<?php echo e(asset('storage/' . $item->product->image)); ?>"
                                                    alt="<?php echo e($item->product->name); ?>" class="w-full h-full object-cover">
                                            <?php else: ?>
                                                <img src="https://placehold.co/100x100/FFF7ED/F58220?text=<?php echo e(urlencode($item->product->name)); ?>"
                                                    alt="<?php echo e($item->product->name); ?>" class="w-full h-full object-cover">
                                            <?php endif; ?>
                                        </div>

                                        <!-- Product Info -->
                                        <div class="ml-4 flex-1 flex flex-col">
                                            <div>
                                                <div class="flex justify-between text-base font-medium text-gray-900">
                                                    <h3><?php echo e($item->product->name); ?></h3>
                                                    <p class="ml-4">৳<?php echo e(number_format($item->price, 2)); ?></p>
                                                </div>
                                                <p class="mt-1 text-sm text-gray-500"><?php echo e($item->product->category->name); ?>

                                                </p>
                                                <?php if($item->color): ?>
                                                    <p class="mt-1 text-sm text-gray-500">Color: <?php echo e($item->color); ?></p>
                                                <?php endif; ?>
                                                <?php if($item->size): ?>
                                                    <p class="mt-1 text-sm text-gray-500">Size: <?php echo e($item->size); ?></p>
                                                <?php endif; ?>
                                            </div>

                                            <div class="flex-1 flex items-end justify-between text-sm">
                                                <p class="text-gray-500">Qty: <?php echo e($item->quantity); ?></p>
                                                <p class="text-gray-900 font-medium">৳<?php echo e(number_format($item->total, 2)); ?>

                                                </p>
                                            </div>
                                        </div>
                                    </div>
                                </li>
                            <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
                        </ul>
                    </div>
                </div>

                <!-- Order Summary -->
                <div>
                    <div class="bg-gray-50 p-6 rounded-md">
                        <h2 class="text-lg font-medium text-gray-900 mb-4">Order Summary</h2>

                        <div class="space-y-3">
                            <div class="flex justify-between">
                                <p class="text-sm text-gray-600">Subtotal</p>
                                <p class="text-sm font-medium text-gray-900">৳<?php echo e(number_format($order->subtotal, 2)); ?></p>
                            </div>

                            <div class="flex justify-between">
                                <p class="text-sm text-gray-600">Delivery Charge</p>
                                <p class="text-sm font-medium text-gray-900">৳<?php echo e(number_format($order->shipping, 2)); ?></p>
                            </div>

                            <div class="flex justify-between pt-4 border-t border-gray-200">
                                <p class="text-base font-medium text-gray-900">Total</p>
                                <p class="text-base font-medium text-gray-900">৳<?php echo e(number_format($order->total, 2)); ?></p>
                            </div>
                        </div>
                    </div>

                    <!-- Order Status -->
                    <div class="mt-6 bg-gray-50 p-6 rounded-md">
                        <h2 class="text-lg font-medium text-gray-900 mb-4">Order Status</h2>

                        <div class="flex items-center">
                            <span
                                class="px-3 py-1 inline-flex text-xs leading-5 font-semibold rounded-full 
                            <?php if($order->status === 'pending'): ?> bg-yellow-100 text-yellow-800
                            <?php elseif($order->status === 'processing'): ?> bg-blue-100 text-blue-800
                            <?php elseif($order->status === 'shipped'): ?> bg-indigo-100 text-indigo-800
                            <?php elseif($order->status === 'delivered'): ?> bg-green-100 text-green-800
                            <?php elseif($order->status === 'cancelled'): ?> bg-red-100 text-red-800
                            <?php else: ?> bg-gray-100 text-gray-800 <?php endif; ?>">
                                <?php echo e(ucfirst($order->status)); ?>

                            </span>
                        </div>

                        <p class="mt-2 text-sm text-gray-500">
                            <?php if($order->status === 'pending'): ?>
                                Your order is being processed.
                            <?php elseif($order->status === 'processing'): ?>
                                Your order is being prepared for shipment.
                            <?php elseif($order->status === 'shipped'): ?>
                                Your order has been shipped.
                            <?php elseif($order->status === 'delivered'): ?>
                                Your order has been delivered.
                            <?php elseif($order->status === 'cancelled'): ?>
                                This order has been cancelled.
                            <?php endif; ?>
                        </p>
                    </div>

                    <!-- Payment Information -->
                    <div class="mt-6 bg-gray-50 p-6 rounded-md">
                        <h2 class="text-lg font-medium text-gray-900 mb-4">Payment Information</h2>

                        <div class="space-y-2">
                            <div class="flex justify-between">
                                <p class="text-sm text-gray-600">Payment Method</p>
                                <p class="text-sm font-medium text-gray-900">
                                    <?php echo e(ucfirst(str_replace('_', ' ', $order->payment_method))); ?></p>
                            </div>

                            <div class="flex justify-between">
                                <p class="text-sm text-gray-600">Payment Status</p>
                                <p class="text-sm font-medium text-gray-900"><?php echo e(ucfirst($order->payment_status)); ?></p>
                            </div>
                        </div>
                    </div>

                    <!-- Shipping Address -->
                    <div class="mt-6 bg-gray-50 p-6 rounded-md">
                        <h2 class="text-lg font-medium text-gray-900 mb-4">Shipping Address</h2>

                        <div class="text-sm text-gray-700 space-y-1">
                            <p><?php echo e($order->shipping_address['name'] ?? ($order->shipping_address['first_name'] ?? '') . ' ' . ($order->shipping_address['last_name'] ?? '')); ?>

                            </p>
                            <p><?php echo e($order->shipping_address['address']); ?></p>
                            <p><?php echo e($order->shipping_address['city']); ?></p>
                            <p><?php echo e($order->shipping_address['phone']); ?></p>
                        </div>
                    </div>

                    <!-- Order Notes -->
                    <?php if($order->notes): ?>
                        <div class="mt-6 bg-gray-50 p-6 rounded-md">
                            <h2 class="text-lg font-medium text-gray-900 mb-4">Order Notes</h2>
                            <div class="text-sm text-gray-700">
                                <p class="whitespace-pre-wrap"><?php echo e($order->notes); ?></p>
                            </div>
                        </div>
                    <?php endif; ?>
                </div>
            </div>
        </div>
    </div>

    <!-- Meta Pixel Purchase Event -->
    <script>
        // Track successful purchase
        if (typeof fbq !== 'undefined') {
            fbq('track', 'Purchase', {
                content_ids: [
                    <?php $__currentLoopData = $order->orderItems; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $item): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                        '<?php echo e($item->product_id); ?>'
                        <?php echo e(!$loop->last ? ',' : ''); ?>

                    <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
                ],
                content_type: 'product',
                value: <?php echo e($order->total); ?>,
                currency: 'BDT',
                num_items: <?php echo e($order->orderItems->sum('quantity')); ?>

            });
        }
    </script>
<?php $__env->stopSection(); ?>

<?php echo $__env->make('layouts.app', \Illuminate\Support\Arr::except(get_defined_vars(), ['__data', '__path']))->render(); ?><?php /**PATH C:\xampp\htdocs\ecomm\resources\views/orders/show.blade.php ENDPATH**/ ?>