

<?php $__env->startSection('styles'); ?>
<link rel="stylesheet" href="<?php echo e(asset('css/penyuluh.css')); ?>">
<?php $__env->stopSection(); ?>

<?php $__env->startSection('content'); ?>

<div class="page-wrapper">

    <div class="page-header">
        <div>
            <h2 class="page-title">🎯 Prioritas Penanganan</h2>
            <p class="page-sub">Diurutkan berdasarkan nilai TOPSIS tertinggi</p>
        </div>
        <div class="header-badge gold-badge">
            <?php echo e($laporan->count()); ?> Kasus Aktif
        </div>
    </div>

    
    <?php if($laporan->count() >= 1): ?>
    <div class="podium-row">
        <?php $__currentLoopData = $laporan->take(3); $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $top): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
        <div class="podium-card rank-<?php echo e($top->ranking); ?>">
            <div class="podium-rank">
                <?php if($top->ranking == 1): ?> 🥇
                <?php elseif($top->ranking == 2): ?> 🥈
                <?php else: ?> 🥉
                <?php endif; ?>
                #<?php echo e($top->ranking); ?>

            </div>
            <div class="podium-name"><?php echo e($top->nama_petani); ?></div>
            <div class="podium-hama"><?php echo e($top->jenis_hama); ?></div>
            <div class="podium-val"><?php echo e(number_format($top->nilai_preferensi, 4)); ?></div>
            <div class="podium-label">Nilai TOPSIS</div>
        </div>
        <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
    </div>
    <?php endif; ?>

    
    <div class="table-card">
        <div class="table-topbar">
            <span class="table-label">📊 Semua Laporan</span>
            <input type="text" id="searchRanking" placeholder="🔍 Cari..." oninput="filterRanking()">
        </div>

        <div class="table-scroll">
            <table class="data-table" id="rankTable">
                <thead>
                    <tr>
                        <th>Rank</th>
                        <th>Petani</th>
                        <th>Hama</th>
                        <th>Tingkat</th>
                        <th>Nilai</th>
                        <th>Status</th>
                        <th>Aksi</th>
                    </tr>
                </thead>
                <tbody>
                    <?php $__empty_1 = true; $__currentLoopData = $laporan; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $item): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); $__empty_1 = false; ?>
                    <tr class="data-row
                        <?php if($item->ranking == 1): ?> row-gold
                        <?php elseif($item->ranking == 2): ?> row-silver
                        <?php elseif($item->ranking == 3): ?> row-bronze
                        <?php endif; ?>">

                        <td>
                            <span class="rank-badge
                                <?php if($item->ranking == 1): ?> rank-gold
                                <?php elseif($item->ranking == 2): ?> rank-silver
                                <?php elseif($item->ranking == 3): ?> rank-bronze
                                <?php else: ?> rank-normal
                                <?php endif; ?>">
                                #<?php echo e($item->ranking); ?>

                            </span>
                        </td>

                        <td>
                            <div class="petani-name"><?php echo e($item->nama_petani); ?></div>
                        </td>

                        <td><span class="hama-tag"><?php echo e($item->jenis_hama); ?></span></td>

                        <td>
                            <span class="tingkat-badge
                                <?php if($item->tingkat_serangan=='Berat'): ?> t-berat
                                <?php elseif($item->tingkat_serangan=='Sedang'): ?> t-sedang
                                <?php else: ?> t-ringan
                                <?php endif; ?>">
                                <?php echo e($item->tingkat_serangan ?? '-'); ?>

                            </span>
                        </td>

                        <td class="nilai-cell">
                            <?php echo e(number_format($item->nilai_preferensi ?? 0, 4)); ?>

                        </td>

                        <td>
                            <span class="status-badge
                                <?php if($item->status=='menunggu'): ?> s-info
                                <?php elseif($item->status=='diproses'): ?> s-process
                                <?php elseif($item->status=='selesai'): ?> s-success
                                <?php else: ?> s-waiting
                                <?php endif; ?>">
                                <?php echo e($item->status); ?>

                            </span>
                        </td>

                        <td>
                            <div class="action-group">
                                <?php if($item->status == 'menunggu'): ?>
                                <form action="<?php echo e(url('/lapor/'.$item->id.'/proses')); ?>" method="POST" style="display:inline">
                                    <?php echo csrf_field(); ?>
                                    <button class="btn-sm btn-proses">▶ Proses</button>
                                </form>
                                <?php endif; ?>
                                <?php if($item->status == 'diproses'): ?>
                                <form action="<?php echo e(url('/lapor/'.$item->id.'/selesai')); ?>" method="POST" style="display:inline">
                                    <?php echo csrf_field(); ?>
                                    <button class="btn-sm btn-selesai">✔ Selesai</button>
                                </form>
                                <?php endif; ?>
                                <?php if($item->status != 'menunggu_validasi'): ?>
                                <a href="<?php echo e(url('/penyuluh/analisis/'.$item->id)); ?>" class="btn-sm btn-analisis">
                                    📊 Analisis
                                </a>
                                <?php endif; ?>
                            </div>
                        </td>
                    </tr>
                    <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); if ($__empty_1): ?>
                    <tr>
                        <td colspan="7" class="empty-cell">
                            <div class="empty-state"><span>📭</span><p>Belum ada data ranking</p></div>
                        </td>
                    </tr>
                    <?php endif; ?>
                </tbody>
            </table>
        </div>
    </div>

</div>

<?php $__env->stopSection(); ?>

<?php $__env->startSection('scripts'); ?>
<script>
function filterRanking(){
    const q = document.getElementById('searchRanking').value.toLowerCase();
    document.querySelectorAll('#rankTable tbody .data-row').forEach(row => {
        row.style.display = row.innerText.toLowerCase().includes(q) ? '' : 'none';
    });
}
</script>
<?php $__env->stopSection(); ?>
<?php echo $__env->make('layouts.app', array_diff_key(get_defined_vars(), ['__data' => 1, '__path' => 1]))->render(); ?><?php /**PATH C:\Users\Maylha\pelaporanpertanian\resources\views/penyuluh/ranking.blade.php ENDPATH**/ ?>