"use client";

import { useState } from "react";
import { useRouter } from "next/navigation";
import { ArrowRight, Sparkles } from "lucide-react";

export default function LandingTransferCallout() {
  const [handle, setHandle] = useState("");
  const router = useRouter();

  const handleStart = (e: React.FormEvent) => {
    e.preventDefault();
    const clean = handle.trim().replace(/^https?:\/\/(?:www\.)?guns\.lol\/?/i, "").replace(/^@/, "");
    if (clean) {
      router.push(`/transfer?handle=${encodeURIComponent(clean)}`);
    } else {
      router.push("/transfer");
    }
  };

  return (
    <div
      style={{
        background: "linear-gradient(135deg, rgba(16, 22, 34, 0.7), rgba(9, 13, 22, 0.7))",
        border: "1px solid rgba(0, 0, 0, 0.08)",
        borderRadius: 20,
        padding: "clamp(24px, 4vw, 36px)",
        margin: "0 0 40px",
        display: "flex",
        flexDirection: "column",
        gap: 20,
      }}
    >
      <div style={{ display: "flex", flexWrap: "wrap", justifyContent: "space-between", alignItems: "flex-start", gap: 16 }}>
        <div style={{ maxWidth: 540 }}>
          <div
            style={{
              display: "inline-flex",
              alignItems: "center",
              gap: 6,
              fontSize: 11,
              fontWeight: 600,
              textTransform: "uppercase",
              letterSpacing: "1.2px",
              color: "#e64949",
              marginBottom: 10,
            }}
          >
            <Sparkles size={12} color="#ffffff" />
            Profile Migration
          </div>
          <h2
            style={{
              fontSize: "clamp(22px, 3.2vw, 32px)",
              fontWeight: 600,
              letterSpacing: "-0.025em",
              margin: "0 0 10px",
              color: "#000",
              lineHeight: 1.25,
            }}
          >
            Switch from guns.lol to sinss.lol in seconds.
          </h2>
          <p
            style={{
              fontSize: 14,
              color: "#2f0c0c",
              margin: 0,
              lineHeight: 1.6,
            }}
          >
            Bring your profile, bio, links, and style over without rebuilding everything from scratch. Keep your identity and unlock free video backgrounds, audio players with synced lyrics, and clean edge performance.
          </p>
        </div>

        {/* Input Form */}
        <form
          onSubmit={handleStart}
          style={{
            display: "flex",
            alignItems: "center",
            background: "rgba(0, 0, 0, 0.4)",
            border: "1px solid rgba(0, 0, 0, 0.12)",
            borderRadius: 12,
            padding: "4px 6px 4px 14px",
            width: "100%",
            maxWidth: 380,
            boxShadow: "0 8px 30px rgba(0, 0, 0, 0.3)",
          }}
        >
          <span style={{ fontSize: 13, color: "#220e0e", fontFamily: "monospace", userSelect: "none" }}>
            guns.lol/
          </span>
          <input
            type="text"
            value={handle}
            onChange={(e) => setHandle(e.target.value)}
            placeholder="username"
            style={{
              flex: 1,
              background: "transparent",
              border: "none",
              outline: "none",
              color: "#000",
              fontSize: 13,
              padding: "10px 8px",
              minWidth: 0,
              fontFamily: "inherit",
            }}
          />
          <button
            type="submit"
            style={{
              background: "#ffffff",
              color: "#08090b",
              border: "none",
              borderRadius: 8,
              padding: "9px 16px",
              fontSize: 12,
              fontWeight: 600,
              cursor: "pointer",
              display: "inline-flex",
              alignItems: "center",
              gap: 6,
              whiteSpace: "nowrap",
              transition: "transform 0.15s ease",
            }}
          >
            Transfer
            <ArrowRight size={13} />
          </button>
        </form>
      </div>
    </div>
  );
}
