{% extends "base.html" %}
{% load static i18n %}

{% block title %}{% trans "Schedule Meeting" %} - {{ job.title }} - ATS{% endblock %}

{% block content %}
<div class="container py-4">
    <div class="d-flex justify-content-between align-items-center mb-4">
        <div>
            <h1 class="h3 mb-1">
                <i class="fas fa-calendar-plus me-2"></i>
                {% if has_future_meeting %}
                    {% trans "Update Interview" %} for {{ candidate.name }}
                {% else %}
                    {% trans "Schedule Interview" %} for {{ candidate.name }}
                {% endif %}
            </h1>
            <p class="text-muted mb-0">{% trans "Job" %}: {{ job.title }}</p>
             {% if has_future_meeting %}
                <div class="alert alert-info mt-2 mb-0" role="alert">
                    <i class="fas fa-info-circle me-1"></i>
                    {% trans "This candidate has upcoming interviews. You are updating an existing schedule." %}
                </div>
            {% endif %}
        </div>
        <a href="{% url 'candidate_interview_view' job.slug %}" class="btn btn-outline-secondary">
            <i class="fas fa-arrow-left me-1"></i> {% trans "Back to Candidates" %}
        </a>
    </div>

    <div class="card shadow-sm">
        <div class="card-body">
            <form method="post">
                {% csrf_token %}

                <div class="mb-3">
                    <label for="{{ form.topic.id_for_label }}" class="form-label">
                        {% 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">
                        {% trans "Default topic will be 'Interview: [Job Title] with [Candidate Name]' if left empty." %}
                    </div>
                </div>

                <div class="mb-3">
                    <label for="{{ form.start_time.id_for_label }}" class="form-label">
                        {% trans "Start 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 class="form-text">
                        {% trans "Please select a date and time for the interview." %}
                    </div>
                </div>

                <div class="mb-4">
                    <label for="{{ form.duration.id_for_label }}" class="form-label">
                        {% 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 class="d-flex gap-2">
                    <button type="submit" class="btn btn-primary">
                        <i class="fas fa-save me-1"></i> {% trans "Schedule Meeting" %}
                    </button>
                    <a href="{% url 'candidate_interview_view' job.slug %}" class="btn btn-secondary">
                        <i class="fas fa-times me-1"></i> {% trans "Cancel" %}
                    </a>
                </div>
            </form>
        </div>
    </div>
</div>
{% endblock %}
