<div class="p-4 bg-white block sm:flex items-center justify-between border-b border-gray-200 lg:mt-1.5">
  <div class="w-full mb-1">
    <div class="mb-4">
      <h1 class="text-xl font-semibold text-gray-900 sm:text-2xl">All Pages (Cross-Tenant)</h1>
      <p class="text-sm text-gray-600">Showing up to 100 most recent pages</p>
    </div>
  </div>
</div>

<div class="flex flex-col">
  <div class="overflow-x-auto">
    <div class="inline-block min-w-full align-middle">
      <div class="overflow-hidden shadow">
        <table class="min-w-full divide-y divide-gray-200">
          <thead class="bg-gray-100">
            <tr>
              <th class="p-4 text-xs font-medium text-left text-gray-500 uppercase">Title</th>
              <th class="p-4 text-xs font-medium text-left text-gray-500 uppercase">Slug</th>
              <th class="p-4 text-xs font-medium text-left text-gray-500 uppercase">Website</th>
              <th class="p-4 text-xs font-medium text-left text-gray-500 uppercase">Created</th>
              <th class="p-4 text-xs font-medium text-left text-gray-500 uppercase">Actions</th>
            </tr>
          </thead>
          <tbody class="bg-white divide-y divide-gray-200">
            <% @pages.each do |page| %>
              <tr class="hover:bg-gray-100">
                <td class="p-4 text-sm font-medium text-gray-900">
                  <%= link_to (page.page_title || page.link_title || "Page ##{page.id}"), tenant_admin_page_path(page), class: "text-blue-600 hover:underline" %>
                </td>
                <td class="p-4 text-sm text-gray-500">
                  <%= page.slug || "N/A" %>
                </td>
                <td class="p-4 text-sm text-gray-500">
                  <% if page.respond_to?(:website) %>
                    <%= page.website&.subdomain || "N/A" %>
                  <% else %>
                    N/A
                  <% end %>
                </td>
                <td class="p-4 text-sm text-gray-500">
                  <%= time_ago_in_words(page.created_at) %> ago
                </td>
                <td class="p-4">
                  <%= link_to "View", tenant_admin_page_path(page), class: "inline-flex items-center px-3 py-2 text-sm font-medium text-center text-white rounded-lg bg-blue-600 hover:bg-blue-700" %>
                </td>
              </tr>
            <% end %>
            <% if @pages.empty? %>
              <tr>
                <td colspan="5" class="p-8 text-center text-gray-500">No pages found</td>
              </tr>
            <% end %>
          </tbody>
        </table>
      </div>
    </div>
  </div>
</div>
