package ru.fincode.tsudesk.core.ui.theme

import androidx.compose.foundation.isSystemInDarkTheme
import androidx.compose.material3.MaterialTheme
import androidx.compose.runtime.Composable
import androidx.compose.runtime.CompositionLocalProvider

@Composable
fun TSUDeskTheme(
    darkTheme: Boolean = isSystemInDarkTheme(),
    content: @Composable () -> Unit
) {
    val scheme = if (darkTheme) DarkColorScheme else LightColorScheme

    val extended = ExtendedColors(
        brand = BrandRed,
        onBrand = OnBrand,
        brandSoft = BrandRed.copy(alpha = 0.12f),
        brandGradientStart = BrandRed.copy(alpha = 0.95f),
        brandGradientEnd = BrandRed,
        borderSoft = if (darkTheme)
            scheme.outline.copy(alpha = 0.4f)
        else
            scheme.outline.copy(alpha = 0.2f),
    )

    CompositionLocalProvider(LocalExtendedColors provides extended) {
        MaterialTheme(
            colorScheme = scheme,
            typography = TSUDeskTypography,
            content = content
        )
    }
}