<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>First-Time Setup — {{ brand_name }}</title>
  <link rel="icon" type="image/png" href="/static/icon.png">
  <link rel="stylesheet" href="/static/style.css?v={{ sv }}">
  <style>
    body { display: flex; align-items: center; justify-content: center; min-height: 100vh; margin: 0; }
    .auth-card {
      background: var(--bg2);
      border: 1px solid var(--border);
      border-radius: var(--radius);
      padding: 2.5rem 2rem;
      width: 100%;
      max-width: 400px;
    }
    .auth-logo { text-align: center; margin-bottom: 1.5rem; }
    .auth-logo img { height: 48px; width: 48px; object-fit: contain; }
    .auth-logo-name { font-size: 1.25rem; font-weight: 600; margin-top: 0.5rem; color: var(--text); }
    .auth-logo-sub { font-size: 0.75rem; color: var(--text-dim); margin-top: 0.15rem; }
    .setup-heading { font-size: 1rem; font-weight: 600; margin-bottom: 0.25rem; color: var(--text); }
    .setup-desc { font-size: 0.82rem; color: var(--text-dim); margin-bottom: 1.25rem; }
    .auth-error {
      background: rgba(224,82,82,0.1);
      border: 1px solid rgba(224,82,82,0.3);
      color: var(--red);
      padding: 0.6rem 0.9rem;
      border-radius: var(--radius);
      font-size: 0.85rem;
      margin-bottom: 1rem;
    }
    .auth-field { margin-bottom: 1rem; }
    .auth-field label { display: block; font-size: 0.8rem; color: var(--text-dim); margin-bottom: 0.35rem; }
    .auth-field input {
      width: 100%;
      box-sizing: border-box;
      background: var(--bg3);
      border: 1px solid var(--border);
      border-radius: var(--radius);
      color: var(--text);
      padding: 0.6rem 0.75rem;
      font-size: 0.9rem;
      font-family: var(--font);
      outline: none;
      transition: border-color 0.15s;
    }
    .auth-field input:focus { border-color: var(--accent-dim); }
    .auth-btn {
      width: 100%;
      padding: 0.65rem;
      background: var(--accent);
      color: #fff;
      border: none;
      border-radius: var(--radius);
      font-size: 0.9rem;
      font-family: var(--font);
      font-weight: 600;
      cursor: pointer;
      margin-top: 0.5rem;
      transition: opacity 0.15s;
    }
    .auth-btn:hover { opacity: 0.88; }
  </style>
</head>
<body>
  <div class="auth-card">
    <div class="auth-logo">
      <img src="{{ logo_url }}" alt="logo">
      <div class="auth-logo-name">{{ brand_name }}</div>
      <div class="auth-logo-sub">oAI-Web</div>
    </div>

    <div class="setup-heading">Create admin account</div>
    <div class="setup-desc">No users exist yet. Create the first admin account to get started.</div>

    {% if errors %}
    <div class="auth-error">
      {% for e in errors %}<div>{{ e }}</div>{% endfor %}
    </div>
    {% endif %}

    <form method="post" action="/setup">
      <div class="auth-field">
        <label for="username">Username</label>
        <input type="text" id="username" name="username" value="{{ username }}" autocomplete="username" autofocus required>
      </div>
      <div class="auth-field">
        <label for="email">Email</label>
        <input type="email" id="email" name="email" value="{{ email }}" autocomplete="email" required>
      </div>
      <div class="auth-field">
        <label for="password">Password (min 8 characters)</label>
        <input type="password" id="password" name="password" autocomplete="new-password" required>
      </div>
      <div class="auth-field">
        <label for="confirm">Confirm password</label>
        <input type="password" id="confirm" name="confirm" autocomplete="new-password" required>
      </div>
      <button type="submit" class="auth-btn">Create account &amp; sign in</button>
    </form>
  </div>
</body>
</html>
