<div class="relative min-h-full max-w-full flex-1 flex flex-col justify-between space-y-3">
  <% if file.present? %>
    <div class="flex flex-col justify-between h-full">
      <% if file.representable? && is_image? %>
        <div class="max-h-[42rem] h-full flex">
          <%= image_tag helpers.main_app.url_for(file), class: 'rounded-lg object-cover' %>
        </div>
      <% elsif is_audio? %>
        <%= audio_tag(helpers.main_app.url_for(file), controls: true, preload: false, class: 'w-full') %>
      <% elsif is_video? %>
        <%= video_tag(helpers.main_app.url_for(file), controls: true, preload: false, class: 'w-full') %>
      <% else %>
        <div class="relative flex flex-col justify-evenly items-center px-2 rounded-lg border bg-white border-gray-500 min-h-24">
          <div class="flex flex-col justify-center items-center w-full">
            <%= helpers.svg 'document-text', class: 'h-10 text-gray-600 mb-2' %>
          </div>
        </div>
      <% end %>
      <span class="text-gray-500 mt-2 text-sm truncate" title="<%= file.filename %>"><%= file.filename %></span>
    </div>
    <div class="flex space-x-2">
      <div class="flex">
        <% if @resource.authorization.authorize_action(:download_attachments?, raise_exception: false) %>
          <%= a_link helpers.main_app.url_for(file),
            icon: 'heroicons/outline/download',
            color: :primary,
            download: true,
            class: 'text-center',
            title: t('avo.download_file'),
            data: { tippy: :tooltip },
            compact: true,
            size: :xs %>
        <% end %>
      </div>
      <div>
        <% if @resource.authorization.authorize_action(:delete_attachments?, raise_exception: false) %>
          <%= a_link destroy_path,
            icon: 'heroicons/outline/trash',
            method: :delete,
            color: :red,
            compact: true,
            size: :xs,
            class: 'text-center',
            title: t('avo.delete_file', item: file.filename),
            data: {
              'turbo-frame': 'destroy_attachment_form',
              confirm: t('avo.are_you_sure'),
              tippy: :tooltip
            } %>
        <% end %>
      </div>
    </div>
  <% else %>
    –
  <% end %>
</div>