<!DOCTYPE html>
<html lang="fr">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>EcoCharge — Connexion</title>
    <style>
        /* ── Variables de couleur ── */
        :root {
            --vert:   #2ecc71;
            --bleu:   #1a1a2e;
            --gris:   #16213e;
            --blanc:  #f0f4f8;
            --rouge:  #e74c3c;
        }

        /* ── Reset simple ── */
        * {
            margin: 0;
            padding: 0;
            box-sizing: border-box;
        }

        /* ── Fond de page ── */
        body {
            background-color: var(--bleu);
            font-family: 'Segoe UI', sans-serif;
            min-height: 100vh;
            display: flex;
            align-items: center;
            justify-content: center;
        }

        /* ── Carte de connexion ── */
        .carte {
            background-color: var(--gris);
            padding: 48px 40px;
            border-radius: 16px;
            width: 100%;
            max-width: 400px;
            box-shadow: 0 8px 32px rgba(0, 0, 0, 0.4);
        }

        /* ── Logo / en-tête ── */
        .logo {
            text-align: center;
            margin-bottom: 32px;
        }

        .logo-icone {
            font-size: 48px;
            display: block;
            margin-bottom: 8px;
        }

        .logo h1 {
            color: var(--vert);
            font-size: 26px;
            letter-spacing: 2px;
        }

        .logo p {
            color: #7f8c8d;
            font-size: 13px;
            margin-top: 4px;
        }

        /* ── Champs du formulaire ── */
        .champ {
            margin-bottom: 20px;
        }

        .champ label {
            display: block;
            color: var(--blanc);
            font-size: 13px;
            margin-bottom: 6px;
            font-weight: 600;
            text-transform: uppercase;
            letter-spacing: 1px;
        }

        .champ input {
            width: 100%;
            padding: 12px 16px;
            border-radius: 8px;
            border: 1px solid #2c3e50;
            background-color: #0f3460;
            color: var(--blanc);
            font-size: 15px;
            outline: none;
            transition: border-color 0.2s;
        }

        /* Met en valeur le champ actif */
        .champ input:focus {
            border-color: var(--vert);
        }

        /* ── Message d'erreur Flask/Jinja ── */
        .erreur {
            background-color: rgba(231, 76, 60, 0.15);
            border: 1px solid var(--rouge);
            color: var(--rouge);
            padding: 10px 14px;
            border-radius: 8px;
            font-size: 14px;
            margin-bottom: 20px;
            text-align: center;
        }

        /* ── Bouton de connexion ── */
        .bouton {
            width: 100%;
            padding: 13px;
            background-color: var(--vert);
            color: #fff;
            border: none;
            border-radius: 8px;
            font-size: 16px;
            font-weight: 700;
            cursor: pointer;
            letter-spacing: 1px;
            transition: background-color 0.2s;
        }

        .bouton:hover {
            background-color: #27ae60;
        }
    </style>
</head>
<body>

    <div class="carte">

        <!-- En-tête avec icône et nom du projet -->
        <div class="logo">
            <span class="logo-icone">⚡</span>
            <h1>ECOCHARGE</h1>
            <p>Interface d'administration</p>
        </div>

        <!-- Message d'erreur affiché si Flask envoie une erreur -->
        {% if error %}
        <div class="erreur">
            {{ error }}
        </div>
        {% endif %}

        <!-- Formulaire de connexion — action vers la route Flask /admin/login -->
        <form method="POST" action="/admin/login">

            <div class="champ">
                <label for="username">Identifiant</label>
                <input
                    type="text"
                    id="username"
                    name="username"
                    placeholder="admin"
                    required
                    autocomplete="username"
                >
            </div>

            <div class="champ">
                <label for="password">Mot de passe</label>
                <input
                    type="password"
                    id="password"
                    name="password"
                    placeholder="••••••••"
                    required
                    autocomplete="current-password"
                >
            </div>

            <button class="bouton" type="submit">Se connecter</button>

        </form>

    </div>

</body>
</html>
