<?php $__env->startSection('title', 'Order Details'); ?>
<?php $__env->startSection('page-title', 'Order Details'); ?>

<?php $__env->startSection('content'); ?>
<div class="mb-6 flex flex-col sm:flex-row items-start sm:items-center justify-between gap-4">
    <div class="flex-1">
        <h2 class="text-xl font-semibold text-gray-900 dark:text-white">Order: #<?php echo e($order->order_number); ?></h2>
        <p class="text-sm text-gray-500 dark:text-gray-400">Order placed on <?php echo e($order->created_at->format('M d, Y H:i')); ?></p>
    </div>
    <div class="flex items-center gap-3">
        <a href="<?php echo e(route('admin.orders.index')); ?>" 
           class="inline-flex items-center px-4 py-2.5 bg-white dark:bg-gray-900 border border-gray-300 dark:border-gray-700 text-gray-700 dark:text-gray-300 text-sm font-medium rounded-lg hover:bg-gray-50 dark:hover:bg-gray-800 transition-colors">
            <i class="fas fa-arrow-left mr-2"></i>Back to List
        </a>
    </div>
</div>

<div class="grid grid-cols-1 lg:grid-cols-3 gap-6">
    <!-- Order Information -->
    <div class="lg:col-span-2 space-y-6">
        <!-- Order Items -->
        <div class="bg-white dark:bg-gray-950 border border-gray-200 dark:border-gray-800 rounded-lg overflow-hidden">
            <div class="px-6 py-4 border-b border-gray-200 dark:border-gray-800">
                <h3 class="text-lg font-medium text-gray-900 dark:text-white">Order Items</h3>
            </div>
            <div class="overflow-x-auto">
                <table class="min-w-full divide-y divide-gray-200 dark:divide-gray-800">
                    <thead class="bg-gray-50 dark:bg-gray-900">
                        <tr>
                            <th class="px-6 py-3 text-left text-xs font-medium text-gray-500 dark:text-gray-400 uppercase tracking-wider">Product</th>
                            <th class="px-6 py-3 text-left text-xs font-medium text-gray-500 dark:text-gray-400 uppercase tracking-wider">Quantity</th>
                            <th class="px-6 py-3 text-left text-xs font-medium text-gray-500 dark:text-gray-400 uppercase tracking-wider">Price</th>
                            <th class="px-6 py-3 text-right text-xs font-medium text-gray-500 dark:text-gray-400 uppercase tracking-wider">Subtotal</th>
                        </tr>
                    </thead>
                    <tbody class="bg-white dark:bg-gray-950 divide-y divide-gray-200 dark:divide-gray-800">
                        <?php $__currentLoopData = $order->items; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $item): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                        <tr>
                            <td class="px-6 py-4 whitespace-nowrap">
                                <div class="flex items-center">
                                    <div class="h-10 w-10 flex-shrink-0 bg-gray-100 dark:bg-gray-800 rounded-lg overflow-hidden">
                                        <?php if($item->product && $item->product->featured_image): ?>
                                            <img src="<?php echo e(Str::startsWith($item->product->featured_image, 'http') ? $item->product->featured_image : asset($item->product->featured_image)); ?>" alt="" class="h-full w-full object-cover">
                                        <?php else: ?>
                                            <div class="h-full w-full flex items-center justify-center text-gray-400"><i class="fas fa-image"></i></div>
                                        <?php endif; ?>
                                    </div>
                                    <div class="ml-4">
                                        <div class="text-sm font-medium text-gray-900 dark:text-white"><?php echo e($item->product ? $item->product->name : 'Deleted Product'); ?></div>
                                    </div>
                                </div>
                            </td>
                            <td class="px-6 py-4 whitespace-nowrap text-sm text-gray-900 dark:text-white"><?php echo e($item->quantity); ?></td>
                            <td class="px-6 py-4 whitespace-nowrap text-sm text-gray-900 dark:text-white"><?php echo e(number_format($item->price, 2)); ?> <?php echo e($order->currency); ?></td>
                            <td class="px-6 py-4 whitespace-nowrap text-right text-sm font-medium text-gray-900 dark:text-white"><?php echo e(number_format($item->line_subtotal, 2)); ?> <?php echo e($order->currency); ?></td>
                        </tr>
                        <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
                    </tbody>
                    <tfoot class="bg-gray-50 dark:bg-gray-900">
                        <tr>
                            <td colspan="3" class="px-6 py-3 text-right text-sm font-medium text-gray-500 dark:text-gray-400">Subtotal</td>
                            <td class="px-6 py-3 text-right text-sm font-bold text-gray-900 dark:text-white"><?php echo e(number_format($order->subtotal, 2)); ?> <?php echo e($order->currency); ?></td>
                        </tr>
                        <?php if($order->discount > 0): ?>
                        <tr>
                            <td colspan="3" class="px-6 py-3 text-right text-sm font-medium text-gray-500 dark:text-gray-400">Discount</td>
                            <td class="px-6 py-3 text-right text-sm font-bold text-red-600">- <?php echo e(number_format($order->discount, 2)); ?> <?php echo e($order->currency); ?></td>
                        </tr>
                        <?php endif; ?>
                        <?php if($order->shipping_fee > 0): ?>
                        <tr>
                            <td colspan="3" class="px-6 py-3 text-right text-sm font-medium text-gray-500 dark:text-gray-400">Shipping Fee</td>
                            <td class="px-6 py-3 text-right text-sm font-bold text-gray-900 dark:text-white">+ <?php echo e(number_format($order->shipping_fee, 2)); ?> <?php echo e($order->currency); ?></td>
                        </tr>
                        <?php endif; ?>
                        <tr class="bg-blue-50 dark:bg-blue-900/10">
                            <td colspan="3" class="px-6 py-4 text-right text-base font-bold text-gray-900 dark:text-white uppercase tracking-wider">Total</td>
                            <td class="px-6 py-4 text-right text-xl font-extrabold text-blue-600 dark:text-blue-400"><?php echo e(number_format($order->total, 2)); ?> <?php echo e($order->currency); ?></td>
                        </tr>
                    </tfoot>
                </table>
            </div>
        </div>

        <!-- Note -->
        <?php if($order->note): ?>
        <div class="bg-white dark:bg-gray-950 border border-gray-200 dark:border-gray-800 rounded-lg p-6">
            <h3 class="text-sm font-bold text-gray-900 dark:text-white mb-2 uppercase tracking-wider">Order Note</h3>
            <p class="text-gray-700 dark:text-gray-300 whitespace-pre-line"><?php echo e($order->note); ?></p>
        </div>
        <?php endif; ?>
    </div>

    <!-- Sidebar Info -->
    <div class="space-y-6">
        <!-- Order Status -->
        <div class="bg-white dark:bg-gray-950 border border-gray-200 dark:border-gray-800 rounded-lg p-6">
            <h3 class="text-sm font-bold text-gray-900 dark:text-white mb-4 uppercase tracking-wider">Order Status</h3>
            <form action="<?php echo e(route('admin.orders.update', $order->id)); ?>" method="POST">
                <?php echo csrf_field(); ?>
                <?php echo method_field('PUT'); ?>
                <div class="space-y-4">
                    <select name="status" class="w-full bg-white dark:bg-gray-900 border border-gray-300 dark:border-gray-700 rounded-lg text-sm text-gray-900 dark:text-white focus:outline-none focus:ring-2 focus:ring-blue-500 dark:focus:ring-blue-400 focus:border-transparent">
                        <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>
                    <button type="submit" class="w-full inline-flex items-center justify-center px-4 py-2.5 bg-blue-600 hover:bg-blue-700 text-white text-sm font-bold rounded-lg transition-colors">
                        Update Status
                    </button>
                </div>
            </form>
        </div>

        <!-- Customer Information -->
        <div class="bg-white dark:bg-gray-950 border border-gray-200 dark:border-gray-800 rounded-lg p-6">
            <h3 class="text-sm font-bold text-gray-900 dark:text-white mb-4 uppercase tracking-wider">Customer Details</h3>
            <div class="space-y-4">
                <div class="flex items-start gap-3">
                    <div class="h-10 w-10 bg-gray-100 dark:bg-gray-800 rounded-full flex items-center justify-center text-gray-500 dark:text-gray-400 flex-shrink-0">
                        <i class="fas fa-user"></i>
                    </div>
                    <div>
                        <div class="text-sm font-bold text-gray-900 dark:text-white"><?php echo e($order->customer_name); ?></div>
                        <?php if($order->user): ?>
                            <div class="text-xs text-blue-600 dark:text-blue-400 font-medium">Registered User #<?php echo e($order->user_id); ?></div>
                        <?php else: ?>
                            <div class="text-xs text-gray-500 dark:text-gray-400 font-medium">Guest Checkout</div>
                        <?php endif; ?>
                    </div>
                </div>
                <div class="pt-4 border-t border-gray-100 dark:border-gray-800 space-y-3">
                    <div class="flex items-center gap-3 text-sm">
                        <i class="fas fa-envelope text-gray-400 w-4"></i>
                        <span class="text-gray-700 dark:text-gray-300 font-medium"><?php echo e($order->customer_email); ?></span>
                    </div>
                    <div class="flex items-center gap-3 text-sm">
                        <i class="fas fa-phone text-gray-400 w-4"></i>
                        <span class="text-gray-700 dark:text-gray-300 font-medium"><?php echo e($order->customer_phone); ?></span>
                    </div>
                    <div class="flex items-start gap-3 text-sm">
                        <i class="fas fa-map-marker-alt text-gray-400 w-4 mt-0.5"></i>
                        <span class="text-gray-700 dark:text-gray-300 font-medium leading-relaxed"><?php echo e($order->shipping_detail); ?></span>
                    </div>
                </div>
            </div>
        </div>

        <!-- Payment Information -->
        <div class="bg-white dark:bg-gray-950 border border-gray-200 dark:border-gray-800 rounded-lg p-6">
            <h3 class="text-sm font-bold text-gray-900 dark:text-white mb-4 uppercase tracking-wider">Payment Details</h3>
            <div class="flex items-center gap-3">
                <div class="h-10 w-10 bg-green-100 dark:bg-green-900/30 rounded-lg flex items-center justify-center text-green-600 dark:text-green-400">
                    <?php if(strtolower($order->payment_method) == 'bakong' || strtolower($order->payment_method) == 'aba'): ?>
                        <i class="fas fa-university"></i>
                    <?php else: ?>
                        <i class="fas fa-money-bill-wave"></i>
                    <?php endif; ?>
                </div>
                <div>
                    <div class="text-sm font-bold text-gray-900 dark:text-white uppercase"><?php echo e($order->payment_method); ?></div>
                    <div class="text-xs text-gray-500 dark:text-gray-400 font-medium font-mono uppercase tracking-widest">Method</div>
                </div>
            </div>
        </div>

        <div class="bg-white dark:bg-gray-950 border border-gray-200 dark:border-gray-800 rounded-lg p-6">
            <h3 class="text-sm font-bold text-gray-900 dark:text-white mb-4 uppercase tracking-wider">Customer Order History</h3>
            <div class="space-y-3">
                <?php $__empty_1 = true; $__currentLoopData = $customerOrderHistory; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $historyOrder): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); $__empty_1 = false; ?>
                    <a href="<?php echo e(route('admin.orders.show', $historyOrder->id)); ?>" class="block rounded-lg border border-gray-100 dark:border-gray-800 p-3 hover:bg-gray-50 dark:hover:bg-gray-900 transition-colors">
                        <div class="flex items-start justify-between gap-3">
                            <div>
                                <div class="text-sm font-semibold text-gray-900 dark:text-white">#<?php echo e($historyOrder->order_number); ?></div>
                                <div class="text-xs text-gray-500 dark:text-gray-400"><?php echo e($historyOrder->created_at->format('M d, Y H:i')); ?></div>
                            </div>
                            <div class="text-right">
                                <div class="text-sm font-medium text-gray-900 dark:text-white"><?php echo e(number_format($historyOrder->total, 2)); ?> <?php echo e($historyOrder->currency); ?></div>
                                <div class="text-xs text-gray-500 dark:text-gray-400"><?php echo e(ucfirst($historyOrder->status)); ?></div>
                            </div>
                        </div>
                    </a>
                <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); if ($__empty_1): ?>
                    <p class="text-sm text-gray-500 dark:text-gray-400">No additional order history found for this customer.</p>
                <?php endif; ?>
            </div>
        </div>
    </div>
</div>
<?php $__env->stopSection(); ?>

<?php echo $__env->make('admin.layouts.app', array_diff_key(get_defined_vars(), ['__data' => 1, '__path' => 1]))->render(); ?><?php /**PATH /Users/mac/Documents/360monicaAPI/resources/views/admin/orders/show.blade.php ENDPATH**/ ?>