"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 {
  LuShield,
  LuThermometer,
  LuFactory,
  LuFlameKindling,
  LuSlidersHorizontal,
  LuSparkles
} from "react-icons/lu";

interface MaterialLayer {
  id: string;
  name: string;
  material: string;
  description: string;
}

export default function PolycabBs5467CableDetail() {
  const [selectedLayerId, setSelectedLayerId] = useState<string>("layer-1");

  const coreTechnicalParameters = [
    { label: "Standard Metric", val: "BS 5467 Standard" },
    { label: "Voltage Grades", val: "600/1000V & 1900/3300V" },
    { label: "Core Availability", val: "Single & Multicore Options" },
    { label: "Max Core Temp", val: "90°C Continuous / 250°C Short-Circuit" }
  ];

  const layerData: MaterialLayer[] = [
    {
      id: "layer-1",
      name: "1. Advanced Core Conductor",
      material: "High-Conductivity Annealed Plain Stranded Copper",
      description: "Manufactured directly from Polycab's state-of-the-art, in-house Contirod line, providing maximum raw electrical conductivity and reliable power transfer efficiency."
    },
    {
      id: "layer-2",
      name: "2. Primary Insulation",
      material: "In-House Thermoset XLPE / EPR Compound",
      description: "Developed with high insulation resistance Cross-Linked Polyethylene (XLPE) or Ethylene Propylene Rubber (EPR) to withstand harsh operational stress over extended spans."
    },
    {
      id: "layer-3",
      name: "3. Polymeric Bedding Barrier",
      material: "Extruded Polymeric Compound Layer",
      description: "Forms a precise structural buffer profile between the inner electrical insulation boundaries and the outer mechanical armoring matrix."
    },
    {
      id: "layer-4",
      name: "4. Tensile Armor Matrix",
      material: "Galvanized Steel Wire (SWA) or Aluminum Wire (AWA)",
      description: "Provides dense directional coverage that allows the cable system to withstand extreme external mechanical impacts and structural tensile stresses during installation."
    },
    {
      id: "layer-5",
      name: "5. Toughened Outer Jacket",
      material: "In-House Formulated Polyvinyl Chloride (PVC)",
      description: "Engineered to deliver heavy abrasion shielding and long-term environmental resistance, customized directly to unique on-site installation environments."
    }
  ];

  return (
    <div className="min-h-screen bg-white text-slate-800 py-12 md:py-20 lg:py-28 xl:py-36 selection:bg-cyan-100 selection:text-cyan-950">
      <div className="container mx-auto px-4 sm:px-6 lg:px-8 max-w-7xl xl:max-w-[1600px] 2xl:max-w-[1800px]">

        {/* ─── HERO SECTION & IMAGE GRID ──────────────────────── */}
        <div className="bg-slate-50 rounded-3xl p-6 md:p-12 xl:p-16 border border-slate-200/60 shadow-xs grid grid-cols-1 lg:grid-cols-12 gap-12 xl:gap-16 items-center mb-12 xl:mb-16">

          {/* Left: Product Image Container */}
          <div className="lg:col-span-5 flex justify-center order-2 lg:order-1">
            <div className="relative w-full max-w-[420px] xl:max-w-[500px] aspect-square rounded-2xl bg-white border border-slate-200 p-6 xl:p-10 shadow-xs group">
              <div className="relative w-full h-full">
                <Image
                  src="/images/polycab/MV-Power-Cable-BS_5467.png"
                  alt="Polycab BS 5467 XLPE insulated round wire armored low to medium voltage power cable structure"
                  fill
                  priority
                  className="object-contain group-hover:scale-105 transition-transform duration-500"
                  sizes="(max-width: 768px) 100vw, (max-width: 1280px) 420px, 500px"
                />
              </div>
            </div>
          </div>

          {/* Right: Technical Product Description */}
          <div className="lg:col-span-7 space-y-6 xl:space-y-8 order-1 lg:order-2">
            <span className="inline-flex items-center gap-1.5 rounded-full bg-cyan-50 px-4 py-1.5 text-xs xl:text-sm font-bold tracking-wider text-cyan-800 uppercase border border-cyan-200">
              British Standard Certified Range
            </span>

            <h1 className="text-3xl md:text-4xl xl:text-5xl 2xl:text-6xl font-black tracking-tight text-slate-900 leading-tight">
              Polycab BS 5467 Armored Cables <br />
              <span className="text-cyan-500 font-extrabold text-xl md:text-2xl xl:text-3xl block mt-2">
                XLPE Insulated Low & Medium Voltage Power Systems
              </span>
            </h1>

            <div className="space-y-4 text-slate-600 text-sm md:text-base xl:text-lg leading-relaxed font-medium">
              <p>
                Polycab manufactures a high-performance selection of low and medium voltage armored cables covering{" "}
                <strong>600/1000V and 1900/3300V</strong> specifications, strictly adhering to the dimensional, constructional, and safety requirements of British Standard **BS 5467**.
              </p>
              <p>
                Engineered for heavy-duty operational stability, these round wire armored profiles are exceptionally suited for fixed indoor or outdoor installations across industrial complexes, major commercial developments, structural cable ductings, and demanding utility grids.
              </p>
            </div>

            {/* Quick Metrics Dashboard */}
            <div className="grid grid-cols-2 sm:grid-cols-4 gap-3 xl:gap-4 bg-white border border-slate-200/60 p-4 rounded-2xl shadow-xs">
              {coreTechnicalParameters.map((param, index) => (
                <div key={index} className="bg-slate-50 border border-slate-100 p-3 xl:p-4 rounded-xl text-center flex flex-col justify-center">
                  <span className="text-[10px] xl:text-xs text-slate-400 font-bold uppercase tracking-wider block mb-1">
                    {param.label}
                  </span>
                  <span className="text-xs xl:text-sm font-black text-slate-900 leading-snug">
                    {param.val}
                  </span>
                </div>
              ))}
            </div>

            {/* Action Interactions Selection */}
            <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-BS_5467.pdf"
                target="_blank"
                className="inline-flex items-center gap-2 bg-slate-900 hover:bg-slate-800 text-white text-xs xl:text-sm font-bold px-6 py-3.5 xl:px-8 xl:py-4 rounded-xl transition-all group shadow-sm"
              >
                <FaDownload className="w-3.5 h-3.5 group-hover:translate-y-0.5 transition-transform" />
                Download BS 5467 PDF
              </Link>
              <Link
                href="/contact"
                className="inline-flex items-center gap-2 bg-cyan-500 hover:bg-cyan-600 text-white text-xs xl:text-sm font-bold px-6 py-3.5 xl:px-8 xl:py-4 rounded-xl transition-all shadow-md shadow-cyan-500/10"
              >
                Send Enquiry <FaEnvelope className="w-3.5 h-3.5" />
              </Link>
            </div>
          </div>

        </div>

        {/* ─── DYNAMIC CROSS-SECTION INTERACTIVE SPEC EXPLORER ─── */}
        <div className="bg-slate-50 rounded-3xl p-6 md:p-12 xl:p-16 border border-slate-200/60 shadow-xs mb-12 xl:mb-16">
          <div className="flex items-center gap-3 mb-10 border-b border-slate-200/80 pb-6">
            <div className="p-2.5 bg-cyan-50 border border-cyan-100 text-cyan-600 rounded-xl">
              <LuSlidersHorizontal className="w-5 h-5 xl:w-6 xl:h-6" />
            </div>
            <div>
              <h2 className="text-lg xl:text-2xl font-black text-slate-900">Cable Layer Architecture</h2>
              <p className="text-xs xl:text-sm text-slate-500 font-medium mt-0.5">
                Select an internal layer component below to inspect specific material properties and industrial structural shielding dimensions.
              </p>
            </div>
          </div>

          <div className="grid grid-cols-1 lg:grid-cols-12 gap-8 xl:gap-12 items-start">

            {/* Left Content List Controls */}
            <div className="lg:col-span-5 space-y-2.5 xl:space-y-3">
              {layerData.map((layer) => (
                <button
                  key={layer.id}
                  onClick={() => setSelectedLayerId(layer.id)}
                  className={`w-full text-left p-4 xl:p-5 rounded-xl border text-xs xl:text-sm font-bold transition-all flex items-center justify-between group ${selectedLayerId === layer.id
                    ? "bg-cyan-500 text-white border-cyan-600 shadow-md shadow-cyan-500/20"
                    : "bg-white text-slate-700 border-slate-200 hover:bg-slate-100 shadow-xs"
                    }`}
                >
                  <span className="truncate">{layer.name}</span>
                  <FaChevronRight className={`w-2.5 h-2.5 xl:w-3 xl:h-3 opacity-70 group-hover:translate-x-0.5 transition-transform ${selectedLayerId === layer.id ? "text-white" : "text-slate-400"
                    }`} />
                </button>
              ))}
            </div>

            {/* Right Interactive Detail Monitor */}
            <div className="lg:col-span-7 bg-white border border-slate-200 rounded-2xl p-6 md:p-8 xl:p-12 min-h-[260px] xl:min-h-[340px] flex flex-col justify-between shadow-xs">
              {(() => {
                const layer = layerData.find((l) => l.id === selectedLayerId)!;
                return (
                  <>
                    <div className="space-y-4 xl:space-y-6">
                      <div>
                        <span className="text-[10px] xl:text-xs font-black tracking-widest text-cyan-500 uppercase block mb-1">
                          Layer Composition Matrix
                        </span>
                        <h3 className="text-base xl:text-xl font-black text-slate-900">
                          {layer.name.substring(3)}
                        </h3>
                      </div>
                      <div className="inline-block bg-slate-50 text-slate-800 text-[11px] xl:text-xs font-extrabold px-3 py-1.5 rounded-md border border-slate-200 shadow-xs">
                        {layer.material}
                      </div>
                      <p className="text-xs md:text-sm xl:text-base text-slate-600 font-medium leading-relaxed pt-2">
                        {layer.description}
                      </p>
                    </div>

                    <div className="mt-6 pt-4 border-t border-slate-100 flex items-center justify-between text-[11px] xl:text-xs text-slate-400 font-bold">
                      <span className="flex items-center gap-1 text-emerald-600">
                        <LuSparkles className="w-3.5 h-3.5 xl:w-4 xl:h-4" /> Premium Raw Sourcing
                      </span>
                      <span>BS 5467 Application Compliant</span>
                    </div>
                  </>
                );
              })()}
            </div>

          </div>
        </div>

        {/* ─── THERMAL DESIGN & INSTALLATION REASSURANCES ──────── */}
        <div className="grid grid-cols-1 md:grid-cols-3 gap-6 xl:gap-8 mb-12 xl:mb-16">
          <div className="bg-slate-50 border border-slate-200/60 rounded-2xl p-6 xl:p-8 shadow-xs flex items-start gap-4">
            <div className="p-2.5 bg-cyan-50 border border-cyan-100 rounded-xl text-cyan-500 shrink-0">
              <LuThermometer className="w-5 h-5 xl:w-6 xl:h-6" />
            </div>
            <div className="space-y-1">
              <h4 className="text-xs xl:text-sm font-black text-slate-900">Continuous 90°C Operations</h4>
              <p className="text-[11px] xl:text-xs text-slate-500 font-medium leading-relaxed">
                Advanced XLPE thermoset core compounds maintain reliable current carrying capacity at continuous baseline grid operating thresholds of 90°C.
              </p>
            </div>
          </div>
          <div className="bg-slate-50 border border-slate-200/60 rounded-2xl p-6 xl:p-8 shadow-xs flex items-start gap-4">
            <div className="p-2.5 bg-cyan-50 border border-cyan-100 rounded-xl text-cyan-500 shrink-0">
              <LuFlameKindling className="w-5 h-5 xl:w-6 xl:h-6" />
            </div>
            <div className="space-y-1">
              <h4 className="text-xs xl:text-sm font-black text-slate-900">250°C Short-Circuit Boundary</h4>
              <p className="text-[11px] xl:text-xs text-slate-500 font-medium leading-relaxed">
                Guarantees complete protection during sudden extreme electrical surges, handling localized peak fault heat thresholds up to 250°C.
              </p>
            </div>
          </div>
          <div className="bg-slate-50 border border-slate-200/60 rounded-2xl p-6 xl:p-8 shadow-xs flex items-start gap-4">
            <div className="p-2.5 bg-cyan-50 border border-cyan-100 rounded-xl text-cyan-500 shrink-0">
              <LuFactory className="w-5 h-5 xl:w-6 xl:h-6" />
            </div>
            <div className="space-y-1">
              <h4 className="text-xs xl:text-sm font-black text-slate-900">Contirod Copper Cast Line</h4>
              <p className="text-[11px] xl:text-xs text-slate-500 font-medium leading-relaxed">
                Utilizes high-purity annealed plain stranded copper conductors drawn from continuous precision production lines for unparalleled signal and power purity.
              </p>
            </div>
          </div>
        </div>

        {/* ─── TECHNICAL PROCUREMENT CALL TO ACTION ────────────── */}
        <div className="flex flex-col sm:flex-row justify-center items-center gap-4 w-full">
          <Link
            href="https://realswitchgears.com/assets/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>
  );
}