{% extends 'base.html' %}

{% block title %}Bot Settings - WhatsApp AI Bot{% endblock %}

{% block content %}
<div class="row justify-content-center">
    <div class="col-md-8">
        <div class="card p-4">
            <h2 class="fw-bold mb-4">AI Bot Personality</h2>
            <form method="POST">
                {% csrf_token %}
                <div class="mb-4">
                    <label class="form-label fw-600">System Instruction (Prompt)</label>
                    <textarea name="system_prompt" class="form-control" rows="6" placeholder="Define how the AI should behave...">{{ settings.system_prompt }}</textarea>
                    <div class="form-text mt-2">
                        This instruction defines the bot's tone, personality, and knowledge limits.
                    </div>
                </div>

                <div class="mb-4">
                    <label class="form-label fw-600">Verification Token (Meta Webhook)</label>
                    <input type="text" name="verify_token" class="form-control" value="{{ settings.verify_token }}">
                    <div class="form-text">
                        Use this token when setting up the webhook in the Meta Developer Portal.
                    </div>
                </div>

                <div class="form-check form-switch mb-4">
                    <input class="form-check-input" type="checkbox" name="is_active" id="activeSwitch" {% if settings.is_active %}checked{% endif %}>
                    <label class="form-check-label fw-600" for="activeSwitch">Enable Auto-Reply</label>
                </div>

                <hr>

                <div class="d-flex justify-content-between">
                    <a href="{% url 'index' %}" class="btn btn-light">Back to Dashboard</a>
                    <button type="submit" class="btn btn-primary px-4">Save Changes</button>
                </div>
            </form>
        </div>
        
        <div class="card mt-4 p-4 border-info bg-info bg-opacity-10">
            <h5><i class="bi bi-info-circle me-2"></i>Setup Tip</h5>
            <p class="mb-0 small text-dark">
                Your Meta Webhook URL: <code>https://your-domain.com/webhook/whatsapp/</code><br>
                Verification Token: <code>{{ settings.verify_token }}</code>
            </p>
        </div>
    </div>
</div>
{% endblock %}
