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

{% block title %}{% trans "New Suggestion" %} - PX360{% endblock %}

{% block extra_css %}
<style>
    .page-header-gradient {
        background: linear-gradient(135deg, #005696 0%, #0069a8 50%, #007bbd 100%);
        color: white;
        padding: 1.5rem 2rem;
        border-radius: 1rem;
        margin-bottom: 1.5rem;
        box-shadow: 0 10px 15px -3px rgba(0, 86, 150, 0.2);
    }
    .section-card {
        background: white;
        border-radius: 1rem;
        border: 2px solid #e2e8f0;
        box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
        overflow: hidden;
        transition: all 0.3s ease;
    }
    .section-card:hover {
        border-color: #005696;
        box-shadow: 0 10px 25px -5px rgba(0, 86, 150, 0.15);
    }
    .section-header {
        padding: 1rem 1.5rem;
        border-bottom: 2px solid #e2e8f0;
        background: linear-gradient(to right, #f8fafc, #f1f5f9);
        display: flex;
        align-items: center;
        gap: 0.75rem;
    }
    .section-icon {
        width: 40px;
        height: 40px;
        border-radius: 0.75rem;
        display: flex;
        align-items: center;
        justify-content: center;
    }
</style>
{% endblock %}

{% block content %}
<div class="page-header-gradient">
    <div class="flex justify-between items-center">
        <div>
            <div class="flex items-center gap-2 text-blue-100 text-sm mb-2">
                <a href="{% url 'feedback:feedback_list' %}" class="hover:text-white transition">{% trans "Suggestions" %}</a>
                <i data-lucide="chevron-right" class="w-3 h-3"></i>
                <span class="text-white">{% trans "New" %}</span>
            </div>
            <h1 class="text-2xl font-bold">{% trans "New Suggestion" %}</h1>
        </div>
        <a href="{% url 'feedback:feedback_list' %}" class="inline-flex items-center px-4 py-2.5 bg-white text-navy font-medium rounded-xl hover:bg-blue-50 transition">
            <i data-lucide="arrow-left" class="w-4 h-4 me-2"></i>{% trans "Back" %}
        </a>
    </div>
</div>

<div class="section-card">
    <div class="section-header">
        <div class="section-icon bg-cyan-500/10">
            <i data-lucide="lightbulb" class="w-5 h-5 text-cyan-600"></i>
        </div>
        <h5 class="text-lg font-semibold text-gray-800">{% trans "Suggestion Details" %}</h5>
    </div>

    {% if messages %}
    <div class="px-6 pt-4">
        {% for message in messages %}
        <div class="{% if message.tags == 'error' %}bg-red-50 border-red-200 text-red-700{% else %}bg-green-50 border-green-200 text-green-700{% endif %} border rounded-lg px-4 py-3 text-sm mb-2">
            {{ message }}
        </div>
        {% endfor %}
    </div>
    {% endif %}

    <form method="post" class="p-6">
        {% csrf_token %}
        {% if communication_request %}
        <input type="hidden" name="comm_req" value="{{ communication_request.id }}">
        {% endif %}

        <div class="grid grid-cols-1 md:grid-cols-2 gap-4 mb-5">
            <div>
                <label class="block text-sm font-semibold text-navy mb-2">{% trans "Your Name" %} <span class="text-red-500">*</span></label>
                <input type="text" name="contact_name" required placeholder="{% trans 'Your full name' %}" value="{{ prefill.contact_name|default:'' }}"
                       class="w-full px-4 py-3 border-2 border-slate-200 rounded-xl text-navy focus:outline-none focus:ring-2 focus:ring-navy/20 focus:border-navy">
            </div>
            <div>
                <label class="block text-sm font-semibold text-navy mb-2">{% trans "Phone Number" %} <span class="text-red-500">*</span></label>
                <input type="tel" name="contact_phone" maxlength="20" required placeholder="{% trans 'Your phone number' %}" value="{{ prefill.contact_phone|default:'' }}"
                       class="w-full px-4 py-3 border-2 border-slate-200 rounded-xl text-navy focus:outline-none focus:ring-2 focus:ring-navy/20 focus:border-navy">
            </div>
        </div>

        <div class="mb-5">
            <label class="block text-sm font-semibold text-navy mb-2">{% trans "Hospital" %} <span class="text-red-500">*</span></label>
            <select name="hospital" required class="w-full px-4 py-3 border-2 border-slate-200 rounded-xl text-navy focus:outline-none focus:ring-2 focus:ring-navy/20 focus:border-navy bg-white">
                <option value="">{% trans "Select Hospital" %}</option>
                {% for h in hospitals %}
                <option value="{{ h.id }}" {% if prefill.hospital == h.id|stringformat:"s" %}selected{% endif %}>{{ h.name }}</option>
                {% endfor %}
            </select>
        </div>

        <div class="mb-5">
            <label class="block text-sm font-semibold text-navy mb-2">{% trans "Message" %} <span class="text-red-500">*</span></label>
            <textarea name="message" rows="5" required placeholder="{% trans 'Describe your suggestion in detail...' %}"
                      class="w-full px-4 py-3 border-2 border-slate-200 rounded-xl text-navy focus:outline-none focus:ring-2 focus:ring-navy/20 focus:border-navy resize-none">{{ prefill.message|default:'' }}</textarea>
        </div>

        <div class="text-center pt-4 border-t border-slate-100">
            <button type="submit" class="px-8 py-3.5 bg-navy text-white rounded-xl font-bold hover:bg-navy/90 transition inline-flex items-center gap-2">
                <i data-lucide="send" class="w-5 h-5"></i> {% trans "Submit Suggestion" %}
            </button>
        </div>
    </form>
</div>
{% endblock %}

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