"use client";

import { Heart, MessageCircle, Share2 } from "lucide-react";

// Mock data generator
function generateMockCharacters() {
  const baseCharacters = [
    { name: "Luna", avatar: "🌙", description: "Mysterious night elf" },
    { name: "Alex", avatar: "⚡", description: "Energetic hacker" },
    { name: "Sage", avatar: "🧙", description: "Wise wizard" },
    { name: "Nova", avatar: "✨", description: "Cosmic explorer" },
  ];
  
  return Array.from({ length: 12 }, (_, i) => {
    const char = baseCharacters[i % baseCharacters.length];
    return {
      id: i + 1,
      ...char,
      messages: Math.floor(Math.random() * 500) + 50,
      likes: Math.floor(Math.random() * 1000) + 100,
    };
  });
}

export default function DiscoverPage() {
  const characters = generateMockCharacters();

  return (
    <div className="p-6 max-w-4xl mx-auto">
      {/* Header */}
      <div className="mb-8">
        <h1 className="text-3xl font-bold mb-2">Discover</h1>
        <p className="text-gray-600">Explore trending characters and conversations</p>
      </div>

      {/* Waterfall Grid */}
      <div className="grid grid-cols-1 md:grid-cols-2 gap-6">
        {characters.map((char) => (
          <div
            key={char.id}
            className="bg-white border border-gray-200 rounded-xl overflow-hidden hover:shadow-lg transition group cursor-pointer"
          >
            {/* Character Card Header */}
            <div className="h-48 bg-gradient-to-br from-blue-200 via-purple-200 to-pink-200 flex items-center justify-center">
              <span className="text-6xl">{char.avatar}</span>
            </div>

            {/* Card Content */}
            <div className="p-4 space-y-4">
              {/* Title */}
              <div>
                <h3 className="text-xl font-bold">{char.name}</h3>
                <p className="text-sm text-gray-600">{char.description}</p>
              </div>

              {/* Stats */}
              <div className="flex gap-4 text-sm text-gray-600 pb-4 border-b border-gray-200">
                <div className="flex items-center gap-1">
                  <MessageCircle className="w-4 h-4" />
                  <span>{char.messages}</span>
                </div>
                <div className="flex items-center gap-1">
                  <Heart className="w-4 h-4" />
                  <span>{char.likes}</span>
                </div>
              </div>

              {/* Actions */}
              <div className="flex gap-2">
                <button className="flex-1 bg-black text-white py-2 rounded-lg font-medium hover:bg-gray-800 transition text-sm">
                  Chat Now
                </button>
                <button className="p-2 hover:bg-gray-100 rounded-lg transition">
                  <Heart className="w-5 h-5" />
                </button>
                <button className="p-2 hover:bg-gray-100 rounded-lg transition">
                  <Share2 className="w-5 h-5" />
                </button>
              </div>
            </div>
          </div>
        ))}
      </div>

      {/* Load More */}
      <div className="mt-12 text-center">
        <button className="px-8 py-3 border-2 border-gray-200 rounded-full font-medium hover:bg-gray-50 transition">
          Load More
        </button>
      </div>
    </div>
  );
}
