File size: 49,700 Bytes
8d3de43
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
<!DOCTYPE html>
<html lang="de">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>NoahsKI - Einstellungen ⚙️</title>
    <style>
        @import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700;800;900&display=swap');
        
        * {
            margin: 0;
            padding: 0;
            box-sizing: border-box;
        }
        
        body {
            font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
            background: linear-gradient(135deg, #667eea 0%, #764ba2 50%, #f093fb 100%);
            min-height: 100vh;
            color: #1f2937;
            padding: 20px;
        }
        
        .container {
            max-width: 1200px;
            margin: 0 auto;
        }
        
        /* Header with Logo */
        .header {
            background: rgba(255, 255, 255, 0.1);
            backdrop-filter: blur(20px);
            border-radius: 20px;
            padding: 30px;
            margin-bottom: 30px;
            border: 1px solid rgba(255, 255, 255, 0.2);
            display: flex;
            align-items: center;
            justify-content: space-between;
        }
        
        .logo-section {
            display: flex;
            align-items: center;
            gap: 20px;
        }
        
        .logo-img {
            width: 60px;
            height: 60px;
            background: white;
            border-radius: 15px;
            padding: 10px;
            box-shadow: 0 4px 15px rgba(0,0,0,0.1);
        }
        
        .logo-text h1 {
            color: white;
            font-size: 32px;
            font-weight: 800;
            text-shadow: 2px 2px 4px rgba(0,0,0,0.1);
        }
        
        .logo-text p {
            color: rgba(255,255,255,0.9);
            font-size: 14px;
        }
        
        .back-btn {
            background: white;
            color: #8b5cf6;
            border: none;
            padding: 12px 24px;
            border-radius: 10px;
            font-weight: 600;
            cursor: pointer;
            transition: all 0.3s;
        }
        
        .back-btn:hover {
            transform: translateY(-2px);
            box-shadow: 0 5px 15px rgba(0,0,0,0.2);
        }
        
        /* Tabs */
        .tabs {
            background: rgba(255, 255, 255, 0.1);
            backdrop-filter: blur(20px);
            border-radius: 15px;
            padding: 10px;
            margin-bottom: 30px;
            display: flex;
            gap: 10px;
            border: 1px solid rgba(255, 255, 255, 0.2);
        }
        
        .tab-btn {
            flex: 1;
            background: transparent;
            color: white;
            border: none;
            padding: 15px 20px;
            border-radius: 10px;
            font-weight: 600;
            cursor: pointer;
            transition: all 0.3s;
        }
        
        .tab-btn.active {
            background: white;
            color: #8b5cf6;
            box-shadow: 0 4px 15px rgba(0,0,0,0.1);
        }
        
        .tab-btn:not(.active):hover {
            background: rgba(255,255,255,0.1);
        }
        
        /* Content Cards */
        .tab-content {
            display: none;
        }
        
        .tab-content.active {
            display: block;
        }
        
        .card {
            background: rgba(255, 255, 255, 0.95);
            backdrop-filter: blur(20px);
            border-radius: 20px;
            padding: 30px;
            margin-bottom: 20px;
            border: 1px solid rgba(255, 255, 255, 0.2);
            box-shadow: 0 8px 32px rgba(0,0,0,0.1);
        }
        
        .card h2 {
            color: #1f2937;
            font-size: 24px;
            margin-bottom: 20px;
            display: flex;
            align-items: center;
            gap: 10px;
        }
        
        .card h3 {
            color: #4b5563;
            font-size: 18px;
            margin: 20px 0 15px 0;
        }
        
        .form-group {
            margin-bottom: 20px;
        }
        
        .form-group label {
            display: block;
            color: #374151;
            font-weight: 500;
            margin-bottom: 8px;
            font-size: 14px;
        }
        
        .form-group input,
        .form-group select,
        .form-group textarea {
            width: 100%;
            padding: 12px 16px;
            border: 2px solid #e5e7eb;
            border-radius: 12px;
            font-family: 'Inter', sans-serif;
            font-size: 14px;
            font-weight: 500;
            transition: all 0.3s ease;
            background: #fafbfc;
        }
        
        .form-group input:focus,
        .form-group select:focus,
        .form-group textarea:focus {
            outline: none;
            border-color: #8b5cf6;
            background: white;
            box-shadow: 0 0 0 4px rgba(139, 92, 246, 0.15), inset 0 0 0 1px rgba(139, 92, 246, 0.1);
        }
        
        .form-group textarea {
            resize: vertical;
            min-height: 100px;
            font-weight: 400;
        }
        
        /* Toggle Switch */
        .toggle-group {
            display: flex;
            align-items: center;
            justify-content: space-between;
            padding: 15px 0;
            border-bottom: 1px solid #e5e7eb;
        }
        
        .toggle-group:last-child {
            border-bottom: none;
        }
        
        .toggle-label {
            flex: 1;
        }
        
        .toggle-label strong {
            display: block;
            color: #1f2937;
            margin-bottom: 4px;
        }
        
        .toggle-label span {
            color: #6b7280;
            font-size: 13px;
        }
        
        .toggle-switch {
            position: relative;
            width: 50px;
            height: 26px;
        }
        
        .toggle-switch input {
            opacity: 0;
            width: 0;
            height: 0;
        }
        
        .toggle-slider {
            position: absolute;
            cursor: pointer;
            top: 0;
            left: 0;
            right: 0;
            bottom: 0;
            background-color: #cbd5e1;
            transition: 0.3s;
            border-radius: 34px;
        }
        
        .toggle-slider:before {
            position: absolute;
            content: "";
            height: 20px;
            width: 20px;
            left: 3px;
            bottom: 3px;
            background-color: white;
            transition: 0.3s;
            border-radius: 50%;
        }
        
        input:checked + .toggle-slider {
            background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
        }
        
        input:checked + .toggle-slider:before {
            transform: translateX(24px);
        }
        
        /* Buttons */
        .btn {
            padding: 12px 24px;
            border: none;
            border-radius: 10px;
            font-weight: 600;
            cursor: pointer;
            transition: all 0.3s;
            font-size: 14px;
        }
        
        .btn-primary {
            background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
            color: white;
            box-shadow: 0 6px 20px rgba(139, 92, 246, 0.3);
        }
        
        .btn-primary:hover {
            transform: translateY(-3px);
            box-shadow: 0 8px 28px rgba(139, 92, 246, 0.45);
        }
        
        .btn-primary:active {
            transform: translateY(-1px);
        }
        
        .btn-secondary {
            background: #e5e7eb;
            color: #1f2937;
        }
        
        .btn-secondary:hover {
            background: #d1d5db;
        }
        
        .btn-danger {
            background: #ef4444;
            color: white;
        }
        
        .btn-danger:hover {
            background: #dc2626;
        }
        
        .btn-group {
            display: flex;
            gap: 10px;
            margin-top: 20px;
        }
        
        /* Stats Grid */
        .stats-grid {
            display: grid;
            grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
            gap: 20px;
            margin-bottom: 20px;
        }
        
        .stat-card {
            background: linear-gradient(135deg, rgba(139, 92, 246, 0.1) 0%, rgba(236, 72, 153, 0.1) 100%);
            padding: 25px;
            border-radius: 15px;
            border: 2px solid rgba(139, 92, 246, 0.2);
        }
        
        .stat-card h3 {
            color: #6b7280;
            font-size: 14px;
            margin: 0 0 10px 0;
            font-weight: 500;
        }
        
        .stat-value {
            color: #8b5cf6;
            font-size: 32px;
            font-weight: 800;
            margin-bottom: 5px;
        }
        
        .stat-label {
            color: #9ca3af;
            font-size: 12px;
        }
        
        /* Status Badge */
        .status-badge {
            display: inline-block;
            padding: 6px 12px;
            border-radius: 20px;
            font-size: 12px;
            font-weight: 600;
        }
        
        .status-active {
            background: #d1fae5;
            color: #065f46;
        }
        
        .status-inactive {
            background: #fee2e2;
            color: #991b1b;
        }
        
        /* Alert Messages */
        .alert {
            padding: 15px 20px;
            border-radius: 10px;
            margin-bottom: 20px;
            display: flex;
            align-items: center;
            gap: 10px;
        }
        
        .alert-success {
            background: #d1fae5;
            color: #065f46;
            border: 1px solid #6ee7b7;
        }
        
        .alert-error {
            background: #fee2e2;
            color: #991b1b;
            border: 1px solid #fca5a5;
        }
        
        .alert-info {
            background: #dbeafe;
            color: #1e40af;
            border: 1px solid #93c5fd;
        }
        
        /* Bot Token Display */
        .token-display {
            background: #f3f4f6;
            padding: 15px;
            border-radius: 10px;
            font-family: 'Courier New', monospace;
            font-size: 13px;
            word-break: break-all;
            color: #374151;
            margin-top: 10px;
        }
        
        /* Loading */
        .loading {
            text-align: center;
            padding: 40px;
        }
        
        .spinner {
            border: 4px solid #f3f4f6;
            border-top: 4px solid #8b5cf6;
            border-radius: 50%;
            width: 40px;
            height: 40px;
            animation: spin 1s linear infinite;
            margin: 0 auto 20px;
        }
        
        @keyframes spin {
            0% { transform: rotate(0deg); }
            100% { transform: rotate(360deg); }
        }
        
        /* Responsive */
        @media (max-width: 768px) {
            .container {
                padding: 10px;
            }
            
            .header {
                flex-direction: column;
                gap: 20px;
            }
            
            .tabs {
                flex-direction: column;
            }
            
            .stats-grid {
                grid-template-columns: 1fr;
            }
        }
    </style>
</head>
<body>
    <div class="container">
        <!-- Header -->
        <div class="header">
            <div class="logo-section">
                <img src="/static/logo.png" alt="NoahsKI Logo" class="logo-img">
                <div class="logo-text">
                    <h1>NoahsKI</h1>
                    <p>Deine persönliche KI - Einstellungen</p>
                </div>
            </div>
            <button class="back-btn" onclick="location.href='/'">← Zurück zur App</button>
        </div>
        
        <!-- Tabs -->
        <div class="tabs">
            <button class="tab-btn active" onclick="switchTab('profile')">👤 Profil</button>
            <button class="tab-btn" onclick="switchTab('discord')">✨ Bot Konfiguration</button>
            <button class="tab-btn" onclick="switchTab('preferences')">⚙️ Einstellungen</button>
            <button class="tab-btn" onclick="switchTab('stats')">📊 Statistiken</button>
            <button class="tab-btn" onclick="switchTab('security')">🔒 Sicherheit</button>
        </div>
        
        <!-- Profile Tab -->
        <div id="profile-tab" class="tab-content active">
            <div class="card">
                <h2>👤 Profil Informationen</h2>
                <div class="form-group">
                    <label>Benutzername</label>
                    <input type="text" id="username" placeholder="Dein Benutzername">
                </div>
                <div class="form-group">
                    <label>E-Mail Adresse</label>
                    <input type="email" id="email" readonly style="background: #f3f4f6;">
                </div>
                <div class="form-group">
                    <label>Mitglied seit</label>
                    <input type="text" id="member-since" readonly style="background: #f3f4f6;">
                </div>
                <div class="btn-group">
                    <button class="btn btn-primary" onclick="saveProfile()">💾 Profil speichern</button>
                </div>
            </div>
        </div>
        
        <!-- Bot Configuration Tab -->
        <div id="discord-tab" class="tab-content">
            <div class="card">
                <h2>✨ Bot Konfiguration</h2>
                <p style="color: #6b7280; margin-bottom: 20px;">
                    Konfiguriere deinen persönlichen Bot, der die NoahsKI Engine nutzt!
                </p>
                
                <div class="alert alert-info">
                    <span>ℹ️</span>
                    <div>
                        <strong>So funktioniert's:</strong><br>
                        1. Konfiguriere die Bot-Einstellungen unten<br>
                        2. Gib deinen Bot Token ein (falls erforderlich)<br>
                        3. Aktiviere den Bot und speichere die Einstellungen<br>
                        4. Der Bot ist bereit und antwortet auf Befehle!
                    </div>
                </div>
                
                <div class="toggle-group">
                    <div class="toggle-label">
                        <strong>Bot aktivieren</strong>
                        <span>Aktiviere deinen persönlichen Bot</span>
                    </div>
                    <label class="toggle-switch">
                        <input type="checkbox" id="discord-enabled" onchange="toggleDiscordSettings()">
                        <span class="toggle-slider"></span>
                    </label>
                </div>
                
                <div id="discord-settings" style="display: none; margin-top: 20px;">
                    <h3>Bot Konfiguration</h3>
                    
                    <div class="form-group">
                        <label>Bot Token</label>
                        <input type="password" id="discord-token" placeholder="Dein Bot Token (optional)">
                        <small style="color: #6b7280; display: block; margin-top: 5px;">
                            🔐 Dein Token wird sicher verschlüsselt gespeichert
                        </small>
                    </div>
                    
                    <div class="form-group">
                        <label>Bot Prefix</label>
                        <input type="text" id="discord-prefix" placeholder="!" maxlength="5" value="!">
                        <small style="color: #6b7280; display: block; margin-top: 5px;">
                            Das Zeichen, mit dem Bot-Befehle starten (z.B. !, ?, $, ~)
                        </small>
                    </div>
                    
                    <div class="form-group">
                        <label>Bot Status</label>
                        <select id="discord-status">
                            <option value="online">🟢 Online</option>
                            <option value="idle">🟡 Abwesend</option>
                            <option value="dnd">🔴 Nicht stören</option>
                            <option value="invisible">⚫ Unsichtbar</option>
                        </select>
                    </div>
                    
                    <div class="form-group">
                        <label>Bot Aktivität</label>
                        <input type="text" id="discord-activity" placeholder="z.B. mit NoahsKI" value="mit NoahsKI">
                    </div>
                    
                    <div class="alert alert-success">
                        <span></span>
                        <div>
                            <strong>Verfügbare Kommandos:</strong><br>
                            `!help` - Zeige alle Befehle | `!ask <Frage>` - Stelle Fragen<br>
                            `!image <Beschr.>` - Generiere Bilder | `!code <Request>` - Generiere Code<br>
                            `!translate <Text>` - Übersetze Text | `!joke` - Höre einen Witz<br>
                            `!summarize <Text>` - Fasse zusammen | `!quote` - Inspirierendes Zitat<br>
                            `!info <Thema>` - Info zu Themen | `!languages` - Unterstützte Sprachen
                        </div>
                    </div>
                    
                    <div class="btn-group">
                        <button class="btn btn-primary" onclick="saveDiscordBot()">💾 Bot Einstellungen speichern</button>
                        <button class="btn btn-secondary" onclick="testDiscordBot()">🧪 Bot testen</button>
                    </div>
                </div>
            </div>
            
            <div class="card" id="bot-status-card" style="display: none;">
                <h2>✨ Bot Status</h2>
                <div class="stats-grid">
                    <div class="stat-card">
                        <h3>Bot Status</h3>
                        <div class="stat-value" id="bot-status">
                            <span class="status-badge status-inactive">Inaktiv</span>
                        </div>
                        <div class="stat-label">Aktueller Status</div>
                    </div>
                    <div class="stat-card">
                        <h3>Server</h3>
                        <div class="stat-value" id="bot-servers">0</div>
                        <div class="stat-label">Verbundene Server</div>
                    </div>
                    <div class="stat-card">
                        <h3>Nachrichten</h3>
                        <div class="stat-value" id="bot-messages">0</div>
                        <div class="stat-label">Heute verarbeitet</div>
                    </div>
                </div>
            </div>
        </div>
        
        <!-- Preferences Tab -->
        <div id="preferences-tab" class="tab-content">
            <div class="card">
                <h2>⚙️ Persönliche Einstellungen</h2>
                
                <div class="form-group">
                    <label>Design / Theme</label>
                    <select id="theme">
                        <option value="dark">🌙 Dunkel</option>
                        <option value="light">☀️ Hell</option>
                        <option value="auto">🔄 Automatisch</option>
                    </select>
                </div>
                
                <div class="form-group">
                    <label>Sprache</label>
                    <select id="language">
                        <option value="de">🇩🇪 Deutsch</option>
                        <option value="en">🇬🇧 English</option>
                        <option value="es">🇪🇸 Español</option>
                        <option value="fr">🇫🇷 Français</option>
                        <option value="it">🇮🇹 Italiano</option>
                    </select>
                </div>
                
                <h3>Benachrichtigungen</h3>
                
                <div class="toggle-group">
                    <div class="toggle-label">
                        <strong>Push Benachrichtigungen</strong>
                        <span>Erhalte Benachrichtigungen über wichtige Ereignisse</span>
                    </div>
                    <label class="toggle-switch">
                        <input type="checkbox" id="notifications" checked>
                        <span class="toggle-slider"></span>
                    </label>
                </div>
                
                <div class="toggle-group">
                    <div class="toggle-label">
                        <strong>E-Mail Benachrichtigungen</strong>
                        <span>Erhalte E-Mails über wichtige Updates</span>
                    </div>
                    <label class="toggle-switch">
                        <input type="checkbox" id="email-notifications" checked>
                        <span class="toggle-slider"></span>
                    </label>
                </div>
                
                <div class="toggle-group">
                    <div class="toggle-label">
                        <strong>Benachrichtigungen</strong>
                        <span>Erhalte Benachrichtigungen über Bot-Dinge</span>
                    </div>
                    <label class="toggle-switch">
                        <input type="checkbox" id="discord-notifications">
                        <span class="toggle-slider"></span>
                    </label>
                </div>
                
                <h3>KI Einstellungen</h3>
                
                <div class="form-group">
                    <label>Kreativität</label>
                    <input type="range" id="creativity" min="0" max="100" value="70" 
                           oninput="document.getElementById('creativity-value').innerText = this.value + '%'"
                           style="width: 100%;">
                    <div style="text-align: right; color: #6b7280; font-size: 13px; margin-top: 5px;">
                        <span id="creativity-value">70%</span>
                    </div>
                </div>
                
                <div class="form-group">
                    <label>Antwortlänge</label>
                    <select id="response-length">
                        <option value="short">Kurz</option>
                        <option value="medium" selected>Mittel</option>
                        <option value="long">Lang</option>
                        <option value="detailed">Sehr detailliert</option>
                    </select>
                </div>
                
                <div class="toggle-group">
                    <div class="toggle-label">
                        <strong>Code-Syntax-Highlighting</strong>
                        <span>Aktiviere Syntax-Highlighting für Code-Blöcke</span>
                    </div>
                    <label class="toggle-switch">
                        <input type="checkbox" id="syntax-highlighting" checked>
                        <span class="toggle-slider"></span>
                    </label>
                </div>
                
                <div class="btn-group">
                    <button class="btn btn-primary" onclick="savePreferences()">💾 Einstellungen speichern</button>
                    <button class="btn btn-secondary" onclick="resetSettings()">🔄 Zurücksetzen</button>
                    <button class="btn btn-secondary" onclick="exportSettings()">📤 Exportieren</button>
                </div>
            </div>
        </div>
        
        <!-- Stats Tab -->
        <div id="stats-tab" class="tab-content">
            <div class="card">
                <h2>📊 Deine Statistiken</h2>
                <div class="stats-grid">
                    <div class="stat-card">
                        <h3>Account Alter</h3>
                        <div class="stat-value" id="account-age">0</div>
                        <div class="stat-label">Tage</div>
                    </div>
                    <div class="stat-card">
                        <h3>Letzte Anmeldung</h3>
                        <div class="stat-value" style="font-size: 18px;" id="last-login">-</div>
                        <div class="stat-label">Datum</div>
                    </div>
                    <div class="stat-card">
                        <h3>Aktive Sessions</h3>
                        <div class="stat-value" id="active-sessions">0</div>
                        <div class="stat-label">Geräte</div>
                    </div>
                    <div class="stat-card">
                        <h3>Nachrichten</h3>
                        <div class="stat-value" id="total-messages">0</div>
                        <div class="stat-label">Gesendet (geschätzt)</div>
                    </div>
                </div>
            </div>
            
            <div class="card">
                <h2>🎯 Nutzungsstatistiken</h2>
                <div class="stats-grid">
                    <div class="stat-card">
                        <h3>Bilder generiert</h3>
                        <div class="stat-value">0</div>
                        <div class="stat-label">Insgesamt</div>
                    </div>
                    <div class="stat-card">
                        <h3>Web-Suchen</h3>
                        <div class="stat-value">0</div>
                        <div class="stat-label">Durchgeführt</div>
                    </div>
                    <div class="stat-card">
                        <h3>Code generiert</h3>
                        <div class="stat-value">0</div>
                        <div class="stat-label">Zeilen</div>
                    </div>
                    <div class="stat-card">
                        <h3>Sprachen</h3>
                        <div class="stat-value">0</div>
                        <div class="stat-label">Verwendet</div>
                    </div>
                </div>
            </div>
        </div>
        
        <!-- Security Tab -->
        <div id="security-tab" class="tab-content">
            <div class="card">
                <h2>🔒 Sicherheit & Passwort</h2>
                
                <h3>Passwort ändern</h3>
                <div class="form-group">
                    <label>Aktuelles Passwort</label>
                    <input type="password" id="current-password" placeholder="Aktuelles Passwort">
                </div>
                <div class="form-group">
                    <label>Neues Passwort</label>
                    <input type="password" id="new-password" placeholder="Neues Passwort (min. 6 Zeichen)">
                </div>
                <div class="form-group">
                    <label>Neues Passwort bestätigen</label>
                    <input type="password" id="confirm-password" placeholder="Neues Passwort bestätigen">
                </div>
                <div class="btn-group">
                    <button class="btn btn-primary" onclick="changePassword()">🔐 Passwort ändern</button>
                </div>
            </div>
            
            <div class="card">
                <h2>⚠️ Gefahrenzone</h2>
                <div class="alert alert-error">
                    <span>⚠️</span>
                    <div>
                        <strong>Achtung:</strong> Diese Aktionen können nicht rückgängig gemacht werden!
                    </div>
                </div>
                
                <div class="btn-group">
                    <button class="btn btn-danger" onclick="deleteAccount()">🗑️ Account löschen</button>
                </div>
            </div>
        </div>
    </div>
    
    <script>
        let userEmail = '';
        
        // Helper function to get auth token from localStorage or cookies
        function getAuthToken() {
            // First, try localStorage
            let token = localStorage.getItem('auth_token');
            if (token) {
                console.log('Token found in localStorage');
                return token;
            }
            
            // Fallback: try to get from cookies
            const cookies = document.cookie.split(';');
            for (let cookie of cookies) {
                const [name, value] = cookie.trim().split('=');
                if (name === 'auth_token' && value) {
                    console.log('Token found in cookies, saving to localStorage');
                    localStorage.setItem('auth_token', value);
                    return value;
                }
            }
            
            console.warn('No auth token found in localStorage or cookies');
            return null;
        }
        
        // Tab switching
        function switchTab(tabName) {
            // Hide all tabs
            document.querySelectorAll('.tab-content').forEach(tab => {
                tab.classList.remove('active');
            });
            
            // Remove active class from all buttons
            document.querySelectorAll('.tab-btn').forEach(btn => {
                btn.classList.remove('active');
            });
            
            // Show selected tab
            document.getElementById(tabName + '-tab').classList.add('active');
            
            // Add active class to clicked button
            event.target.classList.add('active');
            
            // Load data for specific tabs
            if (tabName === 'stats') {
                loadStats();
            }
        }
        
        // Toggle Discord settings visibility
        function toggleDiscordSettings() {
            const enabled = document.getElementById('discord-enabled').checked;
            document.getElementById('discord-settings').style.display = enabled ? 'block' : 'none';
            document.getElementById('bot-status-card').style.display = enabled ? 'block' : 'none';
        }
        
        // Load user data
        async function loadUserData() {
            try {
                const token = localStorage.getItem('auth_token');
                const response = await fetch('/api/auth/user', {
                    headers: {
                        'Authorization': `Bearer ${token}`
                    }
                });
                
                if (response.ok) {
                    const data = await response.json();
                    const user = data.user;
                    userEmail = user.email;
                    
                    // Fill profile
                    document.getElementById('email').value = user.email;
                    document.getElementById('username').value = user.username || '';
                    document.getElementById('member-since').value = new Date(user.created_at * 1000).toLocaleDateString('de-DE');
                    
                    // Fill preferences
                    document.getElementById('theme').value = user.theme || 'dark';
                    document.getElementById('language').value = user.language || 'de';
                    document.getElementById('notifications').checked = user.notifications !== false;
                    
                    // Fill Discord settings
                    document.getElementById('discord-enabled').checked = user.discord_bot_enabled || false;
                    document.getElementById('discord-prefix').value = user.discord_bot_prefix || '!';
                    document.getElementById('discord-status').value = user.discord_bot_status || 'online';
                    toggleDiscordSettings();
                }
            } catch (error) {
                console.error('Error loading user data:', error);
            }
        }
        
        // Load stats
        async function loadStats() {
            try {
                const token = localStorage.getItem('auth_token');
                const response = await fetch('/api/auth/stats', {
                    headers: {
                        'Authorization': `Bearer ${token}`
                    }
                });
                
                if (response.ok) {
                    const stats = await response.json();
                    
                    document.getElementById('account-age').textContent = stats.account_age_days || 0;
                    document.getElementById('active-sessions').textContent = stats.active_sessions || 0;
                    
                    if (stats.last_login) {
                        const date = new Date(stats.last_login * 1000);
                        document.getElementById('last-login').textContent = date.toLocaleString('de-DE');
                    }
                }
            } catch (error) {
                console.error('Error loading stats:', error);
            }
        }
        
        // Save profile with better error handling
        async function saveProfile() {
            try {
                const token = getAuthToken();
                if (!token) {
                    alert('Nicht authentifiziert! Bitte neu anmelden.');
                    return;
                }
                
                const username = document.getElementById('username').value;
                if (!username || username.trim().length === 0) {
                    alert('Benutzername erforderlich!');
                    return;
                }
                
                const settings = { username };
                
                const response = await fetch('/api/auth/update-settings', {
                    method: 'POST',
                    headers: {
                        'Content-Type': 'application/json',
                        'Authorization': `Bearer ${token}`
                    },
                    body: JSON.stringify(settings)
                });
                
                const data = await response.json();
                
                if (response.ok && data.success) {
                    alert('Profil erfolgreich gespeichert!');
                    console.log('Profile saved:', data);
                } else {
                    alert(`Fehler: ${data.message || 'Speichern fehlgeschlagen'}`);
                    console.error('Save error:', data);
                }
            } catch (error) {
                console.error('Error saving profile:', error);
                alert(`Fehler beim Speichern: ${error.message}`);
            }
        }
        
        // Save Discord bot settings
        async function saveDiscordBot() {
            try {
                const token = getAuthToken();
                if (!token) {
                    alert('Nicht authentifiziert! Bitte neu anmelden.');
                    return;
                }
                
                const enabled = document.getElementById('discord-enabled').checked;
                const settings = { discord_bot_enabled: enabled };
                
                if (enabled) {
                    const tokenValue = document.getElementById('discord-token').value;
                    if (!tokenValue || tokenValue.trim().length === 0) {
                        alert('Discord Token erforderlich!');
                        return;
                    }
                    settings.discord_bot_token = tokenValue;
                }
                
                settings.discord_bot_prefix = document.getElementById('discord-prefix').value || '!';
                settings.discord_bot_status = document.getElementById('discord-status').value || 'online';
                
                const response = await fetch('/api/auth/update-settings', {
                    method: 'POST',
                    headers: {
                        'Content-Type': 'application/json',
                        'Authorization': `Bearer ${token}`
                    },
                    body: JSON.stringify(settings)
                });
                
                const data = await response.json();
                
                if (response.ok && data.success) {
                    alert(`Discord Bot ${enabled ? 'aktiviert' : 'deaktiviert'}!`);
                    console.log('Discord settings saved:', data);
                } else {
                    alert(`Fehler: ${data.message || 'Speichern fehlgeschlagen'}`);
                    console.error('Save error:', data);
                }
            } catch (error) {
                console.error('Error saving Discord bot:', error);
                alert('❌ Fehler beim Speichern');
            }
        }
        
        // Test Discord bot
        async function testDiscordBot() {
            alert('🧪 Bot Test-Funktion wird implementiert...');
        }
        
        // Save preferences with new specialized endpoints
        async function savePreferences() {
            try {
                const token = getAuthToken();
                if (!token) {
                    alert('❌ Nicht authentifiziert! Bitte neu anmelden.');
                    return;
                }
                
                const theme = document.getElementById('theme').value;
                const language = document.getElementById('language').value;
                const notifications = document.getElementById('notifications').checked;
                
                let successCount = 0;
                let hasError = false;
                
                // Apply theme
                if (theme) {
                    try {
                        const themeResponse = await fetch('/api/settings/apply-theme', {
                            method: 'POST',
                            headers: {
                                'Content-Type': 'application/json',
                                'Authorization': `Bearer ${token}`
                            },
                            body: JSON.stringify({ theme: theme })
                        });
                        
                        if (themeResponse.ok) {
                            successCount++;
                            console.log('✅ Theme applied:', theme);
                        }
                    } catch (e) {
                        console.error('Theme error:', e);
                        hasError = true;
                    }
                }
                
                // Apply language
                if (language) {
                    try {
                        const langResponse = await fetch('/api/settings/apply-language', {
                            method: 'POST',
                            headers: {
                                'Content-Type': 'application/json',
                                'Authorization': `Bearer ${token}`
                            },
                            body: JSON.stringify({ language: language })
                        });
                        
                        if (langResponse.ok) {
                            successCount++;
                            console.log('✅ Language applied:', language);
                        }
                    } catch (e) {
                        console.error('Language error:', e);
                        hasError = true;
                    }
                }
                
                // Save general settings
                const settings = {
                    theme: theme,
                    language: language,
                    notifications: notifications
                };
                
                const response = await fetch('/api/auth/update-settings', {
                    method: 'POST',
                    headers: {
                        'Content-Type': 'application/json',
                        'Authorization': `Bearer ${token}`
                    },
                    body: JSON.stringify(settings)
                });
                
                const data = await response.json();
                
                if (response.ok && data.success) {
                    successCount++;
                    if (hasError) {
                        alert('⚠️ Einige Einstellungen gespeichert, andere fehlgeschlagen');
                    } else {
                        alert('✅ Alle Einstellungen gespeichert!');
                    }
                    console.log('Preferences saved:', data);
                } else {
                    alert(`Fehler: ${data.message || 'Speichern fehlgeschlagen'}`);
                    console.error('Save error:', data);
                }
            } catch (error) {
                console.error('Error saving preferences:', error);
                alert('❌ Fehler beim Speichern');
            }
        }
        
        // Change password
        async function changePassword() {
            const current = document.getElementById('current-password').value;
            const newPass = document.getElementById('new-password').value;
            const confirm = document.getElementById('confirm-password').value;
            
            if (!current || !newPass || !confirm) {
                alert('❌ Bitte alle Felder ausfüllen');
                return;
            }
            
            if (newPass !== confirm) {
                alert('❌ Passwörter stimmen nicht überein');
                return;
            }
            
            if (newPass.length < 6) {
                alert('❌ Passwort muss mindestens 6 Zeichen haben');
                return;
            }
            
            try {
                const token = getAuthToken();
                if (!token) {
                    alert('❌ Nicht authentifiziert! Bitte neu anmelden.');
                    return;
                }
                
                const response = await fetch('/api/auth/change-password', {
                    method: 'POST',
                    headers: {
                        'Content-Type': 'application/json',
                        'Authorization': `Bearer ${token}`
                    },
                    body: JSON.stringify({
                        current_password: current,
                        new_password: newPass
                    })
                });
                
                const data = await response.json();
                
                if (response.ok && data.success) {
                    alert('✅ Passwort erfolgreich geändert!');
                    document.getElementById('current-password').value = '';
                    document.getElementById('new-password').value = '';
                    document.getElementById('confirm-password').value = '';
                    console.log('Password changed successfully');
                } else {
                    alert(`Fehler: ${data.message || 'Passwort-Änderung fehlgeschlagen'}`);
                    console.error('Password change error:', data);
                }
            } catch (error) {
                console.error('Error changing password:', error);
                alert(`Fehler beim Ändern des Passworts: ${error.message}`);
            }
        }
        
        // Delete account
        async function deleteAccount() {
            if (!confirm('⚠️ Bist du sicher? Diese Aktion kann nicht rückgängig gemacht werden!')) {
                return;
            }
            
            if (!confirm('⚠️ Wirklich ALLE Daten löschen? Letzte Warnung!')) {
                return;
            }
            
            try {
                const token = localStorage.getItem('auth_token');
                const response = await fetch('/api/auth/delete-account', {
                    method: 'POST',
                    headers: {
                        'Authorization': `Bearer ${token}`
                    }
                });
                
                if (response.ok) {
                    alert('✅ Account gelöscht');
                    localStorage.removeItem('auth_token');
                    location.href = '/login';
                } else {
                    alert('❌ Fehler beim Löschen');
                }
            } catch (error) {
                console.error('Error deleting account:', error);
                alert('❌ Fehler beim Löschen');
            }
        }
        
        // Reset settings to defaults
        async function resetSettings() {
            if (!confirm('⚠️ Alle Einstellungen auf Standard zurücksetzen?')) {
                return;
            }
            
            try {
                const token = getAuthToken();
                if (!token) {
                    alert('❌ Nicht authentifiziert!');
                    return;
                }
                
                const response = await fetch('/api/settings/reset', {
                    method: 'POST',
                    headers: {
                        'Authorization': `Bearer ${token}`
                    }
                });
                
                const data = await response.json();
                
                if (response.ok && data.success) {
                    alert('✅ Einstellungen zurückgesetzt!');
                    loadSettings();
                    location.reload();
                } else {
                    alert(`Fehler: ${data.message || 'Zurücksetzen fehlgeschlagen'}`);
                }
            } catch (error) {
                console.error('Error resetting settings:', error);
                alert('❌ Fehler beim Zurücksetzen');
            }
        }
        
        // Export settings
        async function exportSettings() {
            try {
                const token = getAuthToken();
                if (!token) {
                    alert('❌ Nicht authentifiziert!');
                    return;
                }
                
                const response = await fetch('/api/settings/export', {
                    headers: {
                        'Authorization': `Bearer ${token}`
                    }
                });
                
                const data = await response.json();
                
                if (response.ok && data.success) {
                    // Trigger download
                    const json = JSON.stringify(data, null, 2);
                    const blob = new Blob([json], { type: 'application/json' });
                    const url = URL.createObjectURL(blob);
                    const a = document.createElement('a');
                    a.href = url;
                    a.download = `noahski-settings-${new Date().toISOString().split('T')[0]}.json`;
                    a.click();
                    URL.revokeObjectURL(url);
                    alert('✅ Einstellungen exportiert!');
                } else {
                    alert(`Fehler: ${data.message || 'Export fehlgeschlagen'}`);
                }
            } catch (error) {
                console.error('Error exporting settings:', error);
                alert('❌ Fehler beim Exportieren');
            }
        }
        
        // Load saved settings
        async function loadSettings() {
            try {
                const token = localStorage.getItem('auth_token');
                const response = await fetch('/api/auth/get-settings', {
                    headers: {
                        'Authorization': `Bearer ${token}`
                    }
                });
                
                if (response.ok) {
                    const data = await response.json();
                    const settings = data.settings || {};
                    
                    // Apply settings to form fields - handle nested objects
                    if (settings.theme) document.getElementById('theme').value = settings.theme;
                    if (settings.language) document.getElementById('language').value = settings.language;
                    if (settings.notifications_enabled !== undefined) document.getElementById('notifications').checked = settings.notifications_enabled;
                    
                    // Discord bot settings
                    if (settings.discord_bot) {
                        document.getElementById('discord-enabled').checked = settings.discord_bot.enabled || false;
                        if (settings.discord_bot.prefix) document.getElementById('discord-prefix').value = settings.discord_bot.prefix;
                        if (settings.discord_bot.status) document.getElementById('discord-status').value = settings.discord_bot.status;
                    }
                    
                    toggleDiscordSettings();
                    console.log('✅ Settings loaded successfully');
                } else {
                    console.warn('Could not load settings');
                }
            } catch (error) {
                console.error('Error loading settings:', error);
            }
        }
        
        // Initialize
        window.onload = () => {
            // Ensure token is available in localStorage (fallback from cookies)
            const token = getAuthToken();
            if (!token) {
                console.warn('No auth token found - user may need to login again');
            }
            
            loadUserData();
            loadStats();
            loadSettings();
        };
    </script>
</body>
</html>