<?php if (isset($component)) { $__componentOriginal9ac128a9029c0e4701924bd2d73d7f54 = $component; } ?>
<?php if (isset($attributes)) { $__attributesOriginal9ac128a9029c0e4701924bd2d73d7f54 = $attributes; } ?>
<?php $component = App\View\Components\AppLayout::resolve([] + (isset($attributes) && $attributes instanceof Illuminate\View\ComponentAttributeBag ? $attributes->all() : [])); ?>
<?php $component->withName('app-layout'); ?>
<?php if ($component->shouldRender()): ?>
<?php $__env->startComponent($component->resolveView(), $component->data()); ?>
<?php if (isset($attributes) && $attributes instanceof Illuminate\View\ComponentAttributeBag): ?>
<?php $attributes = $attributes->except(\App\View\Components\AppLayout::ignoredParameterNames()); ?>
<?php endif; ?>
<?php $component->withAttributes([]); ?>
     <?php $__env->slot('header', null, []); ?> 
        <div class="flex justify-between items-center">
             <h2 class="font-bold text-2xl text-gray-800 dark:text-gray-200 leading-tight">
                <?php echo e(__('Admin Command Center')); ?>

            </h2>
            <span class="text-sm text-gray-500 dark:text-gray-400 hidden sm:block">Welcome back, <?php echo e(Auth::user()->name); ?></span>
        </div>
     <?php $__env->endSlot(); ?>

    <div class="py-12 bg-gray-50 dark:bg-gray-900 min-h-screen">
        <div class="max-w-7xl mx-auto sm:px-6 lg:px-8 space-y-8">
            
            <!-- Financial Stats Row (Live Data) -->
            <div class="grid grid-cols-1 md:grid-cols-2 lg:grid-cols-4 gap-6 px-4 sm:px-0">
                <!-- Total Income -->
                <div class="bg-white dark:bg-gray-800 overflow-hidden shadow-lg rounded-2xl p-6 border-b-4 border-emerald-500 transition-all duration-300 hover:-translate-y-1 hover:shadow-2xl">
                    <div class="flex items-center justify-between">
                        <div>
                            <p class="text-sm font-medium text-gray-500 dark:text-gray-400">Total Income</p>
                            <h3 class="text-2xl font-bold text-gray-800 dark:text-white">Rs. <?php echo e(number_format($totalIncome, 2)); ?></h3>
                        </div>
                        <div class="p-3 rounded-full bg-emerald-100 dark:bg-emerald-500/20 text-emerald-600 dark:text-emerald-300">
                             <svg class="w-6 h-6" fill="none" stroke="currentColor" viewBox="0 0 24 24"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M12 8c-1.657 0-3 .895-3 2s1.343 2 3 2 3 .895 3 2-1.343 2-3 2m0-8c1.11 0 2.08.402 2.599 1M12 8V7m0 1v8m0 0v1m0-1c-1.11 0-2.08-.402-2.599-1M21 12a9 9 0 11-18 0 9 9 0 0118 0z"></path></svg>
                        </div>
                    </div>
                     <p class="text-xs text-gray-400 mt-2">All collected revenue</p>
                </div>

                <!-- Pending Cash -->
                <div class="bg-white dark:bg-gray-800 overflow-hidden shadow-lg rounded-2xl p-6 border-b-4 border-amber-500 cursor-pointer transition-all duration-300 hover:-translate-y-1 hover:shadow-2xl hover:bg-gray-50 dark:hover:bg-gray-700" onclick="window.location='<?php echo e(route('admin.reports.cash-collections')); ?>'">
                    <div class="flex items-center justify-between">
                        <div>
                            <p class="text-sm font-medium text-gray-500 dark:text-gray-400">Pending Cash</p>
                            <h3 class="text-2xl font-bold text-gray-800 dark:text-white">Rs. <?php echo e(number_format($netPendingCash, 2)); ?></h3>
                        </div>
                        <div class="p-3 rounded-full bg-amber-100 dark:bg-amber-500/20 text-amber-600 dark:text-amber-300">
                             <svg class="w-6 h-6" fill="none" stroke="currentColor" viewBox="0 0 24 24"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M17 9V7a2 2 0 00-2-2H5a2 2 0 00-2 2v6a2 2 0 002 2h2m2 4h10a2 2 0 002-2v-6a2 2 0 00-2-2H9a2 2 0 00-2 2v6a2 2 0 002 2zm7-5a2 2 0 11-4 0 2 2 0 014 0z"></path></svg>
                        </div>
                    </div>
                    <p class="text-xs text-amber-500 mt-2">To be remitted by Reps</p>
                </div>

                <!-- Pending Cheques -->
                <div class="bg-white dark:bg-gray-800 overflow-hidden shadow-lg rounded-2xl p-6 border-b-4 border-blue-500 cursor-pointer transition-all duration-300 hover:-translate-y-1 hover:shadow-2xl hover:bg-gray-50 dark:hover:bg-gray-700" onclick="window.location='<?php echo e(route('admin.reports.cheques')); ?>'">
                    <div class="flex items-center justify-between">
                        <div>
                            <p class="text-sm font-medium text-gray-500 dark:text-gray-400">Cheques on Hand</p>
                            <h3 class="text-2xl font-bold text-gray-800 dark:text-white">Rs. <?php echo e(number_format($pendingCheques, 2)); ?></h3>
                        </div>
                        <div class="p-3 rounded-full bg-blue-100 dark:bg-blue-500/20 text-blue-600 dark:text-blue-300">
                             <svg class="w-6 h-6" fill="none" stroke="currentColor" viewBox="0 0 24 24"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M9 12h6m-6 4h6m2 5H7a2 2 0 01-2-2V5a2 2 0 012-2h5.586a1 1 0 01.707.293l5.414 5.414a1 1 0 01.293.707V19a2 2 0 01-2 2z"></path></svg>
                        </div>
                    </div>
                    <p class="text-xs text-blue-500 mt-2">Pending Realization</p>
                </div>

                <!-- Credit Sales -->
                <div class="bg-white dark:bg-gray-800 overflow-hidden shadow-lg rounded-2xl p-6 border-b-4 border-rose-500 cursor-pointer transition-all duration-300 hover:-translate-y-1 hover:shadow-2xl hover:bg-gray-50 dark:hover:bg-gray-700" onclick="window.location='<?php echo e(route('admin.reports.due-balances')); ?>'">
                    <div class="flex items-center justify-between">
                        <div>
                            <p class="text-sm font-medium text-gray-500 dark:text-gray-400">Credit Sales</p>
                            <h3 class="text-2xl font-bold text-gray-800 dark:text-white">Rs. <?php echo e(number_format($totalCredit, 2)); ?></h3>
                        </div>
                        <div class="p-3 rounded-full bg-rose-100 dark:bg-rose-500/20 text-rose-600 dark:text-rose-300">
                             <svg class="w-6 h-6" fill="none" stroke="currentColor" viewBox="0 0 24 24"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M12 8v4m0 4h.01M21 12a9 9 0 11-18 0 9 9 0 0118 0z"></path></svg>
                        </div>
                    </div>
                    <p class="text-xs text-rose-500 mt-2">Outstanding Dues from Customers</p>
                </div>
            </div>

            <!-- Management Links Row -->
            <div class="grid grid-cols-1 md:grid-cols-2 lg:grid-cols-4 gap-6 px-4 sm:px-0">
                <!-- Card 1 -->
                <div class="bg-white dark:bg-gray-800 overflow-hidden shadow-xl rounded-2xl p-6 border-l-4 border-indigo-500 hover:shadow-2xl transition-all duration-300 group cursor-pointer" onclick="window.location='<?php echo e(route('admin.products.index')); ?>'">
                    <div class="flex items-center">
                        <div class="p-4 rounded-full bg-indigo-50 dark:bg-indigo-900/50 text-indigo-600 dark:text-indigo-400 group-hover:scale-110 transition-transform">
                             <svg class="w-8 h-8" fill="none" stroke="currentColor" viewBox="0 0 24 24"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M20 7l-8-4-8 4m16 0l-8 4m8-4v10l-8 4m0-10L4 7m8 4v10M4 7v10l8 4"></path></svg>
                        </div>
                        <div class="ml-4">
                            <p class="text-sm font-medium text-gray-500 dark:text-gray-400">Inventory</p>
                            <h3 class="text-lg font-bold text-gray-800 dark:text-white group-hover:text-indigo-600 transition-colors">Products</h3>
                        </div>
                    </div>
                </div>

                <!-- Card 2 -->
                <div class="bg-white dark:bg-gray-800 overflow-hidden shadow-xl rounded-2xl p-6 border-l-4 border-emerald-500 hover:shadow-2xl transition-all duration-300 group cursor-pointer" onclick="window.location='<?php echo e(route('admin.reps.index')); ?>'">
                    <div class="flex items-center">
                        <div class="p-4 rounded-full bg-emerald-50 dark:bg-emerald-900/50 text-emerald-600 dark:text-emerald-400 group-hover:scale-110 transition-transform">
                             <svg class="w-8 h-8" fill="none" stroke="currentColor" viewBox="0 0 24 24"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M17 20h5v-2a3 3 0 00-5.356-1.857M17 20H7m10 0v-2c0-.656-.126-1.283-.356-1.857M7 20H2v-2a3 3 0 015.356-1.857M7 20v-2c0-.656.126-1.283.356-1.857m0 0a5.002 5.002 0 019.288 0M15 7a3 3 0 11-6 0 3 3 0 016 0zm6 3a2 2 0 11-4 0 2 2 0 014 0zM7 10a2 2 0 11-4 0 2 2 0 014 0z"></path></svg>
                        </div>
                         <div class="ml-4">
                            <p class="text-sm font-medium text-gray-500 dark:text-gray-400">Sales Force</p>
                            <h3 class="text-lg font-bold text-gray-800 dark:text-white group-hover:text-emerald-600 transition-colors">Team Members</h3>
                        </div>
                    </div>
                </div>

                <!-- Card Reports -->
                <div class="bg-white dark:bg-gray-800 overflow-hidden shadow-xl rounded-2xl p-6 border-l-4 border-purple-500 hover:shadow-2xl transition-all duration-300 group cursor-pointer" onclick="window.location='<?php echo e(route('admin.reports.due-balances')); ?>'">
                    <div class="flex items-center">
                        <div class="p-4 rounded-full bg-purple-50 dark:bg-purple-900/50 text-purple-600 dark:text-purple-400 group-hover:scale-110 transition-transform">
                             <svg class="w-8 h-8" fill="none" stroke="currentColor" viewBox="0 0 24 24"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M9 19v-6a2 2 0 00-2-2H5a2 2 0 00-2 2v6a2 2 0 002 2h2a2 2 0 002-2zm0 0V9a2 2 0 012-2h2a2 2 0 012 2v10m-6 0a2 2 0 002 2h2a2 2 0 002-2m0 0V5a2 2 0 012-2h2a2 2 0 012 2v14a2 2 0 01-2 2h-2a2 2 0 01-2-2z"></path></svg>
                        </div>
                         <div class="ml-4">
                            <p class="text-sm font-medium text-gray-500 dark:text-gray-400">Financial Insights</p>
                            <h3 class="text-lg font-bold text-gray-800 dark:text-white group-hover:text-purple-600 transition-colors">Reports & Dues</h3>
                        </div>
                    </div>
                </div>

                <!-- Card 3 -->
                <div class="bg-white dark:bg-gray-800 overflow-hidden shadow-xl rounded-2xl p-6 border-l-4 border-amber-500 hover:shadow-2xl transition-all duration-300 group cursor-pointer" onclick="window.location='<?php echo e(route('admin.expenses.index')); ?>'">
                    <div class="flex items-center">
                        <div class="p-4 rounded-full bg-amber-50 dark:bg-amber-900/50 text-amber-600 dark:text-amber-400 group-hover:scale-110 transition-transform">
                             <svg class="w-8 h-8" fill="none" stroke="currentColor" viewBox="0 0 24 24"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M12 8c-1.657 0-3 .895-3 2s1.343 2 3 2 3 .895 3 2-1.343 2-3 2m0-8c1.11 0 2.08.402 2.599 1M12 8V7m0 1v8m0 0v1m0-1c-1.11 0-2.08-.402-2.599-1M21 12a9 9 0 11-18 0 9 9 0 0118 0z"></path></svg>
                        </div>
                         <div class="ml-4">
                            <p class="text-sm font-medium text-gray-500 dark:text-gray-400">Financials</p>
                            <h3 class="text-lg font-bold text-gray-800 dark:text-white group-hover:text-amber-600 transition-colors">Approvals</h3>
                        </div>
                    </div>
                </div>

                <!-- Card 4 -->
                <div class="bg-white dark:bg-gray-800 overflow-hidden shadow-xl rounded-2xl p-6 border-l-4 border-rose-500 hover:shadow-2xl transition-all duration-300 group cursor-pointer" onclick="window.location='<?php echo e(route('admin.inventory.index')); ?>'">
                    <div class="flex items-center">
                        <div class="p-4 rounded-full bg-rose-50 dark:bg-rose-900/50 text-rose-600 dark:text-rose-400 group-hover:scale-110 transition-transform">
                             <svg class="w-8 h-8" fill="none" stroke="currentColor" viewBox="0 0 24 24"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M9 17v-2m3 2v-4m3 4v-6m2 10H7a2 2 0 01-2-2V5a2 2 0 012-2h5.586a1 1 0 01.707.293l5.414 5.414a1 1 0 01.293.707V19a2 2 0 01-2 2z"></path></svg>
                        </div>
                         <div class="ml-4">
                            <p class="text-sm font-medium text-gray-500 dark:text-gray-400">Stock</p>
                             <h3 class="text-lg font-bold text-gray-800 dark:text-white group-hover:text-rose-600 transition-colors">Levels & GRN</h3>
                        </div>
                    </div>
                </div>
            </div>

            <!-- Analytics Charts -->
            <div class="grid grid-cols-1 lg:grid-cols-2 gap-6 px-4 sm:px-0">
                <!-- Sales Trend -->
                <div class="bg-white dark:bg-gray-800 overflow-hidden shadow-xl rounded-2xl p-6">
                    <h3 class="text-lg font-bold text-gray-800 dark:text-white mb-4">Weekly Sales Trend</h3>
                    <div class="w-full h-64">
                         <canvas id="salesTrendChart"></canvas>
                    </div>
                </div>

                <!-- Product & Payment Mix -->
                <div class="grid grid-cols-1 md:grid-cols-2 gap-4">
                     <!-- Top Products -->
                    <div class="bg-white dark:bg-gray-800 overflow-hidden shadow-xl rounded-2xl p-6">
                        <h3 class="text-sm font-bold text-gray-800 dark:text-white mb-2">Top Products (Revenue)</h3>
                        <div class="w-full h-48">
                            <canvas id="topProductsChart"></canvas>
                        </div>
                    </div>
                     <!-- Payment Mix -->
                    <div class="bg-white dark:bg-gray-800 overflow-hidden shadow-xl rounded-2xl p-6">
                        <h3 class="text-sm font-bold text-gray-800 dark:text-white mb-2">Collected Payment Mix</h3>
                         <div class="w-full h-48 flex justify-center">
                            <canvas id="paymentMixChart"></canvas>
                        </div>
                    </div>
                </div>
            </div>

            <!-- Operations Section -->
            <div class="bg-white dark:bg-gray-800 overflow-hidden shadow-xl sm:rounded-2xl mx-4 sm:mx-0">
                <div class="p-8 border-b border-gray-200 dark:border-gray-700">
                    <h3 class="text-xl font-bold text-gray-900 dark:text-white mb-6 flex items-center">
                        <svg class="w-6 h-6 mr-2 text-indigo-500" fill="none" stroke="currentColor" viewBox="0 0 24 24"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M13 10V3L4 14h7v7l9-11h-7z"></path></svg>
                        Quick Operations
                    </h3>
                    <div class="grid grid-cols-2 lg:grid-cols-4 gap-6">
                         <a href="<?php echo e(route('admin.deliveries.create')); ?>" class="group flex flex-col items-center p-6 bg-gradient-to-br from-blue-50 to-indigo-50 dark:from-blue-900/20 dark:to-indigo-900/20 rounded-2xl hover:from-blue-100 hover:to-indigo-100 dark:hover:from-blue-900/30 dark:hover:to-indigo-900/30 hover:shadow-lg border-2 border-blue-200 dark:border-blue-800 hover:border-blue-400 dark:hover:border-blue-600 transition-all">
                            <span class="text-4xl mb-3 group-hover:scale-110 transition-transform">🚛</span>
                            <span class="font-bold text-blue-700 dark:text-blue-300">New Delivery</span>
                             <span class="text-xs text-blue-600 dark:text-blue-400 mt-1">Load truck & assign team</span>
                        </a>
                        <a href="<?php echo e(route('admin.deliveries.index')); ?>" class="group flex flex-col items-center p-6 bg-gray-50 dark:bg-gray-700/50 rounded-2xl hover:bg-white dark:hover:bg-gray-700 hover:shadow-lg border border-transparent hover:border-gray-200 dark:hover:border-gray-600 transition-all">
                            <span class="text-4xl mb-3 group-hover:scale-110 transition-transform">📋</span>
                            <span class="font-semibold text-gray-700 dark:text-gray-200">Deliveries</span>
                             <span class="text-xs text-gray-500 mt-1">Track trips & status</span>
                        </a>
                        <a href="<?php echo e(route('admin.vehicle-stocks.index')); ?>" class="group flex flex-col items-center p-6 bg-gray-50 dark:bg-gray-700/50 rounded-2xl hover:bg-white dark:hover:bg-gray-700 hover:shadow-lg border border-transparent hover:border-gray-200 dark:hover:border-gray-600 transition-all">
                             <span class="text-4xl mb-3 group-hover:scale-110 transition-transform">📦</span>
                            <span class="font-semibold text-gray-700 dark:text-gray-200">Lorry Stocks</span>
                            <span class="text-xs text-gray-500 mt-1">View mobile inventory</span>
                        </a>
                         <a href="<?php echo e(route('admin.inventory.grn.create')); ?>" class="group flex flex-col items-center p-6 bg-gray-50 dark:bg-gray-700/50 rounded-2xl hover:bg-white dark:hover:bg-gray-700 hover:shadow-lg border border-transparent hover:border-gray-200 dark:hover:border-gray-600 transition-all">
                             <span class="text-4xl mb-3 group-hover:scale-110 transition-transform">📥</span>
                            <span class="font-semibold text-gray-700 dark:text-gray-200">Add Stock</span>
                            <span class="text-xs text-gray-500 mt-1">Create GRN</span>
                        </a>
                    </div>
                </div>
            </div>
        </div>
    </div>
    <script src="https://cdn.jsdelivr.net/npm/chart.js"></script>
    <script>
        document.addEventListener('DOMContentLoaded', function() {
            // 1. Sales Trend (Line/Bar Chart)
            const ctxSales = document.getElementById('salesTrendChart').getContext('2d');
            new Chart(ctxSales, {
                type: 'line',
                data: {
                    labels: <?php echo json_encode($weeklyDates); ?>, // ['Jan 01', 'Jan 02'...]
                    datasets: [{
                        label: 'Sales (LKR)',
                        data: <?php echo json_encode($weeklySales); ?>,
                        borderColor: '#4f46e5', // Indigo 600
                        backgroundColor: 'rgba(79, 70, 229, 0.1)',
                        borderWidth: 2,
                        fill: true,
                        tension: 0.4
                    }]
                },
                options: {
                    responsive: true,
                    maintainAspectRatio: false,
                    plugins: { legend: { display: false } },
                    scales: { y: { beginAtZero: true } }
                }
            });

            // 2. Top Products (Bar Chart)
            const ctxProducts = document.getElementById('topProductsChart').getContext('2d');
            new Chart(ctxProducts, {
                type: 'bar',
                data: {
                    labels: <?php echo json_encode($topProductsLabels); ?>,
                    datasets: [{
                        label: 'Revenue',
                        data: <?php echo json_encode($topProductsData); ?>,
                        backgroundColor: [
                            '#3b82f6', '#10b981', '#f59e0b', '#ef4444', '#8b5cf6'
                        ],
                        borderRadius: 4
                    }]
                },
                options: {
                    responsive: true,
                    maintainAspectRatio: false,
                    indexAxis: 'y', // Horizontal Bar
                    plugins: { legend: { display: false } }
                }
            });

            // 3. Payment Mix (Doughnut)
            const ctxPayments = document.getElementById('paymentMixChart').getContext('2d');
            new Chart(ctxPayments, {
                type: 'doughnut',
                data: {
                    labels: ['Cash', 'Cheque'],
                    datasets: [{
                        data: [<?php echo e($cashTotal); ?>, <?php echo e($chequeTotal); ?>],
                        backgroundColor: ['#10b981', '#3b82f6'], // Emerald, Blue
                        hoverOffset: 4
                    }]
                },
                options: {
                    responsive: true,
                    maintainAspectRatio: false,
                    plugins: { 
                        legend: { position: 'bottom' } 
                    }
                }
            });
        });
    </script>
 <?php echo $__env->renderComponent(); ?>
<?php endif; ?>
<?php if (isset($__attributesOriginal9ac128a9029c0e4701924bd2d73d7f54)): ?>
<?php $attributes = $__attributesOriginal9ac128a9029c0e4701924bd2d73d7f54; ?>
<?php unset($__attributesOriginal9ac128a9029c0e4701924bd2d73d7f54); ?>
<?php endif; ?>
<?php if (isset($__componentOriginal9ac128a9029c0e4701924bd2d73d7f54)): ?>
<?php $component = $__componentOriginal9ac128a9029c0e4701924bd2d73d7f54; ?>
<?php unset($__componentOriginal9ac128a9029c0e4701924bd2d73d7f54); ?>
<?php endif; ?>
<?php /**PATH C:\Users\kavishka\Desktop\laravel\bulkLkDeliver\resources\views/admin/dashboard.blade.php ENDPATH**/ ?>