{# Step 6: Financing #}
<form hx-post="{{ url_for('leads.quote_step', step=6) }}"
      hx-target="#quote-step" hx-swap="innerHTML">
  <input type="hidden" name="_accumulated" value='{{ data | tojson }}'>
  <input type="hidden" name="csrf_token" value="{{ csrf_token() }}">

  <h2 class="q-step-title">{{ t.q6_heading }}</h2>
  <p class="q-step-sub">{{ t.q6_subheading }}</p>

  <div class="q-field-group">
    <span class="q-label">{{ t.q6_status_label }} <span class="required">*</span></span>
    {% if 'financing_status' in errors %}<p class="q-error-hint">{{ t.q6_required_hint }}</p>{% endif %}
    <div class="q-pills">
      {% for val, label in [('self_funded', t.q6_status_self), ('loan_approved', t.q6_status_loan), ('seeking', t.q6_status_seeking), ('not_started', t.q6_status_not_started)] %}
      <label><input type="radio" name="financing_status" value="{{ val }}" {{ 'checked' if data.get('financing_status') == val }} required><span class="q-pill">{{ label }}</span></label>
      {% endfor %}
    </div>
  </div>

  <div class="q-field-group">
    <label class="q-checkbox-label">
      <input type="checkbox" name="wants_financing_help" value="1" {{ 'checked' if data.get('wants_financing_help') == '1' }}>
      <span>{{ t.q6_help_checkbox }}</span>
    </label>
  </div>

  <div class="q-field-group">
    <span class="q-label">{{ t.q6_decision_label }} <span class="required">*</span></span>
    {% if 'decision_process' in errors %}<p class="q-error-hint">{{ t.q6_decision_required_hint }}</p>{% endif %}
    <div class="q-pills">
      {% for val, label in [('solo', t.q6_decision_solo), ('partners', t.q6_decision_partners), ('committee', t.q6_decision_committee)] %}
      <label><input type="radio" name="decision_process" value="{{ val }}" {{ 'checked' if data.get('decision_process') == val }} required><span class="q-pill">{{ label }}</span></label>
      {% endfor %}
    </div>
  </div>

  <div class="q-nav">
    <button type="button" class="q-btn-back"
            hx-get="{{ url_for('leads.quote_step', step=5, _accumulated=data | tojson) }}"
            hx-target="#quote-step" hx-swap="innerHTML">{{ t.q_btn_back }}</button>
    <button type="submit" class="q-btn-next">{{ t.q_btn_next }}</button>
  </div>
</form>

<div id="q-progress" hx-swap-oob="innerHTML">
  <div class="q-progress__meta">
    <span class="q-progress__label">{{ steps[step - 1].title }}</span>
    <span class="q-progress__count">{{ t.q_step_counter | tformat(step=step, total=steps|length) }}</span>
  </div>
  <div class="q-progress__track">
    <div class="q-progress__fill" style="width: {{ (step / steps|length * 100) | round }}%"></div>
  </div>
</div>
