File size: 43,439 Bytes
1c2c88f
7ad39ae
1c2c88f
02e7723
 
 
 
 
 
 
 
 
 
 
 
1c2c88f
cca696c
7ad39ae
7ae757f
 
 
 
 
 
 
 
 
 
5e75417
7ae757f
 
 
 
 
 
76e1d60
7ae757f
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
ceb3a0d
 
 
 
 
 
 
7ae757f
 
ceb3a0d
7ae757f
ceb3a0d
7ae757f
ceb3a0d
 
 
7ae757f
ceb3a0d
 
7ae757f
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
f2a6b56
 
7ae757f
f2a6b56
7ae757f
 
 
f2a6b56
 
 
 
 
5f7f8fa
f2a6b56
5f7f8fa
 
 
f2a6b56
 
 
 
 
 
 
 
 
 
 
 
 
7ae757f
f2a6b56
7ae757f
f2a6b56
 
 
 
 
 
 
 
7ae757f
 
 
f2a6b56
 
7ae757f
 
f2a6b56
7ae757f
f2a6b56
 
 
 
 
 
 
 
 
 
 
 
 
5e75417
f2a6b56
5e75417
7ae757f
ceb3a0d
 
 
 
 
 
 
 
 
 
 
 
7ae757f
 
ceb3a0d
 
 
 
 
 
 
7ae757f
ceb3a0d
7ae757f
 
ceb3a0d
7ae757f
ceb3a0d
7ae757f
 
ceb3a0d
7ae757f
ceb3a0d
 
 
 
 
7ae757f
 
ceb3a0d
 
 
 
 
7ae757f
 
ceb3a0d
 
 
 
 
 
7ae757f
 
 
 
 
 
 
 
 
 
 
 
 
4126998
 
 
 
99167da
4126998
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
7ae757f
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
5e75417
99167da
 
 
 
818712a
 
 
99167da
 
 
 
 
 
818712a
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
99167da
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
5e75417
99167da
 
 
 
 
 
7ae757f
99167da
1c2c88f
 
99167da
 
 
eb03aa5
99167da
eb03aa5
99167da
eb03aa5
 
 
 
99167da
eb03aa5
99167da
 
eb03aa5
 
 
 
 
 
 
 
 
 
 
818712a
eb03aa5
 
 
99167da
c33a23c
 
1ceaf1e
c33a23c
 
eb03aa5
99167da
eb03aa5
 
818712a
 
 
 
 
 
eb03aa5
 
 
83efd60
eb03aa5
83efd60
 
 
 
09033dc
83efd60
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
eb03aa5
83efd60
 
 
99167da
 
 
cca696c
99167da
5e75417
de15e15
 
bc067e8
 
 
 
 
b95ed82
bc067e8
 
b95ed82
bc067e8
 
 
b95ed82
bc067e8
 
5e75417
de15e15
 
 
cca696c
7ad39ae
ce4dbe0
cca696c
 
ceb3a0d
3dbe2ce
b95ed82
 
ceb3a0d
cfe47de
b95ed82
cca696c
 
 
 
ceb3a0d
 
1c2c88f
cca696c
1c2c88f
de15e15
7ae757f
 
5f7f8fa
356c68b
5f7f8fa
5f06512
5f7f8fa
 
 
7ae757f
 
 
7ad39ae
5e75417
1c2c88f
 
7ae757f
76e1d60
7ae757f
ce4dbe0
1c2c88f
 
 
ce4dbe0
 
1c2c88f
 
cca696c
4126998
 
 
 
 
 
 
 
 
 
 
ceb3a0d
4126998
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
5e75417
1c2c88f
4126998
99167da
7ae757f
 
 
 
 
bc067e8
7ae757f
 
 
 
bc067e8
7ae757f
 
 
 
 
 
bc067e8
7ae757f
 
 
 
 
 
 
 
 
 
 
92064ea
7ae757f
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
92064ea
7ae757f
 
 
 
 
 
 
5e75417
de15e15
7ae757f
 
bc067e8
 
7ae757f
 
 
 
 
 
 
 
 
 
 
 
 
 
 
7ba7eec
bc067e8
7ae757f
 
 
 
 
 
 
 
 
 
 
 
 
 
 
bc067e8
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
2362097
 
bc067e8
 
 
 
 
 
 
7ae757f
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
9637d14
7ae757f
 
 
 
 
 
 
 
 
 
 
 
 
e72559f
7ae757f
 
 
 
 
 
 
 
 
 
 
 
 
 
 
bc067e8
e53b294
7ae757f
7ba7eec
92064ea
99167da
7ae757f
99167da
 
 
7ae757f
027d6f0
eb03aa5
 
 
 
 
 
 
 
 
 
 
99167da
eb03aa5
3f74153
 
 
 
99167da
 
 
 
 
 
 
3f74153
99167da
 
 
 
3f74153
 
99167da
3f74153
99167da
3f74153
 
 
eb03aa5
99167da
eb03aa5
 
 
 
 
 
3f74153
eb03aa5
 
 
99167da
 
 
 
 
 
3f74153
99167da
 
 
 
b966f3d
3f74153
eb03aa5
 
 
 
 
99167da
 
3f74153
f34d094
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
3f74153
f34d094
 
 
eb03aa5
f34d094
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
99167da
f34d094
 
99167da
3f74153
99167da
 
eb03aa5
3f74153
99167da
eb03aa5
1c2c88f
7ae757f
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
<!DOCTYPE html>
<html lang="en">
<head>
  <!-- Google tag (gtag.js) -->
<script async src="https://www.googletagmanager.com/gtag/js?id=G-Z920J6JQHG"></script>
<script>
  window.dataLayer = window.dataLayer || [];
  function gtag(){dataLayer.push(arguments);}
  gtag('js', new Date());

gtag('config', 'G-Z920J6JQHG', {
  'page_location': window.location.href, // 确保记录的是 Space 的实际路径
  'cookie_flags': 'SameSite=None;Secure' // 提升在 iframe 环境下的稳定性
});
</script>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Forlinx Embedded | Resource Center</title>
    <link rel="icon" href="https://forlinx.net/file.php?f=201910/f_c9298f2d11936a72389c41d07739bad1.ico" type="image/x-icon" />
 <style>
    :root { 
        --forlinx-blue: #004a96; 
        --nav-bg: #ffffff;
        --text-dark: #333333;
        --hover-blue: #003366; 
        --hint-bg: #f0f7ff; /* 科技蓝背景 */
        --hint-border: #cce5ff;
    }
    
    body { 
        font-family: "Segoe UI", Arial, sans-serif; 
        margin: 0; 
        background-color: #f5f7fa; 
        color: var(--text-dark); 
        -webkit-font-smoothing: antialiased; 
    }
    
    /* Navigation Bar */
    .top-nav {
        background-color: var(--nav-bg);
        height: 80px;
        display: flex;
        align-items: center;
        justify-content: space-between;
        padding: 0 50px;
        box-shadow: 0 2px 10px rgba(0,0,0,0.05);
        position: sticky;
        top: 0;
        z-index: 1000;
    }
    .nav-logo { display: flex; align-items: center; text-decoration: none; color: var(--forlinx-blue); font-weight: bold; font-size: 22px; }
    .nav-logo img { height: 50px; margin-right: 15px; }
    
    .nav-links { list-style: none; display: flex; margin: 0; padding: 0; }
    .nav-links li { margin-left: 25px; }
    .nav-links a { text-decoration: none; color: #666; font-size: 14px; font-weight: 500; transition: 0.3s; }
    .nav-links a:hover { color: var(--forlinx-blue); }

    /* Banner */
.hero-banner { 
        background: linear-gradient(135deg, var(--forlinx-blue) 0%, #001a36 100%); 
        color: white; 
        padding: 50px 50px 70px; /* 加深底部空间 */
    }
    .hero-banner h2 { margin: 0; font-size: 28px; letter-spacing: 1px; font-weight: 700; }
    .hero-banner p { margin: 10px 0 0; opacity: 0.85; font-size: 15px; }

    /* Main Container */
.container { 
        max-width: 1100px; 
        margin: -40px auto 40px; /* 向上偏移更多,悬浮在Banner上 */
        background: white; 
        padding: 35px 40px; 
        border-radius: 12px; /* 圆角加大 */
        box-shadow: 0 10px 30px rgba(0, 74, 150, 0.08), 0 1px 3px rgba(0,0,0,0.05); /* 阴影改为带一点品牌蓝的透明色 */
        min-height: 400px; 
        box-sizing: border-box;
        position: relative;
    }
    
    /* --- Search Bar --- */
    .search-container { margin-bottom: 20px; }
    .search-input { 
        width: 100%; 
        padding: 12px 15px; 
        border: 1px solid #ddd; 
        border-radius: 6px; 
        font-size: 14px; 
        box-sizing: border-box; 
        outline: none; 
        transition: 0.3s; 
        background: #fff url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="%23aaa" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><circle cx="11" cy="11" r="8"/><line x1="21" y1="21" x2="16.65" y2="16.65"/></svg>') no-repeat 15px center;
        padding-left: 45px;
    }
    .search-input:focus { border-color: var(--forlinx-blue); box-shadow: 0 0 0 3px rgba(0,74,150,0.1); }

    /* --- Download Hint (美化版) --- */
    .download-hint {
        background-color: var(--hint-bg);
        border: 1px solid var(--hint-border);
        padding: 14px 22px; /* 稍微增加内边距,更有呼吸感 */
        border-radius: 10px; /* 边角更圆润 */
        margin-bottom: 25px;
        margin-top: 15px; /* 弥补搜索框注销后的空间 */
        display: flex;
        align-items: center;
        justify-content: space-between;
        box-shadow: 0 4px 12px rgba(0,74,150,0.05); /* 加深阴影,增加悬浮质感 */
    }

    .hint-text { 
        color: #003366; /* 加深蓝色,解决字体发虚、对比度低的问题 */
        line-height: 1.6; 
        display: flex;
        flex-direction: column; /* 强制子元素垂直堆叠 */
        align-items: flex-start;
       
        /* 核心字体优化 */
        font-size: 14px; /* 略微加大字号 */
        font-weight: 500; /* 关键:中等字重,让字体看起来更扎实、更有高级感 */
        letter-spacing: 0.3px; /* 增加字间距,看起来更专业 */
    }

    /* 优化代码标签 <code> 的外观 */
    .hint-text code {
        background: rgba(0, 74, 150, 0.08);
        padding: 2px 6px;
        border-radius: 4px;
        font-family: "Consolas", "Monaco", monospace;
        font-weight: 600;
        color: var(--forlinx-blue);
        margin: 0 4px;
    }

    .hint-text b { 
        color: #1a1a1a; /* 标题文字加深到近乎黑色 */
        font-weight: 700; /* 加粗强调 */
        margin-right: 4px;
    }

    /* 按钮美化:从普通外框变为精致的操作按钮 */
    .btn-tutorial { 
        color: var(--forlinx-blue); 
        text-decoration: none; 
        font-weight: 700; 
        font-size: 12px;
        cursor: pointer; 
        white-space: nowrap;
        margin-left: 20px;
        background: #ffffff;
        padding: 8px 18px;
        border: 1.5px solid var(--forlinx-blue);
        border-radius: 6px;
        transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
        text-transform: uppercase; /* 大写化更显高端 */
        letter-spacing: 0.5px;
    }

    .btn-tutorial:hover { 
        background: var(--forlinx-blue); 
        color: #ffffff !important;
        transform: translateY(-1px); /* 增加微妙的悬浮交互 */
        box-shadow: 0 4px 8px rgba(0,74,150,0.15);
    }
   

    /* Breadcrumb */
.breadcrumb { 
        margin-bottom: 25px; 
        font-size: 14px; 
        color: #64748b; 
        padding: 12px 18px; 
        background: #f8fafc; 
        border-radius: 8px; 
        border: 1px solid #e2e8f0;
        border-left: 4px solid var(--forlinx-blue); 
    }
    .breadcrumb a { color: #334155; text-decoration: none; cursor: pointer; font-weight: 600; transition: 0.2s; }
    .breadcrumb a:hover { color: var(--forlinx-blue); }
    
    /* Table & Files */
    table { width: 100%; border-collapse: separate; border-spacing: 0; table-layout: fixed; }
    th { text-align: left; background: #f8fafc; padding: 16px 15px; border-bottom: 2px solid #e2e8f0; color: #64748b; text-transform: uppercase; font-size: 12px; letter-spacing: 0.5px; font-weight: 600; }
    td { padding: 16px 15px; border-bottom: 1px solid #f1f5f9; font-size: 14px; overflow: hidden; vertical-align: middle; }
    
    /* 新增:表格行鼠标悬浮高亮 */
    tbody tr { transition: background-color 0.2s ease; }
    tbody tr:not(.parent-dir-row):not(.loading-tr):hover { background-color: #f8fafc; }
    
    .folder, .file-item { display: inline-flex; align-items: center; gap: 12px; text-decoration: none; }
    .folder { color: #f39c12; font-weight: bold; cursor: pointer; }
    .folder:hover { color: var(--forlinx-blue); }
    .file-item { color: #1e293b; font-weight: 500; }
    
    .item-icon { flex-shrink: 0; font-size: 1.4em; display: flex; align-items: center;}
    .item-name { word-break: break-all; line-height: 1.4; }

    /* 下载按钮:改为精致的幽灵按钮样式 */
    .btn-download { 
        background: #ffffff; 
        color: var(--forlinx-blue) !important; 
        border: 1.5px solid var(--forlinx-blue);
        padding: 6px 20px; 
        border-radius: 6px; 
        text-decoration: none; 
        font-size: 13px; 
        font-weight: 600; 
        display: inline-flex;
        align-items: center;
        justify-content: center;
        transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1); 
        white-space: nowrap; 
    }
    .btn-download:hover { 
        background: var(--forlinx-blue); 
        color: #ffffff !important; 
        box-shadow: 0 4px 10px rgba(0, 74, 150, 0.2); 
        transform: translateY(-1px);
    }
    
    /* Parent Directory Row */
    .parent-dir-row { background-color: #f8f9fa !important; border-bottom: 2px solid #eaedf0 !important; }
    .parent-link { color: #666 !important; font-weight: 500 !important; text-decoration: none; display: flex; align-items: center; padding: 5px 0; }
    .parent-link:hover { color: var(--forlinx-blue) !important; }
    .parent-icon { margin-right: 8px; font-size: 1.2em; }

    /* Modal Styles */
    .modal { display: none; position: fixed; z-index: 2000; left: 0; top: 0; width: 100%; height: 100%; background-color: rgba(0,0,0,0.5); }
    .modal-content { background-color: white; margin: 10% auto; padding: 30px; border-radius: 10px; width: 60%; max-width: 800px; position: relative; }
    .close-modal { position: absolute; right: 20px; top: 15px; font-size: 24px; cursor: pointer; color: #aaa; }
    pre { background: #f4f4f4; padding: 12px; border-radius: 4px; overflow-x: auto; border: 1px solid #ddd; font-size: 13px; }

.footer { 
    --f-blue: #004a96; /* 内部定义变量,防止失效 */
    background-color: #f8f9fa; 
    margin-top: 80px; 

    padding: 60px 50px 30px; 
    border-top: 1px solid #eee;
    color: #6c757d; 
}

.footer-content {
    max-width: 1100px;
    margin: 0 auto;
    display: flex;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 40px;
    text-align: left;
}

.footer-section { flex: 1; min-width: 200px; }

.footer-section h4 { 
    color: var(--f-blue); 
    font-size: 16px; 
    margin-bottom: 20px; 
    font-weight: 700;
}

.footer-section ul { list-style: none; padding: 0; margin: 0; }
.footer-section ul li { margin-bottom: 12px; font-size: 13.5px; }
.footer-section ul li a { text-decoration: none; color: #6c757d; transition: 0.3s; }
.footer-section ul li a:hover { color: var(--f-blue); }

/* 修正:图标与文字对齐 */
.contact-list li {
    display: flex;
    align-items: flex-start; /* 顶部对齐,适合多行文本 */
    gap: 10px;
}

.contact-list svg {
    flex-shrink: 0;
    margin-top: 2px; /* 微调图标高度使其与文字中心对齐 */
    color: var(--f-blue);
}

.footer-bottom {
    max-width: 1100px;
    margin: 40px auto 0;
    padding-top: 20px;
    border-top: 1px solid #e9ecef;
    text-align: center;
    font-size: 12px;
    color: #adb5bd;
}

@media (max-width: 768px) {
    .footer { padding: 40px 20px 20px; }
    .footer-content { flex-direction: column; gap: 30px; text-align: center; }
    .footer-section { min-width: 100%; }
    .contact-list li { justify-content: center; } /* 移动端居中对齐 */
}



   
    .loading-tr td { text-align: center; padding: 60px; color: #999; }
    .error-msg { color: #d9534f; font-weight: bold; }

    /* --- Mobile Optimization --- */
    @media (max-width: 768px) {
        .top-nav { padding: 0 20px; height: 60px; }
        .nav-logo { font-size: 18px; }
        .nav-logo img { height: 35px; margin-right: 8px; }
        .nav-links { display: none; } 

        .hero-banner { padding: 30px 20px; text-align: center; }
        .hero-banner h2 { font-size: 22px; }
        .container { margin: 15px; padding: 15px; border-radius: 12px; }

        /* Mobile Hint Adjustment */
        .download-hint { padding: 12px 15px; flex-direction: row; align-items: center; justify-content: space-between; }
        .btn-tutorial { margin-left: 10px; padding: 4px 10px; font-size: 12px; }

        table, thead, tbody, th, td, tr { display: block; }
        thead { display: none; } 
        tr { margin-bottom: 15px; padding-bottom: 15px; border-bottom: 1px solid #eee; }
        td { padding: 5px 0; border: none; width: 100% !important; box-sizing: border-box; }

        td:nth-child(3):before { content: "Last Modified: "; font-weight: bold; color: #888; font-size: 12px; }
        td:nth-child(2) { color: #888; font-size: 13px; margin-bottom: 5px; }
        td:nth-child(2):before { content: "Size: "; font-weight: bold; }

        .item-name { font-size: 15px; font-weight: 600; color: #333; }
        .btn-download { display: block; width: 100%; text-align: center; padding: 12px 0; font-size: 15px; box-sizing: border-box; }
        .modal-content { width: 90%; margin: 15% auto; padding: 20px; }
    }
	 

/* --- 现代化登录门禁样式 --- */
#login-gate {
    display: flex; 
	flex-direction: column; /* 💥新增这行,让内部元素上下排列 */
	justify-content: center; align-items: center; min-height: 100vh;
    /* 采用径向渐变,深邃且聚焦 */
    background: radial-gradient(circle at 50% 0%, #005bb5, #001a36 80%);
    position: fixed; top: 0; left: 0; width: 100%; z-index: 9999;
    font-family: "Segoe UI", system-ui, sans-serif;
}

/* 💥新增:底部官方信息的样式,带一点高级的半透明发光感 */
.login-footer-info {
    margin-top: 35px;
    text-align: center;
    color: rgba(255, 255, 255, 0.6); /* 半透明白色 */
    font-size: 13.5px;
    line-height: 1.8;
    animation: cardFadeUp 0.8s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}
.login-footer-info a {
    color: #ffffff;
    text-decoration: none;
    font-weight: 600;
    margin: 0 6px;
    transition: 0.2s;
}
.login-footer-info a:hover {
    color: #66b2ff; /* 鼠标悬浮时变亮蓝 */
    text-decoration: underline;
}
	 
.login-card {
    background: rgba(255, 255, 255, 0.98); /* 极微弱的透明度 */
    backdrop-filter: blur(10px); /* 隐约的毛玻璃质感 */
    padding: 45px 40px; 
    border-radius: 20px; /* 更现代的大圆角 */
    box-shadow: 0 25px 50px -12px rgba(0,0,0,0.3), 0 0 0 1px rgba(255,255,255,0.1) inset;
    width: 90%; max-width: 380px; text-align: center;
    /* 进场时的丝滑上浮动画 */
    animation: cardFadeUp 0.6s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

@keyframes cardFadeUp {
    from { opacity: 0; transform: translateY(20px); }
    to { opacity: 1; transform: translateY(0); }
}

.login-card img { height: 70px; margin-bottom: 24px; }
#auth-title { color: #0f172a; font-size: 24px; font-weight: 700; margin: 0 0 8px 0; }
#auth-desc { color: #64748b; font-size: 14.5px; margin: 0 0 32px 0; }

/* 现代感输入框:无硬边框,浅底色,发光 Focus */
.auth-input { 
    width: 100%; padding: 14px 16px; margin-bottom: 16px; 
    background: #f8fafc; border: 1px solid #e2e8f0; border-radius: 12px; 
    box-sizing: border-box; font-size: 14px; color: #334155;
    transition: all 0.2s ease;
}
.auth-input::placeholder { color: #94a3b8; }
.auth-input:focus { 
    background: #ffffff; border-color: var(--forlinx-blue); 
    box-shadow: 0 0 0 4px rgba(0, 74, 150, 0.12); outline: none; 
}

/* 渐变主按钮 + 悬浮动效 */
.btn-auth { 
    width: 100%; padding: 14px; 
    background: linear-gradient(135deg, var(--forlinx-blue) 0%, #003366 100%); 
    color: white; border: none; border-radius: 12px; 
    font-size: 15px; font-weight: 600; cursor: pointer; 
    transition: all 0.3s ease; 
    box-shadow: 0 4px 12px rgba(0, 74, 150, 0.25); 
}
.btn-auth:hover { 
    transform: translateY(-2px); 
    box-shadow: 0 6px 16px rgba(0, 74, 150, 0.4); 
}


.auth-toggle { font-size: 14px; color: #64748b; margin-top: 28px; }
.auth-toggle a { color: var(--forlinx-blue); font-weight: 600; cursor: pointer; text-decoration: none; transition: 0.2s ease; }
.auth-toggle a:hover { color: #003366; text-decoration: underline; }

/* 默认隐藏主内容 */
#main-portal { display: none; }
</style>
	
</head>
<body>
	
<div id="login-gate">
    <div class="login-card">
        <img src="https://forlinx.net/image/logo/forlinx-logo.svg" alt="Forlinx" style="height:60px; margin-bottom:20px;">
        <h2 id="auth-title">Resource Center</h2>
        <p id="auth-desc" style="color:#64748b; font-size:14px; margin-bottom:25px;">Please sign in to access resources.</p>
        
        <div id="reg-name-field" style="display: none;">
            <input type="text" id="username" class="auth-input" placeholder="Full Name / Company Name">
        </div>

        <input type="email" id="email" class="auth-input" placeholder="Business Email">
        
        <input type="password" id="password" class="auth-input" placeholder="Password">
        
        <div id="reg-confirm-field" style="display: none;">
            <input type="password" id="confirm-password" class="auth-input" placeholder="Confirm Password">
        </div>

        <div id="login-extra" style="text-align: right; margin-top: -8px; margin-bottom: 15px;">
            <a id="forgot-pwd" style="font-size: 13px; color: var(--forlinx-blue); text-decoration: none; cursor: pointer;">Forgot Password?</a>
        </div>
        
        <div id="terms-container" style="display: none; text-align: left; margin-bottom: 15px;">
            <label style="font-size: 12px; color: #64748b; cursor: pointer; display: flex; align-items: flex-start; gap: 8px;">
                <input type="checkbox" id="terms-checkbox" style="margin-top: 2px;">
                <span>I agree to the <a onclick="openAgreement()" style="color: var(--forlinx-blue); text-decoration: underline; cursor: pointer;">User Registration Agreement</a>.</span>
            </label>
        </div>

        <button class="btn-auth" id="btn-main-action">Login</button>
 <div style="margin-top: 25px; padding: 12px; background: rgba(0, 74, 150, 0.05); border: 1px solid rgba(0, 74, 150, 0.1); border-radius: 8px; font-size: 13px; color: #475569; text-align: left; line-height: 1.5;">
    <span style="display: block; font-weight: 600; color: var(--forlinx-blue); margin-bottom: 4px;">🚀 Need Immediate Access?</span>
    Skip the registration. Contact our sales team directly for priority service and professional hardware consultation. <br>
    <a href="mailto:sales@forlinx.com" style="color: var(--forlinx-blue); font-weight: 600; text-decoration: none; display: inline-block; margin-top: 6px;">✉️ Email Sales Team &rarr;</a>
</div>        
        <div class="auth-toggle" style="margin-top:20px; font-size:14px; color:#64748b;">
            <span id="toggle-text">Don't have an account?</span> 
            <a id="toggle-link" style="color:var(--forlinx-blue); font-weight:600; cursor:pointer;">Register Now</a>
        </div>
    </div> <div class="login-footer-info">
        <div>Need help? Contact Forlinx Support Team</div>
        <div style="margin-top: 5px;">
            📧 Email: <a href="mailto:support@forlinx.com">support@forlinx.com</a> | 
            🌐 Website: <a href="https://www.forlinx.net" target="_blank">www.forlinx.net</a>
        </div>
    </div>
</div>


<div id="agreementModal" class="modal" style="z-index: 99999;">
    <div class="modal-content" style="max-width: 700px;"> <span class="close-modal" onclick="closeAgreement()">&times;</span>
        <h3 style="color:var(--forlinx-blue); margin-bottom: 20px;">Terms of Use & User Agreement</h3>
        
        <div style="height: 420px; overflow-y: auto; font-size: 13.5px; line-height: 1.7; color: #444; border-top: 1px solid #eee; padding: 20px 15px 15px 0;">
           
            <p>Welcome to the <b>Forlinx Embedded Resource Center</b>. By registering an account and accessing our technical materials, you acknowledge that you have read and agreed to the following terms:</p>

            <h4 style="color:#333;">1. Authorized Use of Resources</h4>
            <p>The resources provided (including but not limited to Firmware Images, SDKs, User Manuals, Hardware Designs, and CAD Files) are intended solely for technical evaluation, product development, and support related to Forlinx Embedded platforms.</p>

            <h4 style="color:#333;">2. Intellectual Property Rights</h4>
            <p>All technical materials and software code available in this Center remain the exclusive property of <b>Forlinx Embedded Technology Co., Ltd.</b> Access does not grant ownership. Unauthorized redistribution, commercial resale, or public mirroring of these materials is strictly prohibited.</p>

            <h4 style="color:#333;">3. User Obligations & Security</h4>
            <p>You agree to provide accurate business information during registration. You are responsible for maintaining the confidentiality of your credentials. Any attempt to bypass security measures or reverse-engineer proprietary software is a violation of this agreement.</p>

            <h4 style="color:#333;">4. Confidentiality</h4>
            <p>Certain documents provided may contain proprietary information. You agree to exercise reasonable care to prevent unauthorized disclosure of confidential materials to third parties without prior written consent from Forlinx.</p>

            <h4 style="color:#333;">5. Disclaimer & Limitation of Liability</h4>
            <p>All resources are provided "AS IS" without warranties of any kind. Forlinx Embedded shall not be liable for any direct or indirect damages (including hardware damage or data loss) resulting from the use or inability to use the provided materials.</p>

            <h4 style="color:#333;">6. Termination of Access</h4>
            <p>Forlinx reserves the right to suspend or terminate your access at any time, without notice, if we suspect a breach of these terms or for system maintenance purposes.</p>

            <hr style="border: 0; border-top: 1px solid #eee; margin: 25px 0;">
            <p style="font-size: 12px; color: #999;">If you have any legal inquiries or require a formal NDA, please contact our support team at <a href="mailto:sales@forlinx.com" style="color:var(--forlinx-blue);">sales@forlinx.com</a>.</p>
        </div>

        <div style="text-align: center; margin-top: 25px;">
            <button class="btn-auth" onclick="closeAgreement()" style="width: 180px; padding: 12px;">I ACCEPT TERMS</button>
        </div>
    </div>
</div>

<div id="main-portal">
<div id="tutorialModal" class="modal">
        <div class="modal-content">
            <span class="close-modal" onclick="closeModal()">&times;</span>
            <h3>🚀 High-Speed Download Guide (Recommended)</h3>
            <p>For large files (>5GB), browser downloads may fail due to network instability. We strongly recommend using the official Hugging Face CLI for resume-capable and multi-threaded downloading:</p>
            
            <p><b>1. Install the CLI Tool (One-time setup):</b></p>
            <pre>pip install -U "huggingface_hub[cli]"</pre>
            
            <p><b>2. Enable Fast Transfer Mode:</b></p>
            <pre>pip install hf_transfer</pre>
            
            <p><b>3. Download Specific File:</b></p>
            <p>Replace <code>[FILE_NAME]</code> with the actual file name (e.g., <code>demo.zip</code>):</p>
            <pre>huggingface-cli download --repo-type dataset forlinx-embedded/forlinx-downloads [FILE_NAME] --local-dir .</pre>
            
            <div style="background: #e7f3ff; padding: 15px; border-radius: 6px; font-size: 13px; color: #004a96; border-left: 4px solid #004a96;">
                💡 <b>Pro Tip:</b> The CLI automatically performs SHA256 integrity checks. Once the download is finished, the file is 100% verified and ready to use.
            </div>
        </div>
    </div>

    <nav class="top-nav">
        <a href="https://www.forlinx.net/" class="nav-logo">
            <img src="https://forlinx.net/image/logo/forlinx-logo.svg" alt="Forlinx">
        </a>
        <ul class="nav-links">
            <li><a href="https://www.forlinx.net/" target="_blank">Why Forlinx</a></li>
            <li><a href="https://www.forlinx.net/product-index-1.html" target="_blank">Products</a></li>
            <li><a href="https://www.forlinx.net/article_new_c21.html" target="_blank">News</a></li>
            <li><a href="https://www.forlinx.net/article-technology-17-68.html" target="_blank">Services</a></li>
            <li><a href="https://docs.forlinx.net/" target="_blank">Developer Center</a></li>
            <li><a href="https://www.forlinx.net/jishu/technical-support-70.html" target="_blank">Support</a></li>
            <li><a href="https://www.forlinx.net/article-contact.html" target="_blank">Contact</a></li>
        </ul>
    </nav>

    <div class="hero-banner">
        <h2>Forlinx Resource Center</h2>
        <p>Firmware images, manuals, and developer tools for the AI Embedded Ecosystem.</p>
    </div>

    <div class="container">

<div class="download-hint">
    <div class="hint-text">
      <div style="margin-bottom: 8px;">
        <span>💡 <b>Large Files (>5GB)?</b> Use <code>huggingface-cli</code> for 3x speed and 100% integrity.</span>
	</div>
    <div>
            <span>🛠️ <b>CAD/Vector Files (DXF, SVG, STEP):</b> If code appears, please <b>Right-click</b> and select <b>"Save Link As..."</b></span>
    </div>	
   </div>
    <span class="btn-tutorial" onclick="openModal()">Guide</span>
</div>

        <div class="breadcrumb" id="breadcrumb">Location: <a onclick="loadPath('')">Root</a></div>
        <table>
            <thead>
                <tr>
                    <th width="45%">Resource Name</th>
                    <th width="15%">Size</th>
                    <th width="20%">Last Modified</th>
                    <th width="20%">Action</th>
                </tr>
            </thead>
            <tbody id="file-list">
                <tr class="loading-tr"><td colspan="4">Synchronizing data from cloud server...</td></tr>
            </tbody>
        </table>
    </div>

<footer class="footer">
    <div class="footer-content">
        <div class="footer-section">
            <h4>FORLINX EMBEDDED</h4>
            <p style="font-size: 13px; line-height: 1.6;">Focusing on ARM platform technology, providing professional embedded SOM, single board computers and industrial control solutions.</p>
        </div>

        <div class="footer-section">
            <h4>Quick Links</h4>
            <ul>
                <li><a href="https://www.forlinx.net/resources/product-catalog.html" target="_blank">Product Catalog</a></li>
                <li><a href="https://docs.forlinx.net/" target="_blank">Developer Center</a></li>
                <li><a href="https://www.forlinx.net/jishu/technical-support-70.html" target="_blank">Support Policy</a></li>
            </ul>
        </div>

        <div class="footer-section">
            <h4>Contact Support</h4>
            <ul class="contact-list">
                <li>
                    <svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M4 4h16c1.1 0 2 .9 2 2v12c0 1.1-.9 2-2 2H4c-1.1 0-2-.9-2-2V6c0-1.1.9-2 2-2z"/><polyline points="22,6 12,13 2,6"/></svg>
                    <span>Technical Support: <a href="mailto:support@forlinx.com">support@forlinx.com</a></span>
                </li>
                <li>
                    <svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M16 21v-2a4 4 0 0 0-4-4H6a4 4 0 0 0-4 4v2"/><circle cx="9" cy="7" r="4"/><path d="M22 21v-2a4 4 0 0 0-3-3.87"/><path d="M16 3.13a4 4 0 0 1 0 7.75"/></svg>
                    <span>Contact Sales: <a href="mailto:sales@forlinx.com">sales@forlinx.com</a></span>
                </li>
                <li>
                    <svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><circle cx="12" cy="12" r="10"/><polyline points="12 6 12 12 16 14"/></svg>
                    <span>Service Hours: Mon–Fri 9:00–17:00</span>
                </li>
            </ul>
        </div>
    </div>

    <div class="footer-bottom">
        &copy; 2026 Forlinx Embedded Technology Co., Ltd. All Rights Reserved.
    </div>
</footer>
</div>
    <script>
        const USER_NAME = "forlinx-embedded"; 
        const REPO_NAME = "forlinx-downloads"; 
        let currentPath = "";
        let allItems = []; 

        function getPathFromUrl() {
            const params = new URLSearchParams(window.location.search);
            return params.get('path') || ""; 
        }

        function openModal() { document.getElementById('tutorialModal').style.display = "block"; }
        function closeModal() { document.getElementById('tutorialModal').style.display = "none"; }
        window.onclick = (event) => {
            const modal = document.getElementById('tutorialModal');
            if (event.target == modal) modal.style.display = "none";
        }

        async function loadPath(path, isPopState = false) {
            currentPath = path;
            const searchInput = document.getElementById('searchInput');
            if(searchInput) searchInput.value = '';
            
            if (!isPopState) {
                const newUrl = path 
                    ? `${window.location.origin}${window.location.pathname}?path=${encodeURIComponent(path)}`
                    : `${window.location.origin}${window.location.pathname}`;
                window.history.pushState({ path: path }, '', newUrl);
            }

            const listBody = document.getElementById('file-list');
            listBody.innerHTML = '<tr class="loading-tr"><td colspan="4">Loading directory content...</td></tr>';
            
            const cleanPath = path ? `/${path}` : "";
            const apiUrl = `https://huggingface.co/api/datasets/${USER_NAME}/${REPO_NAME}/tree/main${cleanPath}?expand=true`;
            
            try {
                const response = await fetch(apiUrl + `&t=${Date.now()}`);
                if (!response.ok) throw new Error(`HTTP ${response.status}`);
                
                allItems = await response.json(); 
                renderTable(allItems); 
            } catch (e) {
                console.error("API Error:", e);
                listBody.innerHTML = `<tr><td colspan="4" style="text-align:center; padding: 50px;">
                    <span class="error-msg">Sync Failed</span><br>
                    <small style="color:#999; margin-top:10px; display:block;">Please check network connection or Dataset visibility.</small>
                </td></tr>`;
            }
            updateBreadcrumb();
        }

        function filterFiles() {
            const query = document.getElementById('searchInput').value.toLowerCase();
            const filteredItems = allItems.filter(item => {
                const fileName = item.path.split('/').pop().toLowerCase();
                return fileName.includes(query);
            });
            renderTable(filteredItems);
        }

        function renderTable(items) {
            const listBody = document.getElementById('file-list');
            listBody.innerHTML = '';

            if (currentPath !== "") {
                const parts = currentPath.split('/');
                parts.pop();
                const parent = parts.join('/');
                const row = document.createElement('tr');
                row.className = 'parent-dir-row';
                row.innerHTML = `
                    <td colspan="4">
                        <a class="parent-link" style="cursor:pointer" onclick="loadPath('${parent}')">
                            <span class="parent-icon">🔙</span> 
                            <span>.. (Parent Directory)</span>
                        </a>
                    </td>`;
                listBody.appendChild(row);
            }

            if (!items || items.length === 0) {
                listBody.innerHTML += '<tr><td colspan="4" style="text-align:center; padding: 40px; color: #999;">No matches found in this directory.</td></tr>';
                return;
            }

            items.forEach(item => {
                if (item.path.startsWith('.') || item.path.includes('/.')) return;
                
                const row = document.createElement('tr');
                const name = item.path.split('/').pop();
                const rawDate = item.lastCommit ? item.lastCommit.date : "";
                const formattedDate = rawDate ? new Date(rawDate).toISOString().split('T')[0] : "--";

                const getIcon = (fileName) => {
                    const ext = fileName.split('.').pop().toLowerCase();
                    const map = {
// --- 文档类 ---
        'pdf': '📑', 
        'doc': '📝', 
        'docx': '📝', 
        'xls': '📊', 
        'xlsx': '📊', 
        'csv': '📊',
        'txt': '📝', 
        'md': '📝',

        // --- 硬件设计类 (Altium Designer / EDA) ---
        'schdoc': '📐',   // 原理图文件
        'pcbdoc': '🎨',   // PCB设计文件
        'prjpcb': '🏗️',   // 工程项目文件
        'schlib': '📚',   // 原理图库
        'pcblib': '📦',   // PCB封装库
        'bak': '🕒',      // 备份文件
        'prjpcbstructure': '🦴', // 项目结构文件 (注意:由于文件名可能较长,建议在逻辑中先处理成全小写)
        'dxf': '📐',   // CAD 矢量图纸文件
        'dwg': '📐',

        // --- 压缩包与镜像 ---
        'zip': '📦', 
        '7z': '📦', 
        'rar': '📦', 
        'gz': '📦', 
        'tar': '📦',
        'img': '💾',      // 固件镜像
        'bin': '💾',      // 二进制文件
        'iso': '💾',
        'step': '🏗️',
        'stp': '🏗️',

        // --- AI 与 模型 (Rockchip NPU 相关) ---
        'rkllm': '🧠', 
        'onnx': '🧠', 
        'model': '🧠',
        'rknn': '🚀'   
                    };
                    return map[ext] || '📄';
                };
                
                if (item.type === 'directory') {
                    row.innerHTML = `
                        <td>
                            <a class="folder" onclick="loadPath('${item.path}')">
                                <span class="item-icon">📁</span>
                                <span class="item-name">${name}</span>
                            </a>
                        </td>
                        <td style="color:#bbb">--</td>
                        <td style="color:#888; font-size:13px;">${formattedDate}</td>
                        <td><small style="color:#999; cursor:pointer;" onclick="loadPath('${item.path}')">View Folder</small></td>
                    `;
                } else {
                    const dUrl = `https://huggingface.co/datasets/${USER_NAME}/${REPO_NAME}/resolve/main/${item.path}`;
                    const sizeFormatted = item.size > 1073741824 
                        ? (item.size / 1073741824).toFixed(2) + ' GB' 
                        : (item.size / 1048576).toFixed(2) + ' MB';
                        
                    row.innerHTML = `
                        <td>
                            <div class="file-item">
                                <span class="item-icon">${getIcon(name)}</span>
                                <span class="item-name">${name}</span>
                            </div>
                        </td>
                        <td>${sizeFormatted}</td>
                        <td style="color:#888; font-size:13px;">${formattedDate}</td>
                       <td><a href="${dUrl}" target="_blank" class="btn-download" onclick="gtag('event', 'file_download', {'file_name': '${name}'});">Download</a></td>
                    `;
                }
                listBody.appendChild(row);
            });
        }
        
        function updateBreadcrumb() {
            const bc = document.getElementById('breadcrumb');
            let html = 'Location: <a onclick="loadPath(\'\')">Root</a>';
            if (currentPath !== "") {
                const parts = currentPath.split('/');
                let temp = "";
                parts.forEach(p => {
                    temp += (temp === "" ? p : '/' + p);
                    html += ` / <a onclick="loadPath('${temp}')">${p}</a>`;
                });
            }
            bc.innerHTML = html;
        }

       // window.onload = () => loadPath(getPathFromUrl());
        window.onpopstate = (event) => loadPath(event.state ? event.state.path : getPathFromUrl(), true);
		

	
    </script>
	
<script>
    function openAgreement() {
        var modal = document.getElementById('agreementModal');
        if (modal) modal.style.display = "block";
    }
    function closeAgreement() {
        var modal = document.getElementById('agreementModal');
        if (modal) modal.style.display = "none";
    }
</script>
	
<script type="module">
    import { initializeApp } from "https://www.gstatic.com/firebasejs/10.0.0/firebase-app.js";
    import { getAuth, onAuthStateChanged, signInWithEmailAndPassword, createUserWithEmailAndPassword, sendPasswordResetEmail, updateProfile, sendEmailVerification, signOut } from "https://www.gstatic.com/firebasejs/10.0.0/firebase-auth.js";
    
    // === 新增:引入 Firestore 数据库功能 ===
    import { getFirestore, doc, setDoc } from "https://www.gstatic.com/firebasejs/10.0.0/firebase-firestore.js";

    const firebaseConfig = {
        apiKey: "AIzaSyCCSxDqAjcysldz_lG3azcMIKPQ5wt_M3w",
        authDomain: "forlinx-download-center.firebaseapp.com",
        projectId: "forlinx-download-center",
        storageBucket: "forlinx-download-center.firebasestorage.app",
        messagingSenderId: "882790748187",
        appId: "1:882790748187:web:8d09c5e2d98c545cade8be"
    };

    const app = initializeApp(firebaseConfig);
    const auth = getAuth(app);
    const db = getFirestore(app); // === 新增:初始化数据库 ===
    
    let isLoginMode = true;
    let isRegisteringFlow = false; 

    // 核心监控:验证状态改变
    onAuthStateChanged(auth, (user) => {
        if (isRegisteringFlow) return; 

        if (user) {
            if (user.emailVerified) {
                document.getElementById('login-gate').style.display = 'none';
                document.getElementById('main-portal').style.display = 'block';
                if (typeof loadPath === "function") loadPath(getPathFromUrl());
            } else {
                alert("Please check your email and click the verification link to activate your account.");
                signOut(auth);
                document.getElementById('login-gate').style.display = 'flex';
                document.getElementById('main-portal').style.display = 'none';
            }
        } else {
            document.getElementById('login-gate').style.display = 'flex';
            document.getElementById('main-portal').style.display = 'none';
        }
    });

    // 注册/登录 模式切换
    document.getElementById('toggle-link').onclick = () => {
        isLoginMode = !isLoginMode;
        document.getElementById('auth-title').innerText = isLoginMode ? "Resource Center" : "Create Account";
        document.getElementById('btn-main-action').innerText = isLoginMode ? "Login" : "Register";
        document.getElementById('toggle-link').innerText = isLoginMode ? "Register Now" : "Login Now";
        
        const regDisplay = isLoginMode ? 'none' : 'block';
        document.getElementById('reg-name-field').style.display = regDisplay;
        document.getElementById('reg-confirm-field').style.display = regDisplay;
        document.getElementById('terms-container').style.display = regDisplay;
        document.getElementById('login-extra').style.display = isLoginMode ? 'block' : 'none';
    };

    // 执行 登录/注册
  document.getElementById('btn-main-action').onclick = async () => {
    const email = document.getElementById('email').value;
    const pass = document.getElementById('password').value;

    if (isLoginMode) {
        if (!email || !pass) { alert("Please enter both email and password."); return; }
        // 登录逻辑也加上 await 和 try...catch 更稳妥
        try {
            await signInWithEmailAndPassword(auth, email, pass);
        } catch (err) {
            alert("Login failed: " + err.message);
        }
    } else {
        const name = document.getElementById('username').value;
        const confirmPass = document.getElementById('confirm-password').value;
        const isAgreed = document.getElementById('terms-checkbox').checked;

        if (!name || !email || !pass) { alert("Please fill in all required fields."); return; }
        if (pass !== confirmPass) { alert("Passwords do not match!"); return; }
        if (!isAgreed) { alert("Please read and agree to the User Agreement."); return; }

        isRegisteringFlow = true; 
        
        try {
            // 1. 创建账号
            const userCredential = await createUserWithEmailAndPassword(auth, email, pass);
            const user = userCredential.user;
            
            // 2. 更新用户名
            await updateProfile(user, { displayName: name });
            
            // 3. 写入数据库
            const leadData = {
                name: name,
                email: email,
                registerTime: new Date().toISOString() 
            };
            await setDoc(doc(db, "leads", user.uid), leadData);

            // 4. 发送验证邮件
            await sendEmailVerification(user);

            // 5. 提示用户
            alert("Registration successful! A verification email has been sent to " + email + ".\n\n⚠️ Note: If you don't see it in your inbox, please check your Spam or Junk folder.");
            
            // 6. 登出并重置 UI
            await signOut(auth);
            
            isRegisteringFlow = false; 
            isLoginMode = true;
            document.getElementById('auth-title').innerText = "Resource Center";
            document.getElementById('btn-main-action').innerText = "Login";
            document.getElementById('toggle-link').innerText = "Register Now";
            document.getElementById('reg-name-field').style.display = 'none';
            document.getElementById('reg-confirm-field').style.display = 'none';
            document.getElementById('terms-container').style.display = 'none';
            document.getElementById('login-extra').style.display = 'block';
            document.getElementById('password').value = ""; 

        } catch (err) {
            // 只要上面的任何一步(包括写数据库、发邮件)出错,都会立刻走到这里并弹出详细错误原因!
            isRegisteringFlow = false; 
            console.error("Registration Error Details:", err); // 在 F12 控制台打印详细日志
            alert("Registration Error:\n" + err.code + "\n" + err.message);
        }
    }
};

    // 忘记密码重置逻辑
    document.getElementById('forgot-pwd').onclick = () => {
        const email = document.getElementById('email').value;
        if (!email) { alert("Please enter your email address first."); return; }
        sendPasswordResetEmail(auth, email).then(() => alert("Password reset email sent!")).catch((error) => alert("Error: " + error.message));
    };
</script>
</body>
</html>