'use client';

import Link from 'next/link';
import { usePathname } from 'next/navigation';

const SECTIONS = [
  { href: '/reporting/dashboard', label: 'Dashboard', icon: '📊' },
  { href: '/reporting/sales', label: 'Ventas', icon: '🧾' },
  { href: '/reporting/products', label: 'Productos', icon: '📦' },
] as const;

export default function ReportingLayout({ children }: { children: React.ReactNode }) {
  const pathname = usePathname();

  return (
    <div className="space-y-6">
      <div>
        <h1 className="text-2xl font-bold text-gray-900">Reporting</h1>
        <p className="mt-0.5 text-sm text-gray-500">Informes de ventas y rendimiento del negocio.</p>
      </div>

      <div className="flex items-start gap-6">
        <nav aria-label="Apartados de Reporting" className="w-48 shrink-0 space-y-1">
          {SECTIONS.map((section) => {
            const active = pathname === section.href;
            return (
              <Link
                key={section.href}
                href={section.href}
                aria-current={active ? 'page' : undefined}
                className={`block w-full rounded-xl px-4 py-2.5 text-sm font-medium transition-colors ${
                  active ? 'bg-[#2D6A4F] text-white' : 'text-gray-600 hover:bg-gray-100'
                }`}
              >
                <span className="mr-2" aria-hidden="true">{section.icon}</span>
                {section.label}
              </Link>
            );
          })}
        </nav>

        <div className="min-w-0 flex-1">{children}</div>
      </div>
    </div>
  );
}
