package com.radiola.ui.theme

import androidx.compose.foundation.background
import androidx.compose.foundation.border
import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.layout.Row
import androidx.compose.foundation.layout.size
import androidx.compose.foundation.shape.CircleShape
import androidx.compose.foundation.shape.RoundedCornerShape
import androidx.compose.runtime.Composable
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.draw.clip
import androidx.compose.ui.graphics.Brush
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.text.font.FontWeight
import androidx.compose.ui.unit.Dp
import androidx.compose.ui.unit.dp
import androidx.compose.ui.unit.sp
import androidx.compose.material3.Text

/** Брендовый градиент иконки. */
fun brandGradient(): Brush = Brush.linearGradient(listOf(BrandGradientStart, BrandGradientEnd))

/**
 * Марка приложения: объёмная 3D-монограмма «R», перекрашенная под текущую тему.
 */
@Composable
fun AppMark(
    size: Dp = 76.dp,
    modifier: Modifier = Modifier
) {
    val palette = RadiolaTheme.palette
    androidx.compose.foundation.Image(
        painter = androidx.compose.ui.res.painterResource(palette.logoRes),
        contentDescription = "radiOLA",
        modifier = modifier.size(size)
    )
}

/**
 * Текстовый логотип «radiOLA»: «radi» основным цветом, «OLA» акцентом.
 */
@Composable
fun RadiolaWordmark(
    fontSize: Int = 26,
    modifier: Modifier = Modifier
) {
    val colors = RadiolaTheme.colors
    Row(modifier = modifier, verticalAlignment = Alignment.CenterVertically) {
        Text(
            text = "radi",
            color = colors.textPrimary,
            fontWeight = FontWeight.Bold,
            fontSize = fontSize.sp
        )
        Text(
            text = "OLA",
            color = colors.accent,
            fontWeight = FontWeight.Bold,
            fontSize = fontSize.sp
        )
    }
}

/** Монохромная марка для нейтральных подложек (уведомления, виджет). */
@Composable
fun MonoMark(
    size: Dp = 24.dp,
    color: Color = TextPrimary,
    modifier: Modifier = Modifier
) {
    Box(
        modifier = modifier
            .size(size)
            .clip(RoundedCornerShape((size.value * 0.27f).dp))
            .border(1.5.dp, color, RoundedCornerShape((size.value * 0.27f).dp)),
        contentAlignment = Alignment.Center
    ) {
        Text(
            text = "R",
            color = color,
            fontWeight = FontWeight.Black,
            fontSize = (size.value * 0.6f).sp
        )
    }
}
