package chat.vojo.proxy.ui.theme

import androidx.compose.material3.MaterialTheme
import androidx.compose.material3.Typography
import androidx.compose.material3.darkColorScheme
import androidx.compose.runtime.Composable
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.text.TextStyle
import androidx.compose.ui.text.font.FontFamily
import androidx.compose.ui.text.font.FontWeight
import androidx.compose.ui.unit.sp

/**
 * The "Dawn / Fleet" palette ported from the vojo design bundle: near-black
 * surfaces, hairline dividers, a single violet accent, colour used only for
 * status. Monospace is reserved for technical metadata (host:port, ciphers).
 */
object Vojo {
    val bgApp = Color(0xFF0D0E11)     // app background
    val bgPanel = Color(0xFF181A20)   // cards / panels
    val surface = Color(0xFF21232B)   // raised
    val surface2 = Color(0xFF2A2D36)  // hover / active

    val divider = Color(0x0FFFFFFF)   // white 6%
    val hairline = Color(0x14FFFFFF)  // white 8%
    val rail = Color(0x2EE6E6E9)      // thin gray rail ~18%

    val text = Color(0xFFE6E6E9)
    val muted = Color(0x8CE6E6E9)     // 55%
    val faint = Color(0x52E6E6E9)     // 32%

    val fleet = Color(0xFF9580FF)     // violet accent
    val fleetSoft = Color(0xFFA59CFF)
    val green = Color(0xFF7DD3A8)
    val amber = Color(0xFFD4B88A)
    val blue = Color(0xFF7AB6D9)
    val teal = Color(0xFF9BD1B3)
    val danger = Color(0xFFE0796B)

    val mono = FontFamily.Monospace
}

private val VojoColorScheme = darkColorScheme(
    primary = Vojo.fleet,
    onPrimary = Color(0xFF0C0C0E),
    secondary = Vojo.fleetSoft,
    background = Vojo.bgApp,
    onBackground = Vojo.text,
    surface = Vojo.bgPanel,
    onSurface = Vojo.text,
    surfaceVariant = Vojo.surface,
    onSurfaceVariant = Vojo.muted,
    error = Vojo.danger,
    outline = Vojo.hairline,
    // M3 popups (DropdownMenu, ModalBottomSheet) pick surfaceContainer* — keep
    // them inside the Vojo palette instead of the default violet-tinted tones.
    surfaceContainerLowest = Vojo.bgApp,
    surfaceContainerLow = Vojo.bgPanel,
    surfaceContainer = Vojo.bgPanel,
    surfaceContainerHigh = Vojo.surface,
    surfaceContainerHighest = Vojo.surface,
    surfaceDim = Vojo.bgApp,
    surfaceBright = Vojo.surface2,
)

private val VojoTypography = Typography(
    titleLarge = TextStyle(fontSize = 22.sp, fontWeight = FontWeight.SemiBold, color = Vojo.text),
    titleMedium = TextStyle(fontSize = 15.sp, fontWeight = FontWeight.SemiBold, color = Vojo.text),
    bodyLarge = TextStyle(fontSize = 14.sp, color = Vojo.text),
    bodyMedium = TextStyle(fontSize = 13.sp, color = Vojo.text),
    bodySmall = TextStyle(fontSize = 11.5.sp, color = Vojo.muted),
    labelLarge = TextStyle(fontSize = 13.sp, fontWeight = FontWeight.Medium),
    labelSmall = TextStyle(fontSize = 10.5.sp, color = Vojo.faint),
)

@Composable
fun VojoTheme(content: @Composable () -> Unit) {
    // App is dark-only, like the design (no light-theme branch).
    MaterialTheme(
        colorScheme = VojoColorScheme,
        typography = VojoTypography,
        content = content,
    )
}
