<!DOCTYPE html>
<html lang="<?php echo e(str_replace('_', '-', app()->getLocale())); ?>">
<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <title><?php echo e($order->order_number); ?> - Slarry Laundry Service</title>
    
    <!-- Tailwind CSS -->
    <?php echo app('Illuminate\Foundation\Vite')(['resources/css/app.css']); ?>
    
    <style>
        body { 
            font-family: 'Inter', sans-serif; 
            background: white;
            margin: 0;
            padding: 20px;
        }
        
        @media print {
            body {
                margin: 0;
                padding: 0;
                font-size: 11px;
                line-height: 1.2;
            }
            
            .no-print {
                display: none !important;
            }
            
            .print-container {
                margin: 0;
                padding: 8px;
                height: 100vh;
                max-height: 100vh;
                overflow: hidden;
                box-sizing: border-box;
                display: flex;
                flex-direction: column;
            }
            
            .receipt-content {
                flex: 1;
                display: flex;
                flex-direction: column;
                overflow: hidden;
            }
            
            .items-section {
                flex: 1;
                overflow: hidden;
                min-height: 0;
            }
            
            .items-container {
                max-height: 45vh;
                overflow: hidden;
            }
            
            .item-card {
                margin-bottom: 3px !important;
                padding: 3px !important;
                page-break-inside: avoid;
                font-size: 0.7rem !important;
                border-width: 1px !important;
            }
            
            .header-section {
                margin-bottom: 6px !important;
            }
            
            .order-info-section {
                margin-bottom: 6px !important;
            }
            
            .pricing-section {
                margin-bottom: 4px !important;
                margin-top: auto;
            }
            
            .footer-section {
                margin-top: auto;
                padding-top: 4px !important;
                font-size: 0.6rem !important;
            }
            
            /* Ultra-compact text sizes for print */
            h1 { font-size: 1.1rem !important; margin-bottom: 0.2rem !important; line-height: 1.1; }
            h2 { font-size: 0.95rem !important; margin-bottom: 0.2rem !important; line-height: 1.1; }
            h3 { font-size: 0.85rem !important; margin-bottom: 0.2rem !important; line-height: 1.1; }
            h4 { font-size: 0.75rem !important; margin-bottom: 0.1rem !important; line-height: 1.1; }
            h5 { font-size: 0.7rem !important; margin-bottom: 0.1rem !important; line-height: 1.1; }
            p { margin-bottom: 0.1rem !important; font-size: 0.7rem !important; line-height: 1.1; }
            .space-y-2 > * + * { margin-top: 0.1rem !important; }
            .space-y-3 > * + * { margin-top: 0.15rem !important; }
            .space-y-4 > * + * { margin-top: 0.15rem !important; }
            .text-sm { font-size: 0.65rem !important; }
            .text-xs { font-size: 0.6rem !important; }
            .text-lg { font-size: 0.8rem !important; }
            .text-xl { font-size: 0.9rem !important; }
            .text-2xl { font-size: 1rem !important; }
            .text-3xl { font-size: 1.1rem !important; }
            .text-4xl { font-size: 1.2rem !important; }
            
            /* Compact item options */
            .item-options {
                padding: 2px !important;
                margin-bottom: 2px !important;
            }
            
            .pricing-breakdown {
                padding: 2px !important;
                font-size: 0.6rem !important;
            }
            
            /* Compact grid spacing */
            .grid {
                gap: 0.5rem !important;
            }
            
            /* Compact borders and padding */
            .border-2 { border-width: 1px !important; }
            .p-6 { padding: 3px !important; }
            .p-4 { padding: 2px !important; }
            .p-3 { padding: 2px !important; }
            .p-2 { padding: 1px !important; }
            .px-4 { padding-left: 2px !important; padding-right: 2px !important; }
            .py-3 { padding-top: 1px !important; padding-bottom: 1px !important; }
            .mb-8 { margin-bottom: 4px !important; }
            .mb-6 { margin-bottom: 3px !important; }
            .mb-4 { margin-bottom: 2px !important; }
            .mb-3 { margin-bottom: 1px !important; }
            .mt-6 { margin-top: 3px !important; }
            .mt-4 { margin-top: 2px !important; }
            .mt-3 { margin-top: 1px !important; }
        }
        
        @page {
            margin: 0.3in;
            size: A4;
        }
        
        /* Ensure no page breaks */
        * {
            page-break-inside: avoid;
        }
        
        .print-container {
            page-break-inside: avoid;
        }
    </style>
</head>
<body>
    <div class="print-container max-w-4xl mx-auto bg-white">
        <div class="receipt-content">
        <!-- Print Button (hidden when printing) -->
        <div class="no-print mb-6 text-center">
            <button onclick="window.print()" 
                    class="bg-blue-600 hover:bg-blue-700 text-white font-semibold py-2 px-6 rounded-lg mr-4">
                Print Order
            </button>
            <a href="<?php echo e(route('orders.show', $order)); ?>" 
               class="bg-gray-600 hover:bg-gray-700 text-white font-semibold py-2 px-6 rounded-lg">
                Back to Order
            </a>
        </div>

        <!-- Header -->
        <div class="header-section text-center mb-8 border-b-2 border-gray-800 pb-6">
            <h1 class="text-4xl font-bold text-gray-900 mb-2">Slarry Laundry Service</h1>
            <p class="text-gray-700 text-lg">Professional Laundry Services</p>
            <p class="text-gray-600 text-sm mt-2">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-6">
                <h2 class="text-2xl font-semibold text-gray-800">Order Receipt</h2>
                <p class="text-xl font-bold text-blue-600 mt-2"><?php echo e($order->order_number); ?></p>
            </div>
        </div>

        <!-- Order Info -->
        <div class="order-info-section grid grid-cols-2 gap-8 mb-8">
            <div>
                <h3 class="text-lg font-bold mb-4 text-gray-900 border-b border-gray-300 pb-2">Customer Information</h3>
                <div class="space-y-2">
                    <p><span class="font-semibold">Name:</span> <?php echo e($order->customer->full_name); ?></p>
                    <p><span class="font-semibold">Phone:</span> <?php echo e($order->customer->phone); ?></p>
                    <?php if($order->customer->email): ?>
                        <p><span class="font-semibold">Email:</span> <?php echo e($order->customer->email); ?></p>
                    <?php endif; ?>
                    <p><span class="font-semibold">Address:</span> <?php echo e($order->customer->address); ?></p>
                </div>
            </div>
            <div>
                <h3 class="text-lg font-bold mb-4 text-gray-900 border-b border-gray-300 pb-2">Order Details</h3>
                <div class="space-y-2">
                    <p><span class="font-semibold">Order Date:</span> <?php echo e($order->created_at->format('M d, Y g:i A')); ?></p>
                    <p><span class="font-semibold">Status:</span> <span class="capitalize font-medium"><?php echo e($order->status); ?></span></p>
                    
                    <p><span class="font-semibold">Packaging:</span> <?php echo e(ucfirst($order->packaging_preference)); ?></p>
                    <?php if($order->pickup_date): ?>
                        <p><span class="font-semibold">Pickup Date:</span> <?php echo e($order->pickup_date->format('M d, Y')); ?></p>
                    <?php endif; ?>
                    <?php if($order->delivery_date): ?>
                        <p><span class="font-semibold">Delivery Date:</span> <?php echo e($order->delivery_date->format('M d, Y')); ?></p>
                    <?php endif; ?>
                    <p><span class="font-semibold">Created By:</span> <?php echo e($order->createdBy->name ?? 'N/A'); ?></p>
                </div>
            </div>
        </div>

        <!-- Order Items -->
        <div class="items-section mb-8">
            <h3 class="text-lg font-bold mb-4 text-gray-900 border-b border-gray-300 pb-2">Order Items</h3>
            <div class="items-container space-y-4">
                <?php $__currentLoopData = $order->orderItems; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $item): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                    <div class="item-card border-2 border-gray-800 p-4 bg-gray-50">
                        <!-- Item Header -->
                        <div class="flex justify-between items-start mb-3">
                            <div class="flex-1">
                                <h4 class="text-lg font-bold 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 class="text-right">
                                <p class="text-xl font-bold text-gray-900">₦<?php echo e(number_format($item->total_price, 2)); ?></p>
                                <p class="text-sm text-gray-600">₦<?php echo e(number_format($item->unit_price, 2)); ?> each</p>
                            </div>
                        </div>

                        <!-- Item Options -->
                        <div class="grid grid-cols-3 gap-4 mb-3 text-sm">
                                <!-- Compact Item Options -->
                                <div class="text-xs">
                                    <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 * $item->quantity * 0.20, 2)); ?>)</span><?php endif; ?>
                                </div>

                                <div class="text-xs">
                                    <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; ?>
                                </div>

                                <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%: ₦<?php echo e(number_format($item->unit_price * $item->quantity * 0.05, 2)); ?>)</span><?php else: ?><span class="text-gray-500">No</span><?php endif; ?>
                                </div>
                        </div>

                        <!-- Compact Pricing Breakdown -->
                        <div class="pricing-breakdown bg-blue-50 p-1 rounded border border-blue-100">
                            <div class="text-xs text-blue-700">
                                Base: ₦<?php echo e(number_format($item->unit_price * $item->quantity, 2)); ?>

                                <?php if($item->color_type === 'white'): ?>, Color: +₦<?php echo e(number_format($item->unit_price * $item->quantity * 0.20, 2)); ?><?php endif; ?>
                                <?php if($item->starch && $item->starch_price > 0): ?>, Starch: +₦<?php echo e(number_format($item->starch_price, 2)); ?><?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): ?>, Hanger: +₦<?php echo e(number_format($item->unit_price * $item->quantity * 0.05, 2)); ?><?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>

        <!-- Pricing Summary -->
        <div class="pricing-section flex justify-end mb-8">
            <div class="w-80">
                <div class="border-2 border-gray-800 p-6 bg-gray-50">
                    <h3 class="text-lg font-bold mb-4 text-gray-900">Payment Summary</h3>
                    <div class="space-y-3">
                        <div class="flex justify-between text-lg">
                            <span class="font-medium">Subtotal:</span>
                            <span class="font-semibold">₦<?php echo e(number_format($order->total_amount, 2)); ?></span>
                        </div>
                        <?php if($order->discount_amount > 0): ?>
                            <div class="flex justify-between text-lg text-green-700">
                                <span class="font-medium">Discount:</span>
                                <span class="font-semibold">-₦<?php echo e(number_format($order->discount_amount, 2)); ?></span>
                            </div>
                        <?php endif; ?>
                        <div class="border-t-2 border-gray-800 pt-3 mt-3">
                            <div class="flex justify-between text-xl font-bold">
                                <span>Total Amount:</span>
                                <span>₦<?php echo e(number_format($order->final_amount, 2)); ?></span>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </div>

        <?php if($order->notes): ?>
            <div class="mb-8">
                <h3 class="text-lg font-bold mb-4 text-gray-900 border-b border-gray-300 pb-2">Order Notes</h3>
                <div class="border-2 border-gray-400 p-4 bg-yellow-50 rounded">
                    <p class="text-gray-800"><?php echo e($order->notes); ?></p>
                </div>
            </div>
        <?php endif; ?>

        <!-- Footer -->
        <div class="footer-section text-center text-gray-700 border-t-2 border-gray-800 pt-6 mt-8">
            <p class="text-lg font-semibold">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-sm text-gray-600">More blessing complex, along lokoja road, semu semu, ikare akoko ondo state</p>
            <p class="mt-4 text-sm text-gray-600">Printed on <?php echo e(now()->format('M d, Y g:i A')); ?></p>
        </div>
        </div>
    </div>

    <script>
        // Auto-focus for better printing experience
        window.addEventListener('load', function() {
            // Auto-print if requested via URL parameter
            const urlParams = new URLSearchParams(window.location.search);
            if (urlParams.get('auto_print') === '1') {
                setTimeout(() => {
                    window.print();
                }, 500);
            }
        });
    </script>
</body>
</html>
<?php /**PATH /home/rxilrzxf/laundry.paulotech.com.ng/resources/views/orders/print.blade.php ENDPATH**/ ?>