{{define "login.html"}}
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Switchboard Core</title>
    <link rel="icon" type="image/svg+xml" href="{{.BasePath}}/favicon.svg?v={{.Version}}">
    <link rel="icon" type="image/x-icon" href="{{.BasePath}}/favicon.ico?v={{.Version}}">
    <link href="https://fonts.googleapis.com/css2?family=DM+Sans:opsz,wght@9..40,300;9..40,400;9..40,500;9..40,600;9..40,700&family=JetBrains+Mono:wght@400;500&display=swap" rel="stylesheet">
    <link rel="stylesheet" href="{{.BasePath}}/css/variables.css?v={{.Version}}">
    <link rel="stylesheet" href="{{.BasePath}}/css/sw-login.css?v={{.Version}}">
    <style>
        * { margin: 0; padding: 0; box-sizing: border-box; }
        body { font-family: var(--font); background: var(--bg); color: var(--text); overflow: hidden; }
        ::-webkit-scrollbar { width: 5px; }
        ::-webkit-scrollbar-track { background: transparent; }
        ::-webkit-scrollbar-thumb { border-radius: 3px; background: var(--border); }
    </style>
</head>
<body>
    <div id="login-mount"></div>

    <script>
        window.__BASE__ = '{{.BasePath}}';
        window.__AUTH_MODE__ = '{{.AuthMode}}';
        window.__REGISTRATION_OPEN__ = {{if .RegistrationOpen}}true{{else}}false{{end}};
        window.__VERSION__ = '{{.Version}}';
        window.__ENVIRONMENT__ = {{if .Environment}}'{{.Environment}}'{{else}}null{{end}};
        window.__BANNER__ = {{if .Banner.Visible}}{
            visible: true,
            text: '{{.Banner.Text}}',
            background: '{{.Banner.Background}}',
            color: '{{.Banner.Color}}'
        }{{else}}null{{end}};
    </script>

    {{/* Vendor: Preact + htm → globals (window.preact, window.hooks, window.html) */}}
    <script type="module">
        const { h, render } = await import('{{.BasePath}}/js/sw/vendor/preact.module.js');
        const hooksModule = await import('{{.BasePath}}/js/sw/vendor/hooks.module.js');
        const { default: htm } = await import('{{.BasePath}}/js/sw/vendor/htm.module.js');
        const html = htm.bind(h);
        window.preact = { h, render };
        window.hooks = hooksModule;
        window.html = html;

        {{/* SDK boot → window.sw */}}
        const { boot } = await import('{{.BasePath}}/js/sw/sdk/index.js?v={{.Version}}');
        await boot();

        {{/* Login surface */}}
        await import('{{.BasePath}}/js/sw/surfaces/login/index.js?v={{.Version}}');
    </script>
</body>
</html>
{{end}}
