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 { CreditCard, ExternalLink, ArrowLeft } from "lucide-react";
import { Link } from "react-router-dom";

const FinancialToolsDebt = () => {
  // Mapping der Tool-Namen zu ihren URLs
  const getToolUrl = (toolName: string): string => {
    const toolUrlMap: { [key: string]: string } = {
      "Accelerated Debt Payoff": "https://www.cchwebsites.com/content/calculators/DebtAccel.html",
      "Consolidation Loan Investment Calculator": "https://www.cchwebsites.com/content/calculators/InvestmentDebt.html",
      "Cost-of-Debt Calculator": "https://www.cchwebsites.com/content/calculators/Debt2Amount.html",
      "Credit Card Minimum Payment Calculator": "https://www.cchwebsites.com/content/calculators/DebtPayoff2.html",
      "Credit Card Optimizer": "https://www.cchwebsites.com/content/calculators/CardOptimizer.html",
      "Credit Card Pay Off": "https://www.cchwebsites.com/content/calculators/PayoffCC.html",
      "Home Equity Debt Consolidation": "https://www.cchwebsites.com/content/calculators/MortgageEquity.html",
      "How much do you owe?": "https://www.cchwebsites.com/content/calculators/DebtAmount.html",
      "Personal Debt Consolidation": "https://www.cchwebsites.com/content/calculators/DebtConsolidate.html",
      "Roll-Down Your Credit Card Debt!": "https://www.cchwebsites.com/content/calculators/DebtRolldown.html",
      "Snowball Debt Elimination Calculator": "https://www.cchwebsites.com/content/calculators/SnowBall2.html",
      "Student Loan Consolidation and Debt Payoff": "https://www.cchwebsites.com/content/calculators/StudentRolldown.html"
    };
    
    return toolUrlMap[toolName] || "#";
  };

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

  const debtTools = [
    {
      name: "Accelerated Debt Payoff",
      description: "Consolidating your debt is only half of the battle. You still need a plan to get your debt paid in full. This calculator can show you how to accelerate your debt payoff."
    },
    {
      name: "Consolidation Loan Investment Calculator",
      description: "Getting a consolidation loan can do more than payoff your debt. Use this calculator to see the results of paying off your debt and investing your payment savings."
    },
    {
      name: "Cost-of-Debt Calculator",
      description: "Use this calculator to see just how expensive paying interest on your debt can be."
    },
    {
      name: "Credit Card Minimum Payment Calculator",
      description: "Use this calculator to determine how long it will take you to payoff your credit cards if you only make the minimum payments."
    },
    {
      name: "Credit Card Optimizer",
      description: "The Credit Card Optimizer helps you determine the best distribution of your credit card debt."
    },
    {
      name: "Credit Card Pay Off",
      description: "Use this calculator to see what it will take to pay off your credit card balance, and what you can change to meet your repayment goals."
    },
    {
      name: "Home Equity Debt Consolidation",
      description: "This calculator is designed to help determine whether using your home equity to consolidate your debt is right for you."
    },
    {
      name: "How much do you owe?",
      description: "Use this calculator as a starting point for your debt management plan."
    },
    {
      name: "Personal Debt Consolidation",
      description: "Should you consolidate your debt? This calculator is designed to help determine if debt consolidation is right for you."
    },
    {
      name: "Roll-Down Your Credit Card Debt!",
      description: "The Credit Card Roll-Down Calculator applies two simple principles to paying off your credit card debt."
    },
    {
      name: "Snowball Debt Elimination Calculator",
      description: "This Debt Calculator applies two simple principles to paying off all your Debt that can cut years off of your repayment schedule."
    },
    {
      name: "Student Loan Consolidation and Debt Payoff",
      description: "The Student Loan Consolidation and Debt Payoff calculator applies two simple principles to paying off your Debt; Consolidate your student loans, and use the monthly savings to pay off your other outstanding debt."
    }
  ];

  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">
                  <CreditCard 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">
                    Debt & Credit Card Tools
                  </h1>
                  <p className="text-body-lg text-white/90">
                    Debt management and credit card optimization tools to help you get out of debt faster
                  </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>

        {/* Debt 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">
                {debtTools.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">
                          <CreditCard 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 Debt Management?
              </h2>
              
              <p className="text-body-lg text-cream/90 mb-8 leading-relaxed">
                Our experienced CPA team can help you develop a comprehensive debt management 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 Debt Management Consultation
              </Button>
            </div>
          </div>
        </section>
      </main>
      <Footer />
      <ScrollToTop />
    </div>
  );
};

export default FinancialToolsDebt;
