

<?php $__env->startSection('title', 'Dashboard Utama Admin'); ?>
<?php $__env->startSection('page_heading', 'Panel Kendali Operasional Toko (CRM Basis Tindakan)'); ?>

<?php $__env->startSection('content'); ?>
<div class="space-y-6">

    <!-- 1. KARTU STATISTIK UTAMA (Beban Kerja CS & Transaksi) -->
    <div class="grid grid-cols-1 md:grid-cols-2 lg:grid-cols-5 gap-4">

        <div class="bg-white border border-gray-200 rounded-xl p-5 shadow-sm">
            <span class="text-[10px] font-bold text-gray-400 uppercase block tracking-wider">Pesanan Masuk</span>
            <span class="text-2xl font-black text-gray-900 block mt-1"><?php echo e($pesananMasuk); ?></span>
            <span class="text-[10px] text-amber-600 font-semibold block mt-1">⏳ Menunggu Tindakan</span>
        </div>

        <div class="bg-white border border-gray-200 rounded-xl p-5 shadow-sm">
            <span class="text-[10px] font-bold text-gray-400 uppercase block tracking-wider">Kritis Verifikasi</span>
            <span class="text-2xl font-black text-red-600 block mt-1"><?php echo e($menungguVerifikasi); ?></span>
            <span class="text-[10px] text-gray-400 font-medium block mt-1">📂 Struk Sudah Upload</span>
        </div>

        <div class="bg-white border border-gray-200 rounded-xl p-5 shadow-sm">
            <span class="text-[10px] font-bold text-gray-400 uppercase block tracking-wider">Keluhan Terbuka</span>
            <span class="text-2xl font-black text-amber-600 block mt-1"><?php echo e($keluhanTerbuka); ?></span>
            <span class="text-[10px] text-red-500 font-bold block mt-1">⚠️ Komplain Pelanggan</span>
        </div>

        <div class="bg-white border border-gray-200 rounded-xl p-5 shadow-sm">
            <span class="text-[10px] font-bold text-gray-400 uppercase block tracking-wider">Chat CS Antrean</span>
            <span class="text-2xl font-black text-blue-600 block mt-1"><?php echo e($chatBelumDibalas); ?></span>
            <span class="text-[10px] text-blue-500 font-semibold block mt-1">📥 Belum Dibalas</span>
        </div>

        <div class="bg-white border border-gray-200 rounded-xl p-5 shadow-sm">
            <span class="text-[10px] font-bold text-gray-400 uppercase block tracking-wider">Stok Menipis</span>
            <span class="text-2xl font-black text-gray-900 block mt-1"><?php echo e($stokMenipis); ?></span>
            <span class="text-[10px] text-red-500 font-bold block mt-1">🚨 Di Bawah 10 Unit</span>
        </div>

    </div>

    <!-- SECTION DUA KOLOM: TINDAKAN & GRAFIK OMSET -->
    <div class="grid grid-cols-1 lg:grid-cols-3 gap-6 items-start">

        <!-- SISI KIRI: TABEL TINDAKAN SEGERA (ANTREAN TRANSAKSI CRITICAL) -->
        <div class="bg-white border border-gray-200 rounded-xl shadow-sm overflow-hidden lg:col-span-2">
            <div class="px-6 py-4 border-b border-gray-200 bg-gray-50">
                <h3 class="font-bold text-gray-800 text-sm">Antrean Transaksi Perlu Tindakan Segera</h3>
            </div>
            <div class="overflow-x-auto">
                <table class="w-full text-left text-xs text-gray-600">
                    <thead class="bg-gray-100 text-[10px] text-gray-700 uppercase font-bold border-b border-gray-200">
                        <tr>
                            <th class="px-6 py-3">ID Nota</th>
                            <th class="px-6 py-3">Pelanggan</th>
                            <th class="px-6 py-3 text-right">Total Bayar</th>
                            <th class="px-6 py-3 text-center">Tindakan</th>
                        </tr>
                    </thead>
                    <tbody class="divide-y divide-gray-200 font-medium text-gray-900">
                        <?php $__empty_1 = true; $__currentLoopData = $antreanTransaksis; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $antrean): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); $__empty_1 = false; ?>
                        <tr class="hover:bg-gray-50/80">
                            <td class="px-6 py-4 font-mono font-bold text-blue-600">#TRX-<?php echo e($antrean->id); ?></td>
                            <td class="px-6 py-4"><?php echo e($antrean->pelanggan->nama); ?></td>
                            <td class="px-6 py-4 text-right font-bold">Rp <?php echo e(number_format($antrean->total_bayar, 0, ',', '.')); ?></td>
                            <td class="px-6 py-4 text-center">
                                <a href="<?php echo e(route('admin.transaksi.periksa', $antrean->id)); ?>" class="inline-block bg-blue-600 text-white font-black px-3 py-1.5 rounded-lg text-[10px] shadow-sm hover:bg-blue-700 transition">
                                    ⚡ Periksa Struk
                                </a>
                            </td>
                        </tr>
                        <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); if ($__empty_1): ?>
                        <tr>
                            <td colspan="4" class="px-6 py-8 text-center text-gray-400 font-medium">
                                🏖️ Bagus! Tidak ada antrean transaksi baru yang tertahan hari ini.
                            </td>
                        </tr>
                        <?php endif; ?>
                    </tbody>
                </table>
            </div>
        </div>

        <!-- SISI KANAN: GRAFIK TREN OMSET PENJUALAN MURNI CSS & HTML -->
        <div class="bg-white border border-gray-200 rounded-xl p-6 shadow-sm flex flex-col justify-between min-h-[300px]">
            <div>
                <h3 class="font-bold text-gray-800 text-sm">Grafik Tren Penjualan Harian</h3>
                <p class="text-[11px] text-gray-400 font-medium mb-4">Akumulasi nominal rupiah seminggu terakhir</p>
            </div>

            <!-- Kontainer Grafik Batang Flexbox -->
            <div class="flex items-end justify-between h-44 pt-6 px-4 bg-slate-50 border border-slate-100 rounded-xl w-full">
                <?php $__currentLoopData = $trenPesanan; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $data): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                <?php
                // Hitung tinggi batang secara aman dari pembagian nol
                $persenTinggi = $maxPesanan > 1 ? ($data['jumlah'] / $maxPesanan) * 100 : 0;
                // Maksimalkan batas bawah agar batang 0 rupiah tetap kelihatan setebal 4px
                $tinggiFinal = $data['jumlah'] > 0 ? max($persenTinggi, 8) : 4;
                ?>
                <div class="flex flex-col items-center flex-1 group relative">

                    <!-- Pop-up Tooltip Angka Rupiah Saat Di-hover Kursor -->
                    <div class="absolute bottom-full mb-2 bg-slate-900 text-white text-[9px] font-black px-2 py-1 rounded shadow-md opacity-0 group-hover:opacity-100 transition-opacity duration-200 pointer-events-none z-20 whitespace-nowrap">
                        Rp <?php echo e(number_format($data['jumlah'], 0, ',', '.')); ?>

                    </div>

                    <!-- Batang CSS Batang Grafik -->
                    <div style="height: <?php echo e($tinggiFinal); ?>px;"
                        class="w-6 <?php echo e($data['jumlah'] > 0 ? 'bg-blue-600 group-hover:bg-blue-700' : 'bg-gray-200'); ?> rounded-t transition-all duration-500 shadow-sm">
                    </div>

                    <!-- Singkatan Nama Hari -->
                    <span class="text-[9px] text-gray-400 font-bold mt-2 pb-1 block uppercase">
                        <?php echo e(substr($data['hari'], 0, 3)); ?>

                    </span>
                </div>
                <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
            </div>
        </div>

    </div>
</div>
<?php $__env->stopSection(); ?>
<?php echo $__env->make('layouts.backend', array_diff_key(get_defined_vars(), ['__data' => 1, '__path' => 1]))->render(); ?><?php /**PATH D:\SKRIPSI CRM 2026 II\PROGRAM CRM MEGA MART\megamart-crm\resources\views/admin/dashboard.blade.php ENDPATH**/ ?>