<?php
require_once __DIR__ . '/includes/initialize.php';
$u = current_user();
$title = $page_title ?? 'Admin';
$content = $content ?? '';
?>
<!doctype html>
<html lang="en">
<head>
  <meta charset="utf-8"><title><?=htmlspecialchars($title)?> - Pacific Admin</title>
  <meta name="viewport" content="width=device-width,initial-scale=1">
  <link rel="stylesheet" href="/adminconsole/assets/ui.css">
  <style>
    .app{display:grid;grid-template-columns:280px 1fr;min-height:100vh}
    .side{background:linear-gradient(180deg,var(--primary),var(--primary-dark));padding:18px 14px;position:sticky;top:0;height:100vh;color:#fff}
    .brand{display:flex;align-items:center;gap:12px;padding:8px 10px 20px;margin-bottom:14px;border-bottom:1px solid rgba(255,255,255,.14)}
    .brand img{width:44px;height:44px;object-fit:contain;border-radius:12px;background:#fff;padding:4px}
    .brand strong{font-size:16px;color:#fff}
    nav a{display:block;padding:11px 12px;border-radius:12px;color:#fff;text-decoration:none;margin:5px 0;font-weight:650;transition:.18s ease}
    nav a:hover{background:var(--primary-hover);transform:translateX(2px)}
    nav .head{margin-top:18px;color:rgba(255,255,255,.64);font-size:11px;font-weight:800;letter-spacing:.08em;text-transform:uppercase;padding:6px 12px}
    .main{display:flex;flex-direction:column;background:var(--bg-white)}
    .top{display:flex;justify-content:space-between;align-items:center;padding:14px 26px;background:linear-gradient(90deg,var(--primary-dark),var(--primary));color:#fff;box-shadow:0 8px 24px rgba(35,59,104,.18)}
    .wrap{padding:26px}
    .grid{display:grid;grid-template-columns:repeat(auto-fill,minmax(220px,1fr));gap:16px}
    .card h2{margin:0 0 6px;font-size:26px}
    .card span{color:var(--text-secondary);font-size:13px}
    @media(max-width:980px){.app{grid-template-columns:1fr}.side{position:relative;height:auto}}
  </style>
</head>
<body>
<div class="app">
  <aside class="side">
    <div class="brand">
      <img src="/adminconsole/uploads/logo.jpeg" alt="logo">
      <strong>Pacific iConnect</strong>
    </div>
    <nav>
      <a href="/adminconsole/index.php">🏠 Dashboard</a>
      <div class="head">MAIN MENUS</div>
      <a href="/adminconsole/masters/index.php">🧩 Masters</a>
      <a href="/adminconsole/operations/index.php">🛠️ Operations</a>
      <a href="/adminconsole/reports/index.php">📊 Reports</a>
      <div class="head">ACCOUNT</div>
      <a href="/adminconsole/logout.php">🚪 Logout</a>
    </nav>
  </aside>

  <main class="main">
    <div class="top">
      <div><strong><?=htmlspecialchars($title)?></strong></div>
      <div>
        <?php if($u): ?>
          <span style="color:#9ca3af;margin-right:10px">Hello, <?=htmlspecialchars($u['name'])?> (<?=htmlspecialchars($u['role'])?>)</span>
        <?php endif; ?>
        
      </div>
    </div>
    <div class="wrap">
      <?= $content ?>
    </div>
  </main>
</div>
</body>
</html>
