    
    <?php $__env->startSection('title', 'Detail Pesanan #' . $order->order_number); ?>

    <?php $__env->startSection('content'); ?>
    <div class="max-w-3xl mx-auto p-6 md:p-10" style="font-family: 'Plus Jakarta Sans', sans-serif;">
        <div class="bg-white rounded-[40px] shadow-2xl border border-pink-50 overflow-hidden">

            
            <div class="p-8 <?php echo e(in_array($order->status, ['pending', 'cancelled']) ? 'bg-rose-950' : ($order->status == 'completed' ? 'bg-emerald-950' : ($order->status == 'shipping' ? 'bg-pink-900' : 'bg-slate-900'))); ?> text-white flex justify-between items-center transition-colors">
                <div>
                    <p class="text-[10px] font-black text-pink-400 uppercase tracking-widest">Order Detail</p>
                    <h2 class="text-2xl font-black italic">#<?php echo e($order->order_number); ?></h2>
                </div>
                <div class="text-right">
                    <p class="text-[10px] font-bold text-slate-400 uppercase mb-1 italic">Status</p>
                    <?php
                        $statusConfig = match($order->status) {
                            'pending'    => ['label' => 'BELUM BAYAR',       'class' => 'text-rose-400 border-rose-400/30'],
                            'paid'       => ['label' => 'SUDAH DIBAYAR',     'class' => 'text-green-400 border-green-400/30'],
                            'packaging'  => ['label' => 'DIKEMAS',           'class' => 'text-blue-400 border-blue-400/30'],
                            'picking_up' => ['label' => 'KURIR MENUJU TOKO', 'class' => 'text-amber-400 border-amber-400/30'],
                            'shipping'   => ['label' => 'DALAM PERJALANAN',  'class' => 'text-pink-400 border-pink-400/30'],
                            'completed'  => ['label' => 'SELESAI',           'class' => 'text-emerald-400 border-emerald-400/30'],
                            'cancelled'  => ['label' => 'DIBATALKAN',        'class' => 'text-slate-400 border-slate-400/30'],
                            default      => ['label' => strtoupper($order->status), 'class' => 'text-white border-white/30']
                        };
                    ?>
                    <span class="px-4 py-1 <?php echo e($statusConfig['class']); ?> rounded-full text-xs font-black uppercase italic border bg-white/5">
                        <?php echo e($statusConfig['label']); ?>

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

            <div class="p-8 space-y-8">

                
                <?php if($order->status == 'completed' && $order->proof_image): ?>
                <div class="p-6 bg-emerald-50 rounded-[30px] border border-emerald-100">
                    <p class="text-[10px] font-black text-emerald-600 uppercase mb-4 flex items-center gap-2">
                        <i data-lucide="camera" class="w-3 h-3"></i> Bukti Pengiriman Selesai
                    </p>
                    <div class="flex flex-col md:flex-row gap-6 items-start">
                        <div class="w-full md:w-40 h-40 bg-white p-2 rounded-[24px] shadow-sm border border-emerald-100 overflow-hidden">
                            <img src="<?php echo e(asset('storage/' . $order->proof_image)); ?>"
                                class="w-full h-full object-cover rounded-[18px] cursor-zoom-in hover:scale-110 transition-transform duration-500"
                                onclick="window.open(this.src)">
                        </div>
                        <div class="flex-1">
                            <div class="mb-3">
                                <p class="text-[9px] font-black text-slate-400 uppercase tracking-widest">Diterima Oleh</p>
                                <p class="text-sm font-black text-slate-800 italic uppercase"><?php echo e($order->actual_receiver ?? $order->receiver_name ?? 'Pembeli'); ?></p>
                            </div>
                            <div class="mb-3">
                                <p class="text-[9px] font-black text-slate-400 uppercase tracking-widest">Kurir</p>
                                <p class="text-sm font-bold text-slate-700"><?php echo e($order->courier->name ?? '-'); ?></p>
                            </div>
                            <div class="mb-4">
                                <p class="text-[9px] font-black text-slate-400 uppercase tracking-widest">Waktu Sampai</p>
                                <p class="text-xs font-bold text-slate-600">
                                    <?php echo e($order->delivered_at ? \Carbon\Carbon::parse($order->delivered_at)->format('d M Y, H:i') : $order->updated_at->format('d M Y, H:i')); ?> WIB
                                </p>
                            </div>
                            <div class="inline-flex items-center gap-2 text-emerald-600 bg-white px-4 py-2 rounded-full border border-emerald-100 shadow-sm">
                                <i data-lucide="check-circle" class="w-3 h-3"></i>
                                <span class="text-[9px] font-black uppercase tracking-tighter italic">Paket Telah Diterima</span>
                            </div>
                        </div>
                    </div>
                </div>
                <?php endif; ?>

                
                <?php if(Auth::user()->role === 'user' && $order->status === 'completed'): ?>
                    <?php
                        $reviewedCount = \App\Models\Review::where('order_id', $order->id)
                            ->where('user_id', Auth::id())
                            ->count();
                        $allReviewed = $reviewedCount >= $order->items->count();
                    ?>

                    <?php if(!$allReviewed): ?>
                    <div class="p-6 bg-amber-50 rounded-[30px] border border-amber-100">
                        <div class="flex items-center gap-4 mb-4">
                            <div class="w-12 h-12 bg-amber-100 rounded-2xl flex items-center justify-center text-2xl">⭐</div>
                            <div>
                                <p class="text-sm font-black text-slate-800">Gimana pesanannya?</p>
                                <p class="text-[10px] text-slate-400 font-bold">Bantu pembeli lain dengan kasih review produknya!</p>
                            </div>
                        </div>
                        <a href="<?php echo e(route('user.reviews.create', $order->id)); ?>"
                        class="block w-full text-center py-4 bg-amber-400 hover:bg-amber-500 text-white rounded-2xl font-black text-xs uppercase tracking-widest transition-all shadow-lg shadow-amber-100">
                            Kasih Rating Sekarang ⭐
                        </a>
                    </div>
                    <?php else: ?>
                    <div class="p-4 bg-emerald-50 rounded-[24px] border border-emerald-100 flex items-center gap-3">
                        <span class="text-2xl">✅</span>
                        <p class="text-sm font-black text-emerald-600">Kamu sudah kasih review untuk semua produk di pesanan ini!</p>
                    </div>
                    <?php endif; ?>
                <?php endif; ?>

                
                <div class="p-6 bg-slate-50 rounded-[30px] border border-slate-100">
                    <p class="text-[10px] font-black text-slate-400 uppercase mb-4 tracking-widest">Tracking Pesanan</p>
                    <?php
                        $steps = [
                            ['status' => ['paid', 'packaging', 'picking_up', 'shipping', 'completed'], 'label' => 'Pembayaran Diterima', 'icon' => 'circle-check-big'],
                            ['status' => ['packaging', 'picking_up', 'shipping', 'completed'],          'label' => 'Pesanan Dikemas',     'icon' => 'package'],
                            ['status' => ['picking_up', 'shipping', 'completed'],                       'label' => 'Kurir Menuju Toko',  'icon' => 'store'],
                            ['status' => ['shipping', 'completed'],                                     'label' => 'Dalam Perjalanan',   'icon' => 'truck'],
                            ['status' => ['completed'],                                                 'label' => 'Pesanan Diterima',   'icon' => 'check-circle'],
                        ];
                    ?>
                    <div class="space-y-3">
                        <?php $__currentLoopData = $steps; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $step): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                        <?php $active = in_array($order->status, $step['status']); ?>
                        <div class="flex items-center gap-3">
                            <div class="w-8 h-8 rounded-full flex items-center justify-center <?php echo e($active ? 'bg-emerald-500 text-white' : 'bg-slate-200 text-slate-400'); ?> transition-all">
                                <i data-lucide="<?php echo e($step['icon']); ?>" class="w-4 h-4"></i>
                            </div>
                            <span class="text-xs font-bold <?php echo e($active ? 'text-slate-800' : 'text-slate-400'); ?>"><?php echo e($step['label']); ?></span>
                        </div>
                        <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
                    </div>
                </div>

                
                <div class="p-6 bg-slate-50 rounded-[30px] border border-slate-100">
                    <p class="text-[10px] font-black text-slate-400 uppercase mb-3 flex items-center gap-2">
                        <i data-lucide="map-pin" class="w-3 h-3 text-pink-500"></i> Alamat Tujuan
                    </p>
                    <p class="text-sm font-bold text-slate-700 leading-relaxed"><?php echo e($order->full_address); ?></p>
                    <p class="text-xs text-slate-400 font-bold mt-2 italic"><?php echo e($order->phone); ?></p>
                </div>

                
                <div class="space-y-4">
                    <p class="text-[10px] font-black text-slate-400 uppercase px-2 tracking-widest">Daftar Produk</p>
                    <?php $__currentLoopData = $order->items; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $item): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                    <div class="flex items-center gap-4 p-4 rounded-3xl bg-white border border-slate-100 shadow-sm group">
                        <img src="<?php echo e(asset('storage/' . $item->product->image)); ?>" class="w-16 h-16 rounded-2xl object-cover shadow-sm group-hover:scale-110 transition-transform">
                        <div class="flex-1">
                            <h4 class="font-black text-slate-800"><?php echo e($item->product->name); ?></h4>
                            <p class="text-[10px] text-slate-400 font-bold uppercase italic"><?php echo e($item->quantity); ?>x @ Rp <?php echo e(number_format($item->price, 0, ',', '.')); ?></p>
                        </div>
                        <p class="font-black text-slate-900 italic">Rp <?php echo e(number_format($item->price * $item->quantity, 0, ',', '.')); ?></p>
                    </div>
                    <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
                </div>

                <hr class="border-dashed border-slate-200">

                
                <div class="grid grid-cols-2 gap-4 text-sm bg-slate-50 p-6 rounded-[30px] border border-slate-100">
                    <div>
                        <p class="text-[10px] font-black text-slate-400 uppercase mb-1">Metode Bayar</p>
                        <p class="font-bold text-slate-700 italic flex items-center gap-2 uppercase">
                            <?php echo e($order->payment_method); ?>

                            <?php if(!in_array($order->status, ['pending', 'cancelled'])): ?>
                                <i data-lucide="check-circle-2" class="w-4 h-4 text-emerald-500"></i>
                            <?php endif; ?>
                        </p>
                    </div>
                    <div class="text-right">
                        <p class="text-[10px] font-black text-slate-400 uppercase mb-1 italic">Total Tagihan</p>
                        <p class="text-2xl font-black text-rose-500 italic">Rp <?php echo e(number_format($order->total_price, 0, ',', '.')); ?></p>
                    </div>
                </div>

                
                <div class="space-y-4">

                    
                    <?php if(Auth::user()->role === 'courier'): ?>
                        <?php if($order->status === 'packaging'): ?>
                            <form action="<?php echo e(route('courier.orders.pickup', $order)); ?>" method="POST">
                                <?php echo csrf_field(); ?>
                                <button type="submit" class="w-full py-4 bg-amber-500 text-white rounded-2xl font-black text-xs uppercase tracking-widest hover:bg-amber-600 transition-all shadow-xl">
                                    Ambil Pesanan ke Toko 🏪
                                </button>
                            </form>
                        <?php elseif($order->status === 'picking_up' && $order->courier_id == Auth::id()): ?>
                            <form action="<?php echo e(route('courier.orders.start', $order)); ?>" method="POST">
                                <?php echo csrf_field(); ?>
                                <button type="submit" class="w-full py-4 bg-slate-900 text-white rounded-2xl font-black text-xs uppercase tracking-widest hover:bg-pink-600 transition-all shadow-xl">
                                    Sudah Ambil, Mulai Antar 🚚
                                </button>
                            </form>
                        <?php elseif($order->status === 'shipping' && $order->courier_id == Auth::id()): ?>
                            <button onclick="document.getElementById('modalSelesai').classList.remove('hidden')"
                                    class="w-full py-4 bg-emerald-500 text-white rounded-2xl font-black text-xs uppercase tracking-widest hover:bg-emerald-600 transition-all shadow-xl shadow-emerald-500/20">
                                Selesaikan Pengiriman (Upload Bukti) ✅
                            </button>
                        <?php endif; ?>
                    <?php endif; ?>

                    
                    <div class="flex gap-4">
                        <a href="<?php echo e(route('user.orders.index')); ?>" class="flex-1 text-center py-4 bg-slate-100 text-slate-600 rounded-2xl font-black text-[10px] uppercase tracking-widest hover:bg-slate-200 transition-all">
                            Kembali
                        </a>
                        <?php if(Auth::user()->role == 'user' && $order->status == 'pending' && $order->payment_method == 'midtrans'): ?>
                        <button onclick="payOrder('<?php echo e($order->snap_token); ?>')" class="flex-1 text-center py-4 bg-rose-500 text-white rounded-2xl font-black text-[10px] uppercase tracking-widest hover:bg-rose-600 transition-all shadow-lg shadow-rose-500/20">
                            Bayar Sekarang
                        </button>
                        <?php endif; ?>
                    </div>
                </div>

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

    
    <?php if(Auth::user()->role === 'courier'): ?>
    <div id="modalSelesai" class="fixed inset-0 bg-slate-900/80 backdrop-blur-sm z-[99] hidden flex items-center justify-center p-4">
        <div class="bg-white rounded-[40px] w-full max-w-md overflow-hidden shadow-2xl">
            <div class="p-8 bg-slate-900 text-white flex justify-between items-center">
                <h3 class="font-black italic uppercase tracking-widest text-sm">Konfirmasi Selesai</h3>
                <button onclick="document.getElementById('modalSelesai').classList.add('hidden')" class="text-slate-400 hover:text-white">
                    <i data-lucide="x" class="w-5 h-5"></i>
                </button>
            </div>
            <form action="<?php echo e(route('courier.orders.complete', $order)); ?>" method="POST" enctype="multipart/form-data" class="p-8 space-y-6">
                <?php echo csrf_field(); ?>
                <div>
                    <label class="text-[10px] font-black text-slate-400 uppercase tracking-widest mb-2 block italic">Nama Penerima</label>
                    <input type="text" name="receiver_name" required placeholder="Contoh: Budi (Satpam)"
                        class="w-full px-5 py-4 bg-slate-50 border-2 border-slate-100 rounded-2xl focus:border-pink-500 outline-none font-bold text-sm transition-all">
                </div>
                <div>
                    <label class="text-[10px] font-black text-slate-400 uppercase tracking-widest mb-2 block italic">Foto Bukti (JPG/PNG)</label>
                    <input type="file" name="proof_image" required accept="image/*"
                        class="w-full text-xs font-bold text-slate-500 file:mr-4 file:py-2 file:px-4 file:rounded-full file:border-0 file:text-[10px] file:font-black file:bg-pink-50 file:text-pink-600 hover:file:bg-pink-100">
                </div>
                <button type="submit" class="w-full py-4 bg-emerald-500 text-white rounded-2xl font-black text-xs uppercase tracking-widest hover:bg-emerald-600 transition-all">
                    Kirim Bukti & Selesaikan
                </button>
            </form>
        </div>
    </div>
    <?php endif; ?>

    <script type="text/javascript" src="https://app.sandbox.midtrans.com/snap/snap.js" data-client-key="<?php echo e(env('MIDTRANS_CLIENT_KEY')); ?>"></script>
    <script>
        lucide.createIcons();
        function payOrder(token) {
            window.snap.pay(token, {
                onSuccess: function(result) { window.location.reload(); },
                onPending: function(result) { window.location.reload(); },
                onClose: function() { alert('Selesaikan pembayaranmu agar barang segera diproses! ✨'); }
            });
        }
    </script>
    <?php $__env->stopSection(); ?>
<?php echo $__env->make('layouts.app', array_diff_key(get_defined_vars(), ['__data' => 1, '__path' => 1]))->render(); ?><?php /**PATH C:\laragon\www\SwiftCart\resources\views/orders/show.blade.php ENDPATH**/ ?>