package app.closer.ui.theme

import androidx.compose.material3.MaterialTheme
import androidx.compose.material3.Typography
import androidx.compose.material3.lightColorScheme
import androidx.compose.material3.darkColorScheme
import androidx.compose.foundation.isSystemInDarkTheme
import androidx.compose.runtime.Composable
import androidx.compose.ui.graphics.Color

@Composable
fun CloserTheme(
    darkTheme: Boolean = isSystemInDarkTheme(),
    content: @Composable () -> Unit
) {
    val colors = if (darkTheme) darkColors else lightColors

    MaterialTheme(
        colorScheme = colors,
        typography = Typography,
        content = content
    )
}

// Brand palette. Keep accent color in containers and controls; large surfaces stay quiet.
val PrimaryColor = Color(0xFF7B4DB2)
val PrimaryContainerColor = Color(0xFFF1E7FF)
val SecondaryColor = Color(0xFF9B4F78)
val TertiaryColor = Color(0xFF6B5AA6)
val BackgroundColor = Color(0xFFFFFBFF)
val SurfaceColor = Color(0xFFFFFBFF)
val ErrorColor = Color(0xFFBA1A1A)
val SurfaceVariantColor = Color(0xFFF0E8F4)
val OutlineColor = Color(0xFF807581)
val OutlineVariantColor = Color(0xFFD2C7D5)

val OnPrimaryColor = Color(0xFFFFFFFF)
val OnPrimaryContainerColor = Color(0xFF29123F)
val OnSecondaryColor = Color(0xFFFFFFFF)
val OnTertiaryColor = Color(0xFFFFFFFF)
val OnBackgroundColor = Color(0xFF211A24)
val OnSurfaceColor = Color(0xFF211A24)
val OnSurfaceVariantColor = Color(0xFF514957)
val OnErrorColor = Color(0xFFFFFFFF)

val lightColors = lightColorScheme(
    primary = PrimaryColor,
    onPrimary = OnPrimaryColor,
    primaryContainer = PrimaryContainerColor,
    onPrimaryContainer = OnPrimaryContainerColor,
    secondary = SecondaryColor,
    onSecondary = OnSecondaryColor,
    secondaryContainer = Color(0xFFFFD8E9),
    onSecondaryContainer = Color(0xFF3B1730),
    tertiary = TertiaryColor,
    onTertiary = OnTertiaryColor,
    tertiaryContainer = Color(0xFFE9E3FF),
    onTertiaryContainer = Color(0xFF321545),
    background = BackgroundColor,
    surface = SurfaceColor,
    onBackground = OnBackgroundColor,
    onSurface = OnSurfaceColor,
    surfaceVariant = SurfaceVariantColor,
    onSurfaceVariant = OnSurfaceVariantColor,
    outline = OutlineColor,
    outlineVariant = OutlineVariantColor,
    error = ErrorColor,
    onError = OnErrorColor
)

val darkColors = darkColorScheme(
    primary = Color(0xFFD7BBFF),
    onPrimary = Color(0xFF37204E),
    primaryContainer = Color(0xFF4D3865),
    onPrimaryContainer = Color(0xFFF2E8FF),
    secondary = Color(0xFFE8B7D0),
    onSecondary = Color(0xFF482638),
    secondaryContainer = Color(0xFF3D2C36),
    onSecondaryContainer = Color(0xFFFFD8EA),
    tertiary = Color(0xFFC9C1FF),
    onTertiary = Color(0xFF302A55),
    tertiaryContainer = Color(0xFF343047),
    onTertiaryContainer = Color(0xFFE8E2FF),
    background = Color(0xFF111015),
    surface = Color(0xFF19161F),
    onBackground = Color(0xFFEDE7EF),
    onSurface = Color(0xFFEDE7EF),
    surfaceVariant = Color(0xFF2D2933),
    onSurfaceVariant = Color(0xFFD3C8D8),
    outline = Color(0xFF9E93A4),
    outlineVariant = Color(0xFF4D4653),
    error = Color(0xFFFFB4AB),
    onError = Color(0xFF690005),
    errorContainer = Color(0xFF93000A),
    onErrorContainer = Color(0xFFFFDAD6),
    inverseSurface = Color(0xFFEDE7EF),
    inverseOnSurface = Color(0xFF322F36),
    inversePrimary = Color(0xFF6D45A0),
    surfaceTint = Color(0xFFD7BBFF),
    scrim = Color(0xFF000000)
)
