{% load static %}
<c-layouts.auth title="Ingresar | Lo Justo LMS">
    <div class="py-10 px-4 w-full flex justify-center">
        <div class="max-w-md w-full bg-white rounded-3xl border border-zinc-200/80 shadow-2xl p-8 sm:p-10 relative overflow-hidden">
            <!-- Acento esmeralda superior -->
            <div class="absolute top-0 left-0 right-0 h-2 bg-gradient-to-r from-emerald-600 via-emerald-500 to-amber-400"></div>

            <!-- Logo Institucional -->
            <div class="text-center mb-8 mt-2">
                <a href="{% url 'core:landing' %}" class="inline-flex items-center justify-center decoration-0 group mb-2">
                    <img src="{% static 'img/logo.png' %}" alt="Lo Justo Learning" class="h-14 sm:h-16 w-auto object-contain transition-transform group-hover:scale-105" />
                </a>
                <h1 class="text-2xl font-black text-zinc-900 mt-4 tracking-tight">Iniciar Sesión</h1>
                <p class="text-sm text-zinc-500 mt-1 font-medium">Ingresa a tu Portal E-Learning o Panel Docente</p>
            </div>

            <!-- Alertas de mensajes -->
            {% if messages %}
                <div class="mb-6 space-y-2">
                    {% for message in messages %}
                        <div class="p-4 rounded-xl text-xs font-bold {% if message.tags == 'error' %}bg-red-50 text-red-700 border border-red-200{% else %}bg-emerald-50 text-emerald-800 border border-emerald-200{% endif %}">
                            {{ message }}
                        </div>
                    {% endfor %}
                </div>
            {% endif %}

            <form method="post" action="{% url 'users:login' %}" class="space-y-5">
                {% csrf_token %}
                {% if next %}
                    <input type="hidden" name="next" value="{{ next }}">
                {% endif %}

                <div>
                    <label for="username" class="block text-xs font-bold text-zinc-700 uppercase tracking-wider mb-2">
                        Correo Electrónico o Usuario
                    </label>
                    <div class="relative">
                        <input type="text" id="username" name="username" required
                               class="w-full px-4 py-3 bg-zinc-50 border border-zinc-300 rounded-xl text-sm font-medium text-zinc-900 focus:bg-white focus:outline-none focus:ring-2 focus:ring-emerald-500 focus:border-transparent transition-all"
                               placeholder="carlos.mendoza@lojusto.cl">
                    </div>
                </div>

                <div>
                    <div class="flex items-center justify-between mb-2">
                        <label for="password" class="block text-xs font-bold text-zinc-700 uppercase tracking-wider">
                            Contraseña
                        </label>
                    </div>
                    <input type="password" id="password" name="password" required
                           class="w-full px-4 py-3 bg-zinc-50 border border-zinc-300 rounded-xl text-sm font-medium text-zinc-900 focus:bg-white focus:outline-none focus:ring-2 focus:ring-emerald-500 focus:border-transparent transition-all"
                           placeholder="••••••••">
                </div>

                <div class="pt-2">
                    <button type="submit"
                            class="w-full py-3.5 px-6 bg-gradient-to-r from-emerald-600 to-emerald-700 hover:from-emerald-700 hover:to-emerald-800 text-white font-black rounded-xl shadow-lg shadow-emerald-600/20 uppercase tracking-wider text-xs transition-all transform hover:-translate-y-0.5 active:translate-y-0">
                        Ingresar a mi Portal →
                    </button>
                </div>
            </form>

            <div class="mt-8 pt-6 border-t border-zinc-100 text-center text-xs text-zinc-500 font-medium">
                ¿Aún no tienes cuenta en Lo Justo?
                <a href="{% url 'users:register' %}" class="font-bold text-emerald-600 hover:text-emerald-700 hover:underline ml-1">
                    Crear cuenta de Alumno
                </a>
            </div>

            <div class="mt-4 p-3 bg-zinc-100/80 rounded-xl text-[11px] text-zinc-600 text-center font-medium border border-zinc-200/60">
                💡 <span class="font-bold">Usuarios Demo:</span> <br>
                Alumno: <code class="bg-white px-1.5 py-0.5 rounded text-emerald-800 font-bold border border-zinc-300">tecnico_carlos</code> · Docente: <code class="bg-white px-1.5 py-0.5 rounded text-emerald-800 font-bold border border-zinc-300">profesor_marcos</code> <br>
                Manager: <code class="bg-white px-1.5 py-0.5 rounded text-emerald-800 font-bold border border-zinc-300">coordinadora_sofia</code> (Clave todos: <code class="font-bold text-zinc-900">lojusto2026</code>)
            </div>
        </div>
    </div>
</c-layouts.auth>
