<% content_for :title, "Entry" %>

<nav class="sticky top-0 z-50 bg-white border-b border-slate-200">
  <div class="max-w-5xl mx-auto px-4 h-16 flex items-center justify-between">
    <div class="flex items-center gap-2">
      <span class="text-xl font-bold tracking-tight text-indigo-600">Sanasto</span>
      <span class="text-xl font-light text-slate-400">Wiki</span>
    </div>
    <div class="flex items-center gap-4">
      <%= link_to "Browse", entries_path, class: "text-sm font-medium text-slate-600 hover:text-indigo-600" %>
      <%= link_to "Download XLSX", download_entries_path(format: :xlsx), class: "text-sm font-semibold text-indigo-700 px-3 py-2 rounded-lg border border-indigo-200 bg-indigo-50 hover:bg-indigo-100 transition" %>
    </div>
  </div>
</nav>

<main class="max-w-5xl mx-auto px-4 py-8 space-y-6">
  <div>
    <%= link_to "← Back to search", entries_path, class: "text-sm text-slate-500 hover:text-indigo-600" %>
  </div>

  <div class="bg-white border border-slate-200 rounded-xl shadow-sm overflow-hidden">
    <div class="px-6 py-4 border-b border-slate-100 bg-slate-50/50 flex justify-between items-center">
      <span class="text-[10px] font-black uppercase tracking-widest text-slate-400"><%= format_entry_category(@entry) %></span>
      <% if @entry.verified? %>
        <div class="flex items-center gap-1.5 text-emerald-600">
          <svg class="w-4 h-4" 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-xs font-bold">Verified</span>
        </div>
      <% else %>
        <span class="text-xs font-semibold text-amber-600">Unverified</span>
      <% end %>
    </div>

    <div class="p-6">
      <div class="grid grid-cols-1 md:grid-cols-2 gap-y-6 gap-x-12">
        <% @supported_languages.each do |language| %>
          <% translation = entry_translation_for(@entry, language.code) %>
          <% next if translation.blank? %>
          <div class="space-y-1">
            <span class="text-[10px] font-bold text-slate-400 uppercase tracking-tight"><%= "#{language.name} (#{language.code.upcase})" %></span>
            <p class="text-2xl font-semibold text-slate-800"><%= translation %></p>
          </div>
        <% end %>
      </div>

      <% if @entry.notes.present? %>
        <div class="mt-6 pt-5 border-t border-slate-100">
          <h4 class="text-xs font-bold text-slate-400 uppercase mb-2">Context & Notes</h4>
          <p class="text-sm text-slate-600 italic"><%= @entry.notes %></p>
        </div>
      <% end %>
    </div>
  </div>
</main>
