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

const FinancialToolsAuto = () => {
  // Mapping der Tool-Namen zu ihren URLs
  const getToolUrl = (toolName: string): string => {
    const toolUrlMap: { [key: string]: string } = {
      "Auto Loan Early Payoff": "https://www.cchwebsites.com/content/calculators/AutoPayoff.html",
      "Auto Rebate vs. Low Interest Financing": "https://www.cchwebsites.com/content/calculators/AutoRebate.html",
      "Auto Refinance Interest Savings": "https://www.cchwebsites.com/content/calculators/ShouldIRefiAuto.html",
      "Bi-weekly Payments for an Auto Loan": "https://www.cchwebsites.com/content/calculators/AutoBiweekly.html",
      "Bi-weekly Payments for an Auto Loan with Fees": "https://www.cchwebsites.com/content/calculators/ImpoundAutoBiweekly.html",
      "Car Loan Calculator": "https://www.cchwebsites.com/content/calculators/AutoLoan.html",
      "Dealer Financing vs. Credit Union Financing": "https://www.cchwebsites.com/content/calculators/CUAutoRebate.html",
      "Home Equity Loan vs. Auto loan": "https://www.cchwebsites.com/content/calculators/AutoEquityLoan.html",
      "Lease vs. Buy": "https://www.cchwebsites.com/content/calculators/BuyvsLease.html",
      "Low Interest Financing Savings": "https://www.cchwebsites.com/content/calculators/AutoLowInterest.html"
    };
    
    return toolUrlMap[toolName] || "#";
  };

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

  const autoTools = [
    {
      name: "Auto Loan Early Payoff",
      description: "Find out how much interest you can save by increasing your monthly auto loan payment."
    },
    {
      name: "Auto Rebate vs. Low Interest Financing",
      description: "Use this calculator to help you determine whether you should take advantage of low interest financing or a manufacturer rebate."
    },
    {
      name: "Auto Refinance Interest Savings",
      description: "Use this calculator to see how much interest you can save by refinancing your auto loan."
    },
    {
      name: "Bi-weekly Payments for an Auto Loan",
      description: "This calculator shows you possible savings by using an accelerated bi-weekly payment on your auto loan. This simple technique can shave time off your auto loan and could save you hundreds or even thousands of dollars in interest."
    },
    {
      name: "Bi-weekly Payments for an Auto Loan with Fees",
      description: "This calculator shows you possible savings by using an accelerated bi-weekly payment on your auto loan. This simple technique can shave time off your auto loan and could save you hundreds or even thousands of dollars in interest."
    },
    {
      name: "Car Loan Calculator",
      description: "Determine your car loan payment based on your purchase price or find out how much you can buy based on your monthly payment."
    },
    {
      name: "Dealer Financing vs. Credit Union Financing",
      description: "Use this calculator to help you determine whether you should take advantage of low interest dealer financing or credit union financing combined with a manufacturer rebate."
    },
    {
      name: "Home Equity Loan vs. Auto loan",
      description: "Use this calculator to determine if a home equity loan makes sense for your next automobile purchase."
    },
    {
      name: "Lease vs. Buy",
      description: "Should you lease your next automobile or finance it? Find out with this calculator!"
    },
    {
      name: "Low Interest Financing Savings",
      description: "Low, promotional interest rates can save you a great deal of money when you finance your car or truck. Use this calculator to help find the best monthly payment and how much interest you could save."
    }
  ];

  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">
                  <Car 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">
                    Auto Financial Tools
                  </h1>
                  <p className="text-body-lg text-white/90">
                    Auto loan calculators and financing tools to help you make the best vehicle purchase decisions
                  </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>

        {/* Auto 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">
                {autoTools.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">
                          <Car 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 Auto Financing Decisions?
              </h2>
              
              <p className="text-body-lg text-cream/90 mb-8 leading-relaxed">
                Our experienced CPA team can help you understand the financial implications of your vehicle purchase and financing options.
              </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 Auto Financing Consultation
              </Button>
            </div>
          </div>
        </section>
      </main>
      <Footer />
      <ScrollToTop />
    </div>
  );
};

export default FinancialToolsAuto;
