<!DOCTYPE html>
<html lang="es">
<head>
    <meta charset="UTF-8">
    <title>Inicio de sesión</title>
    <script src="https://cdn.jsdelivr.net/npm/sweetalert2@11"></script>
    <style>
        body {
            font-family: Arial, sans-serif;
            background-color: #1c1c1c; 
            margin: 0;
            height: 100vh;
            display: flex;
            justify-content: center;
            align-items: center;
            position: relative;
        }

        /* Triángulos decorativos */
        .triangle-left {
            width: 0;
            height: 0;
            border-left: 150px solid #d1d02e;
            border-top: 150px solid transparent;
            position: absolute;
            top: 0;
            left: 0;
        }

        .triangle-right {
            width: 0;
            height: 0;
            border-right: 150px solid #d1d02e;
            border-bottom: 150px solid transparent;
            position: absolute;
            bottom: 0;
            right: 0;
        }

        .container {
            background-color: #0f0b0b; 
            padding: 50px 40px;
            border-radius: 20px;
            box-shadow: 0 0 20px rgba(0,0,0,0.5);
            text-align: center;
            width: 400px;
            position: relative;
            z-index: 1;
        }

        .logo {
            width: 200px;
            margin-bottom: 20px;
        }

        h2 {
            color: #d1d02e;
            margin-bottom: 30px;
        }

        form label {
            display: block;
            text-align: left;
            font-size: 16px;
            color: #d1d02e;
            margin-bottom: 5px;
        }

        form input[type="text"],
        form input[type="password"] {
            width: 100%;
            padding: 10px;
            margin-bottom: 20px;
            border-radius: 5px;
            border: none;
            font-size: 16px;
        }

        .btn {
            width: 100%;
            padding: 12px;
            font-size: 18px;
            border: none;
            border-radius: 5px;
            background-color: #567d23; 
            color: white;
            cursor: pointer;
        }

        .btn:hover {
            background-color: #46611a;
        }
    </style>
</head>
<body>
    <div class="triangle-left"></div>
    <div class="triangle-right"></div>

    <div class="container">
        <img src="/static/img/logo.jpg" alt="Logo" class="logo">

        <h2>INICIO DE SESIÓN</h2>

        <form method="POST" action="{% url 'iniciose' %}">
            {% csrf_token %}
            <label for="usuario">USUARIO:</label>
            <input type="text" name="usuario" required>

            <label for="contrasena">CONTRASEÑA:</label>
            <input type="password" name="contrasena" required>

            <button type="submit" class="btn">CONTINUAR</button>
        </form>
    </div>

    {% if messages %}
    {% for mensaje in messages %}
    <script>
        // Determinar tipo de mensaje
        let tipoIcono = "info";
        let titulo = "Información";
        let colorBoton = "#d1d02e";
        
        {% if mensaje.tags == 'error' %}
            tipoIcono = "error";
            titulo = "Error";
            colorBoton = "#e74c3c";
        {% elif mensaje.tags == 'success' %}
            tipoIcono = "success";
            titulo = "Éxito";
            colorBoton = "#567d23";
        {% elif mensaje.tags == 'warning' %}
            tipoIcono = "warning";
            titulo = "Advertencia";
            colorBoton = "#f39c12";
        {% endif %}

        Swal.fire({
            title: titulo,
            text: "{{ mensaje }}",
            icon: tipoIcono,
            background: "#1c1c1c",
            color: "#ffffff",
            confirmButtonColor: colorBoton
        });
    </script>
    {% endfor %}
{% endif %}
</body>
</html>
