<%# locals: (entry:, selectable: true, balance_trend: nil) %>

<% trade, account = entry.account_trade, entry.account %>

<div class="grid grid-cols-12 items-center <%= entry.excluded ? "text-gray-400 bg-gray-25" : "text-gray-900" %> text-sm font-medium p-4">
  <div class="col-span-6 flex items-center gap-4">
    <% if selectable %>
      <%= check_box_tag dom_id(entry, "selection"),
                        class: "maybe-checkbox maybe-checkbox--light",
                        data: { id: entry.id, "bulk-select-target": "row", action: "bulk-select#toggleRowSelection" } %>
    <% end %>

    <div class="max-w-full">
      <%= tag.div class: ["flex items-center gap-2"] do %>
        <div class="flex h-8 w-8 shrink-0 items-center justify-center rounded-full bg-gray-600/5 text-gray-600">
          <%= entry.display_name.first.upcase %>
        </div>

        <div class="truncate">
          <% if entry.new_record? %>
            <%= content_tag :p, entry.display_name %>
          <% else %>
            <%= link_to entry.display_name,
                        account_entry_path(entry),
                        data: { turbo_frame: "drawer", turbo_prefetch: false },
                        class: "hover:underline hover:text-gray-800" %>
          <% end %>
        </div>
      <% end %>
    </div>
  </div>

  <div class="col-span-2 flex items-center">
    <%= render "categories/badge", category: trade_category %>
  </div>

  <div class="col-span-2 justify-self-end font-medium text-sm">
    <%= content_tag :p,
                    format_money(-entry.amount_money),
                    class: ["text-green-600": entry.amount.negative?] %>
  </div>

  <div class="col-span-2 justify-self-end">
    <% if balance_trend&.trend %>
      <div class="flex items-center gap-2">
        <%= tag.p format_money(balance_trend.trend.current), class: "font-medium text-sm text-gray-900" %>
      </div>
    <% else %>
      <%= tag.p "--", class: "font-medium text-sm text-gray-400" %>
    <% end %>
  </div>
</div>
