%# Multi-page viewer: one attachment per "page", with prev/next. %>
<% pages = document.pages.to_a %>
<% if pages.empty? %>
<%= empty_state "No files uploaded." %>
<% else %>
<% current = pages[page - 1] %>
<%= link_to "← Prev", url_for(page: page - 1), class: ["btn-secondary btn-sm", ("pointer-events-none opacity-40" if page <= 1)] %>
Page <%= page %> of <%= pages.size %> · <%= link_to current.filename, rails_blob_path(current, disposition: :attachment), class: "link" %>
<%= link_to "Next →", url_for(page: page + 1), class: ["btn-secondary btn-sm", ("pointer-events-none opacity-40" if page >= pages.size)] %>
<% if current.image? %>
<%= image_tag rails_blob_path(current, disposition: :inline), alt: current.filename.to_s, class: "max-h-[80vh] max-w-full" %>
<% elsif current.content_type == "application/pdf" %>
<% else %>
<%= link_to "Download #{current.filename}", rails_blob_path(current, disposition: :attachment), class: "link" %>
<% end %>
<% end %>