<%= @collection.name %>

<% if @collection.subcollection? %>

Subcollection of <%= link_to @collection.parent_collection.name, @collection.parent_collection, class: "text-indigo-600 hover:text-indigo-800" %>

<% end %>
<%= link_to "Edit", edit_collection_path(@collection), class: "px-4 py-2 bg-indigo-600 text-white rounded hover:bg-indigo-700" %> <%= button_to "Delete", @collection, method: :delete, data: { turbo_confirm: "Are you sure you want to delete '#{@collection.name}'? This will permanently remove the collection but games in it will not be deleted." }, class: "px-4 py-2 bg-red-600 text-white rounded hover:bg-red-700" %>
<% if @collection.description.present? %>

<%= @collection.description %>

<% end %>
Total Games
<%= @collection.game_count %>
<% if @collection.subcollections.any? %>
Subcollections
<%= @collection.subcollections.count %>
<% end %>
<% if @collection.subcollections.any? %>

Subcollections

<% @collection.subcollections.each do |subcollection| %>
<%= link_to subcollection.name, subcollection, class: "font-semibold text-indigo-600 hover:text-indigo-800" %>
<%= pluralize(subcollection.game_count, "game") %>
<% end %>
<% end %>

Games in Collection

<% if @games.any? %>
<% @games.each do |game| %>
<%= link_to game.title, game, class: "text-lg font-semibold text-indigo-600 hover:text-indigo-800" %>
<%= game.platform.name %> · <%= game.format.titleize %> <% if game.completion_status %> · <%= game.completion_status.titleize %> <% end %> <% if game.user_rating %> · ⭐ <%= game.user_rating %>/5 <% end %>
<% if game.genres.any? %>
<% game.genres.each do |genre| %> <%= genre.name %> <% end %>
<% end %>
<% end %>
<% if @games.respond_to?(:total_pages) && @games.total_pages > 1 %>
<%#= paginate @games %>
<% end %> <% else %>

No games in this collection yet. <%= link_to "Add games", games_path, class: "text-indigo-600 hover:text-indigo-800" %> to get started.

<% end %>
<%= link_to "← Back to Collections", collections_path, class: "text-indigo-600 hover:text-indigo-800" %>