<%# locals: (budget:, previous_budget:, next_budget:, latest_budget:) %>

<div class="flex items-center gap-1 mb-4">
  <div class="flex items-center gap-2">
    <% if budget.previous_budget_param %>
      <%= link_to budget_path(budget.previous_budget_param) do %>
        <%= lucide_icon "chevron-left" %>
      <% end %>
    <% else %>
      <%= lucide_icon "chevron-left", class: "text-subdued" %>
    <% end %>

    <% if budget.next_budget_param %>
      <%= link_to budget_path(budget.next_budget_param) do %>
        <%= lucide_icon "chevron-right" %>
      <% end %>
    <% else %>
      <%= lucide_icon "chevron-right", class: "text-subdued" %>
    <% end %>
  </div>

  <div data-controller="menu" data-menu-placement-value="bottom-start">
    <%= tag.button data: { menu_target: "button" }, class: "flex items-center gap-1 hover:bg-alpha-black-25 cursor-pointer rounded-md p-2" do %>
      <span class="text-primary font-medium"><%= @budget.name %></span>
      <%= lucide_icon "chevron-down", class: "w-5 h-5 shrink-0 text-secondary" %>
    <% end %>

    <div data-menu-target="content" class="hidden z-10">
      <%= render "budgets/picker", family: Current.family, year: budget.start_date.year %>
    </div>
  </div>

  <div class="ml-auto">
    <% if @budget.current? %>
      <span class="border border-secondary text-primary text-sm font-medium px-3 py-2 rounded-lg">Today</span>
    <% else %>
      <%= link_to "Today", budget_path(Budget.date_to_param(Date.current)), class: "btn btn--outline" %>
    <% end %>
  </div>
</div>
