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
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
import gradio as gr
import time
import random
from typing import List, Dict, Any

def generate_website_code(description: str, complexity: str) -> Dict[str, str]:
    """
    Simulate AI website generation using Qwen models.
    In a real implementation, this would call the actual Qwen model.
    """
    start_time = time.time()
    
    # Simulate different website types based on description
    description_lower = description.lower()
    
    # Generate HTML, CSS, and JS based on the description
    if "portfolio" in description_lower or "personal" in description_lower:
        html_code = generate_portfolio_site(description)
    elif "business" in description_lower or "company" in description_lower:
        html_code = generate_business_site(description)
    elif "blog" in description_lower:
        html_code = generate_blog_site(description)
    elif "landing" in description_lower or "product" in description_lower:
        html_code = generate_landing_site(description)
    else:
        html_code = generate_simple_site(description)
    
    css_code = generate_css(complexity)
    js_code = generate_javascript(complexity)
    
    generation_time = time.time() - start_time
    
    return {
        "html": html_code,
        "css": css_code,
        "javascript": js_code,
        "generation_time": f"{generation_time:.2f}s",
        "status": "βœ… Website generated successfully!" if generation_time < 15 else "⚠️ Generation took longer than expected"
    }

def generate_simple_site(description: str) -> str:
    """Generate a simple website template"""
    return f'''<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Generated Website</title>
    <link rel="stylesheet" href="style.css">
</head>
<body>
    <header>
        <nav>
            <div class="logo">My Website</div>
            <ul class="nav-links">
                <li><a href="#home">Home</a></li>
                <li><a href="#about">About</a></li>
                <li><a href="#services">Services</a></li>
                <li><a href="#contact">Contact</a></li>
            </ul>
        </nav>
    </header>

    <main>
        <section id="hero" class="hero">
            <div class="hero-content">
                <h1>Welcome to Our Website</h1>
                <p>Generated based on: "{description}"</p>
                <button class="cta-button">Get Started</button>
            </div>
        </section>

        <section id="features" class="features">
            <div class="container">
                <h2>Features</h2>
                <div class="feature-grid">
                    <div class="feature-card">
                        <h3>Feature 1</h3>
                        <p>Amazing feature description</p>
                    </div>
                    <div class="feature-card">
                        <h3>Feature 2</h3>
                        <p>Another great feature</p>
                    </div>
                    <div class="feature-card">
                        <h3>Feature 3</h3>
                        <p>Third amazing feature</p>
                    </div>
                </div>
            </div>
        </section>
    </main>

    <footer>
        <p>&copy; 2024 Generated Website. All rights reserved.</p>
    </footer>
    <script src="script.js"></script>
</body>
</html>'''

def generate_portfolio_site(description: str) -> str:
    """Generate a portfolio website template"""
    return f'''<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Portfolio - Generated Website</title>
    <link rel="stylesheet" href="style.css">
</head>
<body>
    <header>
        <nav>
            <div class="logo">Portfolio</div>
            <ul class="nav-links">
                <li><a href="#home">Home</a></li>
                <li><a href="#about">About</a></li>
                <li><a href="#projects">Projects</a></li>
                <li><a href="#contact">Contact</a></li>
            </ul>
        </nav>
    </header>

    <main>
        <section id="hero" class="hero">
            <div class="hero-content">
                <h1>John Doe</h1>
                <p>Web Developer & Designer</p>
                <p class="description">Based on: "{description}"</p>
                <div class="hero-buttons">
                    <button class="cta-button">View My Work</button>
                    <button class="secondary-button">Contact Me</button>
                </div>
            </div>
        </section>

        <section id="projects" class="projects">
            <div class="container">
                <h2>My Projects</h2>
                <div class="project-grid">
                    <div class="project-card">
                        <h3>Project 1</h3>
                        <p>Amazing project description</p>
                        <a href="#" class="project-link">View Project</a>
                    </div>
                    <div class="project-card">
                        <h3>Project 2</h3>
                        <p>Another great project</p>
                        <a href="#" class="project-link">View Project</a>
                    </div>
                </div>
            </div>
        </section>
    </main>

    <footer>
        <p>&copy; 2024 Portfolio Website. Built with passion.</p>
    </footer>
    <script src="script.js"></script>
</body>
</html>'''

def generate_business_site(description: str) -> str:
    """Generate a business website template"""
    return f'''<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Business Website</title>
    <link rel="stylesheet" href="style.css">
</head>
<body>
    <header>
        <nav>
            <div class="logo">BusinessName</div>
            <ul class="nav-links">
                <li><a href="#home">Home</a></li>
                <li><a href="#services">Services</a></li>
                <li><a href="#about">About</a></li>
                <li><a href="#contact">Contact</a></li>
            </ul>
        </nav>
    </header>

    <main>
        <section id="hero" class="hero business-hero">
            <div class="hero-content">
                <h1>Professional Business Solutions</h1>
                <p>Generated for: "{description}"</p>
                <button class="cta-button">Get Quote</button>
            </div>
        </section>

        <section id="services" class="services">
            <div class="container">
                <h2>Our Services</h2>
                <div class="service-grid">
                    <div class="service-card">
                        <h3>Service 1</h3>
                        <p>Professional service description</p>
                    </div>
                    <div class="service-card">
                        <h3>Service 2</h3>
                        <p>Expert service offering</p>
                    </div>
                    <div class="service-card">
                        <h3>Service 3</h3>
                        <p>Quality service solution</p>
                    </div>
                </div>
            </div>
        </section>

        <section id="contact" class="contact">
            <div class="container">
                <h2>Contact Us</h2>
                <p>Ready to get started? Contact us today!</p>
                <button class="cta-button">Contact Now</button>
            </div>
        </section>
    </main>

    <footer>
        <p>&copy; 2024 Business Website. Professional solutions.</p>
    </footer>
    <script src="script.js"></script>
</body>
</html>'''

def generate_blog_site(description: str) -> str:
    """Generate a blog website template"""
    return f'''<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>My Blog</title>
    <link rel="stylesheet" href="style.css">
</head>
<body>
    <header>
        <nav>
            <div class="logo">MyBlog</div>
            <ul class="nav-links">
                <li><a href="#home">Home</a></li>
                <li><a href="#posts">Posts</a></li>
                <li><a href="#about">About</a></li>
                <li><a href="#contact">Contact</a></li>
            </ul>
        </nav>
    </header>

    <main>
        <section id="hero" class="hero">
            <div class="hero-content">
                <h1>Welcome to My Blog</h1>
                <p>Generated for: "{description}"</p>
                <p>Sharing thoughts, stories, and insights</p>
            </div>
        </section>

        <section id="posts" class="blog-posts">
            <div class="container">
                <h2>Latest Posts</h2>
                <div class="post-grid">
                    <article class="post-card">
                        <h3>Blog Post 1</h3>
                        <p class="post-excerpt">This is an excerpt from the first blog post...</p>
                        <a href="#" class="read-more">Read More</a>
                    </article>
                    <article class="post-card">
                        <h3>Blog Post 2</h3>
                        <p class="post-excerpt">This is an excerpt from the second blog post...</p>
                        <a href="#" class="read-more">Read More</a>
                    </article>
                    <article class="post-card">
                        <h3>Blog Post 3</h3>
                        <p class="post-excerpt">This is an excerpt from the third blog post...</p>
                        <a href="#" class="read-more">Read More</a>
                    </article>
                </div>
            </div>
        </section>
    </main>

    <footer>
        <p>&copy; 2024 My Blog. All rights reserved.</p>
    </footer>
    <script src="script.js"></script>
</body>
</html>'''

def generate_landing_site(description: str) -> str:
    """Generate a landing page template"""
    return f'''<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Product Landing Page</title>
    <link rel="stylesheet" href="style.css">
</head>
<body>
    <header>
        <nav>
            <div class="logo">ProductName</div>
            <ul class="nav-links">
                <li><a href="#features">Features</a></li>
                <li><a href="#pricing">Pricing</a></li>
                <li><a href="#contact">Contact</a></li>
            </ul>
        </nav>
    </header>

    <main>
        <section id="hero" class="hero landing-hero">
            <div class="hero-content">
                <h1>Amazing Product</h1>
                <p>Revolutionary solution for: "{description}"</p>
                <p>Transform your business today!</p>
                <div class="hero-buttons">
                    <button class="cta-button">Start Free Trial</button>
                    <button class="secondary-button">Watch Demo</button>
                </div>
            </div>
        </section>

        <section id="features" class="features">
            <div class="container">
                <h2>Key Features</h2>
                <div class="feature-grid">
                    <div class="feature-card">
                        <h3>πŸš€ Fast</h3>
                        <p>Lightning-fast performance</p>
                    </div>
                    <div class="feature-card">
                        <h3>πŸ”’ Secure</h3>
                        <p>Enterprise-grade security</p>
                    </div>
                    <div class="feature-card">
                        <h3>πŸ“± Responsive</h3>
                        <p>Works on all devices</p>
                    </div>
                </div>
            </div>
        </section>

        <section id="pricing" class="pricing">
            <div class="container">
                <h2>Simple Pricing</h2>
                <div class="pricing-grid">
                    <div class="pricing-card">
                        <h3>Starter</h3>
                        <div class="price">$9/month</div>
                        <ul>
                            <li>Basic features</li>
                            <li>Email support</li>
                        </ul>
                        <button class="cta-button">Get Started</button>
                    </div>
                    <div class="pricing-card featured">
                        <h3>Pro</h3>
                        <div class="price">$29/month</div>
                        <ul>
                            <li>All features</li>
                            <li>Priority support</li>
                            <li>Advanced analytics</li>
                        </ul>
                        <button class="cta-button">Get Started</button>
                    </div>
                </div>
            </div>
        </section>
    </main>

    <footer>
        <p>&copy; 2024 Product Landing Page. Built with passion.</p>
    </footer>
    <script src="script.js"></script>
</body>
</html>'''

def generate_css(complexity: str) -> str:
    """Generate CSS based on complexity level"""
    base_css = '''
/* Reset and base styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    line-height: 1.6;
    color: #333;
}

.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 20px;
}

/* Header styles */
header {
    background: #fff;
    box-shadow: 0 2px 10px rgba(0,0,0,0.1);
    position: fixed;
    width: 100%;
    top: 0;
    z-index: 1000;
}

nav {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem 2rem;
}

.logo {
    font-size: 1.5rem;
    font-weight: bold;
    color: #333;
}

.nav-links {
    display: flex;
    list-style: none;
    gap: 2rem;
}

.nav-links a {
    text-decoration: none;
    color: #333;
    font-weight: 500;
    transition: color 0.3s;
}

.nav-links a:hover {
    color: #007bff;
}

/* Hero section */
.hero {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    text-align: center;
    padding: 150px 0 100px;
    margin-top: 80px;
}

.hero-content h1 {
    font-size: 3rem;
    margin-bottom: 1rem;
    font-weight: 700;
}

.hero-content p {
    font-size: 1.2rem;
    margin-bottom: 2rem;
    opacity: 0.9;
}

.hero-buttons {
    display: flex;
    gap: 1rem;
    justify-content: center;
    flex-wrap: wrap;
}

.cta-button {
    background: #007bff;
    color: white;
    border: none;
    padding: 12px 30px;
    border-radius: 5px;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s;
    text-decoration: none;
    display: inline-block;
}

.cta-button:hover {
    background: #0056b3;
    transform: translateY(-2px);
}

.secondary-button {
    background: transparent;
    color: white;
    border: 2px solid white;
    padding: 10px 28px;
    border-radius: 5px;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s;
    text-decoration: none;
    display: inline-block;
}

.secondary-button:hover {
    background: white;
    color: #333;
}

/* Features section */
.features {
    padding: 80px 0;
    background: #f8f9fa;
}

.features h2 {
    text-align: center;
    font-size: 2.5rem;
    margin-bottom: 3rem;
    color: #333;
}

.feature-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 2rem;
    margin-top: 3rem;
}

.feature-card {
    background: white;
    padding: 2rem;
    border-radius: 10px;
    text-align: center;
    box-shadow: 0 5px 15px rgba(0,0,0,0.08);
    transition: transform 0.3s;
}

.feature-card:hover {
    transform: translateY(-5px);
}

.feature-card h3 {
    font-size: 1.5rem;
    margin-bottom: 1rem;
    color: #333;
}

.feature-card p {
    color: #666;
    line-height: 1.6;
}

/* Additional styles for other sections */
.projects, .services, .blog-posts {
    padding: 80px 0;
}

.projects h2, .services h2, .blog-posts h2 {
    text-align: center;
    font-size: 2.5rem;
    margin-bottom: 3rem;
    color: #333;
}

.project-grid, .service-grid, .post-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 2rem;
}

.project-card, .service-card, .post-card {
    background: white;
    padding: 2rem;
    border-radius: 10px;
    box-shadow: 0 5px 15px rgba(0,0,0,0.08);
    transition: transform 0.3s;
}

.project-card:hover, .service-card:hover, .post-card:hover {
    transform: translateY(-5px);
}

.project-link, .read-more {
    color: #007bff;
    text-decoration: none;
    font-weight: 600;
}

.project-link:hover, .read-more:hover {
    text-decoration: underline;
}

/* Pricing section */
.pricing {
    padding: 80px 0;
    background: #f8f9fa;
}

.pricing h2 {
    text-align: center;
    font-size: 2.5rem;
    margin-bottom: 3rem;
    color: #333;
}

.pricing-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 2rem;
    max-width: 800px;
    margin: 0 auto;
}

.pricing-card {
    background: white;
    padding: 2rem;
    border-radius: 10px;
    text-align: center;
    box-shadow: 0 5px 15px rgba(0,0,0,0.08);
}

.pricing-card.featured {
    border: 2px solid #007bff;
    transform: scale(1.05);
}

.price {
    font-size: 2rem;
    font-weight: bold;
    color: #007bff;
    margin: 1rem 0;
}

.pricing-card ul {
    list-style: none;
    margin: 2rem 0;
}

.pricing-card li {
    padding: 0.5rem 0;
    border-bottom: 1px solid #eee;
}

/* Footer */
footer {
    background: #333;
    color: white;
    text-align: center;
    padding: 2rem 0;
}

/* Responsive design */
@media (max-width: 768px) {
    .nav-links {
        display: none;
    }
    
    .hero-content h1 {
        font-size: 2rem;
    }
    
    .hero-content p {
        font-size: 1rem;
    }
    
    .hero-buttons {
        flex-direction: column;
        align-items: center;
    }
    
    .feature-grid, .project-grid, .service-grid, .post-grid {
        grid-template-columns: 1fr;
    }
}
'''
    
    if complexity == "Advanced":
        base_css += '''
/* Advanced styling additions */
.business-hero {
    background: linear-gradient(135deg, #2c3e50 0%, #34495e 100%);
}

.landing-hero {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
}

.hero {
    position: relative;
    overflow: hidden;
}

.hero::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0,0,0,0.3);
    z-index: 1;
}

.hero-content {
    position: relative;
    z-index: 2;
}

.feature-card h3 {
    font-size: 2rem;
    margin-bottom: 1rem;
}

.feature-card:nth-child(1) h3 { color: #e74c3c; }
.feature-card:nth-child(2) h3 { color: #3498db; }
.feature-card:nth-child(3) h3 { color: #2ecc71; }

.post-excerpt {
    color: #666;
    margin-bottom: 1rem;
    line-height: 1.6;
}

/* Smooth scrolling */
html {
    scroll-behavior: smooth;
}

/* Loading animations */
@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(30px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.feature-card, .project-card, .service-card, .post-card {
    animation: fadeInUp 0.6s ease-out;
}
'''
    
    return base_css

def generate_javascript(complexity: str) -> str:
    """Generate JavaScript based on complexity level"""
    base_js = '''
// Basic functionality
document.addEventListener('DOMContentLoaded', function() {
    // Smooth scrolling for navigation links
    const navLinks = document.querySelectorAll('.nav-links a');
    navLinks.forEach(link => {
        link.addEventListener('click', function(e) {
            e.preventDefault();
            const targetId = this.getAttribute('href').substring(1);
            const targetSection = document.getElementById(targetId);
            
            if (targetSection) {
                const headerHeight = document.querySelector('header').offsetHeight;
                const targetPosition = targetSection.offsetTop - headerHeight;
                
                window.scrollTo({
                    top: targetPosition,
                    behavior: 'smooth'
                });
            }
        });
    });

    // CTA button functionality
    const ctaButtons = document.querySelectorAll('.cta-button');
    ctaButtons.forEach(button => {
        button.addEventListener('click', function() {
            // Simulate action (e.g., redirect to contact form)
            alert('Thank you for your interest! This would typically redirect to a contact form or signup page.');
        });
    });

    // Secondary button functionality
    const secondaryButtons = document.querySelectorAll('.secondary-button');
    secondaryButtons.forEach(button => {
        button.addEventListener('click', function() {
            // Simulate demo action
            alert('Demo video would start here!');
        });
    });

    // Add loading animation to cards
    const cards = document.querySelectorAll('.feature-card, .project-card, .service-card, .post-card');
    const observer = new IntersectionObserver((entries) => {
        entries.forEach(entry => {
            if (entry.isIntersecting) {
                entry.target.style.opacity = '1';
                entry.target.style.transform = 'translateY(0)';
            }
        });
    });

    cards.forEach(card => {
        card.style.opacity = '0';
        card.style.transform = 'translateY(30px)';
        card.style.transition = 'opacity 0.6s ease, transform 0.6s ease';
        observer.observe(card);
    });

    // Mobile menu toggle (if needed)
    const mobileMenuToggle = document.querySelector('.mobile-menu-toggle');
    const navLinks = document.querySelector('.nav-links');
    
    if (mobileMenuToggle) {
        mobileMenuToggle.addEventListener('click', function() {
            navLinks.classList.toggle('active');
        });
    }
});
'''
    
    if complexity == "Advanced":
        base_js += '''

// Advanced functionality
// Parallax effect for hero section
window.addEventListener('scroll', function() {
    const scrolled = window.pageYOffset;
    const hero = document.querySelector('.hero');
    if (hero) {
        hero.style.transform = `translateY(${scrolled * 0.5}px)`;
    }
});

// Add dynamic typing effect to hero text
function typeWriter(element, text, speed = 50) {
    let i = 0;
    element.innerHTML = '';
    
    function type() {
        if (i < text.length) {
            element.innerHTML += text.charAt(i);
            i++;
            setTimeout(type, speed);
        }
    }
    type();
}

// Initialize typing effect for main heading
const heroHeading = document.querySelector('.hero-content h1');
if (heroHeading) {
    const originalText = heroHeading.textContent;
    setTimeout(() => {
        typeWriter(heroHeading, originalText, 100);
    }, 500);
}

// Add hover effects to cards
cards.forEach(card => {
    card.addEventListener('mouseenter', function() {
        this.style.transform = 'translateY(-10px) scale(1.02)';
        this.style.boxShadow = '0 20px 40px rgba(0,0,0,0.15)';
    });
    
    card.addEventListener('mouseleave', function() {
        this.style.transform = 'translateY(-5px) scale(1)';
        this.style.boxShadow = '0 5px 15px rgba(0,0,0,0.08)';
    });
});

// Add counter animation for pricing
function animateCounter(element, target, duration = 2000) {
    let start = 0;
    const increment = target / (duration / 16);
    
    function updateCounter() {
        start += increment;
        if (start < target) {
            element.textContent = Math.floor(start);
            requestAnimationFrame(updateCounter);
        } else {
            element.textContent = target;
        }
    }
    updateCounter();
}

// Animate price counters when they come into view
const priceElements = document.querySelectorAll('.price');
const priceObserver = new IntersectionObserver((entries) => {
    entries.forEach(entry => {
        if (entry.isIntersecting) {
            const priceText = entry.target.textContent;
            const priceNumber = parseInt(priceText.replace(/[^0-9]/g, ''));
            animateCounter(entry.target, priceNumber);
            priceObserver.unobserve(entry.target);
        }
    });
});

priceElements.forEach(price => {
    priceObserver.observe(price);
});
'''
    
    return base_js

# Custom theme for modern look
custom_theme = gr.themes.Soft(
    primary_hue="blue",
    secondary_hue="indigo",
    neutral_hue="slate",
    font=gr.themes.GoogleFont("Inter"),
    text_size="lg",
    spacing_size="lg",
    radius_size="md"
).set(
    button_primary_background_fill="*primary_600",
    button_primary_background_fill_hover="*primary_700",
    block_title_text_weight="600",
)

with gr.Blocks(title="AI Web Coder - Qwen Powered", theme=custom_theme) as demo:
    
    # Header with attribution
    gr.HTML("""
    <div style="text-align: center; margin-bottom: 20px; padding: 10px; background: linear-gradient(135deg, #667eea 0%, #764ba2 100%); color: white; border-radius: 10px;">
        <h1 style="margin: 0; font-size: 2.5rem;">πŸš€ AI Web Coder</h1>
        <p style="margin: 5px 0 0 0; font-size: 1.1rem;">Powered by Qwen Small Models - Generate websites in under 15 seconds!</p>
        <p style="margin: 10px 0 0 0; font-size: 0.9rem; opacity: 0.9;">
            <a href="https://huggingface.co/spaces/akhaliq/anycoder" style="color: white; text-decoration: underline;">Built with anycoder</a>
        </p>
    </div>
    """)
    
    with gr.Row():
        with gr.Column(scale=1):
            gr.Markdown("### 🎯 Describe Your Website")
            
            description = gr.Textbox(
                label="What kind of website do you want?",
                placeholder="e.g., 'A personal portfolio for a web developer', 'A business landing page for a coffee shop', 'A blog about travel'",
                lines=3,
                info="Describe your website idea - the AI will generate appropriate code based on your description"
            )
            
            complexity = gr.Radio(
                choices=["Basic", "Advanced"],
                value="Basic",
                label="Complexity Level",
                info="Basic: Clean, responsive design | Advanced: Enhanced animations and effects"
            )
            
            generate_btn = gr.Button("πŸš€ Generate Website", variant="primary", size="lg")
            
            gr.Markdown("""
            ### πŸ’‘ Tips for Better Results
            - Be specific about the purpose (portfolio, business, blog, etc.)
            - Mention target audience or industry
            - Include key features you want
            - Specify style preferences (modern, minimal, etc.)
            """)
        
        with gr.Column(scale=2):
            gr.Markdown("### πŸ“„ Generated Code")
            
            with gr.Tab("HTML"):
                html_output = gr.Code(label="HTML Code", language="html", lines=20)
            
            with gr.Tab("CSS"):
                css_output = gr.Code(label="CSS Code", language="css", lines=20)
            
            with gr.Tab("JavaScript"):
                js_output = gr.Code(label="JavaScript Code", language="javascript", lines=15)
            
            with gr.Row():
                generation_info = gr.Markdown("ℹ️ Click 'Generate Website' to start")
                download_btn = gr.Button("πŸ’Ύ Download All Files", variant="secondary")
    
    # Generation function
    def handle_generation(desc, comp_level):
        if not desc.strip():
            gr.Warning("Please describe your website idea!")
            return "", "", "", "⚠️ Please provide a description"
        
        try:
            result = generate_website_code(desc, comp_level)
            return (
                result["html"],
                result["css"], 
                result["javascript"],
                f"βœ… {result['status']}\n\nπŸ•’ Generation time: {result['generation_time']}\nπŸ“ Complexity: {comp_level}"
            )
        except Exception as e:
            return "", "", "", f"❌ Error: {str(e)}"
    
    # Event handlers
    generate_btn.click(
        fn=handle_generation,
        inputs=[description, complexity],
        outputs=[html_output, css_output, js_output, generation_info],
        api_visibility="public",
        show_progress="full"
    )
    
    # Download functionality (placeholder)
    def download_files(html_code, css_code, js_code):
        if not html_code:
            gr.Warning("Please generate a website first!")
            return
        
        # In a real implementation, this would create downloadable files
        return "Files would be downloaded here. In a real app, this would package the HTML, CSS, and JS into a zip file."
    
    download_btn.click(
        fn=download_files,
        inputs=[html_output, css_output, js_output],
        outputs=[generation_info],
        api_visibility="private"
    )
    
    # Examples section
    gr.Markdown("### 🎨 Example Prompts")
    
    with gr.Row():
        gr.Examples(
            examples=[
                "A personal portfolio for a web developer with projects section",
                "A modern coffee shop website with menu and contact info", 
                "A tech startup landing page with pricing and features",
                "A travel blog with photo galleries and travel tips",
                "A restaurant website with online reservations",
                "A fitness trainer website with services and testimonials"
            ],
            inputs=description,
            examples_per_page=3
        )

# Launch the application
demo.launch(
    theme=custom_theme,
    share=True,
    show_error=True,
    height=600,
    footer_links=[
        {"label": "Built with anycoder", "url": "https://huggingface.co/spaces/akhaliq/anycoder"},
        {"label": "Powered by Qwen", "url": "https://huggingface.co/Qwen"}
    ]
)