<div class="max-w-7xl mx-auto px-4 sm:px-6 lg:px-8 py-8">
  <div class="mb-8">
    <h1 class="text-3xl font-bold text-gray-900">Entry Requests</h1>
    <p class="text-gray-600 mt-2">Review and manage entry requests from public users.</p>
  </div>

  <!-- Requested Entries Section -->
  <div class="mb-12">
    <div class="bg-white rounded-lg shadow-md overflow-hidden">
      <div class="bg-yellow-50 border-b border-yellow-100 px-6 py-4">
        <h2 class="text-xl font-bold text-yellow-900 flex items-center gap-2">
          <span>⏳</span> Pending Review
          <span class="text-sm font-normal text-yellow-700">(<%= @requested_entries.count %> total)</span>
        </h2>
      </div>

      <% if @requested_entries.any? %>
        <div class="overflow-x-auto">
          <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">Entry</th>
                <th class="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">Category</th>
                <th class="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">Requester</th>
                <th class="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">Date</th>
                <th class="px-6 py-3 text-right text-xs font-medium text-gray-500 uppercase tracking-wider">Actions</th>
              </tr>
            </thead>
            <tbody class="bg-white divide-y divide-gray-200">
              <% @requested_entries.each do |entry| %>
                <tr class="hover:bg-gray-50 transition">
                  <td class="px-6 py-4 whitespace-nowrap">
                    <div class="text-sm font-medium text-gray-900">
                      <%= [entry.fi, entry.en, entry.sv, entry.no, entry.ru, entry.de].compact.first || "(empty)" %>
                    </div>
                  </td>
                  <td class="px-6 py-4 whitespace-nowrap">
                    <span class="px-2 py-1 text-xs font-semibold rounded-full bg-indigo-100 text-indigo-800">
                      <%= entry.category.humanize %>
                    </span>
                  </td>
                  <td class="px-6 py-4">
                    <div class="text-sm text-gray-900"><%= entry.requested_by&.name %></div>
                    <div class="text-xs text-gray-500"><%= entry.requested_by&.email %></div>
                  </td>
                  <td class="px-6 py-4 whitespace-nowrap text-sm text-gray-500">
                    <%= entry.created_at.strftime("%b %d, %Y") %>
                  </td>
                  <td class="px-6 py-4 whitespace-nowrap text-right text-sm font-medium space-x-2">
                    <%= link_to "View", admin_request_path(entry), class: "text-indigo-600 hover:text-indigo-900" %>
                    <%= link_to "Edit", edit_admin_request_path(entry), class: "text-blue-600 hover:text-blue-900" %>
                    <%= button_to "Approve", approve_admin_request_path(entry), method: :post, class: "inline text-green-600 hover:text-green-900", form: { data: { turbo_confirm: "Send invitation to #{entry.requested_by&.email}?" } } %>
                    <%= button_to "Reject", reject_admin_request_path(entry), method: :delete, class: "inline text-red-600 hover:text-red-900", form: { data: { turbo_confirm: "Delete this request?" } } %>
                  </td>
                </tr>
              <% end %>
            </tbody>
          </table>
        </div>
      <% else %>
        <div class="px-6 py-12 text-center text-gray-500">
          No pending requests at the moment.
        </div>
      <% end %>
    </div>
  </div>

  <!-- Approved Entries Section -->
  <div>
    <div class="bg-white rounded-lg shadow-md overflow-hidden">
      <div class="bg-blue-50 border-b border-blue-100 px-6 py-4">
        <h2 class="text-xl font-bold text-blue-900 flex items-center gap-2">
          <span>✅</span> Approved (Awaiting User Acceptance)
          <span class="text-sm font-normal text-blue-700">(<%= @approved_entries.count %> total)</span>
        </h2>
      </div>

      <% if @approved_entries.any? %>
        <div class="overflow-x-auto">
          <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">Entry</th>
                <th class="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">Category</th>
                <th class="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">Requester</th>
                <th class="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">Approved</th>
                <th class="px-6 py-3 text-right text-xs font-medium text-gray-500 uppercase tracking-wider">Actions</th>
              </tr>
            </thead>
            <tbody class="bg-white divide-y divide-gray-200">
              <% @approved_entries.each do |entry| %>
                <tr class="hover:bg-gray-50 transition">
                  <td class="px-6 py-4 whitespace-nowrap">
                    <div class="text-sm font-medium text-gray-900">
                      <%= [entry.fi, entry.en, entry.sv, entry.no, entry.ru, entry.de].compact.first || "(empty)" %>
                    </div>
                  </td>
                  <td class="px-6 py-4 whitespace-nowrap">
                    <span class="px-2 py-1 text-xs font-semibold rounded-full bg-indigo-100 text-indigo-800">
                      <%= entry.category.humanize %>
                    </span>
                  </td>
                  <td class="px-6 py-4">
                    <div class="text-sm text-gray-900"><%= entry.requested_by&.name %></div>
                    <div class="text-xs text-gray-500"><%= entry.requested_by&.email %></div>
                  </td>
                  <td class="px-6 py-4 whitespace-nowrap text-sm text-gray-500">
                    <%= entry.updated_at.strftime("%b %d, %Y") %>
                  </td>
                  <td class="px-6 py-4 whitespace-nowrap text-right text-sm font-medium space-x-2">
                    <%= link_to "View", admin_request_path(entry), class: "text-indigo-600 hover:text-indigo-900" %>
                    <%= button_to "Reject", reject_admin_request_path(entry), method: :delete, class: "inline text-red-600 hover:text-red-900", form: { data: { turbo_confirm: "Delete this approved request?" } } %>
                  </td>
                </tr>
              <% end %>
            </tbody>
          </table>
        </div>
      <% else %>
        <div class="px-6 py-12 text-center text-gray-500">
          No approved entries awaiting user acceptance.
        </div>
      <% end %>
    </div>
  </div>
</div>
