{% load i18n %}
<!DOCTYPE html>
<html lang="{{ LANGUAGE_CODE|default:'en' }}" dir="{% if LANGUAGE_CODE == 'ar' %}rtl{% else %}ltr{% endif %}">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>{% trans "Submit Explanation" %} - PX360</title>
    <link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0/dist/css/bootstrap.min.css" rel="stylesheet">
    <style>
        body {
            background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
            min-height: 100vh;
            display: flex;
            align-items: center;
            padding: 20px 0;
        }
        .card {
            border: none;
            border-radius: 15px;
            box-shadow: 0 10px 40px rgba(0,0,0,0.1);
        }
        .card-header {
            background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
            border-radius: 15px 15px 0 0 !important;
            color: white;
        }
        .btn-primary {
            background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
            border: none;
        }
        .btn-primary:hover {
            background: linear-gradient(135deg, #764ba2 0%, #667eea 100%);
        }
        .complaint-details {
            background-color: #f8f9fa;
            border-radius: 10px;
            padding: 15px;
        }
    </style>
</head>
<body>
    <div class="container">
        <div class="row justify-content-center">
            <div class="col-lg-8">
                <div class="card">
                    <div class="card-header py-4">
                        <h3 class="mb-0 text-center">
                            <i class="bi bi-chat-quote"></i>
                            {% trans "Submit Your Explanation" %}
                        </h3>
                    </div>
                    <div class="card-body p-4">
                        {% if error %}
                        <div class="alert alert-danger" role="alert">
                            {{ error }}
                        </div>
                        {% endif %}

                        <div class="complaint-details mb-4">
                            <h5 class="mb-3">{% trans "Complaint Details" %}</h5>
                            <div class="row">
                                <div class="col-md-6 mb-2">
                                    <strong>{% trans "Reference:" %}</strong> #{{ complaint.id }}
                                </div>
                                <div class="col-md-6 mb-2">
                                    <strong>{% trans "Title:" %}</strong> {{ complaint.title }}
                                </div>
                                <div class="col-md-6 mb-2">
                                    <strong>{% trans "Severity:" %}</strong>
                                    <span class="badge bg-{{ complaint.get_severity_badge_class }}">
                                        {{ complaint.get_severity_display }}
                                    </span>
                                </div>
                                <div class="col-md-6 mb-2">
                                    <strong>{% trans "Priority:" %}</strong>
                                    <span class="badge bg-{{ complaint.get_priority_badge_class }}">
                                        {{ complaint.get_priority_display }}
                                    </span>
                                </div>
                                {% if complaint.patient %}
                                <div class="col-12 mb-2">
                                    <strong>{% trans "Patient:" %}</strong> {{ complaint.patient.get_full_name }} (MRN: {{ complaint.patient.mrn }})
                                </div>
                                {% endif %}
                                <div class="col-12 mt-3">
                                    <strong>{% trans "Description:" %}</strong>
                                    <p class="mt-1 mb-0">{{ complaint.description|linebreaks }}</p>
                                </div>
                            </div>
                        </div>

                        <form method="post" enctype="multipart/form-data">
                            {% csrf_token %}

                            <div class="mb-4">
                                <label for="explanation" class="form-label">
                                    <strong>{% trans "Your Explanation" %} *</strong>
                                </label>
                                <p class="text-muted small">
                                    {% trans "Please provide your perspective about the complaint mentioned above. Your explanation will help us understand the situation better." %}
                                </p>
                                <textarea
                                    class="form-control"
                                    id="explanation"
                                    name="explanation"
                                    rows="8"
                                    required
                                    placeholder="{% trans 'Write your explanation here...' %}"
                                ></textarea>
                            </div>

                            <div class="mb-4">
                                <label for="attachments" class="form-label">
                                    <strong>{% trans "Attachments (Optional)" %}</strong>
                                </label>
                                <p class="text-muted small">
                                    {% trans "You can attach relevant documents, images, or other files to support your explanation." %}
                                </p>
                                <input
                                    class="form-control"
                                    type="file"
                                    id="attachments"
                                    name="attachments"
                                    multiple
                                >
                                <div class="form-text">
                                    {% trans "Accepted file types: PDF, DOC, DOCX, JPG, PNG, etc. Maximum file size: 10MB." %}
                                </div>
                            </div>

                            <div class="alert alert-info">
                                <i class="bi bi-info-circle"></i>
                                <strong>{% trans "Important Note:" %}</strong>
                                {% trans "This link can only be used once. After submitting your explanation, it will expire and cannot be used again." %}
                            </div>

                            <div class="d-grid">
                                <button type="submit" class="btn btn-primary btn-lg">
                                    <i class="bi bi-send"></i>
                                    {% trans "Submit Explanation" %}
                                </button>
                            </div>
                        </form>
                    </div>
                    <div class="card-footer text-muted text-center py-3">
                        <small>{% trans "PX360 Complaint Management System" %}</small>
                    </div>
                </div>
            </div>
        </div>
    </div>

    <script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0/dist/js/bootstrap.bundle.min.js"></script>
    <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap-icons@1.10.0/font/bootstrap-icons.css">
</body>
</html>
