<div class="row justify-content-center">
  <div class="col-11 col-sm-8 col-md-6 col-lg-5 col-xl-4 col-xxl-3">

  <h2>
    <i class="bi bi-door-open me-1"></i> Log in
  </h2>
  <p class="lead">Who goes there?</p>

  <%= form_for @conn, Routes.user_session_path(@conn, :create), [as: :user, class: "needs-validation", novalidate: true], fn f -> %>
    <%= if @error_message do %>
      <div class="alert alert-danger alert-dismissible fade show mt-4" role="alert">
        <%= @error_message %>
        <button type="button" class="btn-close" data-bs-dismiss="alert" aria-label="Close"></button>
      </div>
    <% end %>

    <%= label f, :email, class: "form-label" %>
    <div class="inner-addon left-addon mb-3">
      <i class="bi bi-at icon is-left text-muted fs-5"></i>
      <%= email_input f, :email,
          class: "form-control",
          placeholder: "e.g., babka@73k.us",
          maxlength: User.max_email,
          autofocus: true,
          required: true
        %>
      <span class="invalid-feedback">must be a valid email address</span>
    </div>

    <%= label f, :password, class: "form-label" %>
    <div class="inner-addon left-addon mb-3">
      <i class="bi bi-lock icon is-left text-muted fs-5"></i>
      <%= password_input f, :password,
          class: "form-control",
          required: true
        %>
      <span class="invalid-feedback">password is required</span>
    </div>

    <div class="form-check mb-3 no-valid-style">
      <%= checkbox f, :remember_me, class: "form-check-input" %>
      <%= label f, :remember_me, "Keep me logged in for 60 days", class: "form-check-label" %>
    </div>

    <div class="mb-3">
      <%= submit "Log in", class: "btn btn-primary" %>
    </div>

  <% end %>

  <p>
    <%= if allow_registration() do %>
      <%= link "Register", to: Routes.user_registration_path(@conn, :new) %> |
    <% end %>
    <%= link "Forgot your password?", to: Routes.user_reset_password_path(@conn, :new) %>
  </p>

  </div>
</div>
