import React, { createContext, useContext, useEffect, useState } from 'react';

type Theme = 'default' | 'aspirant';

interface ThemeContextType {
    theme: Theme;
    setTheme: (theme: Theme) => void;
}

const ThemeContext = createContext<ThemeContextType | undefined>(undefined);

export function ThemeProvider({ children }: { children: React.ReactNode }) {
    // Aspirant is now the official theme - no switching available
    const [theme] = useState<Theme>('aspirant');
    const setTheme = (_theme: Theme) => { }; // No-op, theme is locked

    useEffect(() => {
        localStorage.setItem('veridian-theme', theme);
        document.documentElement.setAttribute('data-theme', theme);
    }, [theme]);

    return (
        <ThemeContext.Provider value={{ theme, setTheme }}>
            {children}
        </ThemeContext.Provider>
    );
}

export function useTheme() {
    const context = useContext(ThemeContext);
    if (context === undefined) {
        throw new Error('useTheme must be used within a ThemeProvider');
    }
    return context;
}
