package eu.gaudian.translator.ui.theme

import androidx.compose.material3.ColorScheme
import androidx.compose.material3.darkColorScheme
import androidx.compose.material3.lightColorScheme
import androidx.compose.ui.graphics.Color
import eu.gaudian.translator.ui.theme.themes.AutumnSpiceTheme
import eu.gaudian.translator.ui.theme.themes.CitrusSplashTheme
import eu.gaudian.translator.ui.theme.themes.CoffeeTheme
import eu.gaudian.translator.ui.theme.themes.CrimsonTheme
import eu.gaudian.translator.ui.theme.themes.CyberpunkTheme
import eu.gaudian.translator.ui.theme.themes.DebugTheme
import eu.gaudian.translator.ui.theme.themes.DefaultTheme
import eu.gaudian.translator.ui.theme.themes.ForestTheme
import eu.gaudian.translator.ui.theme.themes.NordTheme
import eu.gaudian.translator.ui.theme.themes.OceanicCalmTheme
import eu.gaudian.translator.ui.theme.themes.PixelTheme
import eu.gaudian.translator.ui.theme.themes.SakuraTheme
import eu.gaudian.translator.ui.theme.themes.SlateAndStoneTheme
import eu.gaudian.translator.ui.theme.themes.SpaceTheme
import eu.gaudian.translator.ui.theme.themes.SynthwaveTheme
import eu.gaudian.translator.ui.theme.themes.TealTheme
import eu.gaudian.translator.ui.theme.themes.TwilightSerenityTheme

/**
 * A data class to hold the core colors for a theme variation (light or dark).
 * This makes defining new themes as simple as providing these color values.
 */
data class ThemeColorSet(
    // Main colors
    val primary: Color,
    val secondary: Color,
    val tertiary: Color,

    // Container colors
    val primaryContainer: Color,
    val secondaryContainer: Color,
    val tertiaryContainer: Color,

    // On colors (text/icons on top of main colors)
    val onPrimary: Color,
    val onSecondary: Color,
    val onTertiary: Color,
    val onPrimaryContainer: Color,
    val onSecondaryContainer: Color,
    val onTertiaryContainer: Color,

    // Error colors
    val error: Color,
    val onError: Color,
    val errorContainer: Color,
    val onErrorContainer: Color,

    // Background/surface colors
    val background: Color,
    val onBackground: Color,
    val surface: Color,
    val onSurface: Color,
    val surfaceVariant: Color,
    val onSurfaceVariant: Color,

    // Outline colors
    val outline: Color,
    val outlineVariant: Color,

    // Scrim
    val scrim: Color,

    // Inverse colors
    val inverseSurface: Color,
    val inverseOnSurface: Color,
    val inversePrimary: Color,

    // Surface container colors
    val surfaceDim: Color,
    val surfaceBright: Color,
    val surfaceContainerLowest: Color,
    val surfaceContainerLow: Color,
    val surfaceContainer: Color,
    val surfaceContainerHigh: Color,
    val surfaceContainerHighest: Color
)

/**
 * Represents a complete, named theme in the app, containing both its light and dark color sets.
 */
data class AppTheme(
    val name: String,
    val lightColors: ThemeColorSet,
    val darkColors: ThemeColorSet
)

/**
 * Represents a font style, including its display name and the filename of the font file.
 */



val AllThemes = listOf(

    DefaultTheme,
    PixelTheme,
    CrimsonTheme,
    SakuraTheme,
    AutumnSpiceTheme,
    TealTheme,
    ForestTheme,
    CoffeeTheme,
    CitrusSplashTheme,
    OceanicCalmTheme,
    SlateAndStoneTheme,
    NordTheme,
    TwilightSerenityTheme,
    SpaceTheme,
    CyberpunkTheme,
    SynthwaveTheme,
    DebugTheme,


)

/**
 * A helper function that dynamically builds a Material [ColorScheme]
 * from our generic [ThemeColorSet].
 *
 * @param colorSet The set of colors to use.
 * @param isDark Whether to build a dark or light color scheme.
 * @return A complete Material 3 [ColorScheme].
 */
fun buildColorScheme(colorSet: ThemeColorSet, isDark: Boolean): ColorScheme {
    return if (isDark) {
        darkColorScheme(
            primary = colorSet.primary,
            onPrimary = colorSet.onPrimary,
            primaryContainer = colorSet.primaryContainer,
            onPrimaryContainer = colorSet.onPrimaryContainer,
            inversePrimary = colorSet.inversePrimary,
            secondary = colorSet.secondary,
            onSecondary = colorSet.onSecondary,
            secondaryContainer = colorSet.secondaryContainer,
            onSecondaryContainer = colorSet.onSecondaryContainer,
            tertiary = colorSet.tertiary,
            onTertiary = colorSet.onTertiary,
            tertiaryContainer = colorSet.tertiaryContainer,
            onTertiaryContainer = colorSet.onTertiaryContainer,
            background = colorSet.background,
            onBackground = colorSet.onBackground,
            surface = colorSet.surface,
            onSurface = colorSet.onSurface,
            surfaceVariant = colorSet.surfaceVariant,
            onSurfaceVariant = colorSet.onSurfaceVariant,
            surfaceDim = colorSet.surfaceDim,
            surfaceBright = colorSet.surfaceBright,
            surfaceContainerLowest = colorSet.surfaceContainerLowest,
            surfaceContainerLow = colorSet.surfaceContainerLow,
            surfaceContainer = colorSet.surfaceContainer,
            surfaceContainerHigh = colorSet.surfaceContainerHigh,
            surfaceContainerHighest = colorSet.surfaceContainerHighest,
            error = colorSet.error,
            onError = colorSet.onError,
            errorContainer = colorSet.errorContainer,
            onErrorContainer = colorSet.onErrorContainer,
            outline = colorSet.outline,
            outlineVariant = colorSet.outlineVariant,
            scrim = colorSet.scrim,
            inverseSurface = colorSet.inverseSurface,
            inverseOnSurface = colorSet.inverseOnSurface
        )
    } else {
        lightColorScheme(
            primary = colorSet.primary,
            onPrimary = colorSet.onPrimary,
            primaryContainer = colorSet.primaryContainer,
            onPrimaryContainer = colorSet.onPrimaryContainer,
            inversePrimary = colorSet.inversePrimary,
            secondary = colorSet.secondary,
            onSecondary = colorSet.onSecondary,
            secondaryContainer = colorSet.secondaryContainer,
            onSecondaryContainer = colorSet.onSecondaryContainer,
            tertiary = colorSet.tertiary,
            onTertiary = colorSet.onTertiary,
            tertiaryContainer = colorSet.tertiaryContainer,
            onTertiaryContainer = colorSet.onTertiaryContainer,
            background = colorSet.background,
            onBackground = colorSet.onBackground,
            surface = colorSet.surface,
            onSurface = colorSet.onSurface,
            surfaceVariant = colorSet.surfaceVariant,
            onSurfaceVariant = colorSet.onSurfaceVariant,
            surfaceDim = colorSet.surfaceDim,
            surfaceBright = colorSet.surfaceBright,
            surfaceContainerLowest = colorSet.surfaceContainerLowest,
            surfaceContainerLow = colorSet.surfaceContainerLow,
            surfaceContainer = colorSet.surfaceContainer,
            surfaceContainerHigh = colorSet.surfaceContainerHigh,
            surfaceContainerHighest = colorSet.surfaceContainerHighest,
            error = colorSet.error,
            onError = colorSet.onError,
            errorContainer = colorSet.errorContainer,
            onErrorContainer = colorSet.onErrorContainer,
            outline = colorSet.outline,
            outlineVariant = colorSet.outlineVariant,
            scrim = colorSet.scrim,
            inverseSurface = colorSet.inverseSurface,
            inverseOnSurface = colorSet.inverseOnSurface
        )
    }
}