<div> 
    <div style="overflow-x:auto; -webkit-overflow-scrolling:touch;">
        <table class="dark-table" id="mainTable">
            <thead>
                <tr>
                    <th style="width:50px;">#</th>
                    <th>Nama Pendaki</th>
                    <th>No. WhatsApp</th>
                    <th>Asal</th>
                    <th>Waktu Naik</th>
                    <th>Status / Turun</th>
                    <th>Guide / PJ</th>
                    <th style="text-align:center;">Aksi</th>
                </tr>
            </thead>
            <tbody>
                <?php if(\Livewire\Mechanisms\ExtendBlade\ExtendBlade::isRenderingLivewireComponent()): ?><!--[if BLOCK]><![endif]--><?php \Livewire\Features\SupportCompiledWireKeys\SupportCompiledWireKeys::openLoop(); ?><?php endif; ?><?php $__empty_1 = true; $__currentLoopData = $climbings; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $climbing): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); $__empty_1 = false; ?><?php if(\Livewire\Mechanisms\ExtendBlade\ExtendBlade::isRenderingLivewireComponent()): ?><?php \Livewire\Features\SupportCompiledWireKeys\SupportCompiledWireKeys::startLoopIteration(); ?><?php endif; ?>
                    <?php
                        // Menghitung durasi mendaki
                        $jamMendaki = \Carbon\Carbon::parse($climbing->created_at)->diffInHours(now());
                        // Status Terlambat jika lebih dari 25 jam dan belum checkout
                        $isOverdue = !$climbing->check_out_date && $jamMendaki > 25;
                        $isFinished = !empty($climbing->check_out_date);
                        
                        // LOGIKA PENENTU TOMBOL:
                        // Kita cek route saat ini, jika mengandung kata 'ticket-counter', paksa muncul tombol SELESAI
                        $isLoketRoute = str_contains(request()->url(), 'ticket-counter');
                    ?>
                    
                    
                    <tr <?php \Livewire\Features\SupportCompiledWireKeys\SupportCompiledWireKeys::$currentLoop['key'] = 'climbing-row-'.e($climbing->id).''; ?>wire:key="climbing-row-<?php echo e($climbing->id); ?>" 
                        onclick="Livewire.dispatch('load-climbing', { id: <?php echo e($climbing->id); ?> })"
                        style="cursor: pointer;">
                        
                        <td><?php echo e(str_pad($loop->iteration, 2, '0', STR_PAD_LEFT)); ?></td>
                        
                        <td>
                            <div class="d-flex align-items-center gap-2">
                                <?php if(\Livewire\Mechanisms\ExtendBlade\ExtendBlade::isRenderingLivewireComponent()): ?><!--[if BLOCK]><![endif]--><?php endif; ?><?php if($isOverdue): ?>
                                    <div class="status-box status-overdue">⚠️</div>
                                <?php elseif($isFinished): ?>
                                    <div class="status-box status-dn">DN</div>
                                <?php else: ?>
                                    <div class="status-box status-cl">CL</div>
                                <?php endif; ?><?php if(\Livewire\Mechanisms\ExtendBlade\ExtendBlade::isRenderingLivewireComponent()): ?><!--[if ENDBLOCK]><![endif]--><?php endif; ?>
                                <span class="fw-bold"><?php echo e($climbing->name); ?></span>
                            </div>
                        </td>

                        
                        <td onclick="event.stopPropagation()">
                            <?php if(\Livewire\Mechanisms\ExtendBlade\ExtendBlade::isRenderingLivewireComponent()): ?><!--[if BLOCK]><![endif]--><?php endif; ?><?php if($climbing->phone_number): ?>
                                <a href="https://wa.me/<?php echo e(preg_replace('/[^0-9]/', '', $climbing->phone_number)); ?>" 
                                   target="_blank" 
                                   class="text-decoration-none" 
                                   style="color:var(--accent-teal); font-size:12px; font-weight:600;">
                                    <i class="bi bi-whatsapp me-1" style="color: #25D366;"></i>
                                    <?php echo e($climbing->phone_number); ?>

                                </a>
                            <?php else: ?>
                                <span class="text-muted small">—</span>
                            <?php endif; ?><?php if(\Livewire\Mechanisms\ExtendBlade\ExtendBlade::isRenderingLivewireComponent()): ?><!--[if ENDBLOCK]><![endif]--><?php endif; ?>
                        </td>

                        <td><div style="font-size:12px;"><?php echo e($climbing->residence); ?></div></td>

                        <td>
                            <div class="time-main"><?php echo e(\Carbon\Carbon::parse($climbing->created_at)->timezone('Asia/Makassar')->format('d M Y')); ?></div>
                            <span class="time-sub"><?php echo e(\Carbon\Carbon::parse($climbing->created_at)->timezone('Asia/Makassar')->format('H:i')); ?> WITA</span>
                        </td>

                        <td>
                            <?php if(\Livewire\Mechanisms\ExtendBlade\ExtendBlade::isRenderingLivewireComponent()): ?><!--[if BLOCK]><![endif]--><?php endif; ?><?php if($isFinished): ?>
                                <div class="time-main text-success"><?php echo e(\Carbon\Carbon::parse($climbing->check_out_date)->timezone('Asia/Makassar')->format('d M Y')); ?></div>
                                <span class="time-sub"><?php echo e(\Carbon\Carbon::parse($climbing->check_out_date)->timezone('Asia/Makassar')->format('H:i')); ?> WITA</span>
                            <?php elseif($isOverdue): ?>
                                <span class="status-overdue-blink">⚠️ TERLAMBAT!</span>
                            <?php else: ?>
                                <span style="color:var(--accent-amber); font-weight:700;"><i class="bi bi-geo-alt-fill"></i> Di Gunung</span>
                            <?php endif; ?><?php if(\Livewire\Mechanisms\ExtendBlade\ExtendBlade::isRenderingLivewireComponent()): ?><!--[if ENDBLOCK]><![endif]--><?php endif; ?>
                        </td>

                        <td>
                            <?php if(\Livewire\Mechanisms\ExtendBlade\ExtendBlade::isRenderingLivewireComponent()): ?><!--[if BLOCK]><![endif]--><?php endif; ?><?php if($climbing->group_id && $climbing->group && $climbing->group->guide): ?>
                                
                                <span class="text-info fw-bold" style="cursor:pointer;" 
                                      onclick="event.stopPropagation(); Livewire.dispatch('load-guide', { id: <?php echo e($climbing->group->guide->id); ?> })">
                                    🪖 <?php echo e($climbing->group->guide->name); ?>

                                </span>
                            <?php elseif($climbing->guide_id && $climbing->guide): ?>
                                
                                <span class="text-info fw-bold" style="cursor:pointer;" 
                                      onclick="event.stopPropagation(); Livewire.dispatch('load-guide', { id: <?php echo e($climbing->guide->id); ?> })">
                                    🪖 <?php echo e($climbing->guide->name); ?>

                                </span>
                            <?php else: ?>
                                <span class="text-muted small italic">Mandiri</span>
                            <?php endif; ?><?php if(\Livewire\Mechanisms\ExtendBlade\ExtendBlade::isRenderingLivewireComponent()): ?><!--[if ENDBLOCK]><![endif]--><?php endif; ?>
                        </td>

                        <td style="text-align:center;" onclick="event.stopPropagation()">
                            <?php if(\Livewire\Mechanisms\ExtendBlade\ExtendBlade::isRenderingLivewireComponent()): ?><!--[if BLOCK]><![endif]--><?php endif; ?><?php if($isLoketRoute): ?>
                                
                                <?php if(\Livewire\Mechanisms\ExtendBlade\ExtendBlade::isRenderingLivewireComponent()): ?><!--[if BLOCK]><![endif]--><?php endif; ?><?php if(!$isFinished): ?>
                                    <form action="<?php echo e(route('climbing.finish', $climbing->id)); ?>" method="POST" onsubmit="return confirm('Konfirmasi pendaki ini sudah turun?')">
                                        <?php echo csrf_field(); ?> <?php echo method_field('PATCH'); ?>
                                        <button type="submit" class="btn-finish-modern">
                                            <i class="bi bi-check2-circle me-1"></i> Selesaikan
                                        </button>
                                    </form>
                                <?php else: ?>
                                    <div class="status-done-chip">
                                        <i class="bi bi-check-all"></i> Selesai
                                    </div>
                                <?php endif; ?><?php if(\Livewire\Mechanisms\ExtendBlade\ExtendBlade::isRenderingLivewireComponent()): ?><!--[if ENDBLOCK]><![endif]--><?php endif; ?>
                            <?php else: ?>
                                
                                <form action="<?php echo e(route('admin.climbing.destroy', $climbing->id)); ?>" method="POST" onsubmit="return confirm('Hapus data pendaki ini?')">
                                    <?php echo csrf_field(); ?> <?php echo method_field('DELETE'); ?>
                                    <button type="submit" class="btn btn-sm" style="background: rgba(248,81,73,0.1); color: var(--accent-red); border: 1px solid rgba(248,81,73,0.2); border-radius: 8px; padding: 4px 10px; font-weight: 700; font-size: 11px;">
                                        <i class="bi bi-trash3-fill"></i> HAPUS
                                    </button>
                                </form>
                            <?php endif; ?><?php if(\Livewire\Mechanisms\ExtendBlade\ExtendBlade::isRenderingLivewireComponent()): ?><!--[if ENDBLOCK]><![endif]--><?php endif; ?>
                        </td>
                    </tr>
                <?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; ?>
                    <tr>
                        <td colspan="8" class="text-center py-5 text-muted">Belum ada aktivitas pendakian hari ini.</td>
                    </tr>
                <?php endif; ?><?php if(\Livewire\Mechanisms\ExtendBlade\ExtendBlade::isRenderingLivewireComponent()): ?><!--[if ENDBLOCK]><![endif]--><?php endif; ?>
            </tbody>
        </table>
    </div>
</div><?php /**PATH C:\laragon\www\Pendaki_App-main\resources\views/livewire/climbing-table.blade.php ENDPATH**/ ?>