'use client';

import { DashboardLayout } from '@/components/layout/DashboardLayout';
import { AgencyBranding } from '@/components/layout/AgencyBranding';
import AuthGuard from '@/components/auth/AuthGuard';
import {
    HomeIcon,
    RocketLaunchIcon,
    ChartBarIcon,
    BriefcaseIcon,
    LifebuoyIcon,
    CreditCardIcon,
    DocumentTextIcon,
    FolderIcon,
    ShareIcon,
} from '@heroicons/react/24/outline';

const AGENCY_MENU_ITEMS = [
    { id: 'dashboard', label: 'Visão Geral', href: '/dashboard', icon: HomeIcon },
    {
        id: 'crm',
        label: 'CRM',
        href: '/crm',
        icon: RocketLaunchIcon,
        subItems: [
            { label: 'Dashboard', href: '/crm' },
            { label: 'Clientes', href: '/crm/clientes' },
            { label: 'Funis', href: '/crm/funis' },
            { label: 'Negociações', href: '/crm/negociacoes' },
        ]
    },
    {
        id: 'erp',
        label: 'ERP',
        href: '/erp',
        icon: ChartBarIcon,
        subItems: [
            { label: 'Dashboard', href: '/erp' },
            { label: 'Fluxo de Caixa', href: '/erp/fluxo-caixa' },
            { label: 'Contas a Pagar', href: '/erp/contas-pagar' },
            { label: 'Contas a Receber', href: '/erp/contas-receber' },
        ]
    },
    {
        id: 'projetos',
        label: 'Projetos',
        href: '/projetos',
        icon: BriefcaseIcon,
        subItems: [
            { label: 'Dashboard', href: '/projetos' },
            { label: 'Meus Projetos', href: '/projetos/lista' },
            { label: 'Tarefas', href: '/projetos/tarefas' },
            { label: 'Cronograma', href: '/projetos/cronograma' },
        ]
    },
    {
        id: 'helpdesk',
        label: 'Helpdesk',
        href: '/helpdesk',
        icon: LifebuoyIcon,
        subItems: [
            { label: 'Dashboard', href: '/helpdesk' },
            { label: 'Chamados', href: '/helpdesk/chamados' },
            { label: 'Base de Conhecimento', href: '/helpdesk/kb' },
        ]
    },
    {
        id: 'pagamentos',
        label: 'Pagamentos',
        href: '/pagamentos',
        icon: CreditCardIcon,
        subItems: [
            { label: 'Dashboard', href: '/pagamentos' },
            { label: 'Cobranças', href: '/pagamentos/cobrancas' },
            { label: 'Assinaturas', href: '/pagamentos/assinaturas' },
        ]
    },
    {
        id: 'contratos',
        label: 'Contratos',
        href: '/contratos',
        icon: DocumentTextIcon,
        subItems: [
            { label: 'Dashboard', href: '/contratos' },
            { label: 'Ativos', href: '/contratos/ativos' },
            { label: 'Modelos', href: '/contratos/modelos' },
        ]
    },
    {
        id: 'documentos',
        label: 'Documentos',
        href: '/documentos',
        icon: FolderIcon,
        subItems: [
            { label: 'Meus Arquivos', href: '/documentos' },
            { label: 'Compartilhados', href: '/documentos/compartilhados' },
            { label: 'Lixeira', href: '/documentos/lixeira' },
        ]
    },
    {
        id: 'social',
        label: 'Redes Sociais',
        href: '/social',
        icon: ShareIcon,
        subItems: [
            { label: 'Dashboard', href: '/social' },
            { label: 'Agendamento', href: '/social/agendamento' },
            { label: 'Relatórios', href: '/social/relatorios' },
        ]
    },
];

interface AgencyLayoutClientProps {
    children: React.ReactNode;
    colors?: {
        primary: string;
        secondary: string;
    } | null;
}

export function AgencyLayoutClient({ children, colors }: AgencyLayoutClientProps) {
    return (
        <AuthGuard>
            <AgencyBranding colors={colors} />
            <DashboardLayout menuItems={AGENCY_MENU_ITEMS}>
                {children}
            </DashboardLayout>
        </AuthGuard>
    );
}
