<?php
use Livewire\Component;
use App\Services\CartManager;
?>

<div 
    x-data="{ show: <?php if ((object) ('isOpen') instanceof \Livewire\WireDirective) : ?>window.Livewire.find('<?php echo e($__livewire->getId()); ?>').entangle('<?php echo e('isOpen'->value()); ?>')<?php echo e('isOpen'->hasModifier('live') ? '.live' : ''); ?><?php else : ?>window.Livewire.find('<?php echo e($__livewire->getId()); ?>').entangle('<?php echo e('isOpen'); ?>')<?php endif; ?> }"
    x-show="show"
    @keydown.escape.window="show = false"
    class="fixed inset-0 overflow-hidden z-50"
    style="display: none;"
>
    <!-- Dark transparent backdrop -->
    <div 
        x-show="show"
        x-transition:enter="ease-in-out duration-300"
        x-transition:enter-start="opacity-0"
        x-transition:enter-end="opacity-100"
        x-transition:leave="ease-in-out duration-300"
        x-transition:leave-start="opacity-100"
        x-transition:leave-end="opacity-0"
        @click="show = false"
        class="absolute inset-0 bg-gray-950/60 backdrop-blur-xs transition-opacity"
    ></div>

    <!-- Sliding Sidebar container -->
    <div class="fixed inset-y-0 right-0 max-w-full flex">
        <div 
            x-show="show"
            x-transition:enter="transform transition ease-in-out duration-300 sm:duration-400"
            x-transition:enter-start="translate-x-full"
            x-transition:enter-end="translate-x-0"
            x-transition:leave="transform transition ease-in-out duration-300 sm:duration-400"
            x-transition:leave-start="translate-x-0"
            x-transition:leave-end="translate-x-full"
            class="w-screen max-w-md bg-white dark:bg-gray-900 shadow-2xl flex flex-col"
        >
            <!-- Header panel -->
            <div class="px-6 py-6 border-b border-gray-100 dark:border-gray-800 flex items-center justify-between">
                <div class="flex items-center space-x-2">
                    <h2 class="text-lg font-bold text-gray-900 dark:text-white">Shopping Cart</h2>
                    <span class="bg-indigo-100 text-indigo-800 dark:bg-indigo-900 dark:text-indigo-250 text-xs font-semibold px-2 py-0.5 rounded-full">
                        <?php echo e(count($items)); ?> items
                    </span>
                </div>
                <button 
                    @click="show = false" 
                    class="p-2 text-gray-400 hover:text-gray-650 dark:hover:text-white rounded-lg hover:bg-gray-55/50 transition-colors"
                >
                    <svg class="h-6 w-6" fill="none" viewBox="0 0 24 24" stroke="currentColor">
                        <path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M6 18L18 6M6 6l12 12" />
                    </svg>
                </button>
            </div>

            <!-- Items List -->
            <div class="flex-grow overflow-y-auto px-6 py-4 space-y-4">
                <?php if(\Livewire\Mechanisms\ExtendBlade\ExtendBlade::isRenderingLivewireComponent()): ?><!--[if BLOCK]><![endif]--><?php endif; ?><?php if(count($items) > 0): ?>
                    <?php if(\Livewire\Mechanisms\ExtendBlade\ExtendBlade::isRenderingLivewireComponent()): ?><!--[if BLOCK]><![endif]--><?php \Livewire\Features\SupportCompiledWireKeys\SupportCompiledWireKeys::openLoop(); ?><?php endif; ?><?php $__currentLoopData = $items; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $item): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?><?php if(\Livewire\Mechanisms\ExtendBlade\ExtendBlade::isRenderingLivewireComponent()): ?><?php \Livewire\Features\SupportCompiledWireKeys\SupportCompiledWireKeys::startLoopIteration(); ?><?php endif; ?>
                        <div class="flex items-start space-x-4 pb-4 border-b border-gray-50 dark:border-gray-800/80">
                            <!-- Image -->
                            <div class="w-20 h-20 bg-gray-50 dark:bg-gray-850 rounded-xl overflow-hidden flex-shrink-0 border border-gray-100 dark:border-gray-800">
                                <img src="<?php echo e($item['image']); ?>" alt="<?php echo e($item['name']); ?>" class="w-full h-full object-cover">
                            </div>

                            <!-- Details -->
                            <div class="flex-grow">
                                <h3 class="text-sm font-bold text-gray-900 dark:text-white line-clamp-1 hover:text-indigo-650">
                                    <a href="/products/<?php echo e($item['product_id']); ?>"><?php echo e($item['name']); ?></a>
                                </h3>
                                
                                <?php if(\Livewire\Mechanisms\ExtendBlade\ExtendBlade::isRenderingLivewireComponent()): ?><!--[if BLOCK]><![endif]--><?php endif; ?><?php if(!empty($item['options'])): ?>
                                    <p class="text-xs text-gray-500 mt-0.5">
                                        <?php if(\Livewire\Mechanisms\ExtendBlade\ExtendBlade::isRenderingLivewireComponent()): ?><!--[if BLOCK]><![endif]--><?php \Livewire\Features\SupportCompiledWireKeys\SupportCompiledWireKeys::openLoop(); ?><?php endif; ?><?php $__currentLoopData = $item['options']; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $key => $val): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?><?php if(\Livewire\Mechanisms\ExtendBlade\ExtendBlade::isRenderingLivewireComponent()): ?><?php \Livewire\Features\SupportCompiledWireKeys\SupportCompiledWireKeys::startLoopIteration(); ?><?php endif; ?>
                                            <?php echo e($key); ?>: <?php echo e($val); ?><?php echo e(!$loop->last ? ' | ' : ''); ?>

                                        <?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; ?>
                                    </p>
                                <?php endif; ?><?php if(\Livewire\Mechanisms\ExtendBlade\ExtendBlade::isRenderingLivewireComponent()): ?><!--[if ENDBLOCK]><![endif]--><?php endif; ?>
                                
                                <p class="text-sm font-extrabold text-indigo-600 dark:text-indigo-400 mt-1">
                                    ৳<?php echo e(number_format($item['price'], 2)); ?>

                                </p>

                                <!-- Quantity adjuster & delete -->
                                <div class="flex items-center justify-between mt-2">
                                    <div class="flex items-center border border-gray-200 dark:border-gray-700 rounded-lg overflow-hidden bg-gray-50 dark:bg-gray-800">
                                        <button 
                                            wire:click="decrementQty(<?php echo e($item['id']); ?>)"
                                            class="px-2 py-1 text-gray-500 hover:bg-gray-100 dark:hover:bg-gray-700 text-xs font-bold"
                                        >-</button>
                                        <span class="px-3 py-1 text-xs font-semibold text-gray-900 dark:text-white">
                                            <?php echo e($item['quantity']); ?>

                                        </span>
                                        <button 
                                            wire:click="incrementQty(<?php echo e($item['id']); ?>)"
                                            class="px-2 py-1 text-gray-500 hover:bg-gray-100 dark:hover:bg-gray-700 text-xs font-bold"
                                        >+</button>
                                    </div>

                                    <button 
                                        wire:click="removeItem(<?php echo e($item['id']); ?>)"
                                        class="text-xs text-red-500 hover:underline font-semibold"
                                    >
                                        Remove
                                    </button>
                                </div>
                            </div>
                        </div>
                    <?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; ?>
                <?php else: ?>
                    <div class="h-full flex flex-col items-center justify-center text-center space-y-3 py-16 text-gray-500">
                        <svg class="h-16 w-16 text-gray-200" fill="none" viewBox="0 0 24 24" stroke="currentColor">
                            <path stroke-linecap="round" stroke-linejoin="round" stroke-width="1.5" d="M16 11V7a4 4 0 00-8 0v4M5 9h14l1 12H4L5 9z" />
                        </svg>
                        <p class="text-sm font-semibold">Your cart is currently empty.</p>
                        <p class="text-xs">Browse our shop to add items here!</p>
                        <a 
                            href="/shop" 
                            @click="show = false" 
                            class="inline-flex items-center px-4 py-2 border border-transparent text-xs font-semibold rounded-lg shadow-sm text-white bg-indigo-600 hover:bg-indigo-650 transition-colors"
                        >
                            Shop Now
                        </a>
                    </div>
                <?php endif; ?><?php if(\Livewire\Mechanisms\ExtendBlade\ExtendBlade::isRenderingLivewireComponent()): ?><!--[if ENDBLOCK]><![endif]--><?php endif; ?>
            </div>

            <!-- Footer summary panel -->
            <?php if(\Livewire\Mechanisms\ExtendBlade\ExtendBlade::isRenderingLivewireComponent()): ?><!--[if BLOCK]><![endif]--><?php endif; ?><?php if(count($items) > 0): ?>
                <div class="px-6 py-6 border-t border-gray-100 dark:border-gray-800 bg-gray-50 dark:bg-gray-900/50 space-y-4">
                    <div class="flex items-center justify-between">
                        <span class="text-sm font-bold text-gray-500">Subtotal</span>
                        <span class="text-lg font-extrabold text-gray-955 dark:text-white">
                            ৳<?php echo e(number_format($subtotal, 2)); ?>

                        </span>
                    </div>
                    <p class="text-xs text-gray-400">Shipping fees and taxes are calculated at checkout.</p>
                    
                    <div class="grid grid-cols-1 gap-2">
                        <a 
                            href="/checkout"
                            class="w-full flex items-center justify-center px-6 py-3 border border-transparent text-sm font-bold rounded-xl shadow-md text-white bg-gradient-to-r from-indigo-600 to-violet-600 hover:from-indigo-650 hover:to-violet-650 transition-all text-center"
                        >
                            Proceed to Checkout
                        </a>
                        <button 
                            @click="show = false"
                            class="w-full flex items-center justify-center px-6 py-2.5 border border-gray-200 dark:border-gray-700 text-xs font-semibold rounded-xl text-gray-700 dark:text-gray-300 bg-white dark:bg-gray-800 hover:bg-gray-50 dark:hover:bg-gray-750 transition-colors"
                        >
                            Continue Shopping
                        </button>
                    </div>
                </div>
            <?php endif; ?><?php if(\Livewire\Mechanisms\ExtendBlade\ExtendBlade::isRenderingLivewireComponent()): ?><!--[if ENDBLOCK]><![endif]--><?php endif; ?>
        </div>
    </div>
</div><?php /**PATH storage/framework/views-testing/livewire/views/d29bde1e.blade.php ENDPATH**/ ?>