<?php $__env->startSection('title', 'Wawasan & Ikhtisar Admin'); ?>
<?php $__env->startSection('page_title', 'Dasbor Analitik'); ?>

<?php $__env->startPush('css'); ?>
<style>
    /* ── DASHBOARD PREMIUM UTILITIES ── */
    :root {
        --dash-card-bg: #ffffff;
        --dash-card-border: #f1f5f9;
        --dash-primary: #4f46e5;
        --dash-success: #10b981;
        --dash-warning: #f59e0b;
        --dash-danger: #ef4444;
    }

    .welcome-banner {
        background: radial-gradient(circle at top right, #4f46e5 0%, #312e81 100%);
        border-radius: 24px;
        padding: 45px;
        position: relative;
        overflow: hidden;
        color: white;
        border: none;
        box-shadow: 0 20px 40px rgba(79, 70, 229, 0.15);
    }

    .welcome-banner-img {
        position: absolute;
        right: 0;
        bottom: 0;
        width: 300px;
        opacity: 0.15;
        pointer-events: none;
    }

    .glass-pill {
        background: rgba(255, 255, 255, 0.1);
        backdrop-filter: blur(10px);
        border: 1px solid rgba(255, 255, 255, 0.2);
        padding: 8px 20px;
        border-radius: 100px;
        font-size: 13px;
        font-weight: 700;
        display: inline-flex;
        align-items: center;
        gap: 8px;
    }

    /* STAT CARDS */
    .premium-stat {
        background: var(--dash-card-bg);
        border: 1px solid var(--dash-card-border);
        border-radius: 20px;
        padding: 24px;
        transition: all 0.4s cubic-bezier(0.16, 1, 0.3, 1);
        position: relative;
        overflow: hidden;
    }

    .premium-stat:hover {
        transform: translateY(-8px);
        box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.08);
        border-color: var(--pro-primary-light);
    }

    .stat-icon-box {
        width: 54px;
        height: 54px;
        border-radius: 16px;
        display: flex;
        align-items: center;
        justify-content: center;
        font-size: 24px;
        margin-bottom: 20px;
        transition: 0.3s;
    }

    .premium-stat:hover .stat-icon-box {
        transform: scale(1.1) rotate(-5deg);
    }

    /* CHART & TABLES */
    .dash-card-header {
        display: flex;
        align-items: center;
        justify-content: space-between;
        margin-bottom: 28px;
    }

    .dash-card-title {
        font-size: 17px;
        font-weight: 800;
        color: var(--pro-text);
        letter-spacing: -0.5px;
    }

    .table-modern thead th {
        background: #f8fafc;
        padding: 18px 20px;
        font-weight: 800;
        font-size: 11px;
        text-transform: uppercase;
        letter-spacing: 1px;
        color: #64748b;
        border: none;
    }

    .table-modern tbody td {
        padding: 20px;
        border-bottom: 1px solid #f1f5f9;
        font-size: 14px;
    }

    .product-thumb {
        width: 48px;
        height: 48px;
        border-radius: 12px;
        object-fit: cover;
        border: 2px solid #fff;
        box-shadow: 0 4px 10px rgba(0,0,0,0.05);
    }

    /* QUICK MENU */
    .quick-menu-item {
        background: #fefefe;
        border: 1px solid #f1f5f9;
        padding: 16px;
        border-radius: 16px;
        display: flex;
        align-items: center;
        gap: 14px;
        text-decoration: none;
        color: var(--pro-text);
        font-weight: 700;
        font-size: 14px;
        transition: 0.3s;
    }

    .quick-menu-item:hover {
        background: var(--pro-primary);
        color: #fff;
        transform: translateX(8px);
        box-shadow: 0 10px 20px rgba(79, 70, 229, 0.15);
        border-color: var(--pro-primary);
    }

    .quick-menu-item .icon {
        width: 36px;
        height: 36px;
        background: #f1f5f9;
        border-radius: 10px;
        display: flex;
        align-items: center;
        justify-content: center;
        font-size: 18px;
        transition: 0.3s;
    }

    .quick-menu-item:hover .icon {
        background: rgba(255,255,255,0.2);
        color: #fff;
    }
</style>
<?php $__env->stopPush(); ?>

<?php $__env->startSection('content'); ?>
<div class="row g-4 mb-4">
    <!-- Welcome Banner Professional -->
    <div class="col-12">
        <div class="welcome-banner">
            <img src="https://cdni.iconscout.com/illustration/premium/thumb/abstract-background-2735749-2280209.png" class="welcome-banner-img">
            <div class="row align-items-center position-relative" style="z-index: 2;">
                <div class="col-lg-8">
                    <div class="glass-pill mb-3">
                        <i class="ti ti-activity"></i> Sistem Operasional Aktif
                    </div>
                    <h1 class="fw-800 fs-1 mb-2">Halo, Admin Operasional! 👋</h1>
                    <p class="fs-18 opacity-75 mb-4" style="max-width: 600px;">
                        Selamat datang di hub kontrol **<?php echo e($shop_settings['shop_name'] ?? 'PrintPro'); ?>**. 
                        Berikut ringkasan performa toko Anda hari ini.
                    </p>
                    <div class="d-flex flex-wrap gap-3">
                        <a href="<?php echo e(route('admin.orders.index')); ?>" class="btn btn-white text-primary px-5 py-3 rounded-pill fw-800 shadow-sm transition-all hover-up">
                            <i class="ti ti-receipt-2 me-2"></i> Kelola Transaksi
                        </a>
                        <a href="/products/create" class="btn btn-outline-light px-5 py-3 rounded-pill fw-800 transition-all hover-up">
                            <i class="ti ti-sparkles me-2"></i> Tambah Aset Baru
                        </a>
                    </div>
                </div>
            </div>
        </div>
    </div>

    <!-- Smart Stats Grid -->
    <div class="col-lg-3 col-md-6">
        <div class="premium-stat">
            <div class="stat-icon-box bg-primary bg-opacity-10 text-primary">
                <i class="ti ti-layout-grid"></i>
            </div>
            <div>
                <span class="text-muted small fw-700 letter-spacing-1">KATEGORI</span>
                <div class="d-flex align-items-end gap-2 mt-1">
                    <h2 class="fw-800 mb-0"><?php echo e($total_categories); ?></h2>
                    <span class="text-success small fw-700 mb-1"><i class="ti ti-arrow-up-right"></i> Stabil</span>
                </div>
                <p class="text-muted fs-12 mt-2">Grup aktif dalam katalog</p>
            </div>
        </div>
    </div>

    <div class="col-lg-3 col-md-6">
        <div class="premium-stat">
            <div class="stat-icon-box bg-success bg-opacity-10 text-success">
                <i class="ti ti-box-seam"></i>
            </div>
            <div>
                <span class="text-muted small fw-700 letter-spacing-1">INVENTARIS</span>
                <div class="d-flex align-items-end gap-2 mt-1">
                    <h2 class="fw-800 mb-0"><?php echo e($total_products); ?></h2>
                    <span class="text-success small fw-700 mb-1"><i class="ti ti-package"></i> Tinggi</span>
                </div>
                <p class="text-muted fs-12 mt-2">Total produk aktif</p>
            </div>
        </div>
    </div>

    <div class="col-lg-3 col-md-6">
        <div class="premium-stat">
            <div class="stat-icon-box bg-warning bg-opacity-10 text-warning">
                <i class="ti ti-users-group"></i>
            </div>
            <div>
                <span class="text-muted small fw-700 letter-spacing-1">PELANGGAN</span>
                <div class="d-flex align-items-end gap-2 mt-1">
                    <h2 class="fw-800 mb-0"><?php echo e($total_users); ?></h2>
                    <span class="text-primary small fw-700 mb-1"><i class="ti ti-user-check"></i> Aktif</span>
                </div>
                <p class="text-muted fs-12 mt-2">User terverifikasi</p>
            </div>
        </div>
    </div>

    <div class="col-lg-3 col-md-6">
        <div class="premium-stat">
            <div class="stat-icon-box bg-danger bg-opacity-10 text-danger">
                <i class="ti ti-shield-alert"></i>
            </div>
            <div>
                <span class="text-muted small fw-700 letter-spacing-1">STOK KRITIS</span>
                <div class="d-flex align-items-end gap-2 mt-1">
                    <h2 class="fw-800 <?php echo e($low_stock_count > 0 ? 'text-danger' : ''); ?> mb-0"><?php echo e($low_stock_count); ?></h2>
                    <span class="<?php echo e($low_stock_count > 0 ? 'text-danger' : 'text-success'); ?> small fw-700 mb-1">
                        <i class="ti ti-alert-circle"></i> <?php echo e($low_stock_count > 0 ? 'Mendesak' : 'Aman'); ?>

                    </span>
                </div>
                <p class="text-muted fs-12 mt-2">Perlu segera ditambah</p>
            </div>
        </div>
    </div>

    <!-- Revenue Insights Chart -->
    <div class="col-lg-9">
        <div class="card border-0 shadow-sm rounded-4" style="background: #fff; border: 1px solid #f1f5f9 !important;">
            <div class="card-body p-5">
                <div class="dash-card-header">
                    <div>
                        <h5 class="dash-card-title">Analitik Komersial</h5>
                        <span class="text-muted small fw-600">Monitor performa pendapatan</span>
                    </div>
                    <div class="d-flex gap-2">
                        <button class="btn btn-light btn-sm fw-800 px-3 border">Mingguan</button>
                        <button class="btn btn-outline-primary btn-sm fw-800 px-3 border shadow-none">Pandangan Bulanan</button>
                    </div>
                </div>
                <div id="salesChart"></div>
            </div>
        </div>
    </div>

    <!-- Quick Navigation Center -->
    <div class="col-lg-3">
        <div class="card border-0 shadow-sm rounded-4 h-100" style="background: #f8fafc; border: 1px solid #f1f5f9 !important;">
            <div class="card-body p-4">
                <h5 class="fw-800 fs-16 mb-4">Pusat Komando</h5>
                
                <div class="d-grid gap-3">
                    <a href="/products/create" class="quick-menu-item">
                        <div class="icon"><i class="ti ti-plus"></i></div>
                        <span>Tambah Produk Baru</span>
                    </a>
                    <a href="/categories/create" class="quick-menu-item">
                        <div class="icon"><i class="ti ti-category"></i></div>
                        <span>Kategori Baru</span>
                    </a>
                    <a href="<?php echo e(route('admin.orders.index')); ?>" class="quick-menu-item">
                        <div class="icon"><i class="ti ti-list-check"></i></div>
                        <span>Papan Pesanan</span>
                    </a>
                    <a href="/settings" class="quick-menu-item">
                        <div class="icon"><i class="ti ti-settings"></i></div>
                        <span>Konfigurasi Global</span>
                    </a>
                </div>

                <div class="mt-5 p-4 rounded-4 bg-white border">
                    <div class="d-flex align-items-center gap-3 mb-3">
                        <div class="p-2 bg-success bg-opacity-10 text-success rounded-circle">
                            <i class="ti ti-shield-check fs-4"></i>
                        </div>
                        <h6 class="fw-800 mb-0 fs-14">Sistem Aman</h6>
                    </div>
                    <p class="fs-12 text-muted fw-600 line-height-sm mb-0">Database sehat. Cadangan otomatis terakhir dilakukan 14 menit yang lalu.</p>
                </div>
            </div>
        </div>
    </div>

    <!-- Recent Inventory Feed -->
    <div class="col-12 mb-5">
        <div class="card border-0 shadow-sm rounded-4 overflow-hidden">
            <div class="card-header bg-white border-bottom-0 pt-4 px-5 d-flex align-items-center justify-content-between">
                <div>
                    <h5 class="fw-800 mb-0">Aliran Inventaris Operasional</h5>
                    <span class="text-muted small fw-600">Penambahan aset terbaru dan status stok</span>
                </div>
                <a href="/products" class="btn btn-light px-4 py-2 rounded-3 fw-800 fs-13 border">Audit Seluruh Katalog</a>
            </div>
            <div class="card-body p-0">
                <div class="table-responsive">
                    <table class="table table-modern align-middle mb-0">
                        <thead>
                            <tr>
                                <th>IDENTIFIKASI & ASET</th>
                                <th>TAG KATEGORI</th>
                                <th>NILAI SATUAN</th>
                                <th>STOK TERSEDIA</th>
                                <th class="text-center">MANAJEMEN</th>
                            </tr>
                        </thead>
                        <tbody>
                            <?php $__empty_1 = true; $__currentLoopData = $recent_products; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $rp): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); $__empty_1 = false; ?>
                            <tr>
                                <td>
                                    <div class="d-flex align-items-center gap-3">
                                        <?php if($rp->image): ?>
                                            <img src="<?php echo e(asset('storage/'.$rp->image)); ?>" class="product-thumb">
                                        <?php else: ?>
                                            <div class="product-thumb bg-light d-flex align-items-center justify-content-center">
                                                <i class="ti ti-photo-off text-muted"></i>
                                            </div>
                                        <?php endif; ?>
                                        <div>
                                            <div class="fw-800 text-dark"><?php echo e($rp->name); ?></div>
                                            <div class="text-muted fw-600" style="font-size: 11px;">REF: PRD-<?php echo e(str_pad($rp->id, 5, '0', STR_PAD_LEFT)); ?></div>
                                        </div>
                                    </div>
                                </td>
                                <td>
                                    <span class="badge bg-primary bg-opacity-10 text-primary fw-800 px-3 py-2 rounded-pill fs-11">
                                        <?php echo e($rp->category->name); ?>

                                    </span>
                                </td>
                                <td>
                                    <div class="fw-800 text-dark fs-15">Rp <?php echo e(number_format($rp->price, 0, ',', '.')); ?></div>
                                </td>
                                <td>
                                    <?php 
                                        $stockPct = min(($rp->stock / 50) * 100, 100);
                                        $stockColor = $rp->stock <= 5 ? 'bg-danger' : 'bg-success';
                                    ?>
                                    <div class="d-flex align-items-center gap-3">
                                        <div class="progress flex-grow-1" style="height: 8px; width: 80px; border-radius: 10px; background: #f1f5f9;">
                                            <div class="progress-bar <?php echo e($stockColor); ?>" style="width: <?php echo e($stockPct); ?>%; border-radius: 10px;"></div>
                                        </div>
                                        <span class="fw-800 <?php echo e($rp->stock <= 5 ? 'text-danger' : 'text-success'); ?> fs-14"><?php echo e($rp->stock); ?></span>
                                    </div>
                                </td>
                                <td class="text-center">
                                    <div class="dropdown">
                                        <button class="btn btn-light bg-transparent border-0 rounded-circle p-2" type="button" data-bs-toggle="dropdown">
                                            <i class="ti ti-dots-vertical fs-14"></i>
                                        </button>
                                        <ul class="dropdown-menu dropdown-menu-end p-2 border-0 shadow-lg animate-pro" style="border-radius: 16px;">
                                            <li><a class="dropdown-item rounded-3 py-2 fw-700 fs-13" href="<?php echo e(route('products.edit', $rp)); ?>"><i class="ti ti-edit-circle me-2"></i> Perbarui Aset</a></li>
                                            <li><hr class="dropdown-divider opacity-50"></li>
                                            <li>
                                                <form action="<?php echo e(route('products.destroy', $rp)); ?>" method="POST" onsubmit="return confirm('BAHAYA: Penghapusan permanen akan terjadi. Lanjutkan?')">
                                                    <?php echo csrf_field(); ?>
                                                    <?php echo method_field('DELETE'); ?>
                                                    <button type="submit" class="dropdown-item rounded-3 py-2 fw-700 fs-13 text-danger">
                                                        <i class="ti ti-trash-x me-2"></i> Hapus Data
                                                    </button>
                                                </form>
                                            </li>
                                        </ul>
                                    </div>
                                </td>
                            </tr>
                            <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); if ($__empty_1): ?>
                            <tr>
                                <td colspan="5" class="text-center py-5">
                                    <div class="py-5 opacity-50">
                                        <i class="ti ti-package-off fs-1"></i>
                                        <p class="fw-700 mt-2">Data Operasional Tidak Tersedia</p>
                                    </div>
                                </td>
                            </tr>
                            <?php endif; ?>
                        </tbody>
                    </table>
                </div>
            </div>
        </div>
    </div>
</div>

<?php $__env->startPush('js'); ?>
<script src="<?php echo e(asset('assets/libs/apexcharts/dist/apexcharts.min.js')); ?>"></script>
<script>
    document.addEventListener("DOMContentLoaded", function() {
        var options = {
            chart: {
                type: 'area',
                height: 350,
                toolbar: { show: false },
                foreColor: '#94a3b8',
                fontFamily: "'Plus Jakarta Sans', sans-serif",
                sparkline: { enabled: false }
            },
            dataLabels: { enabled: false },
            stroke: { 
                curve: 'smooth', 
                width: 4,
                colors: ["#4f46e5"]
            },
            fill: {
                type: "gradient",
                gradient: {
                    shadeIntensity: 1,
                    opacityFrom: 0.45,
                    opacityTo: 0.05,
                    stops: [0, 90, 100]
                }
            },
            markers: {
                size: 6,
                colors: ["#4f46e5"],
                strokeColors: "#fff",
                strokeWidth: 4,
                hover: { size: 8 }
            },
            colors: ["#4f46e5"],
            series: [{
                name: 'Pendapatan Bersih',
                data: <?php echo json_encode($chart_data, 15, 512) ?>
            }],
            xaxis: {
                categories: <?php echo json_encode($chart_labels, 15, 512) ?>,
                axisBorder: { show: false },
                axisTicks: { show: false },
                labels: { style: { fontWeight: 800, fontSize: '11px' } }
            },
            yaxis: {
                labels: {
                    style: { fontWeight: 800 },
                    formatter: function(val) {
                        return "Rp " + val.toLocaleString('id-ID');
                    }
                }
            },
            grid: {
                borderColor: "#f1f5f9",
                strokeDashArray: 6,
                padding: { left: 20, right: 20 }
            },
            tooltip: { 
                theme: "light",
                x: { show: true },
                y: {
                    formatter: function(val) {
                        return "Rp " + val.toLocaleString('id-ID');
                    }
                },
                style: { fontSize: '12px', fontWeight: 800 }
            }
        };

        var chart = new ApexCharts(document.querySelector("#salesChart"), options);
        chart.render();
    });
</script>
<?php $__env->stopPush(); ?>
<?php $__env->stopSection(); ?>
<?php echo $__env->make('layout.app', array_diff_key(get_defined_vars(), ['__data' => 1, '__path' => 1]))->render(); ?><?php /**PATH C:\laragon\www\jasa_printer\resources\views/layout/dashboard.blade.php ENDPATH**/ ?>