import Navigation from "@/components/Navigation";
import Footer from "@/components/Footer";
import ScrollToTop from "@/components/ScrollToTop";
import { Card, CardContent } from "@/components/ui/card";
import { Button } from "@/components/ui/button";
import { FileText, ExternalLink, ArrowLeft } from "lucide-react";
import { Link } from "react-router-dom";

const FinancialToolsPersonalFinance = () => {
  // Mapping der Tool-Namen zu ihren URLs
  const getToolUrl = (toolName: string): string => {
    const toolUrlMap: { [key: string]: string } = {
      "Basic Calculator": "https://www.cchwebsites.com/content/calculators/FinCalc.html",
      "Basic Financial Calculator": "https://www.cchwebsites.com/content/calculators/FinCalc3.html",
      "Checkbook Balancer": "https://www.cchwebsites.com/content/calculators/CheckBook.html",
      "Credit Assessment": "https://www.cchwebsites.com/content/calculators/CreditAssessment.html",
      "Home Budget Analysis": "https://www.cchwebsites.com/content/calculators/HomeBudget.html",
      "Life Expectancy": "https://www.cchwebsites.com/content/calculators/LifeTime.html",
      "Net Worth": "https://www.cchwebsites.com/content/calculators/NetWorth.html",
      "Should my spouse work?": "https://www.cchwebsites.com/content/calculators/IncomeOneorTwo.html",
      "Student Budget": "https://www.cchwebsites.com/content/calculators/StudentBudget.html"
    };
    
    return toolUrlMap[toolName] || "#";
  };

  const handleToolClick = (toolName: string) => {
    const url = getToolUrl(toolName);
    if (url !== "#") {
      window.open(url, '_blank', 'noopener,noreferrer');
    }
  };

  const personalFinanceTools = [
    {
      name: "Basic Calculator",
      description: "This works just like a pocket calculator."
    },
    {
      name: "Basic Financial Calculator",
      description: "This works just like a pocket financial calculator. In addition to arithmetic it can also calculate present value, future value, payments or number or periods."
    },
    {
      name: "Checkbook Balancer",
      description: "Balance your checkbook with this quick and easy calculator."
    },
    {
      name: "Credit Assessment",
      description: "How is your credit? Use this calculator for a quick assessment!"
    },
    {
      name: "Home Budget Analysis",
      description: "Analyze your budget, see where your money goes and find out where you can improve!"
    },
    {
      name: "Life Expectancy",
      description: "This calculator can give you an idea of your life expectancy based on your current age, smoking habits, gender and several other important lifestyle choices."
    },
    {
      name: "Net Worth",
      description: "This calculator helps you determine your net worth. It also estimates how your net worth could grow (or shrink!) over the next ten years."
    },
    {
      name: "Should my spouse work?",
      description: "This calculator is designed to help you see the financial impact of having either one or two incomes for your household."
    },
    {
      name: "Student Budget",
      description: "This calculator is specifically designed to help students understand their expenses and income while attending a university, college or other full-time educational institution."
    }
  ];

  return (
    <div className="min-h-screen">
      <Navigation />
      <main className="pt-16">
        {/* Hero Section */}
        <section
          className="py-24 bg-gradient-subtle relative"
          style={{
            backgroundImage: 'url(/lovable-uploads/financialtools-subpages.png)',
            backgroundSize: 'cover',
            backgroundPosition: 'center',
            backgroundRepeat: 'no-repeat'
          }}
        >
          <div className="absolute inset-0 bg-black/60"></div>
          <div className="container mx-auto px-4 relative z-10">
            <div className="max-w-4xl mx-auto">
              <div className="flex items-center gap-4 mb-8">
                <Link 
                  to="/financial-tools" 
                  className="flex items-center gap-2 text-white hover:text-brass gentle-transition"
                >
                  <ArrowLeft className="w-5 h-5" />
                  <span className="font-medium">Back to Financial Tools</span>
                </Link>
              </div>
              
              <div className="flex items-center gap-4 mb-8">
                <div className="w-16 h-16 bg-brass/20 rounded-2xl flex items-center justify-center">
                  <FileText className="w-8 h-8 text-brass" strokeWidth={1.5} />
                </div>
                <div>
                  <h1 className="text-display-xl font-display font-bold text-white mb-2">
                    Personal Finance Tools
                  </h1>
                  <p className="text-body-lg text-white/90">
                    Personal finance management and budgeting tools to help you take control of your finances
                  </p>
                </div>
              </div>
              
              <div className="bg-white/95 rounded-2xl p-6 card-elevation">
                <p className="text-forest text-sm">
                  <strong>Disclaimer:</strong> While these financial tools are not a substitute for financial advice from a qualified professional, they can be used as a starting point in the decision making process.
                </p>
              </div>
            </div>
          </div>
        </section>

        {/* Personal Finance Tools Grid */}
        <section className="py-24 bg-background">
          <div className="container mx-auto px-4">
            <div className="max-w-6xl mx-auto">
              <div className="grid md:grid-cols-2 lg:grid-cols-3 gap-6">
                {personalFinanceTools.map((tool, index) => (
                  <Card 
                    key={index} 
                    className="rounded-xl card-elevation hover:shadow-lg gentle-transition cursor-pointer h-full"
                    onClick={() => handleToolClick(tool.name)}
                  >
                    <CardContent className="p-6 h-full flex flex-col">
                      <div className="flex items-start justify-between mb-4">
                        <div className="w-12 h-12 bg-brass/20 rounded-xl flex items-center justify-center flex-shrink-0">
                          <FileText className="w-6 h-6 text-brass" strokeWidth={1.5} />
                        </div>
                        <ExternalLink className="w-5 h-5 text-brass flex-shrink-0" strokeWidth={1.5} />
                      </div>
                      
                      <h3 className="text-display-sm font-display font-semibold text-forest mb-3 leading-tight">
                        {tool.name}
                      </h3>
                      
                      <p className="text-sage text-sm leading-relaxed flex-grow">
                        {tool.description}
                      </p>
                      
                      <div className="mt-4 pt-4 border-t border-sage/20">
                        <Button 
                          variant="outline" 
                          size="sm" 
                          className="w-full text-brass border-brass hover:bg-brass hover:text-cream"
                        >
                          Use Calculator
                        </Button>
                      </div>
                    </CardContent>
                  </Card>
                ))}
              </div>
            </div>
          </div>
        </section>

        {/* CTA Section */}
        <section className="py-24 bg-gradient-hero">
          <div className="container mx-auto px-4 text-center">
            <div className="max-w-3xl mx-auto">
              <h2 className="text-display-lg font-display font-semibold text-cream mb-6">
                Need Help with Personal Finance Planning?
              </h2>
              
              <p className="text-body-lg text-cream/90 mb-8 leading-relaxed">
                Our experienced CPA team can help you develop a comprehensive personal finance strategy and understand the best approach for your financial situation.
              </p>
              
              <Button 
                size="lg" 
                variant="outline"
                className="bg-cream text-forest hover:bg-cream/90 border-cream btn-shadow text-lg px-8 py-3 rounded-2xl"
              >
                Schedule Personal Finance Consultation
              </Button>
            </div>
          </div>
        </section>
      </main>
      <Footer />
      <ScrollToTop />
    </div>
  );
};

export default FinancialToolsPersonalFinance;
