

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

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

<div class="wrapper">

    
    <div class="page-header">
        <div class="page-header-left">
            <h2>Dashboard Petani</h2>
            <p>Selamat datang, <strong><?php echo e(auth()->user()->name); ?></strong> — pantau laporan hama Anda di sini</p>
        </div>
        <a href="/lapor/create" class="btn-lapor">
            <span class="btn-lapor-icon">＋</span>
            Input Laporan
        </a>
    </div>

    
    <div class="cards">

        <div class="card total">
            <div class="card-icon">📋</div>
            <div class="card-body">
                <h3><?php echo e($total); ?></h3>
                <p>Total Laporan</p>
            </div>
            <div class="card-bar"></div>
        </div>

        <div class="card menunggu">
            <div class="card-icon">⏳</div>
            <div class="card-body">
                <h3><?php echo e($laporan->where('status','menunggu_validasi')->count()); ?></h3>
                <p>Menunggu Validasi</p>
            </div>
            <div class="card-bar"></div>
        </div>

        <div class="card proses">
            <div class="card-icon">⚙️</div>
            <div class="card-body">
                <h3><?php echo e($diproses); ?></h3>
                <p>Sedang Diproses</p>
            </div>
            <div class="card-bar"></div>
        </div>

        <div class="card selesai">
            <div class="card-icon">✅</div>
            <div class="card-body">
                <h3><?php echo e($selesai); ?></h3>
                <p>Selesai</p>
            </div>
            <div class="card-bar"></div>
        </div>

    </div>

    
    <div class="table-section">

        <div class="table-header">
            <div class="table-title">📄 Riwayat Laporan</div>
            <div class="table-search">
                <input type="text" id="searchInput" placeholder="Cari hama atau status..." oninput="filterTable()">
            </div>
        </div>

        <div class="table-wrapper">
            <table class="table" id="laporanTable">

                <thead>
                    <tr>
                        <th>No</th>
                        <th>Jenis Hama</th>
                        <th>Tingkat</th>
                        <th>Status</th>
                        <th>Tanggal</th>
                        <th>Aksi</th>
                    </tr>
                </thead>

                <tbody>

                <?php $__empty_1 = true; $__currentLoopData = $laporan; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $i => $item): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); $__empty_1 = false; ?>
                <tr class="table-row">

                    <td class="td-no"><?php echo e($i + 1); ?></td>

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

                    <td>
                        <?php if(isset($item->tingkat_serangan)): ?>
                        <span class="badge-tingkat <?php echo e(strtolower($item->tingkat_serangan)); ?>">
                            <?php echo e($item->tingkat_serangan); ?>

                        </span>
                        <?php else: ?>
                        <span class="badge-tingkat">—</span>
                        <?php endif; ?>
                    </td>

                    <td>
                        <span class="badge badge-<?php echo e($item->status); ?>">
                            <?php echo e(str_replace('_',' ', $item->status)); ?>

                        </span>
                    </td>

                    <td class="td-date">
                        <span class="date-day"><?php echo e($item->created_at->format('d')); ?></span>
                        <span class="date-month"><?php echo e($item->created_at->format('M Y')); ?></span>
                    </td>

                    <td>
                        <div class="action-btns">

                            <a href="/lapor/<?php echo e($item->id); ?>" class="btn-action detail" title="Lihat Detail">
                                🔍 Detail
                            </a>

                            <?php if($item->status == 'menunggu_validasi'): ?>
                            <a href="/lapor/<?php echo e($item->id); ?>/edit" class="btn-action edit" title="Edit Laporan">
                                ✏ Edit
                            </a>
                            <?php endif; ?>

                        </div>
                    </td>

                </tr>
                <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); if ($__empty_1): ?>
                <tr>
                    <td colspan="6" class="empty-state">
                        <div class="empty-icon">🌾</div>
                        <div>Belum ada laporan yang dibuat</div>
                        <a href="/lapor/create" class="empty-link">Buat laporan pertama Anda →</a>
                    </td>
                </tr>
                <?php endif; ?>

                </tbody>

            </table>
        </div>

        
        <?php if(method_exists($laporan, 'links')): ?>
        <div class="pagination-wrapper">
            <?php echo e($laporan->links()); ?>

        </div>
        <?php endif; ?>

    </div>

</div>

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

<?php $__env->startSection('scripts'); ?>
<script>
function filterTable(){
    const q     = document.getElementById('searchInput').value.toLowerCase();
    const rows  = document.querySelectorAll('#laporanTable tbody .table-row');

    rows.forEach(row => {
        const text = row.innerText.toLowerCase();
        row.style.display = text.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/petani/dashboard.blade.php ENDPATH**/ ?>