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

<?php $__env->startSection('content'); ?>
    <div class="mb-6 hidden items-center justify-between lg:flex">
        <div>
            <h1 class="text-2xl font-extrabold text-slate-900">Good <?php echo e(now()->hour < 12 ? 'morning' : (now()->hour < 17 ? 'afternoon' : 'evening')); ?>, <?php echo e(Str::before(auth()->user()->name, ' ')); ?> 👋</h1>
            <p class="text-sm text-slate-500">Here's what's happening at Epelcon Hospitality today, <?php echo e(now()->format('l j F Y')); ?>.</p>
        </div>
        <a href="<?php echo e(route('epelcon.orders.pos')); ?>" class="rounded-xl bg-indigo-600 px-4 py-2.5 text-sm font-bold text-white shadow-lg shadow-indigo-600/25 hover:bg-indigo-700">+ New Order (POS)</a>
    </div>

    
    <div class="grid grid-cols-2 gap-3 sm:gap-4 xl:grid-cols-4">
        <div class="rounded-2xl bg-gradient-to-br from-indigo-600 to-violet-600 p-4 text-white shadow-lg shadow-indigo-600/20 sm:p-5">
            <p class="text-xs font-semibold uppercase tracking-wide text-indigo-200">Occupancy</p>
            <p class="mt-1 text-3xl font-extrabold"><?php echo e($stats['occupancy']); ?>%</p>
            <p class="mt-1 text-xs text-indigo-200"><?php echo e($stats['rooms_occupied']); ?>/<?php echo e($stats['rooms_total']); ?> rooms occupied · <?php echo e($stats['in_house']); ?> in-house</p>
        </div>
        <div class="rounded-2xl bg-white p-4 shadow-sm ring-1 ring-slate-200 sm:p-5">
            <p class="text-xs font-semibold uppercase tracking-wide text-slate-400">Revenue today</p>
            <p class="mt-1 text-2xl font-extrabold text-emerald-600 sm:text-3xl"><?php echo e($CUR ?? '₦') . number_format((float) ($stats['revenue_today']), 2); ?></p>
            <p class="mt-1 text-xs text-slate-400"><?php echo e($CUR ?? '₦') . number_format((float) ($stats['revenue_month']), 2); ?> this month</p>
        </div>
        <div class="rounded-2xl bg-white p-4 shadow-sm ring-1 ring-slate-200 sm:p-5">
            <p class="text-xs font-semibold uppercase tracking-wide text-slate-400">Arrivals / Departures</p>
            <p class="mt-1 text-2xl font-extrabold text-slate-900 sm:text-3xl"><?php echo e($stats['arrivals_today']); ?> <span class="text-slate-300">/</span> <?php echo e($stats['departures_today']); ?></p>
            <p class="mt-1 text-xs text-slate-400">expected today</p>
        </div>
        <div class="rounded-2xl bg-white p-4 shadow-sm ring-1 ring-slate-200 sm:p-5">
            <p class="text-xs font-semibold uppercase tracking-wide text-slate-400">Open orders</p>
            <p class="mt-1 text-2xl font-extrabold text-slate-900 sm:text-3xl"><?php echo e($stats['orders_open']); ?></p>
            <p class="mt-1 text-xs text-slate-400">Kitchen <?php echo e($stats['kitchen_queue']); ?> · Bar <?php echo e($stats['bar_queue']); ?></p>
        </div>
    </div>

    
    <div class="no-scrollbar mt-4 flex gap-2 overflow-x-auto pb-1">
        <?php if($stats['low_stock'] > 0): ?>
            <a href="<?php echo e(route('epelcon.inventory.index', ['filter' => 'low'])); ?>" class="flex shrink-0 items-center gap-1.5 rounded-full bg-amber-100 px-3.5 py-1.5 text-xs font-bold text-amber-800">⚠️ <?php echo e($stats['low_stock']); ?> low-stock item<?php echo e($stats['low_stock'] === 1 ? '' : 's'); ?></a>
        <?php endif; ?>
        <?php if($stats['housekeeping_pending'] > 0): ?>
            <a href="<?php echo e(route('epelcon.housekeeping.index')); ?>" class="flex shrink-0 items-center gap-1.5 rounded-full bg-sky-100 px-3.5 py-1.5 text-xs font-bold text-sky-800">🧹 <?php echo e($stats['housekeeping_pending']); ?> housekeeping task<?php echo e($stats['housekeeping_pending'] === 1 ? '' : 's'); ?></a>
        <?php endif; ?>
        <span class="flex shrink-0 items-center gap-1.5 rounded-full bg-slate-200 px-3.5 py-1.5 text-xs font-bold text-slate-600">💸 <?php echo e($CUR ?? '₦') . number_format((float) ($stats['expenses_month']), 2); ?> expenses this month</span>
        <span class="flex shrink-0 items-center gap-1.5 rounded-full bg-slate-200 px-3.5 py-1.5 text-xs font-bold text-slate-600">🧾 <?php echo e($stats['orders_today']); ?> orders today</span>
    </div>

    <div class="mt-5 grid gap-5 lg:grid-cols-3">
        
        <div class="rounded-2xl bg-white p-5 shadow-sm ring-1 ring-slate-200 lg:col-span-2">
            <div class="mb-3 flex items-center justify-between">
                <h2 class="font-bold text-slate-900">Revenue vs Expenses <span class="ml-1 text-xs font-medium text-slate-400">last 14 days</span></h2>
            </div>
            <div class="h-64"><canvas id="revChart"></canvas></div>
        </div>

        
        <div class="rounded-2xl bg-white p-5 shadow-sm ring-1 ring-slate-200">
            <h2 class="mb-3 font-bold text-slate-900">Today's arrivals</h2>
            <div class="space-y-3">
                <?php $__empty_1 = true; $__currentLoopData = $arrivals; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $arrival): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); $__empty_1 = false; ?>
                    <a href="<?php echo e(route('epelcon.bookings.show', $arrival)); ?>" class="flex items-center gap-3 rounded-xl bg-slate-50 p-3 hover:bg-indigo-50">
                        <div class="flex h-9 w-9 shrink-0 items-center justify-center rounded-full bg-indigo-100 text-xs font-bold text-indigo-700"><?php echo e(strtoupper(substr($arrival->customer->name, 0, 2))); ?></div>
                        <div class="min-w-0 flex-1">
                            <p class="truncate text-sm font-semibold text-slate-800"><?php echo e($arrival->customer->name); ?></p>
                            <p class="text-xs text-slate-500">Room <?php echo e($arrival->room->number ?? 'TBA'); ?> · <?php echo e($arrival->nights()); ?> night<?php echo e($arrival->nights() === 1 ? '' : 's'); ?></p>
                        </div>
                        <span class="rounded-full bg-emerald-100 px-2 py-0.5 text-[10px] font-bold uppercase text-emerald-700"><?php echo e($arrival->status); ?></span>
                    </a>
                <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); if ($__empty_1): ?>
                    <p class="rounded-xl bg-slate-50 p-4 text-center text-sm text-slate-400">No arrivals expected today.</p>
                <?php endif; ?>
            </div>
        </div>
    </div>

    <div class="mt-5 grid gap-5 lg:grid-cols-3">
        
        <div class="rounded-2xl bg-white p-5 shadow-sm ring-1 ring-slate-200 lg:col-span-2">
            <div class="mb-3 flex items-center justify-between">
                <h2 class="font-bold text-slate-900">Latest orders</h2>
                <a href="<?php echo e(route('epelcon.orders.index')); ?>" class="text-xs font-bold text-indigo-600 hover:underline">View all →</a>
            </div>
            <div class="divide-y divide-slate-100">
                <?php $__empty_1 = true; $__currentLoopData = $recentOrders; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $order): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); $__empty_1 = false; ?>
                    <a href="<?php echo e(route('epelcon.orders.show', $order)); ?>" class="flex items-center gap-3 py-2.5 hover:bg-slate-50">
                        <span class="w-24 shrink-0 font-mono text-xs font-bold text-indigo-600"><?php echo e($order->code); ?></span>
                        <span class="hidden text-xs text-slate-500 sm:inline"><?php echo e($order->items->count()); ?> item<?php echo e($order->items->count() === 1 ? '' : 's'); ?></span>
                        <span class="flex-1 truncate text-sm text-slate-700"><?php echo e($order->displayName()); ?> · <?php echo e(str_replace('_', ' ', $order->type)); ?></span>
                        <span class="text-sm font-bold text-slate-900"><?php echo e($CUR ?? '₦') . number_format((float) ($order->total), 2); ?></span>
                        <?php $badge = ['pending'=>'amber','confirmed'=>'sky','preparing'=>'amber','ready'=>'violet','served'=>'emerald','completed'=>'emerald','cancelled'=>'rose'][$order->status] ?? 'slate'; ?>
                        <span class="rounded-full bg-<?php echo e($badge); ?>-100 px-2 py-0.5 text-[10px] font-bold uppercase text-<?php echo e($badge); ?>-700"><?php echo e($order->status); ?></span>
                    </a>
                <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); if ($__empty_1): ?>
                    <p class="py-6 text-center text-sm text-slate-400">No orders yet today.</p>
                <?php endif; ?>
            </div>
        </div>

        
        <div class="space-y-5">
            <?php if($lowStockItems->isNotEmpty()): ?>
                <div class="rounded-2xl bg-white p-5 shadow-sm ring-1 ring-slate-200">
                    <h2 class="mb-3 font-bold text-slate-900">Low stock</h2>
                    <div class="space-y-2">
                        <?php $__currentLoopData = $lowStockItems; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $item): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                            <div class="flex items-center justify-between rounded-lg bg-amber-50 px-3 py-2">
                                <span class="text-sm font-medium text-slate-700"><?php echo e($item->name); ?></span>
                                <span class="text-xs font-bold text-amber-700"><?php echo e($item->quantity + 0); ?> <?php echo e($item->unit); ?></span>
                            </div>
                        <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
                    </div>
                </div>
            <?php endif; ?>
            <div class="rounded-2xl bg-white p-5 shadow-sm ring-1 ring-slate-200">
                <h2 class="mb-3 font-bold text-slate-900">Recent activity</h2>
                <div class="space-y-2.5">
                    <?php $__empty_1 = true; $__currentLoopData = $activity; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $log): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); $__empty_1 = false; ?>
                        <div class="flex gap-2.5 text-xs">
                            <span class="mt-1 h-1.5 w-1.5 shrink-0 rounded-full bg-indigo-400"></span>
                            <p class="text-slate-600"><span class="font-semibold text-slate-800"><?php echo e($log->user->name ?? 'System'); ?></span> <?php echo e($log->action); ?><?php echo e($log->description ? ' — ' . $log->description : ''); ?> <span class="text-slate-400">· <?php echo e($log->created_at->diffForHumans(short: true)); ?></span></p>
                        </div>
                    <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); if ($__empty_1): ?>
                        <p class="text-sm text-slate-400">No activity recorded yet.</p>
                    <?php endif; ?>
                </div>
            </div>
        </div>
    </div>
<?php $__env->stopSection(); ?>

<?php $__env->startPush('scripts'); ?>
<script>
document.addEventListener('DOMContentLoaded', () => {
    const ctx = document.getElementById('revChart');
    new Chart(ctx, {
        type: 'line',
        data: {
            labels: <?php echo json_encode($trend->pluck('label'), 15, 512) ?>,
            datasets: [
                { label: 'Revenue', data: <?php echo json_encode($trend->pluck('revenue'), 15, 512) ?>, borderColor: '#4f46e5', backgroundColor: 'rgba(79,70,229,.08)', fill: true, tension: .4, borderWidth: 2.5, pointRadius: 0 },
                { label: 'Expenses', data: <?php echo json_encode($trend->pluck('expenses'), 15, 512) ?>, borderColor: '#f43f5e', backgroundColor: 'transparent', tension: .4, borderWidth: 2, pointRadius: 0, borderDash: [5, 4] },
            ],
        },
        options: {
            maintainAspectRatio: false,
            plugins: { legend: { labels: { boxWidth: 12, usePointStyle: true, font: { family: '"Plus Jakarta Sans"' } } } },
            scales: {
                y: { ticks: { callback: v => '<?php echo e($CUR); ?>' + (v >= 1000 ? (v / 1000) + 'k' : v) }, grid: { color: '#f1f5f9' } },
                x: { grid: { display: false } },
            },
        },
    });
});
</script>
<?php $__env->stopPush(); ?>

<?php echo $__env->make('layouts.epelcon', array_diff_key(get_defined_vars(), ['__data' => 1, '__path' => 1]))->render(); ?><?php /**PATH C:\wamp64\www\hms\resources\views/epelcon/dashboard.blade.php ENDPATH**/ ?>