import React from 'react'; import { motion, AnimatePresence } from 'framer-motion'; import { X, Info, DollarSign, Shield } from 'lucide-react'; export default function TransparencyModal({ isOpen, onClose, data, currentPortfolio, totalValue, prices }) { if (!isOpen || !data) return null; return (
{/* Backdrop */} {/* Modal Content */} {/* Header (Fixed at top) */}
Recommendation

{data.title}

{/* The Advice */}

The Action Plan

{(() => { let advice = data.advice; const hasBonds = currentPortfolio?.allocation?.some(a => a.ticker?.includes('BND') || a.name?.toLowerCase().includes('bond') ); if (!hasBonds && advice.includes('Bonds')) { advice = advice.replace('Bonds', 'Cash Reserves'); } return advice; })()}

{/* Visual Comparison Section */}

Visual Rebalance Suggestion

{currentPortfolio?.allocation?.length > 0 ? ( currentPortfolio.allocation.slice(0, 3).map((asset, idx) => { if (!asset) return null; // Mock logic for "Target" based on scenario let change = 0; const trigger = data.trigger || ""; const assetName = asset.name || ""; if (trigger.includes("Market Drop")) { if (assetName.includes("Bond") || assetName.includes("Cash")) change = -5; else change = 5; } else if (trigger.includes("Life Expense")) { if (assetName.includes("Cash")) change = 20; else change = -10; } else if (trigger.includes("Inflation")) { if (assetName.includes("Vanguard") || assetName.includes("Value")) change = 8; else change = -4; } const val = Number(asset.value) || 0; const targetValue = Math.max(0, Math.min(100, val + change)); // Calculate Dollar and Share Changes const ticker = asset.ticker; const priceObj = prices[ticker]; const price = priceObj?.price; // Use a fallback total value if current calculation is still in flight const activeTotal = totalValue > 0 ? totalValue : 50000; const currentValue = (val / 100) * activeTotal; const targetValueDollar = (targetValue / 100) * activeTotal; const dollarDiff = targetValueDollar - currentValue; const sharesDiff = price ? Math.abs(Math.round(dollarDiff / price)) : null; return (
{ticker}
{val.toFixed(2)}% 0 ? 'text-green-600' : change < 0 ? 'text-red-500' : 'text-gs-navy'}> {targetValue.toFixed(2)}%

0 ? 'text-green-600' : 'text-red-500'}`}> {change > 0 ? 'Buy' : 'Sell'} ${Math.abs(Math.round(dollarDiff)).toLocaleString()} {sharesDiff !== null ? ` (${sharesDiff} shares)` : ' (Calculating...)'}

= 0 ? 'bg-green-500' : 'bg-red-500'}`} style={{ width: `${targetValue}%` }} >
); }) ) : (

Add at least one stock to see a visual rebalance simulation.

)}

*Simulated shift based on your {currentPortfolio?.riskLevel || 'selected'} risk profile.

{/* The Why */}

Why we recommend this

{data.explanation}


{/* Radical Transparency Section */}

Full Transparency

Fee Impact {data.feeImpactDollars}
Tax Considerations {data.taxImpact}
); }