<div class="max-w-7xl mx-auto">
  <div class="mb-6">
    <h1 class="text-3xl font-bold text-gray-900">Web Contents</h1>
    <p class="mt-2 text-gray-600">View web contents for <%= current_website.subdomain %></p>
  </div>

  <!-- Search Form -->
  <div class="mb-6 bg-white rounded-lg shadow p-4">
    <%= form_with url: site_admin_contents_path, method: :get, local: true, class: "flex gap-4" do |f| %>
      <div class="flex-1">
        <%= f.text_field :search, value: params[:search], placeholder: "Search by tag...", class: "w-full px-4 py-2 border border-gray-300 rounded-lg focus:ring-2 focus:ring-blue-500 focus:border-blue-500" %>
      </div>
      <%= f.submit "Search", class: "px-6 py-2 bg-blue-600 text-white rounded-lg hover:bg-blue-700" %>
    <% end %>
  </div>

  <!-- Contents Table -->
  <div class="bg-white rounded-lg shadow overflow-hidden">
    <table class="min-w-full divide-y divide-gray-200">
      <thead class="bg-gray-50">
        <tr>
          <th class="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">Tag</th>
          <th class="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">Created</th>
          <th class="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">Actions</th>
        </tr>
      </thead>
      <tbody class="bg-white divide-y divide-gray-200">
        <% if @contents.any? %>
          <% @contents.each do |content| %>
            <tr>
              <td class="px-6 py-4 whitespace-nowrap text-sm font-medium text-gray-900">
                <%= content.tag %>
              </td>
              <td class="px-6 py-4 whitespace-nowrap text-sm text-gray-500">
                <%= format_date(content.created_at) %>
              </td>
              <td class="px-6 py-4 whitespace-nowrap text-sm">
                <%= link_to 'View', site_admin_content_path(content), class: 'text-blue-600 hover:text-blue-800' %>
              </td>
            </tr>
          <% end %>
        <% else %>
          <tr>
            <td colspan="3" class="px-6 py-4 text-center text-gray-500">
              No contents found
            </td>
          </tr>
        <% end %>
      </tbody>
    </table>
  </div>
</div>
