{% extends "base.html" %}

{% block title %}New Pilot Call — ReliefSignal{% endblock %}
{% block meta_description %}Create a tax relief pilot call intake with transcript, extraction fields, integration readiness, and completion scoring.{% endblock %}

{% block content %}
<section class="page-hero compact">
  <div class="container">
    <span class="eyebrow">Create pilot intake</span>
    <h1 class="page-title">Start a real-time call proof point.</h1>
    <p class="hero-copy mb-0">Paste a transcript segment, capture the tax relief fields your AI should extract, and record whether Ytel audio + Logics updates are ready.</p>
  </div>
</section>

<section class="section-pad pt-4">
  <div class="container">
    <form method="post" class="intake-form" novalidate>
      {% csrf_token %}
      {% if form.non_field_errors %}
      <div class="alert alert-danger">{{ form.non_field_errors }}</div>
      {% endif %}

      <div class="form-panel mb-4">
        <div class="panel-heading"><span>01</span><h2>Call identity</h2></div>
        <div class="row g-4">
          {% for field in form %}
            {% if field.name in 'client_name phone email call_source ytel_audio_status logics_api_status' %}
            <div class="col-md-6 col-lg-4">
              <label class="form-label" for="{{ field.id_for_label }}">{{ field.label }}</label>
              {{ field }}
              {% for error in field.errors %}<div class="invalid-note">{{ error }}</div>{% endfor %}
            </div>
            {% endif %}
          {% endfor %}
        </div>
      </div>

      <div class="form-panel mb-4">
        <div class="panel-heading"><span>02</span><h2>Transcript</h2></div>
        <label class="form-label" for="{{ form.transcript.id_for_label }}">{{ form.transcript.label }}</label>
        {{ form.transcript }}
        <p class="form-hint">For the live MVP, this represents the text coming from speech-to-text every few seconds.</p>
        {% for error in form.transcript.errors %}<div class="invalid-note">{{ error }}</div>{% endfor %}
      </div>

      <div class="form-panel mb-4">
        <div class="panel-heading"><span>03</span><h2>Extracted intake schema</h2></div>
        <div class="row g-4">
          {% for field in form %}
            {% if field.name not in 'client_name phone email call_source ytel_audio_status logics_api_status transcript irs_payment_plan levy garnishment assets agent_notes' %}
            <div class="col-md-6 col-lg-4">
              <label class="form-label" for="{{ field.id_for_label }}">{{ field.label }}</label>
              {{ field }}
              {% for error in field.errors %}<div class="invalid-note">{{ error }}</div>{% endfor %}
            </div>
            {% endif %}
          {% endfor %}
          <div class="col-12">
            <label class="form-label" for="{{ form.assets.id_for_label }}">{{ form.assets.label }}</label>
            {{ form.assets }}
          </div>
        </div>
      </div>

      <div class="form-panel mb-4">
        <div class="panel-heading"><span>04</span><h2>Rules engine flags</h2></div>
        <div class="row g-4 align-items-start">
          <div class="col-lg-5">
            <div class="checks-grid">
              {% for field in form %}
                {% if field.name in 'irs_payment_plan levy garnishment' %}
                <label class="form-check signal-check">
                  {{ field }}
                  <span>{{ field.label }}</span>
                </label>
                {% endif %}
              {% endfor %}
            </div>
          </div>
          <div class="col-lg-7">
            <label class="form-label" for="{{ form.agent_notes.id_for_label }}">{{ form.agent_notes.label }}</label>
            {{ form.agent_notes }}
          </div>
        </div>
      </div>

      <div class="d-flex flex-column flex-sm-row gap-3 justify-content-end">
        <a class="btn btn-ghost" href="{% url 'call_list' %}">Cancel</a>
        <button class="btn btn-signal" type="submit">Save and review score</button>
      </div>
    </form>
  </div>
</section>
{% endblock %}
