"use client";

import { useTranslations } from "next-intl";
import { mockData } from "@/lib/mock-data";
import Link from "next/link";
import Image from "next/image";
import { motion } from "framer-motion";
import { ArrowRight } from "lucide-react";

export function RoomList() {
  const t = useTranslations("accommodations");

  // We take the first 3 rooms for the bento grid
  const featuredRoom = mockData.accommodations[0];
  const sideRooms = mockData.accommodations.slice(1, 3);

  return (
    <section className="py-24 max-w-7xl mx-auto px-4 md:px-12" aria-label="Odalarımız">
      <div className="flex justify-between items-end mb-12">
        <motion.div 
          initial={{ opacity: 0, x: -20 }}
          whileInView={{ opacity: 1, x: 0 }}
          viewport={{ once: true, margin: "-100px" }}
          transition={{ duration: 0.6 }}
          className="space-y-2 motion-reduce:!transform-none motion-reduce:!opacity-100"
        >
          <h2 className="font-heading text-3xl md:text-4xl font-bold text-primary dark:text-primary-fixed-dim">{t("title")}</h2>
          <p className="font-body-md text-on-surface-variant dark:text-outline text-lg" style={{ maxWidth: "65ch" }}>{t("desc")}</p>
        </motion.div>
        
        <motion.div
          initial={{ opacity: 0, x: 20 }}
          whileInView={{ opacity: 1, x: 0 }}
          viewport={{ once: true, margin: "-100px" }}
          transition={{ duration: 0.6 }}
          className="motion-reduce:!transform-none motion-reduce:!opacity-100"
        >
          <Link href="/odalar" className="font-label-sm text-[12px] uppercase tracking-widest text-primary dark:text-primary-fixed-dim flex items-center gap-2 group font-bold cursor-pointer focus:ring-2 focus:ring-primary/30 focus:outline-none rounded-md px-2 py-1 min-h-[44px]">
            {t("viewAll")} 
            <ArrowRight className="w-4 h-4 group-hover:translate-x-1 transition-transform duration-200" />
          </Link>
        </motion.div>
      </div>

      {/* Bento-style Grid */}
      <motion.div 
        initial={{ opacity: 0, y: 30 }}
        whileInView={{ opacity: 1, y: 0 }}
        viewport={{ once: true, margin: "-100px" }}
        transition={{ duration: 0.6 }}
        className="grid grid-cols-1 md:grid-cols-12 gap-6 h-auto md:h-[600px] motion-reduce:!transform-none motion-reduce:!opacity-100"
      >
        <Link 
          href={`/odalar/${featuredRoom.slug}`} 
          className="md:col-span-8 group relative overflow-hidden rounded-xl cursor-pointer focus:ring-2 focus:ring-primary/50 focus:outline-none"
          aria-label={`${featuredRoom.name} - ${featuredRoom.type}`}
        >
          <div className="relative w-full h-full min-h-[300px]">
            <Image 
              src={featuredRoom.image} 
              alt={`${featuredRoom.name} - ${featuredRoom.type} oda görseli`}
              fill
              className="object-cover transition-transform duration-500 group-hover:scale-105"
              sizes="(max-width: 768px) 100vw, 66vw"
              loading="lazy"
            />
          </div>
          <div className="absolute inset-0 bg-gradient-to-t from-[#002045]/90 via-[#002045]/20 to-transparent opacity-80" />
          
          <div className="absolute bottom-0 left-0 p-8 text-white w-full">
            <div className="flex gap-2 mb-3">
              <span className="bg-[#CA8A04] text-white px-3 py-1 rounded-full font-label-sm text-[10px] uppercase font-bold tracking-wider">
                {t("bestseller")}
              </span>
            </div>
            <h3 className="font-heading text-3xl md:text-4xl font-bold mb-2">{featuredRoom.name}</h3>
            <p className="font-body-md text-white/80 text-lg">
              {featuredRoom.type} • {t("bedrooms", { count: featuredRoom.bedrooms })} • {t("persons", { count: featuredRoom.capacity })}
            </p>
          </div>
        </Link>

        {/* Side Stacked Items */}
        <div className="md:col-span-4 grid grid-rows-2 gap-6">
          {sideRooms.map((room) => (
            <Link 
              href={`/odalar/${room.slug}`} 
              key={room.id} 
              className="group relative overflow-hidden rounded-xl cursor-pointer focus:ring-2 focus:ring-primary/50 focus:outline-none"
              aria-label={`${room.name} - ${room.type}`}
            >
              <div className="relative w-full h-full min-h-[150px]">
                <Image 
                  src={room.image} 
                  alt={`${room.name} - ${room.type} oda görseli`}
                  fill
                  className="object-cover transition-transform duration-500 group-hover:scale-105"
                  sizes="(max-width: 768px) 100vw, 33vw"
                  loading="lazy"
                />
              </div>
              <div className="absolute inset-0 bg-gradient-to-t from-[#002045]/80 to-transparent opacity-90" />
              <div className="absolute bottom-0 left-0 p-6 text-white w-full">
                <h4 className="font-label-sm text-[12px] uppercase tracking-wider font-bold text-[#CA8A04] mb-1">{room.type}</h4>
                <h3 className="font-heading text-xl font-semibold mb-1">{room.name}</h3>
                <p className="font-body-md text-white/80 text-sm">
                  {t("persons", { count: room.capacity })}
                </p>
              </div>
            </Link>
          ))}
        </div>
      </motion.div>
    </section>
  );
}
