{% extends 'base.html' %}

{% block content %}
<div class="container mt-4">
    <h1 class="mb-4">{{ lead.company }}</h1>

    <div class="card mb-4">
        <div class="card-header">
            Lead Details
        </div>
        <div class="card-body">
            <p><strong>Contact Name:</strong> {{ lead.contact_name }}</p>
            <p><strong>Phone:</strong> {{ lead.phone }}</p>
            <p><strong>Notes:</strong> {{ lead.notes }}</p>
            <p><strong>Created At:</strong> {{ lead.created_at }}</p>
            <p><strong>Last Contacted At:</strong> {{ lead.last_contacted_at }}</p>
        </div>
    </div>

    <div class="card mb-4">
        <div class="card-header">
            Calls
        </div>
        <div class="card-body">
            {% for call in lead.calls.all %}
                <div class="mb-2">
                    <p><strong>{{ call.created_at }}</strong> - {{ call.summary }}</p>
                </div>
            {% empty %}
                <p>No calls logged yet.</p>
            {% endfor %}
        </div>
    </div>

    <div class="card">
        <div class="card-header">
            Log a New Call
        </div>
        <div class="card-body">
            <form method="post">
                {% csrf_token %}
                {{ form.as_p }}
                <button type="submit" class="btn btn-primary">Save Call</button>
            </form>
        </div>
    </div>

    <a href="{% url 'index' %}" class="btn btn-secondary mt-4">Back to Leads</a>
</div>
{% endblock %}
