<% @page_title = "Sign up for Fizzy" %>

<div class="panel shadow center margin-block-double <%= "shake" if flash[:alert] %>" style="--panel-size: 65ch;">
  <h1 class="txt-xx-large margin-block-end-double">Fizzy</h1>
  <h2 class="txt-large margin-block-end-double">Create your account</h2>

  <%= form_with model: @signup, url: signup_accounts_path, scope: "signup", class: "flex flex-column gap txt-large", data: { turbo: false } do |form| %>
    <div class="flex align-center gap">
      <label class="flex align-center gap input input--actor txt-large">
        <%= form.text_field :full_name, class: "input", autocomplete: "name", placeholder: "Your name", autofocus: true, required: true %>
        <%= icon_tag "person", class: "txt-large" %>
      </label>
    </div>

    <div class="flex align-center gap">
      <label class="flex align-center gap input input--actor txt-large">
        <%= form.email_field :email_address, class: "input", autocomplete: "username", placeholder: "Your email address", required: true %>
        <%= icon_tag "email", class: "txt-large" %>
      </label>
    </div>

    <div class="flex align-center gap">
      <label class="flex align-center gap input input--actor txt-large">
        <%= form.text_field :company_name, class: "input", autocomplete: "organization", placeholder: "Your organization's name", required: true %>
        <%= icon_tag "building", class: "txt-large" %>
      </label>
    </div>

    <div class="flex align-center gap">
      <label class="flex align-center gap input input--actor txt-large">
        <%= form.password_field :password, class: "input", autocomplete: "new-password", placeholder: "Password (at least 12 characters)", required: true, maxlength: 72, minlength: 12 %>
        <%= icon_tag "password", class: "txt-large" %>
      </label>
    </div>

    <% if @signup.errors.any? %>
      <div class="alert alert--error">
        <ul class="margin-block-none">
          <% @signup.errors.full_messages.each do |message| %>
            <li><%= message %></li>
          <% end %>
        </ul>
      </div>
    <% end %>

    <button type="submit" class="btn btn--reversed center">
      <%= icon_tag "arrow-right" %>
      <span>Create your account</span>
    </button>
  <% end %>

  <footer class="margin-block-start-double txt-center">
    <p class="txt-small txt-muted">
      Already have an account? 
      <%= link_to "Sign in", Launchpad.login_url(product: true), class: "decorated" %>
    </p>
  </footer>
</div>
