{% extends 'base.html' %}

{% block content %}
<div class="container mt-5">
    <div class="row justify-content-center">
        <div class="col-md-6">
            <div class="card shadow">
                <div class="card-header bg-primary text-white">
                    <h3 class="card-title mb-0">Start a New Project</h3>
                </div>
                <div class="card-body">
                    <form method="post" id="create-project-form">
                        {% csrf_token %}
                        <div class="mb-3">
                            <label for="title" class="form-label">Project Title</label>
                            <input type="text" class="form-control" id="title" name="title" required placeholder="e.g. NextGen CRM">
                        </div>
                        <div class="mb-3">
                            <label for="industry" class="form-label">Industry</label>
                            <input type="text" class="form-control" id="industry" name="industry" required placeholder="e.g. SaaS">
                        </div>
                        <div class="mb-4">
                            <label for="goal" class="form-label">Primary Goal</label>
                            <textarea class="form-control" id="goal" name="goal" rows="3" required placeholder="Describe what you want to achieve..."></textarea>
                        </div>
                        <div class="d-grid">
                            <button type="submit" class="btn btn-primary btn-lg" id="submit-btn">
                                Generate Mind Map
                                <span class="spinner-border spinner-border-sm d-none ms-2" id="loading-spinner" role="status" aria-hidden="true"></span>
                            </button>
                        </div>
                    </form>
                </div>
                <div class="card-footer text-muted text-center" id="loading-text" style="display: none;">
                    <small>Please wait while our AI analyzes your goal and builds the initial map (this may take up to 20 seconds)...</small>
                </div>
            </div>
        </div>
    </div>
</div>

<script>
    document.getElementById('create-project-form').addEventListener('submit', function() {
        // Disable the button to prevent multiple submissions
        const btn = document.getElementById('submit-btn');
        setTimeout(() => { btn.disabled = true; }, 0);
        
        // Show the spinner and loading text
        document.getElementById('loading-spinner').classList.remove('d-none');
        document.getElementById('loading-text').style.display = 'block';
        
        // Let the form submit normally
    });
</script>
{% endblock %}