<%# locals: (investment_metrics:) %> <% if investment_metrics[:has_investments] %>

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

<%# Investment Summary Cards %>
<%# Portfolio Value Card %>
<%= icon("briefcase", class: "w-4 h-4 text-secondary") %> <%= t("reports.investment_performance.portfolio_value") %>

<%= format_money(investment_metrics[:portfolio_value]) %>

<%# Total Return Card %>
<%= icon("trending-up", class: "w-4 h-4 text-secondary") %> <%= t("reports.investment_performance.total_return") %>
<% if investment_metrics[:unrealized_trend] %>

<%= format_money(Money.new(investment_metrics[:unrealized_trend].value, Current.family.currency)) %> (<%= investment_metrics[:unrealized_trend].percent_formatted %>)

<% else %>

-

<% end %>
<%# Period Contributions Card %>
<%= icon("arrow-down-to-line", class: "w-4 h-4 text-secondary") %> <%= t("reports.investment_performance.contributions") %>

<%= format_money(investment_metrics[:period_contributions]) %>

<%# Period Withdrawals Card %>
<%= icon("arrow-up-from-line", class: "w-4 h-4 text-secondary") %> <%= t("reports.investment_performance.withdrawals") %>

<%= format_money(investment_metrics[:period_withdrawals]) %>

<%# Top Holdings Table %> <% if investment_metrics[:top_holdings].any? %>

<%= t("reports.investment_performance.top_holdings") %>

<% investment_metrics[:top_holdings].each do |holding| %> <% end %>
<%= t("reports.investment_performance.holding") %> <%= t("reports.investment_performance.weight") %> <%= t("reports.investment_performance.value") %> <%= t("reports.investment_performance.return") %>
<% if holding.security.logo_url.present? %> <%= holding.ticker %> <% else %>
<%= holding.ticker[0..1] %>
<% end %>

<%= holding.ticker %>

<%= truncate(holding.name, length: 25) %>

<%= number_to_percentage(holding.weight || 0, precision: 1) %> <%= format_money(holding.amount_money) %> <% if holding.trend %> <%= holding.trend.percent_formatted %> <% else %> - <% end %>
<% end %> <%# Investment Accounts Summary %> <% if investment_metrics[:accounts].any? %>

<%= t("reports.investment_performance.accounts") %>

<% investment_metrics[:accounts].each do |account| %>
<%= render "accounts/logo", account: account, size: "sm" %>

<%= account.name %>

<%= account.short_subtype_label %>

<%= format_money(account.balance_money) %>

<% end %>
<% end %>
<% end %>