<?php
declare(strict_types=1);
require_once __DIR__ . '/includes/console_shell.php';
require_login();
extract(console_user_context(), EXTR_SKIP);
console_header('HR Console', 'dashboard.php');
?>
        <div class="flex flex-col md:flex-row justify-between items-start md:items-center mb-6 gap-4">
            <div>
                <h1 class="text-2xl font-bold text-slate-900 tracking-tight">Good Morning, <?= h($displayName) ?></h1>
                <p class="text-sm text-slate-500 mt-1">Here is what's happening at Attendance Box today.</p>
            </div>
            <div class="flex gap-3 flex-wrap">
                <button class="bg-white border border-slate-200 text-slate-700 hover:bg-slate-50 hover:border-slate-300 text-sm font-semibold py-2 px-4 rounded-lg shadow-sm transition-all flex items-center gap-2">
                    <i class="fa-solid fa-user-plus text-brand-600"></i> Add Employee
                </button>
                <button class="bg-card-purple hover:bg-card-purpleDark text-white text-sm font-semibold py-2 px-4 rounded-lg shadow-sm transition-all flex items-center gap-2">
                    <i class="fa-solid fa-calculator"></i> Run Payroll
                </button>
            </div>
        </div>

        <div class="grid grid-cols-1 md:grid-cols-2 lg:grid-cols-4 gap-4 sm:gap-5 mb-6">
            
            <div class="bg-white rounded-[1.25rem] shadow-sm border border-slate-100 p-6 flex flex-col justify-between">
                <div class="flex justify-between items-start mb-4">
                    <div class="text-[13px] font-semibold text-slate-500">Active Workforce</div>
                    <div class="p-2.5 bg-blue-50 text-blue-600 rounded-xl"><i class="fa-solid fa-user-group text-sm"></i></div>
                </div>
                <div>
                    <div class="text-3xl font-bold text-slate-800 tracking-tight">100</div>
                    <div class="text-xs text-slate-500 mt-2 font-medium flex items-center gap-1">
                        <span class="text-emerald-500"><i class="fa-solid fa-arrow-trend-up"></i> +2</span> since last month
                    </div>
                </div>
            </div>

            <div class="bg-white rounded-[1.25rem] shadow-sm border border-slate-100 p-6 flex flex-col justify-between">
                <div class="flex justify-between items-start mb-4">
                    <div class="text-[13px] font-semibold text-slate-500">Today's Attendance</div>
                    <div class="p-2.5 bg-emerald-50 text-emerald-600 rounded-xl"><i class="fa-solid fa-fingerprint text-sm"></i></div>
                </div>
                <div>
                    <div class="text-3xl font-bold text-slate-800 tracking-tight">86<span class="text-lg text-slate-400 font-medium">/100</span></div>
                    <div class="mt-3 w-full bg-slate-100 rounded-full h-1.5 flex overflow-hidden">
                        <div class="bg-emerald-500 h-1.5" style="width: 86%;"></div>
                        <div class="bg-amber-400 h-1.5" style="width: 10%;"></div>
                    </div>
                    <div class="text-xs text-slate-500 mt-3 flex items-center gap-3 font-medium">
                        <span class="flex items-center gap-1.5"><span class="w-2 h-2 rounded-full bg-emerald-500"></span> 86 Present</span>
                        <span class="flex items-center gap-1.5"><span class="w-2 h-2 rounded-full bg-amber-400"></span> 10 Late</span>
                    </div>
                </div>
            </div>

            <div class="bg-white rounded-[1.25rem] shadow-sm border border-slate-100 p-6 flex flex-col justify-between">
                <div class="flex justify-between items-start mb-4">
                    <div class="text-[13px] font-semibold text-slate-500">On Leave Today</div>
                    <div class="p-2.5 bg-purple-50 text-purple-600 rounded-xl"><i class="fa-solid fa-umbrella-beach text-sm"></i></div>
                </div>
                <div>
                    <div class="text-3xl font-bold text-slate-800 tracking-tight">4</div>
                    <div class="text-xs text-slate-500 mt-2 flex flex-col gap-1.5 font-medium">
                        <span>2 Casual Leave (CL)</span>
                        <span>2 Sick Leave (SL)</span>
                    </div>
                </div>
            </div>

            <div class="bg-gradient-to-br from-card-purple to-card-purpleDark rounded-[1.25rem] shadow-md p-6 flex flex-col justify-between text-white relative overflow-hidden">
                <div class="absolute right-0 top-1/2 -translate-y-1/2 translate-x-4 w-32 h-32 bg-white/5 rounded-full flex items-center justify-center">
                    <div class="w-20 h-20 bg-white/5 rounded-full flex items-center justify-center">
                        <div class="p-2 bg-white/10 rounded-lg backdrop-blur-sm"><i class="fa-solid fa-list-ul text-lg"></i></div>
                    </div>
                </div>
                
                <div class="relative z-10 flex justify-between items-start mb-4">
                    <div class="text-[13px] font-semibold text-indigo-50">Tasks & Approvals</div>
                </div>
                <div class="relative z-10">
                    <div class="text-3xl font-bold tracking-tight">12</div>
                    <div class="text-xs text-white mt-3 flex gap-2 font-medium">
                        <span class="bg-black/10 hover:bg-black/20 transition-colors px-3 py-1.5 rounded-md cursor-pointer">8 Leaves</span>
                        <span class="bg-black/10 hover:bg-black/20 transition-colors px-3 py-1.5 rounded-md cursor-pointer">4 Shift Mismatches</span>
                    </div>
                </div>
            </div>

        </div>

        <div class="grid grid-cols-1 lg:grid-cols-3 gap-5 sm:gap-6">
            
            <div class="lg:col-span-2 bg-white rounded-[1.25rem] shadow-sm border border-slate-100 flex flex-col h-[400px]">
                <div class="px-6 py-5 border-b border-slate-50 flex justify-between items-center bg-white rounded-t-[1.25rem]">
                    <h2 class="font-semibold text-slate-800 flex items-center gap-2">
                        <i class="fa-solid fa-clock-rotate-left text-amber-500"></i> Shift Login Mismatches
                    </h2>
                    <span class="text-[11px] font-medium bg-amber-50 text-amber-700 border border-amber-100 px-3 py-1 rounded-md">Requires Regularization</span>
                </div>
                <div class="p-0 flex-grow overflow-y-auto overflow-x-auto">
                    <table class="w-full min-w-[720px] text-sm text-left text-slate-600">
                        <thead class="text-[10px] text-slate-400 font-bold uppercase tracking-wider bg-white sticky top-0 z-10 border-b border-slate-100">
                            <tr>
                                <th class="px-6 py-4">Employee</th>
                                <th class="px-6 py-4">Scheduled Shift</th>
                                <th class="px-6 py-4">Actual Log</th>
                                <th class="px-6 py-4 text-right">Action</th>
                            </tr>
                        </thead>
                        <tbody class="divide-y divide-slate-50">
                            <tr class="hover:bg-slate-50/50 transition-colors">
                                <td class="px-6 py-4 flex items-center gap-3">
                                    <div class="w-9 h-9 rounded-full bg-indigo-50 flex items-center justify-center text-sm font-semibold text-indigo-600">RS</div>
                                    <div><div class="font-semibold text-slate-900">Rahul Sharma</div><div class="text-[11px] text-slate-400 mt-0.5">Tech Team</div></div>
                                </td>
                                <td class="px-6 py-4">
                                    <div class="text-slate-700 font-medium">General (09:00 - 18:00)</div>
                                </td>
                                <td class="px-6 py-4">
                                    <div class="text-red-500 font-semibold text-[13px]">In: 10:45 AM</div>
                                    <div class="text-[11px] text-slate-400 mt-0.5">Location: Satara Plant</div>
                                </td>
                                <td class="px-6 py-4 text-right">
                                    <button class="text-[12px] font-medium text-slate-600 border border-slate-200 hover:border-brand-500 hover:text-brand-600 bg-white px-3 py-1.5 rounded-md transition-colors shadow-sm">Regularize</button>
                                </td>
                            </tr>
                            <tr class="hover:bg-slate-50/50 transition-colors">
                                <td class="px-6 py-4 flex items-center gap-3">
                                    <div class="w-9 h-9 rounded-full bg-pink-50 flex items-center justify-center text-sm font-semibold text-pink-600">PP</div>
                                    <div><div class="font-semibold text-slate-900">Priya Patil</div><div class="text-[11px] text-slate-400 mt-0.5">Sales</div></div>
                                </td>
                                <td class="px-6 py-4">
                                    <div class="text-slate-700 font-medium">Morning (06:00 - 15:00)</div>
                                </td>
                                <td class="px-6 py-4">
                                    <div class="text-amber-500 font-semibold text-[13px]">Out: Missing</div>
                                    <div class="text-[11px] text-slate-400 mt-0.5">Geofence: Pune MIDC</div>
                                </td>
                                <td class="px-6 py-4 text-right">
                                    <button class="text-[12px] font-medium text-slate-600 border border-slate-200 hover:border-brand-500 hover:text-brand-600 bg-white px-3 py-1.5 rounded-md transition-colors shadow-sm">Regularize</button>
                                </td>
                            </tr>
                        </tbody>
                    </table>
                </div>
            </div>

            <div class="bg-white rounded-[1.25rem] shadow-sm border border-slate-100 flex flex-col h-[400px]">
                <div class="px-6 py-5 border-b border-slate-50 flex justify-between items-center bg-white rounded-t-[1.25rem]">
                    <h2 class="font-semibold text-slate-800 flex items-center gap-2">
                        <i class="fa-solid fa-file-invoice-dollar text-emerald-600"></i> Payroll & Compliance
                    </h2>
                </div>
                <div class="p-6 flex-grow flex flex-col gap-6">
                    
                    <div class="bg-slate-50/80 rounded-xl p-4 border border-slate-100">
                        <div class="flex justify-between items-center mb-3">
                            <span class="text-sm font-semibold text-slate-800">June 2026 Cycle</span>
                            <span class="text-[10px] font-bold bg-indigo-100 text-indigo-700 px-2 py-0.5 rounded uppercase tracking-wide">Processing</span>
                        </div>
                        <div class="w-full bg-slate-200 rounded-full h-1.5 mb-3">
                            <div class="bg-card-purple h-1.5 rounded-full" style="width: 40%;"></div>
                        </div>
                        <div class="text-[11px] font-medium text-slate-500 flex justify-between">
                            <span>Attendance Locked</span>
                            <span>Due: 30th Jun</span>
                        </div>
                    </div>

                    <div>
                        <h3 class="text-[10px] font-bold text-slate-400 uppercase tracking-widest mb-3">Upcoming Deadlines</h3>
                        <div class="space-y-3">
                            <div class="flex justify-between items-center text-[13px] font-medium">
                                <span class="text-slate-700 flex items-center gap-2">
                                    <span class="w-1.5 h-1.5 rounded-full bg-red-500"></span> PF Remittance
                                </span>
                                <span class="text-slate-500">15th Jul</span>
                            </div>
                            <div class="flex justify-between items-center text-[13px] font-medium">
                                <span class="text-slate-700 flex items-center gap-2">
                                    <span class="w-1.5 h-1.5 rounded-full bg-amber-500"></span> ESI Challan
                                </span>
                                <span class="text-slate-500">15th Jul</span>
                            </div>
                            <div class="flex justify-between items-center text-[13px] font-medium">
                                <span class="text-slate-700 flex items-center gap-2">
                                    <span class="w-1.5 h-1.5 rounded-full bg-emerald-500"></span> TDS Payment
                                </span>
                                <span class="text-slate-500">7th Jul</span>
                            </div>
                        </div>
                    </div>

                </div>
            </div>

        </div>
<?php console_footer(); ?>

