File size: 44,184 Bytes
bc63cac
5ee09ce
bc63cac
5ee09ce
 
 
e42e61f
5ee09ce
 
e42e61f
5ee09ce
 
 
 
 
 
 
 
 
 
e42e61f
5ee09ce
 
 
deb85aa
 
5ee09ce
e42e61f
5ee09ce
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
deb85aa
5ee09ce
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
e42e61f
5ee09ce
 
 
 
 
 
 
 
 
 
 
deb85aa
5ee09ce
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
e42e61f
71188a8
deb85aa
71188a8
 
 
deb85aa
71188a8
e42e61f
5ee09ce
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
e42e61f
5ee09ce
 
 
deb85aa
5ee09ce
 
 
bc63cac
 
e42e61f
5ee09ce
 
 
 
 
 
 
 
 
 
 
 
 
 
 
deb85aa
5ee09ce
 
deb85aa
 
5ee09ce
 
deb85aa
 
5ee09ce
 
deb85aa
 
5ee09ce
 
deb85aa
 
5ee09ce
 
deb85aa
 
5ee09ce
 
deb85aa
 
5ee09ce
 
deb85aa
4e171a7
5ee09ce
e42e61f
deb85aa
5ee09ce
 
 
 
 
 
 
 
e42e61f
5ee09ce
bc63cac
 
5ee09ce
 
 
 
4e171a7
5ee09ce
 
 
 
e42e61f
 
 
5ee09ce
 
 
4e171a7
5ee09ce
 
 
 
e42e61f
 
 
71188a8
5ee09ce
 
4e171a7
5ee09ce
 
 
 
e42e61f
 
 
5ee09ce
 
 
4e171a7
e42e61f
 
 
 
 
 
 
 
5c477bd
e42e61f
4e171a7
e42e61f
 
 
 
 
 
 
 
5c477bd
e42e61f
4e171a7
e42e61f
 
 
 
 
 
 
 
5c477bd
 
 
5ee09ce
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
71188a8
 
e42e61f
71188a8
0e4c5ec
 
 
 
 
 
 
 
 
 
 
 
 
5ee09ce
0e4c5ec
 
 
5ee09ce
 
e42e61f
 
 
5ee09ce
4e171a7
e42e61f
 
5ee09ce
 
 
e42e61f
 
 
5ee09ce
e42e61f
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
5ee09ce
e42e61f
 
 
 
 
 
 
 
 
 
 
5ee09ce
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
bc63cac
5ee09ce
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
bc63cac
5ee09ce
 
 
 
 
 
 
 
 
 
 
 
0e4c5ec
e42e61f
0e4c5ec
 
 
5ee09ce
 
4e171a7
5ee09ce
 
4e171a7
5ee09ce
 
 
 
 
 
 
71188a8
5ee09ce
deb85aa
5ee09ce
 
 
 
 
 
 
 
 
e42e61f
5ee09ce
 
 
 
deb85aa
 
e42e61f
deb85aa
 
 
 
5ee09ce
 
 
 
 
 
 
 
 
 
e42e61f
5ee09ce
 
 
 
 
 
 
 
 
 
e42e61f
 
 
5ee09ce
 
 
 
e42e61f
 
5ee09ce
 
 
 
 
 
31dd1d0
5ee09ce
 
e42e61f
31dd1d0
 
4e171a7
 
31dd1d0
 
 
 
 
 
 
4e171a7
12bc17e
 
4e171a7
12bc17e
31dd1d0
 
 
 
 
 
 
4e171a7
 
31dd1d0
 
 
 
 
 
 
 
 
4e171a7
31dd1d0
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
4e171a7
31dd1d0
 
 
 
 
 
 
 
 
 
 
 
 
 
 
5ee09ce
 
 
 
e42e61f
5ee09ce
 
 
 
 
e42e61f
5ee09ce
 
 
 
e42e61f
5ee09ce
 
 
 
 
 
 
 
 
 
 
e42e61f
5ee09ce
 
 
e42e61f
5ee09ce
 
 
 
 
e42e61f
5ee09ce
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
e42e61f
5ee09ce
 
 
e42e61f
 
5ee09ce
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
e42e61f
 
5ee09ce
 
e42e61f
 
5ee09ce
 
 
 
 
 
 
 
e42e61f
 
5ee09ce
 
 
 
 
 
 
 
e42e61f
5ee09ce
e42e61f
5ee09ce
e42e61f
 
 
 
 
 
 
5ee09ce
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
e42e61f
 
5ee09ce
 
e42e61f
 
 
 
 
 
 
5ee09ce
e42e61f
 
5ee09ce
 
e42e61f
5ee09ce
 
e42e61f
 
5ee09ce
 
e42e61f
 
5ee09ce
 
 
 
 
 
 
 
e42e61f
5ee09ce
e42e61f
5ee09ce
 
 
 
e42e61f
5ee09ce
 
 
 
 
 
 
 
e42e61f
5ee09ce
 
 
 
e42e61f
5ee09ce
 
 
 
 
 
 
 
e42e61f
0e4c5ec
 
 
 
 
 
 
 
 
e42e61f
0e4c5ec
 
 
 
 
e42e61f
 
0e4c5ec
 
e42e61f
0e4c5ec
5ee09ce
 
0e4c5ec
 
e42e61f
0e4c5ec
 
 
 
 
 
 
e42e61f
 
 
0e4c5ec
 
 
 
5ee09ce
 
 
 
 
 
 
bc63cac
5ee09ce
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
<!DOCTYPE html>
<html dir="rtl" lang="ar">
<head>
  <meta charset="UTF-8" />
  <meta name="viewport" content="width=device-width, initial-scale=1.0" />
  <title>المنصة القانونية الذكية - وإنشاء العقود</title>
  <!-- ربط مكتبات Tailwind وFont Awesome -->
  <link href="https://cdnjs.cloudflare.com/ajax/libs/tailwindcss/2.2.19/tailwind.min.css" rel="stylesheet" />
  <link href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.0.0/css/all.min.css" rel="stylesheet" />
  <!-- ربط مكتبة jsPDF لتحويل النص إلى PDF -->
  <script src="https://cdnjs.cloudflare.com/ajax/libs/jspdf/2.5.1/jspdf.umd.min.js"></script>
  <style>
    @import url("https://fonts.googleapis.com/css2?family=Tajawal:wght@400;500;700&display=swap");

    :root {
      --primary-color: #2563eb;
      --primary-hover: #1d4ed8;
      --background-light: #f8fafc;
      --card-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
    }

    body {
      font-family: "Tajawal", sans-serif;
      background: var(--background-light);
      margin: 0;
      padding-bottom: 60px; /* مساحة للتذييل */
    }

    /* الشريط الجانبي */
    .sidebar {
      background: white;
      width: 280px;
      position: fixed;
      right: 0;
      top: 0;
      height: 100vh;
      z-index: 40;
      transition: transform 0.3s ease;
      box-shadow: var(--card-shadow);
    }
    .main-content {
      margin-right: 280px;
      transition: margin 0.3s ease;
      min-height: 100vh;
      padding: 2rem;
      background: var(--background-light);
    }
    .nav-link {
      display: flex;
      align-items: center;
      padding: 1rem 1.5rem;
      color: #374151;
      transition: all 0.3s ease;
      border-radius: 0.5rem;
      margin: 0.25rem 0.5rem;
      cursor: pointer;
    }
    .nav-link:hover {
      background: #f3f4f6;
      color: var(--primary-color);
    }
    .nav-link.active {
      background: var(--primary-color);
      color: white;
    }
    .feature-card {
      background: white;
      border-radius: 1rem;
      box-shadow: var(--card-shadow);
      transition: all 0.3s ease;
      overflow: hidden;
      height: 100%;
    }
    .feature-card:hover {
      transform: translateY(-4px);
      box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1);
    }
    .action-button {
      background: var(--primary-color);
      color: white;
      padding: 0.75rem 1.5rem;
      border-radius: 0.5rem;
      transition: all 0.3s ease;
      border: none;
      font-weight: 500;
      width: 100%;
      text-align: center;
      cursor: pointer;
    }
    .action-button:hover {
      background: var(--primary-hover);
      transform: translateY(-1px);
    }
    .input-group {
      position: relative;
    }
    .input-group.focused input,
    .input-group.focused textarea {
      border-color: var(--primary-color);
      transform: translateY(-2px);
    }
    .loading-spinner {
      border: 3px solid #f3f3f3;
      border-radius: 50%;
      border-top: 3px solid var(--primary-color);
      width: 24px;
      height: 24px;
      animation: spin 1s linear infinite;
      margin: 0 auto;
    }
    @keyframes spin {
      0% { transform: rotate(0deg); }
      100% { transform: rotate(360deg); }
    }
    .response-container {
      white-space: pre-wrap;
      font-family: "Tajawal", sans-serif;
      line-height: 1.6;
      max-height: 400px;
      overflow-y: auto;
    }
    /* تنسيق مميز لنتائج خريطة التفكير */
    .mind-map-output {
      background: linear-gradient(135deg, #e0f7fa, #b2ebf2);
      padding: 1rem;
      border: 2px dashed #00acc1;
      border-radius: 1rem;
      font-size: 1.1rem;
    }
    /* تنسيق قسم إنشاء العقود */
    .split-screen {
      display: grid;
      grid-template-columns: 1fr 1fr;
      gap: 2rem;
      margin-top: 1rem;
    }
    .contract-card {
      background: white;
      border-radius: 1.5rem;
      box-shadow: var(--card-shadow);
      padding: 2rem;
      border: 1px solid #f3f4f6;
    }
    .contract-output {
      background: #fafafa;
      border-radius: 1rem;
      padding: 2rem;
      min-height: 300px;
      line-height: 1.8;
      font-size: 1.1rem;
      border: 1px solid #f3f4f6;
      white-space: pre-wrap;
    }
    .copy-btn {
      position: absolute;
      top: 1rem;
      left: 1rem;
      padding: 0.5rem 1rem;
      background: #f3f4f6;
      border-radius: 0.75rem;
      cursor: pointer;
      transition: all 0.3s ease;
      display: flex;
      align-items: center;
      gap: 0.5rem;
      font-size: 0.9rem;
      color: #4b5563;
    }
    .copy-btn:hover {
      background: #e5e7eb;
    }
    .success-message {
      position: fixed;
      bottom: 2rem;
      right: 2rem;
      background: #10b981;
      color: white;
      padding: 1rem 2rem;
      border-radius: 1rem;
      animation: slideIn 0.3s ease;
    }
    @keyframes slideIn {
      from { transform: translateX(100%); opacity: 0; }
      to { transform: translateX(0); opacity: 1; }
    }
    .section-title {
      font-size: 1.25rem;
      color: #1f2937;
      margin-bottom: 1.5rem;
      padding-bottom: 0.75rem;
      border-bottom: 2px solid #e5e7eb;
      font-weight: 600;
    }
    /* تحسين التنسيق على الأجهزة المحمولة */
    @media (max-width: 768px) {
      .sidebar { transform: translateX(100%); }
      .sidebar.open { transform: translateX(0); }
      .main-content { margin-right: 0; padding: 1rem; }
      .split-screen { grid-template-columns: 1fr; }
    }
  </style>
</head>
<body>
  <!-- زر إظهار/إخفاء الشريط الجانبي -->
  <button id="sidebarToggle" class="fixed top-4 right-4 z-50 p-2 rounded-lg bg-white shadow-lg md:hidden">
    <i class="fas fa-bars text-xl"></i>
  </button>

  <!-- الشريط الجانبي -->
  <aside class="sidebar">
    <div class="p-6">
      <div class="flex items-center gap-4 mb-8">
        <img src="https://ufastpro.com/wp-content/uploads/2025/02/تصميم-بدون-عنوان.png" alt="شعار المنصة" class="w-12 h-12 rounded-full" />
        <div>
          <h1 class="text-xl font-bold text-gray-800">المنصة القانونية</h1>
          <p class="text-sm text-gray-500">خدمات قانونية ذكية</p>
        </div>
      </div>
      <nav class="space-y-1">
        <div class="nav-link active" data-section="home">
          <i class="fas fa-home ml-3"></i>
          <span>الرئيسية</span>
        </div>
        <div class="nav-link" data-section="analysis">
          <i class="fas fa-balance-scale ml-3"></i>
          <span>التحليل القانوني</span>
        </div>
        <div class="nav-link" data-section="mindMap">
          <i class="fas fa-project-diagram ml-3"></i>
          <span>خريطة التفكير</span>
        </div>
        <div class="nav-link" data-section="search">
          <i class="fas fa-search ml-3"></i>
          <span>البحث القانوني</span>
        </div>
        <div class="nav-link" data-section="documents">
          <i class="fas fa-file-alt ml-3"></i>
          <span>المستندات</span>
        </div>
        <div class="nav-link" data-section="translation">
          <i class="fas fa-language ml-3"></i>
          <span>الترجمة القانونية</span>
        </div>
        <div class="nav-link" data-section="consultation">
          <i class="fas fa-comments ml-3"></i>
          <span>استشارة قانونية</span>
        </div>
        <div class="nav-link" data-section="contracts">
          <i class="fas fa-gavel ml-3"></i>
          <span>الأحكام والسوابق</span>
        </div>
      </nav>
    </div>
  </aside>

  <!-- المحتوى الرئيسي -->
  <main class="main-content">
    <!-- بحث عالمي -->
    <div class="search-container mb-6 relative">
      <input type="text" class="search-input w-full p-3 rounded border" placeholder="ابحث في المنصة..." id="globalSearch" />
      <i class="fas fa-search absolute top-1/2 right-4 transform -translate-y-1/2 text-gray-400"></i>
    </div>

    <!-- قسم الرئيسية -->
    <section id="home" class="section">
      <h2 class="text-3xl font-bold text-gray-800 mb-8">الخدمات القانونية</h2>
      <div class="grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-6">
        <!-- بطاقة خدمة التحليل القانوني -->
        <div class="feature-card p-6">
          <div class="text-center">
            <i class="fas fa-balance-scale text-3xl mb-4 text-blue-600"></i>
            <h3 class="text-xl font-bold text-gray-800 mb-3">التحليل القانوني</h3>
            <p class="text-gray-600 mb-4">
              تحليل متكامل للقضايا والمستندات القانونية باستخدام الذكاء الاصطناعي
            </p>
            <button class="action-button" onclick="showSection('analysis')">ابدأ التحليل</button>
          </div>
        </div>
        <!-- بطاقة خدمة خريطة التفكير -->
        <div class="feature-card p-6">
          <div class="text-center">
            <i class="fas fa-project-diagram text-3xl mb-4 text-blue-600"></i>
            <h3 class="text-xl font-bold text-gray-800 mb-3">خريطة التفكير</h3>
            <p class="text-gray-600 mb-4">
              نظم قضية بشكل احترافي باستخدام خطوات منهجية قوية تساعدك على التفكير مع النموذج
            </p>
            <button class="action-button" onclick="showSection('mindMap')">إنشاء خريطة التفكير</button>
          </div>
        </div>
        <!-- بطاقة خدمة البحث القانوني -->
        <div class="feature-card p-6">
          <div class="text-center">
            <i class="fas fa-search text-3xl mb-4 text-blue-600"></i>
            <h3 class="text-xl font-bold text-gray-800 mb-3">البحث القانوني</h3>
            <p class="text-gray-600 mb-4">
              ابحث عن معلومات قانونية مع برومبت ثابت يشمل منصات: منصة1، منصة2، منصة3
            </p>
            <button class="action-button" onclick="showSection('search')">ابدأ البحث</button>
          </div>
        </div>
        <!-- بطاقة خدمة إنشاء المستندات -->
        <div class="feature-card p-6">
          <div class="text-center">
            <i class="fas fa-file-alt text-3xl mb-4 text-blue-600"></i>
            <h3 class="text-xl font-bold text-gray-800 mb-3">المستندات</h3>
            <p class="text-gray-600 mb-4">
              إنشاء وتحرير المستندات القانونية بمساعدة الذكاء الاصطناعي
            </p>
            <button class="action-button" onclick="showSection('documents')">إنشاء مستند</button>
          </div>
        </div>
        <!-- بطاقة خدمة الترجمة القانونية -->
        <div class="feature-card p-6">
          <div class="text-center">
            <i class="fas fa-language text-3xl mb-4 text-blue-600"></i>
            <h3 class="text-xl font-bold text-gray-800 mb-3">الترجمة القانونية</h3>
            <p class="text-gray-600 mb-4">
              ترجمة احترافية للوثائق القانونية مع إمكانية تنزيلها كملف PDF
            </p>
            <button class="action-button" onclick="showSection('translation')">ترجمة</button>
          </div>
        </div>
        <!-- بطاقة خدمة الاستشارة القانونية -->
        <div class="feature-card p-6">
          <div class="text-center">
            <i class="fas fa-comments text-3xl mb-4 text-blue-600"></i>
            <h3 class="text-xl font-bold text-gray-800 mb-3">استشارة قانونية</h3>
            <p class="text-gray-600 mb-4">
              احصل على استشارة قانونية فورية من خبرائنا
            </p>
            <button class="action-button" onclick="showSection('consultation')">استشر الآن</button>
          </div>
        </div>
      </div>
    </section>

    <!-- قسم التحليل القانوني -->
    <section id="analysis" class="section hidden">
      <h2 class="text-3xl font-bold text-gray-800 mb-8">التحليل القانوني</h2>
      <div class="input-group bg-white rounded p-6 shadow">
        <textarea class="w-full p-3 border rounded" placeholder="اكتب وصف القضية أو المستند الذي تريد تحليله..."></textarea>
        <label class="block text-gray-700 mb-2 mt-4">أو قم بإرفاق ملف PDF:</label>
        <input type="file" accept=".pdf" class="w-full p-3 border rounded" id="analysisPDF" />
        <div class="flex gap-4 mt-4">
          <button class="action-button" onclick="handleSubmit('analysis')">تحليل</button>
          <button id="downloadAnalysisPDFButton" class="action-button">تنزيل التحليل كملف PDF</button>
        </div>
        <div id="analysisResult" class="mt-4 response-container"></div>
      </div>
    </section>

    <!-- قسم إنشاء المستندات القانونية -->
    <section id="documents" class="section hidden">
      <h2 class="text-3xl font-bold text-gray-800 mb-8">إنشاء مستند قانوني</h2>
      <div class="input-group bg-white rounded p-6 shadow">
        <textarea class="w-full p-3 border rounded" placeholder="اكتب وصف المستند المطلوب إنشاؤه..."></textarea>
        <label class="block text-gray-700 mb-2 mt-4">أو قم بإرفاق ملف PDF:</label>
        <input type="file" accept=".pdf" class="w-full p-3 border rounded" id="documentsPDF" />
        <button class="action-button mt-4" onclick="handleSubmit('documents')">إنشاء مستند</button>
        <div id="documentsResult" class="mt-4 response-container"></div>
      </div>
    </section>

    <!-- قسم خريطة التفكير القانونية -->
    <section id="mindMap" class="section hidden">
      <h2 class="text-3xl font-bold text-gray-800 mb-4">خريطة التفكير القانونية</h2>
      <p class="mb-4 text-gray-700">
        أدخل الأفكار والخيوط المتعددة لتنظيم القضية بطريقة إبداعية باستخدام منهجيات قوية مثل تحليل SWOT و5 خطوات لتحليل الأسباب الجذرية. ساعد نفسك في التفكير مع النموذج.
      </p>
      <div id="mindMapFields">
         <div class="mb-4">
            <label class="block text-gray-700 font-bold mb-2">الفكرة الرئيسية:</label>
            <input type="text" class="w-full p-3 border rounded" placeholder="اكتب الفكرة الرئيسية للقضية" />
         </div>
         <div class="mb-4">
            <label class="block text-gray-700 font-bold mb-2">الأساس القانوني:</label>
            <input type="text" class="w-full p-3 border rounded" placeholder="اكتب الأساس القانوني" />
         </div>
         <div class="mb-4">
            <label class="block text-gray-700 font-bold mb-2">النقاط الرئيسية:</label>
            <input type="text" class="w-full p-3 border rounded" placeholder="اكتب النقاط الرئيسية" />
         </div>
      </div>
      <button id="addMindMapField" class="action-button mt-4">إضافة خط جديد</button>
      <button class="action-button mt-4" onclick="handleMindMap()">إنشاء خريطة التفكير</button>
      <div id="mindMapResult" class="mt-4 response-container mind-map-output"></div>
    </section>

    <!-- قسم البحث القانوني -->
    <section id="search" class="section hidden">
      <h2 class="text-3xl font-bold text-gray-800 mb-8">البحث القانوني</h2>
      <div class="input-group bg-white rounded p-6 shadow">
        <textarea class="w-full p-3 border rounded" placeholder="اكتب استعلام البحث القانوني..."></textarea>
        <button class="action-button mt-4" onclick="handleSubmit('search')">بحث</button>
        <div id="searchResult" class="mt-4 response-container"></div>
      </div>
    </section>

    <!-- قسم الترجمة القانونية -->
    <section id="translation" class="section hidden">
      <h2 class="text-3xl font-bold text-gray-800 mb-8">الترجمة القانونية</h2>
      <div class="input-group bg-white rounded p-6 shadow">
        <textarea class="w-full p-3 border rounded" placeholder="اكتب النص المراد ترجمته..."></textarea>
        <label class="block text-gray-700 mb-2 mt-4">أو قم بإرفاق ملف PDF:</label>
        <input type="file" accept=".pdf" class="w-full p-3 border rounded" id="translationPDF" />
        <div class="flex gap-4 my-4">
          <select class="p-3 rounded border w-full" id="fromLang">
            <option value="ar">العربية</option>
            <option value="en">الإنجليزية</option>
            <option value="de">الألمانية</option>
            <option value="zh">الصينية</option>
            <option value="fr">الفرنسية</option>
            <option value="it">الإيطالية</option>
            <option value="es">الإسبانية</option>
          </select>
          <select class="p-3 rounded border w-full" id="toLang">
            <option value="en">الإنجليزية</option>
            <option value="ar">العربية</option>
            <option value="de">الألمانية</option>
            <option value="zh">الصينية</option>
            <option value="fr">الفرنسية</option>
            <option value="it">الإيطالية</option>
            <option value="es">الإسبانية</option>
          </select>
        </div>
        <div class="flex gap-4">
          <button class="action-button" onclick="handleSubmit('translation')">ترجمة</button>
          <button id="downloadPDFButton" class="action-button">تنزيل الترجمة كملف PDF</button>
        </div>
        <div id="translationResult" class="mt-4 response-container"></div>
      </div>
    </section>

    <!-- قسم الاستشارة القانونية -->
    <section id="consultation" class="section hidden">
      <h2 class="text-3xl font-bold text-gray-800 mb-8">استشارة قانونية</h2>
      <div class="input-group bg-white rounded p-6 shadow">
        <textarea class="w-full p-3 border rounded" placeholder="اكتب سؤالك القانوني هنا..."></textarea>
        <button class="action-button mt-4" onclick="handleSubmit('consultation')">احصل على استشارة</button>
        <div id="consultationResult" class="mt-4 response-container"></div>
      </div>
    </section>

    <!-- قسم إنشاء العقود -->
    <section id="contracts" class="section hidden">
      <h2 class="text-3xl font-bold text-gray-800 mb-8">منشئ العقود المصري الذكي</h2>
      <div class="split-screen">
        <!-- نموذج بيانات العقد -->
        <div class="contract-card">
          <div class="space-y-6">
            <div class="mb-4 input-group">
              <label class="block text-gray-700 font-bold mb-2">عنوان العقد:</label>
              <input type="text" id="contractTitle" placeholder="عنوان العقد" class="w-full p-2 border rounded" />
            </div>
            <div class="mb-4 input-group">
              <label class="block text-gray-700 font-bold mb-2">تاريخ تحرير العقد:</label>
              <input type="date" id="contractDate" class="w-full p-2 border rounded" />
            </div>
            <h3 class="section-title">بيانات الطرف الأول</h3>
            <div class="mb-4 input-group">
              <label class="block text-gray-700 font-bold mb-2">اسم الطرف الأول:</label>
              <input type="text" id="firstPartyName" placeholder="الاسم الكامل" class="w-full p-2 border rounded" />
            </div>
            <div class="mb-4 input-group">
              <label class="block text-gray-700 font-bold mb-2">الرقم القومي للطرف الأول:</label>
              <input type="text" id="firstPartyID" placeholder="14 رقم" maxlength="14" class="w-full p-2 border rounded" />
            </div>
            <div class="mb-4 input-group">
              <label class="block text-gray-700 font-bold mb-2">الصفة:</label>
              <input type="text" id="firstPartyTitle" placeholder="مثال: مالك، مدير شركة" class="w-full p-2 border rounded" />
            </div>
            <div class="mb-4 input-group">
              <label class="block text-gray-700 font-bold mb-2">جنسية الطرف الأول:</label>
              <input type="text" id="firstPartyNationality" placeholder="الجنسية" value="مصري" class="w-full p-2 border rounded" />
            </div>
            <div class="mb-4 input-group">
              <label class="block text-gray-700 font-bold mb-2">عنوان الطرف الأول:</label>
              <input type="text" id="firstPartyAddress" placeholder="العنوان التفصيلي" class="w-full p-2 border rounded" />
            </div>
            <h3 class="section-title">بيانات الطرف الثاني</h3>
            <div class="mb-4 input-group">
              <label class="block text-gray-700 font-bold mb-2">اسم الطرف الثاني:</label>
              <input type="text" id="secondPartyName" placeholder="الاسم الكامل" class="w-full p-2 border rounded" />
            </div>
            <div class="mb-4 input-group">
              <label class="block text-gray-700 font-bold mb-2">الرقم القومي للطرف الثاني:</label>
              <input type="text" id="secondPartyID" placeholder="14 رقم" maxlength="14" class="w-full p-2 border rounded" />
            </div>
            <div class="mb-4 input-group">
              <label class="block text-gray-700 font-bold mb-2">الصفة:</label>
              <input type="text" id="secondPartyTitle" placeholder="مثال: مستأجر، مشتري" class="w-full p-2 border rounded" />
            </div>
            <div class="mb-4 input-group">
              <label class="block text-gray-700 font-bold mb-2">جنسية الطرف الثاني:</label>
              <input type="text" id="secondPartyNationality" placeholder="الجنسية" value="مصري" class="w-full p-2 border rounded" />
            </div>
            <div class="mb-4 input-group">
              <label class="block text-gray-700 font-bold mb-2">عنوان الطرف الثاني:</label>
              <input type="text" id="secondPartyAddress" placeholder="العنوان التفصيلي" class="w-full p-2 border rounded" />
            </div>
            <h3 class="section-title">تفاصيل العقد</h3>
            <div class="mb-4 input-group">
              <label class="block text-gray-700 font-bold mb-2">البند التمهيدي:</label>
              <textarea id="contractPreamble" placeholder="اكتب مضمون العقد والغرض منه" class="w-full p-2 border rounded h-24"></textarea>
            </div>
            <div class="mb-4 input-group">
              <label class="block text-gray-700 font-bold mb-2">بنود العقد:</label>
              <textarea id="contractTerms" placeholder="اكتب بنود العقد الأساسية" class="w-full p-2 border rounded h-48"></textarea>
            </div>
          </div>
          <div class="mt-4 text-center">
            <button id="generateButton" class="action-button">إنشاء العقد</button>
          </div>
        </div>
        <!-- عرض العقد المنشأ مع إمكانية النسخ -->
        <div class="contract-card relative">
          <h3 class="text-2xl font-bold text-gray-800 mb-4">العقد المنشأ</h3>
          <button class="copy-btn" id="copyButton">
            <i class="fas fa-copy"></i> نسخ العقد
          </button>
          <div id="contractOutput" class="contract-output"></div>
        </div>
      </div>
    </section>
  </main>

  <!-- تذييل الصفحة -->
  <footer class="text-center py-4 text-gray-600 fixed bottom-0 left-0 w-full bg-white border-t">
    © Copyright 2025・<span class="font-bold">FASTPRO</span>・All rights reserved.
  </footer>

  <!-- سكربتات الموقع -->
  <script>
    // تعريف API النصي (للقسم غير المعتمد على رفع الملفات)
    const API_URL = 'https://g2mgow5tgbxsjy-7777.proxy.runpod.net/proxy/8000/chat';

    // دالة الحصول على البادئة (prompt prefix) بناءً على القسم مع برومبت ثابت
    function getPromptPrefix(section) {
      switch(section) {
        case 'analysis':
          return 'قم بتحليل هذه القضية: ';
        case 'documents':
          return 'قم بإنشاء مستند قانوني بناءً على الوصف التالي: ';
        case 'mindMap':
          return 'قم بإنشاء خريطة ذهنية لحل القضية باستخدام تقنية تونى بوزان الشهيرة: ';
        case 'search':
          return 'ابحث عن معلومات قانونية حول: [منصات: منصة1، منصة2، منصة3] ';
        case 'translation':
          return 'قم بترجمة هذا النص القانوني: ';
        case 'consultation':
          return 'أحتاج استشارة قانونية في الموضوع التالي: ';
        default:
          return '';
      }
    }

    // تفعيل التنقل بين الأقسام
    document.querySelectorAll(".nav-link").forEach(link => {
      link.addEventListener("click", (e) => {
        e.preventDefault();
        const section = e.currentTarget.getAttribute("data-section");
        if(section) {
          showSection(section);
          // إخفاء الشريط الجانبي على الأجهزة المحمولة بعد النقر
          if(window.innerWidth < 768) {
            document.querySelector(".sidebar").classList.remove("open");
          }
        }
      });
    });

    function showSection(sectionId) {
      document.querySelectorAll(".section").forEach(section => {
        section.classList.add("hidden");
      });
      document.getElementById(sectionId).classList.remove("hidden");
      document.querySelectorAll(".nav-link").forEach(link => {
        link.classList.remove("active");
        if (link.getAttribute("data-section") === sectionId) {
          link.classList.add("active");
        }
      });
    }

    // زر القائمة على الهاتف
    document.getElementById("sidebarToggle").addEventListener("click", () => {
      document.querySelector(".sidebar").classList.toggle("open");
    });

    // تحسين تأثير التركيز على حقول الإدخال
    document.querySelectorAll("input, textarea").forEach(element => {
      element.addEventListener("focus", function() {
        const group = this.closest(".input-group");
        if(group) group.classList.add("focused");
        this.style.transform = 'translateY(-2px)';
      });
      
      element.addEventListener("blur", function() {
        const group = this.closest(".input-group");
        if(group) group.classList.remove("focused");
        this.style.transform = 'translateY(0)';
      });
    });

    // دالة إرسال الطلبات لقسم "التحليل القانوني"
    async function handleSubmit(section) {
      const container = document.getElementById(section);
      const resultDiv = container.querySelector(".response-container");
      
      // إذا كان القسم "analysis" نتعامل مع احتمال وجود ملف ونص
      if (section === 'analysis') {
        const fileInput = container.querySelector("#analysisPDF");
        const textArea = container.querySelector("textarea");
        const text = textArea.value.trim();
        // مسح المحتوى السابق
        resultDiv.innerHTML = '';
        let filePromise = null, textPromise = null;
        
        // إذا تم إرفاق ملف PDF، نقوم برفعه وتحليله
        if (fileInput && fileInput.files && fileInput.files.length > 0) {
          const file = fileInput.files[0];
          console.log("Selected file:", file);
          let formData = new FormData();
          formData.append("file", file);
          resultDiv.innerHTML += '<div id="fileAnalysisSpinner" class="loading-spinner"></div>';
          filePromise = fetch('https://g2mgow5tgbxsjy-7777.proxy.runpod.net/proxy/8000/upload', {
            method: "POST",
            body: formData
          })
          .then(response => {
            if (!response.ok) {
              throw new Error("فشل رفع الملف");
            }
            return response.json();
          })
          .then(data => {
            return data.response || "تم تحليل الملف بنجاح";
          })
          .catch(error => {
            console.error("File analysis error:", error);
            return '<div class="text-red-500">حدث خطأ في رفع الملف. يرجى المحاولة مرة أخرى.</div>';
          });
        }
        
        // إذا وُجد نص للتحليل (سواءً مع الملف أو بدونه) نرسله عبر API النصي
        if (text) {
          resultDiv.innerHTML += '<div id="textAnalysisSpinner" class="loading-spinner"></div>';
          const payload = {
            message: getPromptPrefix(section) + text,
            history: []
          };
          textPromise = fetch(API_URL, {
            method: "POST",
            headers: { "Content-Type": "application/json" },
            body: JSON.stringify(payload)
          })
          .then(response => {
            if (!response.ok) {
              throw new Error("فشل الاستجابة من الخادم");
            }
            return response.json();
          })
          .then(data => {
            return data.response || "";
          })
          .catch(error => {
            console.error("Text analysis error:", error);
            return '<div class="text-red-500">حدث خطأ في تحليل النص. يرجى المحاولة مرة أخرى.</div>';
          });
        }
        
        // انتظار انتهاء كلا العمليتين (إن وُجدتا)
        const fileResult = filePromise ? await filePromise : null;
        const textResult = textPromise ? await textPromise : null;
        
        // مسح عناصر التحميل (spinners)
        resultDiv.innerHTML = '';
        if (fileResult) {
          resultDiv.innerHTML += `<div><strong>نتيجة تحليل الملف:</strong><br>${fileResult}</div><br>`;
        }
        if (textResult) {
          resultDiv.innerHTML += `<div><strong>نتيجة تحليل النص:</strong><br>${textResult}</div>`;
        }
        if (!fileResult && !textResult) {
          alert("الرجاء إدخال نص أو إرفاق ملف PDF");
          return;
        }
      } else {
        // للأقسام الأخرى (بدون رفع ملفات)
        const textarea = container.querySelector("textarea");
        const text = textarea.value.trim();
        if (!text) {
          alert("الرجاء إدخال نص");
          return;
        }
        const payload = {
          message: getPromptPrefix(section) + text,
          history: []
        };

        resultDiv.innerHTML = '<div class="loading-spinner"></div>';
        try {
          const response = await fetch(API_URL, {
            method: "POST",
            headers: { "Content-Type": "application/json" },
            body: JSON.stringify(payload)
          });
          if (!response.ok) {
            throw new Error("فشل الاستجابة من الخادم");
          }
          const data = await response.json();
          resultDiv.innerHTML = data.response || "";
        } catch (error) {
          console.error("Error:", error);
          resultDiv.innerHTML = '<div class="text-red-500">حدث خطأ. يرجى المحاولة مرة أخرى.</div>';
        }
      }
    }

    // وظيفة زر النسخ في قسم إنشاء العقود
    document.getElementById("copyButton").addEventListener("click", async function() {
      const contractText = document.getElementById("contractOutput").innerText;
      try {
        await navigator.clipboard.writeText(contractText);
        showSuccessMessage("تم نسخ العقد بنجاح!");
      } catch (err) {
        console.error("فشل نسخ النص:", err);
      }
    });

    // وظيفة إظهار رسالة النجاح عند النسخ
    function showSuccessMessage(message) {
      const successMessage = document.createElement("div");
      successMessage.className = "success-message";
      successMessage.textContent = message;
      document.body.appendChild(successMessage);
      setTimeout(() => {
        successMessage.style.opacity = "0";
        setTimeout(() => successMessage.remove(), 300);
      }, 2000);
    }

    // التحقق من صحة الرقم القومي للطرف الأول والثاني
    document.querySelectorAll("#firstPartyID, #secondPartyID").forEach(input => {
      input.addEventListener("input", function() {
        this.value = this.value.replace(/[^0-9]/g, '');
        if (this.value.length > 14) {
          this.value = this.value.slice(0, 14);
        }
      });
    });

    // دالة الحصول على تسمية الحقل لعرضها في رسائل الخطأ
    function getFieldLabel(field) {
      const labels = {
        contractTitle: 'عنوان العقد',
        contractDate: 'تاريخ العقد',
        firstPartyName: 'اسم الطرف الأول',
        firstPartyID: 'الرقم القومي للطرف الأول',
        firstPartyTitle: 'صفة الطرف الأول',
        firstPartyNationality: 'جنسية الطرف الأول',
        firstPartyAddress: 'عنوان الطرف الأول',
        secondPartyName: 'اسم الطرف الثاني',
        secondPartyID: 'الرقم القومي للطرف الثاني',
        secondPartyTitle: 'صفة الطرف الثاني',
        secondPartyNationality: 'جنسية الطرف الثاني',
        secondPartyAddress: 'عنوان الطرف الثاني',
        contractPreamble: 'البند التمهيدي',
        contractTerms: 'بنود العقد'
      };
      return labels[field] || field;
    }

    // وظيفة زر إنشاء العقد
    document.getElementById("generateButton").addEventListener("click", async function() {
      const button = this;
      const outputDiv = document.getElementById("contractOutput");

      // جمع بيانات النموذج
      const formData = {
        contractTitle: document.getElementById("contractTitle").value.trim(),
        contractDate: document.getElementById("contractDate").value,
        firstPartyName: document.getElementById("firstPartyName").value.trim(),
        firstPartyID: document.getElementById("firstPartyID").value.trim(),
        firstPartyTitle: document.getElementById("firstPartyTitle").value.trim(),
        firstPartyNationality: document.getElementById("firstPartyNationality").value.trim(),
        firstPartyAddress: document.getElementById("firstPartyAddress").value.trim(),
        secondPartyName: document.getElementById("secondPartyName").value.trim(),
        secondPartyID: document.getElementById("secondPartyID").value.trim(),
        secondPartyTitle: document.getElementById("secondPartyTitle").value.trim(),
        secondPartyNationality: document.getElementById("secondPartyNationality").value.trim(),
        secondPartyAddress: document.getElementById("secondPartyAddress").value.trim(),
        contractPreamble: document.getElementById("contractPreamble").value.trim(),
        contractTerms: document.getElementById("contractTerms").value.trim()
      };

      // التحقق من البيانات المطلوبة
      const requiredFields = Object.keys(formData);
      const missingFields = requiredFields.filter(field => !formData[field]);
      
      if (missingFields.length > 0) {
        outputDiv.innerHTML = `
          <div class="text-red-500 font-bold mb-4">يرجى ملء جميع الحقول المطلوبة</div>
          <ul class="list-disc list-inside text-red-500">
            ${missingFields.map(field => `<li>${getFieldLabel(field)}</li>`).join('')}
          </ul>
        `;
        return;
      }

      // تحديث واجهة المستخدم لحالة التحميل
      button.textContent = 'جاري إنشاء العقد...';
      button.disabled = true;
      outputDiv.innerHTML = `
        <div class="flex items-center justify-center space-x-4 text-gray-600">
          <div class="animate-spin rounded-full h-8 w-8 border-b-2 border-blue-600"></div>
          <span>جاري إنشاء العقد باستخدام الذكاء الاصطناعي...</span>
        </div>
      `;

      try {
        // تحويل التاريخ إلى التنسيق العربي
        const dateObj = new Date(formData.contractDate);
        const arabicDate = new Intl.DateTimeFormat('ar-EG', {
          year: 'numeric',
          month: 'long',
          day: 'numeric'
        }).format(dateObj);

        // إنشاء نص الطلب
        const prompt = `قم بإنشاء عقد قانوني مصري رسمي باللغة العربية يتضمن البيانات التالية:

عنوان العقد: ${formData.contractTitle}
تاريخ العقد: ${arabicDate}

الطرف الأول:
- الاسم: ${formData.firstPartyName}
- الرقم القومي: ${formData.firstPartyID}
- الصفة: ${formData.firstPartyTitle}
- الجنسية: ${formData.firstPartyNationality}
- العنوان: ${formData.firstPartyAddress}

الطرف الثاني:
- الاسم: ${formData.secondPartyName}
- الرقم القومي: ${formData.secondPartyID}
- الصفة: ${formData.secondPartyTitle}
- الجنسية: ${formData.secondPartyNationality}
- العنوان: ${formData.secondPartyAddress}

التمهيد:
${formData.contractPreamble}

بنود العقد:
${formData.contractTerms}

يجب أن يتضمن العقد:
1. النص القانوني: "وبعد أن أقر طرفي هذا العقد بكامل أهليتهما المعتبرة قانوناً وشرعاً وبخلو إرادتهما من أي عيب من عيوب الإرادة وبأنهما غير ممنوعين من التصرف وغير محجور عليهما لأي سبب من الأسباب وعدم خضوعهم لقانون الحراسات أو الكسب غير المشروع وبخلوهما من كافة الموانع القانونية والشرعية اللازمة للتعاقد اتفقوا على الآتي"
2. بند حكم التمهيد يوضح أن التمهيد جزء لا يتجزأ من العقد
3. تنسيق قانوني رسمي
4. مكان للتوقيع في النهاية مع كتابة "طرف أول" و "طرف ثاني"`;

        // إرسال الطلب إلى API الخاص بالعقود
        const response = await fetch(API_URL, {
          method: 'POST',
          headers: {
            'Content-Type': 'application/json'
          },
          body: JSON.stringify({
            message: prompt,
            history: []
          })
        });

        if (!response.ok) {
          throw new Error(`HTTP error! status: ${response.status}`);
        }

        const data = await response.json();
        outputDiv.innerHTML = `<div dir="rtl" style="white-space: pre-wrap;">${data.response}</div>`;

      } catch (error) {
        outputDiv.innerHTML = `
          <div class="text-red-600 font-bold">
            عذراً، حدث خطأ في إنشاء العقد. يرجى المحاولة مرة أخرى.
            <br>
            تفاصيل الخطأ: ${error.message}
          </div>
        `;
        console.error('Error:', error);
      } finally {
        button.textContent = 'إنشاء العقد';
        button.disabled = false;
      }
    });

    // وظيفة تنزيل الترجمة كملف PDF (باستخدام مكتبة jsPDF)
    document.getElementById("downloadPDFButton").addEventListener("click", function() {
      const { jsPDF } = window.jspdf;
      const doc = new jsPDF({ orientation: "portrait", unit: "pt", format: "a4" });
      const content = document.getElementById("translationResult").innerText;
      if (!content.trim()) {
        alert("لا يوجد نص للترجمة لتنزيله");
        return;
      }
      doc.setFont("Tajawal", "normal");
      doc.text(content, 40, 60, { maxWidth: 515 });
      doc.save("translation.pdf");
    });

    // وظيفة تنزيل التحليل كملف PDF (باستخدام مكتبة jsPDF)
    document.getElementById("downloadAnalysisPDFButton").addEventListener("click", function() {
      const { jsPDF } = window.jspdf;
      const doc = new jsPDF({ orientation: "portrait", unit: "pt", format: "a4" });
      const content = document.getElementById("analysisResult").innerText;
      if (!content.trim()) {
        alert("لا يوجد نص للتحليل لتنزيله");
        return;
      }
      doc.setFont("Tajawal", "normal");
      doc.text(content, 40, 60, { maxWidth: 515 });
      doc.save("analysis.pdf");
    });

    // وظيفة إضافة حقل جديد في قسم خريطة التفكير
    document.getElementById("addMindMapField").addEventListener("click", function() {
      const container = document.getElementById("mindMapFields");
      const newFieldDiv = document.createElement("div");
      newFieldDiv.className = "mb-4";
      newFieldDiv.innerHTML = `<label class="block text-gray-700 font-bold mb-2">خط جديد:</label>
         <input type="text" class="w-full p-3 border rounded" placeholder="اكتب فكرة جديدة" />`;
      container.appendChild(newFieldDiv);
    });

    // وظيفة إنشاء خريطة التفكير باستخدام الحقول المتعددة
    function handleMindMap() {
      const inputs = document.querySelectorAll("#mindMapFields input");
      let collectedText = "";
      inputs.forEach((input, index) => {
        const value = input.value.trim();
        if(value) {
          collectedText += `الخيط ${index + 1}: ${value}\n`;
        }
      });
      if (!collectedText.trim()) {
        alert("الرجاء إدخال بعض الأفكار لإنشاء خريطة التفكير");
        return;
      }
      const resultDiv = document.getElementById("mindMapResult");
      const prompt = getPromptPrefix("mindMap") + "\n" + collectedText +
                     "\nاستخدم منهجيات قوية مثل تحليل SWOT و5 خطوات لتحليل الأسباب الجذرية مع النظر في البدائل القانونية لتنظيم القضية بشكل احترافي.";
      resultDiv.innerHTML = '<div class="loading-spinner"></div>';
      fetch(API_URL, {
        method: "POST",
        headers: { "Content-Type": "application/json" },
        body: JSON.stringify({ message: prompt, history: [] })
      })
      .then(response => response.json())
      .then(data => {
        resultDiv.innerHTML = data.response || "";
      })
      .catch(error => {
        console.error("Error:", error);
        resultDiv.innerHTML = '<div class="text-red-500">حدث خطأ. يرجى المحاولة مرة أخرى.</div>';
      });
    }

    // تهيئة الصفحة بالعرض الافتراضي للقسم "home"
    document.addEventListener("DOMContentLoaded", () => {
      showSection("home");
    });
  </script>
</body>
</html>