<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Create Your Organization - Savly</title>
    <script src="https://cdn.tailwindcss.com"></script>
    <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.4.0/css/all.min.css">
    <script>
        tailwind.config = {
            theme: {
                extend: {
                    colors: {
                        primary: '#10b981',
                        secondary: '#059669',
                    }
                }
            }
        }
    </script>
</head>
<body class="bg-gradient-to-br from-emerald-50 via-white to-blue-50 min-h-screen">
    <!-- Navigation Header -->
    <nav class="bg-white shadow-lg border-b border-gray-100">
        <div class="max-w-7xl mx-auto px-4 sm:px-6 lg:px-8">
            <div class="flex justify-between items-center h-16">
                <div class="flex items-center space-x-3">
                    <div class="w-10 h-10 bg-gradient-to-r from-emerald-500 to-blue-600 rounded-xl flex items-center justify-center">
                        <i class="fas fa-piggy-bank text-white text-lg"></i>
                    </div>
                    <span class="text-2xl font-bold bg-gradient-to-r from-emerald-600 to-blue-600 bg-clip-text text-transparent">
                        Savly
                    </span>
                </div>
                <div class="flex items-center space-x-4">
                    <a href="{{ url_for('index') }}" class="text-gray-600 hover:text-emerald-600 font-medium">
                        <i class="fas fa-home mr-2"></i>Home
                    </a>
                    <a href="{{ url_for('admin_login') }}" class="text-gray-600 hover:text-emerald-600 font-medium">
                        <i class="fas fa-sign-in-alt mr-2"></i>Login
                    </a>
                </div>
            </div>
        </div>
    </nav>

    <div class="min-h-screen flex items-center justify-center py-12 px-4 sm:px-6 lg:px-8">
        <div class="max-w-2xl w-full space-y-8">
            <!-- Header Section -->
            <div class="text-center">
                <div class="w-20 h-20 bg-gradient-to-r from-emerald-500 to-blue-600 rounded-full flex items-center justify-center mx-auto mb-6">
                    <i class="fas fa-building text-white text-2xl"></i>
                </div>
                <h1 class="text-4xl font-bold text-gray-900 mb-4">Create Your Organization</h1>
                <p class="text-lg text-gray-600 mb-8">Start managing your group's savings with Savly's comprehensive platform</p>
            </div>

            <!-- Features Preview -->
            <div class="grid grid-cols-1 md:grid-cols-3 gap-6 mb-8">
                <div class="bg-white rounded-xl p-6 shadow-sm border border-gray-100 text-center">
                    <div class="w-12 h-12 bg-emerald-100 rounded-full flex items-center justify-center mx-auto mb-4">
                        <i class="fas fa-users text-emerald-600 text-xl"></i>
                    </div>
                    <h3 class="font-semibold text-gray-900 mb-2">Member Management</h3>
                    <p class="text-sm text-gray-600">Add and manage group members with custom IDs and profiles</p>
                </div>
                <div class="bg-white rounded-xl p-6 shadow-sm border border-gray-100 text-center">
                    <div class="w-12 h-12 bg-blue-100 rounded-full flex items-center justify-center mx-auto mb-4">
                        <i class="fas fa-chart-line text-blue-600 text-xl"></i>
                    </div>
                    <h3 class="font-semibold text-gray-900 mb-2">Financial Tracking</h3>
                    <p class="text-sm text-gray-600">Track contributions, generate reports, and monitor progress</p>
                </div>
                <div class="bg-white rounded-xl p-6 shadow-sm border border-gray-100 text-center">
                    <div class="w-12 h-12 bg-purple-100 rounded-full flex items-center justify-center mx-auto mb-4">
                        <i class="fas fa-shield-alt text-purple-600 text-xl"></i>
                    </div>
                    <h3 class="font-semibold text-gray-900 mb-2">Secure Platform</h3>
                    <p class="text-sm text-gray-600">Role-based access control with complete data isolation</p>
                </div>
            </div>

            <!-- Signup Form -->
            <div class="bg-white rounded-2xl shadow-xl border border-gray-200 overflow-hidden">
                <div class="bg-gradient-to-r from-emerald-500 to-blue-600 px-8 py-6">
                    <h2 class="text-2xl font-bold text-white">Get Started Today</h2>
                    <p class="text-emerald-100 mt-2">Fill out the form below to create your organization</p>
                </div>
                
                <form method="POST" action="{{ url_for('group_signup') }}" class="px-8 py-8 space-y-6">
                    {% with messages = get_flashed_messages(with_categories=true) %}
                        {% if messages %}
                            {% for category, message in messages %}
                                <div class="rounded-lg p-4 {% if category == 'error' %}bg-red-50 border border-red-200 text-red-700{% else %}bg-green-50 border border-green-200 text-green-700{% endif %}">
                                    <div class="flex items-center">
                                        <i class="fas {% if category == 'error' %}fa-exclamation-circle{% else %}fa-check-circle{% endif %} mr-2"></i>
                                        {{ message }}
                                    </div>
                                </div>
                            {% endfor %}
                        {% endif %}
                    {% endwith %}

                    <!-- Organization Details -->
                    <div class="space-y-6">
                        <div>
                            <h3 class="text-lg font-semibold text-gray-900 mb-4 flex items-center">
                                <i class="fas fa-building text-emerald-600 mr-2"></i>
                                Organization Details
                            </h3>
                            
                            <div class="grid grid-cols-1 md:grid-cols-2 gap-6">
                                <div>
                                    <label for="organization_name" class="block text-sm font-medium text-gray-700 mb-2">
                                        Organization Name *
                                    </label>
                                    <div class="relative">
                                        <div class="absolute inset-y-0 left-0 pl-3 flex items-center pointer-events-none">
                                            <i class="fas fa-building h-5 w-5 text-gray-400"></i>
                                        </div>
                                        <input type="text" id="organization_name" name="organization_name" required
                                               class="block w-full pl-10 pr-3 py-3 border border-gray-300 rounded-lg focus:outline-none focus:ring-2 focus:ring-emerald-500 focus:border-transparent"
                                               placeholder="Enter organization name">
                                    </div>
                                </div>
                                
                                <div>
                                    <label for="organization_type" class="block text-sm font-medium text-gray-700 mb-2">
                                        Organization Type
                                    </label>
                                    <div class="relative">
                                        <div class="absolute inset-y-0 left-0 pl-3 flex items-center pointer-events-none">
                                            <i class="fas fa-tag h-5 w-5 text-gray-400"></i>
                                        </div>
                                        <select id="organization_type" name="organization_type"
                                                class="block w-full pl-10 pr-8 py-3 border border-gray-300 rounded-lg focus:outline-none focus:ring-2 focus:ring-emerald-500 focus:border-transparent">
                                            <option value="savings_group">Savings Group</option>
                                            <option value="community_org">Community Organization</option>
                                            <option value="social_club">Social Club</option>
                                            <option value="business_group">Business Group</option>
                                            <option value="family_group">Family Group</option>
                                            <option value="other">Other</option>
                                        </select>
                                    </div>
                                </div>
                            </div>
                        </div>

                        <div>
                            <label for="description" class="block text-sm font-medium text-gray-700 mb-2">
                                Description
                            </label>
                            <div class="relative">
                                <div class="absolute top-3 left-3 pointer-events-none">
                                    <i class="fas fa-align-left h-5 w-5 text-gray-400"></i>
                                </div>
                                <textarea id="description" name="description" rows="3"
                                          class="block w-full pl-10 pr-3 py-3 border border-gray-300 rounded-lg focus:outline-none focus:ring-2 focus:ring-emerald-500 focus:border-transparent"
                                          placeholder="Describe your organization's purpose and goals"></textarea>
                            </div>
                        </div>
                    </div>

                    <!-- Admin Account -->
                    <div class="space-y-6">
                        <div>
                            <h3 class="text-lg font-semibold text-gray-900 mb-4 flex items-center">
                                <i class="fas fa-user-shield text-emerald-600 mr-2"></i>
                                Admin Account
                            </h3>
                            
                            <div class="grid grid-cols-1 md:grid-cols-2 gap-6">
                                <div>
                                    <label for="admin_full_name" class="block text-sm font-medium text-gray-700 mb-2">
                                        Full Name *
                                    </label>
                                    <div class="relative">
                                        <div class="absolute inset-y-0 left-0 pl-3 flex items-center pointer-events-none">
                                            <i class="fas fa-user h-5 w-5 text-gray-400"></i>
                                        </div>
                                        <input type="text" id="admin_full_name" name="admin_full_name" required
                                               class="block w-full pl-10 pr-3 py-3 border border-gray-300 rounded-lg focus:outline-none focus:ring-2 focus:ring-emerald-500 focus:border-transparent"
                                               placeholder="Enter your full name">
                                    </div>
                                </div>
                                
                                <div>
                                    <label for="admin_email" class="block text-sm font-medium text-gray-700 mb-2">
                                        Email Address *
                                    </label>
                                    <div class="relative">
                                        <div class="absolute inset-y-0 left-0 pl-3 flex items-center pointer-events-none">
                                            <i class="fas fa-envelope h-5 w-5 text-gray-400"></i>
                                        </div>
                                        <input type="email" id="admin_email" name="admin_email" required
                                               class="block w-full pl-10 pr-3 py-3 border border-gray-300 rounded-lg focus:outline-none focus:ring-2 focus:ring-emerald-500 focus:border-transparent"
                                               placeholder="Enter your email address">
                                    </div>
                                </div>
                            </div>
                        </div>

                        <div class="grid grid-cols-1 md:grid-cols-2 gap-6">
                            <div>
                                <label for="admin_username" class="block text-sm font-medium text-gray-700 mb-2">
                                    Username *
                                </label>
                                <div class="relative">
                                    <div class="absolute inset-y-0 left-0 pl-3 flex items-center pointer-events-none">
                                        <i class="fas fa-at h-5 w-5 text-gray-400"></i>
                                    </div>
                                    <input type="text" id="admin_username" name="admin_username" required
                                           class="block w-full pl-10 pr-3 py-3 border border-gray-300 rounded-lg focus:outline-none focus:ring-2 focus:ring-emerald-500 focus:border-transparent"
                                           placeholder="Choose a username">
                                </div>
                            </div>
                            
                            <div>
                                <label for="admin_phone" class="block text-sm font-medium text-gray-700 mb-2">
                                    Phone Number
                                </label>
                                <div class="relative">
                                    <div class="absolute inset-y-0 left-0 pl-3 flex items-center pointer-events-none">
                                        <i class="fas fa-phone h-5 w-5 text-gray-400"></i>
                                    </div>
                                    <input type="tel" id="admin_phone" name="admin_phone"
                                           class="block w-full pl-10 pr-3 py-3 border border-gray-300 rounded-lg focus:outline-none focus:ring-2 focus:ring-emerald-500 focus:border-transparent"
                                           placeholder="+880 1234 567890">
                                </div>
                            </div>
                        </div>

                        <div>
                            <label for="admin_password" class="block text-sm font-medium text-gray-700 mb-2">
                                Password *
                            </label>
                            <div class="relative">
                                <div class="absolute inset-y-0 left-0 pl-3 flex items-center pointer-events-none">
                                    <i class="fas fa-lock h-5 w-5 text-gray-400"></i>
                                </div>
                                <input type="password" id="admin_password" name="admin_password" required
                                       class="block w-full pl-10 pr-3 py-3 border border-gray-300 rounded-lg focus:outline-none focus:ring-2 focus:ring-emerald-500 focus:border-transparent"
                                       placeholder="Create a secure password">
                            </div>
                            <p class="mt-2 text-sm text-gray-500">Password should be at least 8 characters long</p>
                        </div>
                    </div>

                    <!-- Terms and Submit -->
                    <div class="space-y-6">
                        <div class="flex items-start">
                            <input type="checkbox" id="agree_terms" name="agree_terms" required
                                   class="mt-1 h-4 w-4 text-emerald-600 focus:ring-emerald-500 border-gray-300 rounded">
                            <label for="agree_terms" class="ml-3 text-sm text-gray-700">
                                I agree to the <a href="#" class="text-emerald-600 hover:text-emerald-700 font-medium">Terms of Service</a> 
                                and <a href="#" class="text-emerald-600 hover:text-emerald-700 font-medium">Privacy Policy</a>
                            </label>
                        </div>

                        <button type="submit" 
                                class="w-full bg-gradient-to-r from-emerald-600 to-blue-600 hover:from-emerald-700 hover:to-blue-700 text-white font-bold py-4 px-6 rounded-lg transition-all duration-200 shadow-lg hover:shadow-xl transform hover:-translate-y-1">
                            <i class="fas fa-rocket mr-2"></i>
                            Create Organization
                        </button>
                    </div>
                </form>
            </div>

            <!-- Footer -->
            <div class="text-center py-6">
                <p class="text-gray-600">Already have an organization? 
                    <a href="{{ url_for('admin_login') }}" class="text-emerald-600 hover:text-emerald-700 font-medium">Sign in here</a>
                </p>
            </div>
        </div>
    </div>
</body>
</html>