---
interface Props { title: string }
const { title } = Astro.props;
const user = Astro.locals.user;
---
<!doctype html>
<html lang="it">
  <head>
    <meta charset="utf-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1" />
    <title>{title} — Admin InsanityLab</title>
    <meta name="robots" content="noindex" />
    <style is:global>
      body { font-family: system-ui, sans-serif; margin: 0; background: #f4f2ef; color: #333; }
      .abar { background: #3a2d26; color: #fff; padding: 12px 24px; display: flex; justify-content: space-between; align-items: center; }
      .abar a { color: #d9cfc4; text-decoration: none; margin-left: 16px; }
      .awrap { max-width: 960px; margin: 30px auto; padding: 0 20px; }
      .abtn { background: #b5a48b; color: #fff; border: 0; padding: 10px 18px; cursor: pointer; font-size: .9rem; text-decoration: none; display: inline-block; }
      .abtn--danger { background: #a33; }
      .afield { width: 100%; padding: 10px; margin-bottom: 14px; border: 1px solid #ccc; box-sizing: border-box; font: inherit; }
      table { width: 100%; border-collapse: collapse; background: #fff; }
      th, td { text-align: left; padding: 10px 12px; border-bottom: 1px solid #eee; font-size: .92rem; }
      .pill { font-size: .75rem; padding: 2px 10px; border-radius: 10px; background: #e5decf; }
      .pill--draft { background: #f3d9a4; }
      .form-msg { font-size: .9rem; margin-top: 8px; }
      .form-msg--ok { color: #3c7a3c; }
      .form-msg--err { color: #b03030; }
    </style>
  </head>
  <body>
    <div class="abar">
      <strong>InsanityLab · Admin</strong>
      <span>
        {user && (
          <>
            {`Ciao, ${user.username}`}
            <a href="/admin">Articoli</a>
            {(user.role === 'superuser' || user.role === 'admin') && <a href="/admin/content">Contenuti</a>}
            {user.role === 'admin' && <a href="/admin/users">Utenti</a>}
            <a href="/admin/new">Nuovo</a>
            <a href="/admin/logout">Esci</a>
            <a href="/blog" target="_blank">Vedi sito ↗</a>
          </>
        )}
      </span>
    </div>
    <div class="awrap"><slot /></div>
  </body>
</html>
