<h1>Nuova fattura — <%= @club.name %></h1>
<% if @payment %>
  <p style="color:#666">Collegata al pagamento del <%= @payment.paid_at&.to_date || @payment.created_at.to_date %> (<%= @payment.formatted_amount %>).</p>
<% end %>

<div class="card">
  <%= form_with model: @invoice, url: admin_club_billing_invoices_path(@club) do |f| %>
    <%= f.hidden_field :billing_payment_id if @payment %>

    <%= f.label :number, "Numero fattura" %>
    <%= f.text_field :number, required: true %>

    <%= f.label :issued_on, "Data emissione" %>
    <%= f.date_field :issued_on, required: true %>

    <%= label_tag :amount_euros, "Importo (€)" %>
    <%= number_field_tag "billing_invoice[amount_euros]",
          (@invoice.amount_cents ? @invoice.amount_cents / 100.0 : nil),
          step: 0.01, min: 0.01, required: true %>

    <%= f.label :notes, "Note interne (opzionale)" %>
    <%= f.text_area :notes, rows: 2 %>

    <p style="color:#666;font-size:0.9rem;margin-top:12px">
      Salva la bozza, poi carica il PDF e inviala al cliente dalla schermata successiva.
    </p>

    <%= f.submit "Crea bozza fattura", class: "btn btn-primary" %>
  <% end %>
</div>

<p><%= link_to "← Pagamenti e fatture", admin_club_billing_invoices_path(@club) %></p>
