#!/bin/bash
# Run this on your VPS to deploy StartupLX contact page

set -e

echo "Starting StartupLX deployment..."

# Create website directory
mkdir -p /var/www/startuplx/website/public

# Create minimal Astro-like contact page
cat > /var/www/startuplx/website/public/index.html << 'HTMLEOF'
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>StartupLX - Build Systems That Run Without You</title>
    <script src="https://cdn.tailwindcss.com"></script>
    <style>
        body { font-family: system-ui, -apple-system, sans-serif; }
        .gradient-bg { background: linear-gradient(135deg, #6366f1 0%, #3b82f6 100%); }
    </style>
</head>
<body class="bg-slate-50">
    
    <!-- Contact Form Section -->
    <section class="min-h-screen flex items-center justify-center py-20">
        <div class="max-w-4xl mx-auto px-4">
            <div class="text-center mb-16">
                <h1 class="text-4xl md:text-5xl font-bold text-slate-900 mb-6">
                    Build Systems That Run Without You
                </h1>
                <p class="text-xl text-slate-600 mb-8">
                    Web Development • ERP Solutions • Business Automation
                </p>
                <a href="#contact" class="inline-block bg-blue-600 hover:bg-blue-700 text-white px-8 py-4 rounded-lg font-semibold transition-colors">
                    Book a Free 15-Min System Audit
                </a>
            </div>
            
            <div id="contact" class="bg-white rounded-2xl shadow-lg p-8 lg:p-12">
                <h2 class="text-2xl font-bold text-slate-900 mb-6">Get Your Free System Audit</h2>
                <form action="https://startuplx.typeform.com/to/main" method="POST" class="space-y-6">
                    <div class="grid md:grid-cols-2 gap-6">
                        <div>
                            <label class="block text-sm font-semibold text-slate-700 mb-2">Your Name *</label>
                            <input type="text" name="name" required class="w-full px-4 py-3 border border-slate-300 rounded-lg focus:ring-2 focus:ring-blue-500">
                        </div>
                        <div>
                            <label class="block text-sm font-semibold text-slate-700 mb-2">Your Email *</label>
                            <input type="email" name="email" required class="w-full px-4 py-3 border border-slate-300 rounded-lg focus:ring-2 focus:ring-blue-500">
                        </div>
                    </div>
                    <div>
                        <label class="block text-sm font-semibold text-slate-700 mb-2">Company</label>
                        <input type="text" name="company" class="w-full px-4 py-3 border border-slate-300 rounded-lg focus:ring-2 focus:ring-blue-500">
                    </div>
                    <div>
                        <label class="block text-sm font-semibold text-slate-700 mb-2">What can we help with? *</label>
                        <textarea name="details" rows="4" required placeholder="Tell us about your project..." class="w-full px-4 py-3 border border-slate-300 rounded-lg focus:ring-2 focus:ring-blue-500"></textarea>
                    </div>
                    <button type="submit" class="w-full md:w-auto bg-blue-600 hover:bg-blue-700 text-white px-8 py-4 rounded-lg font-semibold transition-colors">
                        Schedule Free Audit →
                    </button>
                </form>
                
                <div class="mt-8 pt-8 border-t border-slate-200 text-center text-slate-500">
                    <p class="text-sm">Your information is private. Book a 15-minute call to identify revenue opportunities.</p>
                </div>
            </div>
        </div>
    </section>
</body>
</html>
HTMLEOF

# Create simple nginx config
cat > /var/www/startuplx/nginx-site.conf << 'NGINXEOF'
server {
    listen 80;
    server_name _;
    
    root /var/www/startuplx/website/public;
    index index.html;
    
    location / {
        try_files $uri $uri/ =404;
    }
    
    # Health check endpoint
    location /health {
        return 200 'OK';
        add_header Content-Type text/plain;
    }
}
NGINXEOF

echo ""
echo "Deployment files created!"
echo ""
echo "Next steps:"
echo "1. Copy nginx-site.conf to /etc/nginx/sites-available/ and enable it"
echo "2. Restart nginx: systemctl restart nginx"
echo "3. Visit http://localhost or your domain"
echo ""
echo "Or for full Docker deployment:"
echo "cd /var/www/startuplx"
echo "docker-compose up -d"