<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title><?php echo $pageTitle ?? 'Inventory 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; }
    </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"
            style="background:#0d2137; 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,#f59e0b,#d97706)">
                <i class="fas fa-boxes text-white text-sm"></i>
            </div>
            <div>
                <div class="text-white font-bold text-sm leading-tight">Inventory Manager</div>
                <div class="text-xs font-medium" style="color:#f59e0b"><?php echo htmlspecialchars($_SESSION['name']); ?></div>
            </div>
        </div>
        <a href="/restpo/logout"
           class="flex items-center gap-2 text-xs font-semibold px-3 py-2 rounded-lg transition text-slate-400 hover:text-red-400"
           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"
     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"
     style="background:#ef4444; color:white">
    <i class="fas fa-exclamation-circle"></i> <?php echo htmlspecialchars($_GET['error']); ?>
</div>
<?php endif; ?>
</body>
</html>
