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))

/**
 * Иконка-марка приложения: градиентный squircle с монограммой «R».
 */
@Composable
fun AppMark(
    size: Dp = 76.dp,
    modifier: Modifier = Modifier
) {
    val radius = (size.value * 0.29f).dp
    Box(
        modifier = modifier
            .size(size)
            .clip(RoundedCornerShape(radius))
            .background(brandGradient()),
        contentAlignment = Alignment.Center
    ) {
        Text(
            text = "R",
            color = BgBase,
            fontWeight = FontWeight.Black,
            fontSize = (size.value * 0.62f).sp
        )
    }
}

/**
 * Текстовый логотип «radiOLA»: «radi» основным цветом, «OLA» акцентом.
 */
@Composable
fun RadiolaWordmark(
    fontSize: Int = 26,
    modifier: Modifier = Modifier
) {
    Row(modifier = modifier, verticalAlignment = Alignment.CenterVertically) {
        Text(
            text = "radi",
            color = TextPrimary,
            fontWeight = FontWeight.Bold,
            fontSize = fontSize.sp
        )
        Text(
            text = "OLA",
            color = 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
        )
    }
}
