<div wire:poll.15s class="space-y-6" x-init="lucide.createIcons()" x-effect="lucide.createIcons()">
    <div class="bg-white rounded-2xl shadow-sm border border-slate-200 overflow-hidden lg:sticky lg:top-24">
        <div class="p-4 sm:p-6 border-b border-slate-100 flex items-center justify-between">
            <div class="flex items-center gap-2.5 sm:gap-3">
                <div class="w-9 h-9 sm:w-10 sm:h-10 rounded-xl bg-purple-50 flex items-center justify-center text-purple-600 shrink-0">
                    <svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="w-4 h-4 sm:w-5 sm:h-5"><path d="M21 16V8a2 2 0 0 0-1-1.73l-7-4a2 2 0 0 0-2 0l-7 4A2 2 0 0 0 3 8v8a2 2 0 0 0 1 1.73l7 4a2 2 0 0 0 2 0l7-4A2 2 0 0 0 21 16z"></path><polyline points="3.27 6.96 12 12.01 20.73 6.96"></polyline><line x1="12" y1="22.08" x2="12" y2="12"></line></svg>
                </div>
                <h2 class="text-base sm:text-lg font-bold text-slate-900 leading-tight">Pesanan Aktif</h2>
            </div>
            <?php if(\Livewire\Mechanisms\ExtendBlade\ExtendBlade::isRenderingLivewireComponent()): ?><!--[if BLOCK]><![endif]--><?php endif; ?><?php if($pesananAktif->count() > 0): ?>
                <span class="w-5 h-5 sm:w-6 sm:h-6 bg-purple-600 text-white text-[11px] sm:text-xs font-black rounded-full flex items-center justify-center"><?php echo e($pesananAktif->count()); ?></span>
            <?php endif; ?><?php if(\Livewire\Mechanisms\ExtendBlade\ExtendBlade::isRenderingLivewireComponent()): ?><!--[if ENDBLOCK]><![endif]--><?php endif; ?>
        </div>
        
        <div class="p-0">
            <?php if(\Livewire\Mechanisms\ExtendBlade\ExtendBlade::isRenderingLivewireComponent()): ?><!--[if BLOCK]><![endif]--><?php endif; ?><?php if($pesananAktif->count() > 0): ?>
                <div class="divide-y divide-slate-100">
                    <?php if(\Livewire\Mechanisms\ExtendBlade\ExtendBlade::isRenderingLivewireComponent()): ?><!--[if BLOCK]><![endif]--><?php \Livewire\Features\SupportCompiledWireKeys\SupportCompiledWireKeys::openLoop(); ?><?php endif; ?><?php $__currentLoopData = $pesananAktif; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $pesanan): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?><?php if(\Livewire\Mechanisms\ExtendBlade\ExtendBlade::isRenderingLivewireComponent()): ?><?php \Livewire\Features\SupportCompiledWireKeys\SupportCompiledWireKeys::startLoopIteration(); ?><?php endif; ?>
                        <div class="p-3.5 sm:p-4 hover:bg-slate-50 transition-colors">
                            <!-- Header baris -->
                            <div class="flex justify-between items-start mb-2.5 sm:mb-3 gap-2">
                                <div>
                                    <p class="font-bold text-xs sm:text-sm text-slate-900 leading-snug"><?php echo e($pesanan->produk->nama_produk ?? 'Gas LPG'); ?></p>
                                    <p class="text-[10px] sm:text-xs text-slate-500 mt-0.5"><?php echo e(\Carbon\Carbon::parse($pesanan->created_at)->diffForHumans()); ?></p>
                                </div>
                                <?php
                                    $statusCfg = [
                                        'menunggu' => ['bg-yellow-100 text-yellow-700', 'Menunggu Admin'],
                                        'diproses' => ['bg-blue-100 text-blue-700', 'Diproses'],
                                        'dikirim'  => ['bg-indigo-100 text-indigo-700', 'Dikirim'],
                                    ];
                                    $cfg = $statusCfg[$pesanan->status] ?? ['bg-slate-100 text-slate-600', $pesanan->status];
                                ?>
                                <span class="px-2 py-0.5 sm:px-2.5 sm:py-1 <?php echo e($cfg[0]); ?> rounded-full text-[10px] sm:text-[11px] font-bold whitespace-nowrap shrink-0"><?php echo e($cfg[1]); ?></span>
                            </div>

                            <!-- Progress Tracker -->
                            <?php
                                $stepMap = ['menunggu' => 0, 'diproses' => 1, 'dikirim' => 2];
                                $stepIdx  = $stepMap[$pesanan->status] ?? 0;
                            ?>
                            <div class="flex items-center gap-1 mb-3">
                                <?php if(\Livewire\Mechanisms\ExtendBlade\ExtendBlade::isRenderingLivewireComponent()): ?><!--[if BLOCK]><![endif]--><?php \Livewire\Features\SupportCompiledWireKeys\SupportCompiledWireKeys::openLoop(); ?><?php endif; ?><?php $__currentLoopData = ['Menunggu', 'Diproses', 'Dikirim']; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $sIdx => $sLabel): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?><?php if(\Livewire\Mechanisms\ExtendBlade\ExtendBlade::isRenderingLivewireComponent()): ?><?php \Livewire\Features\SupportCompiledWireKeys\SupportCompiledWireKeys::startLoopIteration(); ?><?php endif; ?>
                                    <div class="flex-1 flex flex-col items-center gap-1">
                                        <div class="w-full h-1.5 rounded-full <?php echo e($sIdx <= $stepIdx ? 'bg-blue-500' : 'bg-slate-200'); ?> transition-all duration-500"></div>
                                        <span class="text-[9px] sm:text-[10px] font-bold <?php echo e($sIdx <= $stepIdx ? 'text-blue-600' : 'text-slate-400'); ?>"><?php echo e($sLabel); ?></span>
                                    </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; ?>
                            </div>

                            <!-- Info kurir jika sudah dikirim -->
                            <?php if(\Livewire\Mechanisms\ExtendBlade\ExtendBlade::isRenderingLivewireComponent()): ?><!--[if BLOCK]><![endif]--><?php endif; ?><?php if($pesanan->status === 'dikirim' && $pesanan->kurir): ?>
                                <div class="bg-indigo-50 border border-indigo-100 rounded-xl p-2.5 mb-2 flex items-center gap-2">
                                    <div class="w-7 h-7 bg-indigo-100 rounded-lg flex items-center justify-center shrink-0">
                                        <svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="w-4 h-4 text-indigo-600"><path d="M16 21v-2a4 4 0 0 0-4-4H6a4 4 0 0 0-4 4v2"></path><circle cx="9" cy="7" r="4"></circle><polyline points="16 11 18 13 22 9"></polyline></svg>
                                    </div>
                                    <div class="min-w-0 flex-1">
                                        <p class="text-[10px] text-indigo-500 font-semibold leading-tight">Kurir Pengirim</p>
                                        <p class="text-xs font-bold text-indigo-800 truncate"><?php echo e($pesanan->kurir->name); ?></p>
                                    </div>
                                </div>
                            <?php endif; ?><?php if(\Livewire\Mechanisms\ExtendBlade\ExtendBlade::isRenderingLivewireComponent()): ?><!--[if ENDBLOCK]><![endif]--><?php endif; ?>

                            <!-- Detail -->
                            <div class="flex justify-between items-center text-xs sm:text-sm pt-1">
                                <span class="text-slate-600 text-xs"><?php echo e($pesanan->qty_beli_isi); ?> Tabung · <?php echo e($pesanan->metode_bayar); ?></span>
                                <span class="font-bold text-slate-900 text-xs sm:text-sm">Rp <?php echo e(number_format($pesanan->total_harga, 0, ',', '.')); ?></span>
                            </div>

                            <?php if(\Livewire\Mechanisms\ExtendBlade\ExtendBlade::isRenderingLivewireComponent()): ?><!--[if BLOCK]><![endif]--><?php endif; ?><?php if($pesanan->status === 'menunggu'): ?>
                                <div class="mt-3 pt-2.5 border-t border-slate-100 flex justify-end">
                                    <button 
                                        @click="
                                            Swal.fire({
                                                title: 'Batalkan Pesanan?',
                                                text: 'Apakah Anda yakin ingin membatalkan pesanan ini?',
                                                icon: 'warning',
                                                showCancelButton: true,
                                                confirmButtonColor: '#ef4444',
                                                cancelButtonColor: '#64748b',
                                                confirmButtonText: 'Ya, Batalkan!',
                                                cancelButtonText: 'Batal',
                                                reverseButtons: true
                                            }).then((result) => {
                                                if (result.isConfirmed) {
                                                    $wire.cancelOrder('<?php echo e($pesanan->id); ?>');
                                                }
                                            })
                                        " 
                                        class="w-full sm:w-auto justify-center px-3 py-1.5 bg-red-50 text-red-600 hover:bg-red-100 text-xs font-bold rounded-lg transition-all flex items-center gap-1 shadow-sm border border-red-100"
                                    >
                                        <svg xmlns="http://www.w3.org/2000/svg" width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.5" stroke-linecap="round" stroke-linejoin="round" class="w-3.5 h-3.5"><line x1="18" y1="6" x2="6" y2="18"></line><line x1="6" y1="6" x2="18" y2="18"></line></svg>
                                        <span>Batalkan Pesanan</span>
                                    </button>
                                </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(); ?><?php if(\Livewire\Mechanisms\ExtendBlade\ExtendBlade::isRenderingLivewireComponent()): ?><!--[if ENDBLOCK]><![endif]--><?php \Livewire\Features\SupportCompiledWireKeys\SupportCompiledWireKeys::closeLoop(); ?><?php endif; ?>
                </div>
            <?php else: ?>
                <div class="p-6 sm:p-8 text-center flex flex-col items-center">
                    <div class="w-12 h-12 sm:w-16 sm:h-16 bg-slate-50 rounded-full flex items-center justify-center text-slate-400 mb-2.5 sm:mb-3">
                        <svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="w-6 h-6 sm:w-8 sm:h-8"><polyline points="22 12 16 12 14 15 10 15 8 12 2 12"></polyline><path d="M5.45 5.11L2 12v6a2 2 0 0 0 2 2h16a2 2 0 0 0 2-2v-6l-3.45-6.89A2 2 0 0 0 16.76 4H7.24a2 2 0 0 0 -1.79 1.11z"></path></svg>
                    </div>
                    <p class="text-xs sm:text-sm font-medium text-slate-700">Belum ada pesanan aktif</p>
                    <p class="text-[11px] sm:text-xs text-slate-500 mt-1">Pesanan yang sedang diproses akan muncul di sini</p>
                </div>
            <?php endif; ?><?php if(\Livewire\Mechanisms\ExtendBlade\ExtendBlade::isRenderingLivewireComponent()): ?><!--[if ENDBLOCK]><![endif]--><?php endif; ?>
        </div>
        <?php if(\Livewire\Mechanisms\ExtendBlade\ExtendBlade::isRenderingLivewireComponent()): ?><!--[if BLOCK]><![endif]--><?php endif; ?><?php if($pesananAktif->count() > 0): ?>
            <div class="p-3.5 sm:p-4 border-t border-slate-100 bg-slate-50 text-center">
                 <a href="<?php echo e(route('user.pesanan')); ?>" class="text-xs sm:text-sm font-semibold text-blue-600 hover:text-blue-800">Lihat Semua Pesanan &rarr;</a>
            </div>
        <?php endif; ?><?php if(\Livewire\Mechanisms\ExtendBlade\ExtendBlade::isRenderingLivewireComponent()): ?><!--[if ENDBLOCK]><![endif]--><?php endif; ?>
    </div>
</div>

    <?php
        $__scriptKey = '2842850209-0';
        ob_start();
    ?>
<script>
    $wire.on('swal-success', (event) => {
        Swal.fire({
            icon: 'success',
            title: event[0].title,
            text: event[0].text,
            timer: 1500,
            showConfirmButton: false
        });
    });

    $wire.on('swal-error', (event) => {
        Swal.fire({
            icon: 'error',
            title: event[0].title,
            text: event[0].text
        });
    });
</script>
    <?php
        $__output = ob_get_clean();

        \Livewire\store($this)->push('scripts', $__output, $__scriptKey)
    ?>

<?php /**PATH C:\laragon\www\LPG\resources\views/livewire/user/active-orders.blade.php ENDPATH**/ ?>