"use client"

import { useRef } from "react"
import { useFrame } from "@react-three/fiber"
import type { Mesh } from "three"

export function BeeHive() {
  const meshRef = useRef<Mesh>(null)

  useFrame((state) => {
    if (meshRef.current) {
      meshRef.current.rotation.y = Math.sin(state.clock.elapsedTime * 0.5) * 0.1
    }
  })

  return (
    <group position={[3, 0, -2]}>
      {/* Main hive structure */}
      <mesh ref={meshRef}>
        <cylinderGeometry args={[1.5, 2, 3, 6]} />
        <meshStandardMaterial color="#D97706" />
      </mesh>

      {/* Honeycomb cells */}
      {Array.from({ length: 12 }).map((_, i) => (
        <mesh
          key={i}
          position={[
            Math.cos((i / 12) * Math.PI * 2) * 1.8,
            Math.sin(i * 0.5) * 0.3,
            Math.sin((i / 12) * Math.PI * 2) * 1.8,
          ]}
          rotation={[0, (i / 12) * Math.PI * 2, 0]}
        >
          <cylinderGeometry args={[0.3, 0.3, 0.1, 6]} />
          <meshStandardMaterial color="#F59E0B" />
        </mesh>
      ))}
    </group>
  )
}
