<?php
/**
 * Layout admin - /app/views/layouts/admin.php
 */
?>
<!DOCTYPE html>
<html lang="pt-BR">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title><?= e($pageTitle ?? 'OFFICE Admin') ?></title>
<link href="https://fonts.googleapis.com/css2?family=Cormorant+Garamond:wght@500;600&family=Inter:wght@300;400;500;600;700&display=swap" rel="stylesheet">
<link rel="stylesheet" href="<?= url('assets/css/admin.css') ?>">
</head>
<body class="admin-body">

<div class="admin-wrapper">

  <aside class="admin-sidebar" id="adminSidebar">
    <div class="admin-sidebar__brand">
      <div class="logo">OFFICE</div>
      <small>Painel Administrativo</small>
    </div>
    <ul class="admin-nav">
      <li><a href="<?= admin_url('dashboard') ?>" class="<?= is_active('dashboard') ?>">⊟ Dashboard</a></li>

      <li class="section-label">Catálogo</li>
      <li><a href="<?= admin_url('produtos') ?>" class="<?= is_active('produtos') ?>">◻ Produtos</a></li>
      <li><a href="<?= admin_url('categorias') ?>" class="<?= is_active('categorias') ?>">⊟ Categorias</a></li>
      <li><a href="<?= admin_url('colecoes') ?>" class="<?= is_active('colecoes') ?>">✧ Coleções</a></li>

      <li class="section-label">Vendas</li>
      <li><a href="<?= admin_url('pedidos') ?>" class="<?= is_active('pedidos') ?>">☰ Pedidos</a></li>

      <li class="section-label">Sistema</li>
      <li><a href="<?= admin_url('catalogo-pdf') ?>" class="<?= is_active('catalogo-pdf') ?>">❏ Catálogo PDF</a></li>
      <li><a href="<?= admin_url('configuracoes') ?>" class="<?= is_active('configuracoes') ?>">⚙ Configurações</a></li>

      <li style="margin-top:32px"><a href="<?= url() ?>" target="_blank" style="color:var(--admin-gold)">↗ Ver site</a></li>
      <li><a href="<?= admin_url('logout') ?>">↪ Sair</a></li>
    </ul>
  </aside>

  <div class="admin-main">
    <div class="admin-topbar">
      <div style="display:flex;align-items:center">
        <button class="admin-toggle" onclick="document.getElementById('adminSidebar').classList.toggle('open')">☰</button>
        <h1><?= e($pageTitle ?? '') ?></h1>
      </div>
      <div class="admin-topbar__user">
        <span><?= e($_SESSION['admin_nome'] ?? '') ?></span>
        <span class="avatar"><?= mb_substr(($_SESSION['admin_nome'] ?? 'A'), 0, 1) ?></span>
      </div>
    </div>

    <div class="admin-content">
      <?php if (has_flash('success')): ?><div class="flash success"><?= e(flash('success')) ?></div><?php endif; ?>
      <?php if (has_flash('error')): ?><div class="flash error"><?= e(flash('error')) ?></div><?php endif; ?>

      <?= $content ?>
    </div>
  </div>
</div>

</body>
</html>
