{{ define "login.gohtml" }}{{ template "base" . }}{{ end }}

{{ define "login_content" }}
<section class="auth-shell">
  <input type="hidden" data-auth-next value="{{ .Next }}" />
  <div class="auth-panel">
    <div class="auth-panel__header">
      <p class="eyebrow">Cairnquire</p>
      <h1 data-auth-heading>Log In</h1>
    </div>

    <div class="auth-login-section" data-login-section>
      <div class="auth-tabs">
        <div class="auth-tab-list" role="tablist">
          <button type="button" class="auth-tab is-active" role="tab" aria-selected="true" data-tab="passkey">Passkey</button>
          <button type="button" class="auth-tab" role="tab" aria-selected="false" data-tab="password">Password</button>
        </div>

        <div class="auth-tab-panel is-active" role="tabpanel" data-tab-panel="passkey">
          <form class="auth-form" data-passkey-login>
            <label>
              Email
              <input type="email" name="email" autocomplete="username webauthn" required />
            </label>
            <button type="submit" class="btn-primary">Use passkey</button>
            <p class="form-status" data-passkey-login-status></p>
          </form>
        </div>

        <div class="auth-tab-panel" role="tabpanel" data-tab-panel="password" hidden>
          <form class="auth-form" data-auth-login>
            <label>
              Email
              <input type="email" name="email" autocomplete="email" required />
            </label>
            <label>
              Password
              <input type="password" name="password" autocomplete="current-password" required />
            </label>
            <button type="submit" class="btn-primary">Sign in</button>
            <p class="form-status" data-login-status></p>
          </form>
        </div>
      </div>

      {{ if .DevMode }}<div class="auth-dev-login">
        <p class="auth-note">Development mode is enabled. Use the local development admin without a password.</p>
        <button type="button" class="btn-secondary" data-dev-login>Continue as development admin</button>
        <p class="form-status" data-dev-login-status></p>
      </div>{{ end }}

      {{ if .SignupsEnabled }}<div class="auth-register-cta">
        <button type="button" class="btn-cta" data-register-toggle>Create an Account</button>
      </div>{{ end }}
    </div>

    {{ if .SignupsEnabled }}<div class="auth-register-panel" data-register-panel hidden>
      <div class="auth-tabs">
        <div class="auth-tab-list" role="tablist">
          <button type="button" class="auth-tab is-active" role="tab" aria-selected="true" data-tab="passkey-register">Passkey</button>
          <button type="button" class="auth-tab" role="tab" aria-selected="false" data-tab="password-register">Password</button>
        </div>

        <div class="auth-tab-panel is-active" role="tabpanel" data-tab-panel="passkey-register">
          <form class="auth-form" data-passkey-register>
            <label>
              Email
              <input type="email" name="email" autocomplete="email" required />
            </label>
            <label>
              Display name
              <input type="text" name="displayName" autocomplete="name" />
            </label>
            <button type="submit" class="btn-primary">Create passkey</button>
            <p class="form-status" data-passkey-register-status></p>
          </form>
        </div>

        <div class="auth-tab-panel" role="tabpanel" data-tab-panel="password-register" hidden>
          <form class="auth-form" data-auth-register>
            <label>
              Email
              <input type="email" name="email" autocomplete="email" required />
            </label>
            <label>
              Display name
              <input type="text" name="displayName" autocomplete="name" />
            </label>
            <label>
              Password
              <input type="password" name="password" autocomplete="new-password" minlength="12" required />
            </label>
            <button type="submit" class="btn-primary">Register</button>
            <p class="form-status" data-register-status></p>
          </form>
        </div>
      </div>

      <div class="auth-register-cancel">
        <button type="button" class="btn-secondary" data-register-cancel>Cancel — Back to Log In</button>
      </div>
    </div>{{ end }}
  </div>
</section>
{{ end }}
