<% content_for :title, "Edit Entry" %>

<div class="min-h-screen flex flex-col">
  <%= render "shared/header", show_request_button: false, show_browse_button: true %>

  <div class="flex-1 bg-gradient-to-br from-indigo-50 via-white to-purple-50 flex items-center justify-center px-4 py-12">
    <div class="max-w-2xl w-full">
      <div class="bg-white rounded-2xl shadow-xl p-8">
        <div class="text-center mb-8">
          <div class="flex items-center justify-center gap-3 mb-2">
            <h1 class="text-3xl font-bold text-gray-900">Edit Entry</h1>
            <% if @entry.verified? %>
              <div class="flex items-center gap-1.5 text-emerald-600">
                <svg class="w-5 h-5" fill="currentColor" viewBox="0 0 20 20"><path fill-rule="evenodd" d="M10 18a8 8 0 100-16 8 8 0 000 16zm3.707-9.293a1 1 0 00-1.414-1.414L9 10.586 7.707 9.293a1 1 0 00-1.414 1.414l2 2a1 1 0 001.414 0l4-4z" clip-rule="evenodd"/></svg>
                <span class="text-sm font-bold">Verified</span>
              </div>
            <% else %>
              <span class="text-sm font-semibold text-amber-600 px-3 py-1 rounded-full bg-amber-50">Unverified</span>
            <% end %>
          </div>
          <p class="text-gray-600">Update the translations and details for this entry.</p>
        </div>

        <%= form_with model: @entry, class: "space-y-6" do |f| %>
          <% if @entry.errors.any? %>
            <div class="p-4 bg-red-50 border border-red-200 rounded-lg">
              <h3 class="font-semibold text-red-800 mb-2">Please fix the following errors:</h3>
              <ul class="list-disc list-inside text-red-700 text-sm space-y-1">
                <% @entry.errors.full_messages.each do |message| %>
                  <li><%= message %></li>
                <% end %>
              </ul>
            </div>
          <% end %>

          <div class="space-y-6">
            <%= render 'entries/form_fields', f: f, category_prompt: false %>
          </div>

          <div class="flex flex-col sm:flex-row gap-4 pt-4">
            <%= f.submit "Save Changes", class: "flex-1 bg-indigo-600 hover:bg-indigo-700 text-white font-semibold py-3 px-6 rounded-lg transition shadow-md hover:shadow-lg" %>
            <%= link_to "Cancel", entry_path(@entry), class: "flex-1 text-center bg-gray-100 hover:bg-gray-200 text-gray-800 font-semibold py-3 px-6 rounded-lg transition" %>
          </div>
        <% end %>

        <div class="mt-6 text-center text-sm text-gray-600">
          <%= link_to "← Back to entry", entry_path(@entry), class: "text-indigo-600 hover:text-indigo-800 font-semibold" %> •
          <%= link_to "Back to search", entries_path, class: "text-indigo-600 hover:text-indigo-800 font-semibold" %>
        </div>
      </div>
    </div>
  </div>
</div>
