<?php $__env->startSection('title', 'Dashboard - KITA AKADEMIK'); ?>
<?php $__env->startSection('page-title', 'Dashboard Utama'); ?>

<?php $__env->startSection('content'); ?>
<div class="container-fluid px-0">
    <!-- Premium Greeting Header -->
    <div class="row mb-4">
        <div class="col-12">
            <div class="card border-0 rounded-4 overflow-hidden shadow-sm text-white" style="background: linear-gradient(135deg, #1e1b4b 0%, #312e81 60%, #4f46e5 100%);">
                <div class="card-body p-4.5">
                    <div class="row align-items-center">
                        <div class="col-md-9 mb-3 mb-md-0">
                            <span class="badge bg-warning text-dark px-3 py-1.5 fw-bold mb-2.5" style="font-size: 0.75rem; letter-spacing: 0.5px;">DASHBOARD UTAMA PELAPOR</span>
                            <h3 class="fw-extrabold mb-1 text-white" style="font-size: 1.75rem; letter-spacing: -0.5px;">Selamat Datang Kembali, <?php echo e(auth()->user()->name); ?>!</h3>
                            <p class="text-white-50 mb-0 small" style="max-width: 650px;">
                                Universitas Terdaftar: <strong class="text-white"><?php echo e(auth()->user()->pts_nama ?? 'ADIA (LLDIKTI III)'); ?></strong> | Program Studi: <strong class="text-white"><?php echo e(auth()->user()->prodi ?? 'N/A'); ?></strong>
                            </p>
                        </div>
                        <div class="col-md-3 text-md-end text-center d-none d-md-block">
                            <div class="display-3 text-white-50 opacity-25">
                                <i class="fa-solid fa-graduation-cap"></i>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>

    <!-- ============================================== -->
    <!-- 1. DASHBOARD MAHASISWA / DOSEN -->
    <!-- ============================================== -->
    <?php if(auth()->user()->isMahasiswaDosenRole()): ?>
    <div class="row g-4 mb-4">
        <div class="col-md-4">
            <div class="card card-custom p-4 border-0 shadow-sm rounded-4 border-start border-4 border-primary h-100">
                <div class="d-flex align-items-center justify-content-between">
                    <div>
                        <h6 class="text-muted mb-1 fw-bold small text-uppercase" style="letter-spacing: 0.5px;">Total Laporan Saya</h6>
                        <h2 class="fw-extrabold text-primary mb-0" style="font-size: 2.2rem;"><?php echo e($myLaporansCount); ?></h2>
                    </div>
                    <div class="bg-primary-subtle text-primary rounded-3 p-3 fs-3">
                        <i class="fa-solid fa-file-invoice"></i>
                    </div>
                </div>
            </div>
        </div>
        <div class="col-md-4">
            <div class="card card-custom p-4 border-0 shadow-sm rounded-4 border-start border-4 border-warning h-100">
                <div class="d-flex align-items-center justify-content-between">
                    <div>
                        <h6 class="text-muted mb-1 fw-bold small text-uppercase" style="letter-spacing: 0.5px;">Sedang Diproses</h6>
                        <h2 class="fw-extrabold text-warning mb-0" style="font-size: 2.2rem;"><?php echo e($myPendingCount); ?></h2>
                    </div>
                    <div class="bg-warning-subtle text-warning rounded-3 p-3 fs-3">
                        <i class="fa-solid fa-spinner"></i>
                    </div>
                </div>
            </div>
        </div>
        <div class="col-md-4">
            <div class="card card-custom p-4 border-0 shadow-sm rounded-4 border-start border-4 border-success h-100">
                <div class="d-flex align-items-center justify-content-between">
                    <div>
                        <h6 class="text-muted mb-1 fw-bold small text-uppercase" style="letter-spacing: 0.5px;">Laporan Selesai</h6>
                        <h2 class="fw-extrabold text-success mb-0" style="font-size: 2.2rem;"><?php echo e($myFinishedCount); ?></h2>
                    </div>
                    <div class="bg-success-subtle text-success rounded-3 p-3 fs-3">
                        <i class="fa-solid fa-circle-check"></i>
                    </div>
                </div>
            </div>
        </div>
    </div>

    <div class="row g-4 mb-4">
        <div class="col-md-8">
            <div class="card card-custom p-4 border-0 shadow-sm rounded-4">
                <div class="d-flex align-items-center justify-content-between mb-4">
                    <h5 class="fw-bold mb-0 text-dark">Laporan Terbaru Saya</h5>
                    <a href="<?php echo e(route('laporan.index')); ?>" class="btn btn-outline-primary btn-sm rounded-pill px-3">Lihat Semua</a>
                </div>
                <?php if($recentLaporans->isEmpty()): ?>
                    <div class="text-center py-5">
                        <div class="text-muted mb-3 fs-1 opacity-25">
                            <i class="fa-solid fa-folder-open"></i>
                        </div>
                        <h6 class="fw-bold text-dark">Belum Ada Laporan</h6>
                        <p class="text-muted small mb-0 px-4">Anda belum pernah mengajukan aduan atau permohonan bimbingan konseling.</p>
                    </div>
                <?php else: ?>
                    <div class="table-responsive">
                        <table class="table table-hover align-middle mb-0">
                            <thead>
                                <tr class="text-muted" style="font-size: 0.85rem;">
                                    <th>JUDUL LAPORAN</th>
                                    <th>KATEGORI</th>
                                    <th>TANGGAL KIRIM</th>
                                    <th>STATUS</th>
                                    <th>AKSI</th>
                                </tr>
                            </thead>
                            <tbody>
                                <?php $__currentLoopData = $recentLaporans; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $lap): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                                <tr>
                                    <td>
                                        <div class="fw-semibold text-dark"><?php echo e($lap->judul); ?></div>
                                    </td>
                                    <td>
                                        <?php if($lap->tipe_laporan === 'preventif_konseling'): ?>
                                            <span class="badge bg-info-subtle text-info">Preventif Konseling</span>
                                        <?php elseif($lap->tipe_laporan === 'kekerasan_bullying'): ?>
                                            <span class="badge bg-danger-subtle text-danger">Kekerasan / Bullying</span>
                                        <?php elseif($lap->tipe_laporan === 'integritas_akademik'): ?>
                                            <span class="badge bg-warning-subtle text-warning">Integritas Akademik</span>
                                        <?php endif; ?>
                                    </td>
                                    <td><?php echo e($lap->created_at->format('d M Y H:i')); ?> WIB</td>
                                    <td>
                                        <?php echo $__env->make('laporan._status_badge', ['status' => $lap->status], array_diff_key(get_defined_vars(), ['__data' => 1, '__path' => 1]))->render(); ?>
                                    </td>
                                    <td>
                                        <a href="<?php echo e(route('laporan.show', $lap->id)); ?>" class="btn btn-sm btn-primary rounded-pill px-3">Detail</a>
                                    </td>
                                </tr>
                                <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
                            </tbody>
                        </table>
                    </div>
                <?php endif; ?>
            </div>
        </div>
        <div class="col-md-4">
            <div class="card border-0 rounded-4 shadow-sm text-white h-100" style="background: linear-gradient(135deg, #4f46e5 0%, #3730a3 100%);">
                <div class="card-body p-4 d-flex flex-column justify-content-between">
                    <div>
                        <div class="bg-white-50 text-white rounded-3 p-2.5 d-inline-block mb-3 fs-4" style="background: rgba(255,255,255,0.15);">
                            <i class="fa-solid fa-handshake-angle"></i>
                        </div>
                        <h5 class="fw-bold text-white mb-2">Butuh Bantuan / Konseling?</h5>
                        <p class="text-white-70 small leading-relaxed mb-4" style="opacity: 0.85;">
                            Jangan ragu untuk bersuara. Layanan ini sepenuhnya aman, terenkripsi, dan melindungi kerahasiaan identitas pelapor. Anda dapat melaporkan pelanggaran moral, kekerasan seksual/bullying, atau meminta konsultasi bimbingan akademik.
                        </p>
                    </div>
                    <div>
                        <a href="<?php echo e(route('laporan.create')); ?>" class="btn btn-warning text-dark w-100 py-2.5 rounded-3 fw-bold shadow-sm">
                            <i class="fa-solid fa-circle-plus me-1.5"></i> Ajukan Laporan / KITA
                        </a>
                    </div>
                </div>
            </div>
        </div>
    </div>

    <!-- Panduan Alur Penanganan (Timeline) -->
    <div class="card card-custom p-4 border-0 shadow-sm rounded-4 mb-4">
        <h5 class="fw-bold mb-3 text-dark"><i class="fa-solid fa-timeline text-primary me-2"></i> Alur Penanganan Aduan & Bimbingan KITA</h5>
        <div class="row row-cols-1 row-cols-sm-3 row-cols-md-5 g-3">
            <div class="col">
                <div class="p-3 bg-light rounded-3 h-100 border border-slate-100">
                    <div class="badge bg-primary text-white rounded-circle mb-2" style="width: 25px; height: 25px; line-height: 25px; padding: 0; text-align: center;">1</div>
                    <h6 class="fw-bold small mb-1">Pengajuan</h6>
                    <p class="text-muted mb-0" style="font-size: 0.75rem; line-height: 1.4;">Pelapor mengirimkan laporan detail di web.</p>
                </div>
            </div>
            <div class="col">
                <div class="p-3 bg-light rounded-3 h-100 border border-slate-100">
                    <div class="badge bg-secondary text-white rounded-circle mb-2" style="width: 25px; height: 25px; line-height: 25px; padding: 0; text-align: center;">2</div>
                    <h6 class="fw-bold small mb-1">Validasi Dokumen</h6>
                    <p class="text-muted mb-0" style="font-size: 0.75rem; line-height: 1.4;">Verifikasi berkas oleh Satgas/Tim Penilai.</p>
                </div>
            </div>
            <div class="col">
                <div class="p-3 bg-light rounded-3 h-100 border border-slate-100">
                    <div class="badge bg-secondary text-white rounded-circle mb-2" style="width: 25px; height: 25px; line-height: 25px; padding: 0; text-align: center;">3</div>
                    <h6 class="fw-bold small mb-1">Konseling Psikologi</h6>
                    <p class="text-muted mb-0" style="font-size: 0.75rem; line-height: 1.4;">Bimbingan & pemulihan korban oleh Psikolog.</p>
                </div>
            </div>
            <div class="col">
                <div class="p-3 bg-light rounded-3 h-100 border border-slate-100">
                    <div class="badge bg-secondary text-white rounded-circle mb-2" style="width: 25px; height: 25px; line-height: 25px; padding: 0; text-align: center;">4</div>
                    <h6 class="fw-bold small mb-1">Keputusan Rektor</h6>
                    <p class="text-muted mb-0" style="font-size: 0.75rem; line-height: 1.4;">Penandatanganan keputusan & sanksi akademik.</p>
                </div>
            </div>
            <div class="col">
                <div class="p-3 bg-light rounded-3 h-100 border border-slate-100">
                    <div class="badge bg-success text-white rounded-circle mb-2" style="width: 25px; height: 25px; line-height: 25px; padding: 0; text-align: center;">5</div>
                    <h6 class="fw-bold small mb-1">Selesai & Arsip</h6>
                    <p class="text-muted mb-0" style="font-size: 0.75rem; line-height: 1.4;">Aduan ditutup secara resmi & diarsipkan di ADIA.</p>
                </div>
            </div>
        </div>
    </div>
    <?php elseif(auth()->user()->isPenilaiRole()): ?>
    <div class="row g-4 mb-4">
        <div class="col-md-6">
            <div class="card card-custom p-4 text-center border-start border-4 border-warning">
                <h6 class="text-muted mb-2 fw-semibold">Aduan Menunggu Sidang Etik & Cek Plagiat</h6>
                <h2 class="fw-bold text-warning mb-0"><?php echo e($incomingCount); ?></h2>
            </div>
        </div>
        <div class="col-md-6">
            <div class="card card-custom p-4 text-center border-start border-4 border-success">
                <h6 class="text-muted mb-2 fw-semibold">Aduan Integritas Telah Dinilai</h6>
                <h2 class="fw-bold text-success mb-0"><?php echo e($processedCount); ?></h2>
            </div>
        </div>
    </div>

    <div class="row">
        <div class="col-12">
            <div class="card card-custom p-4 mb-4">
                <h5 class="fw-bold mb-3 text-warning"><i class="fa-solid fa-gavel me-1"></i> Kasus Pelanggaran Integritas Baru (Perlu Sidang & Cek Plagiat)</h5>
                <?php if($incomingLaporans->isEmpty()): ?>
                    <p class="text-muted my-4 text-center">Tidak ada aduan integritas akademik yang menunggu tindakan Anda.</p>
                <?php else: ?>
                    <div class="table-responsive">
                        <table class="table table-hover align-middle mb-0">
                            <thead>
                                <tr class="text-muted" style="font-size: 0.85rem;">
                                    <th>PELAPOR</th>
                                    <th>JUDUL KASUS</th>
                                    <th>TANGGAL MASUK</th>
                                    <th>STATUS</th>
                                    <th>AKSI</th>
                                </tr>
                            </thead>
                            <tbody>
                                <?php $__currentLoopData = $incomingLaporans; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $lap): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                                <tr>
                                    <td>
                                        <div class="fw-semibold text-dark"><?php echo e($lap->pelapor_nama); ?></div>
                                        <small class="text-muted"><?php echo e($lap->pelapor_nim_nidn); ?> | <?php echo e($lap->pts_nama); ?></small>
                                    </td>
                                    <td><?php echo e($lap->judul); ?></td>
                                    <td><?php echo e($lap->created_at->format('d M Y H:i')); ?> WIB</td>
                                    <td><?php echo $__env->make('laporan._status_badge', ['status' => $lap->status], array_diff_key(get_defined_vars(), ['__data' => 1, '__path' => 1]))->render(); ?></td>
                                    <td>
                                        <a href="<?php echo e(route('laporan.show', $lap->id)); ?>" class="btn btn-sm btn-warning text-dark fw-bold rounded-pill px-3">Mulai Sidang</a>
                                    </td>
                                </tr>
                                <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
                            </tbody>
                        </table>
                    </div>
                <?php endif; ?>
            </div>

            <div class="card card-custom p-4">
                <h5 class="fw-bold mb-3 text-success"><i class="fa-solid fa-check-double me-1"></i> Kasus Integritas Telah Anda Rekomendasikan</h5>
                <?php if($processedLaporans->isEmpty()): ?>
                    <p class="text-muted my-4 text-center">Belum ada kasus yang telah selesai Anda nilai.</p>
                <?php else: ?>
                    <div class="table-responsive">
                        <table class="table table-hover align-middle mb-0">
                            <thead>
                                <tr class="text-muted" style="font-size: 0.85rem;">
                                    <th>PELAPOR</th>
                                    <th>JUDUL KASUS</th>
                                    <th>SKOR PLAGIARISME</th>
                                    <th>REKOMENDASI SANKSI</th>
                                    <th>AKSI</th>
                                </tr>
                            </thead>
                            <tbody>
                                <?php $__currentLoopData = $processedLaporans; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $lap): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                                <tr>
                                    <td>
                                        <div class="fw-semibold text-dark"><?php echo e($lap->pelapor_nama); ?></div>
                                        <small class="text-muted"><?php echo e($lap->pelapor_nim_nidn); ?></small>
                                    </td>
                                    <td><?php echo e($lap->judul); ?></td>
                                    <td>
                                        <span class="badge bg-danger fw-bold"><?php echo e($lap->tindakanPenilai->cek_plagiat_score); ?>%</span>
                                    </td>
                                    <td>
                                        <small class="text-truncate d-block" style="max-width: 250px;">
                                            <?php echo e($lap->tindakanPenilai->rekomendasi_sanksi); ?>

                                        </small>
                                    </td>
                                    <td>
                                        <a href="<?php echo e(route('laporan.show', $lap->id)); ?>" class="btn btn-sm btn-outline-primary rounded-pill px-3">Detail</a>
                                    </td>
                                </tr>
                                <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
                            </tbody>
                        </table>
                    </div>
                <?php endif; ?>
            </div>
        </div>
    </div>

    <!-- ============================================== -->
    <!-- 4. DASHBOARD ROLE: PSIKOLOG -->
    <!-- ============================================== -->
    <?php elseif(auth()->user()->isPsikologRole()): ?>
    <div class="row g-4 mb-4">
        <div class="col-md-6">
            <div class="card card-custom p-4 text-center border-start border-4 border-warning">
                <h6 class="text-muted mb-2 fw-semibold">Kasus Konseling Menunggu Sesi Online & Catatan</h6>
                <h2 class="fw-bold text-warning mb-0"><?php echo e($incomingCount); ?></h2>
            </div>
        </div>
        <div class="col-md-6">
            <div class="card card-custom p-4 text-center border-start border-4 border-success">
                <h6 class="text-muted mb-2 fw-semibold">Kasus Konseling Selesai Ditangani</h6>
                <h2 class="fw-bold text-success mb-0"><?php echo e($processedCount); ?></h2>
            </div>
        </div>
    </div>

    <div class="row">
        <div class="col-12">
            <div class="card card-custom p-4 mb-4">
                <h5 class="fw-bold mb-3 text-warning"><i class="fa-solid fa-user-doctor me-1"></i> Antrean Layanan Konseling & Log Pemulihan (Confidential)</h5>
                <?php if($incomingLaporans->isEmpty()): ?>
                    <p class="text-muted my-4 text-center">Tidak ada antrean sesi konseling saat ini.</p>
                <?php else: ?>
                    <div class="table-responsive">
                        <table class="table table-hover align-middle mb-0">
                            <thead>
                                <tr class="text-muted" style="font-size: 0.85rem;">
                                    <th>PELAPOR</th>
                                    <th>JUDUL MASALAH</th>
                                    <th>JALUR</th>
                                    <th>TANGGAL MASUK</th>
                                    <th>AKSI</th>
                                </tr>
                            </thead>
                            <tbody>
                                <?php $__currentLoopData = $incomingLaporans; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $lap): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                                <tr>
                                    <td>
                                        <div class="fw-semibold text-dark"><?php echo e($lap->pelapor_nama); ?></div>
                                        <small class="text-muted"><?php echo e($lap->pelapor_nim_nidn); ?> | <?php echo e($lap->pts_nama); ?></small>
                                    </td>
                                    <td><?php echo e($lap->judul); ?></td>
                                    <td>
                                        <?php if($lap->tipe_laporan === 'preventif_konseling'): ?>
                                            <span class="badge bg-primary text-white"><?php echo e(ucfirst($lap->jalur)); ?></span>
                                        <?php else: ?>
                                            <span class="badge bg-danger text-white">Rujukan Satgas</span>
                                        <?php endif; ?>
                                    </td>
                                    <td><?php echo e($lap->created_at->format('d M Y H:i')); ?> WIB</td>
                                    <td>
                                        <a href="<?php echo e(route('laporan.show', $lap->id)); ?>" class="btn btn-sm btn-warning text-dark fw-bold rounded-pill px-3">Buka Sesi</a>
                                    </td>
                                </tr>
                                <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
                            </tbody>
                        </table>
                    </div>
                <?php endif; ?>
            </div>

            <div class="card card-custom p-4">
                <h5 class="fw-bold mb-3 text-success"><i class="fa-solid fa-check-double me-1"></i> Catatan Konseling Selesai Ditangani</h5>
                <?php if($processedLaporans->isEmpty()): ?>
                    <p class="text-muted my-4 text-center">Belum ada catatan klinis konseling yang dimasukkan.</p>
                <?php else: ?>
                    <div class="table-responsive">
                        <table class="table table-hover align-middle mb-0">
                            <thead>
                                <tr class="text-muted" style="font-size: 0.85rem;">
                                    <th>PELAPOR</th>
                                    <th>SESI KONSELING ONLINE</th>
                                    <th>CATATAN KLINIS RAHASIA</th>
                                    <th>LOG PEMULIHAN KORBAN</th>
                                    <th>AKSI</th>
                                </tr>
                            </thead>
                            <tbody>
                                <?php $__currentLoopData = $processedLaporans; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $lap): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                                <tr>
                                    <td>
                                        <div class="fw-semibold text-dark"><?php echo e($lap->pelapor_nama); ?></div>
                                        <small class="text-muted"><?php echo e($lap->pelapor_nim_nidn); ?></small>
                                    </td>
                                    <td><small class="text-truncate d-block" style="max-width: 150px;"><?php echo e($lap->catatanKlinisPsikolog->sesi_konseling_online); ?></small></td>
                                    <td>
                                        <span class="badge bg-danger text-white"><i class="fa-solid fa-lock me-1"></i> Rahasia Medis</span>
                                    </td>
                                    <td>
                                        <small class="text-truncate d-block" style="max-width: 250px;">
                                            <?php echo e($lap->catatanKlinisPsikolog->log_pemulihan); ?>

                                        </small>
                                    </td>
                                    <td>
                                        <a href="<?php echo e(route('laporan.show', $lap->id)); ?>" class="btn btn-sm btn-outline-primary rounded-pill px-3">Detail</a>
                                    </td>
                                </tr>
                                <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
                            </tbody>
                        </table>
                    </div>
                <?php endif; ?>
            </div>
        </div>
    </div>

    <!-- ============================================== -->
    <!-- 5. DASHBOARD REKTOR / PIMPINAN PTS -->
    <!-- ============================================== -->
    <?php elseif(auth()->user()->isRektorRole()): ?>
    <div class="row g-4 mb-4">
        <div class="col-md-6">
            <div class="card card-custom p-4 text-center border-start border-4 border-warning">
                <h6 class="text-muted mb-2 fw-semibold">Kasus Menunggu Eksekusi Sanksi PTS Anda</h6>
                <h2 class="fw-bold text-warning mb-0"><?php echo e($incomingCount); ?></h2>
            </div>
        </div>
        <div class="col-md-6">
            <div class="card card-custom p-4 text-center border-start border-4 border-success">
                <h6 class="text-muted mb-2 fw-semibold">Kasus Selesai & Sanksi Dieksekusi</h6>
                <h2 class="fw-bold text-success mb-0"><?php echo e($processedCount); ?></h2>
            </div>
        </div>
    </div>

    <div class="row">
        <div class="col-12">
            <div class="card card-custom p-4 mb-4">
                <h5 class="fw-bold mb-3 text-warning"><i class="fa-solid fa-signature me-1"></i> Antrean Kasus Siap Eksekusi Sanksi & Penutupan (Rektor PTS: <?php echo e(auth()->user()->pts_nama); ?>)</h5>
                <?php if($incomingLaporans->isEmpty()): ?>
                    <p class="text-muted my-4 text-center">Tidak ada kasus yang menunggu tanda tangan sanksi Anda.</p>
                <?php else: ?>
                    <div class="table-responsive">
                        <table class="table table-hover align-middle mb-0">
                            <thead>
                                <tr class="text-muted" style="font-size: 0.85rem;">
                                    <th>PELAPOR / MAHASISWA</th>
                                    <th>TIPE KASUS</th>
                                    <th>JUDUL LAPORAN</th>
                                    <th>SUMBER AKHIR</th>
                                    <th>AKSI</th>
                                </tr>
                            </thead>
                            <tbody>
                                <?php $__currentLoopData = $incomingLaporans; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $lap): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                                <tr>
                                    <td>
                                        <div class="fw-semibold text-dark"><?php echo e($lap->pelapor_nama); ?></div>
                                        <small class="text-muted"><?php echo e($lap->pelapor_nim_nidn); ?></small>
                                    </td>
                                    <td>
                                        <?php if($lap->tipe_laporan === 'preventif_konseling'): ?>
                                            <span class="badge bg-info-subtle text-info">Preventif Konseling</span>
                                        <?php elseif($lap->tipe_laporan === 'kekerasan_bullying'): ?>
                                            <span class="badge bg-danger-subtle text-danger">Kekerasan / Bullying</span>
                                        <?php elseif($lap->tipe_laporan === 'integritas_akademik'): ?>
                                            <span class="badge bg-warning-subtle text-warning">Integritas Akademik</span>
                                        <?php endif; ?>
                                    </td>
                                    <td><?php echo e($lap->judul); ?></td>
                                    <td>
                                        <?php if($lap->tipe_laporan === 'integritas_akademik'): ?>
                                            <span class="badge bg-warning text-dark"><i class="fa-solid fa-file-signature me-1"></i> Rekomendasi Tim Penilai</span>
                                        <?php else: ?>
                                            <span class="badge bg-danger text-white"><i class="fa-solid fa-heart-pulse me-1"></i> Log Pemulihan Psikolog</span>
                                        <?php endif; ?>
                                    </td>
                                    <td>
                                        <a href="<?php echo e(route('laporan.show', $lap->id)); ?>" class="btn btn-sm btn-warning text-dark fw-bold rounded-pill px-3">Eksekusi</a>
                                    </td>
                                </tr>
                                <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
                            </tbody>
                        </table>
                    </div>
                <?php endif; ?>
            </div>

            <div class="card card-custom p-4">
                <h5 class="fw-bold mb-3 text-success"><i class="fa-solid fa-check-double me-1"></i> Kasus yang Telah Selesai Dieksekusi</h5>
                <?php if($processedLaporans->isEmpty()): ?>
                    <p class="text-muted my-4 text-center">Belum ada kasus yang berstatus selesai ditutup.</p>
                <?php else: ?>
                    <div class="table-responsive">
                        <table class="table table-hover align-middle mb-0">
                            <thead>
                                <tr class="text-muted" style="font-size: 0.85rem;">
                                    <th>PELAPOR</th>
                                    <th>JUDUL KASUS</th>
                                    <th>SANKSI YANG DIEKSEKUSI</th>
                                    <th>TANGGAL PENUTUPAN</th>
                                    <th>AKSI</th>
                                </tr>
                            </thead>
                            <tbody>
                                <?php $__currentLoopData = $processedLaporans; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $lap): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                                <tr>
                                    <td>
                                        <div class="fw-semibold text-dark"><?php echo e($lap->pelapor_nama); ?></div>
                                        <small class="text-muted"><?php echo e($lap->pelapor_nim_nidn); ?></small>
                                    </td>
                                    <td><?php echo e($lap->judul); ?></td>
                                    <td>
                                        <small class="text-truncate d-block" style="max-width: 250px;">
                                            <?php echo e($lap->eksekusiRektor->sanksi_eksekusi); ?>

                                        </small>
                                    </td>
                                    <td><?php echo e($lap->updated_at->format('d M Y')); ?></td>
                                    <td>
                                        <a href="<?php echo e(route('laporan.show', $lap->id)); ?>" class="btn btn-sm btn-outline-primary rounded-pill px-3">Detail</a>
                                    </td>
                                </tr>
                                <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
                            </tbody>
                        </table>
                    </div>
                <?php endif; ?>
            </div>
        </div>
    </div>

    <!-- ============================================== -->
    <!-- 6. DASHBOARD MONITORING LLDIKTI WILAYAH III -->
    <!-- ============================================== -->
    <?php elseif(auth()->user()->isAdmin()): ?>
    
    <!-- ============================================== -->
    <!-- ALARM OTOMATIS: KASUS MANDEK > 30 HARI -->
    <!-- ============================================== -->
    <?php if($stalledCount > 0): ?>
    <div class="row mb-4">
        <div class="col-12">
            <div class="card alarm-indicator p-4 rounded-4 shadow border-0">
                <div class="d-flex align-items-center gap-3">
                    <div class="fs-1 text-white border border-white border-2 rounded-circle p-2 d-flex align-items-center justify-content-center" style="width: 60px; height: 60px;">
                        <i class="fa-solid fa-bell-slash fa-shake"></i>
                    </div>
                    <div>
                        <h5 class="fw-bold mb-1"><i class="fa-solid fa-circle-exclamation"></i> ALARM OTOMATIS: Ditemukan <?php echo e($stalledCount); ?> Kasus Mandek > 30 Hari!</h5>
                        <p class="mb-0 text-white-50 small">Kasus-kasus berikut belum mendapat penanganan/tindakan lanjut dalam waktu lebih dari 30 hari. Silakan klik salah satu kasus untuk memperingatkan PTS bersangkutan.</p>
                    </div>
                </div>
                <hr class="my-3" style="border-color: rgba(255,255,255,0.2);">
                <div class="row g-2">
                    <?php $__currentLoopData = $stalledLaporans; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $stalled): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                    <div class="col-md-6">
                        <div class="p-3 rounded-3" style="background: rgba(0,0,0,0.2);">
                            <div class="d-flex justify-content-between align-items-start">
                                <div>
                                    <h6 class="fw-bold mb-0 text-white" style="font-size: 0.85rem;"><?php echo e($stalled->judul); ?></h6>
                                    <small class="d-block text-warning" style="font-size: 0.75rem;">PTS: <?php echo e($stalled->pts_nama); ?></small>
                                    <small class="d-block text-white-50" style="font-size: 0.75rem;">Tahap: 
                                        <?php if($stalled->status === 'menunggu_satgas'): ?> Satgas Kampus
                                        <?php elseif($stalled->status === 'menunggu_penilai'): ?> Tim Penilai Ilmiah
                                        <?php elseif($stalled->status === 'menunggu_psikolog'): ?> Psikolog
                                        <?php elseif($stalled->status === 'menunggu_rektor'): ?> Rektor
                                        <?php endif; ?>
                                    </small>
                                </div>
                                <div class="text-end">
                                    <span class="badge bg-dark text-danger fw-bold py-1.5" style="font-size: 0.7rem;">
                                        <?php echo e($stalled->created_at->diffInDays()); ?> Hari Mandek
                                    </span>
                                    <a href="<?php echo e(route('laporan.show', $stalled->id)); ?>" class="btn btn-xs btn-light text-dark fw-bold rounded-pill px-2.5 py-1 small mt-2 d-inline-block" style="font-size: 0.7rem;">Cek Kasus</a>
                                </div>
                            </div>
                        </div>
                    </div>
                    <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
                </div>
            </div>
        </div>
    </div>
    <?php endif; ?>
    <div class="d-flex align-items-center justify-content-between mb-4">
        <h4 class="fw-bold mb-0 text-dark"><i class="fa-solid fa-chart-pie me-2"></i> Ringkasan Eksekutif Wilayah</h4>
        <?php if(auth()->user()->isLldiktiRole()): ?>
        <a href="<?php echo e(route('admin.rekap.pdf')); ?>" target="_blank" class="btn btn-danger fw-bold rounded-pill px-4 shadow-sm">
            <i class="fa-solid fa-file-pdf me-2"></i> Cetak Laporan PDF
        </a>
        <?php endif; ?>
    </div>

    <div class="row g-4 mb-4">
        <div class="col-md-4">
            <div class="card card-custom p-4 text-center">
                <h6 class="text-muted mb-2 fw-semibold">Total Laporan Seluruh PTS</h6>
                <h2 class="fw-bold text-primary mb-0"><?php echo e($totalCount); ?></h2>
            </div>
        </div>
        <div class="col-md-4">
            <div class="card card-custom p-4 text-center border-start border-4 border-warning">
                <h6 class="text-muted mb-2 fw-semibold">Aduan Aktif Butuh Keputusan</h6>
                <h2 class="fw-bold text-warning mb-0"><?php echo e($pendingCount); ?></h2>
            </div>
        </div>
        <div class="col-md-4">
            <div class="card card-custom p-4 text-center border-start border-4 border-success">
                <h6 class="text-muted mb-2 fw-semibold">Total Kasus Selesai Ditutup</h6>
                <h2 class="fw-bold text-success mb-0"><?php echo e($finishedCount); ?></h2>
            </div>
        </div>
    </div>

    <!-- DAFTAR KASUS YANG BUTUH TINDAKAN ADMIN -->
    <div class="row mb-4">
        <div class="col-12">
            <div class="card card-custom p-4">
                <div class="d-flex align-items-center justify-content-between mb-3 border-bottom pb-3">
                    <h5 class="fw-bold mb-0 text-danger"><i class="fa-solid fa-list-check me-2"></i> Kasus Masuk & Aktif (Perlu Tindakan / Keputusan Admin)</h5>
                </div>
                
                <?php if($recentLaporans->where('status', '!=', 'selesai')->where('status', '!=', 'ditolak')->isEmpty()): ?>
                    <p class="text-muted text-center py-4 mb-0">Tidak ada kasus aktif yang perlu ditindaklanjuti saat ini.</p>
                <?php else: ?>
                    <div class="table-responsive">
                        <table class="table table-hover align-middle mb-0">
                            <thead>
                                <tr class="text-muted small">
                                    <th>KODE</th>
                                    <th>JUDUL LAPORAN</th>
                                    <th>KAMPUS</th>
                                    <th>TAHAPAN SAAT INI</th>
                                    <th>TINDAK LANJUT</th>
                                </tr>
                            </thead>
                            <tbody>
                                <?php $__currentLoopData = $recentLaporans->where('status', '!=', 'selesai')->where('status', '!=', 'ditolak'); $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $lap): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                                <tr>
                                    <td><span class="badge bg-secondary">#K-<?php echo e(str_pad($lap->id, 4, '0', STR_PAD_LEFT)); ?></span></td>
                                    <td>
                                        <div class="fw-bold text-dark"><?php echo e($lap->judul); ?></div>
                                        <small class="text-muted"><?php echo e($lap->created_at->diffForHumans()); ?></small>
                                    </td>
                                    <td><?php echo e($lap->pts_nama); ?></td>
                                    <td><?php echo $__env->make('laporan._status_badge', ['status' => $lap->status], array_diff_key(get_defined_vars(), ['__data' => 1, '__path' => 1]))->render(); ?></td>
                                    <td>
                                        <a href="<?php echo e(route('laporan.show', $lap->id)); ?>" class="btn btn-sm btn-danger fw-bold rounded-pill px-3 shadow-sm">
                                            <i class="fa-solid fa-hand-pointer me-1"></i> Buka Kasus & Beri Keputusan
                                        </a>
                                    </td>
                                </tr>
                                <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
                            </tbody>
                        </table>
                    </div>
                <?php endif; ?>
            </div>
        </div>
    </div>

    <div class="row mb-4 g-4">
        <!-- Statistik Kepatuhan PTS -->
        <div class="col-12">
            <div class="card card-custom p-4">
                <h5 class="fw-bold mb-3"><i class="fa-solid fa-university me-1 text-primary"></i> Kepatuhan & Penyelesaian PTS</h5>
                <p class="text-muted mb-3" style="font-size: 0.8rem;">Statistik jumlah penanganan laporan yang masuk pada masing-masing Perguruan Tinggi Swasta (PTS):</p>
                <div class="table-responsive">
                    <table class="table table-sm table-hover align-middle mb-0" style="font-size: 0.85rem;">
                        <thead>
                            <tr class="text-muted">
                                <th>PTS / UNIVERSITAS</th>
                                <th class="text-center">TOTAL KASUS</th>
                                <th class="text-center">SELESAI DITUTUP</th>
                                <th>RASIO PENYELESAIAN</th>
                            </tr>
                        </thead>
                        <tbody>
                            <?php $__currentLoopData = $ptsStats; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $stat): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                            <tr>
                                <td class="fw-semibold text-dark"><?php echo e($stat->pts_nama); ?></td>
                                <td class="text-center"><?php echo e($stat->total); ?></td>
                                <td class="text-center text-success fw-bold"><?php echo e($stat->selesai); ?></td>
                                <td>
                                    <?php
                                        $ratio = $stat->total > 0 ? round(($stat->selesai / $stat->total) * 100) : 0;
                                        $barColor = $ratio >= 75 ? 'bg-success' : ($ratio >= 40 ? 'bg-warning' : 'bg-danger');
                                    ?>
                                    <div class="d-flex align-items-center gap-2">
                                        <div class="progress flex-grow-1" style="height: 8px; max-width: 150px;">
                                            <div class="progress-bar <?php echo e($barColor); ?>" role="progressbar" style="width: <?php echo e($ratio); ?>%"></div>
                                        </div>
                                        <span class="fw-bold"><?php echo e($ratio); ?>%</span>
                                    </div>
                                </td>
                            </tr>
                            <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
                        </tbody>
                    </table>
                </div>
            </div>
        </div>

        <!-- Daftar Laporan Terbaru Seluruh Wilayah -->
        <div class="col-12">
            <div class="card card-custom p-4">
                <div class="d-flex align-items-center justify-content-between mb-3">
                    <h5 class="fw-bold mb-0"><i class="fa-solid fa-list-check me-1 text-primary"></i> Aduan Wilayah Terbaru</h5>
                    <a href="<?php echo e(route('laporan.index')); ?>" class="btn btn-outline-primary btn-sm rounded-pill px-3">Lihat Semua</a>
                </div>
                <div class="table-responsive">
                    <table class="table table-hover align-middle mb-0" style="font-size: 0.85rem;">
                        <thead>
                            <tr class="text-muted">
                                <th>JUDUL LAPORAN</th>
                                <th>PTS</th>
                                <th>KATEGORI</th>
                                <th>STATUS</th>
                                <th>AKSI</th>
                            </tr>
                        </thead>
                        <tbody>
                            <?php $__currentLoopData = $recentLaporans; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $lap): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                            <tr>
                                <td>
                                    <div class="fw-semibold text-dark text-truncate" style="max-width: 250px;"><?php echo e($lap->judul); ?></div>
                                </td>
                                <td><small class="fw-medium"><?php echo e($lap->pts_nama); ?></small></td>
                                <td>
                                    <?php if($lap->tipe_laporan === 'preventif_konseling'): ?>
                                        <span class="badge bg-info-subtle text-info text-xs">Preventif</span>
                                    <?php elseif($lap->tipe_laporan === 'kekerasan_bullying'): ?>
                                        <span class="badge bg-danger-subtle text-danger text-xs">Bullying</span>
                                    <?php elseif($lap->tipe_laporan === 'integritas_akademik'): ?>
                                        <span class="badge bg-warning-subtle text-warning text-xs">Integritas</span>
                                    <?php endif; ?>
                                </td>
                                <td><?php echo $__env->make('laporan._status_badge', ['status' => $lap->status], array_diff_key(get_defined_vars(), ['__data' => 1, '__path' => 1]))->render(); ?></td>
                                <td>
                                    <a href="<?php echo e(route('laporan.show', $lap->id)); ?>" class="btn btn-xs btn-outline-primary rounded-pill px-3 py-1 fw-bold">Detail</a>
                                </td>
                            </tr>
                            <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
                        </tbody>
                    </table>
                </div>
            </div>
        </div>
    </div>
    <?php endif; ?>
</div>
<?php $__env->stopSection(); ?>

<?php echo $__env->make('layouts.app', array_diff_key(get_defined_vars(), ['__data' => 1, '__path' => 1]))->render(); ?><?php /**PATH C:\laragon\www\SIM-KITA-LLDIKTI-3\resources\views/dashboard.blade.php ENDPATH**/ ?>