{% extends "layouts/source_user_base.html" %}
{% load i18n %}

{% block title %}{% trans "Submit Suggestion" %} - {{ source.get_localized_name }}{% endblock %}

{% block extra_css %}
<style>
    @keyframes fadeIn {
        from { opacity: 0; transform: translateY(20px); }
        to { opacity: 1; transform: translateY(0); }
    }
    .animate-in {
        animation: fadeIn 0.5s ease-out forwards;
    }
</style>
{% endblock %}

{% block content %}
<div class="p-6 md:p-8 bg-gradient-to-br from-light to-blue-50 min-h-screen">
    <!-- Page Header -->
    <div class="flex flex-wrap justify-between items-center gap-4 mb-8 animate-in">
        <div class="flex items-center gap-3">
            <div class="flex items-center justify-center w-14 h-14 bg-gradient-to-br from-cyan-500 to-cyan-600 rounded-2xl shadow-lg shadow-cyan-200">
                <i data-lucide="lightbulb" class="w-8 h-8 text-white"></i>
            </div>
            <div>
                <h1 class="text-2xl font-bold text-navy">
                    {% trans "Submit Suggestion" %}
                </h1>
                <p class="text-slate text-sm">
                    {% trans "Share your ideas from" %} <strong>{{ source.get_localized_name }}</strong>
                </p>
            </div>
        </div>
        <a href="{% url 'px_sources:source_user_suggestions' %}"
           class="inline-flex items-center gap-2 px-5 py-2.5 bg-white border-2 border-blue-200 text-navy rounded-xl font-semibold hover:bg-blue-50 transition">
            <i data-lucide="arrow-left" class="w-4 h-4"></i>
            {% trans "Back to Suggestions" %}
        </a>
    </div>

    <!-- Info Banner -->
    <div class="bg-cyan-50 border border-cyan-200 rounded-2xl p-4 mb-8 animate-in">
        <div class="flex items-start gap-3">
            <i data-lucide="info" class="w-5 h-5 text-cyan-600 mt-0.5 flex-shrink-0"></i>
            <div>
                <p class="text-sm font-bold text-cyan-800 mb-1">{% trans "Source Information" %}</p>
                <p class="text-sm text-cyan-700">
                    {% trans "This suggestion will be automatically linked to" %} <strong>{{ source.get_localized_name }}</strong>.
                    {% trans "All required fields are marked with" %} <span class="text-red-500">*</span>
                </p>
            </div>
        </div>
    </div>

    <!-- Form -->
    <div class="bg-white rounded-2xl shadow-sm border border-cyan-100 overflow-hidden animate-in">
        <form method="post" novalidate data-loading data-loading-text="{% trans 'Submitting...' %}">
            {% csrf_token %}

            <div class="p-6 md:p-8">
                <!-- Contact Information -->
                <h2 class="text-lg font-bold text-navy mb-4 flex items-center gap-2">
                    <i data-lucide="user" class="w-5 h-5 text-cyan-500"></i>
                    {% trans "Contact Information" %}
                </h2>
                <div class="grid grid-cols-1 md:grid-cols-2 gap-6 mb-8">
                    <div>
                        <label for="{{ form.contact_name.id_for_label }}" class="block text-sm font-bold text-navy mb-2">
                            {{ form.contact_name.label }} <span class="text-red-500">*</span>
                        </label>
                        {{ form.contact_name }}
                        {% if form.contact_name.errors %}
                        <div class="flex items-center gap-2 mt-2 text-red-600 text-sm">
                            <i data-lucide="alert-circle" class="w-4 h-4"></i>
                            {% for error in form.contact_name.errors %}{{ error }}{% endfor %}
                        </div>
                        {% endif %}
                    </div>

                    <div>
                        <label for="{{ form.contact_phone.id_for_label }}" class="block text-sm font-bold text-navy mb-2">
                            {{ form.contact_phone.label }} <span class="text-red-500">*</span>
                        </label>
                        {{ form.contact_phone }}
                        {% if form.contact_phone.errors %}
                        <div class="flex items-center gap-2 mt-2 text-red-600 text-sm">
                            <i data-lucide="alert-circle" class="w-4 h-4"></i>
                            {% for error in form.contact_phone.errors %}{{ error }}{% endfor %}
                        </div>
                        {% endif %}
                    </div>

                    <div>
                        <label for="{{ form.contact_email.id_for_label }}" class="block text-sm font-bold text-navy mb-2">
                            {{ form.contact_email.label }}
                        </label>
                        {{ form.contact_email }}
                        {% if form.contact_email.errors %}
                        <div class="flex items-center gap-2 mt-2 text-red-600 text-sm">
                            <i data-lucide="alert-circle" class="w-4 h-4"></i>
                            {% for error in form.contact_email.errors %}{{ error }}{% endfor %}
                        </div>
                        {% endif %}
                    </div>
                </div>

                <!-- Suggestion Details -->
                <h2 class="text-lg font-bold text-navy mb-4 flex items-center gap-2">
                    <i data-lucide="file-text" class="w-5 h-5 text-cyan-500"></i>
                    {% trans "Your Suggestion" %}
                </h2>
                <div>
                    <label for="{{ form.message.id_for_label }}" class="block text-sm font-bold text-navy mb-2">
                        {{ form.message.label }} <span class="text-red-500">*</span>
                    </label>
                    {{ form.message }}
                    {% if form.message.errors %}
                    <div class="flex items-center gap-2 mt-2 text-red-600 text-sm">
                        <i data-lucide="alert-circle" class="w-4 h-4"></i>
                        {% for error in form.message.errors %}{{ error }}{% endfor %}
                    </div>
                    {% endif %}
                </div>
            </div>

            <!-- Submit -->
            <div class="px-6 md:px-8 py-4 bg-slate-50 border-t border-slate-100 flex gap-3">
                <button type="submit" class="inline-flex items-center gap-2 px-6 py-3 bg-blue-600 text-white rounded-xl font-semibold hover:bg-blue-700 transition">
                    <i data-lucide="check" class="w-5 h-5"></i>
                    {% trans "Submit Suggestion" %}
                </button>
                <a href="{% url 'px_sources:source_user_suggestions' %}"
                   class="inline-flex items-center gap-2 px-6 py-3 bg-white border-2 border-slate-200 text-slate-700 rounded-xl font-semibold hover:bg-slate-50 transition">
                    <i data-lucide="x" class="w-5 h-5"></i>
                    {% trans "Cancel" %}
                </a>
            </div>
        </form>
    </div>
</div>

<script>
document.addEventListener('DOMContentLoaded', function() {
    lucide.createIcons();
});
</script>
{% endblock %}
