<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title><?php echo htmlspecialchars($pageTitle ?? 'HR Manager'); ?> - RestPO</title>
    <script src="https://cdn.tailwindcss.com"></script>
    <script defer src="https://cdn.jsdelivr.net/npm/alpinejs@3.x.x/dist/cdn.min.js"></script>
    <link href="https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&display=swap" rel="stylesheet">
    <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.4.0/css/all.min.css">
    <style>
        * { font-family: 'Inter', sans-serif; }
        body { background: #0d1117; color: white; }
        ::-webkit-scrollbar { width:4px; } ::-webkit-scrollbar-thumb { background:rgba(255,255,255,0.1); border-radius:10px; }
        @media print { .no-print { display:none!important; } }
    </style>
</head>
<body>
<div class="min-h-screen flex flex-col">
    <!-- Top Nav -->
    <header class="h-16 flex items-center justify-between px-6 flex-shrink-0 no-print"
            style="background:#0d1f3a; border-bottom:1px solid rgba(255,255,255,0.07)">
        <div class="flex items-center gap-3">
            <div class="w-9 h-9 rounded-xl flex items-center justify-center flex-shrink-0"
                 style="background:linear-gradient(135deg,#6366f1,#4f46e5)">
                <i class="fas fa-users-cog text-white text-sm"></i>
            </div>
            <div>
                <div class="text-white font-bold text-sm leading-tight">HR Manager</div>
                <div class="text-xs font-medium" style="color:#818cf8"><?php echo htmlspecialchars($_SESSION['name']); ?></div>
            </div>
        </div>
        <!-- Tab navigation in header -->
        <nav class="flex items-center gap-1">
            <?php
            $base = '/restpo/hr';
            $tabs = [
                'staff'      => ['icon'=>'fas fa-users',          'label'=>'Staff',      'url'=>$base],
                'attendance' => ['icon'=>'fas fa-calendar-check', 'label'=>'Attendance', 'url'=>$base.'/attendance'],
                'payroll'    => ['icon'=>'fas fa-money-bill-wave','label'=>'Payroll',    'url'=>$base.'/payroll'],
            ];
            $currentTab = $activeTab ?? 'staff';
            foreach ($tabs as $key => $tab):
                $isActive = $key === $currentTab;
            ?>
            <a href="<?php echo $tab['url']; ?>"
               class="flex items-center gap-2 px-4 py-2 rounded-xl text-sm font-semibold transition <?php echo $isActive ? 'text-white' : 'text-slate-400 hover:text-white hover:bg-white/5'; ?>"
               style="<?php echo $isActive ? 'background:rgba(99,102,241,0.25); border:1px solid rgba(99,102,241,0.4)' : ''; ?>">
                <i class="<?php echo $tab['icon']; ?> text-xs"></i>
                <?php echo $tab['label']; ?>
            </a>
            <?php endforeach; ?>
        </nav>
        <a href="/restpo/logout"
           class="flex items-center gap-2 text-xs font-semibold px-3 py-2 rounded-lg text-slate-400 hover:text-red-400 transition"
           style="border:1px solid rgba(255,255,255,0.08)">
            <i class="fas fa-sign-out-alt"></i> Sign Out
        </a>
    </header>

    <!-- Content -->
    <main class="flex-1 overflow-y-auto p-5">
        <?php echo $content; ?>
    </main>
</div>

<!-- Toast -->
<?php if(isset($_GET['success'])): ?>
<div x-data="{show:true}" x-show="show" x-init="setTimeout(()=>show=false,3500)"
     class="fixed bottom-6 right-6 z-50 flex items-center gap-3 px-4 py-3 rounded-xl shadow-xl text-sm font-medium no-print"
     style="background:#10b981; color:white">
    <i class="fas fa-check-circle"></i> <?php echo htmlspecialchars($_GET['success']); ?>
</div>
<?php endif; ?>
<?php if(isset($_GET['error'])): ?>
<div x-data="{show:true}" x-show="show" x-init="setTimeout(()=>show=false,4500)"
     class="fixed bottom-6 right-6 z-50 flex items-center gap-3 px-4 py-3 rounded-xl shadow-xl text-sm font-medium no-print"
     style="background:#ef4444; color:white">
    <i class="fas fa-exclamation-circle"></i> <?php echo htmlspecialchars($_GET['error']); ?>
</div>
<?php endif; ?>
</body>
</html>
