<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8" />
  <meta name="viewport" content="width=device-width, initial-scale=1.0" />
  <meta http-equiv="Content-Security-Policy"
        content="default-src 'self' https://cdnjs.cloudflare.com; connect-src 'self' http://localhost:8080 <?= base_url() ?> https://cdnjs.cloudflare.com; script-src 'self' https://cdnjs.cloudflare.com; style-src 'self' 'unsafe-inline' https://cdnjs.cloudflare.com; img-src 'self' data:; font-src https://cdnjs.cloudflare.com;" />
  <title>Al Rahma Sunday School — API Docs</title>
  <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/swagger-ui/5.10.5/swagger-ui.min.css" />
  <style>
    html, body { height: 100%; margin: 0; font-family: "Segoe UI", Roboto, Helvetica, Arial, sans-serif; background-color: #fafafa; }
    .topbar { background-color: #15654f !important; }
    .topbar-wrapper .link { color: white !important; font-weight: 600; }
    .swagger-ui .info { margin-top: 2rem; }
    .admin-banner { background-color: #15654f; color: white; padding: 0.75rem 1.25rem; text-align: right; font-weight: 600; box-shadow: 0 2px 4px rgba(0,0,0,0.1); position: sticky; top: 0; z-index: 1000; }
    .admin-banner span { color: #f2f2f2; font-weight: 500; opacity: 0.9; }
  </style>
</head>
<body>
  <?php $adminName = session()->get('name') ?? session()->get('username') ?? 'Admin'; ?>
  <div class="admin-banner">👋 Welcome, <span><?= esc($adminName) ?></span></div>
  <div id="swagger-ui"></div>
  <script src="https://cdnjs.cloudflare.com/ajax/libs/swagger-ui/5.10.5/swagger-ui-bundle.min.js"></script>
  <script src="https://cdnjs.cloudflare.com/ajax/libs/swagger-ui/5.10.5/swagger-ui-standalone-preset.min.js"></script>
  <script>
    window.onload = function () {
      SwaggerUIBundle({
        url: "<?= base_url('docs/openapi/master.yaml') ?>",
        dom_id: "#swagger-ui",
        deepLinking: true,
        docExpansion: "none",
        filter: true,
        tryItOutEnabled: true,
        persistAuthorization: true,
        presets: [SwaggerUIBundle.presets.apis, SwaggerUIStandalonePreset],
        layout: "StandaloneLayout",
      });
    };
  </script>
</body>
</html>
