<% content_for :head do %> <% end %> <% content_for :page_header do %>

<%= t("reports.index.title") %>

<%= t("reports.index.subtitle") %>

<%# Flash messages %> <% if flash[:alert].present? %>
<%= flash[:alert] %>
<% end %> <%# Period Navigation Tabs %>
<%= render DS::Link.new( text: t("reports.index.periods.monthly"), variant: @period_type == :monthly ? "secondary" : "ghost", href: reports_path(period_type: :monthly), size: :sm ) %> <%= render DS::Link.new( text: t("reports.index.periods.quarterly"), variant: @period_type == :quarterly ? "secondary" : "ghost", href: reports_path(period_type: :quarterly), size: :sm ) %> <%= render DS::Link.new( text: t("reports.index.periods.ytd"), variant: @period_type == :ytd ? "secondary" : "ghost", href: reports_path(period_type: :ytd), size: :sm ) %> <%= render DS::Link.new( text: t("reports.index.periods.last_6_months"), variant: @period_type == :last_6_months ? "secondary" : "ghost", href: reports_path(period_type: :last_6_months), size: :sm ) %> <%= render DS::Link.new( text: t("reports.index.periods.custom"), variant: @period_type == :custom ? "secondary" : "ghost", href: reports_path(period_type: :custom), size: :sm ) %>
<%# Custom Date Range Picker (only shown when custom is selected) %> <% if @period_type == :custom %> <%= form_with url: reports_path, method: :get, data: { controller: "auto-submit-form" }, class: "reports-print-hide flex items-center gap-3 bg-surface-inset p-3 rounded-lg" do |f| %> <%= f.hidden_field :period_type, value: :custom %>
<%= f.date_field :start_date, value: @start_date.strftime("%Y-%m-%d"), data: { auto_submit_form_target: "auto" }, autocomplete: "off", class: "px-3 py-1.5 border border-primary rounded-lg text-sm bg-container-inset text-primary" %>
<%= f.date_field :end_date, value: @end_date.strftime("%Y-%m-%d"), data: { auto_submit_form_target: "auto" }, autocomplete: "off", class: "px-3 py-1.5 border border-primary rounded-lg text-sm bg-container-inset text-primary" %>
<% end %> <% end %> <%# Period Display %>
<%= t("reports.index.showing_period", start: @start_date.strftime("%b %-d, %Y"), end: @end_date.strftime("%b %-d, %Y")) %>
<% end %>
<% if Current.family.transactions.any? %> <%# Summary Dashboard - Always visible, not collapsible %>
<%= render partial: "reports/summary_dashboard", locals: { metrics: @summary_metrics, period_type: @period_type } %>
<%# Collapsible & Reorderable Sections %>
<% @reports_sections.each do |section| %> <% next unless section[:visible] %>

<%= t(section[:title]) %>

<%= render partial: section[:partial], locals: section[:locals] %>
<% end %>
<% else %> <%# Empty State %>
<%= render partial: "reports/empty_state" %>
<% end %>