File size: 56,059 Bytes
037f856
 
 
 
 
 
 
 
 
feefa81
037f856
 
feefa81
 
 
 
 
 
037f856
 
feefa81
037f856
 
 
feefa81
 
 
 
037f856
 
feefa81
 
037f856
 
feefa81
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
037f856
 
 
 
 
feefa81
037f856
 
 
 
 
 
 
 
 
 
 
feefa81
037f856
 
 
 
 
 
 
 
 
 
 
 
 
 
 
feefa81
 
037f856
 
 
 
 
 
feefa81
037f856
 
 
 
feefa81
037f856
 
 
 
 
 
 
 
feefa81
037f856
 
feefa81
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
037f856
 
feefa81
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
037f856
 
feefa81
 
 
 
 
 
 
 
037f856
feefa81
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
037f856
 
 
feefa81
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
037f856
 
 
feefa81
 
037f856
 
 
feefa81
037f856
feefa81
037f856
 
 
 
 
feefa81
037f856
feefa81
037f856
 
 
 
 
 
feefa81
 
 
 
 
 
037f856
feefa81
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
037f856
 
feefa81
 
037f856
 
feefa81
 
 
037f856
 
 
feefa81
 
 
 
 
 
 
 
 
037f856
feefa81
 
 
 
 
 
037f856
feefa81
 
 
 
 
 
037f856
 
 
 
 
 
 
feefa81
037f856
feefa81
037f856
 
 
 
feefa81
 
 
 
 
 
 
 
 
 
 
037f856
 
 
 
 
 
feefa81
 
 
 
 
 
037f856
feefa81
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
037f856
 
feefa81
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
037f856
 
 
 
 
feefa81
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
037f856
 
 
feefa81
037f856
feefa81
037f856
 
 
 
feefa81
 
 
 
 
 
 
 
 
 
 
037f856
 
 
 
feefa81
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
037f856
 
feefa81
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
36a1951
 
 
 
feefa81
 
 
 
 
 
 
 
 
037f856
 
 
 
feefa81
 
037f856
 
feefa81
037f856
 
feefa81
037f856
 
 
 
 
 
 
 
 
 
 
feefa81
 
 
 
037f856
 
 
 
 
 
 
 
 
feefa81
 
 
 
037f856
 
 
 
 
 
 
 
 
 
 
feefa81
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
037f856
feefa81
 
037f856
feefa81
 
037f856
feefa81
 
 
 
 
 
037f856
feefa81
 
037f856
 
 
feefa81
037f856
feefa81
 
 
 
037f856
feefa81
 
 
 
 
 
 
 
 
 
037f856
feefa81
 
037f856
 
 
feefa81
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
037f856
 
feefa81
 
 
 
 
 
 
 
 
 
037f856
 
feefa81
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
037f856
 
 
 
 
 
 
 
 
 
feefa81
037f856
 
 
 
feefa81
037f856
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
feefa81
037f856
 
 
 
feefa81
037f856
 
 
 
feefa81
037f856
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
feefa81
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
037f856
 
feefa81
037f856
 
 
 
 
 
 
 
feefa81
 
 
 
 
 
 
 
 
 
037f856
c86a3da
 
037f856
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
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>OpenAI O4 Analysis App</title>
    <script src="https://cdn.tailwindcss.com"></script>
    <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/animate.css/4.1.1/animate.min.css"/>
    <link href="https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&display=swap" rel="stylesheet">
    <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.4.0/css/all.min.css">
    <script src="https://cdn.jsdelivr.net/npm/axios/dist/axios.min.js"></script>
    <style>
        :root {
            --primary: #6366f1;
            --primary-dark: #4f46e5;
            --primary-light: #818cf8;
        }
        
        body {
            font-family: 'Inter', sans-serif;
            background: linear-gradient(135deg, #f8fafc 0%, #e2e8f0 100%);
            min-height: 100vh;
        }
        
        .gradient-bg {
            background: linear-gradient(135deg, var(--primary) 0%, var(--primary-light) 100%);
        }
        
        .tab-button {
            transition: all 0.3s ease;
            position: relative;
            overflow: hidden;
        }
        
        .tab-button::after {
            content: '';
            position: absolute;
            bottom: 0;
            left: 0;
            width: 100%;
            height: 3px;
            background: white;
            transform: scaleX(0);
            transform-origin: right;
            transition: transform 0.3s ease;
        }
        
        .tab-button.active::after {
            transform: scaleX(1);
            transform-origin: left;
        }
        
        .result-box {
            transition: all 0.3s ease;
            min-height: 200px;
            background: linear-gradient(135deg, #f9fafb 0%, #f3f4f6 100%);
        }
        
        .loading-dots {
            display: inline-block;
        }
        
        .loading-dots span {
            display: inline-block;
            width: 8px;
            height: 8px;
            border-radius: 50%;
            background-color: var(--primary);
            margin: 0 2px;
            animation: bounce 1.4s infinite ease-in-out both;
        }
        
        .loading-dots span:nth-child(1) {
            animation-delay: -0.32s;
        }
        
        .loading-dots span:nth-child(2) {
            animation-delay: -0.16s;
        }
        
        @keyframes bounce {
            0%, 80%, 100% { 
                transform: scale(0);
            } 
            40% { 
                transform: scale(1);
            }
        }
        
        .file-input-label {
            transition: all 0.3s ease;
            position: relative;
        }
        
        .file-input-label:hover {
            transform: translateY(-2px);
            box-shadow: 0 4px 6px -1px rgba(99, 102, 241, 0.3), 0 2px 4px -1px rgba(99, 102, 241, 0.06);
        }
        
        .glow {
            animation: glow 2s infinite alternate;
        }
        
        @keyframes glow {
            from {
                box-shadow: 0 0 5px rgba(99, 102, 241, 0.5);
            }
            to {
                box-shadow: 0 0 20px rgba(99, 102, 241, 0.8);
            }
        }
        
        .card {
            box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
            transition: all 0.3s ease;
        }
        
        .card:hover {
            transform: translateY(-5px);
            box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04);
        }
        
        .btn-primary {
            background: var(--primary);
            transition: all 0.3s ease;
        }
        
        .btn-primary:hover {
            background: var(--primary-dark);
            transform: translateY(-2px);
        }
        
        .btn-secondary {
            background: #f1f5f9;
            transition: all 0.3s ease;
        }
        
        .btn-secondary:hover {
            background: #e2e8f0;
            transform: translateY(-2px);
        }
        
        .input-field {
            transition: all 0.3s ease;
            box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.05);
        }
        
        .input-field:focus {
            box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.3);
        }
        
        .preview-container {
            position: relative;
            border-radius: 0.5rem;
            overflow: hidden;
            box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
        }
        
        .remove-btn {
            position: absolute;
            top: 0.5rem;
            right: 0.5rem;
            background: rgba(0, 0, 0, 0.6);
            color: white;
            border-radius: 50%;
            width: 2rem;
            height: 2rem;
            display: flex;
            align-items: center;
            justify-content: center;
            cursor: pointer;
            transition: all 0.3s ease;
        }
        
        .remove-btn:hover {
            background: rgba(239, 68, 68, 0.8);
            transform: scale(1.1);
        }
        
        .pulse {
            animation: pulse 2s infinite;
        }
        
        @keyframes pulse {
            0% {
                transform: scale(1);
            }
            50% {
                transform: scale(1.05);
            }
            100% {
                transform: scale(1);
            }
        }
        
        .floating {
            animation: floating 6s ease-in-out infinite;
        }
        
        @keyframes floating {
            0% {
                transform: translateY(0px);
            }
            50% {
                transform: translateY(-10px);
            }
            100% {
                transform: translateY(0px);
            }
        }
        
        .wave {
            position: absolute;
            bottom: 0;
            left: 0;
            width: 100%;
            overflow: hidden;
            line-height: 0;
        }
        
        .wave svg {
            position: relative;
            display: block;
            width: calc(100% + 1.3px);
            height: 150px;
        }
        
        .wave .shape-fill {
            fill: #FFFFFF;
        }
        
        .feature-icon {
            width: 60px;
            height: 60px;
            border-radius: 50%;
            background: linear-gradient(135deg, rgba(99, 102, 241, 0.1) 0%, rgba(99, 102, 241, 0.2) 100%);
            display: flex;
            align-items: center;
            justify-content: center;
            margin-bottom: 1rem;
        }
    </style>
</head>
<body class="antialiased">
    <!-- Wave Background -->
    <div class="fixed top-0 left-0 w-full h-full -z-10 opacity-10">
        <div class="absolute top-0 left-0 w-full h-full bg-gradient-to-br from-indigo-100 to-purple-100"></div>
    </div>
    
    <!-- Main Container -->
    <div class="max-w-7xl mx-auto px-4 sm:px-6 lg:px-8 py-12">
        <!-- Header -->
        <div class="text-center mb-16 animate__animated animate__fadeIn">
            <div class="inline-flex items-center justify-center mb-4 px-6 py-2 rounded-full bg-indigo-50 text-indigo-600">
                <i class="fas fa-bolt mr-2"></i>
                <span class="font-medium">AI-Powered Analysis</span>
            </div>
            <h1 class="text-5xl font-bold text-gray-900 mb-4">OpenAI O4 Mini <span class="text-indigo-600">Analysis</span></h1>
            <p class="text-xl text-gray-600 max-w-2xl mx-auto">Unlock insights from your documents and images with cutting-edge AI technology</p>
        </div>
        
        <!-- Features Section -->
        <div class="grid grid-cols-1 md:grid-cols-3 gap-8 mb-16">
            <div class="bg-white rounded-xl card p-6 text-center">
                <div class="feature-icon mx-auto">
                    <i class="fas fa-file-pdf text-indigo-600 text-2xl"></i>
                </div>
                <h3 class="text-xl font-semibold text-gray-800 mb-2">PDF Analysis</h3>
                <p class="text-gray-600">Extract key information and insights from your PDF documents with AI-powered analysis.</p>
            </div>
            
            <div class="bg-white rounded-xl card p-6 text-center">
                <div class="feature-icon mx-auto">
                    <i class="fas fa-image text-indigo-600 text-2xl"></i>
                </div>
                <h3 class="text-xl font-semibold text-gray-800 mb-2">Image Analysis</h3>
                <p class="text-gray-600">Understand visual content with advanced image recognition and description capabilities.</p>
            </div>
            
            <div class="bg-white rounded-xl card p-6 text-center">
                <div class="feature-icon mx-auto">
                    <i class="fas fa-brain text-indigo-600 text-2xl"></i>
                </div>
                <h3 class="text-xl font-semibold text-gray-800 mb-2">Smart Insights</h3>
                <p class="text-gray-600">Get comprehensive answers to your questions with adjustable reasoning levels.</p>
            </div>
        </div>
        
        <!-- API Key Input -->
        <div class="bg-white rounded-xl card p-8 mb-12 animate__animated animate__fadeInUp relative overflow-hidden">
            <div class="absolute -top-10 -right-10 w-32 h-32 rounded-full bg-indigo-100 opacity-50"></div>
            <div class="absolute -bottom-10 -left-10 w-32 h-32 rounded-full bg-purple-100 opacity-50"></div>
            
            <div class="relative z-10">
                <label for="api-key" class="block text-sm font-medium text-gray-700 mb-2 flex items-center">
                    <i class="fas fa-key mr-2 text-indigo-600"></i>
                    OpenAI API Key
                </label>
                <div class="relative">
                    <input 
                        type="password" 
                        id="api-key"
                        placeholder="Enter your OpenAI API key here..." 
                        class="w-full px-4 py-3 rounded-lg border border-gray-300 input-field focus:ring-2 focus:ring-indigo-500 focus:border-indigo-500 transition duration-200"
                    >
                    <button 
                        onclick="toggleApiKeyVisibility()" 
                        class="absolute right-3 top-3 text-gray-500 hover:text-indigo-600 focus:outline-none"
                    >
                        <i class="far fa-eye"></i>
                    </button>
                </div>
                <p class="mt-2 text-sm text-gray-500">
                    <i class="fas fa-info-circle mr-1 text-indigo-500"></i>
                    Your API key is only used for requests and is not stored.
                </p>
            </div>
        </div>
        
        <!-- Tabs Navigation -->
        <div class="flex space-x-2 mb-8 animate__animated animate__fadeIn">
            <button 
                id="pdf-tab" 
                onclick="switchTab('pdf')" 
                class="tab-button active px-8 py-4 rounded-t-lg font-medium bg-white text-indigo-600 border-b-2 border-indigo-600"
            >
                <i class="fas fa-file-pdf mr-2"></i>
                PDF Analysis
            </button>
            <button 
                id="image-tab" 
                onclick="switchTab('image')" 
                class="tab-button px-8 py-4 rounded-t-lg font-medium bg-white text-gray-600 hover:text-indigo-600 border-b-2 border-transparent hover:border-gray-300"
            >
                <i class="fas fa-image mr-2"></i>
                Image Analysis
            </button>
        </div>
        
        <!-- PDF Analysis Tab -->
        <div id="pdf-content" class="animate__animated animate__fadeIn">
            <div class="bg-white rounded-b-xl rounded-tr-xl card overflow-hidden">
                <div class="p-8">
                    <h2 class="text-2xl font-semibold text-gray-800 mb-6 flex items-center">
                        <i class="fas fa-file-pdf mr-3 text-indigo-600"></i>
                        PDF Document Analysis
                    </h2>
                    
                    <div class="mb-8">
                        <label class="block text-sm font-medium text-gray-700 mb-3">Upload PDF</label>
                        <div id="pdf-upload-container">
                            <label for="pdf-upload" class="file-input-label cursor-pointer flex flex-col items-center justify-center px-6 py-12 border-2 border-dashed border-gray-300 rounded-lg bg-gray-50 hover:bg-gray-100 transition duration-200">
                                <i class="fas fa-cloud-upload-alt text-4xl text-gray-400 mb-3"></i>
                                <span class="text-sm font-medium text-gray-600">Drag & drop your PDF here or click to browse</span>
                                <span class="text-xs text-gray-500 mt-1">Supports .pdf files up to 10MB</span>
                                <input id="pdf-upload" type="file" accept=".pdf" class="hidden">
                            </label>
                        </div>
                        <div id="pdf-preview-container" class="hidden mt-4">
                            <div class="preview-container p-4 bg-gray-50 rounded-lg">
                                <div class="flex items-center">
                                    <i class="fas fa-file-pdf text-3xl text-red-500 mr-3"></i>
                                    <div>
                                        <p id="pdf-filename" class="font-medium text-gray-800"></p>
                                        <p id="pdf-filesize" class="text-sm text-gray-500"></p>
                                    </div>
                                    <button id="remove-pdf" class="ml-auto remove-btn">
                                        <i class="fas fa-times"></i>
                                    </button>
                                </div>
                            </div>
                        </div>
                    </div>
                    
                    <div class="mb-8">
                        <label for="pdf-prompt" class="block text-sm font-medium text-gray-700 mb-3">Analysis Prompt</label>
                        <textarea 
                            id="pdf-prompt" 
                            rows="4" 
                            class="w-full px-4 py-3 rounded-lg border border-gray-300 input-field focus:ring-2 focus:ring-indigo-500 focus:border-indigo-500 transition duration-200"
                            placeholder="What would you like to know about this PDF? (e.g., 'Summarize this document', 'What are the key points?', 'Extract the main ideas')"
                        >What is this PDF about?</textarea>
                    </div>
                    
                    <div class="mb-8">
                        <label class="block text-sm font-medium text-gray-700 mb-3">Reasoning Effort Level</label>
                        <div class="grid grid-cols-1 md:grid-cols-3 gap-4">
                            <label class="inline-flex items-center bg-gray-50 hover:bg-gray-100 rounded-lg p-4 cursor-pointer transition duration-200">
                                <input type="radio" name="pdf-effort" value="low" class="h-5 w-5 text-indigo-600 focus:ring-indigo-500">
                                <div class="ml-3">
                                    <span class="block text-sm font-medium text-gray-700">Quick Scan</span>
                                    <span class="block text-xs text-gray-500">Basic analysis, faster results</span>
                                </div>
                            </label>
                            <label class="inline-flex items-center bg-gray-50 hover:bg-gray-100 rounded-lg p-4 cursor-pointer transition duration-200">
                                <input type="radio" name="pdf-effort" value="medium" checked class="h-5 w-5 text-indigo-600 focus:ring-indigo-500">
                                <div class="ml-3">
                                    <span class="block text-sm font-medium text-gray-700">Standard</span>
                                    <span class="block text-xs text-gray-500">Balanced speed and depth</span>
                                </div>
                            </label>
                            <label class="inline-flex items-center bg-gray-50 hover:bg-gray-100 rounded-lg p-4 cursor-pointer transition duration-200">
                                <input type="radio" name="pdf-effort" value="high" class="h-5 w-5 text-indigo-600 focus:ring-indigo-500">
                                <div class="ml-3">
                                    <span class="block text-sm font-medium text-gray-700">Deep Dive</span>
                                    <span class="block text-xs text-gray-500">Comprehensive, detailed analysis</span>
                                </div>
                            </label>
                        </div>
                    </div>
                    
                    <button 
                        id="analyze-pdf-btn" 
                        onclick="analyzePDF()" 
                        class="w-full py-4 px-6 bg-indigo-600 hover:bg-indigo-700 text-white font-medium rounded-lg transition duration-200 transform hover:scale-[1.02] focus:outline-none focus:ring-2 focus:ring-indigo-500 focus:ring-offset-2 flex items-center justify-center"
                    >
                        <i class="fas fa-magic mr-2"></i>
                        Analyze PDF
                    </button>
                </div>
                
                <div id="pdf-result" class="result-box border-t border-gray-200 p-8 hidden">
                    <div class="flex items-center justify-between mb-6">
                        <h3 class="text-xl font-semibold text-gray-800 flex items-center">
                            <i class="fas fa-chart-line mr-2 text-indigo-600"></i>
                            Analysis Results
                        </h3>
                        <button id="copy-pdf-result" class="text-sm text-indigo-600 hover:text-indigo-800 flex items-center">
                            <i class="far fa-copy mr-1"></i> Copy
                        </button>
                    </div>
                    <div id="pdf-result-content" class="min-h-40 p-6 bg-white rounded-lg border border-gray-200 shadow-sm"></div>
                </div>
            </div>
        </div>
        
        <!-- Image Analysis Tab -->
        <div id="image-content" class="hidden animate__animated animate__fadeIn">
            <div class="bg-white rounded-b-xl rounded-tr-xl card overflow-hidden">
                <div class="p-8">
                    <h2 class="text-2xl font-semibold text-gray-800 mb-6 flex items-center">
                        <i class="fas fa-image mr-3 text-indigo-600"></i>
                        Image Analysis
                    </h2>
                    
                    <div class="mb-8">
                        <label class="block text-sm font-medium text-gray-700 mb-3">Image Source</label>
                        <div class="grid grid-cols-1 md:grid-cols-2 gap-6">
                            <div>
                                <div class="flex items-center space-x-4 mb-4">
                                    <div class="flex-1 border-b-2 border-indigo-600 pb-2">
                                        <h4 class="font-medium text-indigo-600 flex items-center">
                                            <i class="fas fa-upload mr-2"></i>
                                            Upload Image
                                        </h4>
                                    </div>
                                    <div class="flex-1 text-center text-gray-400 pb-2">
                                        <h4 class="font-medium">or</h4>
                                    </div>
                                    <div class="flex-1 border-b-2 border-gray-200 pb-2">
                                        <h4 class="font-medium text-gray-600 hover:text-indigo-600 cursor-pointer flex items-center justify-end" onclick="switchImageSource('url')">
                                            <i class="fas fa-link mr-2"></i>
                                            Use URL
                                        </h4>
                                    </div>
                                </div>
                                
                                <div id="image-upload-container">
                                    <label for="image-upload" class="file-input-label cursor-pointer flex flex-col items-center justify-center px-6 py-12 border-2 border-dashed border-gray-300 rounded-lg bg-gray-50 hover:bg-gray-100 transition duration-200">
                                        <i class="fas fa-cloud-upload-alt text-4xl text-gray-400 mb-3"></i>
                                        <span class="text-sm font-medium text-gray-600">Drag & drop your image here or click to browse</span>
                                        <span class="text-xs text-gray-500 mt-1">Supports JPG, PNG, GIF up to 5MB</span>
                                        <input id="image-upload" type="file" accept="image/*" class="hidden">
                                    </label>
                                </div>
                                
                                <div id="image-preview-container" class="hidden mt-4">
                                    <div class="preview-container">
                                        <img id="image-preview" src="" alt="Preview" class="w-full h-auto rounded-lg">
                                        <button id="remove-image" class="remove-btn">
                                            <i class="fas fa-times"></i>
                                        </button>
                                    </div>
                                </div>
                            </div>
                            
                            <div id="image-url-container" class="hidden">
                                <div class="flex items-center space-x-4 mb-4">
                                    <div class="flex-1 border-b-2 border-gray-200 pb-2">
                                        <h4 class="font-medium text-gray-600 hover:text-indigo-600 cursor-pointer flex items-center" onclick="switchImageSource('upload')">
                                            <i class="fas fa-upload mr-2"></i>
                                            Upload Image
                                        </h4>
                                    </div>
                                    <div class="flex-1 text-center text-gray-400 pb-2">
                                        <h4 class="font-medium">or</h4>
                                    </div>
                                    <div class="flex-1 border-b-2 border-indigo-600 pb-2">
                                        <h4 class="font-medium text-indigo-600 flex items-center justify-end">
                                            <i class="fas fa-link mr-2"></i>
                                            Use URL
                                        </h4>
                                    </div>
                                </div>
                                
                                <div class="mb-4">
                                    <label for="image-url" class="block text-sm font-medium text-gray-700 mb-2">Image URL</label>
                                    <input 
                                        type="text" 
                                        id="image-url"
                                        placeholder="https://example.com/image.jpg" 
                                        class="w-full px-4 py-3 rounded-lg border border-gray-300 input-field focus:ring-2 focus:ring-indigo-500 focus:border-indigo-500 transition duration-200"
                                    >
                                </div>
                                
                                <div id="url-preview-container" class="hidden mt-4">
                                    <div class="preview-container">
                                        <img id="url-preview" src="" alt="Preview" class="w-full h-auto rounded-lg">
                                        <button id="remove-url" class="remove-btn">
                                            <i class="fas fa-times"></i>
                                        </button>
                                    </div>
                                </div>
                            </div>
                        </div>
                    </div>
                    
                    <div class="mb-8">
                        <label for="image-prompt" class="block text-sm font-medium text-gray-700 mb-3">Analysis Prompt</label>
                        <textarea 
                            id="image-prompt" 
                            rows="4" 
                            class="w-full px-4 py-3 rounded-lg border border-gray-300 input-field focus:ring-2 focus:ring-indigo-500 focus:border-indigo-500 transition duration-200"
                            placeholder="What would you like to know about this image? (e.g., 'Describe this image', 'What objects are visible?', 'What is the main subject?')"
                        >What is this image about?</textarea>
                    </div>
                    
                    <div class="mb-8">
                        <label class="block text-sm font-medium text-gray-700 mb-3">Reasoning Effort Level</label>
                        <div class="grid grid-cols-1 md:grid-cols-3 gap-4">
                            <label class="inline-flex items-center bg-gray-50 hover:bg-gray-100 rounded-lg p-4 cursor-pointer transition duration-200">
                                <input type="radio" name="image-effort" value="low" class="h-5 w-5 text-indigo-600 focus:ring-indigo-500">
                                <div class="ml-3">
                                    <span class="block text-sm font-medium text-gray-700">Quick Scan</span>
                                    <span class="block text-xs text-gray-500">Basic analysis, faster results</span>
                                </div>
                            </label>
                            <label class="inline-flex items-center bg-gray-50 hover:bg-gray-100 rounded-lg p-4 cursor-pointer transition duration-200">
                                <input type="radio" name="image-effort" value="medium" checked class="h-5 w-5 text-indigo-600 focus:ring-indigo-500">
                                <div class="ml-3">
                                    <span class="block text-sm font-medium text-gray-700">Standard</span>
                                    <span class="block text-xs text-gray-500">Balanced speed and depth</span>
                                </div>
                            </label>
                            <label class="inline-flex items-center bg-gray-50 hover:bg-gray-100 rounded-lg p-4 cursor-pointer transition duration-200">
                                <input type="radio" name="image-effort" value="high" class="h-5 w-5 text-indigo-600 focus:ring-indigo-500">
                                <div class="ml-3">
                                    <span class="block text-sm font-medium text-gray-700">Deep Dive</span>
                                    <span class="block text-xs text-gray-500">Comprehensive, detailed analysis</span>
                                </div>
                            </label>
                        </div>
                    </div>
                    
                    <button 
                        id="analyze-image-btn" 
                        onclick="analyzeImage()" 
                        class="w-full py-4 px-6 bg-indigo-600 hover:bg-indigo-700 text-white font-medium rounded-lg transition duration-200 transform hover:scale-[1.02] focus:outline-none focus:ring-2 focus:ring-indigo-500 focus:ring-offset-2 flex items-center justify-center"
                    >
                        <i class="fas fa-magic mr-2"></i>
                        Analyze Image
                    </button>
                </div>
                
                <div id="image-result" class="result-box border-t border-gray-200 p-8 hidden">
                    <div class="flex items-center justify-between mb-6">
                        <h3 class="text-xl font-semibold text-gray-800 flex items-center">
                            <i class="fas fa-chart-line mr-2 text-indigo-600"></i>
                            Analysis Results
                        </h3>
                        <button id="copy-image-result" class="text-sm text-indigo-600 hover:text-indigo-800 flex items-center">
                            <i class="far fa-copy mr-1"></i> Copy
                        </button>
                    </div>
                    <div id="image-result-content" class="min-h-40 p-6 bg-white rounded-lg border border-gray-200 shadow-sm"></div>
                </div>
            </div>
        </div>
        
        <!-- How It Works Section -->
        <div class="mt-20 bg-white rounded-xl card p-8 relative overflow-hidden">
            <div class="absolute -top-20 -right-20 w-64 h-64 rounded-full bg-indigo-100 opacity-30"></div>
            <div class="absolute -bottom-20 -left-20 w-64 h-64 rounded-full bg-purple-100 opacity-30"></div>
            
            <div class="relative z-10">
                <h2 class="text-3xl font-bold text-center text-gray-900 mb-12">
                    <span class="text-indigo-600">How It Works</span>
                </h2>
                
                <div class="grid grid-cols-1 md:grid-cols-3 gap-8">
                    <div class="flex flex-col items-center text-center">
                        <div class="w-16 h-16 rounded-full bg-indigo-100 text-indigo-600 flex items-center justify-center mb-4 text-2xl">
                            1
                        </div>
                        <h3 class="text-xl font-semibold text-gray-800 mb-2">Upload Your File</h3>
                        <p class="text-gray-600">Select a PDF document or image you want to analyze by uploading from your device or providing a URL.</p>
                    </div>
                    
                    <div class="flex flex-col items-center text-center">
                        <div class="w-16 h-16 rounded-full bg-indigo-100 text-indigo-600 flex items-center justify-center mb-4 text-2xl">
                            2
                        </div>
                        <h3 class="text-xl font-semibold text-gray-800 mb-2">Set Your Preferences</h3>
                        <p class="text-gray-600">Enter your analysis prompt and choose the reasoning effort level that suits your needs.</p>
                    </div>
                    
                    <div class="flex flex-col items-center text-center">
                        <div class="w-16 h-16 rounded-full bg-indigo-100 text-indigo-600 flex items-center justify-center mb-4 text-2xl">
                            3
                        </div>
                        <h3 class="text-xl font-semibold text-gray-800 mb-2">Get AI Insights</h3>
                        <p class="text-gray-600">Receive comprehensive analysis and answers to your questions powered by OpenAI's advanced models.</p>
                    </div>
                </div>
            </div>
        </div>
    </div>
    
    <!-- Footer -->
    <footer class="bg-gray-900 text-white py-12 mt-20 relative">
        <div class="max-w-7xl mx-auto px-4 sm:px-6 lg:px-8">
            <div class="grid grid-cols-1 md:grid-cols-3 gap-8">
                <div>
                    <h3 class="text-xl font-semibold mb-4">OpenAI O4 Mini Analysis</h3>
                    <p class="text-gray-400">Unlock the power of AI to analyze your documents and images with ease.</p>
                </div>
                <div>
                    <h3 class="text-xl font-semibold mb-4">Quick Links</h3>
                    <ul class="space-y-2">
                        <li><a href="#" class="text-gray-400 hover:text-white transition duration-200">Home</a></li>
                        <li><a href="#" class="text-gray-400 hover:text-white transition duration-200">PDF Analysis</a></li>
                        <li><a href="#" class="text-gray-400 hover:text-white transition duration-200">Image Analysis</a></li>
                    </ul>
                </div>
                <div>
                    <h3 class="text-xl font-semibold mb-4">Connect</h3>
                    <div class="flex space-x-4">
                        <a href="https://www.facebook.com/shukdevdattatroy" class="text-gray-400 hover:text-white transition duration-200 text-xl"><i class="fab fa-facebook-f"></i></a>
                        <a href="https://github.com/shukdevtroy" class="text-gray-400 hover:text-white transition duration-200 text-xl"><i class="fab fa-github"></i></a>
                        <a href="https://www.linkedin.com/in/shukdev-datta-729767144/" class="text-gray-400 hover:text-white transition duration-200 text-xl"><i class="fab fa-linkedin"></i></a>
                        <a href="https://huggingface.co./shukdevdatta123" class="text-gray-400 hover:text-white transition duration-200 text-xl"><i class="fa-solid fa-link"></i></a>
                    </div>
                </div>
            </div>
            <div class="border-t border-gray-800 mt-8 pt-8 text-center text-gray-400">
                <p>&copy; 2023 OpenAI O4 Mini Analysis. All rights reserved.</p>
            </div>
        </div>
    </footer>
    
    <script>
        // Toggle API key visibility
        function toggleApiKeyVisibility() {
            const apiKeyInput = document.getElementById('api-key');
            const toggleBtn = apiKeyInput.nextElementSibling;
            
            if (apiKeyInput.type === 'password') {
                apiKeyInput.type = 'text';
                toggleBtn.innerHTML = '<i class="far fa-eye-slash"></i>';
            } else {
                apiKeyInput.type = 'password';
                toggleBtn.innerHTML = '<i class="far fa-eye"></i>';
            }
        }
        
        // Switch between tabs
        function switchTab(tab) {
            const pdfTab = document.getElementById('pdf-tab');
            const imageTab = document.getElementById('image-tab');
            const pdfContent = document.getElementById('pdf-content');
            const imageContent = document.getElementById('image-content');
            
            if (tab === 'pdf') {
                pdfTab.classList.remove('bg-white', 'text-gray-600', 'border-transparent', 'hover:border-gray-300');
                pdfTab.classList.add('bg-white', 'text-indigo-600', 'border-b-2', 'border-indigo-600');
                imageTab.classList.remove('bg-white', 'text-indigo-600', 'border-b-2', 'border-indigo-600');
                imageTab.classList.add('bg-white', 'text-gray-600', 'border-transparent', 'hover:border-gray-300');
                
                pdfContent.classList.remove('hidden');
                imageContent.classList.add('hidden');
                
                // Add animation
                pdfContent.classList.remove('animate__fadeIn');
                void pdfContent.offsetWidth; // Trigger reflow
                pdfContent.classList.add('animate__fadeIn');
            } else {
                imageTab.classList.remove('bg-white', 'text-gray-600', 'border-transparent', 'hover:border-gray-300');
                imageTab.classList.add('bg-white', 'text-indigo-600', 'border-b-2', 'border-indigo-600');
                pdfTab.classList.remove('bg-white', 'text-indigo-600', 'border-b-2', 'border-indigo-600');
                pdfTab.classList.add('bg-white', 'text-gray-600', 'border-transparent', 'hover:border-gray-300');
                
                imageContent.classList.remove('hidden');
                pdfContent.classList.add('hidden');
                
                // Add animation
                imageContent.classList.remove('animate__fadeIn');
                void imageContent.offsetWidth; // Trigger reflow
                imageContent.classList.add('animate__fadeIn');
            }
        }
        
        // Switch between image upload and URL
        function switchImageSource(source) {
            const uploadContainer = document.getElementById('image-upload-container');
            const urlContainer = document.getElementById('image-url-container');
            const uploadPreview = document.getElementById('image-preview-container');
            const urlPreview = document.getElementById('url-preview-container');
            
            if (source === 'upload') {
                uploadContainer.classList.remove('hidden');
                urlContainer.classList.add('hidden');
                urlPreview.classList.add('hidden');
                document.getElementById('image-url').value = '';
            } else {
                uploadContainer.classList.add('hidden');
                urlContainer.classList.remove('hidden');
                uploadPreview.classList.add('hidden');
                document.getElementById('image-upload').value = '';
            }
        }
        
        // Handle file upload display for PDF
        document.getElementById('pdf-upload').addEventListener('change', function(e) {
            const uploadContainer = document.getElementById('pdf-upload-container');
            const previewContainer = document.getElementById('pdf-preview-container');
            const filenameDisplay = document.getElementById('pdf-filename');
            const filesizeDisplay = document.getElementById('pdf-filesize');
            
            if (this.files.length > 0) {
                const file = this.files[0];
                filenameDisplay.textContent = file.name;
                filesizeDisplay.textContent = formatFileSize(file.size);
                
                uploadContainer.classList.add('hidden');
                previewContainer.classList.remove('hidden');
            } else {
                uploadContainer.classList.remove('hidden');
                previewContainer.classList.add('hidden');
            }
        });
        
        // Handle file upload display for Image
        document.getElementById('image-upload').addEventListener('change', function(e) {
            const uploadContainer = document.getElementById('image-upload-container');
            const previewContainer = document.getElementById('image-preview-container');
            const previewImage = document.getElementById('image-preview');
            
            if (this.files.length > 0) {
                const file = this.files[0];
                const reader = new FileReader();
                
                reader.onload = function(event) {
                    previewImage.src = event.target.result;
                    uploadContainer.classList.add('hidden');
                    previewContainer.classList.remove('hidden');
                }
                
                reader.readAsDataURL(file);
            } else {
                uploadContainer.classList.remove('hidden');
                previewContainer.classList.add('hidden');
            }
        });
        
        // Handle image URL preview
        document.getElementById('image-url').addEventListener('change', function(e) {
            const url = this.value.trim();
            const previewContainer = document.getElementById('url-preview-container');
            const previewImage = document.getElementById('url-preview');
            
            if (url) {
                previewImage.src = url;
                previewContainer.classList.remove('hidden');
                
                // Check if image loads successfully
                previewImage.onload = function() {
                    previewContainer.classList.remove('hidden');
                }
                
                previewImage.onerror = function() {
                    previewContainer.classList.add('hidden');
                    alert('Could not load image from the provided URL. Please check the URL and try again.');
                }
            } else {
                previewContainer.classList.add('hidden');
            }
        });
        
        // Remove PDF file
        document.getElementById('remove-pdf').addEventListener('click', function() {
            document.getElementById('pdf-upload').value = '';
            document.getElementById('pdf-upload-container').classList.remove('hidden');
            document.getElementById('pdf-preview-container').classList.add('hidden');
        });
        
        // Remove uploaded image
        document.getElementById('remove-image').addEventListener('click', function() {
            document.getElementById('image-upload').value = '';
            document.getElementById('image-upload-container').classList.remove('hidden');
            document.getElementById('image-preview-container').classList.add('hidden');
        });
        
        // Remove URL image
        document.getElementById('remove-url').addEventListener('click', function() {
            document.getElementById('image-url').value = '';
            document.getElementById('url-preview-container').classList.add('hidden');
        });
        
        // Format file size
        function formatFileSize(bytes) {
            if (bytes === 0) return '0 Bytes';
            
            const k = 1024;
            const sizes = ['Bytes', 'KB', 'MB', 'GB'];
            const i = Math.floor(Math.log(bytes) / Math.log(k));
            
            return parseFloat((bytes / Math.pow(k, i)).toFixed(2)) + ' ' + sizes[i];
        }
        
        // Show loading state
        function showLoading(element) {
            element.innerHTML = `
                <div class="flex flex-col items-center justify-center py-8">
                    <div class="loading-dots mb-4">
                        <span></span>
                        <span></span>
                        <span></span>
                    </div>
                    <p class="text-gray-500">Analyzing content, please wait...</p>
                </div>
            `;
        }
        
        // Copy result to clipboard
        document.getElementById('copy-pdf-result')?.addEventListener('click', function() {
            const resultContent = document.getElementById('pdf-result-content').textContent;
            navigator.clipboard.writeText(resultContent).then(() => {
                const originalText = this.innerHTML;
                this.innerHTML = '<i class="fas fa-check mr-1"></i> Copied!';
                setTimeout(() => {
                    this.innerHTML = originalText;
                }, 2000);
            });
        });
        
        document.getElementById('copy-image-result')?.addEventListener('click', function() {
            const resultContent = document.getElementById('image-result-content').textContent;
            navigator.clipboard.writeText(resultContent).then(() => {
                const originalText = this.innerHTML;
                this.innerHTML = '<i class="fas fa-check mr-1"></i> Copied!';
                setTimeout(() => {
                    this.innerHTML = originalText;
                }, 2000);
            });
        });
        
        // Analyze PDF function
        async function analyzePDF() {
            const apiKey = document.getElementById('api-key').value;
            const pdfFile = document.getElementById('pdf-upload').files[0];
            const prompt = document.getElementById('pdf-prompt').value;
            const effortLevel = document.querySelector('input[name="pdf-effort"]:checked').value;
            const resultContent = document.getElementById('pdf-result-content');
            const resultBox = document.getElementById('pdf-result');
            
            if (!apiKey) {
                showAlert('Please provide an OpenAI API key.', 'error');
                return;
            }
            
            if (!pdfFile) {
                showAlert('Please upload a PDF file.', 'error');
                return;
            }
            
            // Show loading state
            resultBox.classList.remove('hidden');
            showLoading(resultContent);
            
            try {
                // Read the PDF file and convert to base64
                const pdfBase64 = await new Promise((resolve, reject) => {
                    const reader = new FileReader();
                    reader.onload = () => {
                        const arrayBuffer = reader.result;
                        const bytes = new Uint8Array(arrayBuffer);
                        let binary = '';
                        for (let i = 0; i < bytes.byteLength; i++) {
                            binary += String.fromCharCode(bytes[i]);
                        }
                        const base64 = btoa(binary);
                        resolve(base64);
                    };
                    reader.onerror = reject;
                    reader.readAsArrayBuffer(pdfFile);
                });
                
                // Create the request payload
                const payload = {
                    model: "o4-mini",
                    input: [
                        {
                            role: "user",
                            content: [
                                {
                                    type: "input_text",
                                    text: prompt
                                },
                                {
                                    type: "input_file",
                                    filename: pdfFile.name,
                                    file_data: `data:application/pdf;base64,${pdfBase64}`
                                }
                            ]
                        }
                    ],
                    text: {
                        format: {
                            type: "text"
                        }
                    },
                    reasoning: {
                        effort: effortLevel
                    },
                    tools: [],
                    store: true
                };
                
                // Make the API request
                const response = await axios.post('https://api.openai.com/v1/responses', payload, {
                    headers: {
                        'Authorization': `Bearer ${apiKey}`,
                        'Content-Type': 'application/json'
                    }
                });
                
                // Process the response
                const result = extractTextFromResponse(response.data);
                resultContent.innerHTML = `<div class="text-gray-700 whitespace-pre-wrap">${result}</div>`;
                
            } catch (error) {
                console.error('Error:', error);
                let errorMessage = 'An error occurred while analyzing the PDF.';
                if (error.response) {
                    errorMessage = `Error: ${error.response.data.error?.message || error.response.statusText}`;
                } else if (error.message) {
                    errorMessage = `Error: ${error.message}`;
                }
                resultContent.innerHTML = `<div class="text-red-600">${errorMessage}</div>`;
            }
        }
        
        // Analyze Image function
        async function analyzeImage() {
            const apiKey = document.getElementById('api-key').value;
            const imageFile = document.getElementById('image-upload').files[0];
            const imageUrl = document.getElementById('image-url').value;
            const prompt = document.getElementById('image-prompt').value;
            const effortLevel = document.querySelector('input[name="image-effort"]:checked').value;
            const resultContent = document.getElementById('image-result-content');
            const resultBox = document.getElementById('image-result');
            
            if (!apiKey) {
                showAlert('Please provide an OpenAI API key.', 'error');
                return;
            }
            
            if (!imageFile && !imageUrl) {
                showAlert('Please upload an image or provide an image URL.', 'error');
                return;
            }
            
            if (!prompt) {
                showAlert('Please provide a prompt for the image analysis.', 'error');
                return;
            }
            
            // Show loading state
            resultBox.classList.remove('hidden');
            showLoading(resultContent);
            
            try {
                const content = [
                    {
                        type: "input_text",
                        text: prompt
                    }
                ];
                
                if (imageFile) {
                    // Read the image file and convert to base64
                    const imageBase64 = await new Promise((resolve, reject) => {
                        const reader = new FileReader();
                        reader.onload = () => {
                            const base64 = reader.result.split(',')[1];
                            resolve(base64);
                        };
                        reader.onerror = reject;
                        reader.readAsDataURL(imageFile);
                    });
                    
                    content.unshift({
                        type: "input_image",
                        image_url: `data:image/png;base64,${imageBase64}`
                    });
                } else if (imageUrl) {
                    content.unshift({
                        type: "input_image",
                        image_url: imageUrl
                    });
                }
                
                // Create the request payload
                const payload = {
                    model: "o4-mini",
                    input: [
                        {
                            role: "user",
                            content: content
                        }
                    ],
                    text: {
                        format: {
                            type: "text"
                        }
                    },
                    reasoning: {
                        effort: effortLevel
                    },
                    tools: [],
                    store: true
                };
                
                // Make the API request
                const response = await axios.post('https://api.openai.com/v1/responses', payload, {
                    headers: {
                        'Authorization': `Bearer ${apiKey}`,
                        'Content-Type': 'application/json'
                    }
                });
                
                // Process the response
                const result = extractTextFromResponse(response.data);
                resultContent.innerHTML = `<div class="text-gray-700 whitespace-pre-wrap">${result}</div>`;
                
            } catch (error) {
                console.error('Error:', error);
                let errorMessage = 'An error occurred while analyzing the image.';
                if (error.response) {
                    errorMessage = `Error: ${error.response.data.error?.message || error.response.statusText}`;
                } else if (error.message) {
                    errorMessage = `Error: ${error.message}`;
                }
                resultContent.innerHTML = `<div class="text-red-600">${errorMessage}</div>`;
            }
        }
        
        // Extract text from response
        function extractTextFromResponse(response) {
            try {
                // First check if response has an output attribute
                if (response.output) {
                    const output = response.output;
                    
                    // Look for message items in the output list
                    for (const item of output) {
                        if (item.role === 'assistant') {
                            for (const contentItem of item.content) {
                                if (contentItem.type === 'output_text') {
                                    return contentItem.text;
                                }
                            }
                        }
                    }
                    
                    // If we couldn't find it in the expected structure, return an error
                    return `Couldn't extract text from response: ${JSON.stringify(response)}`;
                }
                
                return `Unexpected response structure: ${JSON.stringify(response)}`;
            } catch (error) {
                return `Error processing response: ${error.message}`;
            }
        }
        
        // Show alert message
        function showAlert(message, type = 'info') {
            const alertDiv = document.createElement('div');
            alertDiv.className = `fixed top-4 right-4 z-50 px-6 py-4 rounded-lg shadow-lg flex items-center ${
                type === 'error' ? 'bg-red-100 text-red-800' : 
                type === 'success' ? 'bg-green-100 text-green-800' : 
                'bg-blue-100 text-blue-800'
            }`;
            
            const icon = type === 'error' ? 'exclamation-circle' : 
                         type === 'success' ? 'check-circle' : 'info-circle';
            
            alertDiv.innerHTML = `
                <i class="fas fa-${icon} mr-3"></i>
                <span>${message}</span>
                <button class="ml-4 text-xl" onclick="this.parentElement.remove()">
                    <i class="fas fa-times"></i>
                </button>
            `;
            
            document.body.appendChild(alertDiv);
            
            setTimeout(() => {
                alertDiv.remove();
            }, 5000);
        }
        
        // Add glow effect to buttons on hover
        document.querySelectorAll('button').forEach(button => {
            if (!button.id.includes('remove') && button.id !== 'api-key-toggle') {
                button.addEventListener('mouseenter', () => {
                    button.classList.add('glow');
                });
                button.addEventListener('mouseleave', () => {
                    button.classList.remove('glow');
                });
            }
        });
        
        // Add pulse animation to feature cards on hover
        document.querySelectorAll('.card').forEach(card => {
            card.addEventListener('mouseenter', () => {
                card.classList.add('glow');
            });
            card.addEventListener('mouseleave', () => {
                card.classList.remove('pulse');
            });
        });
    </script>
<!-- <p style="border-radius: 8px; text-align: center; font-size: 12px; color: #fff; margin-top: 16px;position: fixed; left: 8px; bottom: 8px; z-index: 10; background: rgba(0, 0, 0, 0.8); padding: 4px 8px;">Made with <img src="https://enzostvs-deepsite.hf.space/logo.svg" alt="DeepSite Logo" style="width: 16px; height: 16px; vertical-align: middle;display:inline-block;margin-right:3px;filter:brightness(0) invert(1);"><a href="https://enzostvs-deepsite.hf.space" style="color: #fff;text-decoration: underline;" target="_blank" >DeepSite</a> - 🧬 <a href="https://enzostvs-deepsite.hf.space?remix=shukdevdatta123/openai-o4-mini-multi-modal-chat-app" style="color: #fff;text-decoration: underline;" target="_blank" >Remix</a></p> -->
</body>
</html>