

<?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="breadcrumb">
        <a href="/lapor/<?php echo e($lapor->id); ?>">← Detail Laporan</a>
        <span>›</span>
        <span>Analisis TOPSIS</span>
    </div>

    <div class="page-header">
        <div>
            <h2 class="page-title">📊 Analisis AHP–TOPSIS</h2>
            <p class="page-sub"><?php echo e($lapor->nama_petani); ?> · <?php echo e($lapor->jenis_hama); ?></p>
        </div>
        <div class="result-pill">
            Ranking <strong>#<?php echo e($lapor->ranking); ?></strong>
        </div>
    </div>

    
    <div class="analisis-top-grid">

        
        <div class="info-card">
            <div class="info-card-title">📌 Data Laporan</div>
            <div class="info-rows">
                <div class="ir"><span>Petani</span><strong><?php echo e($lapor->nama_petani); ?></strong></div>
                <div class="ir"><span>Jenis Hama</span><strong><?php echo e($lapor->jenis_hama); ?></strong></div>
                <div class="ir">
                    <span>Tingkat Serangan</span>
                    <strong>
                        <span class="tingkat-badge
                            <?php if($lapor->tingkat_serangan=='Berat'): ?> t-berat
                            <?php elseif($lapor->tingkat_serangan=='Sedang'): ?> t-sedang
                            <?php else: ?> t-ringan <?php endif; ?>">
                            <?php echo e($lapor->tingkat_serangan); ?>

                        </span>
                    </strong>
                </div>
                <div class="ir"><span>Luas Lahan</span><strong><?php echo e($lapor->luas_lahan); ?> Ha</strong></div>
                <div class="ir"><span>Lama Kejadian</span><strong><?php echo e($lapor->lama_kejadian); ?> hari</strong></div>
            </div>
        </div>

        
        <div class="info-card">
            <div class="info-card-title">⚖️ Bobot Kriteria AHP</div>
            <?php
                $kriteriaLabel = ['Tingkat Serangan','Luas Lahan','Lama Kejadian','Jenis Hama'];
                $bobotMax = max($bobot);
            ?>
            <div class="bobot-list">
                <?php $__currentLoopData = $bobot; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $i => $b): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                <div class="bobot-row">
                    <span class="bobot-label"><?php echo e($kriteriaLabel[$i] ?? 'C'.($i+1)); ?></span>
                    <div class="bobot-bar-wrap">
                        <div class="bobot-bar" style="width:<?php echo e(round(($b/$bobotMax)*100)); ?>%"></div>
                    </div>
                    <span class="bobot-val"><?php echo e(number_format($b*100,1)); ?>%</span>
                </div>
                <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
            </div>
        </div>

        
        <div class="result-card">
            <div class="info-card-title">🏆 Hasil Akhir</div>
            <div class="result-big">
                <div class="result-num"><?php echo e(number_format($lapor->nilai_preferensi,4)); ?></div>
                <div class="result-lbl">Nilai Preferensi TOPSIS</div>
            </div>
            <div class="result-rank">
                Ranking <span>#<?php echo e($lapor->ranking); ?></span>
                dari <?php echo e(count($matrix)); ?> laporan
            </div>
            <div class="result-note">
                Semakin mendekati 1, semakin prioritas penanganan.
            </div>
        </div>

    </div>

    
    <div class="table-card">
        <div class="table-topbar">
            <span class="table-label">📊 Perbandingan Semua Laporan</span>
        </div>
        <div class="table-scroll">
            <table class="data-table">
                <thead>
                    <tr>
                        <th>Rank</th>
                        <th>Petani</th>
                        <th>Serangan</th>
                        <th>Luas (Ha)</th>
                        <th>Lama (hr)</th>
                        <th>Hama</th>
                        <th>Preferensi</th>
                    </tr>
                </thead>
                <tbody>
                    <?php $__currentLoopData = $matrix; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $row): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                    <tr class="data-row <?php echo e($row['id'] == $lapor->id ? 'row-highlight' : ''); ?>">
                        <td>
                            <span class="rank-badge
                                <?php if($row['ranking']==1): ?> rank-gold
                                <?php elseif($row['ranking']==2): ?> rank-silver
                                <?php elseif($row['ranking']==3): ?> rank-bronze
                                <?php else: ?> rank-normal <?php endif; ?>">
                                #<?php echo e($row['ranking']); ?>

                            </span>
                        </td>
                        <td>
                            <div class="petani-name <?php echo e($row['id']==$lapor->id ? 'highlight-name' : ''); ?>">
                                <?php echo e($row['petani']); ?>

                                <?php if($row['id']==$lapor->id): ?>
                                    <span class="current-tag">◀ Ini</span>
                                <?php endif; ?>
                            </div>
                        </td>
                        <td>
                            <span class="tingkat-badge
                                <?php if($row['c1']=='Berat'): ?> t-berat
                                <?php elseif($row['c1']=='Sedang'): ?> t-sedang
                                <?php else: ?> t-ringan <?php endif; ?>">
                                <?php echo e($row['c1']); ?>

                            </span>
                        </td>
                        <td class="num-cell"><?php echo e($row['c2']); ?></td>
                        <td class="num-cell"><?php echo e($row['c3']); ?></td>
                        <td><span class="hama-tag"><?php echo e($row['c4']); ?></span></td>
                        <td class="nilai-cell <?php echo e($row['id']==$lapor->id ? 'highlight-val' : ''); ?>">
                            <?php echo e(number_format($row['preferensi'],4)); ?>

                        </td>
                    </tr>
                    <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
                </tbody>
            </table>
        </div>
    </div>

</div>

<?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/analisis.blade.php ENDPATH**/ ?>