"use client";

import { useState } from "react";
import { Search, Home, Key } from "lucide-react";
import { priceRanges } from "@/lib/content";

interface HeroSectionProps {
  propertyTypes: string[];
}

const HeroSection = ({ propertyTypes }: HeroSectionProps) => {
  const [activeTab, setActiveTab] = useState<"buy" | "rent">("buy");

  return (
    <section className="relative overflow-visible">
      {/* Background */}
      <div className="absolute inset-0">
        <img
          src="/brand/hero.png"
          alt="Красива гледка към Санторини, Гърция"
          className="w-full h-full object-cover"
          width={1920}
          height={1080}
        />
        <div className="absolute inset-0 bg-gradient-to-r from-primary/70 via-primary/40 to-transparent" />
        <div className="absolute inset-0 bg-gradient-to-t from-primary/50 via-transparent to-primary/20" />
      </div>

      <div className="relative z-10">
        {/* Content */}
        <div className="container mx-auto px-4 lg:px-8 min-h-[48vh] md:min-h-[60vh] flex flex-col items-center justify-center text-center pt-28 pb-8 md:pt-0 md:pb-20">
          <h1 className="text-3xl sm:text-4xl md:text-5xl lg:text-6xl font-bold text-primary-foreground leading-tight mb-3 md:mb-4 animate-fade-in-up font-display">
            Открийте своя мечтан дом в{" "}
            <span className="text-accent">Гърция</span>
          </h1>
          <p
            className="text-base sm:text-lg md:text-xl text-primary-foreground/80 mb-6 max-w-xl animate-fade-in-up font-body"
            style={{ animationDelay: "0.15s" }}
          >
            Луксозни вили, апартаменти с морска гледка и инвестиционни имоти в
            най-красивите региони на Елада.
          </p>
        </div>

        {/* Search box */}
        <div className="w-full max-w-4xl px-4 pb-10 mx-auto md:absolute md:left-1/2 md:-translate-x-1/2 md:bottom-0 md:translate-y-1/2 md:z-50 md:pb-0">
          <div
            className="bg-card/95 backdrop-blur-md rounded-2xl shadow-hero p-2 animate-fade-in-up"
            style={{ animationDelay: "0.3s" }}
          >
            {/* Tabs */}
            <div className="flex gap-1 mb-3 px-2 pt-2">
              <button
                onClick={() => setActiveTab("buy")}
                className={`search-toggle flex items-center gap-2 ${
                  activeTab === "buy" ? "search-toggle-active" : "search-toggle-inactive"
                }`}
              >
                <Home className="w-4 h-4" />
                Купувам
              </button>
              <button
                onClick={() => setActiveTab("rent")}
                className={`search-toggle flex items-center gap-2 ${
                  activeTab === "rent" ? "search-toggle-active" : "search-toggle-inactive"
                }`}
              >
                <Key className="w-4 h-4" />
                Наемам
              </button>
            </div>

            {/* Search fields */}
            <form
              action="/search"
              method="get"
              className="grid grid-cols-2 gap-2 px-2 pb-2 md:flex md:flex-row"
            >
              <input
                type="hidden"
                name="deal"
                value={activeTab === "buy" ? "sale" : "rent"}
              />
              <input
                type="text"
                name="search"
                placeholder="Град, район, характеристика или ID на имот..."
                className="col-span-2 md:flex-1 px-4 py-3 rounded-xl bg-secondary text-foreground text-sm placeholder:text-muted-foreground focus:outline-none focus:ring-2 focus:ring-accent/40 transition-shadow font-body"
              />
              <select
                name="type"
                defaultValue="all"
                className="col-span-1 px-4 py-3 rounded-xl bg-secondary text-foreground text-sm appearance-none cursor-pointer focus:outline-none focus:ring-2 focus:ring-accent/40 font-body"
              >
                <option value="all">Тип имот</option>
                {propertyTypes.map((propertyType) => (
                  <option key={propertyType} value={propertyType}>
                    {propertyType}
                  </option>
                ))}
              </select>
              <select
                name="priceRange"
                defaultValue="0"
                className="col-span-1 px-4 py-3 rounded-xl bg-secondary text-foreground text-sm appearance-none cursor-pointer focus:outline-none focus:ring-2 focus:ring-accent/40 font-body"
              >
                {priceRanges.map((range, index) => (
                  <option key={range.label} value={index}>
                    {index === 0 ? "Ценови диапазон" : range.label}
                  </option>
                ))}
              </select>
              <button
                type="submit"
                className="col-span-2 md:col-auto cta-button flex items-center justify-center gap-2 rounded-xl whitespace-nowrap"
              >
                <Search className="w-4 h-4" />
                Търси
              </button>
            </form>
          </div>
        </div>
      </div>
    </section>
  );
};

export default HeroSection;
