"use client";

import React, { useState } from "react";
import Image from "next/image";
import Link from "next/link";
import { FaDownload, FaEnvelope, FaChevronRight ,FaArrowRight} from "react-icons/fa6";
import {
  LuLayers,
  LuSparkles,
  LuShieldCheck,
  LuFactory,
  LuZap,
  LuTimer
} from "react-icons/lu";

// Next.js client component metadata boundary note: 
// If using Next.js App Router, move metadata to a separate layout.tsx or server component file.
// export const metadata = {
//   title: "Polycab Extra High Voltage (EHV) Power Cables | 66kV - 220kV",
//   description: "Explore Polycab Extra High Voltage (EHV) underground power cables ranging from 66 kV to 220 kV. Built with premium XLPE insulation and dynamic triple extrusion.",
//   keywords: ["Polycab EHV Cable", "Extra High Voltage Power Cable", "66kV Cable", "220kV Transmission Wire", "XLPE Underground Cable"],
// };

interface TechnicalSpec {
  id: string;
  title: string;
  category: string;
  technicalDetails: string;
}

export default function PolycabEhvPowerCable() {
  const [activeSpecId, setActiveSpecId] = useState<string>("spec-1");

  const engineeringMetrics = [
    { label: "Voltage Range", val: "66 kV to 220 kV" },
    { label: "Designed Service Life", val: "40 Years Rating" },
    { label: "Conductor Alloys", val: "Copper & Aluminum" },
    { label: "Network Phases", val: "3-Phase AC Circuits" }
  ];

  const technicalSpecifications: TechnicalSpec[] = [
    {
      id: "spec-1",
      title: "Extruded Semiconducting Conductor Screen",
      category: "Conductor Screening",
      technicalDetails: "Consists of an extruded layer of a specialized semiconducting thermosetting compound that completely covers the outer conductor contours. It bonds firmly to the XLPE insulation layer to eliminate electrical field stress concentrations. A non-hygroscopic semiconducting tape layer is applied directly over the conductor when required."
    },
    {
      id: "spec-2",
      title: "High Resistance XLPE Insulation Matrix",
      category: "Dielectric Layer",
      technicalDetails: "Constructed with Polycab's proprietary, in-house developed cross-linked polyethylene (XLPE) thermoset insulation compound. This layer is engineered to deliver exceptional insulation resistance, withstand high thermal loading, and maintain structural integrity across high-voltage stresses."
    },
    {
      id: "spec-3",
      title: "Void-Free Triple Extrusion Insulation Screen",
      category: "Core Electrical Protection",
      technicalDetails: "Features a non-metallic insulation screen comprised of an extruded layer of cross-linkable semiconducting compound. This layer is applied via an advanced triple extrusion process simultaneously with the conductor screen and insulation, completely eliminating micro-voids and curing risks to unlock an elongated operating lifespan."
    },
    {
      id: "spec-4",
      title: "Heavy-Duty Fault Current Shielding",
      category: "Metallic Screening & Armor",
      technicalDetails: "Highly configurable metallic shield layer engineered to safely route high fault currents. Available options include copper wires, aluminum wires, a corrugated aluminum sheath, or a specialized lead/lead alloy sheath. A semiconducting tape layer may be integrated for advanced wire shielding stability."
    },
    {
      id: "spec-5",
      title: "Low-Smoke Thermoplastic HDPE Outer Sheath",
      category: "Environmental Defense Shell",
      technicalDetails: "Encapsulated within an in-house developed thermoplastic High-Density Polyethylene (HDPE) compound. This outer jacket is chemically optimized for low smoke and minimal corrosive gas emission when exposed to extreme fire hazards. A specialized semiconducting layer can be applied externally for shield testing validation."
    }
  ];

  return (
    <div className="min-h-screen bg-white text-slate-800 py-16 lg:py-24 2xl:py-32 selection:bg-cyan-100 selection:text-cyan-900">
      <div className="container mx-auto px-4 max-w-7xl 2xl:max-w-[1440px]">

        {/* ─── HERO BRAND / DETAILS SECTION ──────────────────── */}
        <div className="grid grid-cols-1 lg:grid-cols-12 gap-12 2xl:gap-16 items-center mb-20 2xl:mb-28">

          {/* Left Frame: Image Asset Viewport */}
          <div className="lg:col-span-5 flex justify-center order-2 lg:order-1">
            <div className="relative w-full max-w-[420px] 2xl:max-w-[500px] aspect-square rounded-3xl overflow-hidden bg-slate-50 border border-slate-100 p-8 shadow-xs group">
              <div className="relative w-full h-full">
                <Image
                  src="/images/polycab/EHV-Power-Cable-IEC.png"
                  alt="Polycab Extra High Voltage Power Cable System"
                  fill
                  priority
                  className="object-contain group-hover:scale-105 transition-transform duration-500"
                  sizes="(max-width: 768px) 100vw, (max-width: 1536px) 420px, 500px"
                />
              </div>
            </div>
          </div>

          {/* Right Frame: Text Narrative Content */}
          <div className="lg:col-span-7 space-y-6 2xl:space-y-8 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-cyan-400 uppercase border border-slate-800">
              Bulk Grid Transmission • Utility Scale Infrastructure
            </span>

            <h1 className="text-3xl md:text-4xl 2xl:text-5xl font-black tracking-tight text-slate-900 leading-tight">
              Polycab Extra High Voltage Cables <br />
              <span className="text-cyan-600 font-extrabold text-xl md:text-2xl 2xl:text-3xl block mt-2">
                66 kV to 220 kV Heavy Duty Underground Transmission Lines
              </span>
            </h1>

            <div className="space-y-4 text-slate-600 text-sm md:text-base 2xl:text-lg leading-relaxed font-medium">
              <p>
                Polycab’s <strong>Extra High Voltage (EHV) Power Cables</strong> provide unmatched dielectric strength and structural longevity for regional bulk power grids, precision engineered for <strong>underground 3-Phase AC grid networks</strong>.
              </p>
              <p>
                Leveraging premium Copper or high-grade Aluminum conductor elements spanning a <strong>66 kV to 220 kV capability range</strong>, these systems are designed to bridge power generation facilities directly to regional distribution centers or massive grid substations. Backed by decades of material testing, they provide a long-term reliable service life of <strong>40 years</strong>.
              </p>
              <p>
                Manufactured at Polycab’s cutting-edge facility in Halol, Gujarat, these lines are forged using premium machinery from <strong>Maillefer, Scholz, and John Royle</strong>. The plant runs on fully automated material feeding architectures to prevent trace atmospheric contamination, defending against micro-void creation and long-term electrical insulation breakdown.
              </p>
            </div>

            {/* Parameter Cards Summary Layout */}
            <div className="grid grid-cols-2 sm:grid-cols-4 gap-3 bg-slate-50 border border-slate-200 p-4 rounded-2xl">
              {engineeringMetrics.map((metric, index) => (
                <div key={index} className="bg-white border border-slate-100 p-3 rounded-xl text-center flex flex-col justify-center shadow-xs">
                  <span className="text-[10px] 2xl:text-xs text-slate-400 font-bold uppercase tracking-wider block mb-1">
                    {metric.label}
                  </span>
                  <span className="text-xs 2xl:text-sm 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="/images/products/polycab-cable/ehv-power-cable-iec/pdf/EHV-Power-Cable-IEC-1.pdf"
                target="_blank"
                className="inline-flex items-center gap-2 bg-slate-900 hover:bg-slate-800 text-white text-xs 2xl:text-sm font-bold px-6 py-3.5 2xl:px-8 2xl:py-4 rounded-xl transition-all group"
              >
                <FaDownload className="w-3.5 h-3.5 group-hover:translate-y-0.5 transition-transform" />
                Download EHV IEC Catalog
              </Link>
              <Link
                href="/contact"
                className="inline-flex items-center gap-2 bg-cyan-500 hover:bg-cyan-600 text-white text-xs 2xl:text-sm font-bold px-6 py-3.5 2xl:px-8 2xl:py-4 rounded-xl transition-all shadow-sm shadow-cyan-500/10"
              >
                Send Enquiry <FaEnvelope className="w-3.5 h-3.5" />
              </Link>
            </div>
          </div>

        </div>

        {/* ─── INTERACTIVE ARCHITECTURE SPECIFICATION VIEWER ──── */}
        <div className="mb-20 2xl:mb-28">
          <div className="flex items-center gap-3 mb-10 border-b border-slate-200 pb-4">
            <div className="p-2 bg-slate-50 border border-slate-200 text-slate-700 rounded-xl">
              <LuLayers className="w-5 h-5 text-cyan-600" />
            </div>
            <div>
              <h2 className="text-lg 2xl:text-xl font-black text-slate-900">EHV Structural Layering &amp; Screening Data</h2>
              <p className="text-xs 2xl:text-sm text-slate-500 font-medium">
                Interact with the dynamic breakdown below to inspect the triple-extrusion insulation and multi-metal shield boundaries.
              </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 2xl:text-sm font-bold transition-all flex items-center justify-between group ${activeSpecId === spec.id
                    ? "bg-slate-900 text-white border-slate-950 shadow-xs"
                    : "bg-slate-50 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-cyan-400" : "text-slate-400"
                    }`} />
                </button>
              ))}
            </div>

            {/* Right Details Information Block */}
            <div className="lg:col-span-7 bg-slate-50 border border-slate-200 rounded-2xl p-6 md:p-8 min-h-[240px] 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] 2xl:text-xs font-black tracking-widest text-cyan-600 uppercase block mb-1">
                          {specMatch.category}
                        </span>
                        <h3 className="text-base 2xl:text-lg font-black text-slate-900">
                          {specMatch.title}
                        </h3>
                      </div>
                      <p className="text-xs md:text-sm 2xl:text-base text-slate-600 font-medium leading-relaxed pt-2 border-t border-slate-200/60">
                        {specMatch.technicalDetails}
                      </p>
                    </div>

                    <div className="mt-6 pt-4 border-t border-slate-200/60 flex items-center justify-between text-[11px] 2xl:text-xs text-slate-400 font-bold">
                      <span className="flex items-center gap-1 text-slate-700">
                        <LuShieldCheck className="w-3.5 h-3.5 text-cyan-600" /> Triple-Extrusion Elimination of Micro-Voids
                      </span>
                      <span>HDPE Shield Enclosure</span>
                    </div>
                  </>
                );
              })()}
            </div>

          </div>
        </div>

        {/* ─── MANUFACTURING & LOGISTICS ADVANTAGE CARDS ─────── */}
        <div className="grid grid-cols-1 md:grid-cols-3 gap-6 mb-20 2xl:mb-28">
          <div className="bg-slate-50 border border-slate-200 rounded-2xl p-5 shadow-xs flex items-start gap-4">
            <div className="p-2.5 bg-white border border-slate-100 rounded-xl text-cyan-600 shrink-0 shadow-xs">
              <LuFactory className="w-5 h-5" />
            </div>
            <div className="space-y-1">
              <h4 className="text-xs 2xl:text-sm font-black text-slate-900">Halol Ultra-Modern Mega Facility</h4>
              <p className="text-[11px] 2xl:text-xs text-slate-500 font-medium leading-relaxed">
                Manufactured using premium automated feeding installations that isolate materials to entirely bypass contamination vectors and raw electrical fault risks.
              </p>
            </div>
          </div>
          <div className="bg-slate-50 border border-slate-200 rounded-2xl p-5 shadow-xs flex items-start gap-4">
            <div className="p-2.5 bg-white border border-slate-100 rounded-xl text-cyan-600 shrink-0 shadow-xs">
              <LuZap className="w-5 h-5" />
            </div>
            <div className="space-y-1">
              <h4 className="text-xs 2xl:text-sm font-black text-slate-900">High Speed Core Stranding</h4>
              <p className="text-[11px] 2xl:text-xs text-slate-500 font-medium leading-relaxed">
                Utilizes specialized high-speed stranding machinery blocks to build dense, compact, and structurally uniform copper/aluminum core assemblies.
              </p>
            </div>
          </div>
          <div className="bg-slate-50 border border-slate-200 rounded-2xl p-5 shadow-xs flex items-start gap-4">
            <div className="p-2.5 bg-white border border-slate-100 rounded-xl text-cyan-600 shrink-0 shadow-xs">
              <LuTimer className="w-5 h-5" />
            </div>
            <div className="space-y-1">
              <h4 className="text-xs 2xl:text-sm font-black text-slate-900">40-Year Extended Service Rating</h4>
              <p className="text-[11px] 2xl:text-xs text-slate-500 font-medium leading-relaxed">
                Advanced cross-linked compounding combined with a triple extrusion shield array guarantees stable deployment for multi-decade operations.
              </p>
            </div>
          </div>
        </div>

        {/* ─── COMMERCIAL INQUIRY BLOCK ──────────────────────── */}
        <div className="flex flex-col sm:flex-row justify-center items-center gap-4 w-full">
          <Link
            href="/images/products/polycab-cable/lv-power-cable/pdf/LV-Power-Cable-IS-1.pdf"
            target="_blank"
            className="inline-flex items-center justify-center gap-2 bg-slate-100 hover:bg-slate-200 text-slate-900 text-xs font-bold px-8 py-4 rounded-full transition-all w-full sm:w-auto uppercase tracking-wider border border-slate-200 shadow-xs"
          >
            <FaDownload className="w-3.5 h-3.5" />
            View Technical PDF
          </Link>

          <Link
            href="/contact"
            className="inline-flex items-center justify-center gap-2 bg-cyan-500 hover:bg-cyan-600 text-white text-xs xl:text-sm font-bold px-8 sm:px-10 py-4 rounded-full transition-all duration-200 active:scale-95 shadow-md shadow-cyan-500/10 w-full sm:w-auto uppercase tracking-wider"
          >
            Send Enquiry
            <FaArrowRight className="w-3.5 h-3.5 transition-transform group-hover:translate-x-0.5" />
          </Link>
        </div>

      </div >
    </div >
  );
}