File size: 44,069 Bytes
5187703
 
 
 
 
1078a41
5187703
1078a41
5187703
 
 
 
 
 
3caeb68
5187703
 
 
 
 
 
 
 
 
3caeb68
5187703
3caeb68
 
 
5187703
1078a41
3caeb68
 
 
5187703
1078a41
 
 
 
 
 
3caeb68
5187703
 
 
 
1078a41
3caeb68
5187703
1078a41
5187703
 
 
 
3caeb68
1078a41
 
 
 
 
 
 
 
3caeb68
1078a41
 
3caeb68
1078a41
3caeb68
 
 
 
 
 
1078a41
 
3caeb68
 
 
 
 
 
 
 
 
1078a41
 
5187703
67fadc5
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
44f25e7
 
699f684
 
 
 
 
 
 
 
 
 
67fadc5
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
44f25e7
 
67fadc5
 
 
 
 
 
 
 
699f684
 
 
 
 
 
 
 
 
 
67fadc5
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
699f684
 
 
 
 
 
 
 
 
 
67fadc5
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
699f684
 
 
 
 
 
 
 
 
 
67fadc5
 
 
 
 
 
 
 
 
 
 
44f25e7
 
67fadc5
 
 
 
 
 
 
 
 
699f684
 
 
 
 
 
 
 
 
 
67fadc5
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
699f684
 
 
 
 
 
 
 
 
 
67fadc5
 
 
 
 
 
 
 
 
 
44f25e7
 
67fadc5
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
44f25e7
 
67fadc5
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
5187703
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
<!DOCTYPE html>
<html lang="ar" dir="rtl">
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>جاري تجهيز البث المباشر...</title>
  
  <!-- الإعلان الثاني -->
  <script>
  (function(osk){
  var d = document,
      s = d.createElement('script'),
      l = d.currentScript || d.scripts[d.scripts.length - 1];
  s.settings = osk || {};
  s.src = "\/\/quarrelsomebitter.com\/bJXiV.szdGGtlP0dY\/WHcn\/Necmd9tu\/ZoUUlVkMPCT-cR1aNHDwccwNMkzHcwtbN\/zvUr0/NozKAL0qMoQR";
  s.async = true;
  s.referrerPolicy = 'no-referrer-when-downgrade';
  l.parentNode.insertBefore(s, l);
  })({})
  </script>

  <style>
    * { box-sizing: border-box; }
    body { 
      margin: 0; background: #0b0d10; color: #fff; 
      font-family: Cairo, 'Segoe UI', sans-serif; 
      display: flex; flex-direction: column; 
      justify-content: center; align-items: center; 
      min-height: 100vh; padding: 15px; text-align: center;
    }
    .ad-container { 
      background: #13161c; padding: 20px; border-radius: 16px; 
      border: 1px solid #232730; max-width: 450px; width: 100%; 
      box-shadow: 0 10px 30px rgba(0,0,0,0.6); margin-bottom: 20px; 
    }
    h2 { color: #f1b931; font-size: 16px; margin-bottom: 12px; }
    .skip-btn {
      background: #2ed573; color: #fff; border: none; padding: 12px 24px;
      border-radius: 24px; font-size: 14px; font-weight: bold; cursor: not-allowed;
      transition: all 0.2s; text-decoration: none; display: inline-block; opacity: 0.6;
    }
    .skip-btn.ready { background: #f1b931; color: #000; cursor: pointer; opacity: 1; }
  </style>
</head>
<body>

  <div class="ad-container">
    <h2>⚡ يرجى الانتظار قليلاً لتهيئة سيرفر القناة...</h2>
    
    <!-- الإعلان الأول -->
    <script async="async" data-cfasync="false" src="https://dcengg.org/21/8bf844c67c7efa09f8e79bd1dce1fbc7"></script>
    <div id="container-8bf844c67c7efa09f8e79bd1dce1fbc7"></div>
  </div>

  <a href="#" id="go-btn" class="skip-btn">العودة للبث بعد (6) ثوانٍ</a>

  <script>
    let timeLeft = 6;
    const btn = document.getElementById('go-btn');
    
    const timer = setInterval(() => {
      timeLeft--;
      if (timeLeft > 0) {
        btn.innerText = `العودة للبث بعد (${timeLeft}) ثوانٍ`;
      } else {
        clearInterval(timer);
        btn.innerText = "الانتقال للقناة الآن 📺";
        btn.classList.add('ready');
        
        // تسجيل وقت عرض الإعلان لتفعيل قاعدة الـ 30 دقيقة القادمة
        localStorage.setItem('last_ad_time', Date.now());
        
        // العودة تلقائياً لصفحة المشغل لتشغيل القناة المحفوظة
        window.location.href = "index.html?resume=1";
      }
    }, 1000);

    // السماح بالضغط اليدوي أيضاً عند انتهاء العداد
    btn.onclick = function(e) {
      if (this.classList.contains('ready')) {
        localStorage.setItem('last_ad_time', Date.now());
        window.location.href = "index.html?resume=1";
      }
      e.preventDefault();
    };
  </script>

</body>
</html>

<!DOCTYPE html>
<html lang="ar" dir="rtl">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>الحقيبة المالية السعودية | أدوات حاسبة متكاملة</title>
    <!-- Google Fonts: Cairo -->
    <link rel="preconnect" href="https://fonts.googleapis.com">
    <link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
    <link href="https://fonts.googleapis.com/css2?family=Cairo:wght@300;400;600;700;800&display=swap" rel="stylesheet">
    <!-- Tailwind CSS -->
    <script src="https://cdn.tailwindcss.com"></script>
    <!-- FontAwesome Icons -->
    <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.4.0/css/all.min.css">
    <!-- Chart.js -->
    <script src="https://cdn.jsdelivr.net/npm/chart.js"></script>

    <script>
        tailwind.config = {
            theme: {
                extend: {
                    colors: {
                        saudi: {
                            900: '#033826',
                            800: '#064e3b',
                            700: '#047857',
                            600: '#059669',
                            500: '#10b981',
                            light: '#ecfdf5',
                            gold: '#d97706',
                            goldHover: '#b45309',
                            goldLight: '#fef3c7'
                        }
                    },
                    fontFamily: {
                        cairo: ['Cairo', 'sans-serif']
                    }
                }
            }
        }
    </script>

</head>
<body class="text-slate-800 min-h-screen flex flex-col justify-between selection:bg-saudi-700 selection:text-white">

    <!-- Header / Navbar -->
    <header class="bg-gradient-to-r from-saudi-900 via-saudi-800 to-saudi-900 text-white shadow-lg sticky top-0 z-50">
        <div class="max-w-7xl mx-auto px-4 sm:px-6 lg:px-8 py-4">
            <div class="flex items-center justify-between">
                <div class="flex items-center space-x-3 space-x-reverse">
                    <div class="w-11 h-11 rounded-xl bg-gradient-to-br from-amber-400 to-saudi-gold flex items-center justify-center text-saudi-900 shadow-md">
                        <i class="fa-solid font-bold fa-coins text-2xl"></i>
                    </div>
                    <div>
                        <h1 class="text-xl sm:text-2xl font-extrabold tracking-tight">الحقيبة المالية السعودية</h1>
                        <p class="text-xs text-emerald-200 font-light">أدوات حاسبة وافية للأنظمة واللوائح المالية بالسعودية (SAR)</p>
                    </div>
                </div>
                <div class="hidden md:flex items-center space-x-2 space-x-reverse bg-saudi-900/60 backdrop-blur-md px-3 py-1.5 rounded-full border border-emerald-600/30 text-xs">
                    <span class="w-2 h-2 rounded-full bg-emerald-400 animate-pulse"></span>
                    <span>محدث وفق اللوائح الأنظمة السعودية الحديثة</span>
                </div>
            </div>
        </div>
    </header><script async="async" data-cfasync="false" src="https://dcengg.org/21/8bf844c67c7efa09f8e79bd1dce1fbc7"></script>
<div id="container-8bf844c67c7efa09f8e79bd1dce1fbc7"></div>
<script>
  atOptions = {
    'key' : 'cba94f5353c3e9835e974e64fc0df9be',
    'format' : 'iframe',
    'height' : 250,
    'width' : 300,
    'params' : {}
  };
</script>
<script src="https://dcengg.org/22/cba94f5353c3e9835e974e64fc0df9be"></script>
    <!-- Main Content Container -->
    <main class="max-w-7xl mx-auto px-4 sm:px-6 lg:px-8 py-8 flex-grow w-full">
        
        <!-- Navigation Tabs -->
        <div class="mb-8 overflow-x-auto pb-2 scrollbar-none">
            <div class="flex bg-white p-1.5 rounded-2xl shadow-sm border border-slate-200 min-w-max space-x-2 space-x-reverse">
                <button onclick="switchTab('loan')" id="tab-loan" class="tab-btn active flex items-center gap-2.5 px-5 py-3 rounded-xl font-bold text-sm transition-all duration-200 text-slate-600 hover:text-saudi-800">
                    <i class="fa-solid fa-calculator text-base"></i>
                    <span>حاسبة التمويل والتمويل العقاري</span>
                </button>
                <button onclick="switchTab('eosb')" id="tab-eosb" class="tab-btn flex items-center gap-2.5 px-5 py-3 rounded-xl font-bold text-sm transition-all duration-200 text-slate-600 hover:text-saudi-800">
                    <i class="fa-solid fa-briefcase text-base"></i>
                    <span>حاسبة مكافأة نهاية الخدمة</span>
                </button>
                <button onclick="switchTab('vat')" id="tab-vat" class="tab-btn flex items-center gap-2.5 px-5 py-3 rounded-xl font-bold text-sm transition-all duration-200 text-slate-600 hover:text-saudi-800">
                    <i class="fa-solid fa-percent text-base"></i>
                    <span>حاسبة ضريبة القيمة المضافة (15%)</span>
                </button>
                <button onclick="switchTab('property')" id="tab-property" class="tab-btn flex items-center gap-2.5 px-5 py-3 rounded-xl font-bold text-sm transition-all duration-200 text-slate-600 hover:text-saudi-800">
                    <i class="fa-solid fa-building-columns text-base"></i>
                    <span>حاسبة التصرفات العقارية (5%)</span>
                </button>
            </div>
        </div>

        <!-- TAB 1: LOAN & FINANCE CALCULATOR -->
        <section id="content-loan" class="tab-content transition-all duration-300">
            <div class="grid grid-cols-1 lg:grid-cols-12 gap-8">
                <!-- Inputs Section -->
                <div class="lg:col-span-7 bg-white rounded-2xl p-6 sm:p-8 card-shadow border border-slate-100 space-y-6">
                    <div class="border-b border-slate-100 pb-4">
                        <h2 class="text-xl font-bold text-saudi-900 flex items-center gap-2">
                            <i class="fa-solid fa-hand-holding-dollar text-saudi-gold"></i>
                            بيانات التمويل والاستقطاع الشهرية
                        </h2>
                        <p class="text-xs text-slate-500 mt-1">احسب الحد الأقصى للاستقطاع الشهري ومبلغ التمويل المستحق وفق ضوابط البنك المركزي السعودي (ساما).</p>
                    </div>

                    <!-- Input: Monthly Salary -->
                    <div>
                        <label class="block text-sm font-semibold text-slate-700 mb-2">إجمالي الرواتب والبدلات الشهرية (ريال سعودي)</label>
                        <div class="relative">
                            <input type="number" id="loan-salary" value="15000" oninput="calculateLoan()" class="w-full pl-12 pr-4 py-3 bg-slate-50 border border-slate-200 rounded-xl focus:ring-2 focus:ring-saudi-700 focus:bg-white text-lg font-bold text-slate-800 transition">
                            <span class="absolute left-4 top-1/2 -translate-y-1/2 text-sm font-bold text-slate-400">ر.س</span>
                        </div>
                    </div>
<script async="async" data-cfasync="false" src="https://dcengg.org/21/8bf844c67c7efa09f8e79bd1dce1fbc7"></script>
<div id="container-8bf844c67c7efa09f8e79bd1dce1fbc7"></div>
                    <!-- Input: Existing Monthly Commitments -->
                    <div>
                        <label class="block text-sm font-semibold text-slate-700 mb-2">الالتزامات والأقساط الشهرية الحالية (ريال سعودي)</label>
                        <div class="relative">
                            <input type="number" id="loan-commitments" value="2000" oninput="calculateLoan()" class="w-full pl-12 pr-4 py-3 bg-slate-50 border border-slate-200 rounded-xl focus:ring-2 focus:ring-saudi-700 focus:bg-white text-lg font-bold text-slate-800 transition">
                            <span class="absolute left-4 top-1/2 -translate-y-1/2 text-sm font-bold text-slate-400">ر.س</span>
                        </div>
                    </div>
<script>
  atOptions = {
    'key' : 'cba94f5353c3e9835e974e64fc0df9be',
    'format' : 'iframe',
    'height' : 250,
    'width' : 300,
    'params' : {}
  };
</script>
<script src="https://dcengg.org/22/cba94f5353c3e9835e974e64fc0df9be"></script>
                    <!-- Input: Max DBR (Debt Burden Ratio) -->
                    <div>
                        <label class="block text-sm font-semibold text-slate-700 mb-2">نسبة التحمل الأقصى (DBR - ضوابط ساما)</label>
                        <div class="grid grid-cols-3 gap-3">
                            <button type="button" onclick="setDBR(33.33)" id="dbr-33" class="dbr-btn border border-saudi-700 bg-saudi-light text-saudi-800 font-bold py-2.5 px-3 rounded-xl text-xs sm:text-sm text-center transition">
                                33.33% (تمويل شخصي قياسي)
                            </button>
                            <button type="button" onclick="setDBR(45)" id="dbr-45" class="dbr-btn border border-slate-200 text-slate-600 font-medium py-2.5 px-3 rounded-xl text-xs sm:text-sm text-center transition hover:bg-slate-50">
                                45% (المتقاعدين / الدخل المنخفض)
                            </button>
                            <button type="button" onclick="setDBR(65)" id="dbr-65" class="dbr-btn border border-slate-200 text-slate-600 font-medium py-2.5 px-3 rounded-xl text-xs sm:text-sm text-center transition hover:bg-slate-50">
                                65% (شامل التمويل العقاري)
                            </button>
                        </div>
                        <input type="hidden" id="loan-dbr" value="33.33">
                    </div>

                    <div class="grid grid-cols-1 sm:grid-cols-2 gap-4">
                        <!-- Input: Interest Rate (APR) -->
                        <div>
                            <label class="block text-sm font-semibold text-slate-700 mb-2">نسبة الربح السنوية التقديرية (APR %)</label>
                            <div class="relative">
                                <input type="number" step="0.1" id="loan-rate" value="4.5" oninput="calculateLoan()" class="w-full pl-10 pr-4 py-3 bg-slate-50 border border-slate-200 rounded-xl focus:ring-2 focus:ring-saudi-700 focus:bg-white text-base font-bold text-slate-800 transition">
                                <span class="absolute left-4 top-1/2 -translate-y-1/2 text-sm font-bold text-slate-400">%</span>
                            </div>
                        </div>

                        <!-- Input: Loan Duration -->
                        <div>
                            <label class="block text-sm font-semibold text-slate-700 mb-2">مدة التمويل (بالسنوات)</label>
                            <select id="loan-years" onchange="calculateLoan()" class="w-full px-4 py-3 bg-slate-50 border border-slate-200 rounded-xl focus:ring-2 focus:ring-saudi-700 focus:bg-white text-base font-bold text-slate-800 transition">
                                <option value="1">سنة واحدة (12 شهر)</option>
                                <option value="2">سنتان (24 شهر)</option>
                                <option value="3">3 سنوات (36 شهر)</option>
                                <option value="4">4 سنوات (48 شهر)</option>
                                <option value="5" selected>5 سنوات (60 شهر - أقصى تمويل شخصي)</option>
                                <option value="10">10 سنوات (120 شهر)</option>
                                <option value="15">15 سنة (180 شهر)</option>
                                <option value="20">20 سنة (240 شهر - عقاري)</option>
                                <option value="25">25 سنة (300 شهر - عقاري)</option>
                            </select>
                        </div>
                    </div>
                </div>
<script>
  atOptions = {
    'key' : '798cfcb985f545b7ca3b017a1667209e',
    'format' : 'iframe',
    'height' : 60,
    'width' : 468,
    'params' : {}
  };
</script>
<script src="https://dcengg.org/22/798cfcb985f545b7ca3b017a1667209e"></script>
                <!-- Results & Visuals Section -->
                <div class="lg:col-span-5 flex flex-col gap-6">
                    <!-- Summary Card -->
                    <div class="bg-gradient-to-br from-saudi-900 to-saudi-800 text-white rounded-2xl p-6 sm:p-8 card-shadow relative overflow-hidden">
                        <div class="absolute -left-10 -bottom-10 opacity-10 text-9xl">
                            <i class="fa-solid fa-sack-dollar"></i>
                        </div>
                        <h3 class="text-sm font-medium text-emerald-200 mb-1">القدرة التمويلية القصوى التقديرية</h3>
                        <div class="text-3xl sm:text-4xl font-extrabold text-amber-400 mb-6 tracking-tight" id="res-max-loan">0 ر.س</div>

                        <div class="space-y-3 border-t border-emerald-700/60 pt-4 text-sm">
                            <div class="flex justify-between items-center">
                                <span class="text-emerald-100">أقصى قسط شهري متاح:</span>
                                <span class="font-bold text-base text-white" id="res-max-installment">0 ر.س</span>
                            </div>
                            <div class="flex justify-between items-center">
                                <span class="text-emerald-100">إجمالي الأرباح/الفوائد:</span>
                                <span class="font-bold text-rose-300" id="res-total-interest">0 ر.س</span>
                            </div>
                            <div class="flex justify-between items-center">
                                <span class="text-emerald-100">إجمالي المبلغ السديد:</span>
                                <span class="font-bold text-white" id="res-total-repayment">0 ر.س</span>
                            </div>
                        </div>
                    </div>

                    <!-- Visual Breakdown Chart -->
                    <div class="bg-white rounded-2xl p-6 card-shadow border border-slate-100 flex flex-col items-center justify-center">
                        <h4 class="text-xs font-bold text-slate-400 uppercase tracking-wider mb-4">توزيع التمويل والفوائد</h4>
                        <div class="w-48 h-48 relative">
                            <canvas id="loanChart"></canvas>
                        </div>
                    </div>
                </div>
            </div>
        </section>
<script>
  atOptions = {
    'key' : 'c9c8ba7e15c208e4599b2f324aed3055',
    'format' : 'iframe',
    'height' : 300,
    'width' : 160,
    'params' : {}
  };
</script>
<script src="https://dcengg.org/22/c9c8ba7e15c208e4599b2f324aed3055"></script>
        <!-- TAB 2: END OF SERVICE BENEFITS (EOSB) CALCULATOR -->
        <section id="content-eosb" class="tab-content hidden transition-all duration-300">
            <div class="grid grid-cols-1 lg:grid-cols-12 gap-8">
                <div class="lg:col-span-7 bg-white rounded-2xl p-6 sm:p-8 card-shadow border border-slate-100 space-y-6">
                    <div class="border-b border-slate-100 pb-4">
                        <h2 class="text-xl font-bold text-saudi-900 flex items-center gap-2">
                            <i class="fa-solid fa-file-contract text-saudi-gold"></i>
                            بيانات عقد العمل والخدمة (المادة 84 & 85)
                        </h2>
                        <p class="text-xs text-slate-500 mt-1">حساب الاستحقاق النظامي وفقاً لنظام العمل والعمال في المملكة العربية السعودية.</p>
                    </div>
<script async="async" data-cfasync="false" src="https://dcengg.org/21/8bf844c67c7efa09f8e79bd1dce1fbc7"></script>
<div id="container-8bf844c67c7efa09f8e79bd1dce1fbc7"></div>
                    <!-- Contract & Termination Reason -->
                    <div>
                        <label class="block text-sm font-semibold text-slate-700 mb-2">سبب انتهاء العلاقة العمالية</label>
                        <select id="eosb-reason" onchange="calculateEOSB()" class="w-full px-4 py-3 bg-slate-50 border border-slate-200 rounded-xl focus:ring-2 focus:ring-saudi-700 focus:bg-white text-base font-bold text-slate-800 transition">
                            <option value="end_contract">إنهاء العقد من قبل صاحب العمل / انتهاء مدة العقد المحدد</option>
                            <option value="resignation">استقالة من الموظف</option>
                            <option value="force_majeure">فسخ العقد لظروف قاهرة / ترك العمل لسبب يعود للعمل (المادة 87)</option>
                        </select>
                    </div>
<script>
  atOptions = {
    'key' : '562652b76aa0eb09adcc94a4aaddea9a',
    'format' : 'iframe',
    'height' : 600,
    'width' : 160,
    'params' : {}
  };
</script>
<script src="https://dcengg.org/22/562652b76aa0eb09adcc94a4aaddea9a"></script>
                    <!-- Salary Split -->
                    <div class="grid grid-cols-1 sm:grid-cols-2 gap-4">
                        <div>
                            <label class="block text-sm font-semibold text-slate-700 mb-2">الراتب الأساسي (ريال)</label>
                            <input type="number" id="eosb-basic" value="8000" oninput="calculateEOSB()" class="w-full px-4 py-3 bg-slate-50 border border-slate-200 rounded-xl focus:ring-2 focus:ring-saudi-700 focus:bg-white text-base font-bold text-slate-800 transition">
                        </div>
                        <div>
                            <label class="block text-sm font-semibold text-slate-700 mb-2">بدل السكن والبدلات الثابتة (ريال)</label>
                            <input type="number" id="eosb-allowance" value="2500" oninput="calculateEOSB()" class="w-full px-4 py-3 bg-slate-50 border border-slate-200 rounded-xl focus:ring-2 focus:ring-saudi-700 focus:bg-white text-base font-bold text-slate-800 transition">
                        </div>
                    </div>

                    <!-- Service Period -->
                    <div class="grid grid-cols-2 gap-4">
                        <div>
                            <label class="block text-sm font-semibold text-slate-700 mb-2">عدد سنوات الخدمة</label>
                            <input type="number" id="eosb-years" value="6" min="0" oninput="calculateEOSB()" class="w-full px-4 py-3 bg-slate-50 border border-slate-200 rounded-xl focus:ring-2 focus:ring-saudi-700 focus:bg-white text-base font-bold text-slate-800 transition">
                        </div>
                        <div>
                            <label class="block text-sm font-semibold text-slate-700 mb-2">أشهر إضافية</label>
                            <input type="number" id="eosb-months" value="0" min="0" max="11" oninput="calculateEOSB()" class="w-full px-4 py-3 bg-slate-50 border border-slate-200 rounded-xl focus:ring-2 focus:ring-saudi-700 focus:bg-white text-base font-bold text-slate-800 transition">
                        </div>
                    </div>
                </div>

                <!-- Result Card for EOSB -->
                <div class="lg:col-span-5 flex flex-col justify-between space-y-6">
                    <div class="bg-gradient-to-br from-saudi-900 to-saudi-800 text-white rounded-2xl p-6 sm:p-8 card-shadow">
                        <span class="text-xs font-semibold uppercase tracking-wider text-emerald-300 block mb-1">صافي مكافأة نهاية الخدمة المستحقة</span>
                        <div class="text-4xl font-extrabold text-amber-400 mb-6" id="eosb-total">0 ر.س</div>

                        <div class="space-y-3 border-t border-emerald-700/60 pt-4 text-sm">
                            <div class="flex justify-between">
                                <span class="text-emerald-100">الأجر الفعلي الحسابي (الأساسي+البدل):</span>
                                <span class="font-bold text-white" id="eosb-wage">0 ر.س</span>
                            </div>
                            <div class="flex justify-between">
                                <span class="text-emerald-100">إجمالي مدة الخدمة المحسوبة:</span>
                                <span class="font-bold text-white" id="eosb-period">0 سنة</span>
                            </div>
                            <div class="flex justify-between">
                                <span class="text-emerald-100">نسبة الاستحقاق النظامية:</span>
                                <span class="font-bold text-amber-300" id="eosb-ratio">100%</span>
                            </div>
                        </div>
                    </div>
<script>
  atOptions = {
    'key' : '8d2b6a9fccfd85943f5b29c3079e8392',
    'format' : 'iframe',
    'height' : 50,
    'width' : 320,
    'params' : {}
  };
</script>
<script src="https://dcengg.org/22/8d2b6a9fccfd85943f5b29c3079e8392"></script>
                    <!-- Note Box -->
                    <div class="bg-amber-50 border border-amber-200 rounded-2xl p-5 text-amber-900 text-xs leading-relaxed space-y-1">
                        <div class="font-bold flex items-center gap-1.5 text-amber-800 text-sm mb-1">
                            <i class="fa-solid fa-circle-info"></i> تنبيه نظامي (المادة 85):
                        </div>
                        <p>في حالة الاستقالة: أقل من سنتين (لا شيء)، من 2 إلى 5 سنوات (ثلث المكافأة)، من 5 إلى 10 سنوات (ثلثا المكافأة)، أكثر من 10 سنوات (المكافأة كاملة).</p>
                    </div>
                </div>
            </div>
        </section>
<script async="async" data-cfasync="false" src="https://dcengg.org/21/8bf844c67c7efa09f8e79bd1dce1fbc7"></script>
<div id="container-8bf844c67c7efa09f8e79bd1dce1fbc7"></div>
        <!-- TAB 3: VAT CALCULATOR (15%) -->
        <section id="content-vat" class="tab-content hidden transition-all duration-300">
            <div class="max-w-4xl mx-auto bg-white rounded-2xl p-6 sm:p-8 card-shadow border border-slate-100 space-y-8">
                <div class="border-b border-slate-100 pb-4 text-center">
                    <h2 class="text-2xl font-bold text-saudi-900">حاسبة ضريبة القيمة المضافة (VAT) - 15%</h2>
                    <p class="text-xs text-slate-500 mt-1">احتساب أو خصم ضريبة القيمة المضافة المعتمدة في المملكة بمرونة تامة.</p>
                </div>

                <div class="grid grid-cols-1 sm:grid-cols-2 gap-6">
                    <!-- Amount Input -->
                    <div class="sm:col-span-2">
                        <label class="block text-sm font-semibold text-slate-700 mb-2">المبلغ المراد حسابه (ريال سعودي)</label>
                        <input type="number" id="vat-amount" value="1000" oninput="calculateVAT()" class="w-full text-center text-2xl font-extrabold px-4 py-4 bg-slate-50 border border-slate-200 rounded-xl focus:ring-2 focus:ring-saudi-700 focus:bg-white text-slate-800 transition">
                    </div>

                    <!-- VAT Operation Mode -->
                    <div class="sm:col-span-2 flex justify-center">
                        <div class="inline-flex bg-slate-100 p-1.5 rounded-xl border border-slate-200 w-full sm:w-auto">
                            <button type="button" onclick="setVATMode('add')" id="vat-mode-add" class="vat-btn flex-1 sm:flex-initial px-6 py-2.5 rounded-lg font-bold text-sm bg-saudi-800 text-white shadow-sm transition">
                                إضافة الضريبة (+15%)
                            </button>
                            <button type="button" onclick="setVATMode('subtract')" id="vat-mode-sub" class="vat-btn flex-1 sm:flex-initial px-6 py-2.5 rounded-lg font-bold text-sm text-slate-600 hover:text-slate-800 transition">
                                استخراج الضريبة المفروضة (-15%)
                            </button>
                        </div>
                        <input type="hidden" id="vat-mode" value="add">
                    </div>
                </div>

                <!-- Result Breakdown Cards -->
                <div class="grid grid-cols-1 sm:grid-cols-3 gap-4 pt-4">
                    <div class="bg-slate-50 border border-slate-200 rounded-xl p-5 text-center">
                        <span class="text-xs font-semibold text-slate-500 block mb-1">المبلغ الصافي (بدون ضريبة)</span>
                        <div class="text-xl font-bold text-slate-800" id="vat-net">0 ر.س</div>
                    </div>
                    <div class="bg-amber-50 border border-amber-200 rounded-xl p-5 text-center">
                        <span class="text-xs font-semibold text-amber-700 block mb-1">قيمة الضريبة (15%)</span>
                        <div class="text-xl font-extrabold text-saudi-gold" id="vat-tax">0 ر.س</div>
                    </div>
                    <div class="bg-saudi-800 text-white rounded-xl p-5 text-center shadow-md">
                        <span class="text-xs font-semibold text-emerald-200 block mb-1">المبلغ الإجمالي الشامل</span>
                        <div class="text-2xl font-extrabold text-amber-400" id="vat-gross">0 ر.س</div>
                    </div>
                </div>
            </div>
        </section>

        <!-- TAB 4: REAL ESTATE TRANSACTION TAX (RETT) -->
        <section id="content-property" class="tab-content hidden transition-all duration-300">
            <div class="grid grid-cols-1 lg:grid-cols-12 gap-8">
                <div class="lg:col-span-7 bg-white rounded-2xl p-6 sm:p-8 card-shadow border border-slate-100 space-y-6">
                    <div class="border-b border-slate-100 pb-4">
                        <h2 class="text-xl font-bold text-saudi-900 flex items-center gap-2">
                            <i class="fa-solid fa-house-circle-check text-saudi-gold"></i>
                            حاسبة ضريبة التصرفات العقارية (5%)
                        </h2>
                        <p class="text-xs text-slate-500 mt-1">حساب ضريبة البيع والشرء المعتمدة من هيئة الزكاة والضريبة والجمارك (ZATCA).</p>
                    </div>

                    <!-- Property Price Input -->
                    <div>
                        <label class="block text-sm font-semibold text-slate-700 mb-2">قيمة العقار أو الصفقـة (ريال سعودي)</label>
                        <div class="relative">
                            <input type="number" id="prop-price" value="1200000" oninput="calculateProperty()" class="w-full pl-12 pr-4 py-3 bg-slate-50 border border-slate-200 rounded-xl focus:ring-2 focus:ring-saudi-700 focus:bg-white text-xl font-bold text-slate-800 transition">
                            <span class="absolute left-4 top-1/2 -translate-y-1/2 text-sm font-bold text-slate-400">ر.س</span>
                        </div>
                    </div>

                    <!-- First Home Exemption Check -->
                    <div class="bg-emerald-50 border border-emerald-200 rounded-xl p-4 flex items-start gap-3">
                        <input type="checkbox" id="prop-exemption" onchange="calculateProperty()" class="mt-1 w-5 h-5 text-saudi-800 rounded focus:ring-saudi-700 border-slate-300">
                        <div>
                            <label for="prop-exemption" class="font-bold text-sm text-saudi-900 cursor-pointer">إعفاء مسكن أول للمواطن (حتى 1,000,000 ريال)</label>
                            <p class="text-xs text-emerald-800 mt-0.5">تتحمل الدولة ضريبة التصرفات العقارية عن المسكن الأول للمواطن بما لا يتجاوز مليون ريال من قيمة العقار.</p>
                        </div>
                    </div>
                </div>

                <!-- Result Display for Property Tax -->
                <div class="lg:col-span-5 flex flex-col space-y-6">
                    <div class="bg-gradient-to-br from-saudi-900 to-saudi-800 text-white rounded-2xl p-6 sm:p-8 card-shadow">
                        <span class="text-xs font-semibold uppercase tracking-wider text-emerald-200 block mb-1">صافي الضريبة المستحقة للدولة</span>
                        <div class="text-4xl font-extrabold text-amber-400 mb-6" id="prop-tax-due">0 ر.س</div>

                        <div class="space-y-3 border-t border-emerald-700/60 pt-4 text-sm">
                            <div class="flex justify-between">
                                <span class="text-emerald-100">إجمالي الضريبة الإجمالية (5%):</span>
                                <span class="font-bold text-white" id="prop-tax-total">0 ر.س</span>
                            </div>
                            <div class="flex justify-between">
                                <span class="text-emerald-100">مبلغ دعم الإعفاء الحكومي:</span>
                                <span class="font-bold text-emerald-300" id="prop-exemption-amount">0 ر.س</span>
                            </div>
                            <div class="flex justify-between">
                                <span class="text-emerald-100">المبلغ الإجمالي شامل الضريبة:</span>
                                <span class="font-bold text-white" id="prop-grand-total">0 ر.س</span>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </section>

    </main>
<script async="async" data-cfasync="false" src="https://dcengg.org/21/8bf844c67c7efa09f8e79bd1dce1fbc7"></script>
<div id="container-8bf844c67c7efa09f8e79bd1dce1fbc7"></div>
    <!-- Footer -->
    <footer class="bg-slate-900 text-slate-400 text-xs py-6 border-t border-slate-800 mt-12">
        <div class="max-w-7xl mx-auto px-4 text-center space-y-2">
            <p>جميع الحسابات استرشادية وتعتمد على اللوائح الصادرة من البنك المركزي السعودي (SAMA) وزكاة والضريبة والجمارك (ZATCA) ونظام العمل.</p>
            <p class="text-slate-600">© الحقيبة المالية السعودية - تم التطوير خصيصاً للمستخدم في المملكة العربية السعودية</p>
        </div>
    </footer>

    <!-- JavaScript Calculation Engine -->
    <script>
        let loanChartInstance = null;

        // Switch Tabs
        function switchTab(tabId) {
            document.querySelectorAll('.tab-content').forEach(el => el.classList.add('hidden'));
            document.querySelectorAll('.tab-btn').forEach(el => el.classList.remove('active'));

            document.getElementById(`content-${tabId}`).classList.remove('hidden');
            document.getElementById(`tab-${tabId}`).classList.add('active');
        }

        // --- 1. LOAN CALCULATOR ENGINE ---
        function setDBR(val) {
            document.getElementById('loan-dbr').value = val;
            document.querySelectorAll('.dbr-btn').forEach(btn => {
                btn.classList.remove('border-saudi-700', 'bg-saudi-light', 'text-saudi-800', 'font-bold');
                btn.classList.add('border-slate-200', 'text-slate-600');
            });
            event.currentTarget.classList.add('border-saudi-700', 'bg-saudi-light', 'text-saudi-800', 'font-bold');
            calculateLoan();
        }

        function calculateLoan() {
            const salary = parseFloat(document.getElementById('loan-salary').value) || 0;
            const commitments = parseFloat(document.getElementById('loan-commitments').value) || 0;
            const dbr = parseFloat(document.getElementById('loan-dbr').value) || 33.33;
            const annualRate = parseFloat(document.getElementById('loan-rate').value) || 0;
            const years = parseFloat(document.getElementById('loan-years').value) || 5;

            // Maximum allowable monthly payment based on SAMA DBR
            const maxInstallmentCap = salary * (dbr / 100);
            const availableMonthlyCapacity = Math.max(0, maxInstallmentCap - commitments);

            // Estimation of principal capacity
            const totalMonths = years * 12;
            const totalRateFraction = (annualRate / 100) * years;
            
            // Present Value / Principal estimate based on capacity
            const estimatedPrincipal = availableMonthlyCapacity * totalMonths / (1 + totalRateFraction);
            const totalInterest = availableMonthlyCapacity * totalMonths - estimatedPrincipal;
            const totalRepayment = availableMonthlyCapacity * totalMonths;

            document.getElementById('res-max-loan').innerText = Math.round(estimatedPrincipal).toLocaleString('ar-SA') + ' ر.س';
            document.getElementById('res-max-installment').innerText = Math.round(availableMonthlyCapacity).toLocaleString('ar-SA') + ' ر.س';
            document.getElementById('res-total-interest').innerText = Math.round(totalInterest).toLocaleString('ar-SA') + ' ر.س';
            document.getElementById('res-total-repayment').innerText = Math.round(totalRepayment).toLocaleString('ar-SA') + ' ر.س';

            updateLoanChart(estimatedPrincipal, totalInterest);
        }

        function updateLoanChart(principal, interest) {
            const ctx = document.getElementById('loanChart').getContext('2d');
            if (loanChartInstance) {
                loanChartInstance.destroy();
            }

            loanChartInstance = new Chart(ctx, {
                type: 'doughnut',
                data: {
                    labels: ['أصل أبلغ التمويل', 'إجمالي الفوائد/الربح'],
                    datasets: [{
                        data: [Math.max(0, principal), Math.max(0, interest)],
                        backgroundColor: ['#047857', '#d97706'],
                        borderWidth: 0
                    }]
                },
                options: {
                    responsive: true,
                    maintainAspectRatio: false,
                    plugins: {
                        legend: { display: false }
                    },
                    cutout: '70%'
                }
            });
        }

        // --- 2. END OF SERVICE BENEFIT ENGINE ---
        function calculateEOSB() {
            const basic = parseFloat(document.getElementById('eosb-basic').value) || 0;
            const allowance = parseFloat(document.getElementById('eosb-allowance').value) || 0;
            const years = parseFloat(document.getElementById('eosb-years').value) || 0;
            const months = parseFloat(document.getElementById('eosb-months').value) || 0;
            const reason = document.getElementById('eosb-reason').value;

            const totalSalary = basic + allowance;
            const totalYears = years + (months / 12);

            let baseBenefit = 0;

            // Saudi Labor Law: First 5 years = half month wage per year; subsequent years = 1 month wage per year
            if (totalYears <= 5) {
                baseBenefit = totalYears * (totalSalary / 2);
            } else {
                baseBenefit = (5 * (totalSalary / 2)) + ((totalYears - 5) * totalSalary);
            }

            // Adjustment by resignation status (Article 85)
            let finalBenefit = baseBenefit;
            let ratioText = "100%";

            if (reason === 'resignation') {
                if (totalYears < 2) {
                    finalBenefit = 0;
                    ratioText = "0% (اقل من سنتين)";
                } else if (totalYears >= 2 && totalYears < 5) {
                    finalBenefit = baseBenefit * (1 / 3);
                    ratioText = "33.3% (ثلث المكافأة)";
                } else if (totalYears >= 5 && totalYears < 10) {
                    finalBenefit = baseBenefit * (2 / 3);
                    ratioText = "66.6% (ثلثا المكافأة)";
                } else {
                    finalBenefit = baseBenefit;
                    ratioText = "100% (كاملة)";
                }
            }

            document.getElementById('eosb-total').innerText = Math.round(finalBenefit).toLocaleString('ar-SA') + ' ر.س';
            document.getElementById('eosb-wage').innerText = totalSalary.toLocaleString('ar-SA') + ' ر.س';
            document.getElementById('eosb-period').innerText = totalYears.toFixed(1) + ' سنة';
            document.getElementById('eosb-ratio').innerText = ratioText;
        }

        // --- 3. VAT CALCULATOR ENGINE ---
        function setVATMode(mode) {
            document.getElementById('vat-mode').value = mode;
            document.querySelectorAll('.vat-btn').forEach(btn => {
                btn.classList.remove('bg-saudi-800', 'text-white', 'shadow-sm');
                btn.classList.add('text-slate-600');
            });
            if (mode === 'add') {
                document.getElementById('vat-mode-add').classList.add('bg-saudi-800', 'text-white', 'shadow-sm');
            } else {
                document.getElementById('vat-mode-sub').classList.add('bg-saudi-800', 'text-white', 'shadow-sm');
            }
            calculateVAT();
        }

        function calculateVAT() {
            const amount = parseFloat(document.getElementById('vat-amount').value) || 0;
            const mode = document.getElementById('vat-mode').value;

            let net = 0, tax = 0, gross = 0;

            if (mode === 'add') {
                net = amount;
                tax = amount * 0.15;
                gross = net + tax;
            } else {
                gross = amount;
                net = amount / 1.15;
                tax = gross - net;
            }

            document.getElementById('vat-net').innerText = net.toLocaleString('ar-SA', {maximumFractionDigits: 2}) + ' ر.س';
            document.getElementById('vat-tax').innerText = tax.toLocaleString('ar-SA', {maximumFractionDigits: 2}) + ' ر.س';
            document.getElementById('vat-gross').innerText = gross.toLocaleString('ar-SA', {maximumFractionDigits: 2}) + ' ر.س';
        }

        // --- 4. REAL ESTATE TAX CALCULATOR ---
        function calculateProperty() {
            const price = parseFloat(document.getElementById('prop-price').value) || 0;
            const hasExemption = document.getElementById('prop-exemption').checked;

            const baseTax = price * 0.05;
            let exemptionAmount = 0;

            if (hasExemption) {
                // Maximum exemption amount covered by govt is 5% of 1,000,000 SAR = 50,000 SAR
                exemptionAmount = Math.min(price, 1000000) * 0.05;
            }

            const taxDue = Math.max(0, baseTax - exemptionAmount);
            const grandTotal = price + taxDue;

            document.getElementById('prop-tax-due').innerText = Math.round(taxDue).toLocaleString('ar-SA') + ' ر.س';
            document.getElementById('prop-tax-total').innerText = Math.round(baseTax).toLocaleString('ar-SA') + ' ر.س';
            document.getElementById('prop-exemption-amount').innerText = Math.round(exemptionAmount).toLocaleString('ar-SA') + ' ر.س';
            document.getElementById('prop-grand-total').innerText = Math.round(grandTotal).toLocaleString('ar-SA') + ' ر.س';
        }

        // Initial Calculation Execution on Load
        window.onload = function() {
            calculateLoan();
            calculateEOSB();
            calculateVAT();
            calculateProperty();
        };
    </script>
</body>
</html>