<!DOCTYPE html>
<html lang="id">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <title>Laporan Aduan SILAPOR Wonosalam - <?php echo e($now); ?></title>
    <style>
        @import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&display=swap');

        * { box-sizing: border-box; margin: 0; padding: 0; }

        body {
            font-family: 'Inter', Arial, sans-serif;
            font-size: 12px;
            color: #1a1a1a;
            background: #fff;
            padding: 24px;
        }

        /* ── Header Laporan ── */
        .report-header {
            display: flex;
            align-items: center;
            gap: 20px;
            border-bottom: 3px solid #3730a3;
            padding-bottom: 16px;
            margin-bottom: 20px;
        }
        .report-header img { width: 64px; height: 64px; object-fit: contain; }
        .report-header-text h1 {
            font-size: 18px;
            font-weight: 700;
            color: #1e1b4b;
            letter-spacing: -0.3px;
        }
        .report-header-text p {
            font-size: 12px;
            color: #4b5563;
            margin-top: 2px;
        }

        /* ── Meta Info ── */
        .meta-grid {
            display: grid;
            grid-template-columns: repeat(4, 1fr);
            gap: 12px;
            margin-bottom: 20px;
        }
        .meta-card {
            background: #f5f3ff;
            border: 1px solid #c4b5fd;
            border-radius: 8px;
            padding: 12px;
            text-align: center;
        }
        .meta-card .meta-label {
            font-size: 10px;
            font-weight: 600;
            text-transform: uppercase;
            letter-spacing: 0.5px;
            color: #6d28d9;
            margin-bottom: 4px;
        }
        .meta-card .meta-val {
            font-size: 20px;
            font-weight: 700;
            color: #3730a3;
        }
        .meta-card .meta-sub {
            font-size: 10px;
            color: #7c3aed;
            margin-top: 2px;
        }

        /* ── Table ── */
        .data-table {
            width: 100%;
            border-collapse: collapse;
            font-size: 11px;
        }
        .data-table thead tr {
            background: #3730a3;
            color: #fff;
        }
        .data-table thead th {
            padding: 10px 8px;
            text-align: left;
            font-weight: 600;
            font-size: 10px;
            text-transform: uppercase;
            letter-spacing: 0.4px;
            white-space: nowrap;
        }
        .data-table tbody tr { border-bottom: 1px solid #e5e7eb; }
        .data-table tbody tr:nth-child(even) { background: #faf5ff; }
        .data-table tbody tr:hover { background: #ede9fe; }
        .data-table td {
            padding: 9px 8px;
            vertical-align: top;
            color: #374151;
        }
        .data-table .col-no { width: 30px; text-align: center; font-weight: 700; color: #6d28d9; }
        .data-table .col-tgl { width: 90px; white-space: nowrap; }
        .data-table .col-nama { width: 110px; }
        .data-table .col-nik { width: 110px; font-family: monospace; font-size: 10.5px; }
        .data-table .col-desa { width: 90px; }
        .data-table .col-isi { max-width: 200px; }
        .data-table .col-kategori { width: 120px; }
        .data-table .col-skor { width: 55px; text-align: center; }
        .data-table .col-prioritas { width: 65px; text-align: center; }
        .data-table .col-status { width: 70px; text-align: center; }
        .data-table .col-tanggapan { max-width: 140px; }

        /* Badges */
        .badge {
            display: inline-block;
            font-size: 9px;
            font-weight: 700;
            text-transform: uppercase;
            letter-spacing: 0.4px;
            padding: 2px 7px;
            border-radius: 50px;
        }
        .badge-penting  { background: #fee2e2; color: #b91c1c; }
        .badge-biasa    { background: #f3f4f6; color: #6b7280; }
        .badge-menunggu { background: #fef3c7; color: #b45309; }
        .badge-diproses { background: #dbeafe; color: #1d4ed8; }
        .badge-selesai  { background: #d1fae5; color: #047857; }

        .isi-text {
            display: -webkit-box;
            -webkit-line-clamp: 3;
            -webkit-box-orient: vertical;
            overflow: hidden;
            line-height: 1.5;
            color: #4b5563;
        }

        .nama-bold { font-weight: 700; color: #111827; }

        /* Footer */
        .report-footer {
            margin-top: 24px;
            padding-top: 12px;
            border-top: 1px solid #e5e7eb;
            display: flex;
            justify-content: space-between;
            align-items: flex-end;
            font-size: 10px;
            color: #9ca3af;
        }
        .signature-box {
            text-align: center;
            font-size: 11px;
            color: #374151;
        }
        .signature-box .sig-title { font-weight: 700; margin-bottom: 60px; }
        .signature-box .sig-line { border-top: 1px solid #374151; padding-top: 4px; min-width: 160px; }

        /* Print Action Bar */
        .action-bar {
            display: flex;
            gap: 12px;
            justify-content: flex-end;
            margin-bottom: 20px;
            padding: 12px 16px;
            background: #f5f3ff;
            border: 1px solid #c4b5fd;
            border-radius: 8px;
        }
        .btn-print {
            background: #4f46e5;
            color: #fff;
            padding: 8px 20px;
            border-radius: 6px;
            border: none;
            font-size: 13px;
            font-weight: 600;
            cursor: pointer;
            display: flex;
            align-items: center;
            gap: 6px;
        }
        .btn-print:hover { background: #3730a3; }
        .btn-close {
            background: #fff;
            color: #374151;
            padding: 8px 20px;
            border-radius: 6px;
            border: 1px solid #d1d5db;
            font-size: 13px;
            font-weight: 600;
            cursor: pointer;
            text-decoration: none;
            display: flex;
            align-items: center;
            gap: 6px;
        }

        @media print {
            .action-bar { display: none; }
            body { padding: 12px; }
        }
    </style>
</head>
<body>

    
    <div class="action-bar">
        <span style="flex:1; font-size:13px; color:#5b21b6; font-weight:600; display:flex; align-items:center; gap:6px;">
            <svg fill="none" stroke="currentColor" stroke-width="2" viewBox="0 0 24 24" width="16" height="16"><path stroke-linecap="round" stroke-linejoin="round" d="M11.25 11.25l.041-.02a.75.75 0 011.063.852l-.708 2.836a.75.75 0 001.063.853l.041-.021M21 12a9 9 0 11-18 0 9 9 0 0118 0zm-9-3.75h.008v.008H12V8.25z" /></svg>
            Laporan siap dicetak. Klik "Cetak / Simpan PDF" atau gunakan Ctrl+P.
        </span>
        <a href="<?php echo e(route('admin.aduan.index')); ?>" class="btn-close">
            <svg fill="none" stroke="currentColor" stroke-width="2" viewBox="0 0 24 24" width="14" height="14"><path stroke-linecap="round" stroke-linejoin="round" d="M6 18L18 6M6 6l12 12" /></svg>
            Tutup
        </a>
        <button onclick="window.print()" class="btn-print">
            <svg fill="none" stroke="currentColor" stroke-width="2" viewBox="0 0 24 24" width="16" height="16"><path stroke-linecap="round" stroke-linejoin="round" d="M6.72 13.829c-.24.03-.48.062-.72.096m.72-.096a42.415 42.415 0 0110.56 0m-10.56 0L6.34 18m10.94-4.171c.24.03.48.062.72.096m-.72-.096L17.66 18m0 0l.229 2.523a1.125 1.125 0 01-1.12 1.227H7.231c-.662 0-1.18-.568-1.12-1.227L6.34 18m11.318 0h1.091A2.25 2.25 0 0021 15.75V9.456c0-1.081-.768-2.015-1.837-2.175a48.055 48.055 0 00-1.913-.247M6.34 18H5.25A2.25 2.25 0 013 15.75V9.456c0-1.081.768-2.015 1.837-2.175a48.041 48.041 0 011.913-.247m10.5 0a48.536 48.536 0 00-10.5 0m10.5 0V3.375c0-.621-.504-1.125-1.125-1.125h-8.25c-.621 0-1.125.504-1.125 1.125v3.659M18 10.5h.008v.008H18V10.5zm-3 0h.008v.008H15V10.5z" /></svg>
            Cetak / Simpan PDF
        </button>
    </div>

    
    <div class="report-header">
        <img src="<?php echo e(asset('logo.png')); ?>" alt="SILAPOR Logo">
        <div class="report-header-text">
            <h1>LAPORAN DATA PENGADUAN MASYARAKAT</h1>
            <p>SILAPOR — Sistem Layanan Pengaduan Online Rakyat</p>
            <p>Kecamatan Wonosalam, Kabupaten Demak, Jawa Tengah</p>
            <p style="margin-top:4px; font-size:11px; color:#6b7280;">Dicetak pada: <strong><?php echo e($now); ?> WIB</strong></p>
        </div>
    </div>

    
    <?php
        $totalMenunggu = $aduans->where('status', 'menunggu')->count();
        $totalDiproses = $aduans->where('status', 'diproses')->count();
        $totalSelesai  = $aduans->where('status', 'selesai')->count();
    ?>
    <div class="meta-grid">
        <div class="meta-card">
            <div class="meta-label">Total Aduan</div>
            <div class="meta-val"><?php echo e($totalData); ?></div>
            <div class="meta-sub">Semua status</div>
        </div>
        <div class="meta-card" style="background:#fffbeb; border-color:#fcd34d;">
            <div class="meta-label" style="color:#b45309;">Menunggu</div>
            <div class="meta-val" style="color:#b45309;"><?php echo e($totalMenunggu); ?></div>
            <div class="meta-sub" style="color:#d97706;">Belum ditangani</div>
        </div>
        <div class="meta-card" style="background:#eff6ff; border-color:#93c5fd;">
            <div class="meta-label" style="color:#1d4ed8;">Diproses</div>
            <div class="meta-val" style="color:#1d4ed8;"><?php echo e($totalDiproses); ?></div>
            <div class="meta-sub" style="color:#2563eb;">Sedang ditangani</div>
        </div>
        <div class="meta-card" style="background:#ecfdf5; border-color:#6ee7b7;">
            <div class="meta-label" style="color:#047857;">Selesai</div>
            <div class="meta-val" style="color:#047857;"><?php echo e($totalSelesai); ?></div>
            <div class="meta-sub" style="color:#059669;">Telah ditangani</div>
        </div>
    </div>

    
    <table class="data-table">
        <thead>
            <tr>
                <th class="col-no">No</th>
                <th class="col-tgl">Tanggal</th>
                <th class="col-nama">Nama Pelapor</th>
                <th class="col-nik">NIK</th>
                <th class="col-desa">Desa</th>
                <th class="col-isi">Isi Pengaduan</th>
                <th class="col-kategori">Kategori (AI)</th>
                <th class="col-skor">Skor</th>
                <th class="col-prioritas">Prioritas</th>
                <th class="col-status">Status</th>
                <th class="col-tanggapan">Tanggapan Petugas</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 = $aduans; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $i => $aduan): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); $__empty_1 = false; ?><?php if(\Livewire\Mechanisms\ExtendBlade\ExtendBlade::isRenderingLivewireComponent()): ?><?php \Livewire\Features\SupportCompiledWireKeys\SupportCompiledWireKeys::startLoopIteration(); ?><?php endif; ?>
                <?php
                    $desaLabel     = $desaList[$aduan->desa] ?? ucfirst($aduan->desa);
                    $katLabel      = $kategoriLabel[$aduan->kategori] ?? ucwords(str_replace('_', ' ', $aduan->kategori ?? '-'));
                    $confidence    = $aduan->confidence_score ? number_format($aduan->confidence_score * 100, 1) . '%' : '-';
                    $tanggalMasuk  = $aduan->created_at ? $aduan->created_at->format('d/m/Y H:i') : '-';
                ?>
                <tr>
                    <td class="col-no"><?php echo e($i + 1); ?></td>
                    <td class="col-tgl"><?php echo e($tanggalMasuk); ?></td>
                    <td class="col-nama">
                        <div class="nama-bold"><?php echo e($aduan->nama_pelapor ?? '-'); ?></div>
                    </td>
                    <td class="col-nik"><?php echo e($aduan->nik ?? '-'); ?></td>
                    <td class="col-desa"><?php echo e($desaLabel); ?></td>
                    <td class="col-isi">
                        <div class="isi-text"><?php echo e($aduan->isi_aduan ?? '-'); ?></div>
                    </td>
                    <td class="col-kategori" style="font-size:10px; color:#5b21b6; font-weight:500;"><?php echo e($katLabel); ?></td>
                    <td class="col-skor"><?php echo e($confidence); ?></td>
                    <td class="col-prioritas">
                        <span class="badge badge-<?php echo e($aduan->prioritas ?? 'biasa'); ?>">
                            <?php echo e(ucfirst($aduan->prioritas ?? 'biasa')); ?>

                        </span>
                    </td>
                    <td class="col-status">
                        <span class="badge badge-<?php echo e($aduan->status ?? 'menunggu'); ?>">
                            <?php echo e(ucfirst($aduan->status ?? 'menunggu')); ?>

                        </span>
                    </td>
                    <td class="col-tanggapan" style="font-size:10.5px; color:#4b5563; font-style: <?php echo e($aduan->tanggapan ? 'normal' : 'italic'); ?>;">
                        <?php echo e($aduan->tanggapan ?? 'Belum ada tanggapan.'); ?>

                    </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="11" style="text-align:center; padding: 24px; color: #9ca3af; font-style: italic;">
                        Tidak ada data pengaduan yang ditemukan.
                    </td>
                </tr>
            <?php endif; ?><?php if(\Livewire\Mechanisms\ExtendBlade\ExtendBlade::isRenderingLivewireComponent()): ?><!--[if ENDBLOCK]><![endif]--><?php endif; ?>
        </tbody>
    </table>

    
    <div class="report-footer">
        <div>
            <p>SILAPOR Wonosalam &mdash; Sistem Layanan Pengaduan Online Rakyat</p>
            <p>Dokumen ini digenerate secara otomatis pada <?php echo e($now); ?> WIB</p>
        </div>
        <div class="signature-box">
            <div class="sig-title">Mengetahui,<br>Camat Wonosalam</div>
            <div class="sig-line">( ______________________________ )</div>
            <div style="font-size:10px; color:#6b7280; margin-top:4px;">NIP. ___________________________</div>
        </div>
    </div>

</body>
</html>
<?php /**PATH D:\silapor-ml\resources\views/admin/export_print.blade.php ENDPATH**/ ?>