<div class="content__form-container pr-8">
  <div class="sci-divider my-6"></div>
  <div class="max-w-[800px] w-full rounded bg-sn-super-light-grey p-6 flex flex-col gap-4">
    <div class="flex items-center">
      <h3 class="my-1"><%= element.form.name %></h3>
      <% if element.status == 'submitted' %>
        <div class="ml-auto text-right text-xs text-sn-grey-700">
          <%= t('forms.response.submitted_on') %> <span class='iso-formatted-date'><%= element.submitted_at.iso8601 %></span><br>
          <%= t('forms.response.by') %> <%= element.submitted_by&.full_name %>
        </div>
      <% else %>
        <div class="ml-auto text-right text-xs text-sn-grey-700">
          <%= t('forms.response.not_submitted') %>
        </div>
      <% end %>
    </div>
    <% element.form.form_fields.each do |field| %>
      <div class="p-4 rounded bg-white text-sm mb-2">
        <div class="grow">
          <div class="font-bold">
            <%= field.name %>
            <% if field.data['unit'] %>
              <span>(<%= field.data['unit'] %>)</span>
            <% end %>
            <% if field.required %>
              <span  class="text-sn-delete-red">*</span>
            <% end %>
          </div>
          <% if field.description %>
            <div>
              <%= smart_annotation_text(field.description) %>
            </div>
          <% end %>
          <div class="mt-2">
            <% field_value = element.form_field_values.find_by(form_field_id: field.id, latest: true) %>
            <% if field_value&.not_applicable %>
              <%= t('forms.export.values.not_applicable') %>
            <% elsif field_value&.formatted.present? %>
              <% if field_value.is_a?(FormDatetimeFieldValue)%>
                <% if field_value.range? %>
                  <span class='iso-formatted-date <%= 'only-date' unless field.data['time'] %>'><%=  field_value.datetime&.iso8601 %></span>
                  -
                  <span class='iso-formatted-date <%= 'only-date' unless field.data['time'] %>'><%= field_value.datetime_to&.iso8601 %></span>
                <% else %>
                  <span class='iso-formatted-date <%= 'only-date' unless field.data['time'] %>'><%= field_value.datetime&.iso8601  %></span>
                <% end %>
              <% elsif field_value.is_a?(FormTextFieldValue)%>
                <%= smart_annotation_text(field_value.formatted) %>
              <% else %>
                <%= field_value.formatted %>
              <% end %>
            <% else %>
              —
            <% end %>
            <% if field_value && field_value.submitted_at %>
              <div class="text-sn-grey-700 text-xs text-right w-full mt-2">
                <span class='iso-formatted-date'><%= field_value.submitted_at.iso8601 %></span>
                <%= I18n.t('forms.fields.by') %>
                <span ><%= field_value.submitted_by.full_name %></span>
              </div>
            <% end %>
          </div>
        </div>
      </div>
    <% end%>
  </div>
</div>
