"use client";

import React, { useState } from "react";
import Image from "next/image";
import Link from "next/link";
import { FaEnvelope, FaChevronRight, FaArrowRight } from "react-icons/fa6";
import {
  LuLayers,
  LuShieldCheck,
  LuCpu,
  LuRotateCw,
  LuGauge,
  LuCompass
} from "react-icons/lu";
import Breadcrumb from "@/components/Common/Breadcrumb";
interface TechnicalSpec {
  id: string;
  title: string;
  category: string;
  technicalDetails: string;
}

export default function RotaryLimitSwitches() {
  const [activeSpecId, setActiveSpecId] = useState<string>("spec-1");

  const engineeringMetrics = [
    { label: "Measurement Basis", val: "Rotation Angle" },
    { label: "Tracking Metric", val: "Shaft Revolutions" },
    { label: "Limit Settings", val: "Upper & Lower" },
    { label: "Intermediate Control", val: "Multi-Point Ready" }
  ];

  const technicalSpecifications: TechnicalSpec[] = [
    {
      id: "spec-1",
      title: "Rotational Angle & Multi-Turn Shaft Tracking",
      category: "Measurement Architecture",
      technicalDetails: "Engineered specifically to monitor and manage the complex movement profiles of industrial machinery. The system operates by precisely measuring physical travel based on the exact rotation angle and the cumulative number of mechanical shaft revolutions."
    },
    {
      id: "spec-2",
      title: "Multi-Point Boundary Limit Configurations",
      category: "Operational Boundaries",
      technicalDetails: "Provides comprehensive position monitoring safeguards across mechanical pathways. The switch mechanisms can be set to flag definitive upper limits, lower limits, or distinct intermediate trip boundaries along a machine's operating cycle."
    },
    {
      id: "spec-3",
      title: "Geared Electro-Mechanical Calibration",
      category: "Internal Mechanics",
      technicalDetails: "Features a rugged internal gear train coupled to electrical contact blocks. This setup converts high-speed, multi-turn shaft revolutions into manageable, high-precision contact responses, ensuring dependable boundary control for critical machinery."
    },
    {
      id: "spec-4",
      title: "Industrial Machinery Safety Integration",
      category: "System Compatibility",
      technicalDetails: "Optimized for heavy industrial moving systems, hoisting units, overhead cranes, and automated winches. The assembly acts as a crucial safety interlock to stop power before mechanical over-travel or structural binding happens."
    }
  ];

  return (
    <>
      <Breadcrumb pageName="Rotary Limit Switches" description="Rotary Limit Switches" />
      <div className="min-h-screen bg-white text-slate-800 py-16 lg:py-24 xl:py-28 selection:bg-cyan-100 selection:text-cyan-950">
        <div className="container mx-auto px-4 sm:px-6 lg:px-8 xl:px-12 max-w-[1600px]">

          {/* ─── HERO BRAND / DETAILS SECTION ──────────────────── */}
          <div className="grid grid-cols-1 lg:grid-cols-12 gap-12 xl:gap-16 items-center mb-24 lg:mb-32">

            {/* 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-slate-50 p-3 sm:p-4 border border-slate-200/60 shadow-2xs group/hero hover:border-cyan-500 transition-colors duration-300">
                <div className="relative w-full h-full rounded-2xl overflow-hidden">
                  <Image
                    src="/images/Knudsen/rotary-limit-switches.jpg"
                    alt="Salzer Heavy Duty Rotary Gear Limit Switches"
                    fill
                    priority
                    className="object-cover group-hover/hero:scale-102 transition-transform duration-500"
                    sizes="(max-width: 1024px) 100vw, 700px"
                  />
                </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-cyan-400 uppercase border border-slate-950">
                Rotary Controls • Position &amp; Travel Safety
              </span>

              <h1 className="text-3xl md:text-4xl lg:text-5xl font-black tracking-tight text-slate-900 leading-tight uppercase">
                Rotary Limit Switches <br />
                <span className="text-cyan-500 font-extrabold text-lg md:text-xl lg:text-2xl block mt-2 normal-case tracking-wide">
                  Heavy Duty Rotary Gear Switches for Shaft &amp; Travel Management
                </span>
              </h1>

              <div className="space-y-4 text-slate-600 text-sm md:text-base xl:text-lg leading-relaxed font-medium">
                <p>
                  Our premium <strong className="text-slate-900 font-bold">Rotary Gear Limit Switches</strong> are designed to control the movement of heavy industrial machinery with absolute precision. They are essential when you need to measure and manage system travel based on rotation angles and shaft revolutions.
                </p>
                <p>
                  By linking directly to a machine's moving shaft, these units deliver safe electrical cutoff signaling. This ensures clear tracking of <strong className="text-slate-900 font-bold">upper, lower, and intermediate limits</strong> along the equipment's path.
                </p>
                <p>
                  Built to handle continuous duty cycles, these control assemblies protect automated machinery from over-travel risks. They offer a compact, dependable layout that integrates smoothly into modern industrial gearboxes and control lines.
                </p>
              </div>

              {/* Parameter Cards Summary Layout */}
              <div className="grid grid-cols-2 sm:grid-cols-4 gap-4 bg-slate-50/50 border border-slate-200/60 p-4 rounded-2xl shadow-2xs">
                {engineeringMetrics.map((metric, index) => (
                  <div key={index} className="bg-white border border-slate-150 p-3 rounded-xl text-center flex flex-col justify-center shadow-2xs">
                    <span className="text-[10px] text-slate-400 font-black uppercase tracking-widest 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="/contact"
                  className="inline-flex items-center gap-2 bg-cyan-500 hover:bg-cyan-600 text-white text-xs font-bold px-6 py-3.5 rounded-xl transition-all shadow-xs uppercase tracking-wider shadow-cyan-500/10 hover:shadow-md"
                >
                  Enquire Now <FaEnvelope className="w-3.5 h-3.5" />
                </Link>
              </div>
            </div>

          </div>

          {/* ─── INTERACTIVE ARCHITECTURE SPECIFICATION VIEWER ──── */}
          <div className="mb-24 lg:mb-32">
            <div className="flex items-center gap-3 mb-10 border-b border-slate-200/60 pb-4">
              <div className="p-2 bg-slate-50 border border-slate-200 text-slate-700 rounded-xl shadow-2xs">
                <LuLayers className="w-5 h-5" />
              </div>
              <div>
                <h2 className="text-lg font-black text-slate-900 uppercase tracking-wide">Technical Parameters &amp; Functionality</h2>
                <p className="text-xs text-slate-500 font-medium mt-0.5">
                  Select a functional parameter below to review tracking methods, limit setups, and machinery integration details.
                </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-4 rounded-xl border text-xs font-black uppercase tracking-wide 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/60 hover:bg-slate-100"
                      }`}
                  >
                    <span className="truncate pr-4">{spec.title}</span>
                    <FaChevronRight className={`w-2.5 h-2.5 shrink-0 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-slate-50/50 border border-slate-200/60 rounded-3xl p-6 md:p-8 min-h-[240px] flex flex-col justify-between shadow-2xs">
                {(() => {
                  const specMatch = technicalSpecifications.find((s) => s.id === activeSpecId)!;
                  return (
                    <>
                      <div className="space-y-4">
                        <div>
                          <span className="text-[10px] font-black tracking-widest text-cyan-600 uppercase block mb-1">
                            {specMatch.category}
                          </span>
                          <h3 className="text-base font-black text-slate-900 uppercase tracking-wide">
                            {specMatch.title}
                          </h3>
                        </div>
                        <p className="text-xs md:text-sm text-slate-600 font-medium leading-relaxed pt-3 border-t border-slate-200/60">
                          {specMatch.technicalDetails}
                        </p>
                      </div>

                      <div className="mt-6 pt-4 border-t border-slate-200/60 flex flex-col sm:flex-row sm:items-center sm:justify-between gap-2 text-[11px] text-slate-400 font-bold uppercase tracking-wider">
                        <span className="flex items-center gap-1.5 text-slate-700">
                          <LuShieldCheck className="w-3.5 h-3.5 text-slate-500" /> Precise Industrial Mechanical Interlocking
                        </span>
                        <span>High-Accuracy Gear Ratio Systems</span>
                      </div>
                    </>
                  );
                })()}
              </div>

            </div>
          </div>

          {/* ─── INDUSTRY APPLICATION & VALUE HIGHLIGHT CARDS ───── */}
          <div className="grid grid-cols-1 md:grid-cols-3 gap-6 mb-24 lg:mb-32">
            <div className="bg-slate-50/50 border border-slate-200/60 rounded-3xl p-6 shadow-2xs flex items-start gap-4 hover:border-cyan-500/20 transition-all duration-300">
              <div className="p-2.5 bg-white border border-slate-200 rounded-xl text-cyan-500 shrink-0 shadow-2xs">
                <LuRotateCw className="w-5 h-5" />
              </div>
              <div className="space-y-1.5">
                <h4 className="text-xs font-black text-slate-900 uppercase tracking-wide">Multi-Turn Tracking</h4>
                <p className="text-xs text-slate-500 font-medium leading-relaxed">
                  Tracks multiple shaft revolutions perfectly. This makes it an excellent choice for deep travel limits, industrial winch drums, and heavy material hoists.
                </p>
              </div>
            </div>
            <div className="bg-slate-50/50 border border-slate-200/60 rounded-3xl p-6 shadow-2xs flex items-start gap-4 hover:border-cyan-500/20 transition-all duration-300">
              <div className="p-2.5 bg-white border border-slate-200 rounded-xl text-cyan-500 shrink-0 shadow-2xs">
                <LuCompass className="w-5 h-5" />
              </div>
              <div className="space-y-1.5">
                <h4 className="text-xs font-black text-slate-900 uppercase tracking-wide">Angular Precision</h4>
                <p className="text-xs text-slate-500 font-medium leading-relaxed">
                  Measures rotation angles to track mechanical paths accurately. This ensures fine-tuned stops for indexing plates and robotic rotating assemblies.
                </p>
              </div>
            </div>
            <div className="bg-slate-50/50 border border-slate-200/60 rounded-3xl p-6 shadow-2xs flex items-start gap-4 hover:border-cyan-500/20 transition-all duration-300">
              <div className="p-2.5 bg-white border border-slate-200 rounded-xl text-cyan-500 shrink-0 shadow-2xs">
                <LuGauge className="w-5 h-5" />
              </div>
              <div className="space-y-1.5">
                <h4 className="text-xs font-black text-slate-900 uppercase tracking-wide">Intermediate Tripping</h4>
                <p className="text-xs text-slate-500 font-medium leading-relaxed">
                  Goes beyond basic endpoint stops to provide intermediate limit markers. This lets you configure staged slowdown steps along the machinery path.
                </p>
              </div>
            </div>
          </div>

          {/* ─── COMMERCIAL INQUIRY BLOCK ──────────────────────── */}
          <div className="flex justify-center">
            <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-10 py-4 rounded-full transition-all duration-200 active:scale-95 shadow-md shadow-cyan-500/10 w-full sm:w-auto justify-center uppercase tracking-wider"
            >
              Send Enquiry
              <FaArrowRight className="w-3.5 h-3.5" />
            </Link>
          </div>

        </div>
      </div>
    </>
  );
}