File size: 62,329 Bytes
fb74069
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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" />
  <title>Cultural Intelligence Explorer - Global Edition with AI Analysis</title>
  <meta name="viewport" content="width=device-width, initial-scale=1" />
  <!-- Tailwind CSS -->
  <script src="https://cdn.tailwindcss.com"></script>
  <!-- React & ReactDOM -->
  <script crossorigin src="https://unpkg.com/react@18/umd/react.development.js"></script>
  <script crossorigin src="https://unpkg.com/react-dom@18/umd/react-dom.development.js"></script>
  <!-- @babel/standalone -->
  <script crossorigin src="https://unpkg.com/@babel/standalone/babel.min.js"></script>
  <!-- Font Awesome for icons -->
  <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.4.0/css/all.min.css">
  <style>

    html, body {

      background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);

      min-height: 100%;

      margin: 0;

      font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;

    }

    

    .glass {

      background: rgba(255, 255, 255, 0.9);

      backdrop-filter: blur(15px);

      border-radius: 1.5rem;

      box-shadow: 0 8px 32px rgba(31, 38, 135, 0.37);

      border: 1px solid rgba(255, 255, 255, 0.18);

    }

    

    .country-dropdown {

      background: linear-gradient(135deg, #f093fb 0%, #f5576c 100%);

      border-radius: 1rem;

      padding: 1.5rem;

      color: white;

      margin-bottom: 2rem;

    }

    

    .dropdown-container {

      position: relative;

      width: 100%;

    }

    

    .dropdown-input {

      width: 100%;

      padding: 1rem;

      border: 2px solid rgba(255,255,255,0.3);

      border-radius: 0.75rem;

      background: rgba(255,255,255,0.9);

      color: #333;

      font-size: 1rem;

      cursor: pointer;

    }

    

    .dropdown-input:focus {

      outline: none;

      border-color: #fbbf24;

      box-shadow: 0 0 0 3px rgba(251, 191, 36, 0.3);

    }

    

    .dropdown-list {

      position: absolute;

      top: 100%;

      left: 0;

      right: 0;

      background: white;

      border: 1px solid #e5e7eb;

      border-radius: 0.75rem;

      max-height: 300px;

      overflow-y: auto;

      z-index: 1000;

      box-shadow: 0 10px 25px rgba(0,0,0,0.15);

    }

    

    .dropdown-item {

      padding: 0.75rem 1rem;

      cursor: pointer;

      border-bottom: 1px solid #f3f4f6;

      display: flex;

      align-items: center;

      gap: 0.75rem;

      transition: background-color 0.2s;

    }

    

    .dropdown-item:hover {

      background-color: #f8fafc;

    }

    

    .dropdown-item:last-child {

      border-bottom: none;

    }

    

    .dropdown-item.highlighted {

      background-color: #eff6ff;

    }

    

    .theme-card {

      background: linear-gradient(135deg, #4facfe 0%, #00f2fe 100%);

      border-radius: 0.75rem;

      padding: 1rem;

      color: white;

      cursor: pointer;

      transition: all 0.3s ease;

      border: 2px solid transparent;

      text-align: center;

    }

    

    .theme-card:hover {

      transform: scale(1.05);

      border-color: rgba(255,255,255,0.5);

    }

    

    .theme-card.selected {

      border-color: #fbbf24;

      box-shadow: 0 0 15px rgba(251, 191, 36, 0.4);

    }

    

    .insight-section {

      background: linear-gradient(135deg, #a8edea 0%, #fed6e3 100%);

      border-radius: 1rem;

      padding: 1.5rem;

      margin: 1rem 0;

      border-left: 4px solid #667eea;

    }

    

    .reflection-card {

      background: rgba(255, 255, 255, 0.95);

      border-radius: 1rem;

      padding: 1.5rem;

      margin: 1rem 0;

      box-shadow: 0 4px 15px rgba(0,0,0,0.1);

      border: 1px solid rgba(102, 126, 234, 0.2);

    }

    

    .analysis-table {

      background: rgba(255, 255, 255, 0.98);

      border-radius: 1rem;

      overflow: hidden;

      box-shadow: 0 8px 25px rgba(0,0,0,0.1);

      border: 1px solid rgba(102, 126, 234, 0.2);

    }

    

    .analysis-table table {

      width: 100%;

      border-collapse: collapse;

    }

    

    .analysis-table th {

      background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);

      color: white;

      padding: 1rem;

      text-align: left;

      font-weight: 600;

      border-bottom: 2px solid rgba(255,255,255,0.2);

    }

    

    .analysis-table td {

      padding: 1rem;

      border-bottom: 1px solid #e5e7eb;

      vertical-align: top;

    }

    

    .analysis-table tr:last-child td {

      border-bottom: none;

    }

    

    .analysis-table tr:nth-child(even) {

      background-color: #f8fafc;

    }

    

    .analysis-table tr:hover {

      background-color: #eff6ff;

    }

    

    .insight-badge {

      display: inline-block;

      background: linear-gradient(135deg, #10b981 0%, #059669 100%);

      color: white;

      padding: 0.25rem 0.75rem;

      border-radius: 1rem;

      font-size: 0.75rem;

      font-weight: 600;

      margin: 0.25rem 0.25rem 0.25rem 0;

    }

    

    .comparison-badge {

      display: inline-block;

      background: linear-gradient(135deg, #f59e0b 0%, #d97706 100%);

      color: white;

      padding: 0.25rem 0.75rem;

      border-radius: 1rem;

      font-size: 0.75rem;

      font-weight: 600;

      margin: 0.25rem 0.25rem 0.25rem 0;

    }

    

    .progress-bar {

      background: linear-gradient(90deg, #667eea 0%, #764ba2 100%);

      height: 6px;

      border-radius: 3px;

      transition: width 0.5s ease;

    }

    

    .typing-indicator {

      display: inline-flex;

      align-items: center;

      gap: 4px;

    }

    

    .typing-dot {

      width: 8px;

      height: 8px;

      border-radius: 50%;

      background: #667eea;

      animation: typing 1.4s infinite ease-in-out;

    }

    

    .typing-dot:nth-child(1) { animation-delay: -0.32s; }

    .typing-dot:nth-child(2) { animation-delay: -0.16s; }

    

    @keyframes typing {

      0%, 80%, 100% { transform: scale(0); opacity: 0.5; }

      40% { transform: scale(1); opacity: 1; }

    }

    

    .fade-in {

      animation: fadeIn 0.6s ease-in;

    }

    

    @keyframes fadeIn {

      from { opacity: 0; transform: translateY(20px); }

      to { opacity: 1; transform: translateY(0); }

    }

    

    .slide-in {

      animation: slideIn 0.5s ease-out;

    }

    

    @keyframes slideIn {

      from { opacity: 0; transform: translateX(-30px); }

      to { opacity: 1; transform: translateX(0); }

    }

    

    /* Accessibility improvements */

    .sr-only {

      position: absolute;

      width: 1px;

      height: 1px;

      padding: 0;

      margin: -1px;

      overflow: hidden;

      clip: rect(0, 0, 0, 0);

      white-space: nowrap;

      border: 0;

    }

    

    button:focus, input:focus, textarea:focus, select:focus {

      outline: 3px solid #fbbf24;

      outline-offset: 2px;

    }

    

    .theme-card:focus {

      outline: 3px solid #fbbf24;

      outline-offset: 2px;

    }

    

    /* Responsive design */

    @media (max-width: 768px) {

      .theme-grid {

        grid-template-columns: repeat(2, 1fr);

      }

      

      .analysis-table {

        overflow-x: auto;

      }

      

      .analysis-table table {

        min-width: 600px;

      }

    }

    

    @media (max-width: 640px) {

      .theme-grid {

        grid-template-columns: 1fr;

      }

    }

  </style>
</head>
<body>
<div id="root"></div>
<script type="text/babel">

const { useState, useEffect, useCallback, useRef } = React;



// Comprehensive list of world countries with flags and regions

const WORLD_COUNTRIES = [

  // Africa

  { id: 'algeria', name: 'Algeria', flag: '🇩🇿', region: 'North Africa' },

  { id: 'angola', name: 'Angola', flag: '🇦🇴', region: 'Central Africa' },

  { id: 'benin', name: 'Benin', flag: '🇧🇯', region: 'West Africa' },

  { id: 'botswana', name: 'Botswana', flag: '🇧🇼', region: 'Southern Africa' },

  { id: 'burkina-faso', name: 'Burkina Faso', flag: '🇧🇫', region: 'West Africa' },

  { id: 'burundi', name: 'Burundi', flag: '🇧🇮', region: 'East Africa' },

  { id: 'cameroon', name: 'Cameroon', flag: '🇨🇲', region: 'Central Africa' },

  { id: 'cape-verde', name: 'Cape Verde', flag: '🇨🇻', region: 'West Africa' },

  { id: 'chad', name: 'Chad', flag: '🇹🇩', region: 'Central Africa' },

  { id: 'comoros', name: 'Comoros', flag: '🇰🇲', region: 'East Africa' },

  { id: 'congo', name: 'Congo', flag: '🇨🇬', region: 'Central Africa' },

  { id: 'drc', name: 'Democratic Republic of Congo', flag: '🇨🇩', region: 'Central Africa' },

  { id: 'djibouti', name: 'Djibouti', flag: '🇩🇯', region: 'East Africa' },

  { id: 'egypt', name: 'Egypt', flag: '🇪🇬', region: 'North Africa' },

  { id: 'equatorial-guinea', name: 'Equatorial Guinea', flag: '🇬🇶', region: 'Central Africa' },

  { id: 'eritrea', name: 'Eritrea', flag: '🇪🇷', region: 'East Africa' },

  { id: 'eswatini', name: 'Eswatini', flag: '🇸🇿', region: 'Southern Africa' },

  { id: 'ethiopia', name: 'Ethiopia', flag: '🇪🇹', region: 'East Africa' },

  { id: 'gabon', name: 'Gabon', flag: '🇬🇦', region: 'Central Africa' },

  { id: 'gambia', name: 'Gambia', flag: '🇬🇲', region: 'West Africa' },

  { id: 'ghana', name: 'Ghana', flag: '🇬🇭', region: 'West Africa' },

  { id: 'guinea', name: 'Guinea', flag: '🇬🇳', region: 'West Africa' },

  { id: 'guinea-bissau', name: 'Guinea-Bissau', flag: '🇬🇼', region: 'West Africa' },

  { id: 'ivory-coast', name: 'Ivory Coast', flag: '🇨🇮', region: 'West Africa' },

  { id: 'kenya', name: 'Kenya', flag: '🇰🇪', region: 'East Africa' },

  { id: 'lesotho', name: 'Lesotho', flag: '🇱🇸', region: 'Southern Africa' },

  { id: 'liberia', name: 'Liberia', flag: '🇱🇷', region: 'West Africa' },

  { id: 'libya', name: 'Libya', flag: '🇱🇾', region: 'North Africa' },

  { id: 'madagascar', name: 'Madagascar', flag: '🇲🇬', region: 'East Africa' },

  { id: 'malawi', name: 'Malawi', flag: '🇲🇼', region: 'Southern Africa' },

  { id: 'mali', name: 'Mali', flag: '🇲🇱', region: 'West Africa' },

  { id: 'mauritania', name: 'Mauritania', flag: '🇲🇷', region: 'West Africa' },

  { id: 'mauritius', name: 'Mauritius', flag: '🇲🇺', region: 'East Africa' },

  { id: 'morocco', name: 'Morocco', flag: '🇲🇦', region: 'North Africa' },

  { id: 'mozambique', name: 'Mozambique', flag: '🇲🇿', region: 'Southern Africa' },

  { id: 'namibia', name: 'Namibia', flag: '🇳🇦', region: 'Southern Africa' },

  { id: 'niger', name: 'Niger', flag: '🇳🇪', region: 'West Africa' },

  { id: 'nigeria', name: 'Nigeria', flag: '🇳🇬', region: 'West Africa' },

  { id: 'rwanda', name: 'Rwanda', flag: '🇷🇼', region: 'East Africa' },

  { id: 'sao-tome', name: 'São Tomé and Príncipe', flag: '🇸🇹', region: 'Central Africa' },

  { id: 'senegal', name: 'Senegal', flag: '🇸🇳', region: 'West Africa' },

  { id: 'seychelles', name: 'Seychelles', flag: '🇸🇨', region: 'East Africa' },

  { id: 'sierra-leone', name: 'Sierra Leone', flag: '🇸🇱', region: 'West Africa' },

  { id: 'somalia', name: 'Somalia', flag: '🇸🇴', region: 'East Africa' },

  { id: 'south-africa', name: 'South Africa', flag: '🇿🇦', region: 'Southern Africa' },

  { id: 'south-sudan', name: 'South Sudan', flag: '🇸🇸', region: 'East Africa' },

  { id: 'sudan', name: 'Sudan', flag: '🇸🇩', region: 'North Africa' },

  { id: 'tanzania', name: 'Tanzania', flag: '🇹🇿', region: 'East Africa' },

  { id: 'togo', name: 'Togo', flag: '🇹🇬', region: 'West Africa' },

  { id: 'tunisia', name: 'Tunisia', flag: '🇹🇳', region: 'North Africa' },

  { id: 'uganda', name: 'Uganda', flag: '🇺🇬', region: 'East Africa' },

  { id: 'zambia', name: 'Zambia', flag: '🇿🇲', region: 'Southern Africa' },

  { id: 'zimbabwe', name: 'Zimbabwe', flag: '🇿🇼', region: 'Southern Africa' },



  // Asia

  { id: 'afghanistan', name: 'Afghanistan', flag: '🇦🇫', region: 'Central Asia' },

  { id: 'armenia', name: 'Armenia', flag: '🇦🇲', region: 'Western Asia' },

  { id: 'azerbaijan', name: 'Azerbaijan', flag: '🇦🇿', region: 'Western Asia' },

  { id: 'bahrain', name: 'Bahrain', flag: '🇧🇭', region: 'Western Asia' },

  { id: 'bangladesh', name: 'Bangladesh', flag: '🇧🇩', region: 'South Asia' },

  { id: 'bhutan', name: 'Bhutan', flag: '🇧🇹', region: 'South Asia' },

  { id: 'brunei', name: 'Brunei', flag: '🇧🇳', region: 'Southeast Asia' },

  { id: 'cambodia', name: 'Cambodia', flag: '🇰🇭', region: 'Southeast Asia' },

  { id: 'china', name: 'China', flag: '🇨🇳', region: 'East Asia' },

  { id: 'cyprus', name: 'Cyprus', flag: '🇨🇾', region: 'Western Asia' },

  { id: 'georgia', name: 'Georgia', flag: '🇬🇪', region: 'Western Asia' },

  { id: 'india', name: 'India', flag: '🇮🇳', region: 'South Asia' },

  { id: 'indonesia', name: 'Indonesia', flag: '🇮🇩', region: 'Southeast Asia' },

  { id: 'iran', name: 'Iran', flag: '🇮🇷', region: 'Western Asia' },

  { id: 'iraq', name: 'Iraq', flag: '🇮🇶', region: 'Western Asia' },

  { id: 'israel', name: 'Israel', flag: '🇮🇱', region: 'Western Asia' },

  { id: 'japan', name: 'Japan', flag: '🇯🇵', region: 'East Asia' },

  { id: 'jordan', name: 'Jordan', flag: '🇯🇴', region: 'Western Asia' },

  { id: 'kazakhstan', name: 'Kazakhstan', flag: '🇰🇿', region: 'Central Asia' },

  { id: 'kuwait', name: 'Kuwait', flag: '🇰🇼', region: 'Western Asia' },

  { id: 'kyrgyzstan', name: 'Kyrgyzstan', flag: '🇰🇬', region: 'Central Asia' },

  { id: 'laos', name: 'Laos', flag: '🇱🇦', region: 'Southeast Asia' },

  { id: 'lebanon', name: 'Lebanon', flag: '🇱🇧', region: 'Western Asia' },

  { id: 'malaysia', name: 'Malaysia', flag: '🇲🇾', region: 'Southeast Asia' },

  { id: 'maldives', name: 'Maldives', flag: '🇲🇻', region: 'South Asia' },

  { id: 'mongolia', name: 'Mongolia', flag: '🇲🇳', region: 'East Asia' },

  { id: 'myanmar', name: 'Myanmar', flag: '🇲🇲', region: 'Southeast Asia' },

  { id: 'nepal', name: 'Nepal', flag: '🇳🇵', region: 'South Asia' },

  { id: 'north-korea', name: 'North Korea', flag: '🇰🇵', region: 'East Asia' },

  { id: 'oman', name: 'Oman', flag: '🇴🇲', region: 'Western Asia' },

  { id: 'pakistan', name: 'Pakistan', flag: '🇵🇰', region: 'South Asia' },

  { id: 'palestine', name: 'Palestine', flag: '🇵🇸', region: 'Western Asia' },

  { id: 'philippines', name: 'Philippines', flag: '🇵🇭', region: 'Southeast Asia' },

  { id: 'qatar', name: 'Qatar', flag: '🇶🇦', region: 'Western Asia' },

  { id: 'saudi-arabia', name: 'Saudi Arabia', flag: '🇸🇦', region: 'Western Asia' },

  { id: 'singapore', name: 'Singapore', flag: '🇸🇬', region: 'Southeast Asia' },

  { id: 'south-korea', name: 'South Korea', flag: '🇰🇷', region: 'East Asia' },

  { id: 'sri-lanka', name: 'Sri Lanka', flag: '🇱🇰', region: 'South Asia' },

  { id: 'syria', name: 'Syria', flag: '🇸🇾', region: 'Western Asia' },

  { id: 'taiwan', name: 'Taiwan', flag: '🇹🇼', region: 'East Asia' },

  { id: 'tajikistan', name: 'Tajikistan', flag: '🇹🇯', region: 'Central Asia' },

  { id: 'thailand', name: 'Thailand', flag: '🇹🇭', region: 'Southeast Asia' },

  { id: 'timor-leste', name: 'Timor-Leste', flag: '🇹🇱', region: 'Southeast Asia' },

  { id: 'turkey', name: 'Turkey', flag: '🇹🇷', region: 'Western Asia' },

  { id: 'turkmenistan', name: 'Turkmenistan', flag: '🇹🇲', region: 'Central Asia' },

  { id: 'uae', name: 'United Arab Emirates', flag: '🇦🇪', region: 'Western Asia' },

  { id: 'uzbekistan', name: 'Uzbekistan', flag: '🇺🇿', region: 'Central Asia' },

  { id: 'vietnam', name: 'Vietnam', flag: '🇻🇳', region: 'Southeast Asia' },

  { id: 'yemen', name: 'Yemen', flag: '🇾🇪', region: 'Western Asia' },



  // Europe

  { id: 'albania', name: 'Albania', flag: '🇦🇱', region: 'Southern Europe' },

  { id: 'andorra', name: 'Andorra', flag: '🇦🇩', region: 'Southern Europe' },

  { id: 'austria', name: 'Austria', flag: '🇦🇹', region: 'Central Europe' },

  { id: 'belarus', name: 'Belarus', flag: '🇧🇾', region: 'Eastern Europe' },

  { id: 'belgium', name: 'Belgium', flag: '🇧🇪', region: 'Western Europe' },

  { id: 'bosnia', name: 'Bosnia and Herzegovina', flag: '🇧🇦', region: 'Southern Europe' },

  { id: 'bulgaria', name: 'Bulgaria', flag: '🇧🇬', region: 'Eastern Europe' },

  { id: 'croatia', name: 'Croatia', flag: '🇭🇷', region: 'Southern Europe' },

  { id: 'czech-republic', name: 'Czech Republic', flag: '🇨🇿', region: 'Central Europe' },

  { id: 'denmark', name: 'Denmark', flag: '🇩🇰', region: 'Northern Europe' },

  { id: 'estonia', name: 'Estonia', flag: '🇪🇪', region: 'Northern Europe' },

  { id: 'finland', name: 'Finland', flag: '🇫🇮', region: 'Northern Europe' },

  { id: 'france', name: 'France', flag: '🇫🇷', region: 'Western Europe' },

  { id: 'germany', name: 'Germany', flag: '🇩🇪', region: 'Central Europe' },

  { id: 'greece', name: 'Greece', flag: '🇬🇷', region: 'Southern Europe' },

  { id: 'hungary', name: 'Hungary', flag: '🇭🇺', region: 'Central Europe' },

  { id: 'iceland', name: 'Iceland', flag: '🇮🇸', region: 'Northern Europe' },

  { id: 'ireland', name: 'Ireland', flag: '🇮🇪', region: 'Northern Europe' },

  { id: 'italy', name: 'Italy', flag: '🇮🇹', region: 'Southern Europe' },

  { id: 'kosovo', name: 'Kosovo', flag: '🇽🇰', region: 'Southern Europe' },

  { id: 'latvia', name: 'Latvia', flag: '🇱🇻', region: 'Northern Europe' },

  { id: 'liechtenstein', name: 'Liechtenstein', flag: '🇱🇮', region: 'Central Europe' },

  { id: 'lithuania', name: 'Lithuania', flag: '🇱🇹', region: 'Northern Europe' },

  { id: 'luxembourg', name: 'Luxembourg', flag: '🇱🇺', region: 'Western Europe' },

  { id: 'malta', name: 'Malta', flag: '🇲🇹', region: 'Southern Europe' },

  { id: 'moldova', name: 'Moldova', flag: '🇲🇩', region: 'Eastern Europe' },

  { id: 'monaco', name: 'Monaco', flag: '🇲🇨', region: 'Western Europe' },

  { id: 'montenegro', name: 'Montenegro', flag: '🇲🇪', region: 'Southern Europe' },

  { id: 'netherlands', name: 'Netherlands', flag: '🇳🇱', region: 'Western Europe' },

  { id: 'north-macedonia', name: 'North Macedonia', flag: '🇲🇰', region: 'Southern Europe' },

  { id: 'norway', name: 'Norway', flag: '🇳🇴', region: 'Northern Europe' },

  { id: 'poland', name: 'Poland', flag: '🇵🇱', region: 'Central Europe' },

  { id: 'portugal', name: 'Portugal', flag: '🇵🇹', region: 'Southern Europe' },

  { id: 'romania', name: 'Romania', flag: '🇷🇴', region: 'Eastern Europe' },

  { id: 'russia', name: 'Russia', flag: '🇷🇺', region: 'Eastern Europe' },

  { id: 'san-marino', name: 'San Marino', flag: '🇸🇲', region: 'Southern Europe' },

  { id: 'serbia', name: 'Serbia', flag: '🇷🇸', region: 'Southern Europe' },

  { id: 'slovakia', name: 'Slovakia', flag: '🇸🇰', region: 'Central Europe' },

  { id: 'slovenia', name: 'Slovenia', flag: '🇸🇮', region: 'Central Europe' },

  { id: 'spain', name: 'Spain', flag: '🇪🇸', region: 'Southern Europe' },

  { id: 'sweden', name: 'Sweden', flag: '🇸🇪', region: 'Northern Europe' },

  { id: 'switzerland', name: 'Switzerland', flag: '🇨🇭', region: 'Central Europe' },

  { id: 'ukraine', name: 'Ukraine', flag: '🇺🇦', region: 'Eastern Europe' },

  { id: 'united-kingdom', name: 'United Kingdom', flag: '🇬🇧', region: 'Northern Europe' },

  { id: 'vatican', name: 'Vatican City', flag: '🇻🇦', region: 'Southern Europe' },



  // North America

  { id: 'antigua', name: 'Antigua and Barbuda', flag: '🇦🇬', region: 'Caribbean' },

  { id: 'bahamas', name: 'Bahamas', flag: '🇧🇸', region: 'Caribbean' },

  { id: 'barbados', name: 'Barbados', flag: '🇧🇧', region: 'Caribbean' },

  { id: 'belize', name: 'Belize', flag: '🇧🇿', region: 'Central America' },

  { id: 'canada', name: 'Canada', flag: '🇨🇦', region: 'North America' },

  { id: 'costa-rica', name: 'Costa Rica', flag: '🇨🇷', region: 'Central America' },

  { id: 'cuba', name: 'Cuba', flag: '🇨🇺', region: 'Caribbean' },

  { id: 'dominica', name: 'Dominica', flag: '🇩🇲', region: 'Caribbean' },

  { id: 'dominican-republic', name: 'Dominican Republic', flag: '🇩🇴', region: 'Caribbean' },

  { id: 'el-salvador', name: 'El Salvador', flag: '🇸🇻', region: 'Central America' },

  { id: 'grenada', name: 'Grenada', flag: '🇬🇩', region: 'Caribbean' },

  { id: 'guatemala', name: 'Guatemala', flag: '🇬🇹', region: 'Central America' },

  { id: 'haiti', name: 'Haiti', flag: '🇭🇹', region: 'Caribbean' },

  { id: 'honduras', name: 'Honduras', flag: '🇭🇳', region: 'Central America' },

  { id: 'jamaica', name: 'Jamaica', flag: '🇯🇲', region: 'Caribbean' },

  { id: 'mexico', name: 'Mexico', flag: '🇲🇽', region: 'North America' },

  { id: 'nicaragua', name: 'Nicaragua', flag: '🇳🇮', region: 'Central America' },

  { id: 'panama', name: 'Panama', flag: '🇵🇦', region: 'Central America' },

  { id: 'saint-kitts', name: 'Saint Kitts and Nevis', flag: '🇰🇳', region: 'Caribbean' },

  { id: 'saint-lucia', name: 'Saint Lucia', flag: '🇱🇨', region: 'Caribbean' },

  { id: 'saint-vincent', name: 'Saint Vincent and the Grenadines', flag: '🇻🇨', region: 'Caribbean' },

  { id: 'trinidad', name: 'Trinidad and Tobago', flag: '🇹🇹', region: 'Caribbean' },

  { id: 'usa', name: 'United States', flag: '🇺🇸', region: 'North America' },



  // South America

  { id: 'argentina', name: 'Argentina', flag: '🇦🇷', region: 'South America' },

  { id: 'bolivia', name: 'Bolivia', flag: '🇧🇴', region: 'South America' },

  { id: 'brazil', name: 'Brazil', flag: '🇧🇷', region: 'South America' },

  { id: 'chile', name: 'Chile', flag: '🇨🇱', region: 'South America' },

  { id: 'colombia', name: 'Colombia', flag: '🇨🇴', region: 'South America' },

  { id: 'ecuador', name: 'Ecuador', flag: '🇪🇨', region: 'South America' },

  { id: 'guyana', name: 'Guyana', flag: '🇬🇾', region: 'South America' },

  { id: 'paraguay', name: 'Paraguay', flag: '🇵🇾', region: 'South America' },

  { id: 'peru', name: 'Peru', flag: '🇵🇪', region: 'South America' },

  { id: 'suriname', name: 'Suriname', flag: '🇸🇷', region: 'South America' },

  { id: 'uruguay', name: 'Uruguay', flag: '🇺🇾', region: 'South America' },

  { id: 'venezuela', name: 'Venezuela', flag: '🇻🇪', region: 'South America' },



  // Oceania

  { id: 'australia', name: 'Australia', flag: '🇦🇺', region: 'Oceania' },

  { id: 'fiji', name: 'Fiji', flag: '🇫🇯', region: 'Oceania' },

  { id: 'kiribati', name: 'Kiribati', flag: '🇰🇮', region: 'Oceania' },

  { id: 'marshall-islands', name: 'Marshall Islands', flag: '🇲🇭', region: 'Oceania' },

  { id: 'micronesia', name: 'Micronesia', flag: '🇫🇲', region: 'Oceania' },

  { id: 'nauru', name: 'Nauru', flag: '🇳🇷', region: 'Oceania' },

  { id: 'new-zealand', name: 'New Zealand', flag: '🇳🇿', region: 'Oceania' },

  { id: 'palau', name: 'Palau', flag: '🇵🇼', region: 'Oceania' },

  { id: 'papua-new-guinea', name: 'Papua New Guinea', flag: '🇵🇬', region: 'Oceania' },

  { id: 'samoa', name: 'Samoa', flag: '🇼🇸', region: 'Oceania' },

  { id: 'solomon-islands', name: 'Solomon Islands', flag: '🇸🇧', region: 'Oceania' },

  { id: 'tonga', name: 'Tonga', flag: '🇹🇴', region: 'Oceania' },

  { id: 'tuvalu', name: 'Tuvalu', flag: '🇹🇻', region: 'Oceania' },

  { id: 'vanuatu', name: 'Vanuatu', flag: '🇻🇺', region: 'Oceania' }

];



const THEMES = [

  {

    id: 'family',

    name: 'Family Life',

    icon: '👨‍👩‍👧‍👦',

    description: 'Family structures, relationships, and traditions'

  },

  {

    id: 'education',

    name: 'Education',

    icon: '📚',

    description: 'Learning systems, values, and approaches to knowledge'

  },

  {

    id: 'traditions',

    name: 'Traditions & Festivals',

    icon: '🎭',

    description: 'Cultural celebrations, rituals, and customs'

  },

  {

    id: 'communication',

    name: 'Communication',

    icon: '💬',

    description: 'Language, non-verbal cues, and social interactions'

  },

  {

    id: 'work',

    name: 'Work & Business',

    icon: '💼',

    description: 'Professional culture, work ethics, and business practices'

  },

  {

    id: 'food',

    name: 'Food & Dining',

    icon: '🍽️',

    description: 'Culinary traditions, dining etiquette, and food culture'

  },

  {

    id: 'values',

    name: 'Core Values',

    icon: '⭐',

    description: 'Fundamental beliefs, principles, and worldviews'

  },

  {

    id: 'challenges',

    name: 'Modern Challenges',

    icon: '🌍',

    description: 'Contemporary issues and cultural adaptations'

  }

];



const REFLECTION_PROMPTS = [

  {

    id: 'similarities',

    question: 'What similarities did you discover between this culture and your own?',

    icon: '🤝'

  },

  {

    id: 'differences',

    question: 'What differences surprised you the most?',

    icon: '🔍'

  },

  {

    id: 'assumptions',

    question: 'What assumptions about this culture were challenged?',

    icon: '💭'

  },

  {

    id: 'learning',

    question: 'What valuable lesson or practice could you adopt from this culture?',

    icon: '💡'

  },

  {

    id: 'empathy',

    question: 'How has this exploration changed your perspective on cultural diversity?',

    icon: '❤️'

  }

];



// Country Dropdown Component

function CountryDropdown({ selectedCountry, onCountrySelect }) {

  const [isOpen, setIsOpen] = useState(false);

  const [searchTerm, setSearchTerm] = useState('');

  const [highlightedIndex, setHighlightedIndex] = useState(-1);

  const dropdownRef = useRef(null);

  const inputRef = useRef(null);

  

  const filteredCountries = WORLD_COUNTRIES.filter(country =>

    country.name.toLowerCase().includes(searchTerm.toLowerCase()) ||

    country.region.toLowerCase().includes(searchTerm.toLowerCase())

  );

  

  useEffect(() => {

    function handleClickOutside(event) {

      if (dropdownRef.current && !dropdownRef.current.contains(event.target)) {

        setIsOpen(false);

        setHighlightedIndex(-1);

      }

    }

    

    document.addEventListener('mousedown', handleClickOutside);

    return () => document.removeEventListener('mousedown', handleClickOutside);

  }, []);

  

  const handleInputChange = (e) => {

    setSearchTerm(e.target.value);

    setIsOpen(true);

    setHighlightedIndex(-1);

  };

  

  const handleKeyDown = (e) => {

    if (!isOpen) {

      if (e.key === 'Enter' || e.key === 'ArrowDown') {

        setIsOpen(true);

        setHighlightedIndex(0);

      }

      return;

    }

    

    switch (e.key) {

      case 'ArrowDown':

        e.preventDefault();

        setHighlightedIndex(prev => 

          prev < filteredCountries.length - 1 ? prev + 1 : 0

        );

        break;

      case 'ArrowUp':

        e.preventDefault();

        setHighlightedIndex(prev => 

          prev > 0 ? prev - 1 : filteredCountries.length - 1

        );

        break;

      case 'Enter':

        e.preventDefault();

        if (highlightedIndex >= 0 && filteredCountries[highlightedIndex]) {

          handleCountrySelect(filteredCountries[highlightedIndex]);

        }

        break;

      case 'Escape':

        setIsOpen(false);

        setHighlightedIndex(-1);

        inputRef.current?.blur();

        break;

    }

  };

  

  const handleCountrySelect = (country) => {

    onCountrySelect(country);

    setSearchTerm('');

    setIsOpen(false);

    setHighlightedIndex(-1);

  };

  

  const displayValue = selectedCountry 

    ? `${selectedCountry.flag} ${selectedCountry.name}`

    : searchTerm;

  

  return (

    <div className="dropdown-container" ref={dropdownRef}>

      <input

        ref={inputRef}

        type="text"

        className="dropdown-input"

        placeholder={selectedCountry ? `${selectedCountry.flag} ${selectedCountry.name}` : "Search for a country..."}

        value={isOpen ? searchTerm : displayValue}

        onChange={handleInputChange}

        onKeyDown={handleKeyDown}

        onFocus={() => setIsOpen(true)}

        autoComplete="off"

        aria-expanded={isOpen}

        aria-haspopup="listbox"

        role="combobox"

      />

      

      {isOpen && (

        <div className="dropdown-list" role="listbox">

          {filteredCountries.length > 0 ? (

            filteredCountries.map((country, index) => (

              <div

                key={country.id}

                className={`dropdown-item ${index === highlightedIndex ? 'highlighted' : ''}`}

                onClick={() => handleCountrySelect(country)}

                role="option"

                aria-selected={selectedCountry?.id === country.id}

              >

                <span className="text-xl">{country.flag}</span>

                <div>

                  <div className="font-semibold text-gray-800">{country.name}</div>

                  <div className="text-sm text-gray-500">{country.region}</div>

                </div>

              </div>

            ))

          ) : (

            <div className="dropdown-item text-gray-500">

              No countries found matching "{searchTerm}"

            </div>

          )}

        </div>

      )}

    </div>

  );

}



function CulturalIntelligenceExplorer() {

  // Core state

  const [phase, setPhase] = useState(1); // 1: Selection, 2: Insights, 3: Reflection, 4: Analysis

  const [selectedCountry, setSelectedCountry] = useState(null);

  const [selectedTheme, setSelectedTheme] = useState(null);

  const [apiKey, setApiKey] = useState('');

  const [showApiKeyModal, setShowApiKeyModal] = useState(false);

  

  // AI and insights state

  const [insights, setInsights] = useState(null);

  const [isGeneratingInsights, setIsGeneratingInsights] = useState(false);

  const [aiError, setAiError] = useState('');

  

  // Reflection state

  const [reflections, setReflections] = useState({});

  const [explorationHistory, setExplorationHistory] = useState([]);

  

  // Analysis state

  const [analysis, setAnalysis] = useState(null);

  const [isGeneratingAnalysis, setIsGeneratingAnalysis] = useState(false);

  

  // Load data from localStorage

  useEffect(() => {

    try {

      const savedApiKey = localStorage.getItem('cultural-explorer-api-key');

      const savedHistory = localStorage.getItem('cultural-explorer-history');

      

      if (savedApiKey) {

        setApiKey(savedApiKey);

      }

      if (savedHistory) {

        setExplorationHistory(JSON.parse(savedHistory));

      }

    } catch (error) {

      console.error('Error loading saved data:', error);

    }

  }, []);

  

  // Save data to localStorage

  useEffect(() => {

    try {

      if (apiKey) {

        localStorage.setItem('cultural-explorer-api-key', apiKey);

      }

    } catch (error) {

      console.error('Error saving API key:', error);

    }

  }, [apiKey]);

  

  useEffect(() => {

    try {

      localStorage.setItem('cultural-explorer-history', JSON.stringify(explorationHistory));

    } catch (error) {

      console.error('Error saving history:', error);

    }

  }, [explorationHistory]);

  

  const handleCountrySelect = (country) => {

    setSelectedCountry(country);

  };

  

  const handleThemeSelect = (theme) => {

    setSelectedTheme(theme);

  };

  

  const proceedToInsights = () => {

    if (!selectedCountry) {

      alert('Please select a country to explore');

      return;

    }

    

    if (!apiKey) {

      setShowApiKeyModal(true);

      return;

    }

    

    setPhase(2);

    generateInsights();

  };

  

  const generateInsights = async () => {

    if (!apiKey || !selectedCountry) return;

    

    setIsGeneratingInsights(true);

    setAiError('');

    

    try {

      const prompt = createInsightPrompt();

      const response = await callOpenAI(prompt);

      setInsights(response);

    } catch (error) {

      console.error('Error generating insights:', error);

      setAiError(`Failed to generate insights: ${error.message}`);

    } finally {

      setIsGeneratingInsights(false);

    }

  };

  

  const createInsightPrompt = () => {

    const country = selectedCountry;

    const theme = selectedTheme;

    

    return `You are a cultural intelligence educator helping students develop empathy and global citizenship. Provide comprehensive, respectful insights about ${country.name} culture.



${theme ? `Focus specifically on: ${theme.name} - ${theme.description}` : 'Provide a general cultural overview.'}



Structure your response with the following sections:



**CULTURAL OVERVIEW:**

Provide a respectful, nuanced introduction to ${country.name} culture, avoiding stereotypes.



**KEY CULTURAL VALUES:**

List and explain 4-5 core values that guide this culture.



**DAILY LIFE INSIGHTS:**

Describe how these values manifest in everyday life.



${theme ? `**${theme.name.toUpperCase()} FOCUS:**

Provide detailed insights about ${theme.description} in ${country.name} culture.` : ''}



**HISTORICAL CONTEXT:**

Brief background on how history shaped current cultural practices.



**MODERN ADAPTATIONS:**

How this culture navigates contemporary global challenges while preserving traditions.



**COMMON MISCONCEPTIONS:**

Address 2-3 common stereotypes or misconceptions about this culture.



**CULTURAL WISDOM:**

Share a meaningful lesson or perspective this culture offers to the world.



Keep the tone educational, respectful, and engaging. Use specific examples while avoiding overgeneralization. Aim for 800-1000 words total.`;

  };

  

  const callOpenAI = async (prompt) => {

    if (!apiKey) {

      throw new Error('API key not provided');

    }

    

    const response = await fetch('https://api.openai.com/v1/chat/completions', {

      method: 'POST',

      headers: {

        'Content-Type': 'application/json',

        'Authorization': `Bearer ${apiKey.trim()}`

      },

      body: JSON.stringify({

        model: 'gpt-4o-mini',

        messages: [

          { role: 'system', content: 'You are a cultural intelligence educator focused on promoting empathy, understanding, and global citizenship.' },

          { role: 'user', content: prompt }

        ],

        max_tokens: 1200,

        temperature: 0.7

      })

    });

    

    if (!response.ok) {

      const errorData = await response.json().catch(() => ({}));

      throw new Error(`OpenAI API error: ${response.status} ${response.statusText}${errorData.error ? ` - ${errorData.error.message}` : ''}`);

    }

    

    const data = await response.json();

    

    if (!data.choices || !data.choices[0] || !data.choices[0].message) {

      throw new Error('Invalid response format from OpenAI API');

    }

    

    return data.choices[0].message.content;

  };

  

  const proceedToReflection = () => {

    setPhase(3);

  };

  

  const handleReflectionChange = (promptId, value) => {

    setReflections(prev => ({

      ...prev,

      [promptId]: value

    }));

  };

  

  const proceedToAnalysis = () => {

    setPhase(4);

    generateAnalysis();

  };

  

  const generateAnalysis = async () => {

    if (!apiKey || !selectedCountry || !insights) return;

    

    setIsGeneratingAnalysis(true);

    setAiError('');

    

    try {

      const prompt = createAnalysisPrompt();

      const response = await callOpenAI(prompt);

      setAnalysis(response);

    } catch (error) {

      console.error('Error generating analysis:', error);

      setAiError(`Failed to generate analysis: ${error.message}`);

    } finally {

      setIsGeneratingAnalysis(false);

    }

  };

  

  const createAnalysisPrompt = () => {

    const country = selectedCountry;

    const theme = selectedTheme;

    const reflectionText = Object.entries(reflections)

      .map(([key, value]) => {

        const prompt = REFLECTION_PROMPTS.find(p => p.id === key);

        return `${prompt?.question}: ${value}`;

      })

      .join('\n\n');

    

    return `You are a cultural intelligence educator analyzing a student's cultural exploration journey. Based on the cultural insights and student reflections below, provide a comprehensive analysis in a structured tabular format.



**CULTURAL CONTEXT:**

Country: ${country.name} (${country.region})

${theme ? `Focus Theme: ${theme.name} - ${theme.description}` : 'General cultural exploration'}



**CULTURAL INSIGHTS PROVIDED:**

${insights}



**STUDENT REFLECTIONS:**

${reflectionText}



**ANALYSIS REQUIREMENTS:**

Create a detailed analysis table with the following structure. Format your response as a structured table with clear rows and columns:



| Analysis Category | Cultural Theme Insights | Student Reflection Analysis | Comparison & Growth Indicators |

|-------------------|------------------------|----------------------------|-------------------------------|

| Cultural Understanding | [Key cultural insights from the theme] | [Analysis of student's understanding] | [Evidence of learning and growth] |

| Personal Connection | [How culture relates to universal themes] | [Student's personal connections made] | [Depth of empathy development] |

| Assumption Challenges | [Cultural misconceptions addressed] | [Student's assumption changes] | [Critical thinking evidence] |

| Learning Integration | [Key cultural lessons identified] | [Student's learning takeaways] | [Application potential] |

| Perspective Transformation | [Cultural wisdom shared] | [Student's perspective shifts] | [Global citizenship development] |



For each row, provide:

- 2-3 specific insights from the cultural theme

- Detailed analysis of the student's reflection quality and depth

- Evidence of learning, growth, and cultural intelligence development

- Specific examples and quotes from student responses where relevant



Keep the analysis educational, encouraging, and focused on cultural intelligence development. Highlight strengths and areas for continued growth.`;

  };

  

  const completeExploration = () => {

    const exploration = {

      id: Date.now(),

      timestamp: new Date().toISOString(),

      country: selectedCountry,

      theme: selectedTheme,

      insights: insights,

      reflections: reflections,

      analysis: analysis

    };

    

    setExplorationHistory(prev => [...prev, exploration]);

    

    // Reset for new exploration

    setPhase(1);

    setSelectedCountry(null);

    setSelectedTheme(null);

    setInsights(null);

    setReflections({});

    setAnalysis(null);

    setAiError('');

  };

  

  const validateApiKey = async (key) => {

    try {

      const response = await fetch('https://api.openai.com/v1/models', {

        headers: {

          'Authorization': `Bearer ${key.trim()}`

        }

      });

      

      if (!response.ok) {

        throw new Error('Invalid API key');

      }

      

      return true;

    } catch (error) {

      throw new Error('Invalid API key. Please check and try again.');

    }

  };

  

  const handleApiKeySubmit = async (key) => {

    try {

      await validateApiKey(key);

      setApiKey(key);

      setShowApiKeyModal(false);

      setPhase(2);

      generateInsights();

    } catch (error) {

      setAiError(error.message);

    }

  };

  

  const formatInsights = (content) => {

    // Convert markdown-style formatting to HTML

    let formatted = content

      .replace(/\*\*(.*?)\*\*/g, '<strong>$1</strong>')

      .replace(/^• (.+)$/gm, '<li>$1</li>')

      .replace(/^- (.+)$/gm, '<li>$1</li>')

      .split('\n\n')

      .map(paragraph => {

        if (paragraph.includes('<li>')) {

          return `<ul class="list-disc list-inside space-y-1">${paragraph}</ul>`;

        }

        return paragraph.trim() ? `<p class="mb-3">${paragraph.trim()}</p>` : '';

      })

      .join('');

    

    return formatted;

  };

  

  const parseAnalysisTable = (content) => {

    // Parse the AI response into a structured table format

    const lines = content.split('\n').filter(line => line.trim());

    const tableData = [];

    

    let currentRow = null;

    let inTable = false;

    

    for (const line of lines) {

      if (line.includes('|') && line.includes('Analysis Category')) {

        inTable = true;

        continue;

      }

      

      if (line.includes('|') && line.includes('---')) {

        continue;

      }

      

      if (inTable && line.includes('|')) {

        const cells = line.split('|').map(cell => cell.trim()).filter(cell => cell);

        if (cells.length >= 4) {

          tableData.push({

            category: cells[0],

            cultural: cells[1],

            reflection: cells[2],

            comparison: cells[3]

          });

        }

      }

    }

    

    // If no table found, create a simple structure from the content

    if (tableData.length === 0) {

      const sections = content.split('\n\n');

      sections.forEach((section, index) => {

        if (section.trim()) {

          tableData.push({

            category: `Analysis ${index + 1}`,

            cultural: section.substring(0, 200) + '...',

            reflection: 'Detailed analysis provided',

            comparison: 'Growth indicators identified'

          });

        }

      });

    }

    

    return tableData;

  };

  

  const getProgressPercentage = () => {

    return (phase / 4) * 100;

  };

  

  // API Key Modal Component

  const ApiKeyModal = () => {

    const [keyInput, setKeyInput] = useState('');

    const [isValidating, setIsValidating] = useState(false);

    

    const handleSubmit = async (e) => {

      e.preventDefault();

      if (!keyInput.trim()) return;

      

      setIsValidating(true);

      try {

        await handleApiKeySubmit(keyInput);

      } catch (error) {

        // Error is handled in parent component

      } finally {

        setIsValidating(false);

      }

    };

    

    return (

      <div className="fixed inset-0 bg-black bg-opacity-50 flex items-center justify-center z-50 p-4">

        <div className="glass p-6 max-w-md w-full">

          <h3 className="text-xl font-bold text-gray-800 mb-4">🔑 OpenAI API Key Required</h3>

          <p className="text-gray-600 mb-4">

            To generate cultural insights, please provide your OpenAI API key. 

            This will be stored locally and used only for this application.

          </p>

          <form onSubmit={handleSubmit}>

            <input

              type="password"

              value={keyInput}

              onChange={(e) => setKeyInput(e.target.value)}

              placeholder="sk-..."

              className="w-full px-3 py-2 border rounded-lg mb-4"

              autoFocus

            />

            <div className="flex gap-2">

              <button

                type="submit"

                disabled={!keyInput.trim() || isValidating}

                className="flex-1 bg-blue-600 text-white py-2 rounded-lg hover:bg-blue-700 transition disabled:opacity-50"

              >

                {isValidating ? 'Validating...' : 'Continue'}

              </button>

              <button

                type="button"

                onClick={() => setShowApiKeyModal(false)}

                className="px-4 py-2 bg-gray-300 text-gray-700 rounded-lg hover:bg-gray-400 transition"

              >

                Cancel

              </button>

            </div>

          </form>

          {aiError && (

            <div className="mt-3 text-red-600 text-sm">{aiError}</div>

          )}

          <p className="text-xs text-gray-500 mt-3">

            Get your API key at <a href="https://platform.openai.com/api-keys" target="_blank" rel="noopener noreferrer" className="text-blue-600 underline">OpenAI</a>

          </p>

        </div>

      </div>

    );

  };

  

  return (

    <div className="min-h-screen py-6">

      <div className="max-w-6xl mx-auto px-4">

        {/* Header */}

        <div className="glass p-6 mb-6 text-center">

          <h1 className="text-4xl font-bold text-gray-800 mb-2">

            🌍 Cultural Intelligence Explorer

          </h1>

          <p className="text-gray-600 mb-4">

            Develop empathy and global citizenship through cultural exploration

          </p>

          <p className="text-sm text-blue-600 font-semibold">

            Global Edition with AI Analysis - Explore any country in the world!

          </p>

          

          {/* Progress Bar */}

          <div className="max-w-md mx-auto mt-4">

            <div className="flex justify-between text-xs text-gray-500 mb-2">

              <span className={phase >= 1 ? 'text-blue-600 font-semibold' : ''}>Selection</span>

              <span className={phase >= 2 ? 'text-blue-600 font-semibold' : ''}>Insights</span>

              <span className={phase >= 3 ? 'text-blue-600 font-semibold' : ''}>Reflection</span>

              <span className={phase >= 4 ? 'text-blue-600 font-semibold' : ''}>Analysis</span>

            </div>

            <div className="w-full bg-gray-200 rounded-full h-2">

              <div 

                className="progress-bar rounded-full h-2"

                style={{ width: `${getProgressPercentage()}%` }}

              ></div>

            </div>

          </div>

        </div>

        

        {/* Phase 1: Cultural Selection */}

        {phase === 1 && (

          <div className="fade-in">

            <div className="glass p-6 mb-6">

              <h2 className="text-2xl font-bold text-gray-800 mb-4">

                🎯 Phase 1: Choose Your Cultural Journey

              </h2>

              <p className="text-gray-600 mb-6">

                Select any country in the world to explore and optionally choose a specific theme to focus on.

              </p>

              

              {/* Country Selection */}

              <div className="mb-8">

                <div className="country-dropdown">

                  <h3 className="text-xl font-semibold mb-4">🌎 Select a Country</h3>

                  <p className="text-sm opacity-90 mb-4">

                    Search from {WORLD_COUNTRIES.length} countries worldwide

                  </p>

                  <CountryDropdown 

                    selectedCountry={selectedCountry}

                    onCountrySelect={handleCountrySelect}

                  />

                </div>

              </div>

              

              {/* Theme Selection */}

              <div className="mb-8">

                <h3 className="text-xl font-semibold text-gray-700 mb-4">

                  Choose a Focus Theme (Optional)

                </h3>

                <div className="grid grid-cols-2 md:grid-cols-4 gap-3 theme-grid">

                  {THEMES.map(theme => (

                    <div

                      key={theme.id}

                      className={`theme-card ${selectedTheme?.id === theme.id ? 'selected' : ''}`}

                      onClick={() => handleThemeSelect(selectedTheme?.id === theme.id ? null : theme)}

                      tabIndex={0}

                      role="button"

                      aria-pressed={selectedTheme?.id === theme.id}

                      onKeyPress={(e) => e.key === 'Enter' && handleThemeSelect(selectedTheme?.id === theme.id ? null : theme)}

                    >

                      <div className="text-2xl mb-2">{theme.icon}</div>

                      <h4 className="font-semibold text-sm">{theme.name}</h4>

                      <p className="text-xs opacity-80 mt-1">{theme.description}</p>

                    </div>

                  ))}

                </div>

              </div>

              

              {/* Selection Summary */}

              {selectedCountry && (

                <div className="bg-blue-50 border border-blue-200 rounded-lg p-4 mb-6">

                  <h4 className="font-semibold text-blue-800 mb-2">Your Selection:</h4>

                  <p className="text-blue-700">

                    <strong>{selectedCountry.flag} {selectedCountry.name}</strong> ({selectedCountry.region})

                    {selectedTheme && (

                      <span> - Focus: {selectedTheme.icon} {selectedTheme.name}</span>

                    )}

                  </p>

                </div>

              )}

              

              {/* Continue Button */}

              <div className="text-center">

                <button

                  onClick={proceedToInsights}

                  disabled={!selectedCountry}

                  className="bg-gradient-to-r from-blue-600 to-purple-600 text-white px-8 py-3 rounded-lg font-semibold hover:from-blue-700 hover:to-purple-700 transition disabled:opacity-50 disabled:cursor-not-allowed"

                >

                  Explore Culture 🚀

                </button>

              </div>

            </div>

          </div>

        )}

        

        {/* Phase 2: AI Cultural Insights */}

        {phase === 2 && (

          <div className="fade-in">

            <div className="glass p-6 mb-6">

              <div className="flex items-center justify-between mb-6">

                <div>

                  <h2 className="text-2xl font-bold text-gray-800">

                    🧠 Phase 2: Cultural Insights

                  </h2>

                  <p className="text-gray-600">

                    Exploring {selectedCountry?.flag} {selectedCountry?.name} ({selectedCountry?.region})

                    {selectedTheme && ` - ${selectedTheme.icon} ${selectedTheme.name}`}

                  </p>

                </div>

                <button

                  onClick={() => setPhase(1)}

                  className="text-blue-600 hover:text-blue-800 transition"

                >

                  ← Back to Selection

                </button>

              </div>

              

              {isGeneratingInsights && (

                <div className="text-center py-12">

                  <div className="typing-indicator mb-4">

                    <span className="text-lg text-gray-600 mr-3">Generating cultural insights</span>

                    <div className="typing-dot"></div>

                    <div className="typing-dot"></div>

                    <div className="typing-dot"></div>

                  </div>

                  <p className="text-gray-500">This may take a moment...</p>

                </div>

              )}

              

              {aiError && (

                <div className="bg-red-50 border border-red-200 rounded-lg p-4 mb-6">

                  <h4 className="font-semibold text-red-800 mb-2">Error:</h4>

                  <p className="text-red-700">{aiError}</p>

                  <button

                    onClick={generateInsights}

                    className="mt-3 bg-red-600 text-white px-4 py-2 rounded hover:bg-red-700 transition"

                  >

                    Try Again

                  </button>

                </div>

              )}

              

              {insights && (

                <div className="slide-in">

                  <div className="insight-section">

                    <div 

                      className="prose prose-lg max-w-none"

                      dangerouslySetInnerHTML={{ __html: formatInsights(insights) }}

                    />

                  </div>

                  

                  <div className="text-center mt-8">

                    <button

                      onClick={proceedToReflection}

                      className="bg-gradient-to-r from-green-600 to-blue-600 text-white px-8 py-3 rounded-lg font-semibold hover:from-green-700 hover:to-blue-700 transition"

                    >

                      Reflect on Learning 💭

                    </button>

                  </div>

                </div>

              )}

            </div>

          </div>

        )}

        

        {/* Phase 3: Reflection & Comparison */}

        {phase === 3 && (

          <div className="fade-in">

            <div className="glass p-6 mb-6">

              <div className="flex items-center justify-between mb-6">

                <div>

                  <h2 className="text-2xl font-bold text-gray-800">

                    💭 Phase 3: Reflection & Growth

                  </h2>

                  <p className="text-gray-600">

                    Reflect on your cultural exploration and personal insights

                  </p>

                </div>

                <button

                  onClick={() => setPhase(2)}

                  className="text-blue-600 hover:text-blue-800 transition"

                >

                  ← Back to Insights

                </button>

              </div>

              

              <div className="space-y-6">

                {REFLECTION_PROMPTS.map(prompt => (

                  <div key={prompt.id} className="reflection-card">

                    <div className="flex items-start gap-3 mb-3">

                      <span className="text-2xl">{prompt.icon}</span>

                      <h3 className="font-semibold text-gray-800 flex-1">

                        {prompt.question}

                      </h3>

                    </div>

                    <textarea

                      value={reflections[prompt.id] || ''}

                      onChange={(e) => handleReflectionChange(prompt.id, e.target.value)}

                      placeholder="Share your thoughts and insights..."

                      className="w-full px-4 py-3 border border-gray-300 rounded-lg resize-none focus:ring-2 focus:ring-blue-500 focus:border-transparent"

                      rows={4}

                    />

                  </div>

                ))}

              </div>

              

              <div className="text-center mt-8">

                <button

                  onClick={proceedToAnalysis}

                  className="bg-gradient-to-r from-purple-600 to-pink-600 text-white px-8 py-3 rounded-lg font-semibold hover:from-purple-700 hover:to-pink-700 transition"

                >

                  Generate AI Analysis 📊

                </button>

              </div>

            </div>

          </div>

        )}

        

        {/* Phase 4: AI Analysis & Comparison */}

        {phase === 4 && (

          <div className="fade-in">

            <div className="glass p-6 mb-6">

              <div className="flex items-center justify-between mb-6">

                <div>

                  <h2 className="text-2xl font-bold text-gray-800">

                    📊 Phase 4: AI Analysis & Insights

                  </h2>

                  <p className="text-gray-600">

                    AI-powered comparison between cultural themes and your reflections

                  </p>

                </div>

                <button

                  onClick={() => setPhase(3)}

                  className="text-blue-600 hover:text-blue-800 transition"

                >

                  ← Back to Reflection

                </button>

              </div>

              

              {isGeneratingAnalysis && (

                <div className="text-center py-12">

                  <div className="typing-indicator mb-4">

                    <span className="text-lg text-gray-600 mr-3">Analyzing your cultural journey</span>

                    <div className="typing-dot"></div>

                    <div className="typing-dot"></div>

                    <div className="typing-dot"></div>

                  </div>

                  <p className="text-gray-500">Creating personalized insights...</p>

                </div>

              )}

              

              {aiError && (

                <div className="bg-red-50 border border-red-200 rounded-lg p-4 mb-6">

                  <h4 className="font-semibold text-red-800 mb-2">Error:</h4>

                  <p className="text-red-700">{aiError}</p>

                  <button

                    onClick={generateAnalysis}

                    className="mt-3 bg-red-600 text-white px-4 py-2 rounded hover:bg-red-700 transition"

                  >

                    Try Again

                  </button>

                </div>

              )}

              

              {analysis && (

                <div className="slide-in">

                  <div className="mb-6">

                    <h3 className="text-xl font-semibold text-gray-800 mb-4">

                      🎯 Cultural Intelligence Analysis

                    </h3>

                    <div className="bg-blue-50 border border-blue-200 rounded-lg p-4 mb-6">

                      <p className="text-blue-700">

                        <strong>Analysis for:</strong> {selectedCountry?.flag} {selectedCountry?.name}

                        {selectedTheme && ` - ${selectedTheme.icon} ${selectedTheme.name}`}

                      </p>

                    </div>

                  </div>

                  

                  <div className="analysis-table mb-8">

                    <table>

                      <thead>

                        <tr>

                          <th className="w-1/4">Analysis Category</th>

                          <th className="w-1/4">Cultural Theme Insights</th>

                          <th className="w-1/4">Your Reflection Analysis</th>

                          <th className="w-1/4">Growth Indicators</th>

                        </tr>

                      </thead>

                      <tbody>

                        {parseAnalysisTable(analysis).map((row, index) => (

                          <tr key={index}>

                            <td className="font-semibold text-gray-800">

                              {row.category}

                              <div className="mt-2">

                                <span className="insight-badge">Cultural Insight</span>

                              </div>

                            </td>

                            <td className="text-gray-700">

                              {row.cultural}

                            </td>

                            <td className="text-gray-700">

                              {row.reflection}

                              <div className="mt-2">

                                <span className="comparison-badge">Personal Growth</span>

                              </div>

                            </td>

                            <td className="text-gray-700">

                              {row.comparison}

                            </td>

                          </tr>

                        ))}

                      </tbody>

                    </table>

                  </div>

                  

                  <div className="text-center mt-8">

                    <button

                      onClick={completeExploration}

                      className="bg-gradient-to-r from-green-600 to-teal-600 text-white px-8 py-3 rounded-lg font-semibold hover:from-green-700 hover:to-teal-700 transition"

                    >

                      Complete Exploration ✨

                    </button>

                  </div>

                </div>

              )}

            </div>

          </div>

        )}

        

        {/* Exploration History */}

        {explorationHistory.length > 0 && (

          <div className="glass p-6">

            <h3 className="text-xl font-bold text-gray-800 mb-4">

              📚 Your Cultural Journey

            </h3>

            <div className="grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-4">

              {explorationHistory.slice(-6).map(exploration => (

                <div key={exploration.id} className="bg-white rounded-lg p-4 border border-gray-200">

                  <div className="flex items-center gap-2 mb-2">

                    <span className="text-xl">{exploration.country.flag}</span>

                    <h4 className="font-semibold text-gray-800">{exploration.country.name}</h4>

                  </div>

                  <p className="text-xs text-gray-500 mb-1">{exploration.country.region}</p>

                  {exploration.theme && (

                    <p className="text-sm text-gray-600 mb-2">

                      {exploration.theme.icon} {exploration.theme.name}

                    </p>

                  )}

                  <div className="flex gap-1 mb-2">

                    <span className="insight-badge text-xs">Insights</span>

                    <span className="comparison-badge text-xs">Analysis</span>

                  </div>

                  <p className="text-xs text-gray-500">

                    {new Date(exploration.timestamp).toLocaleDateString()}

                  </p>

                </div>

              ))}

            </div>

            <p className="text-center text-gray-500 mt-4">

              {explorationHistory.length} culture{explorationHistory.length !== 1 ? 's' : ''} explored with AI analysis

            </p>

          </div>

        )}

      </div>

      

      {/* API Key Modal */}

      {showApiKeyModal && <ApiKeyModal />}

    </div>

  );

}



ReactDOM.createRoot(document.getElementById("root")).render(<CulturalIntelligenceExplorer />);

</script>
</body>
</html>