<%= render 'submissions/preview_tags' %>
<div class="max-w-md mx-auto px-2 mt-12 mb-4">
  <div class="space-y-6 mx-auto">
    <div class="space-y-6">
      <div class="flex items-center justify-center">
        <%= render 'start_form/banner' %>
      </div>
      <div class="flex items-center bg-base-200 rounded-xl p-4 mb-4">
        <div class="flex items-center">
          <div class="mr-3">
            <%= svg_icon('writing_sign', class: 'w-10 h-10') %>
          </div>
          <div>
            <p dir="auto" class="text-lg font-bold mb-1"><%= @submission.template.name %></p>
            <% last_submitter = @submission.submitters.completed.order(:completed_at).last %>
            <% if last_submitter %>
              <p dir="auto" class="text-sm">
                <%= t(last_submitter.with_signature_fields? ? 'signed_on_time' : 'completed_on_time', time: l(last_submitter.completed_at.to_date, format: :long)) %>
              </p>
            <% end %>
          </div>
        </div>
      </div>
    </div>
    <% if Docuseal.multitenant? || Accounts.can_send_emails?(@submission.account) %>
      <%= form_for '', url: send_submission_email_index_path, method: :post, html: { class: 'space-y-4' } do |f| %>
        <div dir="auto" class="form-control !mt-0">
          <%= f.hidden_field :submission_slug, value: @submission.slug %>
          <%= f.label :email, t('email'), class: 'label' %>
          <%= f.email_field :email, value: current_user&.email || params[:email], required: true, class: 'base-input', placeholder: t('send_copy_to_email') %>
          <% if params[:status] == 'error' %>
            <span class="label-text-alt text-red-400 mt-1">
              <%= t('please_enter_your_email_address_associated_with_the_completed_submission') %>
            </span>
          <% end %>
        </div>
        <toggle-submit dir="auto" class="form-control">
          <%= f.button button_title(title: t('send_copy_to_email'), disabled_with: t('starting')), class: 'base-button' %>
        </toggle-submit>
      <% end %>
      <% if Docuseal.multitenant? %>
        <div class="divider uppercase"><%= t('or') %></div>
      <% end %>
    <% end %>
    <% if Docuseal.multitenant? %>
      <div>
        <%= link_to t('create_free_account'), registration_path, class: 'white-button w-full' %>
      </div>
    <% end %>
  </div>
</div>
<%= render 'shared/attribution', link_path: '/start', account: @submission.account %>
