import React, { useState } from 'react'; import { X, Calculator, Droplets, Activity, Scale, ChevronRight, ArrowRight, Check, Dumbbell, Flame, Heart, Percent } from 'lucide-react'; import { motion, AnimatePresence } from 'framer-motion'; import { useLanguage } from '@/contexts/LanguageContext'; interface CalculatorsModalProps { isOpen: boolean; onClose: () => void; } type ToolType = 'bmi' | 'water' | 'bmr' | 'tdee' | 'orm' | 'bodyfat' | 'hr'; const CalculatorsModal: React.FC = ({ isOpen, onClose }) => { const [activeTool, setActiveTool] = useState('bmi'); const { t } = useLanguage(); if (!isOpen) return null; return (
{/* Backdrop Overlay */} {/* Modal Container */} {/* Close Button (Mobile) */} {/* Sidebar Navigation */} {/* Main Content Area */}
{/* Close Button (Desktop) */}
{activeTool === 'bmi' && } {activeTool === 'water' && } {activeTool === 'bmr' && } {activeTool === 'tdee' && } {activeTool === 'orm' && } {activeTool === 'bodyfat' && } {activeTool === 'hr' && }
); }; // --- Components de Navegação --- const NavButton = ({ active, onClick, icon, label, desc }: any) => ( ); // --- Calculadoras (Existentes + Novas) --- const BMICalculator = ({ t }: any) => { const [weight, setWeight] = useState(''); const [height, setHeight] = useState(''); const [bmi, setBmi] = useState(null); const calculate = () => { if (weight && height) { const h = parseFloat(height) / 100; const val = parseFloat(weight) / (h * h); setBmi(parseFloat(val.toFixed(1))); } }; const getStatus = (val: number) => { if (val < 18.5) return { label: 'Abaixo do peso', color: 'text-blue-500', bg: 'bg-blue-500', range: 0 }; if (val < 25) return { label: 'Peso ideal', color: 'text-green-500', bg: 'bg-green-500', range: 33 }; if (val < 30) return { label: 'Sobrepeso', color: 'text-yellow-500', bg: 'bg-yellow-500', range: 66 }; return { label: 'Obesidade', color: 'text-red-500', bg: 'bg-red-500', range: 100 }; }; const status = bmi ? getStatus(bmi) : null; return (

{t.tools.bmi.title}

{t.tools.bmi.desc}

{bmi && status && (

Seu Resultado

{bmi}
{status.label}
{/* Visual Bar */}
18.5 25.0 30.0
)}
); }; const WaterCalculator = ({ t }: any) => { const [weight, setWeight] = useState(''); const [liters, setLiters] = useState(null); const calculate = () => { if (weight) { const val = parseFloat(weight) * 0.035; setLiters(parseFloat(val.toFixed(1))); } }; return (

{t.tools.water.title}

{t.tools.water.desc}

{/* Visual Bottle */}
{liters && {liters}L}
{liters && (

Meta Diária

{liters} L

)}
); }; const BMRCalculator = ({ t }: any) => { const [gender, setGender] = useState<'male' | 'female'>('male'); const [weight, setWeight] = useState(''); const [height, setHeight] = useState(''); const [age, setAge] = useState(''); const [bmr, setBmr] = useState(null); const calculate = () => { if (weight && height && age) { let val = (10 * parseFloat(weight)) + (6.25 * parseFloat(height)) - (5 * parseFloat(age)); val = gender === 'male' ? val + 5 : val - 161; setBmr(Math.round(val)); } }; return (

{t.tools.bmr.title}

{t.tools.bmr.desc}

{bmr && (

Gasto em Repouso

Calorias que você queima parado.

{bmr}

kcal / dia

)}
); }; const TDEECalculator = ({ t }: any) => { const [gender, setGender] = useState<'male' | 'female'>('male'); const [weight, setWeight] = useState(''); const [height, setHeight] = useState(''); const [age, setAge] = useState(''); const [activity, setActivity] = useState(1.2); const [tdee, setTdee] = useState(null); const calculate = () => { if (weight && height && age) { let bmr = (10 * parseFloat(weight)) + (6.25 * parseFloat(height)) - (5 * parseFloat(age)); bmr = gender === 'male' ? bmr + 5 : bmr - 161; setTdee(Math.round(bmr * activity)); } }; const activityLevels = [ { val: 1.2, label: t.tools.tdee.sedentary }, { val: 1.375, label: t.tools.tdee.light }, { val: 1.55, label: t.tools.tdee.moderate }, { val: 1.725, label: t.tools.tdee.active }, { val: 1.9, label: t.tools.tdee.veryActive }, ]; return (

{t.tools.tdee.title}

{t.tools.tdee.desc}

{activityLevels.map((lvl) => ( ))}
{tdee && (

Gasto Calórico Total

Energia necessária para manter seu peso atual.

{tdee}

kcal / dia

)}
); }; const ORMCalculator = ({ t }: any) => { const [lift, setLift] = useState(''); const [reps, setReps] = useState(''); const [orm, setOrm] = useState(null); const calculate = () => { if (lift && reps) { // Epley Formula const w = parseFloat(lift); const r = parseFloat(reps); if (r === 1) { setOrm(w); } else { const val = w * (1 + r / 30); setOrm(Math.round(val)); } } }; return (

{t.tools.orm.title}

{t.tools.orm.desc}

{orm && (
Sua Força Máxima Estimada
{orm} kg
90% {Math.round(orm * 0.9)}kg
70% (Hipertrofia) {Math.round(orm * 0.7)}kg
50% {Math.round(orm * 0.5)}kg
)}
); }; const BodyFatCalculator = ({ t }: any) => { const [gender, setGender] = useState<'male' | 'female'>('male'); const [waist, setWaist] = useState(''); const [neck, setNeck] = useState(''); const [hip, setHip] = useState(''); const [height, setHeight] = useState(''); const [bf, setBf] = useState(null); const calculate = () => { // US Navy Method const h = parseFloat(height); const w = parseFloat(waist); const n = parseFloat(neck); if (gender === 'male' && h && w && n) { const res = 495 / (1.0324 - 0.19077 * Math.log10(w - n) + 0.15456 * Math.log10(h)) - 450; setBf(parseFloat(res.toFixed(1))); } else if (gender === 'female' && h && w && n && hip) { const hi = parseFloat(hip); const res = 495 / (1.29579 - 0.35004 * Math.log10(w + hi - n) + 0.22100 * Math.log10(h)) - 450; setBf(parseFloat(res.toFixed(1))); } }; return (

{t.tools.bodyfat.title}

{t.tools.bodyfat.desc}

{gender === 'female' && ( )}
{bf && (

Gordura Corporal Estimada

{bf}%

Método US Navy
)}
); }; const HeartRateCalculator = ({ t }: any) => { const [age, setAge] = useState(''); const [maxHr, setMaxHr] = useState(null); const calculate = () => { if (age) { const val = 220 - parseFloat(age); setMaxHr(val); } }; return (

{t.tools.hr.title}

{t.tools.hr.desc}

{maxHr && (
Frequência Máxima Teórica
{maxHr} bpm
)}
); }; const ZoneBar = ({ zone, color, range, val, label }: any) => (
Z{zone}
{label} {range}
{val} bpm
); const BigInput = ({ label, value, onChange, placeholder, unit }: any) => (
onChange(e.target.value)} className="w-full px-4 py-4 rounded-xl bg-gray-50 border border-gray-200 text-gray-900 font-bold text-lg focus:border-brand-500 focus:ring-2 focus:ring-brand-200 outline-none transition-all placeholder-gray-300" placeholder={placeholder} /> {unit && {unit}}
); export default CalculatorsModal;