<div class="inheritance-calculator"> <h2>حاسبة المواريث الإسلامية</h2> <label>قيمة التركة:</label> <input type="number" id="estate" placeholder="ادخل قيمة التركة"> <label>عدد الزوجات (0 أو 1 أو أكثر):</label> <input type="number" id="wives" value="0"> <label>هل يوجد زوج؟ (0 أو 1):</label> <input type="number" id="husband" value="0"> <label>هل الأب موجود؟ (0 أو 1):</label> <input type="number" id="father" value="0"> <label>هل الأم موجودة؟ (0 أو 1):</label> <input type="number" id="mother" value="0"> <label>عدد الأبناء الذكور:</label> <input type="number" id="sons" value="0"> <label>عدد البنات:</label> <input type="number" id="daughters" value="0"> <button onclick="calculateInheritance()">احسب الميراث</button> <div id="results"></div> </div> <style> .inheritance-calculator{ max-width:700px; margin:30px auto; padding:25px; background:#fff; border-radius:18px; box-shadow:0 10px 35px rgba(0,0,0,.1); font-family:Tajawal,sans-serif; direction:rtl } h2{ text-align:center; color:#0f766e } label{ display:block; margin-top:15px; font-weight:bold } input{ width:100%; padding:12px; margin-top:8px; border:2px solid #ddd; border-radius:12px; font-size:16px } button{ width:100%; padding:14px; margin-top:20px; background:#0f766e; color:#fff; border:none; border-radius:14px; font-size:18px; cursor:pointer } button:hover{ background:#115e59 } #results{ margin-top:25px; padding:20px; background:#f8fafc; border-radius:14px } .result-item{ padding:12px; margin:8px 0; background:#fff; border-right:5px solid #0f766e; border-radius:10px } </style> <script> function calculateInheritance(){ let estate=parseFloat(document.getElementById('estate').value)||0; let wives=parseInt(document.getElementById('wives').value)||0; let husband=parseInt(document.getElementById('husband').value)||0; let father=parseInt(document.getElementById('father').value)||0; let mother=parseInt(document.getElementById('mother').value)||0; let sons=parseInt(document.getElementById('sons').value)||0; let daughters=parseInt(document.getElementById('daughters').value)||0; let results=[]; let remaining=estate; let hasChildren=(sons+daughters)>0; /* الزوج */ if(husband){ let share=hasChildren?estate/4:estate/2; results.push(["الزوج",share]); remaining-=share; } /* الزوجات */ if(wives>0){ let totalShare=hasChildren?estate/8:estate/4; let each=totalShare/wives; for(let i=1;i<=wives;i++){ results.push(["الزوجة "+i,each]); } remaining-=totalShare; } /* الأم */ if(mother){ let share=hasChildren?estate/6:estate/3; results.push(["الأم",share]); remaining-=share; } /* الأب */ if(father){ let share=hasChildren?estate/6:remaining; results.push(["الأب",share]); remaining-=share; } /* الأبناء والبنات */ if(sons+daughters>0){ let totalParts=(sons*2)+daughters; let unit=remaining/totalParts; for(let i=1;i<=sons;i++){ results.push(["ابن "+i,unit*2]); } for(let i=1;i<=daughters;i++){ results.push(["بنت "+i,unit]); } } let html="<h3>النتائج:</h3>"; results.forEach(r=>{ html+=`<div class="result-item">${r[0]} : ${r[1].toFixed(2)} جنيه</div>`; }); document.getElementById("results").innerHTML=html; } </script>