'use client';

import { ReactNode } from 'react';
import { useEffect } from 'react';
import { usePathname } from 'next/navigation';

const DEFAULT_GRADIENT = 'linear-gradient(135deg, #ff3a05, #ff0080)';

const setGradientVariables = (gradient: string) => {
    document.documentElement.style.setProperty('--gradient-primary', gradient);
    document.documentElement.style.setProperty('--gradient', gradient);
    document.documentElement.style.setProperty('--gradient-text', gradient.replace('90deg', 'to right'));
    document.documentElement.style.setProperty('--color-gradient-brand', gradient.replace('90deg', 'to right'));
};

export default function LayoutWrapper({ children }: { children: ReactNode }) {
    const pathname = usePathname();

    useEffect(() => {
        // Em toda troca de rota, volta para o tema padrão; layouts específicos (ex.: agência) aplicam o próprio na sequência
        setGradientVariables(DEFAULT_GRADIENT);
    }, [pathname]);

    return <>{children}</>;
}
