<?php
$app = app();

// Example: register assets from inside a landing template
$app->assets()->addStyle('/assets/app.css', 'early');
$app->assets()->addScript('/assets/app.js', 'footer', true);

$flash = $app->flash()->get();
?>
<div class="card">
  <div class="pill">env: <?= htmlspecialchars($app->config()->env, ENT_QUOTES) ?></div>
  <h1 style="margin-top: .75rem;"><?= htmlspecialchars(t('common.title'), ENT_QUOTES) ?></h1>

  <p class="muted"><?= htmlspecialchars(t('common.intro'), ENT_QUOTES) ?></p>

  <?php if ($flash): ?>
    <div style="margin: 1rem 0; padding: .75rem 1rem; border: 1px solid #ddd; border-radius: 12px;">
      <strong><?= htmlspecialchars($flash['type'], ENT_QUOTES) ?>:</strong>
      <?= htmlspecialchars($flash['message'], ENT_QUOTES) ?>
    </div>
  <?php endif; ?>

  <div class="grid" style="margin-top: 1rem;">
    <div>
      <h3 style="margin: 0 0 .5rem 0;">Runtime</h3>
      <div><strong>Current URL:</strong> <?= htmlspecialchars($app->request()->currentUrl(), ENT_QUOTES) ?></div>
      <div><strong>Client-ID:</strong> <code><?= htmlspecialchars($GLOBALS['client_id'] ?? '', ENT_QUOTES) ?></code></div>
    </div>
    <div>
      <h3 style="margin: 0 0 .5rem 0;">Actions</h3>
      <form method="post" action="/action/flash">
        <button type="submit" style="padding:.6rem 1rem; border-radius: 12px; border: 1px solid #ddd; background: white; cursor:pointer;">
          Set flash message
        </button>
      </form>
      <p class="muted" style="margin-top:.5rem;">Flash uses SessionManager, no direct globals.</p>
    </div>
  </div>
</div>
