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6
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
import random
from transformers import pipeline
import re

# Initialize the text generation pipeline
try:
    generator = pipeline('text-generation', model='gpt2')
except Exception as e:
    # Fallback for environments where Hugging Face models might not be available
    print("Warning: Using mock generator as fallback. Install transformers for full functionality.")
    class MockGenerator:
        def __call__(self, prompt, max_length=100, num_return_sequences=1):
            return [{"generated_text": prompt + " (This is a mock generation)"}]
    generator = MockGenerator()

# Basic HTML templates
def get_base_template(title, content, theme="light"):
    """Basic HTML template with proper structure and responsive meta tags"""
    css_theme = get_theme_css(theme)

    return f"""<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>{title}</title>
    <style>
        /* Reset and base styles */
        * {{
            margin: 0;
            padding: 0;
            box-sizing: border-box;
        }}
        body {{
            font-family: 'Inter', system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, 'Open Sans', 'Helvetica Neue', sans-serif;
            line-height: 1.6;
        }}

        /* Theme styles */
        {css_theme}

        /* Responsive styles */
        .container {{
            width: 90%;
            max-width: 1200px;
            margin: 0 auto;
            padding: 0 20px;
        }}

        /* Navigation */
        header {{
            padding: 20px 0;
        }}
        .navbar {{
            display: flex;
            justify-content: space-between;
            align-items: center;
        }}
        .logo {{
            font-size: 1.5rem;
            font-weight: 700;
        }}
        .nav-links {{
            display: flex;
            gap: 20px;
        }}
        .nav-links a {{
            text-decoration: none;
            transition: opacity 0.2s;
        }}
        .nav-links a:hover {{
            opacity: 0.8;
        }}

        /* Responsive design */
        @media (max-width: 768px) {{
            .hero-content {{
                flex-direction: column;
            }}
            .hero-text, .hero-image {{
                width: 100%;
            }}
            .feature-grid {{
                grid-template-columns: 1fr;
            }}
            .nav-links {{
                display: none;
            }}
            .mobile-menu-btn {{
                display: block;
            }}
        }}
    </style>
</head>
<body>
    {content}
</body>
</html>"""

def get_theme_css(theme):
    """Generate CSS based on the selected theme"""
    themes = {
        "light": """
            body {
                background-color: #ffffff;
                color: #333333;
            }
            a {
                color: #3b82f6;
            }
            .btn-primary {
                background-color: #3b82f6;
                color: white;
                border: none;
                padding: 10px 20px;
                border-radius: 4px;
                cursor: pointer;
                transition: all 0.2s ease;
            }
            .btn-primary:hover {
                background-color: #2563eb;
            }
            .section {
                padding: 60px 0;
            }
            .hero {
                background-color: #f9fafb;
            }
            .card {
                background-color: #ffffff;
                border-radius: 8px;
                box-shadow: 0 4px 6px rgba(0,0,0,0.05);
            }
        """,
        "dark": """
            body {
                background-color: #121212;
                color: #e0e0e0;
            }
            a {
                color: #90caf9;
            }
            .btn-primary {
                background-color: #90caf9;
                color: #121212;
                border: none;
                padding: 10px 20px;
                border-radius: 4px;
                cursor: pointer;
                transition: all 0.2s ease;
            }
            .btn-primary:hover {
                background-color: #64b5f6;
            }
            .section {
                padding: 60px 0;
            }
            .hero {
                background-color: #1e1e1e;
            }
            .card {
                background-color: #1e1e1e;
                border-radius: 8px;
                box-shadow: 0 4px 6px rgba(0,0,0,0.2);
            }
        """,
        "colorful": """
            body {
                background-color: #ffffff;
                color: #333333;
            }
            a {
                color: #8b5cf6;
            }
            .btn-primary {
                background-color: #8b5cf6;
                color: white;
                border: none;
                padding: 10px 20px;
                border-radius: 4px;
                cursor: pointer;
                transition: all 0.3s ease;
            }
            .btn-primary:hover {
                background-color: #7c3aed;
                transform: translateY(-2px);
            }
            .section {
                padding: 60px 0;
            }
            .hero {
                background: linear-gradient(135deg, #c084fc, #8b5cf6);
                color: white;
            }
            .card {
                background-color: #ffffff;
                border-radius: 8px;
                box-shadow: 0 10px 15px rgba(0,0,0,0.1);
                border-top: 4px solid #8b5cf6;
                transition: transform 0.3s ease;
            }
            .card:hover {
                transform: translateY(-5px);
            }
            .accent {
                color: #f472b6;
            }
        """
    }
    return themes.get(theme.lower(), themes["light"])

# Website section templates
def generate_navbar(site_name, pages=None):
    """Generate a navigation bar for the website"""
    if pages is None:
        pages = ["Home", "Features", "Pricing", "Contact"]

    links = "".join([f'<a href="#{page.lower()}">{page}</a>' for page in pages])

    return f"""
    <header>
        <div class="container">
            <nav class="navbar">
                <div class="logo">{site_name}</div>
                <div class="nav-links">
                    {links}
                </div>
                <div class="mobile-menu-btn" style="display: none; cursor: pointer;">
                    <svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">
                        <line x1="3" y1="12" x2="21" y2="12"></line>
                        <line x1="3" y1="6" x2="21" y2="6"></line>
                        <line x1="3" y1="18" x2="21" y2="18"></line>
                    </svg>
                </div>
            </nav>
        </div>
    </header>
    """

def generate_hero_section(title, subtitle, cta="Get Started"):
    """Generate a hero section with a call to action"""
    return f"""
    <section class="hero" id="home">
        <div class="container">
            <div class="hero-content" style="display: flex; align-items: center; gap: 40px; padding: 60px 0;">
                <div class="hero-text" style="flex: 1;">
                    <h1 style="font-size: 3rem; font-weight: 800; margin-bottom: 20px;">{title}</h1>
                    <p style="font-size: 1.2rem; margin-bottom: 30px;">{subtitle}</p>
                    <a href="#contact" class="btn-primary" style="display: inline-block; text-decoration: none;">{cta}</a>
                </div>
                <div class="hero-image" style="flex: 1;">
                    <div style="background-color: #e5e7eb; height: 300px; border-radius: 8px; display: flex; align-items: center; justify-content: center;">
                        <span style="color: #9ca3af;">Hero Image Placeholder</span>
                    </div>
                </div>
            </div>
        </div>
    </section>
    """

def generate_features_section(features=None):
    """Generate a features section with cards"""
    if features is None:
        features = [
            {"title": "Feature 1", "description": "Description of feature 1 and its benefits."},
            {"title": "Feature 2", "description": "Description of feature 2 and its benefits."},
            {"title": "Feature 3", "description": "Description of feature 3 and its benefits."}
        ]

    feature_cards = ""
    for feature in features:
        feature_cards += f"""
        <div class="feature-card card" style="padding: 30px; margin-bottom: 20px;">
            <h3 style="font-size: 1.5rem; margin-bottom: 15px;">{feature['title']}</h3>
            <p>{feature['description']}</p>
        </div>
        """

    return f"""
    <section class="section" id="features">
        <div class="container">
            <h2 style="font-size: 2rem; text-align: center; margin-bottom: 40px;">Features</h2>
            <div class="feature-grid" style="display: grid; grid-template-columns: repeat(3, 1fr); gap: 30px;">
                {feature_cards}
            </div>
        </div>
    </section>
    """

def generate_pricing_section(plans=None):
    """Generate a pricing section with different plans"""
    if plans is None:
        plans = [
            {
                "name": "Basic",
                "price": "$9.99",
                "period": "month",
                "features": ["Feature 1", "Feature 2", "Email Support"],
                "highlighted": False
            },
            {
                "name": "Pro",
                "price": "$19.99",
                "period": "month",
                "features": ["All Basic features", "Feature 3", "Feature 4", "Priority Support"],
                "highlighted": True
            },
            {
                "name": "Enterprise",
                "price": "$49.99",
                "period": "month",
                "features": ["All Pro features", "Feature 5", "Feature 6", "24/7 Support", "Custom Integration"],
                "highlighted": False
            }
        ]

    pricing_cards = ""
    for plan in plans:
        highlight_style = "transform: scale(1.05);" if plan["highlighted"] else ""
        highlight_badge = '<div style="position: absolute; top: -10px; right: -10px; background-color: #f97316; color: white; padding: 5px 10px; border-radius: 20px; font-size: 0.8rem;">Popular</div>' if plan["highlighted"] else ""

        features_list = "".join([f'<li style="margin-bottom: 10px;">{feature}</li>' for feature in plan["features"]])

        pricing_cards += f"""
        <div class="pricing-card card" style="padding: 30px; position: relative; {highlight_style}">
            {highlight_badge}
            <h3 style="font-size: 1.5rem; margin-bottom: 10px;">{plan['name']}</h3>
            <div style="font-size: 2.5rem; font-weight: 700; margin-bottom: 20px;">
                {plan['price']}
                <span style="font-size: 1rem; font-weight: 400; color: #6b7280;">/{plan['period']}</span>
            </div>
            <ul style="list-style-type: none; margin-bottom: 30px;">
                {features_list}
            </ul>
            <a href="#contact" class="btn-primary" style="display: block; text-align: center; text-decoration: none;">Choose Plan</a>
        </div>
        """

    return f"""
    <section class="section" id="pricing" style="background-color: #f9fafb;">
        <div class="container">
            <h2 style="font-size: 2rem; text-align: center; margin-bottom: 20px;">Pricing</h2>
            <p style="text-align: center; margin-bottom: 40px; max-width: 600px; margin-left: auto; margin-right: auto;">Choose the perfect plan for your needs. All plans include our core features with different levels of support and additional functionalities.</p>
            <div class="pricing-grid" style="display: grid; grid-template-columns: repeat(3, 1fr); gap: 30px;">
                {pricing_cards}
            </div>
        </div>
    </section>
    """

def generate_testimonials_section(testimonials=None):
    """Generate a testimonials section"""
    if testimonials is None:
        testimonials = [
            {"name": "John Doe", "position": "CEO, Company A", "text": "This product has completely transformed how we operate our business. Highly recommended!"},
            {"name": "Jane Smith", "position": "Marketing Director, Company B", "text": "The features and ease of use have made this an essential tool in our daily operations."},
            {"name": "Mike Johnson", "position": "Freelancer", "text": "As someone who works independently, this tool has saved me countless hours of work."}
        ]

    testimonial_cards = ""
    for testimonial in testimonials:
        testimonial_cards += f"""
        <div class="testimonial-card card" style="padding: 30px; text-align: center;">
            <div style="font-size: 2rem; color: #d1d5db; margin-bottom: 20px;">"</div>
            <p style="margin-bottom: 20px;">{testimonial['text']}</p>
            <div style="font-weight: 600;">{testimonial['name']}</div>
            <div style="font-size: 0.9rem; color: #6b7280;">{testimonial['position']}</div>
        </div>
        """

    return f"""
    <section class="section" id="testimonials">
        <div class="container">
            <h2 style="font-size: 2rem; text-align: center; margin-bottom: 40px;">What Our Customers Say</h2>
            <div class="testimonials-grid" style="display: grid; grid-template-columns: repeat(3, 1fr); gap: 30px;">
                {testimonial_cards}
            </div>
        </div>
    </section>
    """

def generate_contact_section():
    """Generate a contact section with a form"""
    return f"""
    <section class="section" id="contact" style="background-color: #f9fafb;">
        <div class="container">
            <h2 style="font-size: 2rem; text-align: center; margin-bottom: 40px;">Contact Us</h2>
            <form style="max-width: 600px; margin: 0 auto; display: flex; flex-direction: column; gap: 20px;">
                <input type="text" placeholder="Your Name" style="padding: 10px; border: 1px solid #d1d5db; border-radius: 4px;">
                <input type="email" placeholder="Your Email" style="padding: 10px; border: 1px solid #d1d5db; border-radius: 4px;">
                <textarea placeholder="Your Message" style="padding: 10px; border: 1px solid #d1d5db; border-radius: 4px; height: 150px;"></textarea>
                <button type="submit" class="btn-primary" style="align-self: center;">Send Message</button>
            </form>
        </div>
    </section>
    """

def generate_website_html(title, sections):
    """
    Generate the complete HTML for a website.

    :param title: The title of the website.
    :param sections: A list of HTML sections to include in the body.
    :return: A complete HTML string.
    """
    content = "".join(sections)
    return get_base_template(title, content, theme="light")