{% load i18n %}
<div class="p-3" id="schedule-meeting-form">
    <div class="d-flex justify-content-between align-items-center mb-3">
        <div>
            <h5 class="mb-1" style="color: var(--kaauh-teal-dark); font-weight: 700;">
                {% if has_future_meeting %}
                    {% trans "Update Interview" %} for {{ candidate.name }}
                {% else %}
                    {% trans "Schedule Interview" %} for {{ candidate.name }}
                {% endif %}
            </h5>
            <p class="text-muted mb-0 small">{% trans "Job" %}: {{ job.title }}</p>
             {% if has_future_meeting %}
                <div class="alert alert-info mt-2 mb-0 p-2 small" role="alert">
                    <i class="fas fa-info-circle me-1"></i>
                    {% trans "Candidate has upcoming interviews. Updating existing schedule." %}
                </div>
            {% endif %}
        </div>
    </div>

    <div>
        <form method="post" action="{% url 'schedule_meeting_for_candidate' job.slug candidate.pk %}">
            {% csrf_token %}
            <div class="mb-3">
                <label for="{{ form.topic.id_for_label }}" class="form-label small">
                    {% trans "Meeting Topic" %}
                </label>
                {{ form.topic }}
                {% if form.topic.errors %}
                    <div class="text-danger">
                        {% for error in form.topic.errors %}
                            <small>{{ error }}</small>
                        {% endfor %}
                    </div>
                {% endif %}
                <div class="form-text small text-muted">
                    {% trans "e.g., Technical Screening, HR Interview" %}
                </div>
            </div>

            <div class="row">
                <div class="col-md-7">
                    <div class="mb-3">
                        <label for="{{ form.start_time.id_for_label }}" class="form-label small">
                            {% trans "Start Time" %} (Date & Time)
                        </label>
                        {{ form.start_time }}
                        {% if form.start_time.errors %}
                            <div class="text-danger">
                                {% for error in form.start_time.errors %}
                                    <small>{{ error }}</small>
                                {% endfor %}
                            </div>
                        {% endif %}
                    </div>
                </div>

                <div class="col-md-5">
                    <div class="mb-3">
                        <label for="{{ form.duration.id_for_label }}" class="form-label small">
                            {% trans "Duration (minutes)" %}
                        </label>
                        {{ form.duration }}
                        {% if form.duration.errors %}
                            <div class="text-danger">
                                {% for error in form.duration.errors %}
                                    <small>{{ error }}</small>
                                {% endfor %}
                            </div>
                        {% endif %}
                    </div>
                </div>
            </div>

            <hr style="border-top: 1px solid var(--kaauh-border); margin-top: 1.5rem; margin-bottom: 1.5rem;">

            <div class="d-flex justify-content-end gap-2">
                <button type="submit" class="btn btn-main-action btn-sm">
                    <i class="fas fa-save me-1"></i>
                    {% if has_future_meeting %}
                        {% trans "Update Meeting" %}
                    {% else %}
                        {% trans "Schedule Meeting" %}
                    {% endif %}
                </button>
            </div>
        </form>
    </div>
</div>