<div class="grid gap-5 lg:grid-cols-[1fr_430px]">
    <div class="space-y-5">
        <div class="rounded-lg bg-white p-5 shadow-sm">
            <div class="flex flex-col gap-3 md:flex-row md:items-end">
                <div class="flex-1 text-sm">
                    <label for="pos-customer-search">Pelanggan</label>
                    <?php if(\Livewire\Mechanisms\ExtendBlade\ExtendBlade::isRenderingLivewireComponent()): ?><!--[if BLOCK]><![endif]--><?php endif; ?><?php if($customerId): ?>
                        <div class="mt-1 flex items-center justify-between gap-3 rounded-md border bg-emerald-50 px-3 py-2 text-emerald-900">
                            <span class="truncate"><?php echo e($selectedCustomerLabel); ?></span>
                            <button type="button" wire:click="clearCustomer" class="text-xs font-medium text-emerald-800 underline">Ganti</button>
                        </div>
                    <?php else: ?>
                        <div class="relative mt-1">
                            <input id="pos-customer-search" wire:model.live.debounce.350ms="customerSearch" autocomplete="off" placeholder="Ketik nama atau nomor HP, kosongkan untuk walk-in" class="w-full rounded-md border px-3 py-2">
                            <?php if(\Livewire\Mechanisms\ExtendBlade\ExtendBlade::isRenderingLivewireComponent()): ?><!--[if BLOCK]><![endif]--><?php endif; ?><?php if(mb_strlen(trim($customerSearch)) >= 2): ?>
                                <div class="absolute z-20 mt-1 max-h-72 w-full overflow-y-auto rounded-md border bg-white shadow-lg">
                                    <?php if(\Livewire\Mechanisms\ExtendBlade\ExtendBlade::isRenderingLivewireComponent()): ?><!--[if BLOCK]><![endif]--><?php \Livewire\Features\SupportCompiledWireKeys\SupportCompiledWireKeys::openLoop(); ?><?php endif; ?><?php $__empty_1 = true; $__currentLoopData = $customers; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $customer): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); $__empty_1 = false; ?><?php if(\Livewire\Mechanisms\ExtendBlade\ExtendBlade::isRenderingLivewireComponent()): ?><?php \Livewire\Features\SupportCompiledWireKeys\SupportCompiledWireKeys::startLoopIteration(); ?><?php endif; ?>
                                        <button type="button" wire:click="selectCustomer(<?php echo e($customer->id); ?>)" class="block w-full px-3 py-3 text-left hover:bg-slate-50">
                                            <span class="block font-medium"><?php echo e($customer->name); ?></span>
                                            <span class="text-xs text-slate-500"><?php echo e($customer->phone); ?><?php echo e($customer->address ? ' - '.$customer->address : ''); ?></span>
                                        </button>
                                    <?php if(\Livewire\Mechanisms\ExtendBlade\ExtendBlade::isRenderingLivewireComponent()): ?><?php \Livewire\Features\SupportCompiledWireKeys\SupportCompiledWireKeys::endLoop(); ?><?php endif; ?><?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); if ($__empty_1): ?><?php if(\Livewire\Mechanisms\ExtendBlade\ExtendBlade::isRenderingLivewireComponent()): ?><?php \Livewire\Features\SupportCompiledWireKeys\SupportCompiledWireKeys::closeLoop(); ?><?php endif; ?>
                                        <div class="px-3 py-3 text-slate-500">Pelanggan tidak ditemukan.</div>
                                    <?php endif; ?><?php if(\Livewire\Mechanisms\ExtendBlade\ExtendBlade::isRenderingLivewireComponent()): ?><!--[if ENDBLOCK]><![endif]--><?php endif; ?>
                                </div>
                            <?php endif; ?><?php if(\Livewire\Mechanisms\ExtendBlade\ExtendBlade::isRenderingLivewireComponent()): ?><!--[if ENDBLOCK]><![endif]--><?php endif; ?>
                        </div>
                    <?php endif; ?><?php if(\Livewire\Mechanisms\ExtendBlade\ExtendBlade::isRenderingLivewireComponent()): ?><!--[if ENDBLOCK]><![endif]--><?php endif; ?>
                </div>
                <button type="button" wire:click="$toggle('showCustomerForm')" class="rounded-md border px-4 py-2 text-sm">Tambah Cepat</button>
            </div>

            <?php if(\Livewire\Mechanisms\ExtendBlade\ExtendBlade::isRenderingLivewireComponent()): ?><!--[if BLOCK]><![endif]--><?php endif; ?><?php if($customerId): ?>
                <div class="mt-3 rounded-md bg-emerald-50 px-3 py-2 text-sm text-emerald-800">
                    Promo pelanggan: <?php echo e($rewardProgress); ?>/5 invoice lunas.
                    <?php if(\Livewire\Mechanisms\ExtendBlade\ExtendBlade::isRenderingLivewireComponent()): ?><!--[if BLOCK]><![endif]--><?php endif; ?><?php if($rewardProgress >= 5): ?>
                        Reward gratis 1 item jasa tersedia.
                    <?php endif; ?><?php if(\Livewire\Mechanisms\ExtendBlade\ExtendBlade::isRenderingLivewireComponent()): ?><!--[if ENDBLOCK]><![endif]--><?php endif; ?>
                </div>
            <?php endif; ?><?php if(\Livewire\Mechanisms\ExtendBlade\ExtendBlade::isRenderingLivewireComponent()): ?><!--[if ENDBLOCK]><![endif]--><?php endif; ?>

            <?php if(\Livewire\Mechanisms\ExtendBlade\ExtendBlade::isRenderingLivewireComponent()): ?><!--[if BLOCK]><![endif]--><?php endif; ?><?php if($showCustomerForm): ?>
                <div class="mt-4 grid gap-3 rounded-md border bg-slate-50 p-4 md:grid-cols-3">
                    <input wire:model="newCustomer.name" placeholder="Nama pelanggan" class="rounded-md border px-3 py-2 text-sm">
                    <input wire:model="newCustomer.phone" placeholder="Nomor HP" class="rounded-md border px-3 py-2 text-sm">
                    <input wire:model="newCustomer.address" placeholder="Alamat" class="rounded-md border px-3 py-2 text-sm">
                    <button type="button" wire:click="saveCustomer" class="rounded-md bg-slate-900 px-4 py-2 text-sm font-medium text-white md:col-span-3">Simpan Pelanggan</button>
                </div>
            <?php endif; ?><?php if(\Livewire\Mechanisms\ExtendBlade\ExtendBlade::isRenderingLivewireComponent()): ?><!--[if ENDBLOCK]><![endif]--><?php endif; ?>
        </div>

        <div class="rounded-lg bg-white p-5 shadow-sm">
            <div class="mb-4 flex items-center justify-between">
                <h2 class="font-semibold">Produk & Layanan</h2>
                <span class="text-sm text-slate-500"><?php echo e($products->count()); ?> item aktif</span>
            </div>
            <div class="grid gap-3 md:grid-cols-2 xl:grid-cols-3">
                <?php if(\Livewire\Mechanisms\ExtendBlade\ExtendBlade::isRenderingLivewireComponent()): ?><!--[if BLOCK]><![endif]--><?php \Livewire\Features\SupportCompiledWireKeys\SupportCompiledWireKeys::openLoop(); ?><?php endif; ?><?php $__currentLoopData = $products; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $product): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?><?php if(\Livewire\Mechanisms\ExtendBlade\ExtendBlade::isRenderingLivewireComponent()): ?><?php \Livewire\Features\SupportCompiledWireKeys\SupportCompiledWireKeys::startLoopIteration(); ?><?php endif; ?>
                    <?php $stock = $product->stocks->first()?->quantity ?? 0; ?>
                    <button type="button" wire:click="addProduct(<?php echo e($product->id); ?>)" class="rounded-md border p-3 text-left text-sm hover:border-slate-400 hover:bg-slate-50">
                        <div class="flex items-start justify-between gap-2">
                            <span class="font-medium"><?php echo e($product->name); ?></span>
                            <span class="rounded bg-slate-100 px-2 py-1 text-xs"><?php echo e($product->type); ?></span>
                        </div>
                        <div class="mt-2 text-slate-600">Rp <?php echo e(number_format($product->price, 0, ',', '.')); ?> / <?php echo e($product->unit); ?></div>
                        <?php if(\Livewire\Mechanisms\ExtendBlade\ExtendBlade::isRenderingLivewireComponent()): ?><!--[if BLOCK]><![endif]--><?php endif; ?><?php if($product->track_stock): ?>
                            <div class="mt-1 text-xs <?php echo e($stock <= $product->minimum_stock ? 'text-red-600' : 'text-slate-500'); ?>">Stok: <?php echo e($stock); ?></div>
                        <?php endif; ?><?php if(\Livewire\Mechanisms\ExtendBlade\ExtendBlade::isRenderingLivewireComponent()): ?><!--[if ENDBLOCK]><![endif]--><?php endif; ?>
                    </button>
                <?php if(\Livewire\Mechanisms\ExtendBlade\ExtendBlade::isRenderingLivewireComponent()): ?><?php \Livewire\Features\SupportCompiledWireKeys\SupportCompiledWireKeys::endLoop(); ?><?php endif; ?><?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?><?php if(\Livewire\Mechanisms\ExtendBlade\ExtendBlade::isRenderingLivewireComponent()): ?><!--[if ENDBLOCK]><![endif]--><?php \Livewire\Features\SupportCompiledWireKeys\SupportCompiledWireKeys::closeLoop(); ?><?php endif; ?>
            </div>
        </div>
    </div>

    <div class="space-y-5">
        <div class="rounded-lg bg-white p-5 shadow-sm">
            <h2 class="font-semibold">Keranjang</h2>
            <div class="mt-4 space-y-3">
                <?php if(\Livewire\Mechanisms\ExtendBlade\ExtendBlade::isRenderingLivewireComponent()): ?><!--[if BLOCK]><![endif]--><?php \Livewire\Features\SupportCompiledWireKeys\SupportCompiledWireKeys::openLoop(); ?><?php endif; ?><?php $__empty_1 = true; $__currentLoopData = $cart; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $productId => $item): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); $__empty_1 = false; ?><?php if(\Livewire\Mechanisms\ExtendBlade\ExtendBlade::isRenderingLivewireComponent()): ?><?php \Livewire\Features\SupportCompiledWireKeys\SupportCompiledWireKeys::startLoopIteration(); ?><?php endif; ?>
                    <div class="rounded-md border p-3">
                        <div class="flex items-start justify-between gap-3">
                            <div>
                                <div class="font-medium"><?php echo e($item['name']); ?></div>
                                <div class="text-xs text-slate-500">Rp <?php echo e(number_format($item['price'], 0, ',', '.')); ?> / <?php echo e($item['unit']); ?></div>
                            </div>
                            <button type="button" wire:click="removeProduct(<?php echo e($productId); ?>)" class="text-sm text-red-600">Hapus</button>
                        </div>
                        <div class="mt-3 grid grid-cols-[88px_1fr] gap-2">
                            <div class="flex overflow-hidden rounded-md border">
                                <button type="button" wire:click="decrement(<?php echo e($productId); ?>)" class="w-8 bg-slate-100">-</button>
                                <input wire:model.live="cart.<?php echo e($productId); ?>.quantity" type="number" step="0.001" min="0.001" class="w-12 border-x px-1 text-center text-sm">
                                <button type="button" wire:click="increment(<?php echo e($productId); ?>)" class="w-8 bg-slate-100">+</button>
                            </div>
                            <select wire:model="cart.<?php echo e($productId); ?>.staff_id" class="rounded-md border px-2 py-2 text-sm">
                                <?php if(\Livewire\Mechanisms\ExtendBlade\ExtendBlade::isRenderingLivewireComponent()): ?><!--[if BLOCK]><![endif]--><?php \Livewire\Features\SupportCompiledWireKeys\SupportCompiledWireKeys::openLoop(); ?><?php endif; ?><?php $__currentLoopData = $staff; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $employee): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?><?php if(\Livewire\Mechanisms\ExtendBlade\ExtendBlade::isRenderingLivewireComponent()): ?><?php \Livewire\Features\SupportCompiledWireKeys\SupportCompiledWireKeys::startLoopIteration(); ?><?php endif; ?>
                                    <option value="<?php echo e($employee->id); ?>"><?php echo e($employee->name); ?></option>
                                <?php if(\Livewire\Mechanisms\ExtendBlade\ExtendBlade::isRenderingLivewireComponent()): ?><?php \Livewire\Features\SupportCompiledWireKeys\SupportCompiledWireKeys::endLoop(); ?><?php endif; ?><?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?><?php if(\Livewire\Mechanisms\ExtendBlade\ExtendBlade::isRenderingLivewireComponent()): ?><!--[if ENDBLOCK]><![endif]--><?php \Livewire\Features\SupportCompiledWireKeys\SupportCompiledWireKeys::closeLoop(); ?><?php endif; ?>
                            </select>
                        </div>
                        <input wire:model.live="cart.<?php echo e($productId); ?>.discount" type="number" min="0" placeholder="Diskon item" class="mt-2 w-full rounded-md border px-3 py-2 text-sm" <?php if($item['is_reward_free_item']): echo 'disabled'; endif; ?>>
                        <?php if(\Livewire\Mechanisms\ExtendBlade\ExtendBlade::isRenderingLivewireComponent()): ?><!--[if BLOCK]><![endif]--><?php endif; ?><?php if($item['type'] === 'service'): ?>
                            <label class="mt-2 flex items-center gap-2 text-sm">
                                <input type="checkbox" wire:click="toggleReward(<?php echo e($productId); ?>)" <?php if($item['is_reward_free_item']): echo 'checked'; endif; ?>>
                                Jadikan item reward gratis
                            </label>
                        <?php endif; ?><?php if(\Livewire\Mechanisms\ExtendBlade\ExtendBlade::isRenderingLivewireComponent()): ?><!--[if ENDBLOCK]><![endif]--><?php endif; ?>
                        <?php if(\Livewire\Mechanisms\ExtendBlade\ExtendBlade::isRenderingLivewireComponent()): ?><!--[if BLOCK]><![endif]--><?php endif; ?><?php if($item['track_stock']): ?>
                            <div class="mt-2 text-xs <?php echo e((float) $item['quantity'] > (float) $item['stock'] ? 'text-red-600' : 'text-slate-500'); ?>">Stok tersedia: <?php echo e($item['stock']); ?></div>
                        <?php endif; ?><?php if(\Livewire\Mechanisms\ExtendBlade\ExtendBlade::isRenderingLivewireComponent()): ?><!--[if ENDBLOCK]><![endif]--><?php endif; ?>
                    </div>
                <?php if(\Livewire\Mechanisms\ExtendBlade\ExtendBlade::isRenderingLivewireComponent()): ?><?php \Livewire\Features\SupportCompiledWireKeys\SupportCompiledWireKeys::endLoop(); ?><?php endif; ?><?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); if ($__empty_1): ?><?php if(\Livewire\Mechanisms\ExtendBlade\ExtendBlade::isRenderingLivewireComponent()): ?><?php \Livewire\Features\SupportCompiledWireKeys\SupportCompiledWireKeys::closeLoop(); ?><?php endif; ?>
                    <div class="rounded-md border border-dashed p-6 text-center text-sm text-slate-500">Pilih produk atau layanan untuk mulai transaksi.</div>
                <?php endif; ?><?php if(\Livewire\Mechanisms\ExtendBlade\ExtendBlade::isRenderingLivewireComponent()): ?><!--[if ENDBLOCK]><![endif]--><?php endif; ?>
            </div>
        </div>

        <div class="rounded-lg bg-white p-5 shadow-sm">
            <h2 class="font-semibold">Pembayaran</h2>
            <label class="mt-4 block text-sm">Estimasi selesai<input wire:model="estimatedDoneAt" type="datetime-local" class="mt-1 w-full rounded-md border px-3 py-2"></label>
            <div class="mt-4 space-y-2 text-sm">
                <div class="flex justify-between"><span>Subtotal</span><strong>Rp <?php echo e(number_format($this->total(), 0, ',', '.')); ?></strong></div>
                <label class="flex items-center justify-between gap-3">Diskon transaksi<input wire:model.live="discountTotal" type="number" min="0" class="w-36 rounded-md border px-3 py-2 text-right"></label>
                <label class="flex items-center justify-between gap-3">Ongkir<input wire:model.live="deliveryFee" type="number" min="0" class="w-36 rounded-md border px-3 py-2 text-right"></label>
                <div class="flex justify-between border-t pt-2 text-base"><span>Grand total</span><strong>Rp <?php echo e(number_format($this->grandTotal(), 0, ',', '.')); ?></strong></div>
                <label class="flex items-center justify-between gap-3">DP / bayar<input wire:model.live="paidAmount" type="number" min="0" class="w-36 rounded-md border px-3 py-2 text-right"></label>
                <div class="flex justify-between"><span>Sisa tagihan</span><strong>Rp <?php echo e(number_format($this->balanceDue(), 0, ',', '.')); ?></strong></div>
            </div>
            <label class="mt-4 block text-sm">Metode
                <select wire:model="paymentMethod" class="mt-1 w-full rounded-md border px-3 py-2">
                    <option value="cash">Cash</option>
                    <option value="transfer">Transfer</option>
                    <option value="qris">QRIS</option>
                </select>
            </label>
            <label class="mt-3 block text-sm">Catatan<textarea wire:model="note" class="mt-1 w-full rounded-md border px-3 py-2"></textarea></label>
            <?php if(\Livewire\Mechanisms\ExtendBlade\ExtendBlade::isRenderingLivewireComponent()): ?><!--[if BLOCK]><![endif]--><?php endif; ?><?php if($errors->any()): ?>
                <div class="mt-4 rounded-md bg-red-50 p-3 text-sm text-red-700"><?php echo e($errors->first()); ?></div>
            <?php endif; ?><?php if(\Livewire\Mechanisms\ExtendBlade\ExtendBlade::isRenderingLivewireComponent()): ?><!--[if ENDBLOCK]><![endif]--><?php endif; ?>
            <button type="button" wire:click="checkout" wire:loading.attr="disabled" class="mt-5 w-full rounded-md bg-slate-900 px-4 py-3 font-medium text-white disabled:opacity-60">
                <span wire:loading.remove>Checkout & Cetak Nota</span>
                <span wire:loading>Memproses...</span>
            </button>
        </div>
    </div>
</div>
<?php /**PATH /Users/dedehermawan/Dokumen/project/laundry/resources/views/livewire/admin/pos-cart.blade.php ENDPATH**/ ?>