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 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <!DOCTYPE html>
2
+ <html lang="ar" dir="rtl">
3
+ <head>
4
+ <meta charset="UTF-8">
5
+ <meta name="viewport" content="width=device-width, initial-scale=1.0">
6
+ <title>منشئ العقود الذكي</title>
7
+ <link href="https://cdn.jsdelivr.net/npm/[email protected]/dist/tailwind.min.css" rel="stylesheet">
8
+ <link href="https://cdnjs.cloudflare.com/ajax/libs/animate.css/4.1.1/animate.min.css" rel="stylesheet">
9
+ <style>
10
+ @import url('https://fonts.googleapis.com/css2?family=IBM+Plex+Sans+Arabic:wght@300;400;500;600;700&display=swap');
11
+
12
+ body {
13
+ font-family: 'IBM Plex Sans Arabic', sans-serif;
14
+ background: #ffffff;
15
+ min-height: 100vh;
16
+ }
17
+
18
+ .split-screen {
19
+ display: grid;
20
+ grid-template-columns: 1fr 1fr;
21
+ gap: 2rem;
22
+ max-width: 1400px;
23
+ margin: 2rem auto;
24
+ padding: 0 2rem;
25
+ min-height: calc(100vh - 4rem);
26
+ }
27
+
28
+ .input-group {
29
+ position: relative;
30
+ margin-bottom: 1.5rem;
31
+ }
32
+
33
+ .input-group input, .input-group textarea, .input-group select {
34
+ width: 100%;
35
+ padding: 1rem 1.25rem;
36
+ border: 2px solid #e5e7eb;
37
+ border-radius: 1rem;
38
+ transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
39
+ background: #ffffff;
40
+ font-size: 1rem;
41
+ }
42
+
43
+ .input-group input:focus, .input-group textarea:focus, .input-group select:focus {
44
+ border-color: #2563eb;
45
+ box-shadow: 0 0 0 4px rgba(37, 99, 235, 0.1);
46
+ outline: none;
47
+ transform: translateY(-2px);
48
+ }
49
+
50
+ .card {
51
+ background: white;
52
+ border-radius: 1.5rem;
53
+ box-shadow: 0 10px 30px rgba(0, 0, 0, 0.08);
54
+ padding: 2.5rem;
55
+ height: fit-content;
56
+ transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
57
+ border: 1px solid #f3f4f6;
58
+ }
59
+
60
+ .card:hover {
61
+ transform: translateY(-4px);
62
+ box-shadow: 0 20px 40px rgba(0, 0, 0, 0.12);
63
+ }
64
+
65
+ .contract-output {
66
+ background: #fafafa;
67
+ border-radius: 1rem;
68
+ padding: 2rem;
69
+ min-height: 300px;
70
+ line-height: 1.8;
71
+ font-size: 1.1rem;
72
+ border: 1px solid #f3f4f6;
73
+ }
74
+
75
+ .btn {
76
+ background: linear-gradient(135deg, #2563eb 0%, #1d4ed8 100%);
77
+ color: white;
78
+ padding: 1rem 2.5rem;
79
+ border-radius: 1rem;
80
+ font-weight: 600;
81
+ transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
82
+ border: none;
83
+ cursor: pointer;
84
+ font-size: 1.1rem;
85
+ position: relative;
86
+ overflow: hidden;
87
+ }
88
+
89
+ .btn:hover {
90
+ transform: translateY(-2px);
91
+ box-shadow: 0 8px 20px rgba(37, 99, 235, 0.25);
92
+ }
93
+
94
+ .btn:active {
95
+ transform: translateY(0);
96
+ }
97
+
98
+ .copy-btn {
99
+ position: absolute;
100
+ top: 1rem;
101
+ left: 1rem;
102
+ padding: 0.5rem 1rem;
103
+ background: #f3f4f6;
104
+ border-radius: 0.75rem;
105
+ cursor: pointer;
106
+ transition: all 0.3s ease;
107
+ display: flex;
108
+ align-items: center;
109
+ gap: 0.5rem;
110
+ font-size: 0.9rem;
111
+ color: #4b5563;
112
+ }
113
+
114
+ .copy-btn:hover {
115
+ background: #e5e7eb;
116
+ }
117
+
118
+ .success-message {
119
+ position: fixed;
120
+ bottom: 2rem;
121
+ right: 2rem;
122
+ background: #10b981;
123
+ color: white;
124
+ padding: 1rem 2rem;
125
+ border-radius: 1rem;
126
+ animation: slideIn 0.3s ease;
127
+ }
128
+
129
+ @keyframes slideIn {
130
+ from { transform: translateX(100%); opacity: 0; }
131
+ to { transform: translateX(0); opacity: 1; }
132
+ }
133
+
134
+ .loading {
135
+ position: relative;
136
+ }
137
+
138
+ .loading::after {
139
+ content: '';
140
+ position: absolute;
141
+ top: 0;
142
+ left: 0;
143
+ width: 100%;
144
+ height: 100%;
145
+ background: linear-gradient(90deg, transparent, rgba(255,255,255,0.4), transparent);
146
+ animation: loading 1.5s infinite;
147
+ }
148
+
149
+ .section-title {
150
+ font-size: 1.25rem;
151
+ color: #1f2937;
152
+ margin-bottom: 1.5rem;
153
+ padding-bottom: 0.75rem;
154
+ border-bottom: 2px solid #e5e7eb;
155
+ font-weight: 600;
156
+ }
157
+
158
+ .contract-type-selector {
159
+ display: flex;
160
+ gap: 1rem;
161
+ margin-bottom: 2rem;
162
+ }
163
+
164
+ .type-option {
165
+ flex: 1;
166
+ padding: 1.5rem;
167
+ border: 2px solid #e5e7eb;
168
+ border-radius: 1rem;
169
+ cursor: pointer;
170
+ transition: all 0.3s ease;
171
+ text-align: center;
172
+ }
173
+
174
+ .type-option.active {
175
+ border-color: #2563eb;
176
+ background: rgba(37, 99, 235, 0.05);
177
+ }
178
+
179
+ .type-option:hover {
180
+ transform: translateY(-2px);
181
+ }
182
+
183
+ @media (max-width: 768px) {
184
+ .split-screen {
185
+ grid-template-columns: 1fr;
186
+ padding: 1rem;
187
+ }
188
+
189
+ .card {
190
+ margin-bottom: 1rem;
191
+ padding: 1.5rem;
192
+ }
193
+ }
194
+ </style>
195
+ </head>
196
+ <body>
197
+ <div class="split-screen">
198
+ <div class="card animate__animated animate__fadeInRight">
199
+ <h1 class="text-4xl font-bold mb-8 text-center text-gray-800">منشئ العقود الذكي</h1>
200
+
201
+ <div class="contract-type-selector">
202
+ <div class="type-option active" data-type="rental">
203
+ <h3 class="font-bold mb-2">عقد إيجار</h3>
204
+ <p class="text-sm text-gray-600">عقود الإيجار السكنية والتجارية</p>
205
+ </div>
206
+ <div class="type-option" data-type="custom">
207
+ <h3 class="font-bold mb-2">عقد مخصص</h3>
208
+ <p class="text-sm text-gray-600">صياغة عقد حسب احتياجاتك</p>
209
+ </div>
210
+ </div>
211
+
212
+ <div id="rentalTemplate" class="contract-template active space-y-6">
213
+ <h2 class="section-title">معلومات العقد الأساسية</h2>
214
+
215
+ <div class="input-group">
216
+ <label class="block text-gray-700 font-bold mb-2">المؤجر:</label>
217
+ <input type="text" id="landlord" placeholder="اسم المؤجر الكامل" class="focus:ring-2 focus:ring-blue-500">
218
+ </div>
219
+
220
+ <div class="input-group">
221
+ <label class="block text-gray-700 font-bold mb-2">المستأجر:</label>
222
+ <input type="text" id="tenant" placeholder="اسم المستأجر الكامل">
223
+ </div>
224
+
225
+ <h2 class="section-title">تفاصيل العقار والإيجار</h2>
226
+
227
+ <div class="input-group">
228
+ <label class="block text-gray-700 font-bold mb-2">عنوان العقار:</label>
229
+ <input type="text" id="propertyAddress" placeholder="العنوان التفصيلي للعقار">
230
+ </div>
231
+
232
+ <div class="grid grid-cols-2 gap-4">
233
+ <div class="input-group">
234
+ <label class="block text-gray-700 font-bold mb-2">مدة الإيجار:</label>
235
+ <input type="text" id="rentalPeriod" placeholder="مثال: سنة واحدة">
236
+ </div>
237
+
238
+ <div class="input-group">
239
+ <label class="block text-gray-700 font-bold mb-2">قيمة الإيجار:</label>
240
+ <input type="text" id="rentalAmount" placeholder="القيمة بالريال السعودي">
241
+ </div>
242
+ </div>
243
+
244
+ <div class="input-group">
245
+ <label class="block text-gray-700 font-bold mb-2">شروط إضافية:</label>
246
+ <textarea id="additionalTerms" class="h-32" placeholder="أي شروط أو ملاحظات إضافية"></textarea>
247
+ </div>
248
+ </div>
249
+
250
+ <div id="customTemplate" class="contract-template hidden space-y-6">
251
+ <h2 class="section-title">معلومات العقد المخصص</h2>
252
+
253
+ <div class="input-group">
254
+ <label class="block text-gray-700 font-bold mb-2">عنوان العقد:</label>
255
+ <input type="text" id="contractTitle" placeholder="عنوان العقد">
256
+ </div>
257
+
258
+ <div class="input-group">
259
+ <label class="block text-gray-700 font-bold mb-2">الطرف الأول:</label>
260
+ <input type="text" id="firstParty" placeholder="اسم الطرف الأول">
261
+ </div>
262
+
263
+ <div class="input-group">
264
+ <label class="block text-gray-700 font-bold mb-2">الطرف الثاني:</label>
265
+ <input type="text" id="secondParty" placeholder="اسم الطرف الثاني">
266
+ </div>
267
+
268
+ <div class="input-group">
269
+ <label class="block text-gray-700 font-bold mb-2">تفاصيل العقد:</label>
270
+ <textarea id="contractDetails" class="h-64" placeholder="اكتب تفاصيل العقد هنا"></textarea>
271
+ </div>
272
+ </div>
273
+
274
+ <div class="mt-8 flex justify-center">
275
+ <button id="generateButton" class="btn">
276
+ إنشاء العقد
277
+ </button>
278
+ </div>
279
+ </div>
280
+
281
+ <div class="card animate__animated animate__fadeInLeft">
282
+ <h2 class="text-2xl font-bold mb-6 text-gray-800">العقد المنشأ</h2>
283
+ <div class="relative">
284
+ <button class="copy-btn" id="copyButton">
285
+ <svg xmlns="http://www.w3.org/2000/svg" class="h-5 w-5" fill="none" viewBox="0 0 24 24" stroke="currentColor">
286
+ <path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M8 16H6a2 2 0 01-2-2V6a2 2 0 012-2h8a2 2 0 012 2v2m-6 12h8a2 2 0 002-2v-8a2 2 0 00-2-2h-8a2 2 0 00-2 2v8a2 2 0 002 2z" />
287
+ </svg>
288
+ نسخ العقد
289
+ </button>
290
+ <div id="contractOutput" class="contract-output prose"></div>
291
+ </div>
292
+ </div>
293
+ </div>
294
+
295
+ <script>
296
+ const API_URL = 'https://j8fp9mu44k547j-7777.proxy.runpod.net/proxy/8000/chat';
297
+ let currentController = null;
298
+
299
+ // تحسين تجربة المستخدم للمدخلات
300
+ document.querySelectorAll('input, textarea').forEach(element => {
301
+ element.addEventListener('focus', function() {
302
+ this.closest('.input-group').classList.add('focused');
303
+ this.style.transform = 'translateY(-2px)';
304
+ });
305
+
306
+ element.addEventListener('blur', function() {
307
+ this.closest('.input-group').classList.remove('focused');
308
+ this.style.transform = 'translateY(0)';
309
+ });
310
+
311
+ // إضافة تأثير ripple عند النقر
312
+ element.addEventListener('click', function(e) {
313
+ const ripple = document.createElement('div');
314
+ ripple.classList.add('ripple');
315
+ this.appendChild(ripple);
316
+ setTimeout(() => ripple.remove(), 1000);
317
+ });
318
+ });
319
+
320
+ // تحسين تبديل نوع العقد
321
+ document.querySelectorAll('.type-option').forEach(option => {
322
+ option.addEventListener('click', function() {
323
+ // إزالة الفئة النشطة من جميع الخيارات
324
+ document.querySelectorAll('.type-option').forEach(opt => {
325
+ opt.classList.remove('active');
326
+ });
327
+
328
+ // إضافة الفئة النشطة للخيار المحدد
329
+ this.classList.add('active');
330
+
331
+ // إخفاء جميع النماذج
332
+ document.querySelectorAll('.contract-template').forEach(template => {
333
+ template.classList.add('hidden');
334
+ });
335
+
336
+ // إظهار النموذج المحدد
337
+ const templateId = this.dataset.type === 'rental' ? 'rentalTemplate' : 'customTemplate';
338
+
339
+ // إظهار النموذج المحدد مع تأثير حركي
340
+ const selectedTemplate = document.getElementById(templateId);
341
+ selectedTemplate.classList.remove('hidden');
342
+ selectedTemplate.classList.add('animate__animated', 'animate__fadeIn');
343
+ });
344
+ });
345
+
346
+ // نسخ العقد إلى الحافظة
347
+ document.getElementById('copyButton').addEventListener('click', async function() {
348
+ const contractText = document.getElementById('contractOutput').innerText;
349
+
350
+ try {
351
+ await navigator.clipboard.writeText(contractText);
352
+
353
+ // إظهار رسالة نجاح
354
+ const successMessage = document.createElement('div');
355
+ successMessage.className = 'success-message animate__animated animate__fadeIn';
356
+ successMessage.textContent = 'تم نسخ العقد بنجاح!';
357
+ document.body.appendChild(successMessage);
358
+
359
+ // إزالة رسالة النجاح بعد ثانيتين
360
+ setTimeout(() => {
361
+ successMessage.classList.add('animate__fadeOut');
362
+ setTimeout(() => successMessage.remove(), 300);
363
+ }, 2000);
364
+
365
+ } catch (err) {
366
+ console.error('فشل نسخ النص: ', err);
367
+ }
368
+ });
369
+
370
+ // تحسين عملية إنشاء العقد
371
+ document.getElementById('generateButton').addEventListener('click', async function() {
372
+ const button = this;
373
+ const outputDiv = document.getElementById('contractOutput');
374
+ const contractType = document.querySelector('.type-option.active').dataset.type;
375
+ let prompt = '';
376
+
377
+ // تجميع البيانات حسب نوع العقد
378
+ if (contractType === 'rental') {
379
+ const formData = {
380
+ landlord: document.getElementById('landlord').value,
381
+ tenant: document.getElementById('tenant').value,
382
+ propertyAddress: document.getElementById('propertyAddress').value,
383
+ rentalPeriod: document.getElementById('rentalPeriod').value,
384
+ rentalAmount: document.getElementById('rentalAmount').value,
385
+ additionalTerms: document.getElementById('additionalTerms').value
386
+ };
387
+
388
+ // التحقق من البيانات المطلوبة
389
+ const requiredFields = ['landlord', 'tenant', 'propertyAddress', 'rentalPeriod', 'rentalAmount'];
390
+ const missingFields = requiredFields.filter(field => !formData[field]);
391
+
392
+ if (missingFields.length > 0) {
393
+ outputDiv.innerHTML = `
394
+ <div class="text-red-500 font-bold mb-4">يرجى ملء الحقول التالية:</div>
395
+ <ul class="list-disc list-inside text-red-500">
396
+ ${missingFields.map(field => `<li>${getFieldLabel(field)}</li>`).join('')}
397
+ </ul>
398
+ `;
399
+ return;
400
+ }
401
+
402
+ prompt = `أنشئ عقد إيجار رسمي باللغة العربية يتضمن البيانات التالية:
403
+ المؤجر: ${formData.landlord}
404
+ المستأجر: ${formData.tenant}
405
+ عنوان العقار: ${formData.propertyAddress}
406
+ مدة الإيجار: ${formData.rentalPeriod}
407
+ قيمة الإيجار: ${formData.rentalAmount}
408
+ ${formData.additionalTerms ? `شروط إضافية: ${formData.additionalTerms}` : ''}
409
+
410
+ يجب أن يكون العقد شاملاً وقانونياً ويحتوي على كافة البنود الأساسية المتعارف عليها في عقود الإيجار.`;
411
+ } else {
412
+ const formData = {
413
+ title: document.getElementById('contractTitle').value,
414
+ firstParty: document.getElementById('firstParty').value,
415
+ secondParty: document.getElementById('secondParty').value,
416
+ details: document.getElementById('contractDetails').value
417
+ };
418
+
419
+ // التحقق من البيانات المطلوبة
420
+ const requiredFields = ['title', 'firstParty', 'secondParty', 'details'];
421
+ const missingFields = requiredFields.filter(field => !formData[field]);
422
+
423
+ if (missingFields.length > 0) {
424
+ outputDiv.innerHTML = `
425
+ <div class="text-red-500 font-bold mb-4">يرجى ملء الحقول التالية:</div>
426
+ <ul class="list-disc list-inside text-red-500">
427
+ ${missingFields.map(field => `<li>${getFieldLabel(field)}</li>`).join('')}
428
+ </ul>
429
+ `;
430
+ return;
431
+ }
432
+
433
+ prompt = `أنشئ عقداً مخصصاً باللغة العربية يتضمن البيانات التالية:
434
+ عنوان العقد: ${formData.title}
435
+ الطرف الأول: ${formData.firstParty}
436
+ الطرف الثاني: ${formData.secondParty}
437
+ تفاصيل العقد: ${formData.details}
438
+
439
+ يجب أن يكون العقد رسمياً وقانونياً ومنظماً بشكل احترافي.`;
440
+ }
441
+
442
+ if (currentController) {
443
+ currentController.abort();
444
+ currentController = null;
445
+ button.textContent = 'إنشاء العقد';
446
+ button.classList.remove('loading');
447
+ return;
448
+ }
449
+
450
+ try {
451
+ // تحديث واجهة المستخدم لحالة التحميل
452
+ button.textContent = 'إيقاف الإنشاء';
453
+ button.classList.add('loading');
454
+ outputDiv.innerHTML = `
455
+ <div class="flex items-center justify-center space-x-4 text-gray-600">
456
+ <div class="animate-spin rounded-full h-8 w-8 border-b-2 border-blue-600"></div>
457
+ <span>جاري إنشاء العقد...</span>
458
+ </div>
459
+ `;
460
+
461
+ currentController = new AbortController();
462
+
463
+ const response = await fetch(API_URL, {
464
+ method: 'POST',
465
+ headers: { 'Content-Type': 'application/json' },
466
+ body: JSON.stringify({
467
+ message: prompt,
468
+ history: []
469
+ }),
470
+ signal: currentController.signal
471
+ });
472
+
473
+ const data = await response.json();
474
+ outputDiv.innerHTML = data.response.replace(/\n/g, '<br>');
475
+ outputDiv.classList.add('animate__animated', 'animate__fadeIn');
476
+
477
+ } catch (error) {
478
+ if (error.name === 'AbortError') {
479
+ outputDiv.innerHTML = `
480
+ <div class="text-yellow-600 font-bold">
481
+ تم إيقاف إنشاء العقد
482
+ </div>
483
+ `;
484
+ } else {
485
+ outputDiv.innerHTML = `
486
+ <div class="text-red-600 font-bold">
487
+ عذراً، حدث خطأ في إنشاء العقد. يرجى المحاولة مرة أخرى.
488
+ </div>
489
+ `;
490
+ }
491
+ } finally {
492
+ currentController = null;
493
+ button.textContent = 'إنشاء العقد';
494
+ button.classList.remove('loading');
495
+ }
496
+ });
497
+
498
+ // دالة مساعدة للحصول على تسميات الحقول بالعربية
499
+ function getFieldLabel(field) {
500
+ const labels = {
501
+ landlord: 'المؤجر',
502
+ tenant: 'المستأجر',
503
+ propertyAddress: 'عنوان العقار',
504
+ rentalPeriod: 'مدة الإيجار',
505
+ rentalAmount: 'قيمة الإيجار',
506
+ title: 'عنوان العقد',
507
+ firstParty: 'الطرف الأول',
508
+ secondParty: 'الطرف الثاني',
509
+ details: 'تفاصيل العقد'
510
+ };
511
+ return labels[field] || field;
512
+ }
513
+
514
+ // إضافة تأثيرات حركية عند التمرير
515
+ const cards = document.querySelectorAll('.card');
516
+ window.addEventListener('scroll', () => {
517
+ cards.forEach(card => {
518
+ const rect = card.getBoundingClientRect();
519
+ const isVisible = rect.top < window.innerHeight && rect.bottom >= 0;
520
+
521
+ if (isVisible) {
522
+ card.style.transform = 'translateY(-4px)';
523
+ } else {
524
+ card.style.transform = 'translateY(0)';
525
+ }
526
+ });
527
+ });
528
+ </script>
529
+ </body>
530
+ </html>