File size: 76,287 Bytes
703d6a1
4e6fa4a
59dc8c6
da83632
bf94ab9
703d6a1
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
bf94ab9
b7122f5
 
a0997aa
b7122f5
38fa334
3943700
a0997aa
b7122f5
c0eaec6
 
2d454cc
 
e04348c
c0eaec6
 
 
 
 
2d454cc
6d265bb
 
c0eaec6
e04348c
c0eaec6
b7122f5
cf068e8
 
 
 
b7122f5
 
e04348c
 
 
 
 
 
 
 
b7122f5
 
 
 
 
 
 
 
 
 
 
bf94ab9
b7122f5
a0997aa
b7122f5
 
 
 
 
 
 
 
 
2d454cc
3943700
38fa334
a0997aa
2d454cc
a0997aa
38fa334
a0997aa
 
38fa334
 
 
 
b7122f5
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
2d454cc
 
 
 
 
 
 
 
 
 
 
 
bf94ab9
b7122f5
 
 
 
2d454cc
b7122f5
 
 
 
 
 
 
27d593b
 
b7122f5
2fb64d9
 
b7122f5
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
bf94ab9
b7122f5
c0eaec6
2d454cc
b7122f5
 
 
2fb64d9
 
b7122f5
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
2d454cc
38fa334
b7122f5
38fa334
b7122f5
 
bf94ab9
b7122f5
2d454cc
b7122f5
 
 
 
 
 
bf94ab9
b7122f5
 
2fb64d9
 
b7122f5
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
da83632
 
 
 
0535d37
 
b7122f5
da83632
2d454cc
b7122f5
3943700
 
b7122f5
c0eaec6
a0997aa
b7122f5
0535d37
32ee33a
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
cf068e8
32ee33a
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
6d265bb
32ee33a
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
0535d37
3943700
b7122f5
2d454cc
bf94ab9
2d454cc
da83632
6d265bb
0535d37
 
 
 
 
 
 
 
 
 
 
6d265bb
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
da83632
 
2d454cc
da83632
 
0535d37
 
da83632
0535d37
 
 
da83632
 
 
0535d37
 
da83632
 
 
 
0535d37
da83632
 
 
0535d37
 
 
 
da83632
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
0535d37
da83632
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
e04348c
da83632
 
 
 
 
 
 
 
 
 
69c33d4
da83632
 
 
 
 
 
 
 
 
 
e04348c
da83632
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
e04348c
da83632
 
 
 
 
 
 
 
 
 
e71710c
da83632
 
 
 
 
 
 
 
 
 
e04348c
da83632
 
 
 
 
 
 
 
 
 
69c33d4
da83632
 
 
 
 
 
 
 
 
 
e04348c
da83632
 
 
 
 
bf94ab9
703d6a1
 
 
 
bf94ab9
6d265bb
 
aeaad82
 
 
 
 
 
 
 
 
 
 
 
 
 
69c33d4
 
 
6d265bb
 
 
69c33d4
 
 
 
 
2d454cc
6d265bb
69c33d4
 
 
 
da83632
b7122f5
da83632
2d454cc
 
e04348c
 
 
 
bf94ab9
2d454cc
 
 
 
bf94ab9
6d265bb
 
 
0535d37
 
 
 
 
6d265bb
0535d37
 
 
 
 
 
 
 
 
 
 
 
e04348c
 
bf94ab9
e04348c
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
59dc8c6
 
 
e04348c
 
2d454cc
e04348c
 
 
 
 
59dc8c6
e04348c
 
 
 
a0997aa
 
e04348c
 
a0997aa
 
e04348c
 
59dc8c6
a0997aa
 
e04348c
 
 
 
 
 
 
2d454cc
 
38fa334
 
e04348c
 
 
 
 
 
2d454cc
 
e04348c
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
38fa334
2d454cc
e04348c
2d454cc
e04348c
 
2d454cc
 
e04348c
 
 
 
 
32ee33a
a0997aa
3943700
 
 
a0997aa
 
 
 
32ee33a
 
a0997aa
e04348c
 
 
da83632
2fb64d9
 
 
 
c0eaec6
da83632
 
 
 
70a5619
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
2fb64d9
 
70a5619
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
459c434
70a5619
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
c170c7c
 
70a5619
 
 
 
 
 
431cce5
70a5619
431cce5
70a5619
 
431cce5
3fa2f83
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
70a5619
 
 
 
3fa2f83
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
import React, { useState, useEffect, useRef, useCallback } from 'react';
import QRCode from 'qrcode';
import jsqr from 'jsqr'; // Changed import statement to lowercase 'jsqr'

// Custom Alert Modal Component
const CustomAlert = ({ message, onClose }) => {
    if (!message) return null;

    return (
        <div className="fixed inset-0 bg-black bg-opacity-50 flex items-center justify-center z-50 p-4">
            <div className="bg-gradient-to-br from-gray-800 to-gray-900 border border-blue-500 rounded-lg shadow-xl p-6 max-w-sm w-full text-white text-center animate-fade-in-up">
                <p className="text-lg font-semibold mb-4">{message}</p>
                <button
                    onClick={onClose}
                    className="bg-blue-600 hover:bg-blue-700 text-white font-bold py-2 px-4 rounded-lg transition duration-300 ease-in-out transform hover:scale-105"
                >
                    OK
                </button>
            </div>
        </div>
    );
};

// --- QRGeneratorTab Component ---
const QRGeneratorTab = ({
    content, setContent, errorLevel, setErrorLevel, qrColor, setQrColor,
    suggestIdeas, downloadQrCode, qrCanvasRef,
    isInputFocused, setIsInputFocused, currentThemeClasses,
    qrStyles, selectedStyleIndex, setSelectedStyleIndex, styleCanvasRefs, drawQrCode,
    suggestedIdea, showSuggestedIdea, setShowSuggestedIdea,
    downloadResolution, setDownloadResolution
}) => {
    // Effect to generate QR code on the main canvas (Generator Tab)
    useEffect(() => {
        // Preview canvas is always 256x256
        drawQrCode(qrCanvasRef.current, content, qrColor, errorLevel, 256);
    }, [content, qrColor, errorLevel, drawQrCode, qrCanvasRef]);

    // Effect to generate QR codes for style previews (Style Selection Panel)
    useEffect(() => {
        qrStyles.forEach((style, index) => {
            const canvas = styleCanvasRefs.current[index];
            // Use a generic sample for style previews, not actual content
            // For style previews, the 'light' color should always be black for contrast with the style's fg color
            drawQrCode(canvas, "Sample", style.fg, 'H', 80, '#000000'); 
        });
    }, [qrStyles, drawQrCode, styleCanvasRefs]);

    return (
        // Modified: Changed lg:items-stretch to lg:items-start to allow independent heights
        <div className="flex flex-col lg:flex-row p-4 md:p-6 space-y-6 lg:space-y-0 lg:space-x-6 flex-grow lg:items-start">
            {/* Left Panel: Input and Controls - Removed flex-grow as it's not needed with items-start */}
            <div className={`flex flex-col w-full lg:w-3/4 p-6 rounded-2xl border ${currentThemeClasses.glassBorder} ${currentThemeClasses.glassBg} shadow-2xl ${currentThemeClasses.shadow} transform transition-all duration-500 ease-in-out`}>
                <label className={`mb-2 font-semibold ${currentThemeClasses.labelColor} font-inter`}>Enter Content:</label>
                <textarea
                    className={
                        "w-full p-3 rounded-xl border " +
                        currentThemeClasses.inputBorder + " " +
                        currentThemeClasses.inputBg + " " +
                        currentThemeClasses.text + " " +
                        "focus:outline-none focus:ring-2 focus:ring-blue-500 transition-all duration-300 font-inter " +
                        (isInputFocused ? 'ring-2 ring-blue-500 shadow-md shadow-blue-500/50' : '')
                    }
                    rows="6"
                    placeholder="Enter text or URL..."
                    value={content}
                    onChange={(e) => setContent(e.target.value)}
                    onFocus={() => setIsInputFocused(true)}
                    onBlur={() => setIsInputFocused(false)}
                ></textarea>

                <div className="flex flex-col sm:flex-row space-y-4 sm:space-y-0 sm:space-x-4 mt-4">
                    <button
                        className={`w-full sm:w-1/2 py-3 px-6 rounded-xl font-bold text-lg bg-gradient-to-r ${currentThemeClasses.primaryAccent} text-white shadow-lg ${currentThemeClasses.buttonGlow} transform hover:-translate-y-1 transition-all duration-300 ease-in-out flex items-center justify-center`}
                        onClick={suggestIdeas}
                    >
                        <i className="fas fa-lightbulb mr-2"></i> Suggest Idea
                    </button>
                    <button
                        className={`w-full sm:w-1/2 py-3 px-6 rounded-xl font-bold text-lg bg-gradient-to-r ${currentThemeClasses.secondaryAccent} text-white shadow-lg ${currentThemeClasses.buttonGlow} transform hover:-translate-y-1 transition-all duration-300 ease-in-out flex items-center justify-center`}
                        onClick={downloadQrCode}
                    >
                        <i className="fas fa-save mr-2"></i> Save QR Code
                    </button>
                </div>

                {/* Suggested Ideas Panel */}
                {showSuggestedIdea && suggestedIdea && (
                    <div className={`mt-4 p-4 rounded-xl border ${currentThemeClasses.glassBorder} ${currentThemeClasses.glassBg} shadow-inner transition-all duration-300 overflow-hidden`}>
                        <div className="flex justify-between items-center cursor-pointer" onClick={() => setShowSuggestedIdea(!showSuggestedIdea)}>
                            <label className={`font-semibold ${currentThemeClasses.labelColor} font-inter`}>Suggested QR Idea:</label>
                            <i className={`fas ${showSuggestedIdea ? 'fa-chevron-up' : 'fa-chevron-down'} transition-transform duration-300`}></i>
                        </div>
                        <div className={`overflow-hidden transition-all duration-500 ease-in-out ${showSuggestedIdea ? 'max-h-96 opacity-100 mt-2' : 'max-h-0 opacity-0'}`}>
                            <p className={`${currentThemeClasses.text} whitespace-pre-wrap text-sm font-inter`}>{suggestedIdea}</p>
                        </div>
                    </div>
                )}

                <label className={`mt-4 mb-2 font-semibold ${currentThemeClasses.labelColor} font-inter`}>Error Correction Level:</label>
                <select
                    className={`w-full p-3 rounded-xl border ${currentThemeClasses.inputBorder} ${currentThemeClasses.inputBg} ${currentThemeClasses.text} focus:outline-none focus:ring-2 focus:ring-blue-500 appearance-none transition-all duration-300 font-inter`}
                    value={errorLevel}
                    onChange={(e) => setErrorLevel(e.target.value)}
                >
                    <option value="L">L - Low</option>
                    <option value="M">M - Medium</option>
                    <option value="Q">Q - Quality</option>
                    <option value="H">H - High</option>
                </select>

                <label className={`mt-4 mb-2 font-semibold ${currentThemeClasses.labelColor} font-inter`}>Pick QR Color:</label>
                <input
                    type="color"
                    className={`w-full h-10 rounded-xl border ${currentThemeClasses.inputBorder} p-1 cursor-pointer transition-all duration-300`}
                    value={qrColor}
                    onChange={(e) => setQrColor(e.target.value)}
                />

                {/* New: Download Resolution Selector */}
                <label className={`mt-4 mb-2 font-semibold ${currentThemeClasses.labelColor} font-inter`}>Download Resolution:</label>
                <select
                    className={`w-full p-3 rounded-xl border ${currentThemeClasses.inputBorder} ${currentThemeClasses.inputBg} ${currentThemeClasses.text} focus:outline-none focus:ring-2 focus:ring-blue-500 appearance-none transition-all duration-300 font-inter`}
                    value={downloadResolution}
                    onChange={(e) => setDownloadResolution(Number(e.target.value))}
                >
                    <option value={256}>256x256 (Preview Size)</option>
                    <option value={512}>512x512 (Medium)</option>
                    <option value={1024}>1024x1024 (High)</option>
                    <option value={2048}>2048x2048 (Very High)</option>
                </select>

                <label className={`mt-6 mb-2 font-semibold ${currentThemeClasses.labelColor} font-inter`}>QR Preview:</label>
                <div
                    className={`relative flex justify-center items-center w-full min-h-[300px] rounded-2xl border-2 ${currentThemeClasses.qrPreviewBorder} ${currentThemeClasses.qrPreviewBg} p-4 shadow-inner overflow-hidden transform transition-all duration-300 hover:scale-[1.01] hover:-translate-y-1 ${currentThemeClasses.glow}`}
                >
                    <canvas ref={qrCanvasRef} width="256" height="256" className={`rounded-lg shadow-xl ${content ? '' : 'hidden'}`}></canvas>
                    {!content && (
                        <p className={`${currentThemeClasses.labelColor} text-lg font-inter absolute top-1/2 left-1/2 -translate-x-1/2 -translate-y-1/2`}>Enter content to see QR preview</p>
                    )}
                    <div className="absolute inset-0 scan-line"></div>
                </div>
            </div>

            {/* Right Panel: Style Selection - Increased max-h slightly to 800px */}
            <div className={`w-full lg:w-1/4 p-6 rounded-2xl shadow-2xl border ${currentThemeClasses.glassBorder} ${currentThemeClasses.glassBg} ${currentThemeClasses.text} flex flex-col transform transition-all duration-500 ease-in-out max-h-[800px]`}>
                <label className={`mb-4 font-semibold ${currentThemeClasses.labelColor} font-inter`}>Choose Style:</label>
                {/* This inner div needs to scroll if content overflows. flex-grow and overflow-y-auto */}
                <div className={`overflow-y-auto flex-grow rounded-xl p-2 ${currentThemeClasses.cardBg} custom-scrollbar`}> 
                    <div className="grid grid-cols-2 gap-4">
                        {qrStyles.map((style, index) => (
                            <div
                                key={index}
                                className={`flex flex-col items-center justify-center p-2 rounded-xl cursor-pointer transition-all duration-200 ease-in-out
                                    ${selectedStyleIndex === index ? `border-4 ${currentThemeClasses.qrPreviewBorder} shadow-lg scale-105 ${currentThemeClasses.glow}` : `border-2 ${currentThemeClasses.inputBorder} hover:border-blue-400/50 hover:scale-[1.02]`}
                                    ${currentThemeClasses.inputBg}`}
                                onClick={() => {
                                    setSelectedStyleIndex(index);
                                    setQrColor(style.fg);
                                }}
                            >
                                <canvas ref={el => styleCanvasRefs.current[index] = el} width="80" height="80" className="rounded-lg"></canvas>
                                <span className={`mt-2 text-sm font-medium ${currentThemeClasses.labelColor} font-inter`}>{style.name}</span>
                            </div>
                        ))}
                    </div>
                </div>
            </div>
        </div>
    );
};

// --- QRDecoderTab Component ---
const QRDecoderTab = ({
    decodedContent, setDecodedContent,
    isSummarizing, summarizeContent, showAlert, decodeQrCode,
    currentThemeClasses
}) => {
    return (
        // Added flex-grow to ensure it takes available vertical space
        <div className={`flex flex-col p-4 md:p-6 space-y-6 flex-grow ${currentThemeClasses.bg} ${currentThemeClasses.text}`}>
            <div
                className={`flex flex-col items-center justify-center p-10 border-2 border-dashed ${currentThemeClasses.glassBorder} rounded-2xl min-h-[200px] ${currentThemeClasses.glassBg} ${currentThemeClasses.text} transition-all duration-300 shadow-2xl ${currentThemeClasses.shadow} hover:scale-[1.01] hover:-translate-y-1`}
            >
                <p className={`text-lg ${currentThemeClasses.labelColor} mb-4 font-inter`}>Drag & Drop QR Image Here</p>
                <input
                    type="file"
                    accept="image/*"
                    className="hidden"
                    id="qr-upload-input"
                    onChange={decodeQrCode}
                />
                <label
                    htmlFor="qr-upload-input"
                    className={`cursor-pointer py-3 px-6 rounded-xl font-bold text-lg bg-gradient-to-r ${currentThemeClasses.primaryAccent} text-white shadow-lg ${currentThemeClasses.buttonGlow} transform hover:-translate-y-1 transition-all duration-300 ease-in-out flex items-center justify-center`}
                >
                    <i className="fas fa-upload mr-2 animate-bounce"></i> Upload QR Image to Decode
                </label>
            </div>

            <div className={`p-6 rounded-2xl border ${currentThemeClasses.glassBorder} ${currentThemeClasses.glassBg} shadow-2xl ${currentThemeClasses.shadow} transform transition-all duration-500 ease-in-out`}>
                <label className={`mb-2 font-semibold ${currentThemeClasses.labelColor} font-inter`}>Decoded Content:</label>
                <textarea
                    className={`w-full p-3 rounded-xl border ${currentThemeClasses.inputBorder} ${currentThemeClasses.inputBg} ${currentThemeClasses.text} focus:outline-none focus:ring-2 focus:ring-blue-500 transition-all duration-300 font-inter`}
                    rows="8"
                    value={decodedContent}
                    onChange={(e) => setDecodedContent(e.target.value)}
                    placeholder="Decoded content will appear here..."
                ></textarea>

                <button
                    className={`mt-4 w-full py-3 px-6 rounded-xl font-bold text-lg bg-gradient-to-r ${currentThemeClasses.secondaryAccent} text-white shadow-lg ${currentThemeClasses.buttonGlow} transform hover:-translate-y-1 transition-all duration-300 ease-in-out flex items-center justify-center`}
                    onClick={summarizeContent}
                    disabled={isSummarizing || !decodedContent.trim() || decodedContent === 'No QR code detected.'}
                >
                    {isSummarizing ? (
                        <i className="fas fa-spinner fa-spin mr-2"></i>
                    ) : (
                        <i className="fas fa-file-alt mr-2"></i>
                    )}
                    📝 {isSummarizing ? 'Summarizing Content...' : 'Summarize Content'}
                </button>
            </div>
        </div>
    );
};

// --- SettingsTab Component ---
const SettingsTab = ({ currentTheme, setCurrentTheme, currentThemeClasses, themes }) => {
    return (
        // Added flex-grow to ensure it takes available vertical space
        <div className={`flex flex-col p-4 md:p-6 space-y-6 flex-grow ${currentThemeClasses.bg} ${currentThemeClasses.text}`}>
            <div className={`p-6 rounded-2xl border ${currentThemeClasses.glassBorder} ${currentThemeClasses.glassBg} shadow-2xl ${currentThemeClasses.shadow} transform transition-all duration-500 ease-in-out`}>
                <label className={`mb-2 font-semibold ${currentThemeClasses.labelColor} font-inter`}>Select Theme:</label>
                <select
                    className={`w-full p-3 rounded-xl border ${currentThemeClasses.inputBorder} ${currentThemeClasses.inputBg} ${currentThemeClasses.text} focus:outline-none focus:ring-2 focus:ring-blue-500 appearance-none transition-all duration-300 font-inter`}
                    value={currentTheme}
                    onChange={(e) => setCurrentTheme(e.target.value)}
                >
                    {Object.keys(themes).map((themeName) => (
                        <option key={themeName} value={themeName}>
                            {themeName.split('-').map(word => word.charAt(0).toUpperCase() + word.slice(1)).join(' ')}
                        </option>
                    ))}
                </select>

                <button
                    className={`mt-6 w-full py-3 px-6 rounded-xl font-bold text-lg bg-gradient-to-r ${currentThemeClasses.primaryAccent} text-white shadow-lg ${currentThemeClasses.buttonGlow} transform hover:-translate-y-1 transition-all duration-300 ease-in-out flex items-center justify-center`}
                    onClick={() => setCurrentTheme('dark')}
                >
                    Reset to Dark Theme
                </button>
            </div>
        </div>
    );
};

// --- Main App component ---
const App = () => {
    const [activeTab, setActiveTab] = useState('generator');
    const [content, setContent] = useState('');
    const [errorLevel, setErrorLevel] = useState('L');
    // Default QR color set to neon cyan
    const [qrColor, setQrColor] = useState('#00FFFF'); 
    const [decodedContent, setDecodedContent] = useState('');
    const [selectedStyleIndex, setSelectedStyleIndex] = useState(0);
    const [currentTheme, setCurrentTheme] = useState('dark');
    const [isSummarizing, setIsSummarizing] = useState(false);
    const [suggestedIdea, setSuggestedIdea] = useState('');
    const [showSuggestedIdea, setShowSuggestedIdea] = useState(false);
    const [alertMessage, setAlertMessage] = useState(null);
    const [isInputFocused, setIsInputFocused] = useState(false);
    const [downloadResolution, setDownloadResolution] = useState(512);

    // Suggested ideas now directly within App.jsx
    const [allSuggestedIdeas, setAllSuggestedIdeas] = useState([
        "❤️📞 My Girlfriend's Mobile Number",
        "❤️👩 My Girlfriend's Name",
        "❤️🏠 My Girlfriend's Address",
        "🏠📍 My Home Address",
        "📞📱 My Mobile Number",
        "📧✉️ My Email Address",
        "🌐🔗 My Website URL",
        "👔🔗 My LinkedIn Profile",
        "💭✨ My Favorite Quote",
        "📡🔑 Wi-Fi Network: MyHomeWiFi; Pass: MySecretPass",
        "💰💳 UPI ID: myname@bank",
        "🎉🗓️ Event: Birthday Party, Date: 2025-12-25, Location: My House",
        "🛍️🛒 Product Link: https://www.google.com/search?q=example.com/product/xyz",
        "🗺️➡️ Directions: geo:34.0522,-118.2437?q=Los Angeles",
        "🤫✨ Secret Message: You are awesome!",
        "📇💼 My Business Card Info",
        "🎨💻 Link to my Portfolio",
        "👨‍💻🐙 My GitHub Repository",
        "🎶🎧 My Favorite Song on Spotify",
        "🤲💖 A Donation Link",
        "🚨📞 Emergency Contact: John Doe, 9876543210",
        "🏥🩸 Medical Info: Blood Type O+, Allergies: Penicillin",
        "🐾🆔 Pet's Microchip ID: 1234567890",
        "🍝📝 Favorite Recipe: Pasta Carbonara Ingredients",
        "📚💡 Book Recommendation: 'Dune' by Frank Herbert",
        "🎬🍿 Movie to Watch: 'Inception'",
        "🎮🆔 Game ID: PlayerOne#1234",
        "₿👛 Crypto Wallet Address (ETH): 0x...",
        "🖼️🔗 NFT Collection Link",
        "📜🔗 Smart Contract Address",
        "🗳️💡 DAO Proposal Link",
        "🔗✨ Web3 DApp URL",
        "🆔🌐 Decentralized Identity (DID)",
        "🔑🔒 My Public Key",
        "🗄️🔗 IPFS Hash of a Document",
        "⛓️✅ Blockchain Transaction ID",
        "🌌📍 Metaverse Coordinates: X:100, Y:200, Z:50",
        "👓🔗 VR Experience Link",
        "📸✨ AR Filter Link",
        "🎨🌐 Digital Art Gallery URL",
        "✅🗓️ Event RSVP Link",
        "📝💡 Feedback Form Link",
        "📊❓ Survey Link",
        "💬🤝 Customer Support Chat Link",
        "🍎⬇️ Download App Link (iOS)",
        "🤖⬇️ Download App Link (Android)",
        "📖🔧 Product Manual Link",
        "📄🛡️ Warranty Information",
        "↩️📜 Return Policy URL",
        "🏢📞 Company Contact Info",
        "💼✍️ Job Application Link",
        "📄⬇️ Resume Download Link",
        "🗓️🤝 Interview Schedule",
        "📅🎤 Conference Agenda",
        "🗣️📄 Speaker Bio Link",
        "✍️💡 Workshop Registration",
        "🍽️📜 Restaurant Menu",
        "🍽️🗓️ Table Reservation Link",
        "📦🚚 Delivery Order Tracking",
        "🎥🍳 Recipe Video Link",
        "💪🗓️ Workout Plan",
        "🥗🗓️ Diet Plan",
        "❤️‍🩹📊 Health Tracker Link",
        "🚨🚑 Emergency Services Number",
        "🐾🔍 Lost Pet Poster Link",
        "🔎📞 Found Item Contact",
        "📚💳 Public Library Card Number",
        "🏛️🖼️ Museum Exhibit Info",
        "🗽🗺️ Tourist Attraction Details",
        "🗓️🎉 Local Event Calendar",
        "🚌⏰ Public Transport Schedule",
        "🅿️📍 Parking Spot Locator",
        "🚗🤝 Car Share Booking Link",
        "🚲 rent Bike Rental Info",
        "🛴🔓 Scooter Share Unlock Code",
        "⚡📍 Charging Station Locator",
        "🔌🚗 Electric Vehicle Info",
        "♻️📍 Recycling Center Address",
        "🌱🗑️ Compost Drop-off Location",
        "💧💡 Water Conservation Tips",
        "💡💰 Energy Saving Advice",
        "🤝💖 Volunteer Opportunity",
        "🎁❤️ Charity Donation Link",
        "🧑‍🌾🥕 Community Garden Info",
        "🥕🗓️ Local Farmers Market Schedule",
        "🎨✍️ Art Class Registration",
        "🎶🗓️ Music Lesson Booking",
        "💃🗓️ Dance Studio Schedule",
        "🧘‍♀️🗓️ Yoga Class Info",
        "🏋️‍♀️🗓️ Fitness Class Booking",
        "⚽✍️ Sports League Sign-up",
        "🌳🗺️ Outdoor Activity Guide",
        "⛰️🗺️ Hiking Trail Map",
        "🏕️🗓️ Camping Site Reservation",
        "🎣📜 Fishing License Info",
        "🏹📜 Hunting License Info",
        "🚤📜 Boating Regulations",
        "⛷️❄️ Ski Resort Conditions",
        "🏂❄️ Snowboarding Park Info",
        "🏄‍♀️🌊 Surf Report",
        "🤿🐠 Scuba Diving Spot",
        "🪂🗓️ Paragliding Booking",
        "🎈🗓️ Hot Air Balloon Ride",
        "🪂✨ Skydiving Experience",
        "🌲🎢 Zipline Adventure",
        "🪢🤸 Bungee Jumping Spot",
        "🧗‍♀️📍 Rock Climbing Gym",
        "🔐🗓️ Escape Room Booking",
        "🎲☕ Board Game Cafe",
        "📚🗓️ Book Club Meeting Details",
        "🎤📜 Poetry Slam Event",
        "🎙️🗓️ Open Mic Night",
        "😂🎟️ Comedy Show Tickets",
        "🎭🗓️ Theater Play Schedule",
        "🎶🎟️ Concert Tickets",
        "🎨🗓️ Art Exhibition Info",
        "📸💡 Photography Workshop",
        "🍳✍️ Cooking Class Registration",
        "🍰📝 Baking Recipe",
        "🍹📝 Cocktail Recipe",
        "🍷🗓️ Wine Tasting Event",
        "🍺🏭 Beer Brewery Tour",
        "☕💳 Coffee Shop Loyalty Program",
        "🛍️🎨 Local Craft Market",
        "🛍️🕰️ Vintage Store Address",
        "👕♻️ Thrift Shop Location",
        "🏺🕰️ Antique Shop Info",
        "💿📍 Record Store Address",
        "📚🦸 Comic Book Store",
        "🎲🛍️ Board Game Store",
        "🛠️🛍️ Hobby Shop Inventory",
        "🔨💡 DIY Project Instructions",
        "🧑‍🌾💡 Gardening Tips",
        "🪴📖 Plant Care Guide",
        "💐🚚 Flower Shop Delivery",
        "🐾✂️ Pet Grooming Appointment",
        "🐶📞 Veterinarian Contact",
        "🐾❤️ Animal Shelter Donation",
        "🐕🌳 Dog Park Location",
        "🐈☕ Cat Cafe Details",
        "🐦🌳 Bird Watching Spot",
        "🦌🌳 Wildlife Sanctuary Info",
        "🐠🎟️ Aquarium Tickets",
        "🦁🎟️ Zoo Visit Booking",
        "🚜🗓️ Farm Tour Schedule",
        "🍎🗓️ Orchard Picking Season",
        "🍇🍷 Vineyard Tour & Tasting",
        "🛒🏷️ Local Market Deals",
        "💻💰 Online Store Discount Code",
        "🔑📺 Subscription Service Login",
        "💻🔑 Software License Key",
        "🎮⬇️ Game Download Code",
        "📚⬇️ E-book Download Link",
        "🎧📖 Audiobook Chapter List",
        "🎙️🔗 Podcast Series Link",
        "▶️🔗 YouTube Channel Link",
        "🎮🔴 Twitch Stream Link",
        "💬🎮 Discord Server Invite",
        "✈️💬 Telegram Group Link",
        "🟢💬 WhatsApp Group Invite",
        "🔒💬 Signal Group Link",
        "👍👥 Facebook Group Link",
        "📸👤 Instagram Profile",
        "🐦✍️ Twitter Handle",
        "🎵💃 TikTok Profile",
        "👻📸 Snapchat Username",
        "📌🖼️ Pinterest Board Link",
        "👽💬 Reddit Community",
        "❓💡 Quora Profile",
        "💻❓ Stack Overflow Profile",
        "✍️💻 Dev.to Article Link",
        "✍️📖 Medium Article Link",
        "✉️📰 Substack Newsletter",
        "💖🤝 Patreon Page",
        "☕💖 Ko-fi Link",
        "☕🎁 Buy Me a Coffee Link",
        "👕🛍️ Merchandise Store Link",
        "🎟️🗓️ Eventbrite Ticket Link",
        "💻🤝 Zoom Meeting ID",
        "💻💬 Google Meet Link",
        "💻📊 Microsoft Teams Meeting",
        "💻✍️ Webinar Registration",
        "🎓💻 Online Course Link",
        "🎥💡 Tutorial Video Link",
        "📄📖 Documentation Link",
        "🔗💻 API Endpoint URL",
        "⬆️💻 Software Update Link",
        "🐛📝 Bug Report Form",
        "✨📝 Feature Request Form",
        "🎫🤝 Support Ticket System",
        "📚💡 Knowledge Base Article",
        "❓📄 FAQ Page",
        "🛠️📖 Troubleshooting Guide",
        "📖🔧 User Manual",
        "🚀📖 Quick Start Guide",
        "⬇️🛠️ Installation Instructions",
        "💻✅ System Requirements",
        "✅🔗 Compatibility List",
        "📝✨ Release Notes",
        "📜🔄 Changelog",
        "🌳💻 Version Control Repository",
        "✅📊 Build Status Page",
        "🚀📊 Deployment Pipeline Status",
        "🖥️✅ Server Status Page",
        "🌐🗺️ Network Diagram",
        "🔒📜 Security Policy",
        "🕵️‍♀️📜 Privacy Policy",
        "📄🤝 Terms of Service",
        "🍪📜 Cookie Policy",
        "🇪🇺✅ GDPR Compliance Info",
        "♿📜 Accessibility Statement",
        "🗺️🌐 Sitemap",
        "🤖📄 Robots.txt Content",
        "💡💻 Open Source Project Page",
        "🤝📝 Contributor Guidelines",
        "🤝📜 Code of Conduct",
        "📜✅ License Information",
        "💰🐛 Bug Bounty Program",
        "🚨🔒 Security Vulnerability Report",
        "🛡️📊 Penetration Test Report",
        "✅📊 Compliance Audit Report",
        "🏆📜 Certification Details",
        "🏆✨ Awards and Recognition",
        "📰⬇️ Press Kit Download",
        "📞📰 Media Contact Info",
        "📈🤝 Investor Relations Page",
        "📊🗓️ Annual Report",
        "📞📈 Quarterly Earnings Call",
        "📈💰 Stock Information",
        "🧑‍💼👩‍💼 Board of Directors",
        "📜🕰️ Company History",
        "🎯✨ Mission Statement",
        "🔭✨ Vision Statement",
        "💖📜 Values Statement",
        "💼✨ Career Opportunities",
        "📖🧑‍💼 Employee Handbook",
        "📞👩‍💼 HR Contact Info",
        "💰🏥 Benefits Information",
        "📚💡 Training Resources",
        "📚🌐 Internal Wiki Link",
        "📊🛠️ Project Management Tool",
        "💬🤝 Team Communication Channel",
        "📝🗓️ Meeting Notes Link",
        "📁🤝 Shared Document Folder",
        "🗓️✍️ Time Off Request Form",
        "💰📝 Expense Report System",
        "🖥️🤝 IT Support Portal",
        "🏢🗺️ Office Location Map",
        "🅿️📝 Parking Instructions",
        "📡🔑 Visitor Wi-Fi Password",
        "🚨🗺️ Emergency Evacuation Plan",
        "🩹📍 First Aid Kit Location",
        "defibrillator AED Location",
        "🔥📍 Fire Extinguisher Location",
        "⚠️📜 Safety Guidelines",
        "🚪🔑 Building Access Code",
        "👮📞 Security Guard Contact",
        "🧹🗓️ Cleaning Schedule",
        "🔧📝 Maintenance Request Form",
        "📦📝 Supply Order Form",
        "☕📖 Coffee Machine Instructions",
        "🖨️📖 Printer Setup Guide",
        "🌐🛠️ Network Troubleshooting Steps",
        "💻⬇️ Software Installation Guide",
        "🔒🌐 VPN Connection Details",
        "🖥️🔗 Remote Desktop Access",
        "📞🤝 Help Desk Contact",
        "📝📊 Feedback Survey for Employees",
        "💡🗳️ Suggestion Box Link",
        "🗓️🎉 Company Event Calendar",
        "🤝🎉 Team Building Activity Info",
        "🎄🗓️ Holiday Schedule",
        "👔📜 Dress Code Policy",
        "✈️📜 Travel Policy",
        "💰📜 Expense Reimbursement Policy",
        "💻📊 IT Asset Management System",
        "💻📦 Software Inventory",
        "🖥️📦 Hardware Inventory",
        "🏷️📜 Asset Tagging Guidelines",
        "♻️💻 Disposal Procedures for Electronics",
        "💾🗓️ Data Backup Schedule",
        "🚨💾 Disaster Recovery Plan",
        "🚨📝 Incident Report Form",
        "🔄📜 Change Management Process",
        "📊📝 Project Plan Document",
        "✅📝 Task List for Project",
        "🏃‍♂️📝 Sprint Backlog",
        "📉📊 Burndown Chart Link",
        "📝💡 Retrospective Notes",
        "👥📜 Team Roster",
        "✅🧑‍💻 Onboarding Checklist",
        "✅👋 Offboarding Checklist",
        "📚🔗 Training Module Link",
        "🏆📊 Certification Tracking",
        "📝📈 Performance Review Form",
        "🎯📝 Goal Setting Worksheet",
        "🤝💡 Mentorship Program Info",
        "📈📚 Career Development Resources",
        "🌟👏 Employee Recognition Program",
        "🧘‍♀️💖 Wellness Program Details",
        "🧠💖 Mental Health Resources",
        "💪✍️ Fitness Challenge Sign-up",
        "🥗📖 Nutrition Guide",
        "🪑✅ Ergonomics Checklist",
        "🏠💻 Work From Home Policy",
        "🗓️✍️ Flexible Work Arrangement Request",
        "🚌💰 Commuter Benefits Info",
        "📰✍️ Company Newsletter Sign-up",
        "💼📢 Internal Job Postings",
        "🤝💰 Referral Program Details",
        "🌍🤝 Diversity & Inclusion Initiatives",
        "♻️📊 Sustainability Report",
        "🤝🌍 Corporate Social Responsibility",
        "📈📄 Investor Deck",
        "📰🗄️ Press Release Archive",
        "🎨📜 Brand Guidelines",
        "🖼️⬇️ Logo Download Page",
        "📚📈 Marketing Collateral Library",
        "📈📖 Sales Playbook",
        "🤝💻 Customer Relationship Management (CRM) Login",
        "📈📊 Sales Forecasting Dashboard",
        "✍️💡 Lead Generation Form",
        "🤝📜 Partnership Program Details",
        "🔗💰 Affiliate Program Info",
        "🤝✍️ Reseller Application",
        "🤝💻 Vendor Portal Login",
        "🛒📜 Procurement Policy",
        "🧾💻 Invoice Submission Portal",
        "💰✅ Payment Status Checker",
        "📊💰 Budget Tracking Spreadsheet",
        "📈📄 Financial Report Access",
        "📜📚 Legal Document Library",
        "📝🤝 Contract Review Request",
        "®️📜 Trademark Registration Info",
        "💡📜 Patent Application Status",
        "✅📚 Compliance Training Module",
        "⚠️📊 Risk Assessment Report",
        "🗓️🔎 Audit Schedule",
        "🔎📝 Internal Audit Findings",
        "📊📜 External Audit Report",
        "📜🔄 Regulatory Updates",
        "📏📖 Industry Standards Guide",
        "✨📖 Best Practices Document",
        "🔬🔗 Research Paper Link",
        "📊⬇️ Case Study Download",
        "📄💡 Whitepaper Access",
        "🎥💻 Webinar Recording",
        "🎧🔗 Podcast Series Link",
        "✍️📚 Blog Post Archive",
        "📰✨ News Article About Us",
        "🗣️🌟 Customer Testimonials",
        "⭐📝 Product Reviews",
        "💬🌐 User Forum Link",
        "🤝📜 Community Guidelines",
        "🛡️📜 Moderation Policy",
        "🚨📝 Report Abuse Form",
        "⚙️👤 Account Settings Page",
        "🔑🔄 Password Reset Link",
        "🔒📱 Two-Factor Authentication Setup",
        "🔔⚙️ Notification Preferences",
        "💳⚙️ Payment Methods Management",
        "📦📜 Order History",
        "🚚📍 Shipping Tracking",
        "↩️💰 Returns & Refunds Policy",
        "💖🛍️ Wishlist Link",
        "🛒🛍️ Shopping Cart Link",
        "📚🛍️ Product Catalog",
        "🗓️🤝 Service Booking Page",
        "🗓️✍️ Appointment Scheduling",
        "🗓️📚 Class Schedule",
        "🗓️🎉 Event Calendar",
        "🎟️🛍️ Ticket Purchase Link",
        "🗺️📍 Venue Map",
        "💺🗺️ Seating Chart",
        "➡️📍 Directions to Venue",
        "🅿️📝 Parking Information",
        "🚌🚊 Public Transport Options",
        "🏨🗓️ Hotel Booking Link",
        "✈️🗓️ Flight Information",
        "🚗🗓️ Car Rental Booking",
        "✈️🛡️ Travel Insurance Info",
        "🛂📖 Passport Renewal Guide",
        "🛂📝 Visa Application Requirements",
        "💱📊 Currency Exchange Rates",
        "🌍🤝 Local Customs Guide",
        "⚠️✈️ Travel Advisory Updates",
        "🚨📞 Emergency Travel Contacts",
        "🧳📝 Lost Luggage Report",
        "🗺️🗓️ Travel Itinerary",
        "✅🧳 Packing Checklist",
        "🏥✈️ Travel Health Information",
        "💉✅ Vaccination Requirements",
        "🛡️✈️ Travel Safety Tips",
        "🍽️🗺️ Local Cuisine Guide",
        "🍽️⭐ Restaurant Recommendations",
        "☕🗺️ Cafe Directory",
        "🍻🗺️ Bar & Pub Guide",
        "🌃🎉 Nightlife Events",
        "🛍️🗺️ Shopping Districts",
        "🛒🗺️ Local Markets",
        "🎁🗺️ Souvenir Shop Locations",
        "🏛️🖼️ Museums & Galleries",
        "📜🏛️ Historical Sites",
        "🌳🌷 Parks & Gardens",
        "🏖️🌊 Beaches & Lakes",
        "⛰️🚲 Hiking & Biking Trails",
        "🏟️⚽ Sports Facilities",
        "🎤🏟️ Concert Venues",
        "🎭📍 Theater & Performance Spaces",
        "🎬⏰ Cinema Showtimes",
        "📚📍 Library Branches",
        "✉️📍 Post Office Locations",
        "🏦🏧 Bank & ATM Locations",
        "💊🗺️ Pharmacy Directory",
        "🏥🗺️ Hospital & Clinic Finder",
        "🚓📞 Police Station Contact",
        "🚒📞 Fire Station Contact",
        "🏢🌍 Embassy/Consulate Info",
        "🏛️🤝 Local Government Services",
        "🗓️🎉 Public Holidays Calendar",
        "🏫📚 School Directory",
        "🎓📚 University Course Catalog",
        "👶🏠 Childcare Services",
        "👵🏠 Elderly Care Resources",
        "♿🤝 Disability Support Services",
        "⚖️🤝 Legal Aid Services",
        "💰🤝 Financial Advisor Contact",
        "🛡️📞 Insurance Agent Info",
        "🏠📞 Real Estate Agent Contact",
        "📦✅ Moving Checklist",
        "💡📞 Utility Provider Contacts",
        "🌐📞 Internet Service Provider Info",
        "📺📞 Cable TV Provider Info",
        "🗑️🗓️ Waste Collection Schedule",
        "♻️📜 Recycling Guidelines",
        "🛋️📝 Bulk Item Pickup Request",
        "🧹🗓️ Street Cleaning Schedule",
        "🤫📝 Noise Complaint Form",
        "🔎📝 Lost & Found Reporting",
        "👀🏠 Neighborhood Watch Info",
        "🗓️🎉 Community Events Calendar",
        "📰🌐 Local News Feed",
        "☀️☁️ Weather Forecast Link",
        "🚦🚗 Traffic Updates",
        "🚨📢 Public Safety Alerts",
        "🛡️💡 Crime Prevention Tips",
        "🚨📖 Emergency Preparedness Guide",
        "🆘🤝 Disaster Relief Resources",
        "🤝💖 Volunteer Opportunities",
        "💖🏢 Charitable Organizations",
        "🍎🥫 Food Bank Locations",
        "🏠🤝 Homeless Shelter Info",
        "🐾❤️ Animal Rescue Groups",
        "🌳🛡️ Environmental Protection Agencies",
        "🌱🤝 Conservation Programs",
        "☀️⚡ Renewable Energy Initiatives",
        "♻️🏠 Sustainable Living Tips",
        "🌱🏢 Green Building Certifications",
        "♻️🛍️ Eco-Friendly Product List",
        "🤝🛍️ Fair Trade Product Info",
        "📜🤝 Ethical Sourcing Policy",
        "Rights🤝 Human Rights Organizations",
        "⚖️🤝 Social Justice Initiatives",
        "🧠📞 Mental Health Support Hotlines",
        "🚨🤝 Crisis Intervention Services",
        "🚭🤝 Addiction Recovery Resources",
        "🤝💬 Support Groups Directory",
        "🛋️🔎 Therapist/Counselor Finder",
        "🧘‍♀️💡 Stress Management Techniques",
        "🧘‍♂️✨ Mindfulness Exercises",
        "🧘‍♀️📱 Meditation Apps",
        "😴💡 Sleep Hygiene Tips",
        "🍎📖 Healthy Eating Guide",
        "💪🗓️ Exercise Routines",
        "🏋️‍♀️📞 Personal Trainer Contact",
        "🏋️‍♀️💳 Gym Membership Info",
        "⚽🗓️ Sports Team Schedule",
        "🎟️🏟️ Game Tickets Purchase",
        "fanatic Fan Club Registration",
        "👕🛍️ Team Merchandise Store",
        "📊⛹️ Player Statistics",
        "🏆📊 League Standings",
        "🎥⚽ Match Highlights Video",
        "📰⚽ Sports News Feed",
        "🎮🏆 Fantasy Sports League",
        "🎲💰 Betting Odds",
        "🍻📍 Sports Bar Locator",
        "🏟️🗓️ Stadium Tour Booking",
        "🏅👤 Athlete Bio",
        "🧑‍🏫👥 Coaching Staff Directory",
        "📜🏆 Team History",
        "🏆✨ Hall of Fame Inductees",
        "🖼️💰 Memorabilia Auction",
        "✍️🗓️ Autograph Session Details",
        "🤝🎉 Fan Meetup Info",
        "🎟️🌟 Season Ticket Holder Benefits",
        "✨🎟️ VIP Experience Packages",
        "🤝💰 Sponsorship Opportunities",
        "📰✍️ Media Accreditation Form",
        "🎤🗓️ Press Conference Schedule",
        "🎙️🤝 Post-Game Interview Access",
        "🔄👥 Team Roster Changes",
        "🩹📊 Injury Report",
        "🔄💬 Trade Rumors",
        "📈💡 Draft Pick Analysis",
        "🔎📝 Scouting Reports",
        "👶⚽ Youth Sports Programs",
        "🧑‍🏫🏆 Coaching Certification Courses",
        "⚖️🏆 Referee Training Programs",
        "🛍️⚽ Sports Equipment Store",
        "👕🛍️ Sports Apparel Shop",
        "💊💪 Nutritional Supplements Info",
        "🏥🩹 Sports Injury Clinic",
        "🚶‍♀️🩹 Physical Therapy Services",
        "🧠💪 Sports Psychology Resources",
        "📈🧑‍🏫 Performance Coaching",
        "🏅✍️ Athlete Sponsorship Application",
        "🎓💰 Sports Scholarship Info",
        "🔬💪 Sports Science Research",
        "🔬🚶 Biomechanics Lab Access",
        "📊💻 Sports Analytics Tools",
        "⌚💪 Wearable Tech for Athletes",
        "😴🩹 Recovery Techniques",
        "💧💡 Hydration Guidelines",
        "😴✨ Sleep Optimization Tips",
        "💪⏰ Pre-Workout Routine",
        "🍽️💪 Post-Workout Meal Ideas",
        "🛡️💪 Injury Prevention Exercises",
        "🔥💪 Warm-up Drills",
        "🌬️🧘 Cool-down Stretches",
        "🔄💪 Cross-Training Ideas",
        "🏋️‍♀️🗓️ Strength Training Program",
        "🏃‍♀️🗓️ Cardio Workout Plan",
        "🤸‍♀️🧘 Flexibility Exercises",
        "⚖️🤸 Balance Training Drills",
        "⚡🏃 Agility Training Drills",
        "💨🏃 Speed Training Workouts",
        "wytrwalosc Endurance Training Tips",
        "💥💪 Plyometric Exercises",
        "💪🧘 Core Strength Workouts",
        "💪⬆️ Upper Body Workout",
        "💪⬇️ Lower Body Workout",
        "💪🌐 Full Body Workout",
        "😴🌳 Rest Day Activities",
        "🚶‍♀️🩹 Active Recovery Ideas",
        "🧘‍♀️🤸 Stretching Routine",
        "roll Foam Rolling Techniques",
        "💆‍♀️🗓️ Massage Therapy Booking",
        "❄️🩹 Cryotherapy Benefits",
        "🧖‍♀️🔥 Sauna Session Info",
        "💧🩹 Hydrotherapy Benefits",
        "📍🩹 Acupuncture Clinic",
        "🦴📞 Chiropractor Contact",
        "🚶‍♀️📞 Physical Therapist Contact",
        "🏥📞 Sports Doctor Contact",
        "🥗📞 Dietitian Consultation",
        "🍎📞 Sports Nutritionist",
        "🧠🧑‍🏫 Mental Performance Coach",
        "🧠📞 Sports Psychologist",
        "🧘‍♀️💪 Yoga for Athletes",
        "🤸‍♀️💪 Pilates for Core Strength",
        "🏋️‍♀️🗓️ CrossFit WODs",
        "⏱️💪 HIIT Workout Examples",
        "⏱️🏋️‍♀️ Tabata Training Guide",
        "🔄💪 Circuit Training Ideas",
        "🤸‍♀️💪 Bodyweight Exercises",
        "elastic Resistance Band Workouts",
        "kettlebell Kettlebell Training",
        "dumbbell Dumbbell Exercises",
        "barbell Barbell Workouts",
        "⚙️💪 Gym Machine Guide",
        "🌳💪 Outdoor Workout Spots",
        "🏃‍♀️🗺️ Running Routes",
        "🚲🗺️ Cycling Trails",
        "🏊‍♀️🗓️ Swimming Pool Schedule",
        "🏀📍 Basketball Court Locator",
        "🎾🗓️ Tennis Court Booking",
        "🏐📍 Volleyball Court Info",
        "🏸🗓️ Badminton Court Booking",
        "squash Squash Court Booking",
        "🏓📍 Table Tennis Club",
        "🎳📍 Bowling Alley Info",
        "⛸️📍 Ice Skating Rink",
        "🛼📍 Roller Skating Rink",
        "🛹📍 Skate Park Location",
        "🧗‍♀️📍 Climbing Wall Gym",
        "🧗‍♂️📍 Bouldering Gym",
        "🥋📍 Martial Arts Dojo",
        "🥊📍 Boxing Gym",
        "🤺📍 Fencing Club",
        "🏹📍 Archery Range",
        "🔫📍 Shooting Range",
        "⛳🗓️ Golf Course Booking",
        "⛳📍 Mini Golf Course",
        "🏌️‍♂️📍 Driving Range",
        "🐎🗓️ Horse Riding Lessons",
        "🐎📍 Equestrian Center"
    ]);
    // No need for isFetchingIdeas state or useEffect for fetching ideas anymore
    const [isFetchingIdeas, setIsFetchingIdeas] = useState(false); 

    const qrCanvasRef = useRef(null);
    const styleCanvasRefs = useRef(Array(12).fill(null));

    // Define QR code styles (remains in App as it's static data used by QRGeneratorTab)
    const qrStyles = [
        { name: "Classic", fg: "#FFFFFF" }, // Changed to white for visibility
        { name: "Neon Green", fg: "#39FF14" }, // Vibrant Neon Green
        { name: "Electric Blue", fg: "#00BFFF" }, // Bright Sky Blue
        { name: "Radiant Pink", fg: "#FF007F" }, // Hot Pink
        { name: "Cyber Purple", fg: "#BF00FF" }, // Bright Purple
        { name: "Gold Spark", fg: "#FFD700" }, // Gold
        { name: "Aqua Glow", fg: "#00FFFF" }, // Cyan (default)
        { name: "Fire Orange", fg: "#FF4500" }, // Orange-Red
        { name: "Lava Red", fg: "#FF2400" }, // Bright Red
        { name: "Lime Zing", fg: "#7FFF00" }, // Chartreuse
        { name: "Deep Teal", fg: "#008080" }, // Teal
        { name: "Violet Ray", fg: "#8A2BE2" }, // Blue-Violet
        { name: "Emerald", fg: "#00C957" }, // Deep Green
        { name: "Sapphire", fg: "#082567" }, // Deep Blue
        { name: "Ruby", fg: "#E0115F" }, // Deep Red
        { name: "Amethyst", fg: "#9966CC" }, // Medium Purple
        { name: "Sunshine", fg: "#FFD300" }, // Bright Yellow
        { name: "Ocean Wave", fg: "#007FFF" }, // Medium Blue
        { name: "Forest Mist", fg: "#A8C3BC" }, // Light Greenish-Gray
        { name: "Crimson Tide", fg: "#DC143C" }, // Crimson
        { name: "Midnight Blue", fg: "#191970" }, // Dark Blue
        { name: "Rose Gold", fg: "#B76E79" }, // Rose Gold
        { name: "Spring Green", fg: "#00FF7F" }, // Spring Green
        { name: "Royal Purple", fg: "#7851A9" }, // Royal Purple
        { name: "Azure", fg: "#007FFF" }, // Azure Blue
        { name: "Coral", fg: "#FF7F50" }, // Coral Orange
        { name: "Mint Green", fg: "#98FF98" }, // Light Mint Green
        { name: "Lavender", fg: "#E6E6FA" }, // Light Lavender
        { name: "Chocolate", fg: "#D2691E" }, // Chocolate Brown
        { name: "Silver", fg: "#C0C0C0" }, // Silver
        { name: "Bronze", fg: "#CD7F32" }, // Bronze
        { name: "Copper", fg: "#B87333" }, // Copper
        { name: "Plum", fg: "#8E4585" }, // Plum Purple
        { name: "Olive", fg: "#808000" }, // Olive Green
        { name: "Maroon", fg: "#800000" }, // Maroon Red
        { name: "Teal Blue", fg: "#367588" }, // Teal Blue
        { name: "Sky Blue", fg: "#87CEEB" }, // Sky Blue
        { name: "Slate Gray", fg: "#708090" }, // Slate Gray
        { name: "Dark Green", fg: "#006400" }, // Dark Green
        { name: "Dark Red", fg: "#8B0000" }, // Dark Red
        { name: "Dark Blue", fg: "#00008B" }, // Dark Blue
        { name: "Dark Cyan", fg: "#008B8B" }, // Dark Cyan
        { name: "Dark Magenta", fg: "#8B008B" }, // Dark Magenta
        { name: "Dark Yellow", fg: "#8B8B00" }, // Dark Yellow
        { name: "Light Gray", fg: "#D3D3D3" }, // Light Gray
        { name: "Light Blue", fg: "#ADD8E6" }, // Light Blue
        { name: "Light Green", fg: "#90EE90" }, // Light Green
        { name: "Light Pink", fg: "#FFB6C1" }, // Light Pink
        { name: "Light Yellow", fg: "#FFFFE0" }, // Light Yellow
        { name: "Pale Green", fg: "#98FB98" }, // Pale Green
        { name: "Pale Blue", fg: "#AFEEEE" }, // Pale Blue
        { name: "Pale Red", fg: "#F08080" }, // Pale Red
        { name: "Pale Yellow", fg: "#FFFF99" }, // Pale Yellow
        { name: "Deep Orange", fg: "#FF6600" }, // Deep Orange
        { name: "Deep Pink", fg: "#FF1493" }, // Deep Pink
        { name: "Deep Purple", fg: "#800080" }, // Deep Purple
        { name: "Deep Sky Blue", fg: "#00BFFF" }, // Deep Sky Blue
        { name: "Medium Sea Green", fg: "#3CB371" }, // Medium Sea Green
        { name: "Medium Slate Blue", fg: "#7B68EE" }, // Medium Slate Blue
        { name: "Medium Spring Green", fg: "#00FA9A" }, // Medium Spring Green
        { name: "Medium Turquoise", fg: "#48D1CC" }, // Medium Turquoise
        { name: "Medium Violet Red", fg: "#C71585" }, // Medium Violet Red
        { name: "Dark Goldenrod", fg: "#B8860B" }, // Dark Goldenrod
        { name: "Dark Orchid", fg: "#9932CC" }, // Dark Orchid
        { name: "Dark Salmon", fg: "#E9967A" }, // Dark Salmon
        { name: "Dark Sea Green", fg: "#8FBC8F" }, // Dark Sea Green
        { name: "Dark Slate Blue", fg: "#483D8B" }, // Dark Slate Blue
        { name: "Dark Slate Gray", fg: "#2F4F4F" }, // Dark Slate Gray
        { name: "Dark Turquoise", fg: "#00CED1" }, // Dark Turquoise
        { name: "Dark Violet", fg: "#9400D3" }, // Dark Violet
        { name: "Light Coral", fg: "#F08080" }, // Light Coral
        { name: "Light Cyan", fg: "#E0FFFF" }, // Light Cyan
        { name: "Light Goldenrod Yellow", fg: "#FAFAD2" }, // Light Goldenrod Yellow
        { name: "Light Green", fg: "#90EE90" }, // Light Green
        { name: "Light Pink", fg: "#FFB6C1" }, // Light Pink
        { name: "Light Salmon", fg: "#FFA07A" }, // Light Salmon
        { name: "Light Sea Green", fg: "#20B2AA" }, // Light Sea Green
        { name: "Light Sky Blue", fg: "#87CEFA" }, // Light Sky Blue
        { name: "Light Slate Gray", fg: "#778899" }, // Light Slate Gray
        { name: "Light Steel Blue", fg: "#B0C4DE" }, // Light Steel Blue
        { name: "Light Yellow", fg: "#FFFFE0" }, // Light Yellow
        { name: "Hot Pink", fg: "#FF69B4" }, // Hot Pink
        { name: "Indian Red", fg: "#CD5C5C" }, // Indian Red
        { name: "Indigo", fg: "#4B0082" }, // Indigo
        { name: "Khaki", fg: "#F0E68C" }, // Khaki
        { name: "Lavender Blush", fg: "#FFF0F5" }, // Lavender Blush
        { name: "Lemon Chiffon", fg: "#FFFACD" }, // Lemon Chiffon
        { name: "Lime Green", fg: "#32CD32" }, // Lime Green
        { name: "Linen", fg: "#FAF0E6" }, // Linen
        { name: "Medium Aqua Marine", fg: "#66CDAA" }, // Medium Aqua Marine
        { name: "Medium Blue", fg: "#0000CD" }, // Medium Blue
        { name: "Medium Orchid", fg: "#BA55D3" }, // Medium Orchid
        { name: "Medium Purple", fg: "#9370DB" }, // Medium Purple
        { name: "Medium Violet Red", fg: "#C71585" }, // Medium Violet Red
        { name: "Misty Rose", fg: "#FFE4E1" }, // Misty Rose
        { name: "Moccasin", fg: "#FFE4B5" }, // Moccasin
        { name: "Navajo White", fg: "#FFDEAD" }, // Navajo White
        { name: "Old Lace", fg: "#FDF5E6" }, // Old Lace
        { name: "Olive Drab", fg: "#6B8E23" }, // Olive Drab
        { name: "Orange Red", fg: "#FF4500" }, // Orange Red
        { name: "Orchid", fg: "#DA70D6" }, // Orchid
        { name: "Pale Goldenrod", fg: "#EEE8AA" }, // Pale Goldenrod
        { name: "Pale Turquoise", fg: "#AFEEEE" }, // Pale Turquoise
        { name: "Pale Violet Red", fg: "#DB7093" }, // Pale Violet Red
        { name: "Papaya Whip", fg: "#FFEFD5" }, // Papaya Whip
        { name: "Peach Puff", fg: "#FFDAB9" }, // Peach Puff
        { name: "Peru", fg: "#CD853F" }, // Peru
        { name: "Pink", fg: "#FFC0CB" }, // Pink
        { name: "Plum", fg: "#DDA0DD" }, // Plum
        { name: "Powder Blue", fg: "#B0E0E6" }, // Powder Blue
        { name: "Rosy Brown", fg: "#BC8F8F" }, // Rosy Brown
        { name: "Royal Blue", fg: "#4169E1" }, // Royal Blue
        { name: "Saddle Brown", fg: "#8B4513" }, // Saddle Brown
        { name: "Salmon", fg: "#FA8072" }, // Salmon
        { name: "Sandy Brown", fg: "#F4A460" }, // Sandy Brown
        { name: "Sea Green", fg: "#2E8B57" }, // Sea Green
        { name: "Sea Shell", fg: "#FFF5EE" }, // Sea Shell
        { name: "Sienna", fg: "#A0522D" }, // Sienna
        { name: "Sky Blue", fg: "#87CEEB" }, // Sky Blue
        { name: "Slate Blue", fg: "#6A5ACD" }, // Slate Blue
        { name: "Slate Gray", fg: "#708090" }, // Slate Gray
        { name: "Snow", fg: "#FFFAFA" }, // Snow
        { name: "Spring Green", fg: "#00FF7F" }, // Spring Green
        { name: "Steel Blue", fg: "#4682B4" }, // Steel Blue
        { name: "Tan", fg: "#D2B48C" }, // Tan
        { name: "Thistle", fg: "#D8BFD8" }, // Thistle
        { name: "Tomato", fg: "#FF6347" }, // Tomato
        { name: "Turquoise", fg: "#40E0D0" }, // Turquoise
        { name: "Violet", fg: "#EE82EE" }, // Violet
        { name: "Wheat", fg: "#F5DEB3" }, // Wheat
        { name: "White Smoke", fg: "#F5F5F5" }, // White Smoke
        { name: "Yellow Green", fg: "#9ACD32" }, // Yellow Green
    ];

    // Define themes (remains in App)
    const themes = {
        dark: {
            // Deeper, more consistent dark background
            bg: 'bg-gradient-to-br from-[#050505] via-[#100515] to-[#050505] animate-gradient-shift', 
            text: 'text-gray-100',
            // More vibrant neon accents
            primaryAccent: 'from-cyan-500 to-blue-600', 
            secondaryAccent: 'from-fuchsia-500 to-purple-600', 
            glassBg: 'bg-white/5 backdrop-blur-3xl',
            glassBorder: 'border-white/10',
            shadow: 'shadow-blue-500/20',
            glow: 'shadow-lg shadow-cyan-400/40', // Stronger neon glow
            buttonGlow: 'hover:shadow-xl hover:shadow-cyan-300/50', // Stronger button glow
            success: 'text-green-400',
            alert: 'text-pink-500',
            inputBg: 'bg-white/5',
            inputBorder: 'border-white/10',
            tabActive: 'bg-white/10 border-cyan-500 shadow-lg shadow-cyan-500/20', // Neon active tab
            tabInactive: 'bg-transparent border-transparent',
            cardBg: 'bg-white/5 backdrop-blur-md',
            cardBorder: 'border-white/10',
            // Ensure QR preview background is very dark for neon contrast
            qrPreviewBorder: 'border-cyan-500/50', 
            qrPreviewBg: 'bg-gradient-to-br from-gray-950/40 to-gray-900/40 backdrop-blur-md', 
            headerGlow: 'animate-quantum-flux' 
        },
        light: {
            bg: 'bg-gradient-to-br from-[#F8F8F8] via-[#E8E8E8] to-[#F8F8F8] animate-gradient-shift-light',
            text: 'text-gray-800',
            primaryAccent: 'from-blue-400 to-purple-500',
            secondaryAccent: 'from-cyan-300 to-teal-400',
            glassBg: 'bg-white/80 backdrop-blur-3xl',
            glassBorder: 'border-gray-200',
            shadow: 'shadow-gray-400/20',
            glow: 'shadow-lg shadow-blue-300/40',
            buttonGlow: 'hover:shadow-xl hover:shadow-blue-300/50',
            success: 'text-green-600',
            alert: 'text-red-600',
            inputBg: 'bg-white/90',
            inputBorder: 'border-gray-300',
            tabActive: 'bg-white/90 border-blue-500 shadow-lg shadow-blue-300/20',
            tabInactive: 'bg-transparent border-transparent',
            cardBg: 'bg-white/90 backdrop-blur-md',
            cardBorder: 'border-gray-200',
            qrPreviewBorder: 'border-blue-400/50',
            qrPreviewBg: 'bg-gradient-to-br from-gray-100/60 to-gray-200/60 backdrop-blur-md',
            headerGlow: 'animate-quantum-flux-light' 
        },
        'forest-green': {
            bg: 'bg-gradient-to-br from-[#0A2A1A] via-[#1A4A3A] to-[#0A3A2A] animate-gradient-shift',
            text: 'text-white',
            primaryAccent: 'from-green-500 to-emerald-600',
            secondaryAccent: 'from-lime-400 to-green-500',
            glassBg: 'bg-green-900/40 backdrop-blur-3xl',
            glassBorder: 'border-green-800/20',
            shadow: 'shadow-green-500/20',
            glow: 'shadow-lg shadow-green-500/40',
            buttonGlow: 'hover:shadow-xl hover:shadow-green-400/50',
            success: 'text-lime-400',
            alert: 'text-red-400',
            inputBg: 'bg-green-950/30',
            inputBorder: 'border-green-900/15',
            tabActive: 'bg-green-800/20 border-green-500 shadow-lg shadow-green-500/20',
            tabInactive: 'bg-transparent border-transparent',
            cardBg: 'bg-green-950/30 backdrop-blur-md',
            cardBorder: 'border-green-900/15',
            qrPreviewBorder: 'border-green-500/50',
            qrPreviewBg: 'bg-gradient-to-br from-green-900/30 to-green-800/30 backdrop-blur-md',
            headerGlow: 'animate-quantum-flux'
        },
        'ocean-blue': {
            bg: 'bg-gradient-to-br from-[#001A33] via-[#003366] to-[#002A5A] animate-gradient-shift',
            text: 'text-white',
            primaryAccent: 'from-blue-600 to-indigo-700',
            secondaryAccent: 'from-sky-400 to-cyan-500',
            glassBg: 'bg-blue-900/40 backdrop-blur-3xl',
            glassBorder: 'border-blue-800/20',
            shadow: 'shadow-blue-600/20',
            glow: 'shadow-lg shadow-blue-600/40',
            buttonGlow: 'hover:shadow-xl hover:hover:shadow-blue-500/50',
            success: 'text-sky-400',
            alert: 'text-red-400',
            inputBg: 'bg-blue-950/30',
            inputBorder: 'border-blue-900/15',
            tabActive: 'bg-blue-800/20 border-blue-500 shadow-lg shadow-blue-600/20',
            tabInactive: 'bg-transparent border-transparent',
            cardBg: 'bg-blue-950/30 backdrop-blur-md',
            cardBorder: 'border-blue-900/15',
            qrPreviewBorder: 'border-blue-600/50',
            qrPreviewBg: 'bg-gradient-to-br from-blue-950/30 to-blue-900/30 backdrop-blur-md',
            headerGlow: 'animate-quantum-flux'
        },
        'warm-grey': {
            bg: 'bg-gradient-to-br from-[#202020] via-[#404040] to-[#303030] animate-gradient-shift',
            text: 'text-gray-100',
            primaryAccent: 'from-gray-500 to-gray-700',
            secondaryAccent: 'from-yellow-400 to-orange-500',
            glassBg: 'bg-gray-700/40 backdrop-blur-3xl',
            glassBorder: 'border-gray-600/20',
            shadow: 'shadow-gray-500/20',
            glow: 'shadow-lg shadow-gray-500/40',
            buttonGlow: 'hover:shadow-xl hover:shadow-gray-400/50',
            success: 'text-lime-400',
            alert: 'text-red-400',
            inputBg: 'bg-gray-800/30',
            inputBorder: 'border-gray-700/15',
            tabActive: 'bg-gray-600/20 border-gray-500 shadow-lg shadow-gray-500/20',
            tabInactive: 'bg-transparent border-transparent',
            cardBg: 'bg-gray-800/30 backdrop-blur-md',
            cardBorder: 'border-gray-700/15',
            qrPreviewBorder: 'border-gray-500/50',
            qrPreviewBg: 'bg-gradient-to-br from-gray-800/30 to-gray-700/30 backdrop-blur-md',
            headerGlow: 'animate-quantum-flux'
        },
        'deep-purple': {
            bg: 'bg-gradient-to-br from-[#100830] via-[#201040] to-[#180C38] animate-gradient-shift',
            text: 'text-white',
            primaryAccent: 'from-purple-600 to-fuchsia-700',
            secondaryAccent: 'from-pink-400 to-purple-500',
            glassBg: 'bg-purple-900/40 backdrop-blur-3xl',
            glassBorder: 'border-purple-800/20',
            shadow: 'shadow-purple-600/20',
            glow: 'shadow-lg shadow-purple-600/40',
            buttonGlow: 'hover:shadow-xl hover:hover:shadow-purple-500/50',
            success: 'text-lime-400',
            alert: 'text-red-400',
            inputBg: 'bg-purple-950/30',
            inputBorder: 'border-purple-900/15',
            tabActive: 'bg-purple-800/20 border-purple-500 shadow-lg shadow-purple-600/20',
            tabInactive: 'bg-transparent border-transparent',
            cardBg: 'bg-purple-950/30 backdrop-blur-md',
            cardBorder: 'border-purple-900/15',
            qrPreviewBorder: 'border-purple-600/50',
            qrPreviewBg: 'bg-gradient-to-br from-purple-950/30 to-purple-900/30 backdrop-blur-md',
            headerGlow: 'animate-quantum-flux'
        },
        'sunrise-orange': {
            bg: 'bg-gradient-to-br from-[#A0300A] via-[#D0501A] to-[#B84012] animate-gradient-shift',
            text: 'text-white',
            primaryAccent: 'from-orange-600 to-red-700',
            secondaryAccent: 'from-yellow-400 to-orange-500',
            glassBg: 'bg-orange-800/40 backdrop-blur-3xl',
            glassBorder: 'border-orange-700/20',
            shadow: 'shadow-orange-600/20',
            glow: 'shadow-lg shadow-orange-600/40',
            buttonGlow: 'hover:shadow-xl hover:hover:shadow-orange-500/50',
            success: 'text-lime-400',
            alert: 'text-red-400',
            inputBg: 'bg-orange-900/30',
            inputBorder: 'border-orange-800/15',
            tabActive: 'bg-orange-700/20 border-orange-500 shadow-lg shadow-orange-600/20',
            tabInactive: 'bg-transparent border-transparent',
            cardBg: 'bg-orange-900/30 backdrop-blur-md',
            cardBorder: 'border-orange-800/15',
            qrPreviewBorder: 'border-orange-600/50',
            qrPreviewBg: 'bg-gradient-to-br from-orange-900/30 to-orange-800/30 backdrop-blur-md',
            headerGlow: 'animate-quantum-flux'
        },
    };

    const currentThemeClasses = themes[currentTheme];

    // Function to show custom alert
    const showAlert = (message) => {
        setAlertMessage(message);
    };

    // Callback to generate QR code on a given canvas
    // Added a new parameter `lightColorOverride` to explicitly set the light module color
    const drawQrCode = useCallback((canvas, text, color, errorLevel, size = 256, lightColorOverride = null) => {
        if (!canvas) {
            console.warn("Canvas element is null, cannot draw QR code.");
            return;
        }
        if (!QRCode) {
            console.error("QRCode library is not loaded.");
            const context = canvas.getContext('2d');
            context.clearRect(0, 0, canvas.width, canvas.height);
            context.fillStyle = 'red';
            context.font = '10px Arial';
            context.fillText('QR Lib Error', 10, 20);
            return;
        }

        const context = canvas.getContext('2d');
        context.clearRect(0, 0, canvas.width, canvas.height);

        // Determine the light module color: white if QR color is black, otherwise black
        const effectiveLightColor = lightColorOverride || (color === '#000000' ? '#FFFFFF' : '#000000');

        if (text.trim() !== '') {
            QRCode.toCanvas(canvas, text, {
                errorCorrectionLevel: errorLevel,
                width: size,
                color: {
                    dark: color,
                    light: effectiveLightColor // Use the determined light color
                }
            }, function (error) {
                if (error) console.error("QR Code drawing error:", error);
            });
        }
    }, []);

    // Function to download the generated QR code
    const downloadQrCode = () => {
        if (content.trim() === '') {
            showAlert('Please enter content to generate QR code.');
            return;
        }

        // Create a temporary canvas for high-resolution download
        const tempCanvas = document.createElement('canvas');
        tempCanvas.width = downloadResolution;
        tempCanvas.height = downloadResolution;

        // Determine the light module color for download: white if QR color is black, otherwise black
        const effectiveLightColorForDownload = qrColor === '#000000' ? '#FFFFFF' : '#000000';

        QRCode.toCanvas(tempCanvas, content, {
            errorCorrectionLevel: errorLevel,
            width: downloadResolution,
            color: {
                dark: qrColor,
                light: effectiveLightColorForDownload // Use the determined light color for download
            }
        }, function (error) {
            if (error) console.error("QR Code drawing error for download:", error);
            const pngUrl = tempCanvas.toDataURL("image/png");
            const downloadLink = document.createElement('a');
            downloadLink.href = pngUrl;
            downloadLink.download = `qrcode_${downloadResolution}x${downloadResolution}.png`;
            document.body.appendChild(downloadLink);
            downloadLink.click();
            document.body.removeChild(downloadLink);
            showAlert(`QR Code saved as ${downloadResolution}x${downloadResolution} PNG!`);
        });
    };

    // Function to decode QR code from an uploaded image
    const decodeQrCode = (event) => {
        const file = event.target.files[0];
        if (!file) return;

        const reader = new FileReader();
        reader.onload = (e) => {
            const img = new Image();
            img.onload = () => {
                const canvas = document.createElement('canvas');
                const context = canvas.getContext('2d');
                canvas.width = img.width;
                canvas.height = img.height;
                context.drawImage(img, 0, 0, img.width, img.height);

                const imageData = context.getImageData(0, 0, canvas.width, canvas.height);

                // Use jsqr (lowercase) here
                if (jsqr) {
                    let code = jsqr(imageData.data, imageData.width, imageData.height);

                    if (!code) {
                        // Attempt to invert colors and try again
                        for (let i = 0; i < imageData.data.length; i += 4) {
                            imageData.data[i] = 255 - imageData.data[i];
                            imageData.data[i + 1] = 255 - imageData.data[i + 1];
                            imageData.data[i + 2] = 255 - imageData.data[i + 2];
                        }
                        code = jsqr(imageData.data, imageData.width, imageData.height);
                    }

                    if (code) {
                        setDecodedContent(code.data);
                        setSuggestedIdea(''); // Clear previous suggestions when new QR is decoded
                        setShowSuggestedIdea(false);
                    } else {
                        setDecodedContent('No QR code detected.');
                        setSuggestedIdea('');
                        setShowSuggestedIdea(false);
                    }
                } else {
                    showAlert('QR decoder library (jsqr) not loaded. Please try again or check internet connection.');
                    setSuggestedIdea('');
                    setShowSuggestedIdea(false);
                }
            };
            img.src = e.target.result;
        };
        reader.readAsDataURL(file);
    };

    // Function to summarize content using Gemini API
    const summarizeContent = async () => {
        if (!decodedContent.trim() || decodedContent === 'No QR code detected.') {
            showAlert('Please decode a QR code first to summarize its content.');
            return;
        }

        setIsSummarizing(true);
        try {
            let chatHistory = [];
            // Prompt to handle various content types for summarization
            const prompt = `Summarize the following text concisely. If the text appears to be in XML, JSON, or another large structured format, extract the key information and present it as plain text. If it's a very long plain text, provide a brief summary. Text to summarize: "${decodedContent}"`;
            chatHistory.push({ role: "user", parts: [{ text: prompt }] });
            const payload = { contents: chatHistory };
            const apiKey = ""; // Canvas will provide this at runtime
            const apiUrl = `https://generativelanguage.googleapis.com/v1beta/models/gemini-2.0-flash:generateContent?key=${apiKey}`;

            const response = await fetch(apiUrl, {
                method: 'POST',
                headers: { 'Content-Type': 'application/json' },
                body: JSON.stringify(payload)
            });

            const result = await response.json();

            if (result.candidates && result.candidates.length > 0 &&
                result.candidates[0].content && result.candidates[0].content.parts &&
                result.candidates[0].content.parts.length > 0) {
                const text = result.candidates[0].content.parts[0].text;
                setContent(text); // Update the generator's input field with summarized content
                showAlert('Content summarized and moved to QR Generator tab!');
            } else {
                showAlert("Failed to summarize content. Please try again.");
            }
        } catch (error) {
            console.error("Error summarizing content:", error);
            showAlert("An error occurred while summarizing content.");
        } finally {
            setIsSummarizing(false);
        }
    };

    // Function to suggest ideas for QR code generation from the local array
    const suggestIdeas = () => {
        if (allSuggestedIdeas.length > 0) {
            const randomIndex = Math.floor(Math.random() * allSuggestedIdeas.length);
            const randomIdea = allSuggestedIdeas[randomIndex];
            setSuggestedIdea(randomIdea); // Display the randomly selected idea
            setContent(randomIdea); // Set the QR content to the suggested idea
            setShowSuggestedIdea(true); // Ensure the ideas panel is shown
        } else {
            // This case should ideally not be hit if allSuggestedIdeas is hardcoded
            setSuggestedIdea("No ideas available in the local list.");
            setShowSuggestedIdea(true);
        }
    };

    return (
        // Modified: min-h-screen to allow page to grow, flex-col for vertical layout
        <div className={`min-h-screen flex flex-col font-inter antialiased ${currentThemeClasses.bg} ${currentThemeClasses.text} transition-all duration-500 ease-in-out`}>
            {/* Container for header, tabs, and tab content */}
            <div className="container mx-auto p-4 max-w-7xl flex flex-col flex-grow"> 
                <h1 className={`text-4xl lg:text-5xl font-extrabold text-center mb-8 bg-clip-text text-transparent ${currentThemeClasses.headerGlow} font-orbitron`}>
                    QuantumQR Studio
                </h1>

                {/* Tabs Navigation */}
                <div className={`flex flex-wrap justify-center mb-8 p-1 rounded-xl shadow-inner ${currentThemeClasses.cardBg} ${currentThemeClasses.cardBorder} border`}>
                    <button
                        className={`flex-1 min-w-[150px] py-3 px-6 text-lg font-semibold rounded-lg transition-all duration-300 ease-in-out transform hover:scale-[1.02] hover:shadow-md
                            ${activeTab === 'generator' ? currentThemeClasses.tabActive : currentThemeClasses.tabInactive}
                            ${activeTab === 'generator' ? currentThemeClasses.primaryAccent : currentThemeClasses.text}`}
                        onClick={() => setActiveTab('generator')}
                    >
                        <i className="fas fa-qrcode mr-2"></i> QR Generator
                    </button>
                    <button
                        className={`flex-1 min-w-[150px] py-3 px-6 text-lg font-semibold rounded-lg transition-all duration-300 ease-in-out transform hover:scale-[1.02] hover:shadow-md
                            ${activeTab === 'decoder' ? currentThemeClasses.tabActive : currentThemeClasses.tabInactive}
                            ${activeTab === 'decoder' ? currentThemeClasses.primaryAccent : currentThemeClasses.text}`}
                        onClick={() => setActiveTab('decoder')}
                    >
                        <i className="fas fa-camera mr-2"></i> QR Decoder
                    </button>
                    <button
                        className={`flex-1 min-w-[150px] py-3 px-6 text-lg font-semibold rounded-lg transition-all duration-300 ease-in-out transform hover:scale-[1.02] hover:shadow-md
                            ${activeTab === 'settings' ? currentThemeClasses.tabActive : currentThemeClasses.tabInactive}
                            ${activeTab === 'settings' ? currentThemeClasses.primaryAccent : currentThemeClasses.text}`}
                        onClick={() => setActiveTab('settings')}
                    >
                        <i className="fas fa-cog mr-2"></i> Settings
                    </button>
                </div>

                {/* Tab Content - Added flex-grow to fill remaining space */}
                <div className="tab-content flex flex-col flex-grow">
                    {activeTab === 'generator' && (
                        <QRGeneratorTab
                            content={content}
                            setContent={setContent}
                            errorLevel={errorLevel}
                            setErrorLevel={setErrorLevel}
                            qrColor={qrColor}
                            setQrColor={setQrColor}
                            suggestIdeas={suggestIdeas}
                            downloadQrCode={downloadQrCode}
                            qrCanvasRef={qrCanvasRef}
                            isInputFocused={isInputFocused}
                            setIsInputFocused={setIsInputFocused}
                            currentThemeClasses={currentThemeClasses}
                            qrStyles={qrStyles}
                            selectedStyleIndex={selectedStyleIndex}
                            setSelectedStyleIndex={setSelectedStyleIndex}
                            styleCanvasRefs={styleCanvasRefs}
                            drawQrCode={drawQrCode}
                            suggestedIdea={suggestedIdea}
                            showSuggestedIdea={setShowSuggestedIdea}
                            downloadResolution={downloadResolution}
                            setDownloadResolution={setDownloadResolution}
                        />
                    )}
                    {activeTab === 'decoder' && (
                        <QRDecoderTab
                            decodedContent={decodedContent}
                            setDecodedContent={setDecodedContent}
                            isSummarizing={isSummarizing}
                            summarizeContent={summarizeContent}
                            showAlert={showAlert}
                            decodeQrCode={decodeQrCode}
                            currentThemeClasses={currentThemeClasses}
                        />
                    )}
                    {activeTab === 'settings' && (
                        <SettingsTab
                            currentTheme={currentTheme}
                            setCurrentTheme={setCurrentTheme}
                            currentThemeClasses={currentThemeClasses}
                            themes={themes}
                        />
                    )}
                </div>
                {/* Added padding to the bottom of the container to ensure space below content */}
                <div className="pb-8"></div> 
            </div>

            {/* Custom Alert Modal */}
            <CustomAlert message={alertMessage} onClose={() => setAlertMessage(null)} />

            {/* Font Awesome for Icons */}
            <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.0.0-beta3/css/all.min.css"></link>
            {/* Google Fonts - Inter & Orbitron */}
            <link href="https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700;800&family=Orbitron:wght@400;500;600;700;800;900&display=swap" rel="stylesheet"></link>

            {/* Tailwind CSS CDN - Ensure this is loaded */}
            <script src="https://cdn.tailwindcss.com"></script>

            {/* Custom Scrollbar Styles */}
            <style>
                {`
                .custom-scrollbar::-webkit-scrollbar {
                    width: 8px;
                }

                .custom-scrollbar::-webkit-scrollbar-track {
                    background: rgba(255, 255, 255, 0.05); /* Light track for dark themes */
                    border-radius: 10px;
                }

                .custom-scrollbar::-webkit-scrollbar-thumb {
                    background: #00BFFF; /* Electric Blue, matching a primary accent */
                    border-radius: 10px;
                    border: 2px solid rgba(255, 255, 255, 0.1); /* Slight border for depth */
                }

                .custom-scrollbar::-webkit-scrollbar-thumb:hover {
                    background: #00FFFF; /* Lighter cyan on hover */
                }

                /* For Firefox */
                .custom-scrollbar {
                    scrollbar-width: thin;
                    scrollbar-color: #00BFFF rgba(255, 255, 255, 0.05);
                }
                `}
            </style>
        </div>
    );
};

export default App;