<PhoenixKitWeb.Components.AuthPageWrapper.auth_page_wrapper
  flash={@flash}
  phoenix_kit_current_scope={assigns[:phoenix_kit_current_scope]}
  page_title={gettext("Resend confirmation")}
  current_path={assigns[:url_path] || "/users/confirm"}
  dev_mailbox_message={gettext("confirmation emails")}
>
  <%= if @awaiting_confirmation? do %>
    <h1 class="text-2xl font-bold text-center mb-2">
      {gettext("Confirm your email")}
    </h1>
    <p class="text-center text-base-content/60 text-sm mb-6">
      {gettext(
        "We sent a confirmation link to your inbox. This page continues automatically once your email is confirmed."
      )}
    </p>
  <% else %>
    <h1 class="text-2xl font-bold text-center mb-2">
      {gettext("No confirmation instructions received?")}
    </h1>
    <p class="text-center text-base-content/60 text-sm mb-6">
      {gettext("We'll send a new confirmation link to your inbox")}
    </p>
  <% end %>
  <.form for={@form} id="resend_confirmation_form" phx-submit="send_instructions">
    <fieldset class="fieldset min-w-0">
      <legend class="fieldset-legend sr-only">{gettext("Resend Confirmation")}</legend>
      <.input
        field={@form[:email]}
        type="email"
        label={gettext("Email")}
        required
        readonly={@awaiting_confirmation?}
      />
      <button
        type="submit"
        phx-disable-with={gettext("Sending...")}
        class="btn btn-primary w-full mt-4 transition-all hover:scale-[1.02] active:scale-[0.98]"
      >
        {gettext("Resend confirmation instructions")} <span aria-hidden="true">→</span>
      </button>
    </fieldset>
  </.form>

  <%= if @awaiting_confirmation? do %>
    <div class="text-center mt-4">
      <button
        type="button"
        phx-click="toggle_change_email"
        class="text-sm font-semibold text-primary hover:underline"
      >
        {if @change_email?, do: gettext("Cancel"), else: gettext("Wrong email? Change it")}
      </button>
    </div>

    <%= if @change_email? do %>
      <.form
        for={@email_form}
        id="change_email_form"
        phx-submit="update_email"
        phx-change="validate_email_change"
        class="mt-4"
      >
        <fieldset class="fieldset min-w-0">
          <legend class="fieldset-legend sr-only">{gettext("Change Email")}</legend>
          <.input field={@email_form[:email]} type="email" label={gettext("New email")} required />
          <.input
            field={@email_form[:current_password]}
            name="current_password"
            id="change-email-current-password"
            type="password"
            label={gettext("Current password")}
            value={@email_form_current_password}
            required
          />
          <button
            type="submit"
            phx-disable-with={gettext("Updating...")}
            class="btn btn-secondary w-full mt-4"
          >
            {gettext("Update email & resend confirmation")}
          </button>
        </fieldset>
      </.form>
    <% end %>
  <% end %>

  <div class="text-center mt-4 text-sm">
    <.link
      href={Routes.path("/users/register")}
      class="font-semibold text-primary hover:underline"
    >
      {gettext("Register")}
    </.link>
    <span class="mx-2 text-base-content/40">|</span>
    <.link
      href={Routes.path("/users/log-in")}
      class="font-semibold text-primary hover:underline"
    >
      {gettext("Log in")}
    </.link>
  </div>
</PhoenixKitWeb.Components.AuthPageWrapper.auth_page_wrapper>
