<!DOCTYPE html>
<html lang="ro">
<head>
    <meta charset="UTF-8">
    <title>Nutriție AI Pro</title>
    <link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0/dist/css/bootstrap.min.css" rel="stylesheet">
</head>
<body class="p-5 bg-light">
    <div class="container" style="max-width: 600px;">
        <h1 class="mb-4 text-center">Calculator Kcal & AI Menu</h1>
        
        <div class="card p-4 shadow-sm">
            <form action="/calculate" method="post">
                <div class="mb-3">
                    <label class="form-label">Greutate actuală (kg)</label>
                    <input type="number" name="weight" class="form-control" required>
                </div>
                <div class="mb-3">
                    <label class="form-label">Înălțime (cm)</label>
                    <input type="number" name="height" class="form-control" required>
                </div>
                <div class="mb-3">
                    <label class="form-label">Vârstă</label>
                    <input type="number" name="age" class="form-control" required>
                </div>
                <div class="mb-3">
                    <label class="form-label">Sex</label>
                    <select name="gender" class="form-select">
                        <option value="masculin">Masculin</option>
                        <option value="feminin">Feminin</option>
                    </select>
                </div>
                <div class="mb-3">
                    <label class="form-label">Nivel activitate</label>
                    <select name="activity" class="form-select">
                        <option value="1.2">Sedentar (birou)</option>
                        <option value="1.55">Activ (3-5 zile sport)</option>
                        <option value="1.9">Extrem (muncă fizică/sport zilnic)</option>
                    </select>
                </div>
                <div class="mb-3">
                    <label class="form-label">Obiectiv</label>
                    <select name="goal" class="form-select">
                        <option value="mentinere">Menținere</option>
                        <option value="slabire">Slăbire (-500 kcal)</option>
                        <option value="ingrasare">Îngrășare (+500 kcal)</option>
                    </select>
                </div>
                <button type="submit" class="btn btn-success w-100">Calculează</button>
            </form>

            {% if rezultat %}
            <div class="mt-4 alert alert-info text-center">
                <h4>Ținta ta: {{ rezultat }} kcal / zi</h4>
            </div>
            <hr>
            
            <h5>🤖 Cere meniu de la AI</h5>
            <form action="/calculate" method="post">
                <input type="hidden" name="weight" value="{{ request.form.weight }}">
                <input type="hidden" name="height" value="{{ request.form.height }}">
                <input type="hidden" name="age" value="{{ request.form.age }}">
                <input type="hidden" name="gender" value="{{ request.form.gender }}">
                <input type="hidden" name="activity" value="{{ request.form.activity }}">
                <input type="hidden" name="goal" value="{{ request.form.goal }}">
                
                <textarea name="preferences" class="form-control mb-2" placeholder="Ex: Sunt vegetarian, nu îmi place peștele..."></textarea>
                <button type="submit" class="btn btn-outline-primary btn-sm w-100">Generează Meniu Personalizat</button>
            </form>
            {% endif %}

            {% if meniu_ai %}
            <div class="mt-4 p-3 border rounded bg-white">
                <h6 class="text-primary font-weight-bold">Meniul tău generat:</h6>
                <p style="white-space: pre-line;">{{ meniu_ai }}</p>
            </div>
            {% endif %}
        </div>
    </div>
</body>
</html>