<% content_for :title, "Modifica squadra — #{@team.name}" %>
<% content_for :robots, "noindex, nofollow" %>

<div class="wrap" style="padding-top:20px;max-width:560px">
  <h1><%= @team.name %></h1>
  <p style="color:#888">Società: <%= link_to @club.name, public_club_path(@club) %></p>
  <div class="card">
    <%= form_with url: public_team_path(@team), method: :patch, multipart: true do %>
      <%= label_tag "team[name]", "Nome squadra" %>
      <%= text_field_tag "team[name]", @team.name, required: true %>
      <%= label_tag "team[sport]", "Sport" %>
      <%= select_tag "team[sport]", options_for_select([["Pallavolo", "volleyball"], ["Calcio", "football"], ["Basket", "basketball"]], @team.sport) %>

      <%= label_tag "team[description]", "Descrizione squadra" %>
      <%= text_area_tag "team[description]", @team.description, rows: 5, placeholder: "Presentazione della squadra, palmarès, obiettivi della stagione…" %>

      <div class="branding-logo-block">
        <%= label_tag "team[photo_file]", "Foto di squadra (gruppo o stemma)" %>
        <% if @team.team_photo_url.present? %>
          <div class="branding-logo-preview">
            <%= image_tag @team.team_photo_url, alt: "Foto squadra", class: "team-profile-photo-preview", width: 200 %>
          </div>
        <% end %>
        <%= file_field_tag "team[photo_file]", accept: "image/png,image/jpeg,image/webp", class: "branding-file-input" %>
      </div>

      <%= render "shared/branding_fields", record: @team, show_inherit_hint: true, legend: "Branding squadra (override)" %>
      <p class="branding-hint">
        Colori società: 
        <span class="color-swatch" style="background:<%= @club.effective_primary_color %>"></span>
        <span class="color-swatch" style="background:<%= @club.effective_secondary_color %>"></span>
      </p>
      <%= submit_tag "Salva squadra", class: "btn btn-primary" %>
    <% end %>
  </div>
  <p><%= link_to "← Dettagli squadra", public_team_details_path(@team) %></p>
</div>
