<?php if (isset($component)) { $__componentOriginal9ac128a9029c0e4701924bd2d73d7f54 = $component; } ?>
<?php if (isset($attributes)) { $__attributesOriginal9ac128a9029c0e4701924bd2d73d7f54 = $attributes; } ?>
<?php $component = App\View\Components\AppLayout::resolve([] + (isset($attributes) && $attributes instanceof Illuminate\View\ComponentAttributeBag ? $attributes->all() : [])); ?>
<?php $component->withName('app-layout'); ?>
<?php if ($component->shouldRender()): ?>
<?php $__env->startComponent($component->resolveView(), $component->data()); ?>
<?php if (isset($attributes) && $attributes instanceof Illuminate\View\ComponentAttributeBag): ?>
<?php $attributes = $attributes->except(\App\View\Components\AppLayout::ignoredParameterNames()); ?>
<?php endif; ?>
<?php $component->withAttributes([]); ?>
     <?php $__env->slot('header', null, []); ?> 
        <div class="flex items-center space-x-4">
            <a href="<?php echo e(route('orders.index')); ?>" 
               class="p-2 text-gray-600 hover:text-gray-900 hover:bg-gray-100 rounded-xl transition-all duration-200 flex items-center justify-center">
                <svg class="w-5 h-5" fill="none" stroke="currentColor" viewBox="0 0 24 24">
                    <path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M15 19l-7-7 7-7"></path>
                </svg>
            </a>
            <div class="flex-1">
                <h1 class="text-2xl font-bold text-gray-900"><?php echo e($order->order_number); ?></h1>
                <p class="text-gray-600 text-sm mt-0.5">Order for <?php echo e($order->customer->full_name); ?> • <?php echo e($order->created_at->format('M d, Y')); ?></p>
            </div>
            <div class="flex items-center space-x-3">
                <?php if($order->status === 'created'): ?>
                    <a href="<?php echo e(route('orders.edit', $order)); ?>" 
                       class="bg-gradient-to-r from-yellow-500 to-yellow-600 hover:from-yellow-600 hover:to-yellow-700 text-white font-semibold py-2.5 px-5 rounded-xl transition-all duration-200 flex items-center shadow-lg hover:shadow-xl text-sm">
                        <svg class="w-4 h-4 mr-2" fill="none" stroke="currentColor" viewBox="0 0 24 24">
                            <path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M11 5H6a2 2 0 00-2 2v11a2 2 0 002 2h11a2 2 0 002-2v-5m-1.414-9.414a2 2 0 112.828 2.828L11.828 15H9v-2.828l8.586-8.586z"></path>
                        </svg>
                        Edit Order
                    </a>
                <?php endif; ?>
                <?php if($order->status !== 'ready'): ?>
                    <button onclick="updateStatus()"
                            class="bg-gradient-to-r from-blue-600 to-blue-700 hover:from-blue-700 hover:to-blue-800 text-white font-semibold py-2.5 px-5 rounded-xl transition-all duration-200 flex items-center shadow-lg hover:shadow-xl text-sm">
                        <svg class="w-4 h-4 mr-2" fill="none" stroke="currentColor" viewBox="0 0 24 24">
                            <path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M4 4v5h.582m15.356 2A8.001 8.001 0 004.582 9m0 0H9m11 11v-5h-.581m0 0a8.003 8.003 0 01-15.357-2m15.357 2H15"></path>
                        </svg>
                        Update Status
                    </button>
                <?php endif; ?>
                <?php if(Auth::user()->hasPermission('manage_orders')): ?>
                    <button onclick="confirmDeleteOrder()"
                            class="bg-gradient-to-r from-red-600 to-red-700 hover:from-red-700 hover:to-red-800 text-white font-semibold py-2.5 px-5 rounded-xl transition-all duration-200 flex items-center shadow-lg hover:shadow-xl text-sm">
                        <svg class="w-4 h-4 mr-2" fill="none" stroke="currentColor" viewBox="0 0 24 24">
                            <path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M19 7l-.867 12.142A2 2 0 0116.138 21H7.862a2 2 0 01-1.995-1.858L5 7m5 4v6m4-6v6m1-10V4a1 1 0 00-1-1h-4a1 1 0 00-1 1v3M4 7h16"></path>
                        </svg>
                        Delete Order
                    </button>
                <?php endif; ?>
            </div>
        </div>
     <?php $__env->endSlot(); ?>

    <div class="p-6">
        <div class="max-w-7xl mx-auto">
            <div class="grid grid-cols-1 lg:grid-cols-3 gap-8">
                <!-- Order Details -->
                <div class="lg:col-span-2 space-y-6">
                    <!-- Order Items -->
                    <div class="bg-white overflow-hidden shadow-lg rounded-xl border border-gray-100">
                        <div class="p-6">
                            <h3 class="text-xl font-bold text-gray-900 mb-6">Order Items</h3>
                            <div class="space-y-4">
                                <?php $__currentLoopData = $order->orderItems; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $item): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                                    <div class="p-4 bg-gray-50 rounded-xl border border-gray-200">
                                        <!-- Item Header -->
                                        <div class="flex items-center justify-between mb-3">
                                            <div class="flex items-center space-x-4">
                                                <div class="w-12 h-12 bg-gradient-to-r from-blue-500 to-indigo-600 rounded-xl flex items-center justify-center text-white font-bold">
                                                    <?php echo e($item->quantity); ?>

                                                </div>
                                                <div>
                                                    <h4 class="font-semibold text-gray-900"><?php echo e($item->laundryItem->name); ?></h4>
                                                    <p class="text-sm text-gray-600">Quantity: <?php echo e($item->quantity); ?></p>
                                                </div>
                                            </div>
                                            <div class="text-right">
                                                <div class="font-bold text-gray-900">₦<?php echo e(number_format($item->total_price, 2)); ?></div>
                                                <div class="text-sm text-gray-500">₦<?php echo e(number_format($item->unit_price, 2)); ?> each</div>
                                            </div>
                                        </div>

                                        <!-- Item Options -->
                                        <div class="bg-white p-3 rounded-lg border border-gray-100 mb-3">
                                            <h5 class="text-sm font-semibold text-gray-700 mb-2">Item Options</h5>
                                            <div class="grid grid-cols-1 md:grid-cols-3 gap-4 text-sm">
                                                <!-- Color -->
                                                <div>
                                                    <span class="font-medium text-gray-600">Color:</span>
                                                    <span class="font-semibold"><?php echo e(ucfirst($item->color_type)); ?></span>
                                                    <?php if($item->color_type === 'white'): ?>
                                                        <div class="text-xs text-green-600">
                                                            Surcharge: +20% (₦<?php echo e(number_format($item->unit_price * 0.20, 2)); ?>)
                                                        </div>
                                                    <?php endif; ?>
                                                </div>

                                                <!-- Starch -->
                                                <div>
                                                    <span class="font-medium text-gray-600">Starch:</span>
                                                    <span class="ml-1"><?php echo e($item->starch ? 'Yes' : 'No'); ?></span>
                                                    <?php if($item->starch && $item->starch_price > 0): ?>
                                                        <div class="text-xs text-green-600 mt-1">
                                                            ₦100 per item: ₦<?php echo e(number_format($item->starch_price, 2)); ?>

                                                        </div>
                                                    <?php endif; ?>
                                                </div>

                                                <!-- Hanger -->
                                                <div class="text-xs">
                                                    <?php
                                                        $__base = $item->unit_price * $item->quantity;
                                                        $__white = $item->color_type === 'white' ? $__base * 0.20 : 0;
                                                        $__starchAmt = ($item->starch && $item->starch_price > 0) ? $item->starch_price : 0;
                                                        $__hasHanger = abs($item->total_price - ($__base + $__white + $__starchAmt + $__base * 0.05)) < 0.01;
                                                    ?>
                                                    <span class="font-medium">Hanger:</span> <?php if($__hasHanger): ?><span class="text-green-600">Yes (+5%)</span><?php else: ?><span>No</span><?php endif; ?>
                                                </div>
                                            </div>
                                        </div>

                                        <!-- Pricing Breakdown -->
                                        <div class="bg-blue-50 p-3 rounded-lg border border-blue-100">
                                            <div class="text-xs text-blue-700">
                                                <div class="flex justify-between">
                                                    <span>Base (<?php echo e($item->quantity); ?> × ₦<?php echo e(number_format($item->unit_price, 2)); ?>):</span>
                                                    <span>₦<?php echo e(number_format($item->unit_price * $item->quantity, 2)); ?></span>
                                                </div>
                                                <?php if($item->color_type === 'white'): ?>
                                                    <div class="flex justify-between">
                                                        <span>Color Surcharge (20%):</span>
                                                        <span>₦<?php echo e(number_format($item->unit_price * $item->quantity * 0.20, 2)); ?></span>
                                                    </div>
                                                <?php endif; ?>
                                                <?php if($item->starch && $item->starch_price > 0): ?>
                                                    <div class="flex justify-between">
                                                        <span>Starch (₦100 × <?php echo e($item->quantity); ?>):</span>
                                                        <span>₦<?php echo e(number_format($item->starch_price, 2)); ?></span>
                                                    </div>
                                                <?php endif; ?>
                                                <?php
                                                    $__base2 = $item->unit_price * $item->quantity;
                                                    $__white2 = $item->color_type === 'white' ? $__base2 * 0.20 : 0;
                                                    $__starchAmt2 = ($item->starch && $item->starch_price > 0) ? $item->starch_price : 0;
                                                    $__hasHanger2 = abs($item->total_price - ($__base2 + $__white2 + $__starchAmt2 + $__base2 * 0.05)) < 0.01;
                                                ?>
                                                <?php if($__hasHanger2): ?>
                                                    <div class="flex justify-between">
                                                        <span>Hanger Surcharge (5%):</span>
                                                        <span>₦<?php echo e(number_format($item->unit_price * $item->quantity * 0.05, 2)); ?></span>
                                                    </div>
                                                <?php endif; ?>
                                            </div>
                                        </div>

                                        <?php if($item->special_instructions): ?>
                                            <div class="mt-3 p-2 bg-yellow-100 border border-yellow-400 rounded">
                                                <p class="text-sm text-gray-800"><span class="font-semibold">Special Instructions:</span> <?php echo e($item->special_instructions); ?></p>
                                            </div>
                                        <?php endif; ?>
                                    </div>
                                <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
                            </div>
                        </div>
                    </div>

                    <!-- Status History -->
                    <div class="bg-white overflow-hidden shadow-lg rounded-xl border border-gray-100">
                        <div class="p-6">
                            <h3 class="text-xl font-bold text-gray-900 mb-6">Status History</h3>
                            <div class="space-y-4">
                                <?php $__currentLoopData = $order->statusHistory; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $history): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                                    <div class="flex items-start space-x-4">
                                        <div class="w-8 h-8 bg-gradient-to-r from-blue-500 to-indigo-600 rounded-full flex items-center justify-center flex-shrink-0">
                                            <svg class="w-4 h-4 text-white" fill="none" stroke="currentColor" viewBox="0 0 24 24">
                                                <path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M5 13l4 4L19 7"></path>
                                            </svg>
                                        </div>
                                        <div class="flex-1">
                                            <div class="flex items-center justify-between">
                                                <h4 class="font-semibold text-gray-900"><?php echo e(ucfirst($history->status)); ?></h4>
                                                <span class="text-sm text-gray-500"><?php echo e($history->created_at->format('M d, Y g:i A')); ?></span>
                                            </div>
                                            <p class="text-gray-600 text-sm"><?php echo e($history->notes); ?></p>
                                            <p class="text-xs text-gray-500">by <?php echo e($history->changedBy->name); ?></p>
                                        </div>
                                    </div>
                                <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
                            </div>
                        </div>
                    </div>
                </div>

                <!-- Order Summary -->
                <div class="lg:col-span-1 space-y-6">
                    <!-- Status & Customer Info -->
                    <div class="bg-white overflow-hidden shadow-lg rounded-xl border border-gray-100">
                        <div class="p-6">
                            <div class="text-center mb-6">
                                <span class="px-4 py-2 text-lg font-semibold rounded-full <?php echo e($order->status_color); ?>">
                                    <?php echo e(ucfirst($order->status)); ?>

                                </span>
                            </div>
                            
                            <div class="space-y-4">
                                <div>
                                    <h4 class="font-semibold text-gray-900 mb-2">Customer</h4>
                                    <p class="text-gray-600"><?php echo e($order->customer->full_name); ?></p>
                                    <p class="text-gray-600"><?php echo e($order->customer->phone); ?></p>
                                    <?php if($order->customer->email): ?>
                                        <p class="text-gray-600"><?php echo e($order->customer->email); ?></p>
                                    <?php endif; ?>
                                </div>
                                
                                <div>
                                    <h4 class="font-semibold text-gray-900 mb-2">Order Details</h4>
                                    <div class="text-sm space-y-1">
                                        
                                        <?php if($order->express_delivery): ?>
                                            <div class="flex justify-between">
                                                <span class="text-gray-600">Express Delivery:</span>
                                                <span class="font-medium text-green-600">Yes (+₦<?php echo e(number_format($order->express_delivery_price, 2)); ?>)</span>
                                            </div>
                                        <?php endif; ?>
                                        <?php if($order->pickup_date): ?>
                                            <div class="flex justify-between">
                                                <span class="text-gray-600">Pickup Date:</span>
                                                <span class="font-medium"><?php echo e($order->pickup_date->format('M d, Y')); ?></span>
                                            </div>
                                        <?php endif; ?>
                                        <?php if($order->delivery_date): ?>
                                            <div class="flex justify-between">
                                                <span class="text-gray-600">Delivery Date:</span>
                                                <span class="font-medium"><?php echo e($order->delivery_date->format('M d, Y')); ?></span>
                                            </div>
                                        <?php endif; ?>
                                    </div>
                                </div>
                                
                                <?php if($order->notes): ?>
                                    <div>
                                        <h4 class="font-semibold text-gray-900 mb-2">Notes</h4>
                                        <p class="text-gray-600 text-sm"><?php echo e($order->notes); ?></p>
                                    </div>
                                <?php endif; ?>
                            </div>
                        </div>
                    </div>

                    <!-- Pricing Summary -->
                    <div class="bg-white overflow-hidden shadow-lg rounded-xl border border-gray-100">
                        <div class="p-6">
                            <h4 class="font-semibold text-gray-900 mb-4">Pricing Summary</h4>
                            <div class="space-y-3">
                                <div class="flex justify-between text-sm">
                                    <span class="text-gray-600">Subtotal:</span>
                                    <span class="font-medium">₦<?php echo e(number_format($order->total_amount, 2)); ?></span>
                                </div>
                                <?php if($order->express_delivery_price > 0): ?>
                                    <div class="flex justify-between text-sm">
                                        <span class="text-gray-600">Express Delivery:</span>
                                        <span class="font-medium text-blue-600">+₦<?php echo e(number_format($order->express_delivery_price, 2)); ?></span>
                                    </div>
                                <?php endif; ?>
                                <?php if($order->discount_amount > 0): ?>
                                    <div class="flex justify-between text-sm">
                                        <span class="text-gray-600">Discount:</span>
                                        <span class="font-medium text-green-600">-₦<?php echo e(number_format($order->discount_amount, 2)); ?></span>
                                    </div>
                                <?php endif; ?>
                                <div class="border-t border-gray-200 pt-3">
                                    <div class="flex justify-between">
                                        <span class="text-lg font-bold text-gray-900">Total:</span>
                                        <span class="text-lg font-bold text-gray-900">₦<?php echo e(number_format($order->final_amount, 2)); ?></span>
                                    </div>
                                </div>
                                <div class="border-t border-gray-200 pt-3">
                                    <div class="flex justify-between text-sm">
                                        <span class="text-gray-600">Amount Paid:</span>
                                        <span class="font-medium">₦<?php echo e(number_format($order->amount_paid, 2)); ?></span>
                                    </div>
                                    <?php if($order->payment_method): ?>
                                        <div class="flex justify-between text-sm">
                                            <span class="text-gray-600">Payment Method:</span>
                                            <span class="font-medium"><?php echo e(ucfirst($order->payment_method)); ?></span>
                                        </div>
                                    <?php endif; ?>
                                    <div class="flex justify-between">
                                        <span class="text-lg font-bold <?php echo e($order->outstanding_balance > 0 ? 'text-red-600' : 'text-green-600'); ?>">Outstanding Balance:</span>
                                        <span class="text-lg font-bold <?php echo e($order->outstanding_balance > 0 ? 'text-red-600' : 'text-green-600'); ?>">₦<?php echo e(number_format($order->outstanding_balance, 2)); ?></span>
                                    </div>
                                    <?php if($order->outstanding_balance > 0): ?>
                                        <div class="mt-3">
                                            <button onclick="updatePayment()"
                                                    class="w-full bg-gradient-to-r from-green-600 to-green-700 hover:from-green-700 hover:to-green-800 text-white font-semibold py-2 px-4 rounded-xl transition-all duration-200 flex items-center justify-center">
                                                <svg class="w-4 h-4 mr-2" fill="none" stroke="currentColor" viewBox="0 0 24 24">
                                                    <path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M12 8c-1.657 0-3 .895-3 2s1.343 2 3 2 3 .895 3 2-1.343 2-3 2m0-8c1.11 0 2.08.402 2.599 1M12 8V7m0 1v8m0 0v1m0-1c-1.11 0-2.08-.402-2.599-1"></path>
                                                </svg>
                                                Update Payment
                                            </button>
                                        </div>
                                    <?php endif; ?>
                                </div>
                            </div>
                        </div>
                    </div>

                    <!-- Quick Actions -->
                    <div class="bg-white overflow-hidden shadow-lg rounded-xl border border-gray-100">
                        <div class="p-6">
                            <h4 class="font-semibold text-gray-900 mb-4">Quick Actions</h4>
                            <div class="space-y-3">
                                <button onclick="printOrder()"
                                        class="w-full bg-gradient-to-r from-gray-600 to-gray-700 hover:from-gray-700 hover:to-gray-800 text-white font-semibold py-3 px-4 rounded-xl transition-all duration-200 flex items-center justify-center">
                                    <svg class="w-4 h-4 mr-2" fill="none" stroke="currentColor" viewBox="0 0 24 24">
                                        <path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M17 17h2a2 2 0 002-2v-4a2 2 0 00-2-2H5a2 2 0 00-2 2v4a2 2 0 002 2h2m2 4h6a2 2 0 002-2v-4a2 2 0 00-2-2H9a2 2 0 00-2 2v4a2 2 0 002 2zm8-12V5a2 2 0 00-2-2H9a2 2 0 00-2 2v4h10z"></path>
                                    </svg>
                                    Quick Print
                                </button>
                                <a href="<?php echo e(route('orders.print', $order)); ?>" target="_blank"
                                   class="w-full bg-gradient-to-r from-indigo-600 to-indigo-700 hover:from-indigo-700 hover:to-indigo-800 text-white font-semibold py-3 px-4 rounded-xl transition-all duration-200 flex items-center justify-center">
                                    <svg class="w-4 h-4 mr-2" fill="none" stroke="currentColor" viewBox="0 0 24 24">
                                        <path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M10 6H6a2 2 0 00-2 2v10a2 2 0 002 2h10a2 2 0 002-2v-2M7 7h10v10M17 3l4 4-4 4"></path>
                                    </svg>
                                    Print View
                                </a>
                                <a href="<?php echo e(route('customers.show', $order->customer)); ?>" 
                                   class="w-full bg-gradient-to-r from-blue-600 to-blue-700 hover:from-blue-700 hover:to-blue-800 text-white font-semibold py-3 px-4 rounded-xl transition-all duration-200 flex items-center justify-center">
                                    <svg class="w-4 h-4 mr-2" fill="none" stroke="currentColor" viewBox="0 0 24 24">
                                        <path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M16 7a4 4 0 11-8 0 4 4 0 018 0zM12 14a7 7 0 00-7 7h14a7 7 0 00-7-7z"></path>
                                    </svg>
                                    View Customer
                                </a>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>

    <!-- Status Update Modal -->
    <div id="statusModal" class="fixed inset-0 bg-gray-600 bg-opacity-50 overflow-y-auto h-full w-full hidden z-50">
        <div class="relative top-20 mx-auto p-5 border w-96 shadow-lg rounded-xl bg-white">
            <div class="mt-3">
                <h3 class="text-lg font-bold text-gray-900 mb-4">Update Order Status</h3>
                <form method="POST" action="<?php echo e(route('orders.update-status', $order)); ?>">
                    <?php echo csrf_field(); ?>
                    <div class="mb-4">
                        <label for="status" class="block text-sm font-medium text-gray-700 mb-2">New Status</label>
                        <select name="status" id="status" required class="w-full px-3 py-2 border border-gray-300 rounded-lg focus:ring-2 focus:ring-blue-500 focus:border-transparent">
                            <option value="created" <?php echo e($order->status === 'created' ? 'selected' : ''); ?>>Created</option>
                            <option value="processing" <?php echo e($order->status === 'processing' ? 'selected' : ''); ?>>Processing</option>
                            <option value="ready" <?php echo e($order->status === 'ready' ? 'selected' : ''); ?>>Ready</option>
                            <option value="completed" <?php echo e($order->status === 'completed' ? 'selected' : ''); ?>>Completed</option>
                            <?php if(Auth::user()->hasPermission('cancel_orders')): ?>
                                <option value="cancelled" <?php echo e($order->status === 'cancelled' ? 'selected' : ''); ?>>Cancelled</option>
                            <?php endif; ?>
                        </select>
                    </div>
                    <div class="mb-4">
                        <label for="notes" class="block text-sm font-medium text-gray-700 mb-2">Notes (Optional)</label>
                        <textarea name="notes" id="notes" rows="3" placeholder="Add any notes about this status change..." class="w-full px-3 py-2 border border-gray-300 rounded-lg focus:ring-2 focus:ring-blue-500 focus:border-transparent"></textarea>
                    </div>
                    <div class="flex space-x-3">
                        <button type="button" onclick="closeStatusModal()" class="flex-1 bg-gray-200 hover:bg-gray-300 text-gray-700 font-semibold py-2 px-4 rounded-lg transition-all duration-200">
                            Cancel
                        </button>
                        <button type="submit" class="flex-1 bg-gradient-to-r from-blue-600 to-blue-700 hover:from-blue-700 hover:to-blue-800 text-white font-semibold py-2 px-4 rounded-lg transition-all duration-200">
                            Update Status
                        </button>
                    </div>
                </form>
            </div>
        </div>
    </div>

    <!-- Payment Update Modal -->
    <div id="paymentModal" class="fixed inset-0 bg-gray-600 bg-opacity-50 overflow-y-auto h-full w-full hidden z-50">
        <div class="relative top-20 mx-auto p-5 border w-96 shadow-lg rounded-xl bg-white">
            <div class="mt-3">
                <h3 class="text-lg font-bold text-gray-900 mb-4">Update Payment</h3>
                <form method="POST" action="<?php echo e(route('orders.update-payment', $order)); ?>">
                    <?php echo csrf_field(); ?>
                    <div class="mb-4">
                        <div class="bg-gray-50 p-3 rounded-lg mb-3">
                            <div class="flex justify-between items-center">
                                <span class="text-sm font-medium text-gray-700">Outstanding Balance:</span>
                                <span class="text-lg font-bold text-red-600">₦<?php echo e(number_format($order->outstanding_balance, 2)); ?></span>
                            </div>
                            <div class="flex justify-between items-center mt-1">
                                <span class="text-xs text-gray-500">Already Paid:</span>
                                <span class="text-xs text-gray-500">₦<?php echo e(number_format($order->amount_paid, 2)); ?></span>
                            </div>
                        </div>
                        <label for="payment_amount" class="block text-sm font-medium text-gray-700 mb-2">Amount Being Paid</label>
                        <input type="number"
                               name="payment_amount"
                               id="payment_amount"
                               step="0.01"
                               min="0"
                               max="<?php echo e($order->outstanding_balance); ?>"
                               value="<?php echo e($order->outstanding_balance); ?>"
                               required
                               class="w-full px-3 py-2 border border-gray-300 rounded-lg focus:ring-2 focus:ring-blue-500 focus:border-transparent">
                        <p class="text-xs text-gray-500 mt-1">Enter the amount customer is paying now</p>
                    </div>
                    <div class="mb-4">
                        <label for="payment_method" class="block text-sm font-medium text-gray-700 mb-2">Payment Method</label>
                        <select name="payment_method" id="payment_method" required class="w-full px-3 py-2 border border-gray-300 rounded-lg focus:ring-2 focus:ring-blue-500 focus:border-transparent">
                            <option value="cash" <?php echo e($order->payment_method === 'cash' ? 'selected' : ''); ?>>Cash</option>
                            <option value="card" <?php echo e($order->payment_method === 'card' ? 'selected' : ''); ?>>Card</option>
                            <option value="transfer" <?php echo e($order->payment_method === 'transfer' ? 'selected' : ''); ?>>Bank Transfer</option>
                            <option value="cheque" <?php echo e($order->payment_method === 'cheque' ? 'selected' : ''); ?>>Cheque</option>
                            <option value="other" <?php echo e($order->payment_method === 'other' ? 'selected' : ''); ?>>Other</option>
                        </select>
                    </div>
                    <div class="mb-4">
                        <label for="payment_notes" class="block text-sm font-medium text-gray-700 mb-2">Payment Notes (Optional)</label>
                        <textarea name="payment_notes" id="payment_notes" rows="2" placeholder="Add any notes about this payment..." class="w-full px-3 py-2 border border-gray-300 rounded-lg focus:ring-2 focus:ring-blue-500 focus:border-transparent"></textarea>
                    </div>
                    <div class="flex space-x-3">
                        <button type="button" onclick="closePaymentModal()" class="flex-1 bg-gray-200 hover:bg-gray-300 text-gray-700 font-semibold py-2 px-4 rounded-lg transition-all duration-200">
                            Cancel
                        </button>
                        <button type="submit" class="flex-1 bg-gradient-to-r from-green-600 to-green-700 hover:from-green-700 hover:to-green-800 text-white font-semibold py-2 px-4 rounded-lg transition-all duration-200">
                            Update Payment
                        </button>
                    </div>
                </form>
            </div>
        </div>
    </div>

    <!-- Delete Order Confirmation Modal -->
    <?php if(Auth::user()->hasPermission('manage_orders')): ?>
        <div id="deleteOrderModal" class="fixed inset-0 bg-gray-600 bg-opacity-50 overflow-y-auto h-full w-full hidden z-50">
            <div class="relative top-20 mx-auto p-5 border w-96 shadow-lg rounded-xl bg-white">
                <div class="mt-3 text-center">
                    <div class="mx-auto flex items-center justify-center h-12 w-12 rounded-full bg-red-100">
                        <svg class="h-6 w-6 text-red-600" fill="none" stroke="currentColor" viewBox="0 0 24 24">
                            <path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M12 9v2m0 4h.01m-6.938 4h13.856c1.54 0 2.502-1.667 1.732-2.5L13.732 4c-.77-.833-1.964-.833-2.732 0L3.732 16.5c-.77.833.192 2.5 1.732 2.5z"></path>
                        </svg>
                    </div>
                    <h3 class="text-lg font-bold text-gray-900 mt-4 mb-2">Delete Order</h3>
                    <p class="text-sm text-gray-600 mb-6">
                        Are you sure you want to delete order <strong><?php echo e($order->order_number); ?></strong>?
                        This action cannot be undone and will permanently remove all order data including items and payment history.
                    </p>
                    <div class="flex space-x-3">
                        <button onclick="closeDeleteOrderModal()"
                                class="flex-1 bg-gray-200 hover:bg-gray-300 text-gray-700 font-semibold py-2 px-4 rounded-lg transition-all duration-200">
                            Cancel
                        </button>
                        <form method="POST" action="<?php echo e(route('orders.destroy', $order)); ?>" class="flex-1">
                            <?php echo csrf_field(); ?>
                            <?php echo method_field('DELETE'); ?>
                            <button type="submit"
                                    class="w-full bg-gradient-to-r from-red-600 to-red-700 hover:from-red-700 hover:to-red-800 text-white font-semibold py-2 px-4 rounded-lg transition-all duration-200">
                                Delete Order
                            </button>
                        </form>
                    </div>
                </div>
            </div>
        </div>
    <?php endif; ?>

    <!-- Print-only content -->
    <div id="printContent" class="hidden print:block">
        <div class="max-w-4xl mx-auto p-8 bg-white">
            <!-- Header -->
            <div class="text-center mb-8 border-b-2 border-gray-300 pb-6">
                <h1 class="text-3xl font-bold text-gray-900 mb-2">Slarry Laundry Service</h1>
                <p class="text-gray-600">Professional Laundry Services</p>
                <p class="text-gray-600 text-sm mt-1">More blessing complex, along lokoja road, semu semu, ikare akoko ondo state</p>
                <p class="text-gray-600 text-sm">Email: Ayodejiademide@gmail.com</p>
                <div class="mt-4">
                    <h2 class="text-xl font-semibold">Order Receipt</h2>
                    <p class="text-lg font-medium text-blue-600"><?php echo e($order->order_number); ?></p>
                </div>
            </div>

            <!-- Order Info -->
            <div class="grid grid-cols-2 gap-8 mb-8">
                <div>
                    <h3 class="text-lg font-semibold mb-3 text-gray-900">Customer Information</h3>
                    <div class="space-y-2 text-sm">
                        <p><strong>Name:</strong> <?php echo e($order->customer->full_name); ?></p>
                        <p><strong>Phone:</strong> <?php echo e($order->customer->phone); ?></p>
                        <?php if($order->customer->email): ?>
                            <p><strong>Email:</strong> <?php echo e($order->customer->email); ?></p>
                        <?php endif; ?>
                        <p><strong>Address:</strong> <?php echo e($order->customer->address); ?></p>
                    </div>
                </div>
                <div>
                    <h3 class="text-lg font-semibold mb-3 text-gray-900">Order Details</h3>
                    <div class="space-y-2 text-sm">
                        <p><strong>Order Date:</strong> <?php echo e($order->created_at->format('M d, Y g:i A')); ?></p>
                        <p><strong>Status:</strong> <span class="capitalize"><?php echo e($order->status); ?></span></p>
                        
                        <?php if($order->pickup_date): ?>
                            <p><strong>Pickup Date:</strong> <?php echo e($order->pickup_date->format('M d, Y')); ?></p>
                        <?php endif; ?>
                        <?php if($order->delivery_date): ?>
                            <p><strong>Delivery Date:</strong> <?php echo e($order->delivery_date->format('M d, Y')); ?></p>
                        <?php endif; ?>
                    </div>
                </div>
            </div>

            <!-- Order Items -->
            <div class="print-items mb-8">
                <h3 class="text-lg font-semibold mb-4 text-gray-900">Order Items</h3>
                <div class="items-container space-y-2">
                    <?php $__currentLoopData = $order->orderItems; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $item): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                        <div class="item-card border border-gray-800 p-2 bg-gray-50">
                            <!-- Item Header -->
                            <div class="flex justify-between items-start mb-1">
                                <div class="flex-1">
                                    <h4 class="text-sm font-bold text-gray-900"><?php echo e($item->laundryItem->name); ?></h4>
                                    <p class="text-xs text-gray-600">Quantity: <?php echo e($item->quantity); ?></p>
                                </div>
                                <div class="text-right">
                                    <p class="text-sm font-bold text-gray-900">₦<?php echo e(number_format($item->total_price, 2)); ?></p>
                                    <p class="text-xs text-gray-600">₦<?php echo e(number_format($item->unit_price, 2)); ?> each</p>
                                </div>
                            </div>

                            <!-- Compact Item Options -->
                            <div class="text-xs mb-1">
                                <span class="font-medium">Color:</span> <span class="capitalize"><?php echo e($item->color_type); ?></span><?php if($item->color_type === 'white'): ?> <span class="text-blue-600">(+20%: ₦<?php echo e(number_format($item->unit_price * 0.20, 2)); ?>)</span><?php endif; ?> |
                                <span class="font-medium">Starch:</span> <?php echo e($item->starch ? 'Yes' : 'No'); ?><?php if($item->starch && $item->starch_price > 0): ?> <span class="text-green-600">(₦<?php echo e(number_format($item->starch_price, 2)); ?>)</span><?php endif; ?> |
                                <?php
                                    $__base3 = $item->unit_price * $item->quantity;
                                    $__white3 = $item->color_type === 'white' ? $__base3 * 0.20 : 0;
                                    $__starchAmt3 = ($item->starch && $item->starch_price > 0) ? $item->starch_price : 0;
                                    $__hasHanger3 = abs($item->total_price - ($__base3 + $__white3 + $__starchAmt3 + $__base3 * 0.05)) < 0.01;
                                ?>
                                <span class="font-medium">Hanger:</span> <?php if($__hasHanger3): ?><span class="text-green-600">Yes (+5%)</span><?php else: ?><span class="text-gray-500">N/A</span><?php endif; ?>
                            </div>

                            <?php if($item->special_instructions): ?>
                                <div class="text-xs text-blue-600 mt-1">
                                    <span class="font-semibold">Note:</span> <?php echo e($item->special_instructions); ?>

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

            <!-- Pricing Summary -->
            <div class="flex justify-end mb-8">
                <div class="w-64">
                    <div class="border border-gray-300 p-4">
                        <h3 class="text-lg font-semibold mb-3 text-gray-900">Payment Summary</h3>
                        <div class="space-y-2 text-sm">
                            <div class="flex justify-between">
                                <span>Subtotal:</span>
                                <span>₦<?php echo e(number_format($order->total_amount, 2)); ?></span>
                            </div>
                            <?php if($order->discount_amount > 0): ?>
                                <div class="flex justify-between text-green-600">
                                    <span>Discount:</span>
                                    <span>-₦<?php echo e(number_format($order->discount_amount, 2)); ?></span>
                                </div>
                            <?php endif; ?>
                            <div class="border-t border-gray-300 pt-2 mt-2">
                                <div class="flex justify-between font-bold text-lg">
                                    <span>Total:</span>
                                    <span>₦<?php echo e(number_format($order->final_amount, 2)); ?></span>
                                </div>
                            </div>
                            <div class="border-t border-gray-300 pt-2 mt-2">
                                <div class="flex justify-between text-sm">
                                    <span>Amount Paid:</span>
                                    <span>₦<?php echo e(number_format($order->amount_paid, 2)); ?></span>
                                </div>
                                <?php if($order->payment_method): ?>
                                    <div class="flex justify-between text-sm">
                                        <span>Payment Method:</span>
                                        <span><?php echo e(ucfirst($order->payment_method)); ?></span>
                                    </div>
                                <?php endif; ?>
                                <div class="flex justify-between font-bold <?php echo e($order->outstanding_balance > 0 ? 'text-red-600' : 'text-green-600'); ?>">
                                    <span>Outstanding Balance:</span>
                                    <span>₦<?php echo e(number_format($order->outstanding_balance, 2)); ?></span>
                                </div>
                            </div>
                        </div>
                    </div>
                </div>
            </div>

            <?php if($order->notes): ?>
                <div class="mb-8">
                    <h3 class="text-lg font-semibold mb-3 text-gray-900">Order Notes</h3>
                    <div class="border border-gray-300 p-4 bg-gray-50">
                        <p class="text-sm"><?php echo e($order->notes); ?></p>
                    </div>
                </div>
            <?php endif; ?>

            <!-- Footer -->
            <div class="text-center text-sm text-gray-600 border-t border-gray-300 pt-6">
                <p>Thank you for choosing Slarry Laundry Service!</p>
                <p class="mt-2">For inquiries, please contact us at Ayodejiademide@gmail.com</p>
                <p class="text-xs text-gray-500">More blessing complex, along lokoja road, semu semu, ikare akoko ondo state</p>
                <p class="mt-4 text-xs">Printed on <?php echo e(now()->format('M d, Y g:i A')); ?></p>
            </div>
        </div>
    </div>

    <script>
        function updateStatus() {
            document.getElementById('statusModal').classList.remove('hidden');
        }

        function closeStatusModal() {
            document.getElementById('statusModal').classList.add('hidden');
        }

        function updatePayment() {
            document.getElementById('paymentModal').classList.remove('hidden');
        }

        function closePaymentModal() {
            document.getElementById('paymentModal').classList.add('hidden');
        }

        <?php if(Auth::user()->hasPermission('manage_orders')): ?>
            function confirmDeleteOrder() {
                document.getElementById('deleteOrderModal').classList.remove('hidden');
            }

            function closeDeleteOrderModal() {
                document.getElementById('deleteOrderModal').classList.add('hidden');
            }
        <?php endif; ?>

        function printOrder() {
            // Hide the main content and show print content
            const mainContent = document.querySelector('.max-w-7xl');
            const printContent = document.getElementById('printContent');

            // Store original display values
            const originalMainDisplay = mainContent.style.display;
            const originalPrintDisplay = printContent.style.display;

            // Hide main content and show print content
            mainContent.style.display = 'none';
            printContent.style.display = 'block';
            printContent.classList.remove('hidden');

            // Print
            window.print();

            // Restore original display values
            mainContent.style.display = originalMainDisplay;
            printContent.style.display = originalPrintDisplay;
            printContent.classList.add('hidden');
        }

        // Close modal when clicking outside
        document.getElementById('statusModal').addEventListener('click', function(e) {
            if (e.target === this) {
                closeStatusModal();
            }
        });

        document.getElementById('paymentModal').addEventListener('click', function(e) {
            if (e.target === this) {
                closePaymentModal();
            }
        });

        <?php if(Auth::user()->hasPermission('manage_orders')): ?>
            document.getElementById('deleteOrderModal').addEventListener('click', function(e) {
                if (e.target === this) {
                    closeDeleteOrderModal();
                }
            });
        <?php endif; ?>
    </script>
 <?php echo $__env->renderComponent(); ?>
<?php endif; ?>
<?php if (isset($__attributesOriginal9ac128a9029c0e4701924bd2d73d7f54)): ?>
<?php $attributes = $__attributesOriginal9ac128a9029c0e4701924bd2d73d7f54; ?>
<?php unset($__attributesOriginal9ac128a9029c0e4701924bd2d73d7f54); ?>
<?php endif; ?>
<?php if (isset($__componentOriginal9ac128a9029c0e4701924bd2d73d7f54)): ?>
<?php $component = $__componentOriginal9ac128a9029c0e4701924bd2d73d7f54; ?>
<?php unset($__componentOriginal9ac128a9029c0e4701924bd2d73d7f54); ?>
<?php endif; ?>
<?php /**PATH C:\xampp\htdocs\slarry\resources\views/orders/show.blade.php ENDPATH**/ ?>