<?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([]); ?>
    <script src="https://cdn.jsdelivr.net/npm/sweetalert2@11"></script>

    <div class="bg-[#FAF7F2] min-h-screen py-12">
        <div class="max-w-7xl mx-auto px-4 sm:px-6 lg:px-8">
            
            
            <div class="flex flex-col sm:flex-row sm:items-center justify-between gap-6 mb-10">
                <div>
                    <div class="flex items-center gap-2 text-sm text-[#8c6a4a] mb-1">
                        <i class="fas fa-shopping-cart"></i>
                        <span>Daftar Belanja</span>
                    </div>
                    <h1 class="text-3xl font-extrabold text-[#2c1a0e] tracking-tight">
                        Keranjang <span class="text-[#f59e0b]">Belanja</span>
                    </h1>
                    <p class="text-sm text-[#8c6a4a] mt-1">Anda memiliki <span class="font-bold"><?php echo e($cartItems->count()); ?></span> item di keranjang.</p>
                </div>
                <a href="<?php echo e(route('products.index')); ?>" class="inline-flex items-center gap-2 px-4 py-2 rounded-xl bg-white border border-[#e0d3c2] text-[#8c6a4a] hover:border-[#f59e0b] hover:text-[#f59e0b] transition-all text-sm font-bold">
                    <i class="fas fa-arrow-left text-xs"></i> Lanjut Belanja
                </a>
            </div>

            <?php if($cartItems->count() == 0): ?>
                <div class="bg-white p-12 md:p-16 rounded-2xl shadow-sm text-center border border-[#e0d3c2]">
                    <div class="w-24 h-24 bg-[#fef9f0] rounded-full flex items-center justify-center mx-auto mb-6">
                        <i class="fas fa-shopping-basket text-[#c9b59b] text-4xl"></i>
                    </div>
                    <h3 class="text-xl font-bold text-[#2c1a0e] mb-2">Keranjang Anda masih kosong</h3>
                    <p class="text-[#8c6a4a] mb-8 max-w-xs mx-auto">Sepertinya Anda belum menambahkan produk apapun.</p>
                    <a href="<?php echo e(route('products.index')); ?>" class="inline-block bg-gradient-to-r from-[#f59e0b] to-[#d97706] text-white px-8 py-4 rounded-xl font-bold text-xs uppercase tracking-wider hover:from-[#d97706] hover:to-[#b45309] transition-all shadow-md">
                        Mulai Belanja Sekarang
                    </a>
                </div>
            <?php else: ?>
            
            <div class="bg-white p-4 rounded-xl shadow-sm border border-[#e0d3c2] mb-6 flex items-center gap-3">
                <form action="<?php echo e(route('cart.toggle-all')); ?>" method="POST" id="form-select-all">
                    <?php echo csrf_field(); ?>
                    <input type="checkbox" 
                        onchange="this.form.submit()"
                        <?php echo e($cartItems->every('is_selected', true) && $cartItems->count() > 0 ? 'checked' : ''); ?>

                        class="w-5 h-5 rounded border-[#e0d3c2] text-[#f59e0b] focus:ring-[#f59e0b]/30 cursor-pointer">
                </form>
                <span class="text-sm font-bold text-[#2c1a0e]">Pilih Semua Produk</span>
            </div>
                <div class="flex flex-col lg:flex-row gap-10">
                    
                    
                    <div class="flex-1 space-y-5">
                        <?php $__currentLoopData = $cartItems; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $item): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                            <div class="bg-white p-5 rounded-2xl shadow-sm border border-[#e0d3c2] flex flex-col sm:flex-row items-center gap-5 transition-all hover:shadow-md group">
                                
                                
                                <div class="flex items-center">
                                    <form action="<?php echo e(route('cart.toggle', $item->id)); ?>" method="POST">
                                        <?php echo csrf_field(); ?>
                                        <input type="checkbox" onchange="this.form.submit()" <?php echo e($item->is_selected ? 'checked' : ''); ?>

                                               class="w-5 h-5 rounded border-[#e0d3c2] text-[#f59e0b] focus:ring-[#f59e0b]/30 cursor-pointer transition-all">
                                    </form>
                                </div>

                                
                                <div class="w-24 h-24 bg-[#fef9f0] rounded-xl border border-[#e0d3c2] overflow-hidden flex-shrink-0 relative group-hover:scale-105 transition-transform duration-300">
                                    <?php 
                                        $variantImage = $item->variant->images->first() ?? null;
                                        $productImage = $item->product->images->first() ?? null;
                                        $displayPath = $variantImage ? $variantImage->image : ($productImage ? $productImage->image : null);
                                    ?>
                                    <img src="<?php echo e($displayPath ? asset('storage/' . $displayPath) : 'https://placehold.co/400x400?text=No+Photo'); ?>" 
                                         alt="<?php echo e($item->product->name); ?>" 
                                         class="w-full h-full object-cover">
                                    <?php if($item->variant->color_code): ?>
                                        <div class="absolute top-1 right-1 w-3 h-3 rounded-full border border-white shadow-sm" style="background-color: <?php echo e($item->variant->color_code); ?>"></div>
                                    <?php endif; ?>
                                </div>

                                
                                <div class="flex-1 text-center sm:text-left">
                                    <p class="text-[10px] font-black uppercase tracking-wider text-[#d97706] mb-1">
                                        <?php echo e($item->product->category->name ?? 'Produk'); ?>

                                    </p>
                                    <h3 class="font-bold text-[#2c1a0e] text-lg mb-1"><?php echo e($item->product->name); ?></h3>
                                    <div class="flex flex-wrap justify-center sm:justify-start gap-2 mt-2">
                                        <span class="inline-flex items-center gap-1 px-2 py-1 bg-[#fef9f0] text-[#8c6a4a] rounded-full text-[10px] font-bold">
                                            <i class="fas fa-palette text-[9px]"></i> <?php echo e($item->variant->color ?? 'Standar'); ?>

                                        </span>
                                        <span class="inline-flex items-center gap-1 px-2 py-1 bg-[#fef3c7] text-[#d97706] rounded-full text-[10px] font-bold">
                                            Rp <?php echo e(number_format($item->price_at_add, 0, ',', '.')); ?>

                                        </span>
                                    </div>
                                </div>

                                
                                <div class="flex flex-col items-center gap-1">
                                    <form action="<?php echo e(route('cart.update', $item->id)); ?>" method="POST" class="flex items-center bg-[#fef9f0] rounded-xl p-1 border border-[#e0d3c2]">
                                        <?php echo csrf_field(); ?>
                                        <input type="number" name="quantity" value="<?php echo e($item->quantity); ?>" min="1" 
                                               class="w-12 bg-transparent border-none text-center font-black text-[#2c1a0e] focus:ring-0 text-sm"
                                               onchange="this.form.submit()">
                                    </form>
                                    <p class="text-[9px] text-[#8c6a4a] font-bold uppercase">Jumlah</p>
                                </div>

                                
                                <div class="text-right min-w-[110px]">
                                    <p class="text-[9px] text-[#8c6a4a] font-bold uppercase mb-1">Subtotal</p>
                                    <p class="font-black text-[#2c1a0e] text-lg">
                                        Rp <?php echo e(number_format($item->quantity * $item->price_at_add, 0, ',', '.')); ?>

                                    </p>
                                </div>

                                
                                <div>
                                    <button type="button" 
                                        onclick="confirmDelete('<?php echo e($item->id); ?>')" 
                                        class="w-9 h-9 rounded-xl flex items-center justify-center text-[#c9b59b] hover:text-red-500 hover:bg-red-50 transition-all">
                                        <i class="fas fa-trash-alt text-sm"></i>
                                    </button>
                                    <form id="delete-form-<?php echo e($item->id); ?>" action="<?php echo e(route('cart.remove', $item->id)); ?>" method="POST" class="hidden">
                                        <?php echo csrf_field(); ?> <?php echo method_field('DELETE'); ?>
                                    </form>
                                </div>
                            </div>
                        <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
                    </div>

                    
                    <div class="w-full lg:w-[380px]">
                        <div class="bg-[#2c1a0e] rounded-2xl p-6 text-white shadow-xl sticky top-10 overflow-hidden">
                            <div class="absolute -top-10 -right-10 w-32 h-32 bg-[#f59e0b]/20 rounded-full blur-2xl"></div>
                            <h2 class="text-xl font-black mb-6 flex items-center gap-3">
                                <i class="fas fa-receipt text-[#fbbf24]"></i>
                                Ringkasan Belanja
                            </h2>
                            <div class="space-y-3 mb-6">
                                <div class="flex justify-between text-[#c9b59b] text-sm">
                                    <span>Subtotal Produk</span>
                                    <span class="text-white font-bold">Rp <?php echo e(number_format($total, 0, ',', '.')); ?></span>
                                </div>
                                <div class="flex justify-between text-[#c9b59b] text-sm pb-3 border-b border-white/10">
                                    <span>Estimasi Pengiriman</span>
                                    <span class="text-xs italic text-[#a08162]">Dihitung saat checkout</span>
                                </div>
                                <div class="flex justify-between items-center pt-2">
                                    <span class="font-bold text-lg">Total Tagihan</span>
                                    <span class="font-black text-2xl text-[#fbbf24]">Rp <?php echo e(number_format($total, 0, ',', '.')); ?></span>
                                </div>
                            </div>

                            <a href="<?php echo e(route('checkout.index')); ?>" 
                               class="block w-full bg-gradient-to-r from-[#f59e0b] to-[#d97706] text-white text-center py-4 rounded-xl font-bold text-xs uppercase tracking-wider hover:from-[#d97706] hover:to-[#b45309] transition-all active:scale-95 shadow-md <?php echo e($total == 0 ? 'opacity-50 pointer-events-none' : ''); ?>">
                                Proses Checkout <i class="fas fa-arrow-right ml-2"></i>
                            </a>

                            <div class="mt-6 flex items-center justify-center gap-5 grayscale opacity-40">
                                <i class="fab fa-cc-visa text-2xl"></i>
                                <i class="fab fa-cc-mastercard text-2xl"></i>
                                <i class="fas fa-university text-xl"></i>
                            </div>
                        </div>
                    </div>
                </div>
            <?php endif; ?>
        </div>
    </div>

    <script>
        function confirmDelete(id) {
            Swal.fire({
                title: 'Hapus Item?',
                text: "Produk ini akan dikeluarkan dari keranjang belanja Anda.",
                icon: 'warning',
                showCancelButton: true,
                confirmButtonColor: '#ef4444',
                cancelButtonColor: '#8c6a4a',
                confirmButtonText: 'Ya, Hapus!',
                cancelButtonText: 'Batal',
                reverseButtons: true,
                customClass: {
                    popup: 'rounded-2xl',
                    confirmButton: 'rounded-xl font-bold text-xs px-6 py-3',
                    cancelButton: 'rounded-xl font-bold text-xs px-6 py-3'
                }
            }).then((result) => {
                if (result.isConfirmed) {
                    document.getElementById('delete-form-' + id).submit();
                }
            });
        }

        <?php if(session('success')): ?>
            Swal.fire({
                icon: 'success',
                title: 'Berhasil!',
                text: "<?php echo e(session('success')); ?>",
                showConfirmButton: false,
                timer: 2000,
                customClass: { popup: 'rounded-2xl' }
            });
        <?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:\laragon\www\LokaPustaka\resources\views/cart/index.blade.php ENDPATH**/ ?>