"use client";

import React, { useState } from "react";
import Image from "next/image";
import Link from "next/link";
import { FaDownload, FaEnvelope, FaChevronRight } from "react-icons/fa6";
import {
  LuLayers,
  LuShieldCheck,
  LuCpu,
  LuZap,
  LuActivity,
  LuClock
} from "react-icons/lu";

export const metadata = {
  title: "Automatic Source Changeover with Current Limiter (ACCL) | Salzer Switchgear",
  description: "Patented contactor-based ACCL for efficient generator power distribution. Features 5 kA short circuit capacity, auto-reset, and overload warning buffers.",
  keywords: ["ACCL", "Automatic Source Changeover", "Current Limiter", "Salzer Switchgear", "Generator Overload Protection", "Contactor ACCL"],
};

interface TechnicalSpec {
  id: string;
  title: string;
  category: string;
  technicalDetails: string;
}

export default function ACCLComponent() {
  const [activeSpecId, setActiveSpecId] = useState<string>("spec-1");

  const engineeringMetrics = [
    { label: "Operations Life", val: "25,000 Cycles" },
    { label: "Short Circuit Cap", val: "5 kA (UL Lab)" },
    { label: "EB Power Drain", val: "< 0.2 VA (Cool)" },
    { label: "Categories", val: "AC-32A / AC-22A" }
  ];

  const productFeatures = [
    "Patented contactor-based internal architecture",
    "Break-before-make design via optimized air gaps",
    "Intelligent auto-reset recovery sequences",
    "Dual installation methods (1 or 2 sub-main wiring)",
    "Integrated warning buzzer and LED signaling diagnostics",
    "Coil optimization drawing power only during DG cycles"
  ];

  const technicalSpecifications: TechnicalSpec[] = [
    {
      id: "spec-1",
      title: "Intelligent Load Automation & Overload Safeguards",
      category: "Operational Logic",
      technicalDetails: "The ACCL automatically switches critical building circuits over to the generator supply immediately upon main power line failure. To protect standby power architecture, it monitors grid draw and functions as an active current limiter if the consumer load exceeds pre-set backup thresholds, preventing total generator stall."
    },
    {
      id: "spec-2",
      title: "Patented Heavy-Duty Contactor Architecture",
      category: "Hardware Integrity",
      technicalDetails: "Engineered around a patented contactor-based mechanism rather than delicate micro-relays. This builds a robust design certified for heavy-duty AC-32A and AC-22A utilization categories, rated to withstand up to 25,000 independent mechanical transition operations over its service life."
    },
    {
      id: "spec-3",
      title: "Certified Safety Framework & Thermal Efficiency",
      category: "Compliance & Power",
      technicalDetails: "Tested extensively at independent third-party facilities (including UL Laboratories) to guarantee a 5 kA short circuit fault capacity. Operating temperatures remain exceptionally low because the internal coil draws less than 0.2 VA when running on standard electricity lines."
    },
    {
      id: "spec-4",
      title: "User-Friendly Buffer Periods & Retrofitting",
      category: "Integration & UX",
      technicalDetails: "When an overload event triggers, the system grants consumers a smart 10-second warning window accompanied by an audible beep and LED blink before tripping. This provides time to switch off auxiliary appliances. The physical profile supports both new infrastructure projects and legacy retrofits using 1 sub-main or 2 sub-main wiring paths."
    }
  ];

  return (
    <div className="min-h-screen bg-slate-50 text-slate-800 py-16 lg:py-24 selection:bg-amber-100 selection:text-slate-900">
      <div className="container mx-auto px-4 max-w-7xl">

        {/* ─── HERO BRAND / DETAILS SECTION ──────────────────── */}
        <div className="grid grid-cols-1 lg:grid-cols-12 gap-12 items-center mb-20">

          {/* Left Frame: Image Asset Viewport */}
          <div className="lg:col-span-6 flex justify-center order-2 lg:order-1">
            <div className="relative w-full aspect-[4/3] rounded-3xl overflow-hidden bg-white border border-slate-200 p-2 shadow-xs group">
              <div className="relative w-full h-full rounded-2xl overflow-hidden">
                <Image
                  src="https://realswitchgears.com/assets/images/products/salzer/accl-banner.jpg"
                  alt="Salzer Automatic Source Changeover with Current Limiter Assembly"
                  fill
                  priority
                  className="object-cover group-hover:scale-102 transition-transform duration-500"
                  sizes="(max-width: 1024px) 100vw, 600px"
                />
              </div>
            </div>
          </div>

          {/* Right Frame: Text Narrative Content */}
          <div className="lg:col-span-6 space-y-6 order-1 lg:order-2">
            <span className="inline-flex items-center gap-1.5 rounded-full bg-slate-900 px-4 py-1.5 text-xs font-bold tracking-wider text-amber-400 uppercase border border-slate-800">
              Patented Design • UL Lab Tested &amp; Proven
            </span>

            <h1 className="text-3xl md:text-4xl font-black tracking-tight text-slate-900 leading-tight">
              Automatic Source Changeover <br />
              <span className="text-amber-600 font-extrabold text-xl md:text-2xl block mt-2">
                With Integrated Current Limiter (ACCL)
              </span>
            </h1>

            <div className="space-y-4 text-slate-600 text-sm md:text-base leading-relaxed font-medium">
              <p>
                Salzer&apos;s **Automatic Source Changeover with Current Limiter (ACCL)** provides smart, automated power distribution for high-rise residential complexes, expansive townships, and modern commercial complexes.
              </p>
              <p>
                The module instantly transfers building loads over to standby generators during grid blackouts. Beyond basic source switching, it operates as a proactive safety layer by constantly analyzing total current demand. If the consumer draw overshoots pre-set thresholds, the current limiter steps in to protect the localized generator network from damage or destabilizing overloads.
              </p>
              <p>
                Built to outperform standard relay setups, this intelligent module features a patented break-before-make contactor layout that prevents phase crossover, improves building energy efficiency, and simplifies power management.
              </p>
            </div>

            {/* Parameter Cards Summary Layout */}
            <div className="grid grid-cols-2 sm:grid-cols-4 gap-3 bg-white border border-slate-200 p-4 rounded-2xl shadow-xs">
              {engineeringMetrics.map((metric, index) => (
                <div key={index} className="bg-slate-50 border border-slate-100 p-3 rounded-xl text-center flex flex-col justify-center">
                  <span className="text-[10px] text-slate-400 font-bold uppercase tracking-wider block mb-1">
                    {metric.label}
                  </span>
                  <span className="text-xs font-black text-slate-900 leading-snug">
                    {metric.val}
                  </span>
                </div>
              ))}
            </div>

            {/* Direct Brochure CTAs */}
            <div className="flex flex-wrap gap-4 pt-2">
              <Link
                href="https://realswitchgears.com/assets/images/products/salzer/pdf/accl-brochure-print-filecompressed.pdf"
                target="_blank"
                className="inline-flex items-center gap-2 bg-slate-900 hover:bg-slate-800 text-white text-xs font-bold px-6 py-3.5 rounded-xl transition-all group"
              >
                <FaDownload className="w-3.5 h-3.5 group-hover:translate-y-0.5 transition-transform" />
                Download ACCL Catalog
              </Link>
              <Link
                href="/contact"
                className="inline-flex items-center gap-2 bg-amber-500 hover:bg-amber-600 text-slate-950 text-xs font-bold px-6 py-3.5 rounded-xl transition-all shadow-sm"
              >
                Enquire Now <FaEnvelope className="w-3.5 h-3.5" />
              </Link>
            </div>
          </div>

        </div>

        {/* ─── INTERACTIVE ARCHITECTURE SPECIFICATION VIEWER ──── */}
        <div className="mb-20">
          <div className="flex items-center gap-3 mb-10 border-b border-slate-200/60 pb-4">
            <div className="p-2 bg-slate-100 border border-slate-200 text-slate-700 rounded-xl">
              <LuLayers className="w-5 h-5" />
            </div>
            <div>
              <h2 className="text-lg font-black text-slate-900">Technical Specifications &amp; Operational Matrix</h2>
              <p className="text-xs text-slate-500 font-medium">
                Select an engineering parameter to examine short-circuit lab validations, internal coil efficiency metrics, and overload timing tolerances.
              </p>
            </div>
          </div>

          <div className="grid grid-cols-1 lg:grid-cols-12 gap-8 items-start">

            {/* Left Control Panel Column */}
            <div className="lg:col-span-5 space-y-2">
              {technicalSpecifications.map((spec) => (
                <button
                  key={spec.id}
                  onClick={() => setActiveSpecId(spec.id)}
                  className={`w-full text-left p-3.5 rounded-xl border text-xs font-bold transition-all flex items-center justify-between group ${activeSpecId === spec.id
                    ? "bg-slate-900 text-white border-slate-950 shadow-xs"
                    : "bg-white text-slate-700 border-slate-200 hover:bg-slate-100"
                    }`}
                >
                  <span className="truncate">{spec.title}</span>
                  <FaChevronRight className={`w-2.5 h-2.5 opacity-70 group-hover:translate-x-0.5 transition-transform ${activeSpecId === spec.id ? "text-white" : "text-slate-400"
                    }`} />
                </button>
              ))}
            </div>

            {/* Right Details Information Block */}
            <div className="lg:col-span-7 bg-white border border-slate-200 rounded-2xl p-6 md:p-8 min-h-[220px] flex flex-col justify-between shadow-xs">
              {(() => {
                const specMatch = technicalSpecifications.find((s) => s.id === activeSpecId)!;
                return (
                  <>
                    <div className="space-y-4">
                      <div>
                        <span className="text-[10px] font-black tracking-widest text-amber-600 uppercase block mb-1">
                          {specMatch.category}
                        </span>
                        <h3 className="text-base font-black text-slate-900">
                          {specMatch.title}
                        </h3>
                      </div>
                      <p className="text-xs md:text-sm text-slate-600 font-medium leading-relaxed pt-2 border-t border-slate-100">
                        {specMatch.technicalDetails}
                      </p>
                    </div>

                    <div className="mt-6 pt-4 border-t border-slate-100 flex items-center justify-between text-[11px] text-slate-400 font-bold">
                      <span className="flex items-center gap-1 text-slate-700">
                        <LuShieldCheck className="w-3.5 h-3.5" /> Break-Before-Make Air Gap Safety
                      </span>
                      <span>Auto Reset Active</span>
                    </div>
                  </>
                );
              })()}
            </div>

          </div>
        </div>

        {/* ─── PRODUCT LINEUP VARIATION MAPPING ───────────────── */}
        <div className="mb-20">
          <div className="flex items-center gap-3 mb-8 border-b border-slate-200/60 pb-4">
            <div className="p-2 bg-slate-100 border border-slate-200 text-slate-700 rounded-xl">
              <LuActivity className="w-5 h-5" />
            </div>
            <div>
              <h2 className="text-lg font-black text-slate-900">Engineered Features &amp; Performance Highlights</h2>
              <p className="text-xs text-slate-500 font-medium">
                Advanced performance characteristics built directly into the micro-contactor framing core.
              </p>
            </div>
          </div>

          <div className="grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-3 gap-4">
            {productFeatures.map((feature, index) => (
              <div
                key={index}
                className="bg-white border border-slate-200 rounded-xl p-4 flex items-center gap-3 shadow-xs hover:border-amber-300 transition-colors"
              >
                <div className="w-2 h-2 rounded-full bg-amber-500 shrink-0" />
                <span className="text-xs font-bold text-slate-700 leading-tight">
                  {feature}
                </span>
              </div>
            ))}
          </div>
        </div>

        {/* ─── STRUCTURAL ADVANTAGES CARDS ────────────────────── */}
        <div className="grid grid-cols-1 md:grid-cols-3 gap-6 mb-20">
          <div className="bg-white border border-slate-200 rounded-2xl p-5 shadow-xs flex items-start gap-4">
            <div className="p-2.5 bg-amber-50 border border-amber-100 rounded-xl text-amber-700 shrink-0">
              <LuClock className="w-5 h-5" />
            </div>
            <div className="space-y-1">
              <h4 className="text-xs font-black text-slate-900">10-Second Intelligent Overload Window</h4>
              <p className="text-[11px] text-slate-500 font-medium leading-relaxed">
                When thresholds are exceeded, power remains active for 10 seconds. This grace period gives users time to manually switch off high-drain appliances before a trip occurs.
              </p>
            </div>
          </div>
          <div className="bg-white border border-slate-200 rounded-2xl p-5 shadow-xs flex items-start gap-4">
            <div className="p-2.5 bg-blue-50 border border-blue-100 rounded-xl text-blue-700 shrink-0">
              <LuZap className="w-5 h-5" />
            </div>
            <div className="space-y-1">
              <h4 className="text-xs font-black text-slate-900">Ultra-Low Standby Thermal Rise</h4>
              <p className="text-[11px] text-slate-500 font-medium leading-relaxed">
                Consuming less than 0.2 VA of energy while running on primary mains power, the ACCL maintains a cool internal profile, dramatically reducing thermal stress.
              </p>
            </div>
          </div>
          <div className="bg-white border border-slate-200 rounded-2xl p-5 shadow-xs flex items-start gap-4">
            <div className="p-2.5 bg-red-50 border border-red-100 rounded-xl text-red-700 shrink-0">
              <LuLayers className="w-5 h-5" />
            </div>
            <div className="space-y-1">
              <h4 className="text-xs font-black text-slate-900">Universal Retrofitting Options</h4>
              <p className="text-[11px] text-slate-500 font-medium leading-relaxed">
                Engineered for quick deployment across standard layouts. Fully compatible with both single sub-main and dual sub-main building wiring systems.
              </p>
            </div>
          </div>
        </div>

        {/* ─── COMMERCIAL INQUIRY BLOCK ──────────────────────── */}
        <div className="bg-gradient-to-br from-slate-900 to-slate-800 text-white rounded-3xl p-8 md:p-12 text-center max-w-4xl mx-auto shadow-xs">
          <div className="inline-flex p-3 bg-slate-800 rounded-2xl border border-slate-700 text-amber-500 mb-4">
            <LuCpu className="w-6 h-6" />
          </div>
          <h3 className="text-xl md:text-2xl font-black text-white mb-3">
            Optimize Commercial Power Distribution Networks
          </h3>
          <p className="text-slate-400 text-sm max-w-xl mx-auto mb-8 font-medium">
            Consult with our engineering team to review current trip curves, multi-dwelling layouts, and specific current-limiter integration plans for your property infrastructure.
          </p>
          <div className="flex flex-col sm:flex-row justify-center items-center gap-4">
            <Link
              href="https://realswitchgears.com/assets/images/products/salzer/pdf/accl-brochure-print-filecompressed.pdf"
              target="_blank"
              className="inline-flex items-center gap-2 bg-slate-800 hover:bg-slate-700 text-white text-xs font-bold px-8 py-4 rounded-full transition-all w-full sm:w-auto justify-center uppercase tracking-wider border border-slate-700"
            >
              <FaDownload className="w-3.5 h-3.5" /> Technical Brochure PDF
            </Link>
            <Link
              href="/contact"
              className="inline-flex items-center gap-2 bg-amber-500 hover:bg-amber-600 text-slate-950 text-xs font-bold px-8 py-4 rounded-full transition-all duration-200 active:scale-95 shadow-md shadow-amber-500/10 w-full sm:w-auto justify-center uppercase tracking-wider"
            >
              Contact Our Engineers
              <FaChevronRight className="w-3 h-3" />
            </Link>
          </div>
        </div>

      </div >
    </div >
  );
}