<?php $__env->startSection('title', 'Dashboard - Sistem Distribusi Qurban'); ?>

<?php $__env->startSection('header_title', 'Ringkasan Distribusi'); ?>
<?php $__env->startSection('header_subtitle', 'Pantau status penyaluran daging qurban secara real-time'); ?>

<?php $__env->startSection('content'); ?>
<!-- KPI Stat Grid -->
<div class="kpi-grid">
    <div class="kpi-card" style="border-bottom: 4px solid var(--primary);">
        <div class="kpi-card-icon">👥</div>
        <div class="kpi-card-info">
            <span class="kpi-card-value"><?php echo e(number_format($totalParticipants)); ?></span>
            <span class="kpi-card-label">Total Penerima</span>
        </div>
    </div>

    <div class="kpi-card" style="border-bottom: 4px solid var(--success);">
        <div class="kpi-card-icon" style="background-color: var(--success-bg); color: var(--success);">✅</div>
        <div class="kpi-card-info">
            <span class="kpi-card-value"><?php echo e(number_format($totalDistributed)); ?></span>
            <span class="kpi-card-label">Sudah Diambil</span>
        </div>
    </div>

    <div class="kpi-card" style="border-bottom: 4px solid var(--info);">
        <div class="kpi-card-icon" style="background-color: var(--info-bg); color: var(--info);">📦</div>
        <div class="kpi-card-info">
            <span class="kpi-card-value"><?php echo e(number_format($totalEntrusted)); ?></span>
            <span class="kpi-card-label">Paket Dititipkan</span>
        </div>
    </div>

    <div class="kpi-card" style="border-bottom: 4px solid var(--danger);">
        <div class="kpi-card-icon" style="background-color: var(--danger-bg); color: var(--danger);">⏳</div>
        <div class="kpi-card-info">
            <span class="kpi-card-value"><?php echo e(number_format($totalBelum)); ?></span>
            <span class="kpi-card-label">Belum Diambil</span>
        </div>
    </div>
</div>

<!-- Secondary Widgets Row -->
<div class="dashboard-row">
    <!-- Recent Activity -->
    <div class="panel">
        <div class="panel-header">
            <h2 class="panel-title"><span>🕒</span> Aktivitas Distribusi Terbaru</h2>
            <a href="<?php echo e(route('distribution.index')); ?>" class="btn btn-secondary btn-sm">Lihat Semua</a>
        </div>

        <?php if($recentDistributions->isEmpty()): ?>
            <div style="text-align: center; padding: 3rem 0; color: var(--text-muted);">
                <span style="font-size: 3rem; display: block; margin-bottom: 1rem;">🐏</span>
                Belum ada transaksi distribusi saat ini.
            </div>
        <?php else: ?>
            <div class="table-wrapper">
                <table class="table-custom">
                    <thead>
                        <tr>
                            <th>No. Kupon</th>
                            <th>Nama Penerima</th>
                            <th>Status</th>
                            <th>Waktu Distribusi</th>
                        </tr>
                    </thead>
                    <tbody>
                        <?php $__currentLoopData = $recentDistributions; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $dist): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                            <tr>
                                <td style="font-weight: 700; color: var(--primary-dark);"><?php echo e($dist->participant->no_kupon); ?></td>
                                <td><?php echo e($dist->participant->nama); ?></td>
                                <td>
                                    <?php if($dist->status === 'Sudah'): ?>
                                        <span class="badge badge-success">Sudah Diambil</span>
                                    <?php elseif($dist->status === 'Titip'): ?>
                                        <span class="badge badge-info">Dititipkan</span>
                                    <?php else: ?>
                                        <span class="badge badge-warning">Belum</span>
                                    <?php endif; ?>
                                </td>
                                <td>
                                    <span style="font-size: 0.85rem; color: var(--text-muted);">
                                        <?php echo e($dist->updated_at->diffForHumans()); ?>

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

    <!-- Right Sidebar Widgets -->
    <div style="display: flex; flex-direction: column; gap: 1.5rem;">
        <!-- Titipan workflow progress -->
        <div class="panel" style="flex-grow: 1;">
            <h2 class="panel-title" style="margin-bottom: 1.25rem;"><span>📦</span> Alur Titipan Paket</h2>
            <div style="display: flex; flex-direction: column; gap: 1rem;">
                <div>
                    <div style="display: flex; justify-content: space-between; font-size: 0.85rem; font-weight: 600; margin-bottom: 0.35rem;">
                        <span>Pending (Baru)</span>
                        <span style="color: var(--warning);"><?php echo e($titipPending); ?> Paket</span>
                    </div>
                    <div style="height: 8px; background-color: var(--border); border-radius: 4px; overflow: hidden;">
                        <div style="height: 100%; background-color: var(--warning); width: <?php echo e($totalEntrusted > 0 ? ($titipPending / $totalEntrusted) * 100 : 0); ?>%;"></div>
                    </div>
                </div>

                <div>
                    <div style="display: flex; justify-content: space-between; font-size: 0.85rem; font-weight: 600; margin-bottom: 0.35rem;">
                        <span>Sedang Diproses</span>
                        <span style="color: var(--info);"><?php echo e($titipDiproses); ?> Paket</span>
                    </div>
                    <div style="height: 8px; background-color: var(--border); border-radius: 4px; overflow: hidden;">
                        <div style="height: 100%; background-color: var(--info); width: <?php echo e($totalEntrusted > 0 ? ($titipDiproses / $totalEntrusted) * 100 : 0); ?>%;"></div>
                    </div>
                </div>

                <div>
                    <div style="display: flex; justify-content: space-between; font-size: 0.85rem; font-weight: 600; margin-bottom: 0.35rem;">
                        <span>Sudah Diambil (Selesai)</span>
                        <span style="color: var(--success);"><?php echo e($titipSelesai); ?> Paket</span>
                    </div>
                    <div style="height: 8px; background-color: var(--border); border-radius: 4px; overflow: hidden;">
                        <div style="height: 100%; background-color: var(--success); width: <?php echo e($totalEntrusted > 0 ? ($titipSelesai / $totalEntrusted) * 100 : 0); ?>%;"></div>
                    </div>
                </div>
            </div>
            
            <a href="<?php echo e(route('titip.index')); ?>" class="btn btn-secondary btn-sm" style="margin-top: 1.5rem; justify-content: center;">
                Kelola Titipan ➔
            </a>
        </div>

        <!-- Jatah RT Status -->
        <div class="panel">
            <h2 class="panel-title" style="margin-bottom: 1rem;"><span>👥</span> Jatah RT / Kelompok</h2>
            <div style="display: flex; align-items: center; justify-content: space-between; margin-bottom: 1rem;">
                <div style="text-align: center; flex: 1; border-right: 1px solid var(--border);">
                    <span style="font-size: 1.5rem; font-weight: 700; color: var(--success);"><?php echo e($jatahDiambil); ?></span>
                    <span style="display: block; font-size: 0.75rem; color: var(--text-muted); font-weight: 600;">DIAMBIL</span>
                </div>
                <div style="text-align: center; flex: 1;">
                    <span style="font-size: 1.5rem; font-weight: 700; color: var(--danger);"><?php echo e($jatahBelum); ?></span>
                    <span style="display: block; font-size: 0.75rem; color: var(--text-muted); font-weight: 600;">BELUM</span>
                </div>
            </div>
            <div style="font-size: 0.85rem; color: var(--text-muted); text-align: center; margin-bottom: 1rem;">
                Total ada <strong><?php echo e($totalJatah); ?> kelompok/RT</strong> terdaftar.
            </div>
            <a href="<?php echo e(route('jatah.index')); ?>" class="btn btn-primary btn-sm" style="justify-content: center;">
                Rincian Jatah Kelompok
            </a>
        </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 /Users/sagara/Projects/distribusi-apps/resources/views/dashboard.blade.php ENDPATH**/ ?>