"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,
  LuThermometer,
  LuFlame,
  LuWorkflow,
  LuActivity,
  LuShieldAlert
} from "react-icons/lu";

export const metadata = {
  title: "Polycab ICEA S-93-639 MV HT Cables | EPR Insulated Power Cable",
  description: "Explore Polycab Medium Voltage High Tension power cables conforming to ICEA S-93-639. Features 105°C EPR insulation, 5kV to 36kV options, and halogen-free fire protection.",
  keywords: ["Polycab ICEA S-93-639", "EPR Insulated Cable", "High Tension Cable", "Triple Extrusion Screen", "Medium Voltage Power Cable"],
};

interface CableLayer {
  id: string;
  name: string;
  materialSpec: string;
  benefit: string;
}

export default function PolycabIceaCableDetail() {
  const [activeLayerId, setActiveLayerId] = useState<string>("layer-1");

  const coreSpecs = [
    { label: "Standard Metric", val: "ICEA S-93-639" },
    { label: "Voltage Range", val: "5 kV to 36 kV" },
    { label: "Insulation Core", val: "EPR Thermoset (105°C)" },
    { label: "Fire Profile", val: "Halogen Free Flame Retardant" }
  ];

  const layerData: CableLayer[] = [
    {
      id: "layer-1",
      name: "1. Core Conductor",
      materialSpec: "High conductivity annealed plain stranded compacted aluminium / copper",
      benefit: "Produced in-house using state-of-the-art machinery to guarantee maximum electrical conductance and absolute geometric uniformity."
    },
    {
      id: "layer-2",
      name: "2. Conductor Screen",
      materialSpec: "Extruded layer of cross-linkable semi-conducting compound",
      benefit: "Eliminates sharp structural points on the conductor surface and nullifies the chance of electrical discharge at the conductor-insulation interface."
    },
    {
      id: "layer-3",
      name: "3. Primary Insulation",
      materialSpec: "In-house developed high insulation resistance Ethylene Propylene Rubber (EPR)",
      benefit: "Engineered for superior thermal endurance up to 105°C. High-performance XLPE insulation is also available on demand."
    },
    {
      id: "layer-4",
      name: "4. Non-Metallic Insulation Screen",
      materialSpec: "Extruded layer of cross-linkable semi-conducting compound",
      benefit: "Applied in a simultaneous triple-extrusion process alongside the conductor screen and insulation to completely eliminate micro-voids, maximizing cable life."
    },
    {
      id: "layer-5",
      name: "5. Metallic Shield Matrix",
      materialSpec: "Helically applied copper tape screen",
      benefit: "Provides an efficient low-resistance path to carry fault currents safely. Corrugated or round wire copper screening is optional."
    },
    {
      id: "layer-6",
      name: "6. Laying Up & Core Fillers",
      materialSpec: "Laid up together with in-house developed fillers",
      benefit: "For 3-core variants, insulated elements are nested with specialized fillers to preserve perfect circularity. Includes an optional ground wire for earthing."
    },
    {
      id: "layer-7",
      name: "7. Structural Binding Tape",
      materialSpec: "High-tensile wrapping tape",
      benefit: "Helically applied over the 3-core laid-up element assembly to lock the bundle securely before final sheathing phases."
    },
    {
      id: "layer-8",
      name: "8. Mechanical Armor (Optional)",
      materialSpec: "Heavy-duty protective metallic armoring layer",
      benefit: "Furnishes robust physical impact defense and serves concurrently as a reliable return path for ground earth fault currents."
    },
    {
      id: "layer-9",
      name: "9. Outer Protect Sheath",
      materialSpec: "In-house developed thermoplastic compound",
      benefit: "Formulated to resist heavy mechanical friction and climate hazards while ensuring exceptionally low emissions of toxic smoke and corrosive gases during fire exposure."
    }
  ];

  return (
    <div className="min-h-screen bg-slate-50 text-slate-800 py-16 lg:py-24 selection:bg-amber-100 selection:text-amber-950">
      <div className="container mx-auto px-4 max-w-7xl">

        {/* ─── HERO VIEWPORT / MARKETING GRID ────────────────── */}
        <div className="grid grid-cols-1 lg:grid-cols-12 gap-12 items-center mb-20">

          {/* Left Block: Image Viewport */}
          <div className="lg:col-span-5 flex justify-center order-2 lg:order-1">
            <div className="relative w-full max-w-[420px] aspect-square rounded-3xl overflow-hidden bg-white border border-slate-200 p-6 shadow-xs group">
              <div className="relative w-full h-full">
                <Image
                  src="https://realswitchgears.com/assets/images/products/polycab-cable/mv-power-cable/MV-Power-Cable-ICEA.png"
                  alt="Polycab ICEA S-93-639 medium voltage high tension power cable"
                  fill
                  priority
                  className="object-contain group-hover:scale-105 transition-transform duration-500"
                  sizes="(max-width: 768px) 100vw, 420px"
                />
              </div>
            </div>
          </div>

          {/* Right Block: Cable Attributes & Text */}
          <div className="lg:col-span-7 space-y-6 order-1 lg:order-2">
            <span className="inline-flex items-center gap-1.5 rounded-full bg-amber-50 px-4 py-1.5 text-xs font-bold tracking-wider text-amber-800 uppercase border border-amber-200">
              High Temperature Series
            </span>

            <h1 className="text-3xl md:text-4xl font-black tracking-tight text-slate-900 leading-tight">
              Polycab ICEA S-93-639 <br />
              <span className="text-amber-600 font-extrabold text-xl md:text-2xl block mt-2">
                Medium Voltage High Tension Power Cables
              </span>
            </h1>

            <div className="space-y-4 text-slate-600 text-sm md:text-base leading-relaxed font-medium">
              <p>
                Polycab Medium Voltage High Tension (MV HT) power cables are precision engineered to meet the stringent benchmarks of the <strong>ICEA S-93-639 standard</strong>, covering diverse distribution networks graded from <strong>5 kV up to 36 kV</strong>.
              </p>
              <p>
                Built for deep environmental endurance, these distribution runs are highly versatile—ideal for installation inside structural conduits, open trays, routing troughs, cable ducts, or via <strong>direct burial across both wet and dry conditions</strong>.
              </p>
              <p>
                Equipped with premium <strong>Ethylene Propylene Rubber (EPR) thermoset insulation</strong> as standard, they operate comfortably under continuous thermal loads hitting <strong>105°C</strong> (high insulation resistance XLPE insulation is available on demand).
              </p>
              <p>
                Boasting <strong>halogen-free flame retardant characteristics</strong>, these cables prevent fire spread, providing robust load delivery alongside active protection against intense short circuits.
              </p>
            </div>

            {/* Quick Metrics Reference Board */}
            <div className="grid grid-cols-2 sm:grid-cols-4 gap-3 bg-white border border-slate-200 p-4 rounded-2xl shadow-xs">
              {coreSpecs.map((spec, idx) => (
                <div key={idx} 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">
                    {spec.label}
                  </span>
                  <span className="text-xs font-black text-slate-900 leading-snug">
                    {spec.val}
                  </span>
                </div>
              ))}
            </div>

            {/* Action Buttons */}
            <div className="flex flex-wrap gap-4 pt-2">
              <Link
                href="https://realswitchgears.com/assets/images/products/polycab-cable/mv-power-cable/pdf/MV-Power-Cable-ICEA.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 ICEA 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"
              >
                Send Enquiry <FaEnvelope className="w-3.5 h-3.5" />
              </Link>
            </div>
          </div>

        </div>

        {/* ─── INTERACTIVE LAYER DATA SYSTEM ──────────────────── */}
        <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">Cross-Sectional Material Profile</h2>
              <p className="text-xs text-slate-500 font-medium">
                Select an engineering layer below to view material specifications, structural compositions, and safety parameters.
              </p>
            </div>
          </div>

          <div className="grid grid-cols-1 lg:grid-cols-12 gap-8 items-start">

            {/* Left Column Controllers */}
            <div className="lg:col-span-5 max-h-[480px] overflow-y-auto pr-2 space-y-2 scrollbar-thin scrollbar-thumb-slate-200">
              {layerData.map((layer) => (
                <button
                  key={layer.id}
                  onClick={() => setActiveLayerId(layer.id)}
                  className={`w-full text-left p-3.5 rounded-xl border text-xs font-bold transition-all flex items-center justify-between group ${activeLayerId === layer.id
                    ? "bg-amber-500 text-slate-950 border-amber-600 shadow-sm"
                    : "bg-white text-slate-700 border-slate-200 hover:bg-slate-100"
                    }`}
                >
                  <span className="truncate">{layer.name}</span>
                  <FaChevronRight className={`w-2.5 h-2.5 opacity-70 group-hover:translate-x-0.5 transition-transform ${activeLayerId === layer.id ? "text-slate-950" : "text-slate-400"
                    }`} />
                </button>
              ))}
            </div>

            {/* Right Information Dynamic Display */}
            <div className="lg:col-span-7 bg-white border border-slate-200 rounded-2xl p-6 md:p-8 min-h-[290px] flex flex-col justify-between shadow-xs">
              {(() => {
                const targetLayer = layerData.find((l) => l.id === activeLayerId)!;
                return (
                  <>
                    <div className="space-y-4">
                      <div>
                        <span className="text-[10px] font-black tracking-widest text-amber-600 uppercase block mb-1">
                          Material Engineering Specifications
                        </span>
                        <h3 className="text-base font-black text-slate-900">
                          {targetLayer.name.substring(3)}
                        </h3>
                      </div>
                      <div className="inline-block bg-slate-100 text-slate-800 text-[11px] font-extrabold px-3 py-1.5 rounded-md border border-slate-200">
                        {targetLayer.materialSpec}
                      </div>
                      <p className="text-xs md:text-sm text-slate-600 font-medium leading-relaxed pt-2">
                        {targetLayer.benefit}
                      </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-blue-600">
                        <LuWorkflow className="w-3.5 h-3.5" /> High-Purity Compounding
                      </span>
                      <span>ICEA S-93-639 Compliant</span>
                    </div>
                  </>
                );
              })()}
            </div>

          </div>
        </div>

        {/* ─── VALUE MATRIX SPEC 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">
              <LuThermometer className="w-5 h-5" />
            </div>
            <div className="space-y-1">
              <h4 className="text-xs font-black text-slate-900">105°C Continuous Thermals</h4>
              <p className="text-[11px] text-slate-500 font-medium leading-relaxed">
                Premium EPR thermoset insulation handles elevated high-load distribution runs comfortably over standard 90°C compounds.
              </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-rose-50 border border-rose-100 rounded-xl text-rose-700 shrink-0">
              <LuFlame className="w-5 h-5" />
            </div>
            <div className="space-y-1">
              <h4 className="text-xs font-black text-slate-900">Low Smoke & Acid Safety</h4>
              <p className="text-[11px] text-slate-500 font-medium leading-relaxed">
                Advanced thermoplastic outers restrict harmful emissions and corrosive gas output if exposed to severe fires.
              </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">
              <LuActivity className="w-5 h-5" />
            </div>
            <div className="space-y-1">
              <h4 className="text-xs font-black text-slate-900">Dual Submersion Endurance</h4>
              <p className="text-[11px] text-slate-500 font-medium leading-relaxed">
                Extruded materials provide long life cycles and protect circuits reliably within both wet and dry installations.
              </p>
            </div>
          </div>
        </div>

        {/* ─── PROCUREMENT CALL TO ACTION ─────────────────────── */}
        <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">
            <LuShieldAlert className="w-6 h-6" />
          </div>
          <h3 className="text-xl md:text-2xl font-black text-white mb-3">
            Source Certified ICEA S-93-639 High-Tension Cables
          </h3>
          <p className="text-slate-400 text-sm max-w-xl mx-auto mb-8 font-medium">
            Get in touch with our commercial sales desk to configure custom core counts, cross-sectional conductor configurations, or obtain immediate budget estimates.
          </p>
          <div className="flex flex-col sm:flex-row justify-center items-center gap-4">
            <Link
              href="https://realswitchgears.com/assets/images/products/polycab-cable/mv-power-cable/pdf/MV-Power-Cable-ICEA.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 Specification 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"
            >
              Request Commercial Quote
              <FaChevronRight className="w-3 h-3" />
            </Link>
          </div>
        </div>

      </div >
    </div >
  );
}