<?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-semibold text-xl text-slate-900 leading-tight">
                <?php echo e(__('Dashboard')); ?>

            </h2>
        </div>
     <?php $__env->endSlot(); ?>

    <div class="py-6">
        <div class="max-w-7xl mx-auto px-4 sm:px-6 lg:px-8">
            
            <!-- Metrics Grid -->
            <div class="grid grid-cols-1 sm:grid-cols-2 md:grid-cols-3 lg:grid-cols-6 gap-4  mb-6">

                <div class="bg-white border border-slate-200 rounded-xl shadow-sm overflow-hidden p-4 ">
                    <div class="text-sm text-slate-500 uppercase font-bold">Today Trips</div>
                    <div class="text-2xl font-black text-slate-900"><?php echo e($todayTrips); ?></div>
                </div>

                <div class="bg-white border border-slate-200 rounded-xl shadow-sm overflow-hidden p-4 ">
                    <div class="text-sm text-slate-500 uppercase font-bold">Today Hours</div>
                    <div class="text-2xl font-black text-indigo-600"><?php echo e(number_format($todayHours, 2)); ?></div>
                </div>

                <div class="bg-white border border-slate-200 rounded-xl shadow-sm overflow-hidden p-4 ">
                    <div class="text-sm text-slate-500 uppercase font-bold">Today Income</div>
                    <div class="text-2xl font-black text-green-600">₹<?php echo e(number_format($todayIncome, 2)); ?></div>
                </div>
                
                <div class="bg-white border border-slate-200 rounded-xl shadow-sm overflow-hidden p-4 ">
                    <div class="text-sm text-slate-500 uppercase font-bold">Fuel Expense</div>
                    <div class="text-2xl font-black text-red-600">₹<?php echo e(number_format($fuelExpense, 2)); ?></div>
                </div>
                
                <div class="bg-white border border-slate-200 rounded-xl shadow-sm overflow-hidden p-4 ">
                    <div class="text-sm text-slate-500 uppercase font-bold">Today Profit</div>
                    <div class="text-2xl font-black text-purple-600">₹<?php echo e(number_format($profit, 2)); ?></div>
                </div>

                <div class="bg-white border border-slate-200 rounded-xl shadow-sm overflow-hidden p-4 ">
                    <div class="text-sm text-slate-500 uppercase font-bold flex justify-between items-center">
                        Last Login
                        <svg class="w-4 h-4 text-slate-400" fill="none" stroke="currentColor" viewBox="0 0 24 24"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M11 16l-4-4m0 0l4-4m-4 4h14m-5 4v1a3 3 0 01-3 3H6a3 3 0 01-3-3V7a3 3 0 013-3h7a3 3 0 013 3v1"/></svg>
                    </div>
                    <?php if(isset($lastLogin) && $lastLogin): ?>
                        <div class="text-sm font-black text-slate-900 mt-1"><?php echo e(\Carbon\Carbon::parse($lastLogin->login_datetime)->format('d M Y, h:i A')); ?></div>
                        <div class="text-xs font-semibold text-slate-500 mt-0.5 truncate" title="<?php echo e($lastLogin->device_name); ?>"><?php echo e($lastLogin->device_name); ?></div>
                    <?php else: ?>
                        <div class="text-sm font-black text-slate-400 mt-1">No prior login</div>
                    <?php endif; ?>
                </div>
            </div>

            <!-- Pending Payments -->
            <div class=" mb-6">
                <div class="bg-amber-50 border border-amber-200  text-orange-700 p-4 rounded shadow-sm flex justify-between items-center">
                    <div>
                        <p class="font-bold text-lg">Pending Payments</p>
                        <p>Total outstanding balance from trips.</p>
                    </div>
                    <div class="text-2xl font-black">₹<?php echo e(number_format($pendingPayments, 2)); ?></div>
                </div>
            </div>

            <!-- Row 1: Expiry Alerts + Recent Trips (separate grids) -->
            <div class="grid grid-cols-1 md:grid-cols-2 gap-6  mb-6">
                
                <!-- Expiry Alerts -->
                <div class="bg-white border border-slate-200 rounded-xl shadow-sm overflow-hidden">
                    <div class="bg-red-500 text-white px-4 py-3 font-bold flex justify-between">
                        <span>⚠️ Expiry Alerts (Next 30 Days)</span>
                        <span class="bg-white text-red-500 rounded-full px-2 py-0.5 text-xs"><?php echo e($expiryAlerts->count()); ?></span>
                    </div>
                    <div class="p-4">
                        <?php if($expiryAlerts->isEmpty()): ?>
                            <p class="text-slate-500 text-center py-4">No upcoming expiries. ✅</p>
                        <?php else: ?>
                            <ul class="divide-y divide-slate-100">
                                <?php $__currentLoopData = $expiryAlerts; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $alert): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                                    <li class="py-3 flex justify-between items-center">
                                        <div>
                                            <p class="font-bold text-slate-900"><?php echo e($alert->vehicle->vehicle_number ?? 'Unknown'); ?></p>
                                            <p class="text-sm text-slate-500 uppercase"><?php echo e($alert->expiry_type); ?></p>
                                        </div>
                                        <div class="text-right">
                                            <span class="text-red-500 font-bold"><?php echo e(\Carbon\Carbon::parse($alert->expiry_date)->format('d M Y')); ?></span>
                                            <p class="text-xs text-gray-400"><?php echo e(\Carbon\Carbon::parse($alert->expiry_date)->diffForHumans()); ?></p>
                                        </div>
                                    </li>
                                <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
                            </ul>
                        <?php endif; ?>
                    </div>
                </div>

                <!-- Recent Trips -->
                <div class="bg-white border border-slate-200 rounded-xl shadow-sm overflow-hidden">
                    <div class="bg-blue-500 text-white px-4 py-3 font-bold flex justify-between">
                        <span>🚛 Recent Trips</span>
                        <span class="bg-white text-blue-500 rounded-full px-2 py-0.5 text-xs">Last 5</span>
                    </div>
                    <div class="p-4">
                        <?php if($recentTrips->isEmpty()): ?>
                            <p class="text-slate-500 text-center py-4">No trips recorded yet.</p>
                        <?php else: ?>
                            <ul class="divide-y divide-slate-100">
                                <?php $__currentLoopData = $recentTrips; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $trip): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                                    <li class="py-3 flex justify-between items-center">
                                        <div>
                                            <p class="font-bold text-slate-900"><?php echo e($trip->location); ?></p>
                                            <p class="text-xs text-slate-500"><?php echo e($trip->vehicle->vehicle_number ?? ''); ?> • <?php echo e($trip->driver->driver_name ?? ''); ?></p>
                                        </div>
                                        <div class="text-right">
                                            <span class="font-bold text-green-600">₹<?php echo e(number_format($trip->total_amount, 0)); ?></span>
                                            <p class="text-xs text-gray-400"><?php echo e($trip->date->format('d M Y')); ?></p>
                                        </div>
                                    </li>
                                <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
                            </ul>
                        <?php endif; ?>
                    </div>
                </div>
            </div>
            
            <!-- Row 2: Top Vehicles + Business Overview (separate grids) -->
            <div class="grid grid-cols-1 lg:grid-cols-2 gap-6  mb-6">
                <!-- Top Vehicles Chart -->
                <div class="bg-white border border-slate-200 rounded-xl shadow-sm overflow-hidden p-6">
                    <h3 class="text-lg font-bold text-slate-900 mb-4 border-b pb-2 flex justify-between items-center">
                        <span>🏆 Top Vehicles (Last 30 Days)</span>
                        <span class="text-xs font-normal text-slate-500">By Profit</span>
                    </h3>
                    
                    <?php if($topVehiclesQuery->isEmpty()): ?>
                        <p class="text-slate-500 text-center py-4">No data available yet.</p>
                    <?php else: ?>
                        <?php
                            $maxProfit = $topVehiclesQuery->max('total_profit') > 0 ? $topVehiclesQuery->max('total_profit') : 1;
                        ?>
                        <div class="space-y-4">
                            <?php $__currentLoopData = $topVehiclesQuery; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $tv): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                                <?php
                                    $percentage = min(100, max(0, ($tv->total_profit / $maxProfit) * 100));
                                ?>
                                <div>
                                    <div class="flex justify-between text-sm mb-1">
                                        <span class="font-bold text-slate-700"><?php echo e($tv->vehicle->vehicle_number ?? 'Unknown'); ?></span>
                                        <span class="font-bold <?php echo e($tv->total_profit >= 0 ? 'text-green-600' : 'text-red-500'); ?>">₹<?php echo e(number_format($tv->total_profit, 2)); ?></span>
                                    </div>
                                    <div class="w-full bg-gray-200 rounded-full h-2.5">
                                        <div class="<?php echo e($tv->total_profit >= 0 ? 'bg-indigo-600' : 'bg-red-500'); ?> h-2.5 rounded-full" style="width: <?php echo e($percentage); ?>%"></div>
                                    </div>
                                    <div class="text-xs text-gray-400 flex justify-between mt-1">
                                        <span>Rent: ₹<?php echo e(number_format($tv->total_rent, 0)); ?></span>
                                        <span>Fuel: ₹<?php echo e(number_format($tv->total_fuel, 0)); ?></span>
                                    </div>
                                </div>
                            <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
                        </div>
                    <?php endif; ?>
                </div>

                <!-- Business Overview -->
                <div class="bg-white border border-slate-200 rounded-xl shadow-sm overflow-hidden p-6">
                    <h3 class="text-lg font-bold text-slate-900 mb-4 border-b pb-2">
                        <span>📈 Business Overview</span>
                    </h3>
                    <?php if($profitData->isEmpty()): ?>
                        <p class="text-slate-500 text-center py-4">No data for last 30 days.</p>
                    <?php else: ?>
                        <?php
                            $maxVal = max($profitData->max('rent'), 1);
                        ?>
                        <div class="h-48 flex items-end justify-around gap-3 px-2 border-b border-gray-100 pb-2">
                            <?php $__currentLoopData = $profitData; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $week): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                                <?php
                                    $rentH = max(5, ($week->rent / $maxVal) * 100);
                                    $fuelH = max(3, ($week->fuel / $maxVal) * 100);
                                ?>
                                <div class="flex flex-col items-center gap-1 flex-1">
                                    <div class="w-full flex items-end justify-center gap-0.5" style="height:180px;">
                                        <div class="w-1/2 bg-blue-400 rounded-t" style="height:<?php echo e($rentH); ?>%"></div>
                                        <div class="w-1/2 bg-red-300 rounded-t" style="height:<?php echo e($fuelH); ?>%"></div>
                                    </div>
                                </div>
                            <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
                        </div>
                        <div class="flex justify-center gap-6 mt-3 text-xs text-slate-500">
                            <span class="flex items-center gap-1"><span class="w-3 h-3 bg-blue-400 rounded"></span> Income</span>
                            <span class="flex items-center gap-1"><span class="w-3 h-3 bg-red-300 rounded"></span> Fuel</span>
                        </div>
                    <?php endif; ?>
                </div>
            </div>

            <!-- Quick Actions -->
            <div class="">
                <h3 class="text-lg font-bold text-slate-900 mb-4">Quick Actions</h3>
                <div class="grid grid-cols-1 sm:grid-cols-2 md:grid-cols-4 gap-4">
                    <a href="<?php echo e(route('trips.create')); ?>" class="bg-white border border-slate-200 text-slate-900 text-center py-4 rounded-xl shadow-sm font-semibold text-sm hover:bg-slate-50 hover:border-slate-300 transition flex flex-col items-center gap-2">
                        <svg class="w-6 h-6 text-slate-400" fill="none" stroke="currentColor" viewBox="0 0 24 24"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="1.5" d="M12 4v16m8-8H4"/></svg>
                        New Trip
                    </a>
                    <a href="<?php echo e(route('payments.create')); ?>" class="bg-white border border-slate-200 text-slate-900 text-center py-4 rounded-xl shadow-sm font-semibold text-sm hover:bg-slate-50 hover:border-slate-300 transition flex flex-col items-center gap-2">
                        <svg class="w-6 h-6 text-emerald-500" fill="none" stroke="currentColor" viewBox="0 0 24 24"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="1.5" d="M12 8c-1.657 0-3 1.343-3 3s1.343 3 3 3 3-1.343 3-3-1.343-3-3-3z"/><path stroke-linecap="round" stroke-linejoin="round" stroke-width="1.5" d="M12 2C6.477 2 2 6.477 2 12s4.477 10 10 10 10-4.477 10-10S17.523 2 12 2zm0 18c-4.411 0-8-3.589-8-8s3.589-8 8-8 8 3.589 8 8-3.589 8-8 8z"/></svg>
                        Add Payment
                    </a>
                    <a href="<?php echo e(route('reports.index')); ?>" class="bg-white border border-slate-200 text-slate-900 text-center py-4 rounded-xl shadow-sm font-semibold text-sm hover:bg-slate-50 hover:border-slate-300 transition flex flex-col items-center gap-2">
                        <svg class="w-6 h-6 text-indigo-500" fill="none" stroke="currentColor" viewBox="0 0 24 24"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="1.5" 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"/></svg>
                        Reports
                    </a>
                    <a href="<?php echo e(route('vehicles.index')); ?>" class="bg-white border border-slate-200 text-slate-900 text-center py-4 rounded-xl shadow-sm font-semibold text-sm hover:bg-slate-50 hover:border-slate-300 transition flex flex-col items-center gap-2">
                        <svg class="w-6 h-6 text-blue-500" fill="none" stroke="currentColor" viewBox="0 0 24 24"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="1.5" d="M8 17h.01M16 17h.01M3 11l1.5-5A2 2 0 016.4 4h11.2a2 2 0 011.9 1.5L21 11M3 11v6a1 1 0 001 1h1m16-7v6a1 1 0 01-1 1h-1M3 11h18M7 17a1 1 0 100 2 1 1 0 000-2zm10 0a1 1 0 100 2 1 1 0 000-2z"/></svg>
                        Vehicles
                    </a>
                </div>
            </div>



        </div>
    </div>
 <?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 /Users/roni/Documents/Vicky/vms/resources/views/dashboard.blade.php ENDPATH**/ ?>