'use client';

import { useState } from 'react';
import Link from 'next/link';

const PRODUCTION_CAPS = [
  { label: 'Pellet and mash feed production (100 kg/hr)',               icon: 'fa-gears'         },
  { label: 'Precision premixing and progressive dilution systems',       icon: 'fa-sliders'       },
  { label: 'Pellet durability, hardness, and particle size analysis',    icon: 'fa-ruler-combined' },
  { label: 'Pelleting efficiency, throughput, and energy consumption',   icon: 'fa-gauge-high'    },
  { label: 'Enzyme and probiotic recovery evaluation',                   icon: 'fa-bacteria'      },
];

type Accent = 'green' | 'blue' | 'teal';

function BrlCard({ label, icon, accent }: { label: string; icon: string; accent: Accent }) {
  return (
    <div className={`brl-card brl-card--${accent}`}>
      <div className="brl-card-icon"><i className={`fas ${icon}`} /></div>
      <p className="brl-card-title">{label}</p>
    </div>
  );
}

type SectionKey = 'production' | 'feedmill';

export default function FeedResearchPage() {
  const [open, setOpen] = useState<Record<SectionKey, boolean>>({
    production: false, feedmill: false,
  });
  const toggle = (key: SectionKey) => setOpen(prev => ({ ...prev, [key]: !prev[key] }));

  return (
    <>
      <div className="op-hero">
        <div className="op-hero-deco" aria-hidden="true">
          <svg className="deco-leaf-1" viewBox="0 0 200 300" fill="none">
            <path d="M100 10 C160 40 190 120 160 200 C130 280 40 290 20 220 C0 150 40 80 100 10Z" fill="#7abf9e"/>
            <path d="M100 50 C140 70 160 130 140 190 C120 250 60 260 40 200" stroke="#a9d4bc" strokeWidth="1.5" fill="none"/>
          </svg>
          <svg className="deco-leaf-2" viewBox="0 0 200 300" fill="none">
            <path d="M100 10 C160 40 190 120 160 200 C130 280 40 290 20 220 C0 150 40 80 100 10Z" fill="#7abf9e"/>
          </svg>
        </div>
        <div className="container op-hero-inner">
          <nav className="op-breadcrumb" aria-label="Breadcrumb">
            <Link href="/" className="op-bc-item">Home</Link>
            <span className="op-bc-sep" aria-hidden="true">/</span>
            <Link href="/research" className="op-bc-item">Research</Link>
            <span className="op-bc-sep" aria-hidden="true">/</span>
            <span className="op-bc-item active">Feed Research &amp; Production</span>
          </nav>
          <h1>Feed Research &amp; <em>Production Facility</em></h1>
        </div>
        <div className="op-hero-wave" aria-hidden="true">
          <svg viewBox="0 0 1440 60" preserveAspectRatio="none" fill="#fff">
            <path d="M0,40 C360,70 1080,10 1440,40 L1440,60 L0,60Z"/>
          </svg>
        </div>
      </div>

      {/* ── Production Capabilities ──────────────────── */}
      <section className="brl-section">
        <div className="container">
          <button
            className={`brl-accord-head brl-head--green${open.production ? ' open' : ''}`}
            onClick={() => toggle('production')}
            aria-expanded={open.production}
          >
            <div className="brl-accord-left">
              <div className="brl-section-icon"><i className="fas fa-gears" /></div>
              <h2>Production Capabilities</h2>
            </div>
            <i className="fas fa-chevron-down brl-accord-arrow" />
          </button>

          {open.production && (
            <div className="brl-accord-body">
              <div className="brl-grid brl-grid--3">
                {PRODUCTION_CAPS.map((item, i) => (
                  <BrlCard key={i} label={item.label} icon={item.icon} accent="green" />
                ))}
              </div>
            </div>
          )}
        </div>
      </section>

      {/* ── Feed Mill Operations Study ────────────────── */}
      <section className="brl-section">
        <div className="container">
          <button
            className={`brl-accord-head brl-head--blue${open.feedmill ? ' open' : ''}`}
            onClick={() => toggle('feedmill')}
            aria-expanded={open.feedmill}
          >
            <div className="brl-accord-left">
              <div className="brl-section-icon"><i className="fas fa-flask-vial" /></div>
              <h2>Feed Mill Operations Study</h2>
            </div>
            <i className="fas fa-chevron-down brl-accord-arrow" />
          </button>

          {open.feedmill && (
            <div className="brl-accord-body">
              <p className="brl-section-desc">
                Explore the detailed study areas conducted within the feed mill facility — covering mash and pellet
                production research, mixing uniformity, and post-pelleting additive recovery.
              </p>
              <Link href="/research/feedmill" className="brl-detail-link">
                View Feed Mill Study Details <i className="fas fa-arrow-right" />
              </Link>
            </div>
          )}
        </div>
      </section>
    </>
  );
}
