<?php require APPROOT . '/app/Views/layouts/header.php'; ?>

<div class="max-w-6xl mx-auto mb-10">
    
    <div class="bg-gradient-to-r from-primary to-blue-600 rounded-2xl shadow-lg p-8 mb-8 text-white flex flex-col md:flex-row items-center justify-between relative overflow-hidden">
        <div class="absolute top-0 right-0 -mt-4 -mr-4 w-32 h-32 bg-white opacity-10 rounded-full blur-2xl"></div>
        <div class="absolute bottom-0 left-10 -mb-4 w-24 h-24 bg-white opacity-10 rounded-full blur-xl"></div>
        
        <div class="relative z-10">
            <h1 class="text-3xl font-bold mb-2">Welcome back, <?php echo explode(' ', $data['user']->name)[0]; ?>!</h1>
            <p class="text-blue-100 opacity-90"><?php echo $data['description']; ?></p>
        </div>
        <div class="mt-4 md:mt-0 flex flex-col items-end relative z-10">
            <span class="px-4 py-2 bg-white/20 rounded-lg text-sm font-bold backdrop-blur-md shadow-sm border border-white/30 flex items-center">
                Status: <?php echo ($data['user']->is_active == 1) ? '<span class="w-2 h-2 rounded-full bg-green-400 ml-2 mr-1"></span> Active Account' : '<span class="w-2 h-2 rounded-full bg-red-400 ml-2 mr-1"></span> Restricted'; ?>
            </span>
        </div>
    </div>
    
    <div class="grid grid-cols-1 md:grid-cols-3 gap-8">
        
        <!-- Profile Column -->
        <div class="col-span-1 bg-white dark:bg-gray-800 rounded-xl shadow-sm border border-gray-200 dark:border-gray-700/50 overflow-hidden flex flex-col h-full">
            <div class="p-5 border-b border-gray-200 dark:border-gray-700/50 bg-gray-50 dark:bg-gray-900/40 flex items-center">
                <svg class="w-4 h-4 mr-2 text-primary" fill="none" stroke="currentColor" viewBox="0 0 24 24"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M16 7a4 4 0 11-8 0 4 4 0 018 0zM12 14a7 7 0 00-7 7h14a7 7 0 00-7-7z"></path></svg>
                <h2 class="text-sm font-bold text-gray-900 dark:text-white">My Details</h2>
            </div>
            
            <div class="p-6 flex-1 flex flex-col space-y-5">
                <div>
                    <span class="block text-[10px] font-bold text-gray-400 uppercase tracking-wider mb-1">Full Name</span>
                    <span class="text-sm text-gray-900 dark:text-white font-medium"><?php echo htmlspecialchars($data['user']->name); ?></span>
                </div>
                <div>
                    <span class="block text-[10px] font-bold text-gray-400 uppercase tracking-wider mb-1">Email Address</span>
                    <span class="text-sm text-gray-900 dark:text-white font-medium"><?php echo htmlspecialchars($data['user']->email); ?></span>
                </div>
                <div class="mb-6">
                    <span class="block text-[10px] font-bold text-gray-400 uppercase tracking-wider mb-1">Member Since</span>
                    <span class="text-sm text-gray-900 dark:text-white font-medium"><?php echo date('F j, Y', strtotime($data['user']->created_at)); ?></span>
                </div>
                
                <a href="<?php echo URLROOT; ?>/profile/index" class="block w-full text-center bg-gray-100 hover:bg-gray-200 dark:bg-gray-900 dark:hover:bg-gray-700 text-gray-800 dark:text-white font-bold py-2.5 px-4 rounded-lg transition-colors mt-auto border border-gray-200 dark:border-gray-700/50 shadow-sm">
                    Edit Profile
                </a>
            </div>
        </div>

        <!-- Metrics & Workspace Column -->
        <div class="col-span-1 md:col-span-2 flex flex-col gap-6">
            
            <!-- Statistics Row -->
            <div class="grid grid-cols-1 sm:grid-cols-3 gap-6">
                <div class="p-6 bg-white dark:bg-gray-800 rounded-xl shadow-sm border border-gray-200 dark:border-gray-700/50 flex flex-col items-start justify-center">
                    <h3 class="text-[10px] font-bold text-gray-500 dark:text-gray-400 uppercase tracking-wider mb-2">Active Tasks</h3>
                    <p class="text-3xl font-extrabold text-blue-600 dark:text-blue-500"><?php echo $data['stats']['active']; ?></p>
                </div>
                <div class="p-6 bg-white dark:bg-gray-800 rounded-xl shadow-sm border border-gray-200 dark:border-gray-700/50 flex flex-col items-start justify-center">
                    <h3 class="text-[10px] font-bold text-gray-500 dark:text-gray-400 uppercase tracking-wider mb-2">Completed Jobs</h3>
                    <p class="text-3xl font-extrabold text-emerald-600 dark:text-emerald-500"><?php echo $data['stats']['completed']; ?></p>
                </div>
                <div class="p-6 bg-white dark:bg-gray-800 rounded-xl shadow-sm border border-gray-200 dark:border-gray-700/50 flex flex-col items-start justify-center">
                    <h3 class="text-[10px] font-bold text-gray-500 dark:text-gray-400 uppercase tracking-wider mb-2">Total Lifetime Jobs</h3>
                    <p class="text-3xl font-extrabold text-gray-900 dark:text-white"><?php echo $data['stats']['total']; ?></p>
                </div>
            </div>

            <!-- Workspace Action -->
            <div class="bg-white dark:bg-gray-800 rounded-xl shadow-sm border border-gray-200 dark:border-gray-700/50 p-8 flex flex-col justify-center items-center text-center flex-grow relative overflow-hidden">
                <div class="w-16 h-16 bg-blue-50 dark:bg-blue-900/20 text-primary rounded-2xl flex items-center justify-center mb-5 shadow-inner border border-blue-100 dark:border-blue-800/30">
                    <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 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2m-3 7h3m-3 4h3m-6-4h.01M9 16h.01"></path></svg>
                </div>
                <h2 class="text-2xl font-bold text-gray-900 dark:text-white mb-2">Your Workspace</h2>
                <p class="text-sm text-gray-600 dark:text-gray-400 mb-6 max-w-md leading-relaxed">
                    Check your active jobcard matrix to begin logging time, adding materials, and executing client requests.
                </p>
                <a href="<?php echo URLROOT; ?>/staff/jobcards" class="bg-primary hover:opacity-90 text-white font-bold py-2.5 px-8 rounded-lg transition-all focus:ring-4 focus:ring-primary/50 shadow-sm inline-block">
                    View Active Jobcards
                </a>
            </div>

        </div>
    </div>
</div>

<?php require APPROOT . '/app/Views/layouts/footer.php'; ?>