<?php $__env->startSection('title', 'Data Survei - Admin SKM'); ?>

<?php $__env->startSection('content'); ?>
<div class="container-fluid">
    <div class="row mb-4">
        <div class="col-12">
            <div class="d-flex justify-content-between align-items-center">
                <div>
                    <h2 style="color: #1e3a8a; font-weight: 700;">
                        <i class="bi bi-clipboard-data me-2"></i> Data Survei
                    </h2>
                    <p class="text-muted">Data hasil survei kepuasan masyarakat</p>
                </div>
                <a href="<?php echo e(route('admin.survei.laporan')); ?>" class="btn btn-gov-primary">
                    <i class="bi bi-bar-chart-line me-2"></i> Lihat Laporan
                </a>
            </div>
        </div>
    </div>

    <div class="row mb-4">
        <div class="col-md-4 mb-3">
            <div class="card border-0 shadow-sm" style="border-left: 4px solid #1e3a8a !important;">
                <div class="card-body">
                    <div class="d-flex justify-content-between align-items-center">
                        <div>
                            <h6 class="text-muted mb-2" style="font-size: 0.85rem; text-transform: uppercase; letter-spacing: 0.5px;">
                                Total Responden
                            </h6>
                            <h3 class="mb-0" style="color: #1e3a8a; font-weight: 700;"><?php echo e($totalResponden); ?></h3>
                        </div>
                        <div class="bg-primary bg-opacity-10 rounded p-3">
                            <i class="bi bi-people text-primary" style="font-size: 2.5rem;"></i>
                        </div>
                    </div>
                </div>
            </div>
        </div>
        <div class="col-md-4 mb-3">
            <div class="card border-0 shadow-sm" style="border-left: 4px solid #28a745 !important;">
                <div class="card-body">
                    <div class="d-flex justify-content-between align-items-center">
                        <div>
                            <h6 class="text-muted mb-2" style="font-size: 0.85rem; text-transform: uppercase; letter-spacing: 0.5px;">
                                Hari Ini
                            </h6>
                            <h3 class="mb-0" style="color: #28a745; font-weight: 700;"><?php echo e($totalHariIni); ?></h3>
                        </div>
                        <div class="bg-success bg-opacity-10 rounded p-3">
                            <i class="bi bi-calendar-check text-success" style="font-size: 2.5rem;"></i>
                        </div>
                    </div>
                </div>
            </div>
        </div>
        <div class="col-md-4 mb-3">
            <div class="card border-0 shadow-sm" style="border-left: 4px solid #17a2b8 !important;">
                <div class="card-body">
                    <div class="d-flex justify-content-between align-items-center">
                        <div>
                            <h6 class="text-muted mb-2" style="font-size: 0.85rem; text-transform: uppercase; letter-spacing: 0.5px;">
                                Bulan Ini
                            </h6>
                            <h3 class="mb-0" style="color: #17a2b8; font-weight: 700;"><?php echo e($totalBulanIni); ?></h3>
                        </div>
                        <div class="bg-info bg-opacity-10 rounded p-3">
                            <i class="bi bi-calendar3 text-info" style="font-size: 2.5rem;"></i>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>

    <!-- Penilaian Keseluruhan -->
    <div class="card card-gov shadow-sm mb-4">
        <div class="card-header">
            <h5 class="mb-0">
                <i class="bi bi-star-fill me-2"></i> Penilaian Keseluruhan Data
            </h5>
        </div>
        <div class="card-body">
            <div class="row">
                <div class="col-md-4 mb-3">
                    <div class="text-center p-3 bg-light rounded">
                        <h6 class="text-muted mb-2">IKM Keseluruhan</h6>
                        <h2 class="mb-0" style="color: #1e3a8a; font-weight: 700;">
                            <?php echo e(number_format($ikmKeseluruhan, 2)); ?>

                        </h2>
                        <small class="text-muted">dari 44</small>
                    </div>
                </div>
                <div class="col-md-4 mb-3">
                    <div class="text-center p-3 bg-light rounded">
                        <h6 class="text-muted mb-2">Kategori</h6>
                        <?php
                            if ($ikmKeseluruhan >= 38.83) {
                                $badgeClass = 'success';
                            } elseif ($ikmKeseluruhan >= 33) {
                                $badgeClass = 'info';
                            } elseif ($ikmKeseluruhan >= 28.60) {
                                $badgeClass = 'warning';
                            } else {
                                $badgeClass = 'danger';
                            }
                        ?>
                        <h3 class="mb-0">
                            <span class="badge bg-<?php echo e($badgeClass); ?> fs-5"><?php echo e($kategoriKeseluruhan); ?></span>
                        </h3>
                    </div>
                </div>
                <div class="col-md-4 mb-3">
                    <div class="text-center p-3 bg-light rounded">
                        <h6 class="text-muted mb-2">Persentase</h6>
                        <h2 class="mb-0" style="color: #28a745; font-weight: 700;">
                            <?php echo e(number_format(($ikmKeseluruhan / 44) * 100, 1)); ?>%
                        </h2>
                    </div>
                </div>
            </div>

            <div class="mt-3">
                <h6 class="mb-3">Rata-rata Per Unsur</h6>
                <div class="row">
                    <?php
                        $unsurLabels = [
                            1 => 'Persyaratan',
                            2 => 'Sistem, Mekanisme, dan Prosedur',
                            3 => 'Waktu Penyelesaian',
                            4 => 'Biaya / Tarif',
                            5 => 'Produk Spesifikasi Jenis Pelayanan',
                            6 => 'Kompetensi Pelaksana',
                            7 => 'Perilaku Pelaksana',
                            8 => 'Penanganan Pengaduan, Saran dan Masukan',
                            9 => 'Sarana dan Prasarana',
                            10 => 'Unsur 10',
                            11 => 'Unsur 11'
                        ];
                    ?>
                    <?php $__currentLoopData = $rataRataPerUnsur; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $unsurId => $rataRata): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                        <div class="col-md-6 col-lg-4 mb-2">
                            <div class="d-flex justify-content-between align-items-center p-2 bg-light rounded">
                                <small class="text-muted"><?php echo e($unsurLabels[$unsurId]); ?></small>
                                <span class="badge bg-primary"><?php echo e(number_format($rataRata, 2)); ?></span>
                            </div>
                        </div>
                    <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
                </div>
            </div>
        </div>
    </div>

    <div class="card card-gov shadow-sm">
        <div class="card-header">
            <h5 class="mb-0">
                <i class="bi bi-list-ul me-2"></i> Daftar Responden
            </h5>
        </div>
        <div class="card-body">
            <form method="GET" action="<?php echo e(route('admin.survei.index')); ?>" class="mb-3">
                <div class="row g-3">
                    <div class="col-md-3">
                        <input type="text" name="nama" class="form-control" placeholder="Cari nama..." value="<?php echo e(request('nama')); ?>">
                    </div>
                    <div class="col-md-3">
                        <input type="date" name="tanggal_dari" class="form-control" placeholder="Dari tanggal" value="<?php echo e(request('tanggal_dari')); ?>">
                    </div>
                    <div class="col-md-3">
                        <input type="date" name="tanggal_sampai" class="form-control" placeholder="Sampai tanggal" value="<?php echo e(request('tanggal_sampai')); ?>">
                    </div>
                    <div class="col-md-3">
                        <button type="submit" class="btn btn-gov-primary w-100">
                            <i class="bi bi-search me-1"></i> Filter
                        </button>
                    </div>
                </div>
            </form>

            <div class="table-responsive">
                <table class="table table-hover align-middle">
                    <thead class="table-light">
                        <tr>
                            <th style="width: 50px;">No</th>
                            <th>Nama Pelapor</th>
                            <th>No. HP</th>
                            <th>Email</th>
                            <th>Tanggal Survei</th>
                            <th style="width: 200px;" class="text-center">Aksi</th>
                        </tr>
                    </thead>
                    <tbody>
                        <?php $__empty_1 = true; $__currentLoopData = $responden; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $index => $item): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); $__empty_1 = false; ?>
                            <tr>
                                <td class="fw-semibold"><?php echo e($responden->firstItem() + $index); ?></td>
                                <td>
                                    <div class="d-flex align-items-center">
                                        <i class="bi bi-person-fill text-primary me-2"></i>
                                        <strong><?php echo e($item->nama_pelapor); ?></strong>
                                    </div>
                                </td>
                                <td><?php echo e($item->no_hp); ?></td>
                                <td><?php echo e($item->email ?? '-'); ?></td>
                                <td><?php echo e(\Carbon\Carbon::parse($item->tanggal_survei)->format('d/m/Y')); ?></td>
                                <td>
                                    <div class="btn-group" role="group">
                                        <a href="<?php echo e(route('admin.survei.show', $item->id)); ?>" class="btn btn-sm btn-gov-primary">
                                            <i class="bi bi-eye me-1"></i> Detail
                                        </a>
                                        <form action="<?php echo e(route('admin.survei.destroy', $item->id)); ?>" method="POST" class="d-inline" onsubmit="return confirm('Yakin ingin menghapus data ini?')">
                                            <?php echo csrf_field(); ?>
                                            <?php echo method_field('DELETE'); ?>
                                            <button type="submit" class="btn btn-sm btn-danger">
                                                <i class="bi bi-trash me-1"></i> Hapus
                                            </button>
                                        </form>
                                    </div>
                                </td>
                            </tr>
                        <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); if ($__empty_1): ?>
                            <tr>
                                <td colspan="6" class="text-center py-4">
                                    <i class="bi bi-inbox text-muted" style="font-size: 3rem;"></i>
                                    <p class="text-muted mt-2 mb-0">Belum ada data responden</p>
                                </td>
                            </tr>
                        <?php endif; ?>
                    </tbody>
                </table>
            </div>

            <div class="d-flex justify-content-center mt-3">
                <?php echo e($responden->links()); ?>

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

<?php if(session('success')): ?>
    <script>
        alert('<?php echo e(session('success')); ?>');
    </script>
<?php endif; ?>
<?php $__env->stopSection(); ?>
<?php echo $__env->make('layouts.app', \Illuminate\Support\Arr::except(get_defined_vars(), ['__data', '__path']))->render(); ?><?php /**PATH /Users/user/Documents/giriwidyan/project/inhouse/skm/resources/views/admin/survei/index.blade.php ENDPATH**/ ?>