<% content_for :title, "Sanasto Wiki" %>

<div class="min-h-screen flex flex-col">
  <%= render "shared/header" %>

  <%= render "shared/notifications" %>

  <div class="flex-1 flex flex-col">
    <section id="search">
      <div class="max-w-7xl mx-auto px-4 pb-1 space-y-4">
        <%= render "entries/search_form" %>

        <div id="entries_filters" class="hidden">
          <%= render "entries/filters" %>
        </div>
      </div>
    </section>

    <div id="entries_results">
      <%= render "entries/results" %>
    </div>

  </div>
</div>

<script>
  document.addEventListener("click", function (event) {
    const toggle = event.target.closest("[data-toggle-filters]");
    if (!toggle) {
      return;
    }

    const panel = document.getElementById("entries_filters");
    if (!panel) {
      return;
    }

    const isHidden = panel.classList.toggle("hidden");
    toggle.setAttribute("aria-expanded", (!isHidden).toString());
    toggle.textContent = isHidden ? "Show Filters" : "Hide Filters";
  });
</script>
