'use client'
import Image from "next/image";
import Link from "next/link";
import { useState, useEffect } from "react";

export default function OncologyIntro() {
  const [currentSlide, setCurrentSlide] = useState(0);

  const slides = [
    {
      content: "Cancer is not a single disease—it's a highly complex and dynamic group of disorders, often driven by a multitude of genomic alterations. Despite advancements in treatment, many patients still face uncertainty due to incomplete or delayed molecular diagnoses."
    },
    {
      content: "At Operify Health, we recognize that behind every tumor is a unique genetic story waiting to be told. Our precision oncology solutions utilize high-throughput Next Generation Sequencing (NGS) to analyze both somatic and germline mutations—providing clinicians with actionable insights that inform targeted therapies, immunotherapy decisions, and hereditary cancer risk assessments."
    },
    {
      content: "This genomic-driven approach is especially critical in advanced and treatment-resistant cancers, where conventional methods often fall short. Studies have shown that integrating broad-panel NGS into cancer care can impact clinical decision-making in up to 30% of cases, leading to more personalized and effective treatment strategies."
    },
    {
      content: "By combining cutting-edge sequencing, advanced bioinformatics, and curated clinical evidence, Operify Health empowers oncologists to move from uncertainty to precision—ensuring every cancer patient's care is as individualized as their diagnosis."
    }
  ];

  // Auto-advance slides every 5 seconds
  useEffect(() => {
    const timer = setInterval(() => {
      setCurrentSlide((prev) => (prev + 1) % slides.length);
    }, 5000);

    return () => clearInterval(timer);
  }, [slides.length]);

  const goToSlide = (index) => {
    setCurrentSlide(index);
  };

  const nextSlide = () => {
    setCurrentSlide((prev) => (prev + 1) % slides.length);
  };

  const prevSlide = () => {
    setCurrentSlide((prev) => (prev - 1 + slides.length) % slides.length);
  };

  return (
    <section className="bg-teal-700">
      <div className="flex min-h-[350px]">
        {/* Left Side - Image */}
        <div className="hidden lg:block w-1/2 relative">
          <div className="absolute inset-0">
            <Image
              src="https://images.unsplash.com/photo-1579684385127-1ef15d508118?ixlib=rb-4.0.3&auto=format&fit=crop&w=1200&q=80"
              alt="Cancer research and oncology molecular analysis"
              fill
              className="object-cover grayscale-[20%]"
              priority
            />
            <div className="absolute inset-0 bg-slate-900/10"></div>
          </div>
          
          {/* Subtle border */}
          <div className="absolute right-0 top-0 w-px h-full bg-teal-600"></div>
        </div>

        {/* Right Side - Content */}
        <div className="w-full lg:w-3/4">
          <div className="h-full flex flex-col justify-center px-4 lg:px-8 py-4">
            {/* Brand/Title */}
            <div className="mb-4">
              <h2 className="text-3xl font-bold text-white mb-4">
                <span>Turning</span>
                <span className="ml-2">Complexity into Clarity</span>
              </h2>
              <div className="w-10 h-0.5" style={{backgroundColor: '#faae31'}}></div>
            </div>

            {/* Content Slider */}
            <div className="mb-4 max-w-3xl">
              <div className="text-gray-200 leading-relaxed text-base mb-4 text-justify font-light transition-opacity duration-500">
                {slides[currentSlide].content}
              </div>
            </div>

            {/* Navigation */}
            <div className="flex items-center justify-between">
              <div className="flex items-center space-x-3">
                <button
                  onClick={prevSlide}
                  className="w-8 h-8 flex items-center justify-center border rounded-full transition-all duration-200"
                  style={{
                    borderColor: '#ffffff',
                    color: '#ffffff'
                  }}
                  onMouseEnter={(e) => {
                    e.target.style.borderColor = '#faae31';
                    e.target.style.backgroundColor = '#faae31';
                    e.target.style.color = '#0f766e';
                  }}
                  onMouseLeave={(e) => {
                    e.target.style.borderColor = '#ffffff';
                    e.target.style.backgroundColor = 'transparent';
                    e.target.style.color = '#ffffff';
                  }}
                  aria-label="Previous slide"
                >
                  <svg className="w-3 h-3" fill="none" stroke="currentColor" viewBox="0 0 24 24">
                    <path strokeLinecap="round" strokeLinejoin="round" strokeWidth={1.5} d="M15 19l-7-7 7-7" />
                  </svg>
                </button>

                <button
                  onClick={nextSlide}
                  className="w-8 h-8 flex items-center justify-center border rounded-full transition-all duration-200"
                  style={{
                    borderColor: '#ffffff',
                    color: '#ffffff'
                  }}
                  onMouseEnter={(e) => {
                    e.target.style.borderColor = '#faae31';
                    e.target.style.backgroundColor = '#faae31';
                    e.target.style.color = '#0f766e';
                  }}
                  onMouseLeave={(e) => {
                    e.target.style.borderColor = '#ffffff';
                    e.target.style.backgroundColor = 'transparent';
                    e.target.style.color = '#ffffff';
                  }}
                  aria-label="Next slide"
                >
                  <svg className="w-3 h-3" fill="none" stroke="currentColor" viewBox="0 0 24 24">
                    <path strokeLinecap="round" strokeLinejoin="round" strokeWidth={1.5} d="M9 5l7 7-7 7" />
                  </svg>
                </button>

                {/* Progress Indicators */}
                <div className="flex space-x-2 ml-4">
                  {slides.map((_, index) => (
                    <button
                      key={index}
                      onClick={() => goToSlide(index)}
                      className="transition-all duration-200 rounded-full"
                      style={{
                        width: index === currentSlide ? '24px' : '6px',
                        height: '6px',
                        backgroundColor: index === currentSlide ? '#faae31' : '#ffffff'
                      }}
                      onMouseEnter={(e) => {
                        if (index !== currentSlide) {
                          e.target.style.backgroundColor = '#f1f5f9';
                        }
                      }}
                      onMouseLeave={(e) => {
                        if (index !== currentSlide) {
                          e.target.style.backgroundColor = '#ffffff';
                        }
                      }}
                      aria-label={`Go to slide ${index + 1}`}
                    />
                  ))}
                </div>
              </div>
            </div>
          </div>
        </div>
      </div>
    </section>
  );
}