<%# locals: (record:, show_legend: true) %>
<% if show_legend %>
  <h2 class="form-section-title" style="margin-top:24px">Dati di fatturazione</h2>
  <p style="color:#888;font-size:0.88rem;margin:-8px 0 16px">
    Tutti i campi contrassegnati sono obbligatori per abbonarti a un piano premium e per emettere le fatture.
    Per le società serve la P.IVA; per le persone fisiche il Codice Fiscale. Serve SDI <em>oppure</em> PEC.
    I pagamenti restano gestiti in modo sicuro da Stripe.
  </p>
<% end %>

<%= label_tag "club[billing_entity_type]", "Tipo intestatario *" %>
<%= select_tag "club[billing_entity_type]",
      options_for_select(Club::BILLING_ENTITY_TYPES.map { |k, v| [v, k] }, record.billing_entity_type),
      include_blank: false %>

<%= label_tag "club[billing_legal_name]", "Ragione sociale / nome e cognome *" %>
<%= text_field_tag "club[billing_legal_name]", record.billing_legal_name, placeholder: "es. ASD Tigers Volley" %>

<div style="display:grid;grid-template-columns:1fr 1fr;gap:12px">
  <div>
    <%= label_tag "club[billing_vat_number]", "Partita IVA * (società)" %>
    <%= text_field_tag "club[billing_vat_number]", record.billing_vat_number, placeholder: "12345678901" %>
  </div>
  <div>
    <%= label_tag "club[billing_fiscal_code]", "Codice Fiscale * (persona fisica)" %>
    <%= text_field_tag "club[billing_fiscal_code]", record.billing_fiscal_code, placeholder: "RSSMRA80A01H501U" %>
  </div>
</div>

<%= label_tag "club[billing_email]", "Email fatturazione *" %>
<%= email_field_tag "club[billing_email]", record.billing_email, placeholder: "amministrazione@societa.it" %>

<%= label_tag "club[billing_phone]", "Telefono (opzionale)" %>
<%= text_field_tag "club[billing_phone]", record.billing_phone %>

<%= label_tag "club[billing_address_line]", "Indirizzo *" %>
<%= text_field_tag "club[billing_address_line]", record.billing_address_line, placeholder: "Via Roma 1" %>

<div style="display:grid;grid-template-columns:2fr 1fr 1fr;gap:12px">
  <div>
    <%= label_tag "club[billing_city]", "Città *" %>
    <%= text_field_tag "club[billing_city]", record.billing_city %>
  </div>
  <div>
    <%= label_tag "club[billing_province]", "Prov. *" %>
    <%= text_field_tag "club[billing_province]", record.billing_province, maxlength: 2, placeholder: "MI" %>
  </div>
  <div>
    <%= label_tag "club[billing_postal_code]", "CAP *" %>
    <%= text_field_tag "club[billing_postal_code]", record.billing_postal_code %>
  </div>
</div>

<%= label_tag "club[billing_country]", "Paese (ISO) *" %>
<%= text_field_tag "club[billing_country]", record.billing_country.presence || "IT", maxlength: 2 %>

<div style="display:grid;grid-template-columns:1fr 1fr;gap:12px">
  <div>
    <%= label_tag "club[billing_recipient_code]", "Codice destinatario SDI (7 car.) *" %>
    <%= text_field_tag "club[billing_recipient_code]", record.billing_recipient_code, maxlength: 7, placeholder: "XXXXXXX" %>
  </div>
  <div>
    <%= label_tag "club[billing_pec]", "PEC (alternativa a SDI) *" %>
    <%= email_field_tag "club[billing_pec]", record.billing_pec, placeholder: "pec@societa.it" %>
  </div>
</div>
