{% load i18n %}
{% load static %}
<!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 Response" %} - PX360</title>
    <link rel="stylesheet" href="{% static 'dist/css/tailwind.css' %}">
    <link rel="stylesheet" href="{% static 'vendor/fonts/noto-kufi-arabic/arabic.css' %}">
    <style>
        @import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&display=swap');
        body { font-family: 'Inter', 'Noto Kufi Arabic', sans-serif; }
        [dir="rtl"] body,
        [dir="rtl"] input,
        [dir="rtl"] textarea,
        [dir="rtl"] select,
        [dir="rtl"] button {
            font-family: 'Noto Kufi Arabic', sans-serif;
        }
        .page-header-gradient {
            background: linear-gradient(135deg, #0891b2 0%, #06b6d4 50%, #22d3ee 100%);
            color: white; padding: 1.5rem 2rem; border-radius: 1rem; margin-bottom: 1.5rem;
            box-shadow: 0 10px 15px -3px rgba(8, 145, 178, 0.2);
        }
        .form-section {
            background: #fff; border: 2px solid #e2e8f0; border-radius: 1rem;
            padding: 1.5rem; margin-bottom: 1.5rem; transition: all 0.3s ease;
        }
        .form-section:hover { border-color: #0891b2; box-shadow: 0 4px 12px rgba(8, 145, 178, 0.1); }
        .form-label { display: block; font-size: 0.875rem; font-weight: 600; color: #1e293b; margin-bottom: 0.5rem; }
        .form-control {
            width: 100%; padding: 0.75rem 1rem; border: 2px solid #e2e8f0; border-radius: 0.75rem;
            font-size: 0.875rem; transition: all 0.2s ease;
        }
        .form-control:focus { outline: none; border-color: #0891b2; box-shadow: 0 0 0 3px rgba(8, 145, 178, 0.1); }
        .hh-btn-primary {
            display: inline-flex; align-items: center; justify-content: center; gap: 0.5rem;
            padding: 0.75rem 1.5rem; background: #0891b2; color: white; border-radius: 0.75rem;
            font-weight: 600; transition: all 0.2s ease; border: none; cursor: pointer; width: 100%;
        }
        .hh-btn-primary:hover { background: #0e7490; }
    </style>
</head>
<body class="bg-light min-h-screen flex items-center py-8 px-4">
    <div class="w-full max-w-3xl mx-auto">
        <div class="page-header-gradient text-center">
            <div class="inline-flex items-center justify-center w-16 h-16 bg-white/20 rounded-2xl mb-4">
                <i data-lucide="help-circle" class="w-8 h-8"></i>
            </div>
            <h1 class="text-2xl font-bold">{% trans "Submit Your Response" %}</h1>
            <p class="text-white/80 mt-1">{% trans "PX360 Inquiry Management System" %}</p>
        </div>

        <div class="form-section">
            {% if error %}
            <div class="bg-red-50 border-l-4 border-red-500 p-4 mb-6 rounded-r-lg">
                <div class="flex items-center gap-3">
                    <i data-lucide="alert-circle" class="w-5 h-5 text-red-500 flex-shrink-0"></i>
                    <p class="text-red-700 font-medium">{{ error }}</p>
                </div>
            </div>
            {% endif %}

            {% if explanation.staff %}
            <div class="bg-cyan-700 p-6 text-white rounded-t-lg -mx-6 -mt-6 mb-6">
                <h2 class="text-sm font-semibold text-cyan-200 mb-3 flex items-center gap-2">
                    <i data-lucide="user" class="w-4 h-4"></i>
                    {% trans "Requested From" %}
                </h2>
                <div class="flex items-center gap-4">
                    <div class="w-14 h-14 bg-white/20 rounded-full flex items-center justify-center text-2xl font-bold">
                        {{ explanation.staff.first_name|first }}{{ explanation.staff.last_name|first }}
                    </div>
                    <div class="flex-1">
                        <h3 class="text-xl font-bold">{{ explanation.staff.first_name }} {{ explanation.staff.last_name }}</h3>
                        {% if explanation.staff.department %}
                        <div class="flex items-center gap-1 mt-1 text-sm text-cyan-100">
                            <i data-lucide="building-2" class="w-4 h-4"></i>
                            {{ explanation.staff.department.name }}
                        </div>
                        {% endif %}
                    </div>
                </div>
            </div>
            {% endif %}

            <div class="bg-light/50 border border-slate-200 rounded-xl p-6 mb-6">
                <h2 class="text-lg font-bold text-navy mb-4 flex items-center gap-2">
                    <i data-lucide="help-circle" class="w-5 h-5 text-cyan-600"></i>
                    {% trans "Inquiry Details" %}
                </h2>
                <div class="grid grid-cols-1 md:grid-cols-2 gap-4">
                    <div class="flex items-center gap-2">
                        <span class="text-slate text-sm">{% trans "Reference:" %}</span>
                        <span class="font-bold text-navy">#{{ inquiry.reference_number|default:inquiry.id|truncatechars:12 }}</span>
                    </div>
                    <div class="flex items-center gap-2">
                        <span class="text-slate text-sm">{% trans "Subject:" %}</span>
                        <span class="font-bold text-navy">{{ inquiry.subject }}</span>
                    </div>
                </div>
                <div class="mt-4 pt-4 border-t border-slate-200">
                    <span class="text-slate text-sm">{% trans "Message:" %}</span>
                    <p class="mt-2 text-slate leading-relaxed">{{ inquiry.message|linebreaksbr }}</p>
                </div>
            </div>

            {% if explanation.request_message %}
            <div class="bg-blue-50 border border-blue-200 rounded-xl p-4 mb-6">
                <p class="text-xs font-semibold text-blue-700 mb-1">{% trans "Request Message:" %}</p>
                <p class="text-sm text-slate">{{ explanation.request_message }}</p>
            </div>
            {% endif %}

            <form method="post" enctype="multipart/form-data" class="space-y-6">
                {% csrf_token %}
                <div>
                    <label for="explanation" class="form-label">
                        {% trans "Your Response" %} <span class="text-red-500">*</span>
                    </label>
                    <textarea id="explanation" name="explanation" rows="6" required
                        class="form-control resize-none"
                        placeholder="{% trans 'Write your response here...' %}"></textarea>
                </div>
                <div>
                    <label for="attachments" class="form-label">{% trans "Attachments (Optional)" %}</label>
                    <input type="file" id="attachments" name="attachments" multiple
                        class="block w-full text-sm text-slate file:mr-4 file:py-2 file:px-4 file:rounded-xl file:border-0 file:text-sm file:font-semibold file:bg-light file:text-navy hover:file:bg-slate-100 file:transition cursor-pointer border-2 border-slate-200 rounded-xl">
                </div>
                <div class="bg-cyan-50 border border-cyan-200 rounded-xl p-4">
                    <div class="flex items-start gap-3">
                        <i data-lucide="info" class="w-5 h-5 text-cyan-600 flex-shrink-0 mt-0.5"></i>
                        <p class="text-slate text-sm">
                            {% trans "This link can only be used once. After submitting your response, it will expire." %}
                        </p>
                    </div>
                </div>
                <button type="submit" class="hh-btn-primary py-4 text-lg">
                    <i data-lucide="send" class="w-5 h-5"></i>
                    {% trans "Submit Response" %}
                </button>
            </form>
        </div>
    </div>
    <script src="{% static 'vendor/lucide/lucide.min.js' %}"></script>
    <script>lucide.createIcons();</script>
</body>
</html>
