File size: 64,582 Bytes
decfecc
 
 
 
 
7b894c1
decfecc
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
4a2d87a
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
7b894c1
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
4a2d87a
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
7b894c1
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
decfecc
 
 
 
 
 
 
 
 
 
7b894c1
decfecc
 
4a2d87a
 
 
 
7b894c1
 
 
 
 
 
 
 
decfecc
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
4a2d87a
 
 
decfecc
4a2d87a
 
 
 
 
 
 
7b894c1
 
4a2d87a
 
 
decfecc
4a2d87a
 
7b894c1
 
decfecc
 
4a2d87a
 
 
decfecc
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
7b894c1
 
 
 
 
 
 
 
 
 
 
decfecc
4a2d87a
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
7b894c1
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
decfecc
4a2d87a
 
 
 
 
 
decfecc
 
 
 
 
 
 
4a2d87a
decfecc
 
 
 
4a2d87a
 
 
 
 
 
decfecc
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
4a2d87a
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
7b894c1
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
decfecc
 
 
 
 
 
 
 
 
4a2d87a
 
7b894c1
 
 
decfecc
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
4a2d87a
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
7b894c1
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
4a2d87a
 
 
 
 
decfecc
 
 
 
 
4a2d87a
 
7b894c1
 
 
 
4a2d87a
decfecc
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
7b894c1
decfecc
 
 
 
 
 
 
4a2d87a
decfecc
 
4a2d87a
 
 
 
 
 
 
 
 
7b894c1
4a2d87a
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
7b894c1
 
 
 
 
 
 
 
 
 
 
 
 
 
 
4a2d87a
7b894c1
 
decfecc
 
4a2d87a
7b894c1
 
4a2d87a
7b894c1
 
4a2d87a
7b894c1
 
 
 
 
4a2d87a
 
7b894c1
 
4a2d87a
7b894c1
 
 
 
 
 
4a2d87a
 
7b894c1
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
decfecc
7b894c1
 
 
decfecc
 
 
7b894c1
 
 
 
 
 
 
 
 
decfecc
 
7b894c1
 
 
 
decfecc
 
 
7b894c1
 
 
 
decfecc
7b894c1
decfecc
7b894c1
 
decfecc
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
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
1362
1363
1364
1365
1366
1367
1368
1369
1370
1371
1372
1373
1374
1375
1376
1377
1378
1379
1380
1381
1382
1383
1384
1385
1386
1387
1388
1389
1390
1391
1392
1393
1394
1395
1396
1397
1398
1399
1400
1401
1402
1403
1404
1405
1406
1407
1408
1409
1410
1411
1412
1413
1414
1415
1416
1417
1418
1419
1420
1421
1422
1423
1424
1425
1426
1427
1428
1429
1430
1431
1432
1433
1434
1435
1436
1437
1438
1439
1440
1441
1442
1443
1444
1445
1446
1447
1448
1449
1450
1451
1452
1453
1454
1455
1456
1457
1458
1459
1460
1461
1462
1463
1464
1465
1466
1467
1468
1469
1470
1471
1472
1473
1474
1475
1476
1477
1478
1479
1480
1481
1482
1483
1484
1485
1486
1487
1488
1489
1490
1491
1492
1493
1494
1495
1496
1497
1498
1499
1500
1501
1502
1503
1504
1505
1506
1507
1508
1509
1510
1511
1512
1513
1514
1515
1516
1517
1518
1519
1520
1521
1522
1523
1524
1525
1526
1527
1528
1529
1530
1531
1532
1533
<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>DeepSeek Visual Builder with APWB & DeepCoder Integration</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">
  <style>
    @import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&display=swap');
    
    :root {
      --primary: #6366f1;
      --primary-dark: #4f46e5;
      --secondary: #f43f5e;
      --dark: #1e293b;
      --light: #f8fafc;
    }
    
    body {
      font-family: 'Inter', sans-serif;
      @apply bg-gray-50 text-gray-800;
    }
    
    .component {
      transition: all 0.2s ease;
      cursor: grab;
      @apply hover:shadow-md hover:border-primary/50;
    }
    
    .component:active {
      cursor: grabbing;
    }
    
    .droppable {
      min-height: calc(100vh - 180px);
      transition: background-color 0.3s;
      background-image: 
        linear-gradient(45deg, #f1f5f9 25%, transparent 25%),
        linear-gradient(-45deg, #f1f5f9 25%, transparent 25%),
        linear-gradient(45deg, transparent 75%, #f1f5f9 75%),
        linear-gradient(-45deg, transparent 75%, #f1f5f9 75%);
      background-size: 20px 20px;
      background-position: 0 0, 0 10px, 10px -10px, -10px 0px;
    }
    
    .droppable.highlight {
      @apply bg-primary/5 border-2 border-dashed border-primary;
      animation: pulse 1.5s infinite;
    }
    
    .canvas-component {
      @apply relative rounded-lg mb-4 overflow-hidden group transition-all duration-200;
      box-shadow: 0 1px 3px rgba(0,0,0,0.1);
    }
    
    .canvas-component:hover {
      @apply shadow-lg;
    }
    
    .canvas-component.selected {
      @apply ring-2 ring-primary ring-offset-2;
    }
    
    .component-toolbar {
      @apply absolute top-0 left-0 right-0 bg-gray-800 flex items-center justify-between px-2 h-8 opacity-0 group-hover:opacity-100 transition-opacity duration-200;
    }
    
    .component-handle {
      @apply text-white/80 hover:text-white cursor-move flex items-center;
    }
    
    .component-actions {
      @apply flex items-center space-x-2;
    }
    
    .component-action-btn {
      @apply text-white/60 hover:text-white p-1;
    }
    
    .properties-panel {
      scrollbar-width: thin;
      scrollbar-color: var(--primary) transparent;
    }
    
    .properties-panel::-webkit-scrollbar {
      width: 6px;
    }
    
    .properties-panel::-webkit-scrollbar-thumb {
      @apply bg-primary/30 rounded-full;
    }
    
    .properties-panel::-webkit-scrollbar-thumb:hover {
      @apply bg-primary/50;
    }
    
    @keyframes pulse {
      0%, 100% { background-color: rgba(99, 102, 241, 0.05); }
      50% { background-color: rgba(99, 102, 241, 0.1); }
    }
    
    .color-option {
      @apply w-6 h-6 rounded-full cursor-pointer border border-gray-200;
      transition: transform 0.2s;
    }
    
    .color-option:hover {
      transform: scale(1.1);
    }
    
    .color-option.selected {
      @apply ring-2 ring-offset-2 ring-gray-400;
      transform: scale(1.1);
    }
    
    .tab-btn {
      @apply px-4 py-2 font-medium text-sm rounded-md transition-colors;
    }
    
    .tab-btn.active {
      @apply bg-primary text-white;
    }
    
    .tab-btn:not(.active) {
      @apply text-gray-500 hover:text-gray-700 hover:bg-gray-100;
    }
    
    .preview-frame-container {
      background-image: 
        linear-gradient(45deg, #e2e8f0 25%, transparent 25%),
        linear-gradient(-45deg, #e2e8f0 25%, transparent 25%),
        linear-gradient(45deg, transparent 75%, #e2e8f0 75%),
        linear-gradient(-45deg, transparent 75%, #e2e8f0 75%);
      background-size: 20px 20px;
      background-position: 0 0, 0 10px, 10px -10px, -10px 0px;
    }
    
    .toast {
      @apply fixed bottom-4 right-4 px-4 py-2 rounded-md shadow-lg text-white font-medium flex items-center;
      background-color: var(--primary);
      animation: slideIn 0.3s, fadeOut 0.5s 2.5s forwards;
    }
    
    @keyframes slideIn {
      from { transform: translateY(20px); opacity: 0; }
      to { transform: translateY(0); opacity: 1; }
    }
    
    @keyframes fadeOut {
      to { opacity: 0; }
    }
    
    .resize-handle {
      @apply absolute right-0 bottom-0 w-3 h-3 bg-primary rounded-tl-md cursor-nwse-resize opacity-0 group-hover:opacity-100 transition-opacity;
    }
    
    .resize-handle:hover {
      @apply bg-primary-dark;
    }

    /* AI Prompt Modal Styles */
    .ai-modal {
      @apply fixed inset-0 bg-black/50 flex items-center justify-center z-50 p-4;
    }
    
    .ai-modal-content {
      @apply bg-white rounded-lg w-full max-w-2xl flex flex-col overflow-hidden shadow-xl;
    }
    
    .ai-modal-header {
      @apply p-4 border-b flex justify-between items-center bg-gray-50;
    }
    
    .ai-modal-body {
      @apply p-4 flex-1 overflow-auto;
    }
    
    .ai-modal-footer {
      @apply p-4 border-t flex justify-end space-x-3;
    }
    
    .ai-prompt-textarea {
      @apply w-full p-3 border rounded-md text-sm h-32 focus:ring-2 focus:ring-primary focus:border-transparent;
    }
    
    .ai-response {
      @apply mt-4 p-3 bg-gray-50 rounded-md text-sm whitespace-pre-wrap;
    }
    
    .ai-loading {
      @apply flex items-center justify-center py-4;
    }
    
    .ai-loading-spinner {
      @apply animate-spin h-5 w-5 text-primary;
    }
    
    .ai-generated-component {
      @apply border-l-4 border-primary pl-3 my-2;
    }
    
    /* APWB Integration Styles */
    .apwb-container {
      @apply border rounded-lg overflow-hidden;
    }
    
    .apwb-header {
      @apply bg-gray-100 p-3 border-b flex justify-between items-center;
    }
    
    .apwb-body {
      @apply p-4;
    }
    
    .apwb-input {
      @apply w-full p-2 border rounded-md text-sm mb-2;
    }
    
    .apwb-button {
      @apply bg-blue-500 hover:bg-blue-600 text-white px-3 py-1.5 rounded-md text-sm font-medium;
    }
    
    .apwb-response {
      @apply mt-4 p-3 bg-gray-50 rounded-md text-sm whitespace-pre-wrap;
    }
    
    /* DeepCoder AI Assistant Styles */
    .deepcoder-container {
      @apply border rounded-lg overflow-hidden;
    }
    
    .deepcoder-header {
      @apply bg-gray-100 p-3 border-b flex justify-between items-center;
    }
    
    .deepcoder-body {
      @apply p-4;
    }
    
    .deepcoder-input {
      @apply w-full p-2 border rounded-md text-sm mb-2;
    }
    
    .deepcoder-button {
      @apply bg-purple-600 hover:bg-purple-700 text-white px-3 py-1.5 rounded-md text-sm font-medium;
    }
    
    .deepcoder-response {
      @apply mt-4 p-3 bg-gray-50 rounded-md text-sm whitespace-pre-wrap;
    }
    
    .deepcoder-tabs {
      @apply flex border-b;
    }
    
    .deepcoder-tab {
      @apply px-4 py-2 text-sm font-medium cursor-pointer;
    }
    
    .deepcoder-tab.active {
      @apply border-b-2 border-purple-600 text-purple-600;
    }
    
    .deepcoder-code {
      @apply w-full h-64 p-2 border rounded-md text-sm font-mono;
    }
    
    .model-selector {
      @apply flex items-center space-x-2 bg-gray-100 rounded-md px-3 py-1.5;
    }
    
    .model-selector select {
      @apply bg-transparent border-none focus:ring-0 text-sm;
    }
    
    /* Split view layout */
    .split-container {
      @apply flex flex-1 overflow-hidden;
    }
    
    .split-panel {
      @apply flex-1 overflow-auto;
    }
    
    .split-divider {
      @apply w-1 bg-gray-200 cursor-col-resize;
    }
    
    /* Tabs */
    .tab-content {
      @apply hidden;
    }
    
    .tab-content.active {
      @apply block;
    }
    
    /* Code editor styles */
    .code-editor {
      @apply border rounded-md overflow-hidden;
    }
    
    .code-toolbar {
      @apply bg-gray-100 p-2 flex justify-between items-center;
    }
    
    .code-area {
      @apply w-full h-64 p-3 font-mono text-sm bg-gray-900 text-gray-100;
    }
    
    /* Terminal styles */
    .terminal {
      @apply bg-gray-900 text-gray-100 font-mono text-sm p-3 rounded-b-md;
      height: 200px;
      overflow-y: auto;
    }
    
    .terminal-line {
      @apply mb-1;
    }
    
    .terminal-prompt {
      @apply text-green-400;
    }
    
    .terminal-command {
      @apply text-white;
    }
    
    .terminal-output {
      @apply text-gray-300;
    }

    /* Rosebud AI Styles */
    .rosebud-container {
      @apply border rounded-lg overflow-hidden;
    }
    
    .rosebud-header {
      @apply bg-gray-100 p-3 border-b flex justify-between items-center;
    }
    
    .rosebud-body {
      @apply p-4;
    }
    
    .rosebud-input {
      @apply w-full p-2 border rounded-md text-sm mb-2;
    }
    
    .rosebud-button {
      @apply bg-pink-600 hover:bg-pink-700 text-white px-3 py-1.5 rounded-md text-sm font-medium;
    }
    
    .rosebud-response {
      @apply mt-4 p-3 bg-gray-50 rounded-md text-sm whitespace-pre-wrap;
    }
    
    .rosebud-image-container {
      @apply grid grid-cols-2 gap-4 mt-4;
    }
    
    .rosebud-image {
      @apply rounded-lg border border-gray-200 cursor-pointer transition-all hover:shadow-md;
    }
    
    .rosebud-image.selected {
      @apply ring-2 ring-pink-500;
    }
    
    .rosebud-controls {
      @apply flex items-center space-x-2 mt-4;
    }
    
    .rosebud-control-btn {
      @apply bg-gray-200 hover:bg-gray-300 text-gray-700 px-3 py-1 rounded text-sm;
    }
    
    .rosebud-slider {
      @apply w-full;
    }
    
    .rosebud-edit-tools {
      @apply grid grid-cols-4 gap-2 mt-4;
    }
    
    .rosebud-tool-btn {
      @apply p-2 border rounded-md text-center cursor-pointer hover:bg-gray-100;
    }
    
    .rosebud-tool-btn.active {
      @apply bg-pink-100 border-pink-500;
    }
    
    /* Image Editor Styles */
    .image-editor-container {
      @apply relative overflow-hidden;
    }
    
    .image-editor-tools {
      @apply absolute top-0 left-0 right-0 bg-gray-800 text-white p-2 flex space-x-2;
    }
    
    .image-editor-tool {
      @apply p-1 rounded cursor-pointer hover:bg-gray-700;
    }
    
    .image-editor-canvas {
      @apply w-full h-full;
    }
    
    /* Style Transfer Styles */
    .style-transfer-container {
      @apply grid grid-cols-2 gap-4 mt-4;
    }
    
    .style-transfer-image {
      @apply rounded-lg border border-gray-200 cursor-pointer;
    }
    
    .style-transfer-btn {
      @apply bg-purple-600 hover:bg-purple-700 text-white px-3 py-1.5 rounded-md text-sm font-medium w-full mt-2;
    }
  </style>
</head>
<body class="h-screen flex flex-col overflow-hidden">
  <!-- Header -->
  <header class="bg-gradient-to-r from-primary to-primary-dark text-white shadow-md">
    <div class="container mx-auto flex justify-between items-center px-4 py-3">
      <div class="flex items-center space-x-2">
        <svg xmlns="http://www.w3.org/2000/svg" class="h-6 w-6" fill="none" viewBox="0 0 24 24" stroke="currentColor">
          <path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M9.75 17L9 20l-1 1h8l-1-1-.75-3M3 13h18M5 17h14a2 2 0 002-2V5a2 2 0 00-2-2H5a2 2 0 00-2 2v10a2 2 0 002 2z" />
        </svg>
        <h1 class="text-xl font-bold">DeepSeek + APWB + DeepCoder + Rosebud</h1>
      </div>
      <div class="flex items-center space-x-3">
        <button id="aiPromptBtn" class="flex items-center space-x-1 bg-white/10 hover:bg-white/20 px-3 py-1.5 rounded-md text-sm font-medium transition-colors">
          <i class="fas fa-robot"></i>
          <span>AI Builder</span>
        </button>
        <button id="deepcoderBtn" class="flex items-center space-x-1 bg-white/10 hover:bg-white/20 px-3 py-1.5 rounded-md text-sm font-medium transition-colors">
          <i class="fas fa-code"></i>
          <span>DeepCoder</span>
        </button>
        <button id="rosebudBtn" class="flex items-center space-x-1 bg-white/10 hover:bg-white/20 px-3 py-1.5 rounded-md text-sm font-medium transition-colors">
          <i class="fas fa-magic"></i>
          <span>Rosebud AI</span>
        </button>
        <button id="saveBtn" class="flex items-center space-x-1 bg-white/10 hover:bg-white/20 px-3 py-1.5 rounded-md text-sm font-medium transition-colors">
          <i class="fas fa-save"></i>
          <span>Save</span>
        </button>
        <button id="previewBtn" class="flex items-center space-x-1 bg-white/10 hover:bg-white/20 px-3 py-1.5 rounded-md text-sm font-medium transition-colors">
          <i class="fas fa-eye"></i>
          <span>Preview</span>
        </button>
        <button id="exportBtn" class="flex items-center space-x-1 bg-white/10 hover:bg-white/20 px-3 py-1.5 rounded-md text-sm font-medium transition-colors">
          <i class="fas fa-file-export"></i>
          <span>Export</span>
        </button>
      </div>
    </div>
  </header>

  <!-- Main Content -->
  <div class="split-container">
    <!-- Left Panel - Components & APWB Integration -->
    <div class="split-panel w-64 bg-white border-r border-gray-200 flex flex-col">
      <div class="p-3 border-b border-gray-200">
        <div class="flex items-center justify-between">
          <h2 class="text-lg font-semibold text-gray-800">Tools</h2>
          <div class="model-selector">
            <span>Model:</span>
            <select id="modelSelector">
              <option value="apwb">APWB</option>
              <option value="deepseek">DeepSeek</option>
              <option value="deepcoder">DeepCoder</option>
              <option value="rosebud">Rosebud</option>
            </select>
          </div>
        </div>
        <div class="mt-2 flex space-x-1">
          <button class="tab-btn active" data-tab="components">Components</button>
          <button class="tab-btn" data-tab="apwb">APWB</button>
          <button class="tab-btn" data-tab="deepcoder">DeepCoder</button>
          <button class="tab-btn" data-tab="rosebud">Rosebud</button>
        </div>
      </div>
      
      <!-- Components Tab -->
      <div id="componentsTab" class="tab-content active flex-1 overflow-y-auto p-3 space-y-3">
        <div class="component bg-white p-3 rounded-lg border border-gray-200 shadow-sm" draggable="true" data-type="header">
          <div class="flex items-center space-x-3">
            <div class="bg-primary/10 text-primary p-2 rounded-lg">
              <i class="fas fa-header"></i>
            </div>
            <div>
              <h3 class="font-medium text-sm">Header</h3>
              <p class="text-xs text-gray-500">Navigation with logo</p>
            </div>
          </div>
        </div>
        <div class="component bg-white p-3 rounded-lg border border-gray-200 shadow-sm" draggable="true" data-type="hero">
          <div class="flex items-center space-x-3">
            <div class="bg-blue-100 text-blue-500 p-2 rounded-lg">
              <i class="fas fa-star"></i>
            </div>
            <div>
              <h3 class="font-medium text-sm">Hero Section</h3>
              <p class="text-xs text-gray-500">Banner with CTA</p>
            </div>
          </div>
        </div>
        <div class="component bg-white p-3 rounded-lg border border-gray-200 shadow-sm" draggable="true" data-type="features">
          <div class="flex items-center space-x-3">
            <div class="bg-green-100 text-green-500 p-2 rounded-lg">
              <i class="fas fa-th-large"></i>
            </div>
            <div>
              <h3 class="font-medium text-sm">Features</h3>
              <p class="text-xs text-gray-500">Card grid layout</p>
            </div>
          </div>
        </div>
        <div class="component bg-white p-3 rounded-lg border border-gray-200 shadow-sm" draggable="true" data-type="text">
          <div class="flex items-center space-x-3">
            <div class="bg-purple-100 text-purple-500 p-2 rounded-lg">
              <i class="fas fa-align-left"></i>
            </div>
            <div>
              <h3 class="font-medium text-sm">Text Block</h3>
              <p class="text-xs text-gray-500">Rich text content</p>
            </div>
          </div>
        </div>
        <div class="component bg-white p-3 rounded-lg border border-gray-200 shadow-sm" draggable="true" data-type="image">
          <div class="flex items-center space-x-3">
            <div class="bg-yellow-100 text-yellow-500 p-2 rounded-lg">
              <i class="fas fa-image"></i>
            </div>
            <div>
              <h3 class="font-medium text-sm">Image</h3>
              <p class="text-xs text-gray-500">Single image</p>
            </div>
          </div>
        </div>
        <div class="component bg-white p-3 rounded-lg border border-gray-200 shadow-sm" draggable="true" data-type="cta">
          <div class="flex items-center space-x-3">
            <div class="bg-red-100 text-red-500 p-2 rounded-lg">
              <i class="fas fa-bullhorn"></i>
            </div>
            <div>
              <h3 class="font-medium text-sm">Call to Action</h3>
              <p class="text-xs text-gray-500">Button with text</p>
            </div>
          </div>
        </div>
        <div class="component bg-white p-3 rounded-lg border border-gray-200 shadow-sm" draggable="true" data-type="footer">
          <div class="flex items-center space-x-3">
            <div class="bg-gray-100 text-gray-500 p-2 rounded-lg">
              <i class="fas fa-window-minimize"></i>
            </div>
            <div>
              <h3 class="font-medium text-sm">Footer</h3>
              <p class="text-xs text-gray-500">Page footer</p>
            </div>
          </div>
        </div>
        <div class="component bg-white p-3 rounded-lg border border-gray-200 shadow-sm" draggable="true" data-type="ai-image">
          <div class="flex items-center space-x-3">
            <div class="bg-pink-100 text-pink-500 p-2 rounded-lg">
              <i class="fas fa-magic"></i>
            </div>
            <div>
              <h3 class="font-medium text-sm">AI Image</h3>
              <p class="text-xs text-gray-500">Generated with Rosebud</p>
            </div>
          </div>
        </div>
      </div>
      
      <!-- APWB Tab -->
      <div id="apwbTab" class="tab-content flex-1 overflow-y-auto p-3">
        <div class="apwb-container">
          <div class="apwb-header">
            <h3 class="text-sm font-medium">APWB AI Assistant</h3>
            <i class="fas fa-info-circle text-gray-500"></i>
          </div>
          <div class="apwb-body">
            <textarea id="apwbPrompt" class="apwb-input" placeholder="Describe what you want to create..."></textarea>
            <button id="apwbSubmit" class="apwb-button w-full">
              <i class="fas fa-paper-plane mr-1"></i> Generate
            </button>
            <div id="apwbResponse" class="apwb-response hidden"></div>
            <div id="apwbLoading" class="ai-loading hidden">
              <i class="ai-loading-spinner fas fa-spinner"></i>
              <span class="ml-2">Generating with APWB...</span>
            </div>
          </div>
        </div>
      </div>
      
      <!-- DeepCoder Tab -->
      <div id="deepcoderTab" class="tab-content flex-1 overflow-y-auto p-3">
        <div class="deepcoder-container">
          <div class="deepcoder-header">
            <h3 class="text-sm font-medium">DeepCoder AI Assistant</h3>
            <i class="fas fa-info-circle text-gray-500"></i>
          </div>
          <div class="deepcoder-body">
            <textarea id="deepcoderPrompt" class="deepcoder-input" placeholder="Describe the code you want to generate..."></textarea>
            <button id="deepcoderSubmit" class="deepcoder-button w-full">
              <i class="fas fa-code mr-1"></i> Generate Code
            </button>
            <div id="deepcoderResponse" class="deepcoder-response hidden"></div>
            <div id="deepcoderLoading" class="ai-loading hidden">
              <i class="ai-loading-spinner fas fa-spinner"></i>
              <span class="ml-2">Generating with DeepCoder...</span>
            </div>
          </div>
        </div>
      </div>
      
      <!-- Rosebud Tab -->
      <div id="rosebudTab" class="tab-content flex-1 overflow-y-auto p-3">
        <div class="rosebud-container">
          <div class="rosebud-header">
            <h3 class="text-sm font-medium">Rosebud AI</h3>
            <i class="fas fa-info-circle text-gray-500"></i>
          </div>
          <div class="rosebud-body">
            <textarea id="rosebudPrompt" class="rosebud-input" placeholder="Describe the image you want to generate..."></textarea>
            <div class="flex items-center space-x-2">
              <select id="rosebudStyle" class="rosebud-input flex-1">
                <option value="realistic">Realistic</option>
                <option value="cartoon">Cartoon</option>
                <option value="anime">Anime</option>
                <option value="fantasy">Fantasy</option>
                <option value="watercolor">Watercolor</option>
              </select>
              <select id="rosebudRatio" class="rosebud-input flex-1">
                <option value="1:1">Square (1:1)</option>
                <option value="4:3">Standard (4:3)</option>
                <option value="16:9">Widescreen (16:9)</option>
                <option value="9:16">Portrait (9:16)</option>
              </select>
            </div>
            <button id="rosebudSubmit" class="rosebud-button w-full mt-2">
              <i class="fas fa-magic mr-1"></i> Generate Image
            </button>
            <div id="rosebudResponse" class="rosebud-response hidden"></div>
            <div id="rosebudLoading" class="ai-loading hidden">
              <i class="ai-loading-spinner fas fa-spinner"></i>
              <span class="ml-2">Generating with Rosebud...</span>
            </div>
            <div id="rosebudImages" class="rosebud-image-container hidden"></div>
            <div id="rosebudEditControls" class="rosebud-controls hidden">
              <button id="rosebudEditBtn" class="rosebud-control-btn">
                <i class="fas fa-edit mr-1"></i> Edit
              </button>
              <button id="rosebudDownloadBtn" class="rosebud-control-btn">
                <i class="fas fa-download mr-1"></i> Download
              </button>
              <button id="rosebudAddToCanvasBtn" class="rosebud-control-btn">
                <i class="fas fa-plus mr-1"></i> Add to Canvas
              </button>
            </div>
          </div>
        </div>
      </div>
    </div>
    
    <!-- Divider -->
    <div class="split-divider"></div>
    
    <!-- Center Panel - Canvas -->
    <div class="split-panel bg-gray-100 overflow-auto p-6">
      <div id="canvas" class="droppable bg-white mx-auto w-full max-w-4xl min-h-full rounded-lg shadow-sm relative">
        <div class="absolute inset-0 flex items-center justify-center" id="emptyState">
          <div class="text-center p-6 max-w-md">
            <div class="bg-gray-100 w-16 h-16 rounded-full flex items-center justify-center mx-auto mb-4">
              <i class="fas fa-plus text-gray-400 text-2xl"></i>
            </div>
            <h3 class="text-lg font-medium text-gray-700 mb-1">Drag components here</h3>
            <p class="text-gray-500 text-sm">Start building your page by dragging components or using the AI tools</p>
          </div>
        </div>
      </div>
    </div>
    
    <!-- Divider -->
    <div class="split-divider"></div>
    
    <!-- Right Panel - Properties -->
    <div class="split-panel w-72 bg-white border-l border-gray-200 flex flex-col">
      <div class="p-3 border-b border-gray-200">
        <h2 class="text-lg font-semibold text-gray-800">Properties</h2>
      </div>
      <div id="propertiesPanel" class="flex-1 overflow-y-auto properties-panel p-4">
        <div class="text-center text-gray-500 py-10">
          <i class="fas fa-mouse-pointer text-3xl mb-3 text-gray-300"></i>
          <p>Select a component to edit its properties</p>
        </div>
      </div>
    </div>
  </div>

  <!-- Preview Modal -->
  <div id="previewModal" class="fixed inset-0 bg-black/50 hidden items-center justify-center z-50 p-4">
    <div class="bg-white rounded-lg w-full max-w-6xl h-[90vh] flex flex-col overflow-hidden shadow-xl">
      <div class="p-4 border-b flex justify-between items-center bg-gray-50">
        <h3 class="text-lg font-semibold">Live Preview</h3>
        <div class="flex items-center space-x-3">
          <div class="flex items-center space-x-1 text-sm bg-gray-100 rounded-md px-2 py-1">
            <span>Device:</span>
            <select id="deviceSelector" class="bg-transparent border-none focus:ring-0 text-sm">
              <option value="desktop">Desktop</option>
              <option value="tablet">Tablet</option>
              <option value="mobile">Mobile</option>
            </select>
          </div>
          <button id="closePreview" class="text-gray-500 hover:text-gray-700">
            <i class="fas fa-times"></i>
          </button>
        </div>
      </div>
      <div class="flex-1 overflow-hidden p-4 bg-gray-100 flex items-center justify-center">
        <div id="previewContainer" class="w-full h-full preview-frame-container rounded overflow-hidden">
          <iframe id="previewFrame" class="w-full h-full bg-white border-none"></iframe>
        </div>
      </div>
    </div>
  </div>

  <!-- Export Modal -->
  <div id="exportModal" class="fixed inset-0 bg-black/50 hidden items-center justify-center z-50 p-4">
    <div class="bg-white rounded-lg w-full max-w-2xl flex flex-col overflow-hidden shadow-xl">
      <div class="p-4 border-b flex justify-between items-center bg-gray-50">
        <h3 class="text-lg font-semibold">Export HTML</h3>
        <button id="closeExport" class="text-gray-500 hover:text-gray-700">
          <i class="fas fa-times"></i>
        </button>
      </div>
      <div class="p-4 flex-1 overflow-auto">
        <div class="flex space-x-2 mb-4">
          <button id="copyCodeBtn" class="bg-primary hover:bg-primary-dark text-white px-3 py-1.5 rounded-md text-sm font-medium">
            <i class="fas fa-copy mr-1"></i> Copy Code
          </button>
          <button id="downloadBtn" class="bg-gray-200 hover:bg-gray-300 text-gray-700 px-3 py-1.5 rounded-md text-sm font-medium">
            <i class="fas fa-download mr-1"></i> Download
          </button>
        </div>
        <pre id="exportCode" class="bg-gray-100 p-3 rounded-md text-sm overflow-x-auto max-h-[60vh]"></pre>
      </div>
    </div>
  </div>

  <!-- AI Prompt Modal -->
  <div id="aiModal" class="ai-modal hidden">
    <div class="ai-modal-content">
      <div class="ai-modal-header">
        <h3 class="text-lg font-semibold">AI Builder</h3>
        <button id="closeAIModal" class="text-gray-500 hover:text-gray-700">
          <i class="fas fa-times"></i>
        </button>
      </div>
      <div class="ai-modal-body">
        <p class="text-sm text-gray-600 mb-3">Describe the component or page you want to create. The AI will generate it for you.</p>
        <textarea id="aiPrompt" class="ai-prompt-textarea" placeholder="Example: Create a hero section with a dark background, centered text, a headline, a subheadline, and a primary button that says 'Get Started'"></textarea>
        <div id="aiResponse" class="ai-response hidden"></div>
        <div id="aiLoading" class="ai-loading hidden">
          <i class="ai-loading-spinner fas fa-spinner"></i>
          <span class="ml-2">Generating your component...</span>
        </div>
        <div id="aiGeneratedComponents" class="mt-4 hidden">
          <h4 class="font-medium mb-2">Generated Components:</h4>
          <div id="aiComponentsList"></div>
        </div>
      </div>
      <div class="ai-modal-footer">
        <button id="cancelAIBtn" class="px-4 py-2 text-sm font-medium text-gray-700 bg-gray-200 rounded-md hover:bg-gray-300">
          Cancel
        </button>
        <button id="generateAIBtn" class="px-4 py-2 text-sm font-medium text-white bg-primary rounded-md hover:bg-primary-dark">
          Generate
        </button>
      </div>
    </div>
  </div>

  <!-- DeepCoder Modal -->
  <div id="deepcoderModal" class="fixed inset-0 bg-black/50 hidden items-center justify-center z-50 p-4">
    <div class="bg-white rounded-lg w-full max-w-4xl h-[80vh] flex flex-col overflow-hidden shadow-xl">
      <div class="p-4 border-b flex justify-between items-center bg-gray-50">
        <h3 class="text-lg font-semibold">DeepCoder AI Assistant</h3>
        <button id="closeDeepcoderModal" class="text-gray-500 hover:text-gray-700">
          <i class="fas fa-times"></i>
        </button>
      </div>
      <div class="flex-1 overflow-hidden flex flex-col">
        <div class="deepcoder-tabs">
          <div class="deepcoder-tab active" data-tab="code">Code Editor</div>
          <div class="deepcoder-tab" data-tab="terminal">Terminal</div>
        </div>
        <div class="flex-1 overflow-auto">
          <div id="deepcoderCodeTab" class="tab-content active h-full">
            <div class="code-editor h-full flex flex-col">
              <div class="code-toolbar">
                <div class="flex space-x-2">
                  <button id="runCodeBtn" class="bg-green-600 hover:bg-green-700 text-white px-3 py-1 rounded text-sm">
                    <i class="fas fa-play mr-1"></i> Run
                  </button>
                  <button id="clearCodeBtn" class="bg-gray-200 hover:bg-gray-300 text-gray-700 px-3 py-1 rounded text-sm">
                    <i class="fas fa-trash-alt mr-1"></i> Clear
                  </button>
                </div>
              </div>
              <textarea id="deepcoderCode" class="code-area flex-1" placeholder="Write your code here or generate it with AI..."></textarea>
            </div>
          </div>
          <div id="deepcoderTerminalTab" class="tab-content h-full">
            <div class="terminal">
              <div id="terminalContent">
                <div class="terminal-line">
                  <span class="terminal-prompt">$</span>
                  <span class="terminal-command">Welcome to DeepCoder Terminal</span>
                </div>
                <div class="terminal-line">
                  <span class="terminal-prompt">$</span>
                  <span class="terminal-command">Type 'help' for available commands</span>
                </div>
              </div>
              <div class="terminal-input flex items-center mt-2">
                <span class="terminal-prompt mr-2">$</span>
                <input type="text" id="terminalCommand" class="bg-transparent border-none text-white flex-1 focus:ring-0" placeholder="Enter command...">
              </div>
            </div>
          </div>
        </div>
      </div>
      <div class="p-4 border-t">
        <div class="flex items-center space-x-3">
          <textarea id="deepcoderAIPrompt" class="flex-1 p-2 border rounded-md text-sm" placeholder="Ask DeepCoder to generate or modify code..."></textarea>
          <button id="deepcoderAISubmit" class="bg-purple-600 hover:bg-purple-700 text-white px-4 py-2 rounded-md text-sm">
            <i class="fas fa-code mr-1"></i> Ask AI
          </button>
        </div>
        <div id="deepcoderAIResponse" class="deepcoder-response hidden mt-2"></div>
        <div id="deepcoderAILoading" class="ai-loading hidden">
          <i class="ai-loading-spinner fas fa-spinner"></i>
          <span class="ml-2">DeepCoder is thinking...</span>
        </div>
      </div>
    </div>
  </div>

  <!-- Rosebud AI Modal -->
  <div id="rosebudModal" class="fixed inset-0 bg-black/50 hidden items-center justify-center z-50 p-4">
    <div class="bg-white rounded-lg w-full max-w-4xl h-[90vh] flex flex-col overflow-hidden shadow-xl">
      <div class="p-4 border-b flex justify-between items-center bg-gray-50">
        <h3 class="text-lg font-semibold">Rosebud AI - Advanced Image Generation</h3>
        <button id="closeRosebudModal" class="text-gray-500 hover:text-gray-700">
          <i class="fas fa-times"></i>
        </button>
      </div>
      <div class="flex-1 overflow-hidden flex">
        <!-- Left Panel - Generation Controls -->
        <div class="w-1/3 border-r p-4 overflow-y-auto">
          <div class="mb-4">
            <label class="block text-sm font-medium text-gray-700 mb-1">Prompt</label>
            <textarea id="rosebudAdvancedPrompt" class="rosebud-input h-24" placeholder="Describe the image you want to generate..."></textarea>
          </div>
          
          <div class="grid grid-cols-2 gap-4 mb-4">
            <div>
              <label class="block text-sm font-medium text-gray-700 mb-1">Style</label>
              <select id="rosebudAdvancedStyle" class="rosebud-input w-full">
                <option value="realistic">Realistic</option>
                <option value="cartoon">Cartoon</option>
                <option value="anime">Anime</option>
                <option value="fantasy">Fantasy</option>
                <option value="watercolor">Watercolor</option>
                <option value="oil-painting">Oil Painting</option>
                <option value="pixel-art">Pixel Art</option>
                <option value="cyberpunk">Cyberpunk</option>
              </select>
            </div>
            
            <div>
              <label class="block text-sm font-medium text-gray-700 mb-1">Aspect Ratio</label>
              <select id="rosebudAdvancedRatio" class="rosebud-input w-full">
                <option value="1:1">Square (1:1)</option>
                <option value="4:3">Standard (4:3)</option>
                <option value="16:9">Widescreen (16:9)</option>
                <option value="9:16">Portrait (9:16)</option>
                <option value="2:3">Portrait (2:3)</option>
                <option value="3:2">Landscape (3:2)</option>
              </select>
            </div>
          </div>
          
          <div class="mb-4">
            <label class="block text-sm font-medium text-gray-700 mb-1">Quality</label>
            <input type="range" id="rosebudQuality" class="rosebud-slider" min="1" max="10" value="7">
            <div class="flex justify-between text-xs text-gray-500 mt-1">
              <span>Fast</span>
              <span>Balanced</span>
              <span>High Quality</span>
            </div>
          </div>
          
          <div class="mb-4">
            <label class="block text-sm font-medium text-gray-700 mb-1">Creativity</label>
            <input type="range" id="rosebudCreativity" class="rosebud-slider" min="1" max="10" value="5">
            <div class="flex justify-between text-xs text-gray-500 mt-1">
              <span>Precise</span>
              <span>Balanced</span>
              <span>Creative</span>
            </div>
          </div>
          
          <div class="mb-4">
            <label class="block text-sm font-medium text-gray-700 mb-1">Negative Prompt</label>
            <textarea id="rosebudNegativePrompt" class="rosebud-input h-16" placeholder="What you don't want in the image..."></textarea>
          </div>
          
          <button id="rosebudAdvancedSubmit" class="rosebud-button w-full">
            <i class="fas fa-magic mr-1"></i> Generate Image
          </button>
          
          <div id="rosebudAdvancedResponse" class="rosebud-response hidden mt-4"></div>
          <div id="rosebudAdvancedLoading" class="ai-loading hidden">
            <i class="ai-loading-spinner fas fa-spinner"></i>
            <span class="ml-2">Generating with Rosebud...</span>
          </div>
        </div>
        
        <!-- Right Panel - Image Display & Editing -->
        <div class="w-2/3 flex flex-col">
          <div class="border-b p-4">
            <div class="flex justify-between items-center">
              <h4 class="text-sm font-medium">Generated Images</h4>
              <div class="flex space-x-2">
                <button id="rosebudUpscaleBtn" class="rosebud-control-btn">
                  <i class="fas fa-expand mr-1"></i> Upscale
                </button>
                <button id="rosebudVariationsBtn" class="rosebud-control-btn">
                  <i class="fas fa-copy mr-1"></i> Variations
                </button>
              </div>
            </div>
          </div>
          
          <div id="rosebudAdvancedImages" class="rosebud-image-container p-4 grid grid-cols-2 gap-4 overflow-y-auto flex-1">
            <!-- Images will be inserted here -->
          </div>
          
          <div class="border-t p-4">
            <h4 class="text-sm font-medium mb-2">Image Editing Tools</h4>
            <div class="rosebud-edit-tools">
              <button class="rosebud-tool-btn" data-tool="crop">
                <i class="fas fa-crop"></i>
                <div class="text-xs mt-1">Crop</div>
              </button>
              <button class="rosebud-tool-btn" data-tool="adjust">
                <i class="fas fa-sliders-h"></i>
                <div class="text-xs mt-1">Adjust</div>
              </button>
              <button class="rosebud-tool-btn" data-tool="filter">
                <i class="fas fa-filter"></i>
                <div class="text-xs mt-1">Filter</div>
              </button>
              <button class="rosebud-tool-btn" data-tool="text">
                <i class="fas fa-font"></i>
                <div class="text-xs mt-1">Text</div>
              </button>
              <button class="rosebud-tool-btn" data-tool="draw">
                <i class="fas fa-pencil-alt"></i>
                <div class="text-xs mt-1">Draw</div>
              </button>
              <button class="rosebud-tool-btn" data-tool="erase">
                <i class="fas fa-eraser"></i>
                <div class="text-xs mt-1">Erase</div>
              </button>
              <button class="rosebud-tool-btn" data-tool="style">
                <i class="fas fa-paint-brush"></i>
                <div class="text-xs mt-1">Style</div>
              </button>
              <button class="rosebud-tool-btn" data-tool="enhance">
                <i class="fas fa-sparkles"></i>
                <div class="text-xs mt-1">Enhance</div>
              </button>
            </div>
            
            <div id="rosebudToolOptions" class="hidden mt-4 p-3 bg-gray-50 rounded-md">
              <!-- Tool options will be inserted here -->
            </div>
            
            <div class="flex justify-end space-x-2 mt-4">
              <button id="rosebudAdvancedDownloadBtn" class="rosebud-control-btn">
                <i class="fas fa-download mr-1"></i> Download
              </button>
              <button id="rosebudAdvancedAddToCanvasBtn" class="rosebud-control-btn bg-pink-600 hover:bg-pink-700 text-white">
                <i class="fas fa-plus mr-1"></i> Add to Canvas
              </button>
            </div>
          </div>
        </div>
      </div>
    </div>
  </div>

  <!-- Image Editor Modal -->
  <div id="imageEditorModal" class="fixed inset-0 bg-black/50 hidden items-center justify-center z-50 p-4">
    <div class="bg-white rounded-lg w-full max-w-6xl h-[90vh] flex flex-col overflow-hidden shadow-xl">
      <div class="p-4 border-b flex justify-between items-center bg-gray-50">
        <h3 class="text-lg font-semibold">Image Editor</h3>
        <div class="flex items-center space-x-3">
          <button id="imageEditorUndoBtn" class="text-gray-500 hover:text-gray-700">
            <i class="fas fa-undo"></i>
          </button>
          <button id="imageEditorRedoBtn" class="text-gray-500 hover:text-gray-700">
            <i class="fas fa-redo"></i>
          </button>
          <button id="closeImageEditor" class="text-gray-500 hover:text-gray-700">
            <i class="fas fa-times"></i>
          </button>
        </div>
      </div>
      <div class="flex-1 overflow-hidden flex">
        <!-- Left Panel - Tools -->
        <div class="w-16 border-r bg-gray-100 flex flex-col items-center py-4 space-y-4">
          <button class="image-editor-tool active" data-tool="select" title="Select">
            <i class="fas fa-mouse-pointer"></i>
          </button>
          <button class="image-editor-tool" data-tool="crop" title="Crop">
            <i class="fas fa-crop"></i>
          </button>
          <button class="image-editor-tool" data-tool="adjust" title="Adjust">
            <i class="fas fa-sliders-h"></i>
          </button>
          <button class="image-editor-tool" data-tool="filter" title="Filter">
            <i class="fas fa-filter"></i>
          </button>
          <button class="image-editor-tool" data-tool="text" title="Text">
            <i class="fas fa-font"></i>
          </button>
          <button class="image-editor-tool" data-tool="draw" title="Draw">
            <i class="fas fa-pencil-alt"></i>
          </button>
          <button class="image-editor-tool" data-tool="erase" title="Erase">
            <i class="fas fa-eraser"></i>
          </button>
          <button class="image-editor-tool" data-tool="shapes" title="Shapes">
            <i class="fas fa-shapes"></i>
          </button>
        </div>
        
        <!-- Center Panel - Canvas -->
        <div class="flex-1 relative">
          <div class="image-editor-tools">
            <div class="flex space-x-2">
              <button id="imageEditorZoomIn" class="image-editor-tool">
                <i class="fas fa-search-plus"></i>
              </button>
              <button id="imageEditorZoomOut" class="image-editor-tool">
                <i class="fas fa-search-minus"></i>
              </button>
              <button id="imageEditorResetZoom" class="image-editor-tool">
                <i class="fas fa-expand-arrows-alt"></i>
              </button>
            </div>
          </div>
          <canvas id="imageEditorCanvas" class="image-editor-canvas"></canvas>
        </div>
        
        <!-- Right Panel - Properties -->
        <div class="w-64 border-l p-4 overflow-y-auto">
          <div id="imageEditorProperties">
            <h4 class="text-sm font-medium mb-2">Tool Properties</h4>
            <div class="space-y-4">
              <div>
                <label class="block text-xs text-gray-500 mb-1">Brush Size</label>
                <input type="range" class="w-full" min="1" max="50" value="5">
              </div>
              <div>
                <label class="block text-xs text-gray-500 mb-1">Opacity</label>
                <input type="range" class="w-full" min="0" max="100" value="100">
              </div>
              <div>
                <label class="block text-xs text-gray-500 mb-1">Color</label>
                <input type="color" class="w-full h-8" value="#000000">
              </div>
            </div>
            
            <div class="mt-6">
              <h4 class="text-sm font-medium mb-2">Filters</h4>
              <div class="grid grid-cols-3 gap-2">
                <button class="p-2 border rounded text-xs hover:bg-gray-100">Brightness</button>
                <button class="p-2 border rounded text-xs hover:bg-gray-100">Contrast</button>
                <button class="p-2 border rounded text-xs hover:bg-gray-100">Saturation</button>
                <button class="p-2 border rounded text-xs hover:bg-gray-100">Blur</button>
                <button class="p-2 border rounded text-xs hover:bg-gray-100">Sharpen</button>
                <button class="p-2 border rounded text-xs hover:bg-gray-100">Grayscale</button>
                <button class="p-2 border rounded text-xs hover:bg-gray-100">Sepia</button>
                <button class="p-2 border rounded text-xs hover:bg-gray-100">Invert</button>
                <button class="p-2 border rounded text-xs hover:bg-gray-100">Vintage</button>
              </div>
            </div>
          </div>
        </div>
      </div>
      <div class="p-4 border-t flex justify-end space-x-3">
        <button id="imageEditorCancelBtn" class="px-4 py-2 text-sm font-medium text-gray-700 bg-gray-200 rounded-md hover:bg-gray-300">
          Cancel
        </button>
        <button id="imageEditorSaveBtn" class="px-4 py-2 text-sm font-medium text-white bg-primary rounded-md hover:bg-primary-dark">
          Save Changes
        </button>
      </div>
    </div>
  </div>

  <!-- Style Transfer Modal -->
  <div id="styleTransferModal" class="fixed inset-0 bg-black/50 hidden items-center justify-center z-50 p-4">
    <div class="bg-white rounded-lg w-full max-w-4xl flex flex-col overflow-hidden shadow-xl">
      <div class="p-4 border-b flex justify-between items-center bg-gray-50">
        <h3 class="text-lg font-semibold">Style Transfer</h3>
        <button id="closeStyleTransferModal" class="text-gray-500 hover:text-gray-700">
          <i class="fas fa-times"></i>
        </button>
      </div>
      <div class="p-4">
        <p class="text-sm text-gray-600 mb-4">Upload a content image and select a style to apply.</p>
        
        <div class="style-transfer-container">
          <div>
            <label class="block text-sm font-medium text-gray-700 mb-1">Content Image</label>
            <div class="border-2 border-dashed border-gray-300 rounded-lg p-4 flex items-center justify-center">
              <div id="styleTransferContentPreview" class="hidden"></div>
              <div id="styleTransferContentUpload" class="text-center">
                <i class="fas fa-image text-4xl text-gray-400 mb-2"></i>
                <p class="text-sm text-gray-500">Drag & drop or click to upload</p>
                <input type="file" id="styleTransferContentInput" class="hidden" accept="image/*">
                <button id="styleTransferContentBtn" class="mt-2 bg-gray-200 hover:bg-gray-300 text-gray-700 px-3 py-1 rounded text-sm">
                  Select Image
                </button>
              </div>
            </div>
          </div>
          
          <div>
            <label class="block text-sm font-medium text-gray-700 mb-1">Style Image</label>
            <div class="border-2 border-dashed border-gray-300 rounded-lg p-4 flex items-center justify-center">
              <div id="styleTransferStylePreview" class="hidden"></div>
              <div id="styleTransferStyleUpload" class="text-center">
                <i class="fas fa-paint-brush text-4xl text-gray-400 mb-2"></i>
                <p class="text-sm text-gray-500">Drag & drop or click to upload</p>
                <input type="file" id="styleTransferStyleInput" class="hidden" accept="image/*">
                <button id="styleTransferStyleBtn" class="mt-2 bg-gray-200 hover:bg-gray-300 text-gray-700 px-3 py-1 rounded text-sm">
                  Select Style
                </button>
              </div>
            </div>
          </div>
        </div>
        
        <div class="mt-4">
          <label class="block text-sm font-medium text-gray-700 mb-1">Style Strength</label>
          <input type="range" id="styleTransferStrength" class="w-full" min="0" max="100" value="50">
          <div class="flex justify-between text-xs text-gray-500 mt-1">
            <span>Subtle</span>
            <span>Balanced</span>
            <span>Strong</span>
          </div>
        </div>
        
        <button id="styleTransferSubmit" class="style-transfer-btn mt-4">
          <i class="fas fa-magic mr-1"></i> Apply Style Transfer
        </button>
        
        <div id="styleTransferResult" class="hidden mt-6">
          <label class="block text-sm font-medium text-gray-700 mb-2">Result</label>
          <div id="styleTransferResultImage" class="border rounded-lg overflow-hidden"></div>
          <div class="flex justify-end space-x-2 mt-4">
            <button id="styleTransferDownloadBtn" class="rosebud-control-btn">
              <i class="fas fa-download mr-1"></i> Download
            </button>
            <button id="styleTransferAddToCanvasBtn" class="rosebud-control-btn bg-purple-600 hover:bg-purple-700 text-white">
              <i class="fas fa-plus mr-1"></i> Add to Canvas
            </button>
          </div>
        </div>
        
        <div id="styleTransferLoading" class="ai-loading hidden">
          <i class="ai-loading-spinner fas fa-spinner"></i>
          <span class="ml-2">Applying style transfer...</span>
        </div>
      </div>
    </div>
  </div>

  <script>
    document.addEventListener('DOMContentLoaded', function() {
      // Global variables
      let draggedItem = null;
      let selectedComponent = null;
      let components = [];
      let componentCounter = 0;
      let isResizing = false;
      let startX, startY, startWidth, startHeight;
      let isDraggingDivider = false;
      let activeModel = 'apwb'; // Default to APWB model
      let selectedRosebudImage = null;
      let selectedStyleTransferImage = null;
      let imageEditor = null;

      // DOM elements
      const canvas = document.getElementById('canvas');
      const emptyState = document.getElementById('emptyState');
      const propertiesPanel = document.getElementById('propertiesPanel');
      const previewModal = document.getElementById('previewModal');
      const previewFrame = document.getElementById('previewFrame');
      const previewContainer = document.getElementById('previewContainer');
      const deviceSelector = document.getElementById('deviceSelector');
      const previewBtn = document.getElementById('previewBtn');
      const closePreview = document.getElementById('closePreview');
      const saveBtn = document.getElementById('saveBtn');
      const exportBtn = document.getElementById('exportBtn');
      const exportModal = document.getElementById('exportModal');
      const exportCode = document.getElementById('exportCode');
      const copyCodeBtn = document.getElementById('copyCodeBtn');
      const downloadBtn = document.getElementById('downloadBtn');
      const closeExport = document.getElementById('closeExport');
      const tabBtns = document.querySelectorAll('[data-tab]');
      const tabsContent = document.querySelectorAll('.tab-content');
      const modelSelector = document.getElementById('modelSelector');
      
      // AI Modal elements
      const aiPromptBtn = document.getElementById('aiPromptBtn');
      const aiModal = document.getElementById('aiModal');
      const aiPrompt = document.getElementById('aiPrompt');
      const aiResponse = document.getElementById('aiResponse');
      const aiLoading = document.getElementById('aiLoading');
      const aiGeneratedComponents = document.getElementById('aiGeneratedComponents');
      const aiComponentsList = document.getElementById('aiComponentsList');
      const generateAIBtn = document.getElementById('generateAIBtn');
      const cancelAIBtn = document.getElementById('cancelAIBtn');
      const closeAIModal = document.getElementById('closeAIModal');
      
      // APWB elements
      const apwbTab = document.getElementById('apwbTab');
      const apwbPrompt = document.getElementById('apwbPrompt');
      const apwbSubmit = document.getElementById('apwbSubmit');
      const apwbResponse = document.getElementById('apwbResponse');
      const apwbLoading = document.getElementById('apwbLoading');
      
      // DeepCoder elements
      const deepcoderBtn = document.getElementById('deepcoderBtn');
      const deepcoderModal = document.getElementById('deepcoderModal');
      const closeDeepcoderModal = document.getElementById('closeDeepcoderModal');
      const deepcoderTabs = document.querySelectorAll('.deepcoder-tab');
      const deepcoderCodeTab = document.getElementById('deepcoderCodeTab');
      const deepcoderTerminalTab = document.getElementById('deepcoderTerminalTab');
      const deepcoderCode = document.getElementById('deepcoderCode');
      const runCodeBtn = document.getElementById('runCodeBtn');
      const clearCodeBtn = document.getElementById('clearCodeBtn');
      const terminalContent = document.getElementById('terminalContent');
      const terminalCommand = document.getElementById('terminalCommand');
      const deepcoderAIPrompt = document.getElementById('deepcoderAIPrompt');
      const deepcoderAISubmit = document.getElementById('deepcoderAISubmit');
      const deepcoderAIResponse = document.getElementById('deepcoderAIResponse');
      const deepcoderAILoading = document.getElementById('deepcoderAILoading');
      
      // Rosebud elements
      const rosebudBtn = document.getElementById('rosebudBtn');
      const rosebudModal = document.getElementById('rosebudModal');
      const closeRosebudModal = document.getElementById('closeRosebudModal');
      const rosebudPrompt = document.getElementById('rosebudPrompt');
      const rosebudStyle = document.getElementById('rosebudStyle');
      const rosebudRatio = document.getElementById('rosebudRatio');
      const rosebudSubmit = document.getElementById('rosebudSubmit');
      const rosebudResponse = document.getElementById('rosebudResponse');
      const rosebudLoading = document.getElementById('rosebudLoading');
      const rosebudImages = document.getElementById('rosebudImages');
      const rosebudEditBtn = document.getElementById('rosebudEditBtn');
      const rosebudDownloadBtn = document.getElementById('rosebudDownloadBtn');
      const rosebudAddToCanvasBtn = document.getElementById('rosebudAddToCanvasBtn');
      const rosebudEditControls = document.getElementById('rosebudEditControls');
      
      // Rosebud Advanced elements
      const rosebudAdvancedPrompt = document.getElementById('rosebudAdvancedPrompt');
      const rosebudAdvancedStyle = document.getElementById('rosebudAdvancedStyle');
      const rosebudAdvancedRatio = document.getElementById('rosebudAdvancedRatio');
      const rosebudQuality = document.getElementById('rosebudQuality');
      const rosebudCreativity = document.getElementById('rosebudCreativity');
      const rosebudNegativePrompt = document.getElementById('rosebudNegativePrompt');
      const rosebudAdvancedSubmit = document.getElementById('rosebudAdvancedSubmit');
      const rosebudAdvancedResponse = document.getElementById('rosebudAdvancedResponse');
      const rosebudAdvancedLoading = document.getElementById('rosebudAdvancedLoading');
      const rosebudAdvancedImages = document.getElementById('rosebudAdvancedImages');
      const rosebudUpscaleBtn = document.getElementById('rosebudUpscaleBtn');
      const rosebudVariationsBtn = document.getElementById('rosebudVariationsBtn');
      const rosebudAdvancedDownloadBtn = document.getElementById('rosebudAdvancedDownloadBtn');
      const rosebudAdvancedAddToCanvasBtn = document.getElementById('rosebudAdvancedAddToCanvasBtn');
      const rosebudToolOptions = document.getElementById('rosebudToolOptions');
      
      // Image Editor elements
      const imageEditorModal = document.getElementById('imageEditorModal');
      const imageEditorCanvas = document.getElementById('imageEditorCanvas');
      const imageEditorUndoBtn = document.getElementById('imageEditorUndoBtn');
      const imageEditorRedoBtn = document.getElementById('imageEditorRedoBtn');
      const closeImageEditor = document.getElementById('closeImageEditor');
      const imageEditorZoomIn = document.getElementById('imageEditorZoomIn');
      const imageEditorZoomOut = document.getElementById('imageEditorZoomOut');
      const imageEditorResetZoom = document.getElementById('imageEditorResetZoom');
      const imageEditorProperties = document.getElementById('imageEditorProperties');
      const imageEditorCancelBtn = document.getElementById('imageEditorCancelBtn');
      const imageEditorSaveBtn = document.getElementById('imageEditorSaveBtn');
      
      // Style Transfer elements
      const styleTransferModal = document.getElementById('styleTransferModal');
      const closeStyleTransferModal = document.getElementById('closeStyleTransferModal');
      const styleTransferContentPreview = document.getElementById('styleTransferContentPreview');
      const styleTransferContentUpload = document.getElementById('styleTransferContentUpload');
      const styleTransferContentInput = document.getElementById('styleTransferContentInput');
      const styleTransferContentBtn = document.getElementById('styleTransferContentBtn');
      const styleTransferStylePreview = document.getElementById('styleTransferStylePreview');
      const styleTransferStyleUpload = document.getElementById('styleTransferStyleUpload');
      const styleTransferStyleInput = document.getElementById('styleTransferStyleInput');
      const styleTransferStyleBtn = document.getElementById('styleTransferStyleBtn');
      const styleTransferStrength = document.getElementById('styleTransferStrength');
      const styleTransferSubmit = document.getElementById('styleTransferSubmit');
      const styleTransferResult = document.getElementById('styleTransferResult');
      const styleTransferResultImage = document.getElementById('styleTransferResultImage');
      const styleTransferDownloadBtn = document.getElementById('styleTransferDownloadBtn');
      const styleTransferAddToCanvasBtn = document.getElementById('styleTransferAddToCanvasBtn');
      const styleTransferLoading = document.getElementById('styleTransferLoading');
      
      // Split view elements
      const splitContainer = document.querySelector('.split-container');
      const leftPanel = document.querySelector('.split-panel:first-child');
      const rightPanel = document.querySelector('.split-panel:last-child');
      const dividers = document.querySelectorAll('.split-divider');

      // Initialize the builder
      function initBuilder() {
        initDragAndDrop();
        initEventListeners();
        initAIEventListeners();
        initAPWBEventListeners();
        initDeepCoderEventListeners();
        initRosebudEventListeners();
        initImageEditor();
        initStyleTransfer();
        initSplitView();
        loadFromLocalStorage();
      }

      // Initialize drag and drop
      function initDragAndDrop() {
        // Add event listeners to all components
        document.querySelectorAll('.component').forEach(item => {
          item.addEventListener('dragstart', handleDragStart);
          item.addEventListener('dragend', handleDragEnd);
        });

        // Canvas drop events
        canvas.addEventListener('dragover', handleDragOver);
        canvas.addEventListener('dragleave', handleDragLeave);
        canvas.addEventListener('drop', handleDrop);
      }

      // Initialize event listeners
      function initEventListeners() {
        // Preview button
        previewBtn.addEventListener('click', showPreview);
        closePreview.addEventListener('click', hidePreview);
        
        // Save button
        saveBtn.addEventListener('click', saveToLocalStorage);
        
        // Export button
        exportBtn.addEventListener('click', showExportModal);
        closeExport.addEventListener('click', hideExportModal);
        copyCodeBtn.addEventListener('click', copyExportCode);
        downloadBtn.addEventListener('click', downloadHTML;
        
        // Device selector
        deviceSelector.addEventListener('change', updatePreviewDevice);
        
        // Tab buttons
        tabBtns.forEach(btn => {
          btn.addEventListener('click', () => {
            const tabId = btn.dataset.tab;
            tabBtns.forEach(b => b.classList.remove('active'));
            btn.classList.add('active');
            
            tabsContent.forEach(content => content.classList.remove('active'));
            document.getElementById(`${tabId}Tab`).classList.add('active');
          });
        });
        
        // Model selector
        modelSelector.addEventListener('change', (e) => {
          activeModel = e.target.value;
          showToast(`Switched to ${activeModel === 'apwb' ? 'APWB' : activeModel === 'deepcoder' ? 'DeepCoder' : activeModel === 'rosebud' ? 'Rosebud' : 'DeepSeek'} model`);
        });
      }

      // Initialize AI event listeners
      function initAIEventListeners() {
        // AI Prompt button
        aiPromptBtn.addEventListener('click', showAIModal);
        closeAIModal.addEventListener('click', hideAIModal);
        cancelAIBtn.addEventListener('click', hideAIModal);
        
        // Generate AI button
        generateAIBtn.addEventListener('click', generateAIComponents);
      }
      
      // Initialize APWB event listeners
      function initAPWBEventListeners() {
        apwbSubmit.addEventListener('click', generateWithAPWB);
        
        // Allow pressing Enter in the APWB prompt
        apwbPrompt.addEventListener('keydown', (e) => {
          if (e.key === 'Enter' && !e.shiftKey) {
            e.preventDefault();
            generateWithAPWB();
          }
        });
      }
      
      // Initialize DeepCoder event listeners
      function initDeepCoderEventListeners() {
        // DeepCoder button
        deepcoderBtn.addEventListener('click', showDeepcoderModal);
        closeDeepcoderModal.addEventListener('click', hideDeepcoderModal);
        
        // DeepCoder tabs
        deepcoderTabs.forEach(tab => {
          tab.addEventListener('click', () => {
            const tabId = tab.dataset.tab;
            deepcoderTabs.forEach(t => t.classList.remove('active'));
            tab.classList.add('active');
            
            document.querySelectorAll('.tab-content').forEach(content => {
              content.classList.remove('active');
            });
            
            document.getElementById(`deepcoder${tabId.charAt(0).toUpperCase() + tabId.slice(1)}Tab`).classList.add('active');
          });
        });
        
        // Run code button
        runCodeBtn.addEventListener('click', runCode);
        
        // Clear code button
        clearCodeBtn.addEventListener('click', clearCode);
        
        // Terminal command input
        terminalCommand.addEventListener('keydown', (e) => {
          if (e.key === 'Enter') {
            executeTerminalCommand();
          }
        });
        
        // DeepCoder AI submit
        deepcoderAISubmit.addEventListener('click', generateWithDeepCoder);
        
        // Allow pressing Enter in the DeepCoder prompt
        deepcoderAIPrompt.addEventListener('keydown', (e) => {
          if (e.key === 'Enter' && !e.shiftKey) {
            e.preventDefault();
            generateWithDeepCoder();
          }
        });
      }
      
      // Initialize Rosebud event listeners
      function initRosebudEventListeners() {
        // Rosebud button
        rosebudBtn.addEventListener('click', showRosebudModal);
        closeRosebudModal.addEventListener('click', hideRosebudModal);
        
        // Rosebud submit
        rosebudSubmit.addEventListener('click', generateWithRosebud);
        
        // Rosebud advanced submit
        rosebudAdvancedSubmit.addEventListener('click', generateWithRosebudAdvanced);
        
        // Rosebud image selection
        rosebudImages.addEventListener('click', (e) => {
          if (e.target.classList.contains('rosebud-image')) {
            document.querySelectorAll('.rosebud-image').forEach(img => {
              img.classList.remove('selected');
            });
            e.target.classList.add('selected');
            selectedRosebudImage = e.target.src;
            rosebudEditControls.classList.remove('hidden');
          }
        });
        
        // Rosebud advanced image selection
        rosebudAdvancedImages.addEventListener('click', (e) => {
          if (e.target.classList.contains('rosebud-image')) {
            document.querySelectorAll('.rosebud-image').forEach(img => {
              img.classList.remove('selected');
            });
            e.target.classList.add('selected');
            selectedRosebudImage = e.target.src;
          }
        });
        
        // Rosebud edit button
        rosebudEditBtn.addEventListener('click', () => {
          if (selectedRosebudImage) {
            openImageEditor(selectedRosebudImage);
          }
        });
        
        // Rosebud download button
        rosebudDownloadBtn.addEventListener('click', () => {
          if (selectedRosebudImage) {
            downloadImage(selectedRosebudImage, 'rosebud-image.png');
          }
        });
        
        // Rosebud add to canvas button
       
</html>