package id.iiyh.inatrading.core.ui.theme

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

// ─── Shape tokens ─────────────────────────────────────────────────────────────
// Dipakai langsung sebagai Dp di komponen, bukan lewat MaterialTheme.shapes
// agar bisa mix sm/md/full sesuai design spec
object InaShape {
    val sm  = 4    // tags kecil
    val md  = 12   // kartu & container besar
    val lg  = 16
    val full = 9999 // chip merchant
}

// ─── Elevation tokens ─────────────────────────────────────────────────────────
object InaElevation {
    val none    = 0
    /** Ambient shadow untuk floating element: on-surface @ 4% opacity */
    val ambient = 0.04f
    val blurDp  = 32
    val offsetY = 8
}

// ─── Light Color Scheme ───────────────────────────────────────────────────────
private val LightColorScheme = lightColorScheme(
    primary             = BrandRed,
    onPrimary           = Color.White,
    primaryContainer    = BrandRedContainer,
    onPrimaryContainer  = Color(0xFF410002),

    secondary           = AccentBlue,
    onSecondary         = OnAccentBlue,
    secondaryContainer  = AccentBlueContainer,
    onSecondaryContainer = OnAccentBlueContainer,

    tertiary            = AccentPurple,
    onTertiary          = OnAccentPurple,
    tertiaryContainer   = AccentPurpleContainer,
    onTertiaryContainer = OnAccentPurpleContainer,

    error               = ErrorRed,
    onError             = OnError,
    errorContainer      = ErrorContainer,
    onErrorContainer    = OnErrorContainer,

    background          = Background,
    onBackground        = OnSurface,

    surface             = Background,
    onSurface           = OnSurface,
    onSurfaceVariant    = OnSurfaceVariant,
    surfaceContainerLowest = SurfaceContainerLowest,
    surfaceContainerLow    = SurfaceContainerLow,
    surfaceContainerHigh   = SurfaceContainerHighest,

    outline             = OutlineVariant,
    outlineVariant      = OutlineVariant,
)

// ─── Dark Color Scheme ────────────────────────────────────────────────────────
private val DarkColorScheme = darkColorScheme(
    primary             = Color(0xFFFFB3AC),
    onPrimary           = Color(0xFF680005),
    primaryContainer    = Color(0xFF93000F),
    onPrimaryContainer  = BrandRedContainer,

    secondary           = Color(0xFFBBC3FF),
    onSecondary         = Color(0xFF00178E),
    secondaryContainer  = Color(0xFF203097),
    onSecondaryContainer = Color(0xFFDEE0FF),

    tertiary            = Color(0xFFD3BBFF),
    onTertiary          = Color(0xFF3C007E),
    tertiaryContainer   = Color(0xFF560097),
    onTertiaryContainer = AccentPurpleContainer,

    error               = Color(0xFFFFB4AB),
    onError             = Color(0xFF690005),
    errorContainer      = Color(0xFF93000A),
    onErrorContainer    = ErrorContainer,

    background          = Color(0xFF191C1D),
    onBackground        = Color(0xFFE1E3E4),

    surface             = Color(0xFF191C1D),
    onSurface           = Color(0xFFE1E3E4),
    onSurfaceVariant    = Color(0xFFC0C8CD),
    surfaceContainerLowest = Color(0xFF0E1112),
    surfaceContainerLow    = Color(0xFF191C1D),
    surfaceContainerHigh   = Color(0xFF2C3032),

    outline             = Color(0xFF8A9297),
    outlineVariant      = Color(0xFF41484D),
)

// ─── Theme Entry Point ────────────────────────────────────────────────────────
@Composable
fun InaTradingTheme(
    darkTheme: Boolean = isSystemInDarkTheme(),
    content: @Composable () -> Unit
) {
    val colorScheme = if (darkTheme) DarkColorScheme else LightColorScheme

    MaterialTheme(
        colorScheme = colorScheme,
        typography  = InaTypography,
        content     = content
    )
}
