"use client";
import Image from "next/image";
import Link from "next/link";
import Faq from "@/src/components/web/Faq";
import StepsApply from "@/src/components/web/StepsApply";
import Document from "@/src/components/web/Document";
import { useRouter } from "next/navigation";
import axios from "axios";

export default function ServiceDetails() {
  const router = useRouter();
  const handleApplyNow = async () => {
    try {
      const res = await axios.get(
        `${process.env.NEXT_PUBLIC_EXPRESS_BACKEND_URL}/web/auth/verify`,
        {
          withCredentials: true,
        }
      );
      if (res.data.valid) {
        router.push("/first-time-home-buyer-application-form");
      } else {
        router.push("/web-auth");
      }
    } catch (error) {
      console.error('Verify error:', error instanceof Error ? error.message : 'Unknown error');
      router.push("/web-auth");
    }
  };
  return (
    <>
      <section
        className="relative w-full bg-cover bg-center bg-no-repeat py-6 md:py-10 px-5 lg:px-20 rounded-lg overflow-hidden mt-5"
        style={{
          backgroundImage: "url('about/about-bg.png')",
        }}
      >
        <div className="absolute inset-0 bg-black/40"></div>

        <div className="relative z-10 max-w-7xl mx-auto">
          <div className="flex flex-col lg:flex-row lg:items-center lg:justify-between gap-6">
            <div>
              <nav className="inline-flex items-center gap-4 px-8 py-2 rounded-full bg-teal-transperent backdrop-blur-sm mb-6">
                <Link
                  href="/"
                  className="text-[15px] md:text-[17px] text-white font-medium hover:underline"
                >
                  Home
                </Link>
                <span className="text-white text-2xl leading-none">›</span>
                <span className="text-[15px] md:text-[17px] text-white font-medium">
                  First-Time Home Buyer Assistance
                </span>
              </nav>

              <h1 className="text-[20px] lg:text-[35px] font-semibold text-white leading-tight md:leading-snug">
                <span className="inline-flex items-center gap-3 relative pr-[25px]
">
                  First-Time Home Buyer Assistance
                  <Image
                    src="/icons/top-arrow.svg"
                    alt="Top Arrow"
                    width={36}
                    height={36}
                    className="absolute right-[0px]  md:right-[-25px] lg:right-[-50px]  top-[-15px]"
                  />
                </span>
                <br />

              </h1>
            </div>

            <div className="lg:self-start">
              <button
                onClick={handleApplyNow}
                className="
            px-8  py-2 md:py-3
            rounded-full
            border border-white
            text-white
            text-sm md:text-base
            font-medium
            backdrop-blur-sm
            hover:bg-white hover:text-black
            transition-all duration-300
            w-fit
          "
              >
                Apply Now
              </button>
            </div>
          </div>
        </div>
      </section>

      {/* services*/}
      <section className=" py-10">
        <div className="max-w-7xl mx-auto px-0 md:px-4">
          <div className="grid grid-cols-1 lg:grid-cols-12 gap-8">
            <div className="lg:col-span-3">
              <div className="">
                <div className="bg-transparent ">
                  <div className="flex items-center gap-2 text-teal-600 text-xs font-semibold uppercase tracking-wider mb-4">
                    <Image
                      src="/icons/home.svg"
                      alt=""
                      width={16}
                      height={16}
                      className="w-4 h-4"
                    />

                    <span className="text-[16px]">SERVICE</span>
                  </div>

                  <h2 className="text-[20px] lg:text-[35px] font-semibold leading-tight text-gray-900">
                    We Support Improved Housing & Stronger Community Value.
                  </h2>
                </div>
              </div>
            </div>

            {/*right */}
            <div className="lg:col-span-9">
              <div>
                <div className="relative h-[240px] sm:h-[450px] rounded-2xl overflow-hidden">
                  <Image
                    src="/blog.jpg"
                    alt="Blog"
                    fill
                    className="object-cover"
                  />
                </div>

                <div className="pt-6">
                  <h1 className="mt-3 text-2xl sm:text-3xl font-semibold text-gray-900 leading-tight">
                  First Time Home Buyer Program
                  </h1>
                
                   


                  <div className="mt-4 space-y-4 text-gray-600 text-sm leading-relaxed">



                    <p>Thank you for your interest in the Lackawanna Housing Development Corporation’s (LHDC) First-Time Homebuyer Assistance Program.</p>

                    <p>If you decide to apply, please complete all required information within this application and compile the required income and eligibility documents listed on the last page of this application packet (Exhibit “A”). LHDC will only accept completed applications with 100% of documentation submitted.</p>

                    <p>Once you have completed the application and gathered all required documents, please call our office at <span className="contact">(716) 823-5124</span> to schedule a meeting to submit your application. During this meeting, LHDC will go over the approval process, eligibility requirements, homebuyer education standards, lender coordination, and all program restrictions.</p>

                    <h2 className="mt-3 text-xl sm:text-2xl font-semibold text-gray-900 leading-tight" >Program Overview</h2>
                    <p>This program assists first-time homebuyers — defined as individuals or households who have not owned a home within the past three (3) years — in purchasing an owner-occupied 1- or 2-unit home in the City of Lackawanna.</p>

                    <p>Eligible applicants must meet moderate-to-low income limits and have less than <strong>$15,000</strong> in total net assets (not including retirement accounts).</p>

                    <p>Funding for this program is provided by the New York State Division of Homes and Community Renewal (HCR) Office of Affordable Housing Corporation (AHC).</p>

                    <div className="highlight">
                      <strong>Note:</strong> Funding is limited. There is no guarantee that funds will be available for the entire 2025 Program Year. A waiting list may be established based on program readiness, income status, and demonstrated need.
                    </div>

                    <h2 className="mt-3 text-xl sm:text-2xl font-semibold text-gray-900 leading-tight" >Program Benefits</h2>
                    <p>This Program can provide up to a <strong>$30,000 deferred loan</strong> for the purchase and rehabilitation of one (1) or two (2) family homes in the City of Lackawanna. The loan is funded by the New York State Affordable Housing Corporation (AHC) and secured by a mortgage.</p>

                    <h2 className="mt-3 text-xl sm:text-2xl font-semibold text-gray-900 leading-tight" >General Requirements</h2>
                    <ol className="list-decimal list-inside space-y-2">
                      <li>Maximum gross family income of <strong>80% of area median income</strong> (combined assets of no more than 25% of the unsubsidized sale price of the home). *See Income Eligibility based on HUD guidelines*</li>
                      <li>Must attend a Homebuyer Education class.</li>
                      <li>Must be able to contribute <strong>$1,500 or 2% of the purchase price</strong> towards down payment and closing costs, whichever is greater.</li>
                      <li>Must be able to secure a first mortgage at an acceptable market interest rate, with taxes and insurance escrowed.</li>
                      <li>The home must be approved by LHDC. The homeowner must agree to spend at least <strong>51% of the grant funds ($15,300)</strong> on rehabilitation costs, as determined by LHDC. Rehab must be completed within <strong>6 months</strong> of closing.</li>
                      <li>Must live in the home for <strong>ten (10) years</strong> to receive the full benefit of the subsidy.</li>
                      <li>Must carry Homeowners Insurance naming the <strong>NEW YORK STATE AFFORDABLE HOUSING CORPORATION</strong> as an additional insured.</li>
                    </ol>

                    <h2 className="mt-3 text-xl sm:text-2xl font-semibold text-gray-900 leading-tight" >Steps to Home Ownership</h2>
                    <ol className="list-decimal list-inside space-y-2">
                      <li>Pre-qualify for a mortgage from a reputable lending institution.</li>
                      <li>Complete the LHDC application to determine eligibility.</li>
                      <li>Once approved, begin your search for a home with a real estate agent (approximately 60 days).</li>
                      <li>LHDC will inspect the property and determine the scope and cost of rehabilitation.</li>
                      <li>Applicant signs the rehabilitation agreement.</li>
                      <li>Sign the purchase offer (with LHDC approval, or include a contingency for LHDC approval).</li>
                      <li>Submit a mortgage application within <strong>seven (7) days</strong> of acceptance of the purchase offer.</li>
                      <li>Close on the house (approximately 45 days).</li>
                      <li>LHDC will provide the homeowner with bid documents.</li>
                      <li>Solicit a minimum of <strong>three (3) bids</strong> for rehabilitation within 30 days of closing.</li>
                      <li>Complete the rehabilitation within <strong>six (6) months</strong> of closing.</li>
                    </ol>

                    <h2 className="mt-3 text-xl sm:text-2xl font-semibold text-gray-900 leading-tight" >Important Program Rules</h2>
                    <ul>
                      <li>All contracts of sale, mortgage agreements, and closing documents will be between you and the lender or seller.</li>
                      <li>No purchase offer or contract may be executed using program funds prior to written authorization by LHDC.</li>
                      <li>LHDC does not assign lenders, real estate agents, attorneys, or property inspectors. However, a resource directory may be provided to assist applicants during the homebuying process.</li>
                    </ul>

                    <p>If you have any questions or concerns regarding this program, please contact us at <span className="contact">(716) 823-5124</span>.</p>

                    <p><strong>We look forward to assisting you in your goal of becoming a homeowner!</strong></p>


                  </div>
                </div>
              </div>
            </div>
          </div>
        </div>
      </section>

      {/* Document */}
      <Document />

      {/* We apply */}
      <StepsApply />

      {/* FAQ */}
      <Faq faq_type="3" />
    </>
  );
}
