File size: 80,685 Bytes
0864cee
4acb194
 
 
 
 
 
 
0864cee
4acb194
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
0864cee
4acb194
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>AI Ebook Generator</title>
    <script src="https://cdn.tailwindcss.com"></script>
    <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.4.0/css/all.min.css">
    <style>
        .gradient-bg {
            background: linear-gradient(135deg, #6b73ff 0%, #000dff 100%);
        }
        .ebook-preview {
            min-height: 500px;
            background: linear-gradient(to bottom, #f8fafc, #e2e8f0);
        }
        .chapter-item:hover {
            transform: translateX(5px);
        }
        .loading-dots:after {
            content: '.';
            animation: dots 1.5s steps(5, end) infinite;
        }
        @keyframes dots {
            0%, 20% { content: '.'; }
            40% { content: '..'; }
            60% { content: '...'; }
            80%, 100% { content: ''; }
        }
        .tab-content {
            display: none;
        }
        .tab-content.active {
            display: block;
        }
        .plan-card {
            transition: all 0.3s ease;
        }
        .plan-card:hover {
            transform: translateY(-5px);
            box-shadow: 0 10px 25px rgba(0, 0, 0, 0.1);
        }
        .premium-badge {
            position: absolute;
            top: -10px;
            right: -10px;
            background: linear-gradient(45deg, #ff9500, #ff5e00);
            color: white;
            padding: 3px 10px;
            border-radius: 20px;
            font-size: 12px;
            font-weight: bold;
            box-shadow: 0 2px 5px rgba(0,0,0,0.2);
        }
        .api-status {
            width: 10px;
            height: 10px;
            border-radius: 50%;
            display: inline-block;
            margin-right: 5px;
        }
        .api-status.connected {
            background-color: #10B981;
        }
        .api-status.disconnected {
            background-color: #EF4444;
        }
        .toggle-checkbox:checked {
            right: 0;
            border-color: #3B82F6;
        }
        .toggle-checkbox:checked + .toggle-label {
            background-color: #3B82F6;
        }
        .format-card {
            transition: all 0.2s ease;
            border-left: 4px solid transparent;
        }
        .format-card:hover {
            transform: translateY(-3px);
            border-left-color: #3B82F6;
        }
        .requirement-item {
            position: relative;
            padding-left: 20px;
        }
        .requirement-item:before {
            content: "•";
            position: absolute;
            left: 0;
            color: #3B82F6;
            font-weight: bold;
        }
        .progress-bar {
            height: 6px;
            border-radius: 3px;
            background-color: #e2e8f0;
        }
        .progress-fill {
            height: 100%;
            border-radius: 3px;
            background-color: #3B82F6;
            transition: width 0.3s ease;
        }
    </style>
</head>
<body class="bg-gray-50">
    <div class="min-h-screen">
        <!-- Header -->
        <header class="gradient-bg text-white shadow-lg">
            <div class="container mx-auto px-4 py-6">
                <div class="flex justify-between items-center">
                    <div class="flex items-center space-x-2">
                        <i class="fas fa-book-open text-2xl"></i>
                        <h1 class="text-2xl font-bold">AI Ebook Generator</h1>
                    </div>
                    <nav>
                        <ul class="flex space-x-6">
                            <li><a href="#" class="hover:underline" onclick="showTab('generator')">Generator</a></li>
                            <li><a href="#" class="hover:underline" onclick="showTab('export')">Export</a></li>
                            <li><a href="#" class="hover:underline" onclick="showTab('api-settings')">API Settings</a></li>
                        </ul>
                    </nav>
                </div>
            </div>
        </header>

        <!-- Main Content -->
        <main class="container mx-auto px-4 py-8">
            <!-- Generator Tab -->
            <div id="generator-tab" class="tab-content active">
                <div class="grid grid-cols-1 lg:grid-cols-3 gap-8">
                    <!-- Generator Form -->
                    <div class="lg:col-span-1 bg-white rounded-xl shadow-md p-6 h-fit sticky top-8">
                        <h2 class="text-xl font-semibold mb-4 text-gray-800">Create Your Ebook</h2>
                        
                        <form id="ebookForm" class="space-y-4">
                            <div>
                                <label for="ebookTitle" class="block text-sm font-medium text-gray-700 mb-1">Ebook Title</label>
                                <input type="text" id="ebookTitle" class="w-full px-4 py-2 border border-gray-300 rounded-lg focus:ring-2 focus:ring-blue-500 focus:border-blue-500" placeholder="Enter ebook title" required>
                            </div>
                            
                            <div>
                                <label for="ebookTopic" class="block text-sm font-medium text-gray-700 mb-1">Main Topic</label>
                                <input type="text" id="ebookTopic" class="w-full px-4 py-2 border border-gray-300 rounded-lg focus:ring-2 focus:ring-blue-500 focus:border-blue-500" placeholder="e.g. Digital Marketing" required>
                            </div>
                            
                            <div>
                                <label for="ebookKeywords" class="block text-sm font-medium text-gray-700 mb-1">Keywords (comma separated)</label>
                                <textarea id="ebookKeywords" rows="3" class="w-full px-4 py-2 border border-gray-300 rounded-lg focus:ring-2 focus:ring-blue-500 focus:border-blue-500" placeholder="SEO, content marketing, social media"></textarea>
                            </div>
                            
                            <div>
                                <label for="ebookSummary" class="block text-sm font-medium text-gray-700 mb-1">Brief Summary</label>
                                <textarea id="ebookSummary" rows="4" class="w-full px-4 py-2 border border-gray-300 rounded-lg focus:ring-2 focus:ring-blue-500 focus:border-blue-500" placeholder="Describe what your ebook should cover"></textarea>
                            </div>
                            
                            <div>
                                <label for="chapterCount" class="block text-sm font-medium text-gray-700 mb-1">Number of Chapters</label>
                                <select id="chapterCount" class="w-full px-4 py-2 border border-gray-300 rounded-lg focus:ring-2 focus:ring-blue-500 focus:border-blue-500">
                                    <option value="5">5 Chapters</option>
                                    <option value="7" selected>7 Chapters</option>
                                    <option value="10">10 Chapters</option>
                                    <option value="12">12 Chapters</option>
                                </select>
                            </div>
                            
                            <div>
                                <label for="writingStyle" class="block text-sm font-medium text-gray-700 mb-1">Writing Style</label>
                                <select id="writingStyle" class="w-full px-4 py-2 border border-gray-300 rounded-lg focus:ring-2 focus:ring-blue-500 focus:border-blue-500">
                                    <option value="professional">Professional</option>
                                    <option value="casual">Casual</option>
                                    <option value="academic">Academic</option>
                                    <option value="storytelling">Storytelling</option>
                                </select>
                            </div>
                            
                            <div class="pt-2">
                                <button type="submit" id="generateBtn" class="w-full gradient-bg text-white py-3 px-6 rounded-lg font-medium hover:opacity-90 transition duration-300 flex items-center justify-center">
                                    <i class="fas fa-magic mr-2"></i> Generate Ebook
                                </button>
                            </div>
                        </form>
                    </div>
                    
                    <!-- Ebook Preview -->
                    <div class="lg:col-span-2">
                        <div class="bg-white rounded-xl shadow-md overflow-hidden">
                            <div class="p-6 border-b border-gray-200">
                                <h2 class="text-xl font-semibold text-gray-800">Ebook Preview</h2>
                                <p class="text-sm text-gray-500">Your generated content will appear here</p>
                            </div>
                            
                            <div id="ebookPreview" class="ebook-preview p-8">
                                <div id="emptyState" class="flex flex-col items-center justify-center h-full text-center py-20">
                                    <i class="fas fa-book-reader text-6xl text-gray-300 mb-4"></i>
                                    <h3 class="text-xl font-medium text-gray-500 mb-2">No Ebook Generated Yet</h3>
                                    <p class="text-gray-400 max-w-md">Fill out the form and click "Generate Ebook" to create your custom content.</p>
                                </div>
                                
                                <div id="loadingState" class="hidden flex-col items-center justify-center h-full text-center py-20">
                                    <div class="animate-pulse mb-4">
                                        <div class="h-12 w-12 bg-blue-200 rounded-full"></div>
                                    </div>
                                    <h3 class="text-xl font-medium text-gray-600 mb-2">Generating your ebook<span class="loading-dots"></span></h3>
                                    <p class="text-gray-500">This may take a few moments</p>
                                </div>
                                
                                <div id="ebookContent" class="hidden">
                                    <div class="flex justify-between items-center mb-8">
                                        <div>
                                            <h1 id="previewTitle" class="text-3xl font-bold text-gray-800 mb-2"></h1>
                                            <p id="previewSubtitle" class="text-lg text-gray-600"></p>
                                        </div>
                                        <div class="bg-blue-100 text-blue-800 px-4 py-2 rounded-full text-sm font-medium">
                                            <i class="fas fa-clock mr-1"></i> <span id="generatedTime"></span>
                                        </div>
                                    </div>
                                    
                                    <div class="mb-10">
                                        <h2 class="text-xl font-semibold text-gray-700 mb-3">Table of Contents</h2>
                                        <div id="tocList" class="space-y-2 border-l-2 border-blue-200 pl-4"></div>
                                    </div>
                                    
                                    <div id="chaptersContainer" class="space-y-12"></div>
                                    
                                    <div class="mt-12 pt-8 border-t border-gray-200">
                                        <div class="flex justify-between items-center">
                                            <div>
                                                <h3 class="font-medium text-gray-700">Your ebook is ready!</h3>
                                                <p class="text-sm text-gray-500">Download or continue editing</p>
                                            </div>
                                            <div class="space-x-3">
                                                <button class="px-4 py-2 bg-gray-100 text-gray-700 rounded-lg hover:bg-gray-200 transition">
                                                    <i class="fas fa-edit mr-1"></i> Edit
                                                </button>
                                                <button onclick="showTab('export')" class="px-4 py-2 gradient-bg text-white rounded-lg hover:opacity-90 transition">
                                                    <i class="fas fa-download mr-1"></i> Export Options
                                                </button>
                                            </div>
                                        </div>
                                    </div>
                                </div>
                            </div>
                        </div>
                    </div>
                </div>
            </div>

            <!-- Export Tab -->
            <div id="export-tab" class="tab-content">
                <div class="max-w-6xl mx-auto">
                    <div class="bg-white rounded-xl shadow-md overflow-hidden">
                        <div class="p-6 border-b border-gray-200">
                            <h2 class="text-2xl font-semibold text-gray-800">Export Your Ebook</h2>
                            <p class="text-sm text-gray-500">Choose from multiple formats optimized for different platforms</p>
                        </div>
                        
                        <div class="p-6">
                            <!-- Format Selection -->
                            <div class="mb-8">
                                <h3 class="text-lg font-medium text-gray-800 mb-4">Available Formats</h3>
                                <div class="grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-4">
                                    <!-- PDF Format -->
                                    <div class="format-card bg-white p-5 rounded-lg border border-gray-200 shadow-sm cursor-pointer" onclick="selectFormat('pdf')">
                                        <div class="flex items-center mb-3">
                                            <div class="bg-red-100 p-3 rounded-full mr-3">
                                                <i class="fas fa-file-pdf text-red-600 text-xl"></i>
                                            </div>
                                            <div>
                                                <h4 class="font-bold text-gray-800">PDF</h4>
                                                <p class="text-xs text-gray-500">Standard format</p>
                                            </div>
                                        </div>
                                        <p class="text-sm text-gray-600 mb-3">Universal format that works on all devices and maintains formatting.</p>
                                        <div class="text-xs text-gray-500 requirement-item mb-1">Fixed layout</div>
                                        <div class="text-xs text-gray-500 requirement-item mb-1">Print-ready</div>
                                        <div class="text-xs text-gray-500 requirement-item">DRM support</div>
                                    </div>
                                    
                                    <!-- EPUB Format -->
                                    <div class="format-card bg-white p-5 rounded-lg border border-gray-200 shadow-sm cursor-pointer" onclick="selectFormat('epub')">
                                        <div class="flex items-center mb-3">
                                            <div class="bg-blue-100 p-3 rounded-full mr-3">
                                                <i class="fas fa-book-open text-blue-600 text-xl"></i>
                                            </div>
                                            <div>
                                                <h4 class="font-bold text-gray-800">EPUB</h4>
                                                <p class="text-xs text-gray-500">E-reader optimized</p>
                                            </div>
                                        </div>
                                        <p class="text-sm text-gray-600 mb-3">Reflowable format perfect for Kindle, Kobo, and other e-readers.</p>
                                        <div class="text-xs text-gray-500 requirement-item mb-1">Responsive layout</div>
                                        <div class="text-xs text-gray-500 requirement-item mb-1">Metadata support</div>
                                        <div class="text-xs text-gray-500 requirement-item">Accessibility features</div>
                                    </div>
                                    
                                    <!-- MOBI Format -->
                                    <div class="format-card bg-white p-5 rounded-lg border border-gray-200 shadow-sm cursor-pointer" onclick="selectFormat('mobi')">
                                        <div class="flex items-center mb-3">
                                            <div class="bg-yellow-100 p-3 rounded-full mr-3">
                                                <i class="fab fa-amazon text-yellow-600 text-xl"></i>
                                            </div>
                                            <div>
                                                <h4 class="font-bold text-gray-800">MOBI</h4>
                                                <p class="text-xs text-gray-500">Amazon Kindle</p>
                                            </div>
                                        </div>
                                        <p class="text-sm text-gray-600 mb-3">Specialized format for Amazon Kindle Direct Publishing (KDP).</p>
                                        <div class="text-xs text-gray-500 requirement-item mb-1">Kindle compatible</div>
                                        <div class="text-xs text-gray-500 requirement-item mb-1">KDP requirements</div>
                                        <div class="text-xs text-gray-500 requirement-item">Fixed/Reflowable</div>
                                    </div>
                                    
                                    <!-- HTML Format -->
                                    <div class="format-card bg-white p-5 rounded-lg border border-gray-200 shadow-sm cursor-pointer" onclick="selectFormat('html')">
                                        <div class="flex items-center mb-3">
                                            <div class="bg-green-100 p-3 rounded-full mr-3">
                                                <i class="fab fa-html5 text-green-600 text-xl"></i>
                                            </div>
                                            <div>
                                                <h4 class="font-bold text-gray-800">HTML</h4>
                                                <p class="text-xs text-gray-500">Web format</p>
                                            </div>
                                        </div>
                                        <p class="text-sm text-gray-600 mb-3">Perfect for selling directly on your website or blog.</p>
                                        <div class="text-xs text-gray-500 requirement-item mb-1">Web responsive</div>
                                        <div class="text-xs text-gray-500 requirement-item mb-1">SEO optimized</div>
                                        <div class="text-xs text-gray-500 requirement-item">Embeddable</div>
                                    </div>
                                    
                                    <!-- DOCX Format -->
                                    <div class="format-card bg-white p-5 rounded-lg border border-gray-200 shadow-sm cursor-pointer" onclick="selectFormat('docx')">
                                        <div class="flex items-center mb-3">
                                            <div class="bg-indigo-100 p-3 rounded-full mr-3">
                                                <i class="fas fa-file-word text-indigo-600 text-xl"></i>
                                            </div>
                                            <div>
                                                <h4 class="font-bold text-gray-800">DOCX</h4>
                                                <p class="text-xs text-gray-500">Editable format</p>
                                            </div>
                                        </div>
                                        <p class="text-sm text-gray-600 mb-3">Microsoft Word format for further editing and customization.</p>
                                        <div class="text-xs text-gray-500 requirement-item mb-1">Editable</div>
                                        <div class="text-xs text-gray-500 requirement-item mb-1">Track changes</div>
                                        <div class="text-xs text-gray-500 requirement-item">Comments</div>
                                    </div>
                                    
                                    <!-- Plain Text -->
                                    <div class="format-card bg-white p-5 rounded-lg border border-gray-200 shadow-sm cursor-pointer" onclick="selectFormat('txt')">
                                        <div class="flex items-center mb-3">
                                            <div class="bg-gray-100 p-3 rounded-full mr-3">
                                                <i class="fas fa-file-alt text-gray-600 text-xl"></i>
                                            </div>
                                            <div>
                                                <h4 class="font-bold text-gray-800">Plain Text</h4>
                                                <p class="text-xs text-gray-500">Minimal format</p>
                                            </div>
                                        </div>
                                        <p class="text-sm text-gray-600 mb-3">Simple text format for maximum compatibility and minimal styling.</p>
                                        <div class="text-xs text-gray-500 requirement-item mb-1">Universal</div>
                                        <div class="text-xs text-gray-500 requirement-item mb-1">Lightweight</div>
                                        <div class="text-xs text-gray-500 requirement-item">No formatting</div>
                                    </div>
                                </div>
                            </div>
                            
                            <!-- Selected Format Options -->
                            <div id="formatOptions" class="hidden bg-gray-50 p-6 rounded-lg mb-8">
                                <div class="flex justify-between items-center mb-4">
                                    <h3 class="text-lg font-medium text-gray-800">Export as <span id="selectedFormatName" class="font-bold"></span></h3>
                                    <button onclick="resetFormatSelection()" class="text-sm text-gray-500 hover:text-gray-700">
                                        <i class="fas fa-times mr-1"></i> Change format
                                    </button>
                                </div>
                                
                                <div class="grid grid-cols-1 md:grid-cols-2 gap-6">
                                    <!-- Format Settings -->
                                    <div>
                                        <h4 class="font-medium text-gray-700 mb-3">Format Settings</h4>
                                        
                                        <div id="pdfOptions" class="space-y-4">
                                            <div>
                                                <label class="block text-sm text-gray-600 mb-1">Page Size</label>
                                                <select class="w-full px-4 py-2 border border-gray-300 rounded-lg focus:ring-2 focus:ring-blue-500 focus:border-blue-500">
                                                    <option>A4 (210 × 297 mm)</option>
                                                    <option>Letter (8.5 × 11 in)</option>
                                                    <option>5.5 × 8.5 in</option>
                                                    <option>6 × 9 in</option>
                                                </select>
                                            </div>
                                            
                                            <div>
                                                <label class="block text-sm text-gray-600 mb-1">Orientation</label>
                                                <div class="flex space-x-4">
                                                    <label class="flex items-center">
                                                        <input type="radio" name="orientation" checked class="h-4 w-4 text-blue-600 focus:ring-blue-500">
                                                        <span class="ml-2 text-gray-700">Portrait</span>
                                                    </label>
                                                    <label class="flex items-center">
                                                        <input type="radio" name="orientation" class="h-4 w-4 text-blue-600 focus:ring-blue-500">
                                                        <span class="ml-2 text-gray-700">Landscape</span>
                                                    </label>
                                                </div>
                                            </div>
                                            
                                            <div>
                                                <label class="block text-sm text-gray-600 mb-1">Margins (mm)</label>
                                                <div class="grid grid-cols-4 gap-2">
                                                    <div>
                                                        <label class="block text-xs text-gray-500 mb-1">Top</label>
                                                        <input type="number" value="20" class="w-full px-3 py-1 border border-gray-300 rounded-lg">
                                                    </div>
                                                    <div>
                                                        <label class="block text-xs text-gray-500 mb-1">Bottom</label>
                                                        <input type="number" value="20" class="w-full px-3 py-1 border border-gray-300 rounded-lg">
                                                    </div>
                                                    <div>
                                                        <label class="block text-xs text-gray-500 mb-1">Left</label>
                                                        <input type="number" value="15" class="w-full px-3 py-1 border border-gray-300 rounded-lg">
                                                    </div>
                                                    <div>
                                                        <label class="block text-xs text-gray-500 mb-1">Right</label>
                                                        <input type="number" value="15" class="w-full px-3 py-1 border border-gray-300 rounded-lg">
                                                    </div>
                                                </div>
                                            </div>
                                        </div>
                                        
                                        <div id="epubOptions" class="space-y-4 hidden">
                                            <div>
                                                <label class="block text-sm text-gray-600 mb-1">EPUB Version</label>
                                                <select class="w-full px-4 py-2 border border-gray-300 rounded-lg focus:ring-2 focus:ring-blue-500 focus:border-blue-500">
                                                    <option>EPUB 3 (recommended)</option>
                                                    <option>EPUB 2 (compatibility)</option>
                                                </select>
                                            </div>
                                            
                                            <div>
                                                <label class="block text-sm text-gray-600 mb-1">Layout</label>
                                                <div class="flex space-x-4">
                                                    <label class="flex items-center">
                                                        <input type="radio" name="epubLayout" checked class="h-4 w-4 text-blue-600 focus:ring-blue-500">
                                                        <span class="ml-2 text-gray-700">Reflowable</span>
                                                    </label>
                                                    <label class="flex items-center">
                                                        <input type="radio" name="epubLayout" class="h-4 w-4 text-blue-600 focus:ring-blue-500">
                                                        <span class="ml-2 text-gray-700">Fixed Layout</span>
                                                    </label>
                                                </div>
                                            </div>
                                            
                                            <div>
                                                <label class="block text-sm text-gray-600 mb-1">Include</label>
                                                <div class="space-y-2">
                                                    <label class="flex items-center">
                                                        <input type="checkbox" checked class="h-4 w-4 text-blue-600 focus:ring-blue-500">
                                                        <span class="ml-2 text-gray-700">Table of Contents</span>
                                                    </label>
                                                    <label class="flex items-center">
                                                        <input type="checkbox" checked class="h-4 w-4 text-blue-600 focus:ring-blue-500">
                                                        <span class="ml-2 text-gray-700">Cover Image</span>
                                                    </label>
                                                    <label class="flex items-center">
                                                        <input type="checkbox" class="h-4 w-4 text-blue-600 focus:ring-blue-500">
                                                        <span class="ml-2 text-gray-700">DRM Protection</span>
                                                    </label>
                                                </div>
                                            </div>
                                        </div>
                                        
                                        <div id="mobiOptions" class="space-y-4 hidden">
                                            <div>
                                                <label class="block text-sm text-gray-600 mb-1">Kindle Format</label>
                                                <select class="w-full px-4 py-2 border border-gray-300 rounded-lg focus:ring-2 focus:ring-blue-500 focus:border-blue-500">
                                                    <option>KF8 (recommended)</option>
                                                    <option>MOBI (legacy)</option>
                                                    <option>Dual Format</option>
                                                </select>
                                            </div>
                                            
                                            <div>
                                                <label class="block text-sm text-gray-600 mb-1">Kindle Features</label>
                                                <div class="space-y-2">
                                                    <label class="flex items-center">
                                                        <input type="checkbox" checked class="h-4 w-4 text-blue-600 focus:ring-blue-500">
                                                        <span class="ml-2 text-gray-700">Enhanced Typesetting</span>
                                                    </label>
                                                    <label class="flex items-center">
                                                        <input type="checkbox" checked class="h-4 w-4 text-blue-600 focus:ring-blue-500">
                                                        <span class="ml-2 text-gray-700">Page Flip</span>
                                                    </label>
                                                    <label class="flex items-center">
                                                        <input type="checkbox" class="h-4 w-4 text-blue-600 focus:ring-blue-500">
                                                        <span class="ml-2 text-gray-700">Whispersync</span>
                                                    </label>
                                                </div>
                                            </div>
                                            
                                            <div>
                                                <label class="block text-sm text-gray-600 mb-1">KDP Requirements</label>
                                                <div class="bg-yellow-50 border border-yellow-200 rounded p-3">
                                                    <p class="text-xs text-yellow-700">Make sure your ebook meets all <a href="#" class="underline">Kindle Direct Publishing requirements</a> before uploading.</p>
                                                </div>
                                            </div>
                                        </div>
                                    </div>
                                    
                                    <!-- Platform Requirements -->
                                    <div>
                                        <h4 class="font-medium text-gray-700 mb-3">Platform Requirements</h4>
                                        
                                        <div id="platformRequirements" class="space-y-4">
                                            <div class="bg-white p-4 rounded-lg border border-gray-200">
                                                <h5 class="font-medium text-gray-700 mb-2">Amazon KDP</h5>
                                                <div class="text-xs text-gray-500 requirement-item mb-1">Cover image (2560×1600px min)</div>
                                                <div class="text-xs text-gray-500 requirement-item mb-1">Table of Contents</div>
                                                <div class="text-xs text-gray-500 requirement-item">Valid ISBN (optional)</div>
                                            </div>
                                            
                                            <div class="bg-white p-4 rounded-lg border border-gray-200">
                                                <h5 class="font-medium text-gray-700 mb-2">Apple Books</h5>
                                                <div class="text-xs text-gray-500 requirement-item mb-1">EPUB 3 format</div>
                                                <div class="text-xs text-gray-500 requirement-item mb-1">High-res cover</div>
                                                <div class="text-xs text-gray-500 requirement-item">Metadata complete</div>
                                            </div>
                                            
                                            <div class="bg-white p-4 rounded-lg border border-gray-200">
                                                <h5 class="font-medium text-gray-700 mb-2">Kobo Writing Life</h5>
                                                <div class="text-xs text-gray-500 requirement-item mb-1">EPUB or PDF</div>
                                                <div class="text-xs text-gray-500 requirement-item mb-1">Cover image (1400×1873px)</div>
                                                <div class="text-xs text-gray-500 requirement-item">DRM options</div>
                                            </div>
                                        </div>
                                        
                                        <div class="mt-6">
                                            <label class="block text-sm text-gray-600 mb-2">Metadata</label>
                                            <div class="bg-white p-4 rounded-lg border border-gray-200">
                                                <div class="grid grid-cols-1 md:grid-cols-2 gap-4">
                                                    <div>
                                                        <label class="block text-xs text-gray-500 mb-1">Title</label>
                                                        <input type="text" class="w-full px-3 py-1 border border-gray-300 rounded-lg" value="My Awesome Ebook">
                                                    </div>
                                                    <div>
                                                        <label class="block text-xs text-gray-500 mb-1">Author</label>
                                                        <input type="text" class="w-full px-3 py-1 border border-gray-300 rounded-lg" value="John Doe">
                                                    </div>
                                                    <div>
                                                        <label class="block text-xs text-gray-500 mb-1">ISBN</label>
                                                        <input type="text" class="w-full px-3 py-1 border border-gray-300 rounded-lg" placeholder="Optional">
                                                    </div>
                                                    <div>
                                                        <label class="block text-xs text-gray-500 mb-1">Language</label>
                                                        <select class="w-full px-3 py-1 border border-gray-300 rounded-lg">
                                                            <option>English</option>
                                                            <option>Portuguese</option>
                                                            <option>Spanish</option>
                                                        </select>
                                                    </div>
                                                </div>
                                            </div>
                                        </div>
                                    </div>
                                </div>
                                
                                <div class="mt-6 flex justify-between items-center">
                                    <div>
                                        <label class="block text-sm text-gray-600 mb-1">Cover Image</label>
                                        <div class="flex items-center">
                                            <div class="w-16 h-16 bg-gray-200 rounded flex items-center justify-center mr-3">
                                                <i class="fas fa-image text-gray-400"></i>
                                            </div>
                                            <button class="text-sm text-blue-600 hover:text-blue-800">
                                                <i class="fas fa-upload mr-1"></i> Upload Cover
                                            </button>
                                        </div>
                                    </div>
                                    
                                    <div class="flex space-x-3">
                                        <button class="px-4 py-2 bg-gray-100 text-gray-700 rounded-lg hover:bg-gray-200 transition">
                                            <i class="fas fa-eye mr-1"></i> Preview
                                        </button>
                                        <button id="exportBtn" class="px-4 py-2 gradient-bg text-white rounded-lg hover:opacity-90 transition">
                                            <i class="fas fa-file-export mr-1"></i> Export Now
                                        </button>
                                    </div>
                                </div>
                            </div>
                            
                            <!-- Export Progress -->
                            <div id="exportProgress" class="hidden bg-white p-6 rounded-lg border border-gray-200">
                                <div class="flex items-center mb-4">
                                    <div class="bg-green-100 p-2 rounded-full mr-3">
                                        <i class="fas fa-file-export text-green-600"></i>
                                    </div>
                                    <div>
                                        <h3 class="font-medium text-gray-800">Exporting as <span id="exportingFormat" class="font-bold"></span></h3>
                                        <p class="text-sm text-gray-500">Your ebook is being prepared for download</p>
                                    </div>
                                </div>
                                
                                <div class="mb-3">
                                    <div class="progress-bar">
                                        <div id="progressFill" class="progress-fill" style="width: 0%"></div>
                                    </div>
                                </div>
                                
                                <div class="flex justify-between text-xs text-gray-500 mb-6">
                                    <span>Preparing files...</span>
                                    <span id="progressPercent">0%</span>
                                </div>
                                
                                <div class="bg-blue-50 border border-blue-200 rounded-lg p-4">
                                    <div class="flex items-start">
                                        <div class="bg-blue-100 p-2 rounded-full mr-3">
                                            <i class="fas fa-info-circle text-blue-600"></i>
                                        </div>
                                        <div>
                                            <h4 class="font-medium text-blue-800 mb-1">Your ebook is almost ready!</h4>
                                            <p class="text-sm text-blue-600">While you wait, consider these next steps to sell your ebook:</p>
                                            <ul class="list-disc list-inside text-xs text-blue-600 mt-2 space-y-1">
                                                <li>Upload to Amazon KDP for global distribution</li>
                                                <li>Create a sales page on your website</li>
                                                <li>Set up email automation for delivery</li>
                                            </ul>
                                        </div>
                                    </div>
                                </div>
                            </div>
                            
                            <!-- Export Complete -->
                            <div id="exportComplete" class="hidden bg-white p-6 rounded-lg border border-gray-200">
                                <div class="flex items-center mb-4">
                                    <div class="bg-green-100 p-2 rounded-full mr-3">
                                        <i class="fas fa-check-circle text-green-600"></i>
                                    </div>
                                    <div>
                                        <h3 class="font-medium text-gray-800">Export Complete!</h3>
                                        <p class="text-sm text-gray-500">Your ebook is ready to download</p>
                                    </div>
                                </div>
                                
                                <div class="mb-6">
                                    <div class="progress-bar">
                                        <div class="progress-fill" style="width: 100%"></div>
                                    </div>
                                </div>
                                
                                <div class="grid grid-cols-1 md:grid-cols-2 gap-6">
                                    <div class="bg-gray-50 p-4 rounded-lg border border-gray-200">
                                        <h4 class="font-medium text-gray-700 mb-2">Download Options</h4>
                                        <div class="space-y-2">
                                            <button class="w-full text-left px-4 py-2 bg-white border border-gray-200 rounded-lg hover:bg-gray-100 transition">
                                                <i class="fas fa-download mr-2 text-blue-600"></i> Download Now
                                            </button>
                                            <button class="w-full text-left px-4 py-2 bg-white border border-gray-200 rounded-lg hover:bg-gray-100 transition">
                                                <i class="fas fa-envelope mr-2 text-blue-600"></i> Email to Me
                                            </button>
                                            <button class="w-full text-left px-4 py-2 bg-white border border-gray-200 rounded-lg hover:bg-gray-100 transition">
                                                <i class="fas fa-cloud-upload-alt mr-2 text-blue-600"></i> Upload to Cloud
                                            </button>
                                        </div>
                                    </div>
                                    
                                    <div class="bg-gray-50 p-4 rounded-lg border border-gray-200">
                                        <h4 class="font-medium text-gray-700 mb-2">Next Steps</h4>
                                        <div class="space-y-3">
                                            <div class="flex items-center">
                                                <div class="bg-blue-100 p-1 rounded-full mr-2">
                                                    <i class="fas fa-store text-blue-600 text-xs"></i>
                                                </div>
                                                <span class="text-sm text-gray-600">Publish on Amazon KDP</span>
                                            </div>
                                            <div class="flex items-center">
                                                <div class="bg-purple-100 p-1 rounded-full mr-2">
                                                    <i class="fas fa-globe text-purple-600 text-xs"></i>
                                                </div>
                                                <span class="text-sm text-gray-600">Create a sales page</span>
                                            </div>
                                            <div class="flex items-center">
                                                <div class="bg-green-100 p-1 rounded-full mr-2">
                                                    <i class="fas fa-envelope text-green-600 text-xs"></i>
                                                </div>
                                                <span class="text-sm text-gray-600">Set up email delivery</span>
                                            </div>
                                        </div>
                                    </div>
                                </div>
                                
                                <div class="mt-6 flex justify-end">
                                    <button onclick="resetExportProcess()" class="px-4 py-2 bg-gray-100 text-gray-700 rounded-lg hover:bg-gray-200 transition">
                                        <i class="fas fa-redo mr-1"></i> Export Another
                                    </button>
                                </div>
                            </div>
                        </div>
                    </div>
                </div>
            </div>

            <!-- API Settings Tab -->
            <div id="api-settings-tab" class="tab-content">
                <div class="max-w-4xl mx-auto">
                    <div class="bg-white rounded-xl shadow-md overflow-hidden">
                        <div class="p-6 border-b border-gray-200">
                            <h2 class="text-2xl font-semibold text-gray-800">API Configuration</h2>
                            <p class="text-sm text-gray-500">Connect to different AI services and customize generation parameters</p>
                        </div>
                        
                        <div class="p-6">
                            <!-- API Connection Status -->
                            <div class="bg-blue-50 border border-blue-200 rounded-lg p-4 mb-6">
                                <div class="flex items-center">
                                    <div class="api-status connected"></div>
                                    <span class="font-medium text-blue-800">Connected to Free Tier API</span>
                                </div>
                                <p class="text-sm text-blue-600 mt-1">You're using our free community API endpoint with limited requests.</p>
                            </div>
                            
                            <!-- Quick Start Section -->
                            <div class="mb-8">
                                <h3 class="text-lg font-medium text-gray-800 mb-3">Quick Start</h3>
                                <div class="bg-gray-50 p-4 rounded-lg">
                                    <p class="text-sm text-gray-600 mb-4">You can start generating ebooks immediately with our free community API. No configuration needed!</p>
                                    <div class="grid grid-cols-1 md:grid-cols-3 gap-4">
                                        <div class="bg-white p-4 rounded-lg border border-gray-200">
                                            <div class="flex items-center mb-2">
                                                <i class="fas fa-bolt text-yellow-500 mr-2"></i>
                                                <h4 class="font-medium">Instant Access</h4>
                                            </div>
                                            <p class="text-xs text-gray-600">Start generating immediately</p>
                                        </div>
                                        <div class="bg-white p-4 rounded-lg border border-gray-200">
                                            <div class="flex items-center mb-2">
                                                <i class="fas fa-tachometer-alt text-blue-500 mr-2"></i>
                                                <h4 class="font-medium">3 RPM Limit</h4>
                                            </div>
                                            <p class="text-xs text-gray-600">3 requests per minute</p>
                                        </div>
                                        <div class="bg-white p-4 rounded-lg border border-gray-200">
                                            <div class="flex items-center mb-2">
                                                <i class="fas fa-robot text-green-500 mr-2"></i>
                                                <h4 class="font-medium">GPT-3.5 Turbo</h4>
                                            </div>
                                            <p class="text-xs text-gray-600">Basic AI model</p>
                                        </div>
                                    </div>
                                </div>
                            </div>
                            
                            <!-- Advanced Parameters -->
                            <div class="mb-8">
                                <h3 class="text-lg font-medium text-gray-800 mb-3">Generation Parameters</h3>
                                <div class="bg-gray-50 p-4 rounded-lg">
                                    <div class="grid grid-cols-1 md:grid-cols-2 gap-6">
                                        <!-- Language Settings -->
                                        <div>
                                            <h4 class="font-medium text-gray-700 mb-2">Language Settings</h4>
                                            <div class="space-y-3">
                                                <div>
                                                    <label class="block text-sm text-gray-600 mb-1">Content Language</label>
                                                    <select class="w-full px-4 py-2 border border-gray-300 rounded-lg focus:ring-2 focus:ring-blue-500 focus:border-blue-500">
                                                        <option>English</option>
                                                        <option>Portuguese</option>
                                                        <option>Spanish</option>
                                                        <option>French</option>
                                                        <option>German</option>
                                                        <option>Italian</option>
                                                    </select>
                                                </div>
                                                <div>
                                                    <label class="block text-sm text-gray-600 mb-1">Target Audience</label>
                                                    <select class="w-full px-4 py-2 border border-gray-300 rounded-lg focus:ring-2 focus:ring-blue-500 focus:border-blue-500">
                                                        <option>Global</option>
                                                        <option>Brazil</option>
                                                        <option>United States</option>
                                                        <option>Europe</option>
                                                        <option>Latin America</option>
                                                    </select>
                                                </div>
                                            </div>
                                        </div>
                                        
                                        <!-- Tone and Style -->
                                        <div>
                                            <h4 class="font-medium text-gray-700 mb-2">Tone & Style</h4>
                                            <div class="space-y-3">
                                                <div>
                                                    <label class="block text-sm text-gray-600 mb-1">Writing Tone</label>
                                                    <select class="w-full px-4 py-2 border border-gray-300 rounded-lg focus:ring-2 focus:ring-blue-500 focus:border-blue-500">
                                                        <option>Professional</option>
                                                        <option>Friendly</option>
                                                        <option>Academic</option>
                                                        <option>Conversational</option>
                                                        <option>Authoritative</option>
                                                    </select>
                                                </div>
                                                <div>
                                                    <label class="block text-sm text-gray-600 mb-1">Content Formality</label>
                                                    <select class="w-full px-4 py-2 border border-gray-300 rounded-lg focus:ring-2 focus:ring-blue-500 focus:border-blue-500">
                                                        <option>Medium</option>
                                                        <option>Very Formal</option>
                                                        <option>Formal</option>
                                                        <option>Casual</option>
                                                        <option>Very Casual</option>
                                                    </select>
                                                </div>
                                            </div>
                                        </div>
                                        
                                        <!-- Content Parameters -->
                                        <div>
                                            <h4 class="font-medium text-gray-700 mb-2">Content Parameters</h4>
                                            <div class="space-y-3">
                                                <div>
                                                    <label class="block text-sm text-gray-600 mb-1">Creativity Level</label>
                                                    <input type="range" min="0" max="100" value="70" class="w-full h-2 bg-gray-200 rounded-lg appearance-none cursor-pointer">
                                                    <div class="flex justify-between text-xs text-gray-500">
                                                        <span>Factual</span>
                                                        <span>Balanced</span>
                                                        <span>Creative</span>
                                                    </div>
                                                </div>
                                                <div>
                                                    <label class="block text-sm text-gray-600 mb-1">Content Length</label>
                                                    <input type="range" min="0" max="100" value="50" class="w-full h-2 bg-gray-200 rounded-lg appearance-none cursor-pointer">
                                                    <div class="flex justify-between text-xs text-gray-500">
                                                        <span>Concise</span>
                                                        <span>Medium</span>
                                                        <span>Detailed</span>
                                                    </div>
                                                </div>
                                            </div>
                                        </div>
                                        
                                        <!-- Visual Elements -->
                                        <div>
                                            <h4 class="font-medium text-gray-700 mb-2">Visual Elements</h4>
                                            <div class="space-y-3">
                                                <div class="flex items-center justify-between">
                                                    <label class="block text-sm text-gray-600">Include Images</label>
                                                    <div class="relative inline-block w-10 mr-2 align-middle select-none">
                                                        <input type="checkbox" id="includeImages" class="toggle-checkbox absolute block w-6 h-6 rounded-full bg-white border-4 appearance-none cursor-pointer"/>
                                                        <label for="includeImages" class="toggle-label block overflow-hidden h-6 rounded-full bg-gray-300 cursor-pointer"></label>
                                                    </div>
                                                </div>
                                                <div class="flex items-center justify-between">
                                                    <label class="block text-sm text-gray-600">Include Diagrams</label>
                                                    <div class="relative inline-block w-10 mr-2 align-middle select-none">
                                                        <input type="checkbox" id="includeDiagrams" class="toggle-checkbox absolute block w-6 h-6 rounded-full bg-white border-4 appearance-none cursor-pointer"/>
                                                        <label for="includeDiagrams" class="toggle-label block overflow-hidden h-6 rounded-full bg-gray-300 cursor-pointer"></label>
                                                    </div>
                                                </div>
                                                <div>
                                                    <label class="block text-sm text-gray-600 mb-1">Image Style</label>
                                                    <select class="w-full px-4 py-2 border border-gray-300 rounded-lg focus:ring-2 focus:ring-blue-500 focus:border-blue-500">
                                                        <option>Photorealistic</option>
                                                        <option>Illustration</option>
                                                        <option>Minimalist</option>
                                                        <option>3D Render</option>
                                                    </select>
                                                </div>
                                            </div>
                                        </div>
                                    </div>
                                    
                                    <div class="mt-6">
                                        <button class="gradient-bg text-white py-2 px-6 rounded-lg hover:opacity-90 transition">
                                            <i class="fas fa-save mr-2"></i> Save Parameters
                                        </button>
                                    </div>
                                </div>
                            </div>
                            
                            <!-- Premium Upgrade Section -->
                            <div>
                                <h3 class="text-lg font-medium text-gray-800 mb-3">Upgrade for More Features</h3>
                                <div class="bg-gradient-to-r from-blue-50 to-purple-50 p-6 rounded-lg border border-blue-100">
                                    <div class="flex flex-col md:flex-row items-center">
                                        <div class="md:w-2/3 mb-4 md:mb-0">
                                            <h4 class="font-bold text-lg text-gray-800 mb-1">Unlock Premium Features</h4>
                                            <p class="text-sm text-gray-600">Get higher limits, better models, and advanced customization options with our premium plans.</p>
                                        </div>
                                        <div class="md:w-1/3 flex justify-end">
                                            <button class="gradient-bg text-white py-2 px-6 rounded-lg hover:opacity-90 transition">
                                                View Plans
                                            </button>
                                        </div>
                                    </div>
                                </div>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </main>
    </div>

    <script>
        // Tab switching functionality
        function showTab(tabName) {
            document.querySelectorAll('.tab-content').forEach(tab => {
                tab.classList.remove('active');
            });
            document.getElementById(`${tabName}-tab`).classList.add('active');
        }

        // Ebook generation functionality
        document.getElementById('ebookForm').addEventListener('submit', function(e) {
            e.preventDefault();
            generateEbook();
        });

        function generateEbook() {
            // Show loading state
            document.getElementById('emptyState').classList.add('hidden');
            document.getElementById('ebookContent').classnelist.add('hidden');
            document.getElementById('loadingState').classList.remove('hidden');
            
            // Get form values
            const title = document.getElementById('ebookTitle').value;
            const topic = document.getElementById('ebookTopic').value;
            const keywords = document.getElementById('ebookKeywords').value;
            const summary = document.getElementById('ebookSummary').value;
            const chapterCount = parseInt(document.getElementById('chapterCount').value);
            const writingStyle = document.getElementById('writingStyle').value;
            
            // Simulate API call with timeout
            setTimeout(() => {
                // Hide loading state
                document.getElementById('loadingState').classList.add('hidden');
                
                // Generate ebook content
                const ebookData = generateMockEbook(title, topic, keywords, summary, chapterCount, writingStyle);
                
                // Display the generated ebook
                displayEbook(ebookData);
                
                // Show content
                document.getElementById('ebookContent').classList.remove('hidden');
            }, 3000);
        }
        
        function generateMockEbook(title, topic, keywords, summary, chapterCount, style) {
            const styles = {
                professional: "This comprehensive guide provides professional insights",
                casual: "This friendly guide walks you through",
                academic: "This scholarly examination presents",
                storytelling: "Let me tell you the story of"
            };
            
            const subtitle = `${styles[style]} ${topic.toLowerCase()}.`;
            
            // Generate chapters
            const chapters = [];
            const toc = [];
            
            for (let i = 1; i <= chapterCount; i++) {
                const chapterTitle = generateChapterTitle(topic, i, chapterCount);
                const chapterContent = generateChapterContent(topic, keywords, i, chapterCount, style);
                
                chapters.push({
                    title: chapterTitle,
                    content: chapterContent
                });
                
                toc.push({
                    title: chapterTitle,
                    id: `chapter-${i}`
                });
            }
            
            return {
                title,
                subtitle,
                toc,
                chapters,
                generatedAt: new Date().toLocaleString()
            };
        }
        
        function generateChapterTitle(topic, index, total) {
            const prefixes = [
                "Introduction to",
                "The Fundamentals of",
                "Advanced Techniques in",
                "Practical Applications of",
                "Case Studies in",
                "Future Trends in",
                "Best Practices for",
                "Common Mistakes in",
                "Tools and Resources for",
                "Getting Started with"
            ];
            
            const suffixes = [
                "Explained",
                "Demystified",
                "Uncovered",
                "Revealed",
                "Made Simple",
                "for Beginners",
                "for Professionals",
                "in Practice",
                "in the Real World",
                "and Beyond"
            ];
            
            // Use more specific prefixes for later chapters
            const prefix = index === 1 ? prefixes[0] : 
                          index === total ? prefixes[5] : 
                          prefixes[Math.min(index, prefixes.length - 1)];
            
            const suffix = suffixes[Math.floor(Math.random() * suffixes.length)];
            
            return `${prefix} ${topic} ${suffix}`;
        }
        
        function generateChapterContent(topic, keywords, index, total, style) {
            const keywordList = keywords.split(',').map(k => k.trim()).filter(k => k.length > 0);
            
            const paragraphs = [];
            const paragraphCount = 3 + Math.floor(Math.random() * 3); // 3-5 paragraphs
            
            for (let i = 0; i < paragraphCount; i++) {
                let paragraph = "";
                
                // First paragraph introduces the chapter
                if (i === 0) {
                    paragraph = `In this chapter, we ${style === 'academic' ? 'examine' : style === 'professional' ? 'explore' : 'look at'} `;
                    paragraph += `the ${index === 1 ? 'basic concepts' : index === total ? 'future implications' : 'key aspects'} `;
                    paragraph += `of ${topic.toLowerCase()}. `;
                    
                    if (keywordList.length > 0) {
                        paragraph += `Particular focus will be given to ${keywordList.join(', ')}. `;
                    }
                }
                // Middle paragraphs provide content
                else {
                    const concepts = [
                        "This approach has been shown to produce significant results",
                        "Many experts agree that this method is effective",
                        "Recent studies have demonstrated the value of this technique",
                        "When implemented correctly, this strategy can yield benefits",
                        "Organizations that adopt this practice often see improvements",
                        "The data clearly supports the effectiveness of this solution"
                    ];
                    
                    const examples = [
                        "For example, a recent case study showed",
                        "Consider how this applies to a typical scenario",
                        "To illustrate this point, imagine a situation where",
                        "A practical example of this would be",
                        "This can be seen in the way that",
                        "We can observe this in action when"
                    ];
                    
                    const transitions = [
                        "Building on this concept,",
                        "Taking this a step further,",
                        "In addition to this,",
                        "Furthermore,",
                        "Another important consideration is",
                        "It's also worth noting that"
                    ];
                    
                    if (i === 1) {
                        paragraph = concepts[Math.floor(Math.random() * concepts.length)] + ". ";
                        paragraph += examples[Math.floor(Math.random() * examples.length)] + " ";
                        paragraph += "this leads to measurable outcomes. ";
                    } else {
                        paragraph = transitions[Math.floor(Math.random() * transitions.length)] + " ";
                        paragraph += concepts[Math.floor(Math.random() * concepts.length)].toLowerCase() + ". ";
                        
                        if (Math.random() > 0.3) {
                            paragraph += examples[Math.floor(Math.random() * examples.length)] + " ";
                            paragraph += "the results speak for themselves. ";
                        }
                    }
                }
                
                // Add some keywords if available
                if (keywordList.length > 0 && Math.random() > 0.5) {
                    const keyword = keywordList[Math.floor(Math.random() * keywordList.length)];
                    paragraph += `The role of ${keyword} in this process cannot be overstated. `;
                }
                
                paragraphs.push(paragraph);
            }
            
            // Add a concluding paragraph
            let conclusion = "";
            if (index === 1) {
                conclusion = "This chapter has introduced the fundamental concepts that will be explored in more depth throughout this ebook. ";
            } else if (index === total) {
                conclusion = "In conclusion, this chapter has summarized the key takeaways and looked ahead to future developments in the field. ";
            } else {
                conclusion = "The insights from this chapter provide a solid foundation for understanding the more advanced topics that follow. ";
            }
            
            conclusion += "In the next chapter, we will " + 
                (index === total ? "summarize all the key lessons from this ebook." : 
                `explore ${index === total - 1 ? "the final aspects" : "more advanced concepts"} of ${topic.toLowerCase()}.`);
            
            paragraphs.push(conclusion);
            
            return paragraphs;
        }
        
        function displayEbook(ebookData) {
            // Set title and metadata
            document.getElementById('previewTitle').textContent = ebookData.title;
            document.getElementById('previewSubtitle').textContent = ebookData.subtitle;
            document.getElementById('generatedTime').textContent = `Generated ${ebookData.generatedAt}`;
            
            // Generate table of contents
            const tocList = document.getElementById('tocList');
            tocList.innerHTML = '';
            
            ebookData.toc.forEach((item, index) => {
                const tocItem = document.createElement('div');
                tocItem.className = 'chapter-item transition duration-200';
                tocItem.innerHTML = `
                    <a href="#${item.id}" class="flex items-center text-blue-600 hover:text-blue-800">
                        <span class="w-6 text-gray-500 font-medium">${index + 1}.</span>
                        <span>${item.title}</span>
                    </a>
                `;
                tocList.appendChild(tocItem);
            });
            
            // Generate chapters
            const chaptersContainer = document.getElementById('chaptersContainer');
            chaptersContainer.innerHTML = '';
            
            ebookData.chapters.forEach((chapter, index) => {
                const chapterElement = document.createElement('div');
                chapterElement.id = `chapter-${index + 1}`;
                chapterElement.className = 'chapter';
                
                let chapterHTML = `
                    <div class="mb-6">
                        <div class="flex items-center mb-4">
                            <span class="bg-blue-100 text-blue-800 font-bold rounded-full w-8 h-8 flex items-center justify-center mr-3">${index + 1}</span>
                            <h2 class="text-2xl font-bold text-gray-800">${chapter.title}</h2>
                        </div>
                `;
                
                chapter.content.forEach(paragraph => {
                    chapterHTML += `<p class="text-gray-700 mb-4">${paragraph}</p>`;
                });
                
                chapterHTML += `</div>`;
                chapterElement.innerHTML = chapterHTML;
                chaptersContainer.appendChild(chapterElement);
            });
        }

        // Export functionality
        function selectFormat(format) {
            document.getElementById('formatOptions').classList.remove('hidden');
            document.getElementById('selectedFormatName').textContent = format.toUpperCase();
            
            // Hide all format options
            document.querySelectorAll('#formatOptions > div > div[id$="Options"]').forEach(el => {
                el.classList.add('hidden');
            });
            
            // Show selected format options
            document.getElementById(`${format}Options`).classList.remove('hidden');
        }
        
        function resetFormatSelection() {
            document.getElementById('formatOptions').classList.add('hidden');
        }
        
        document.getElementById('exportBtn').addEventListener('click', function() {
            document.getElementById('formatOptions').classList.add('hidden');
            document.getElementById('exportProgress').classList.remove('hidden');
            document.getElementById('exportingFormat').textContent = document.getElementById('selectedFormatName').textContent;
            
            // Simulate export progress
            let progress = 0;
            const progressInterval = setInterval(() => {
                progress += Math.floor(Math.random() * 10) + 5;
                if (progress > 100) progress = 100;
                
                document.getElementById('progressFill').style.width = `${progress}%`;
                document.getElementById('progressPercent').textContent = `${progress}%`;
                
                if (progress === 100) {
                    clearInterval(progressInterval);
                    setTimeout(() => {
                        document.getElementById('exportProgress').classList.add('hidden');
                        document.getElementById('exportComplete').classList.remove('hidden');
                    }, 500);
                }
            }, 300);
        });
        
        function resetExportProcess() {
            document.getElementById('exportComplete').classList.add('hidden');
            document.getElementById('formatOptions').classList.remove('hidden');
        }

        // Initialize toggle switches
        document.addEventListener('DOMContentLoaded', function() {
            const toggleCheckboxes = document.querySelectorAll('.toggle-checkbox');
            toggleCheckboxes.forEach(checkbox => {
                checkbox.addEventListener('change', function() {
                    const label = this.nextElementSibling;
                    if (this.checked) {
                        label.classList.remove('bg-gray-300');
                        label.classList.add('bg-blue-500');
                    } else {
                        label.classList.remove('bg-blue-500');
                        label.classList.add('bg-gray-300');
                    }
                });
            });
        });
    </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=amwolf36/de" style="color: #fff;text-decoration: underline;" target="_blank" >Remix</a></p></body>
</html>