<?php
require_once __DIR__ . '/../../config/bootstrap.php';
$pdo = db();
$base = app_base_path();
$brandLogo = $base . '/assets/img/fb-logo.svg';
$avatarImg = $base . '/assets/img/avatar.png';
$btnPlus = $base . '/assets/img/btn-plus-blue.svg';
$btnWeb = $base . '/assets/img/btn-web-orange.svg';
$btnOut = $base . '/assets/img/btn-sign-out.svg';

$builderVersion = app_config_get($pdo, 'builder_version', 'v1.6');
$u = $_SESSION['admin_user'] ?? ['nome' => 'Admin', 'email' => ''];
?><!doctype html>
<html lang="pt-br">
<head>
  <meta charset="utf-8">
  <meta name="viewport" content="width=device-width, initial-scale=1">
  <title><?= htmlspecialchars($title ?? 'Admin'); ?></title>
  <link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.3/dist/css/bootstrap.min.css" rel="stylesheet">
  <link href="<?= $base; ?>/assets/css/fb-admin.css" rel="stylesheet">
</head>
<body class="fb-body">

<div class="fb-topbar">
  <div class="container fb-wrap">
    <div class="fb-topbar-inner">
      <div class="fb-brand">
        <a href="index.php"><img src="<?= htmlspecialchars($brandLogo); ?>" alt="FrameBuilder"></a>
        <small>Versão do builder <?= htmlspecialchars($builderVersion); ?></small>
      </div>
      <div class="fb-userbox">
        <a class="fb-iconbtn" href="<?= $base; ?>/admin/events.php" title="Novo evento" aria-label="Novo evento">
          <img src="<?= htmlspecialchars($btnPlus); ?>" alt="+">
        </a>
        <a class="fb-iconbtn" href="<?= $base; ?>/" target="_blank" title="Abrir público" aria-label="Abrir público">
          <img src="<?= htmlspecialchars($btnWeb); ?>" alt="Web">
        </a>
        <img class="fb-avatar" src="<?= htmlspecialchars($avatarImg); ?>" alt="Avatar">
        <div class="fb-usertext">
          <div class="n"><?= htmlspecialchars((string)$u['nome']); ?></div>
          <div class="e"><?= htmlspecialchars((string)$u['email']); ?></div>
        </div>
        <a class="fb-iconbtn" href="<?= $base; ?>/admin/logout.php" style="height: 30px;" title="Sair" aria-label="Sair">
          <img src="<?= htmlspecialchars($btnOut); ?>" alt="Sair">
        </a>
      </div>
    </div>
  </div>
</div>

<main class="container fb-wrap py-4">
