<?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([]); ?>
    <div class="py-12 bg-gray-50 min-h-screen">
        <div class="max-w-4xl mx-auto sm:px-6 lg:px-8 space-y-6">
            
            <!-- Header Section -->
            <div class="bg-white p-8 rounded-2xl border border-gray-100 shadow-sm">
                <h2 class="text-2xl font-black text-gray-800 uppercase tracking-tight">Buat Pesanan Baru</h2>
                <p class="text-sm text-gray-400 font-medium mt-1">Pilih produk dan tentukan jumlah pesanan Anda.</p>
            </div>

            <form action="<?php echo e(route('customer.pesanan.store')); ?>" method="POST" class="space-y-6">
                <?php echo csrf_field(); ?>
                
                <!-- Product List -->
                <div class="bg-white p-8 rounded-2xl border border-gray-100 shadow-sm space-y-4">
                    <?php $__currentLoopData = $produks; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $produk): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                        <div class="flex items-center justify-between p-4 bg-gray-50 rounded-2xl border border-gray-100">
                            <div class="flex-grow">
                                <h4 class="font-black text-gray-800 text-sm"><?php echo e($produk->nama_produk); ?></h4>
                                <p class="text-[10px] font-bold text-gray-400 uppercase tracking-widest"><?php echo e($produk->berat); ?> <?php echo e($produk->satuan); ?></p>
                                
                                <div class="mt-2 space-y-0.5">
                                    <p class="text-[10px] font-black text-gray-400 uppercase">Harga: Rp <?php echo e(number_format($produk->harga, 0, ',', '.')); ?></p>
                                    <?php if($produk->min_qty_mitra > 0): ?>
                                        <p class="text-[10px] font-black text-green-700 uppercase">Harga Mitra: Rp <?php echo e(number_format($produk->harga_mitra, 0, ',', '.')); ?> (Min. <?php echo e($produk->min_qty_mitra); ?> pcs)</p>
                                    <?php endif; ?>
                                </div>
                            </div>
                            
                            <input type="number" 
                                   name="qty[<?php echo e($produk->id); ?>]" 
                                   class="qty-input w-24 px-3 py-2 rounded-xl border border-gray-200 text-center font-black text-sm text-gray-800 focus:ring-2 focus:ring-green-700/20 focus:border-green-700" 
                                   value="0" min="0"
                                   data-harga="<?php echo e($produk->harga); ?>"
                                   data-min-mitra="<?php echo e($produk->min_qty_mitra); ?>"
                                   data-harga-mitra="<?php echo e($produk->harga_mitra); ?>"
                                   oninput="hitungTotal()">
                        </div>
                    <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
                </div>

                <!-- Shipping Details -->
                <div class="bg-white p-8 rounded-2xl border border-gray-100 shadow-sm space-y-6">
                    <h5 class="font-black text-gray-800 uppercase text-sm tracking-widest border-b border-gray-100 pb-4">Detail Pengiriman</h5>
                    
                    <div class="grid grid-cols-1 md:grid-cols-2 gap-6">
                        <div class="space-y-2">
                            <label class="text-[10px] font-black text-gray-400 uppercase tracking-widest">Tanggal Kirim</label>
                            <input type="date" name="tanggal_kirim" required 
                                   class="w-full px-4 py-3 rounded-xl border border-gray-200 text-sm font-bold text-gray-800 focus:ring-2 focus:ring-green-700/20 focus:border-green-700">
                        </div>
                    </div>

                    <div class="space-y-2">
                        <label class="text-[10px] font-black text-gray-400 uppercase tracking-widest">Catatan Tambahan (Opsional)</label>
                        <textarea name="catatan" rows="3" 
                                  class="w-full px-4 py-3 rounded-xl border border-gray-200 text-sm font-bold text-gray-800 focus:ring-2 focus:ring-green-700/20 focus:border-green-700" 
                                  placeholder="Contoh: Titip di pos satpam..."></textarea>
                    </div>
                </div>

                <!-- Total & Submit -->
                <div class="bg-green-700 p-8 rounded-2xl flex flex-col sm:flex-row justify-between items-center gap-4 shadow-lg shadow-green-700/20">
                    <div class="text-white">
                        <p class="text-[10px] font-black uppercase tracking-widest opacity-80">Total Pembayaran</p>
                        <span id="total-display" class="text-2xl font-black">Rp 0</span>
                    </div>
                    <button type="submit" class="bg-white text-green-700 px-8 py-3 rounded-xl font-black text-xs uppercase tracking-widest shadow-sm hover:bg-gray-50 transition-all active:scale-95">
                        Konfirmasi Pesanan
                    </button>
                </div>
            </form>
        </div>
    </div>

    <script>
        function hitungTotal() {
            let grandTotal = 0;
            document.querySelectorAll('.qty-input').forEach(input => {
                let qty = parseInt(input.value) || 0;
                let hargaNormal = parseInt(input.dataset.harga);
                let minMitra = parseInt(input.dataset.minMitra);
                let hargaMitra = parseInt(input.dataset.hargaMitra);
                
                let hargaSatuan = (minMitra > 0 && qty >= minMitra) ? hargaMitra : hargaNormal;
                grandTotal += (qty * hargaSatuan);
            });
            document.getElementById('total-display').innerText = 'Rp ' + grandTotal.toLocaleString('id-ID');
        }
    </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 D:\TempeZhi\resources\views/customer/pesanan/create.blade.php ENDPATH**/ ?>