'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(() => {
        // Reseta tema padrão em toda troca de rota
        setGradientVariables(DEFAULT_GRADIENT);
    }, [pathname]);

    return <>{children}</>;
}
