<% content_for :title, "Aggiungi staff — #{@team.name}" %>

<div class="wrap" style="padding-top:20px">
  <h1>Aggiungi staff</h1>
  <p>
    Trasmissione: <strong><%= @entitlements.staff_count_for("transmission") %> / <%= @entitlements.max_staff_transmission || "∞" %></strong>
    · Regia: <strong><%= @entitlements.staff_count_for("regia") %> / <%= @entitlements.max_staff_regia || "∞" %></strong>
  </p>

  <div class="card" style="max-width:520px">
    <%= form_with url: public_team_invite_path(@team), method: :post do %>
      <%= label_tag :staff_kind, "Ruolo" %>
      <%= select_tag :staff_kind, options_for_select([
        ["Trasmissione (camera / streaming)", "transmission"],
        ["Regia (punteggio)", "regia"]
      ], params[:staff_kind] || "transmission") %>
      <%= label_tag :email, "Email del membro staff" %>
      <%= email_field_tag :email, params[:email], required: true %>
      <%= submit_tag "Genera link di accesso", class: "btn btn-primary" %>
    <% end %>
    <% if defined?(@invite_url) && @invite_url.present? %>
      <p style="margin-top:16px">Condividi (valido 7 giorni):</p>
      <code style="word-break:break-all;display:block;background:#0a0a0e;padding:12px;border-radius:8px"><%= @invite_url %></code>
      <p style="color:#888;font-size:0.88rem;margin-top:8px">Il membro dello staff si registra con la stessa email e accetta l'accesso.</p>
    <% end %>
  </div>
  <p><%= link_to "← Dashboard", public_team_dashboard_path(@team) %></p>
</div>
