package com.mhss.app.mybrain.presentation.tgbot import androidx.compose.foundation.background import androidx.compose.foundation.layout.Arrangement import androidx.compose.foundation.layout.Box import androidx.compose.foundation.layout.Column import androidx.compose.foundation.layout.Row import androidx.compose.foundation.layout.Spacer import androidx.compose.foundation.layout.fillMaxWidth import androidx.compose.foundation.layout.height import androidx.compose.foundation.layout.padding import androidx.compose.foundation.layout.size import androidx.compose.foundation.shape.CircleShape import androidx.compose.foundation.shape.RoundedCornerShape import androidx.compose.material3.Card import androidx.compose.material3.CardDefaults import androidx.compose.material3.Icon import androidx.compose.material3.MaterialTheme import androidx.compose.material3.Text 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.Color import androidx.compose.ui.text.font.FontWeight import androidx.compose.ui.unit.dp import androidx.compose.ui.unit.sp import com.mhss.app.ui.Res import com.mhss.app.ui.ic_bolt import com.mhss.app.ui.ic_check import com.mhss.app.ui.ic_home import com.mhss.app.ui.ic_send import com.mhss.app.ui.theme.Blue import com.mhss.app.ui.theme.Green import com.mhss.app.ui.theme.Orange import com.mhss.app.ui.theme.PrimaryColor import com.mhss.app.ui.theme.Purple import org.jetbrains.compose.resources.DrawableResource import org.jetbrains.compose.resources.painterResource @Composable fun TgMetricsGrid( totalBots: Int, activeBots: Int, totalUsers: Int, messagesSent: Long, modifier: Modifier = Modifier ) { Column( modifier = modifier .fillMaxWidth() .padding(horizontal = 14.dp, vertical = 6.dp), verticalArrangement = Arrangement.spacedBy(10.dp) ) { Row( modifier = Modifier.fillMaxWidth(), horizontalArrangement = Arrangement.spacedBy(10.dp) ) { MetricCard( title = "Total Bots", value = "$totalBots / 1", subtitle = "Free Plan Limit", badge = if (totalBots > 0) "100%" else "0%", badgeColor = PrimaryColor, icon = Res.drawable.ic_bolt, iconTint = PrimaryColor, modifier = Modifier.weight(1f) ) MetricCard( title = "Active Bots", value = "$activeBots Online", subtitle = if (activeBots > 0) "Healthy Status" else "No Active Bot", badge = if (activeBots > 0) "LIVE" else "IDLE", badgeColor = if (activeBots > 0) Green else Orange, icon = Res.drawable.ic_check, iconTint = Green, modifier = Modifier.weight(1f) ) } Row( modifier = Modifier.fillMaxWidth(), horizontalArrangement = Arrangement.spacedBy(10.dp) ) { MetricCard( title = "Total Users", value = "$totalUsers", subtitle = "Max 500 (Free)", badge = "${((totalUsers.toFloat() / 500f) * 100).toInt()}% Used", badgeColor = Purple, icon = Res.drawable.ic_home, iconTint = Purple, modifier = Modifier.weight(1f) ) MetricCard( title = "Messages Sent", value = "$messagesSent", subtitle = "Broadcasts & Auto", badge = "ACTIVE", badgeColor = Blue, icon = Res.drawable.ic_send, iconTint = Blue, modifier = Modifier.weight(1f) ) } } } @Composable private fun MetricCard( title: String, value: String, subtitle: String, badge: String, badgeColor: Color, icon: DrawableResource, iconTint: Color, modifier: Modifier = Modifier ) { Card( modifier = modifier, shape = RoundedCornerShape(18.dp), colors = CardDefaults.cardColors( containerColor = MaterialTheme.colorScheme.surface ), elevation = CardDefaults.cardElevation(defaultElevation = 2.dp) ) { Column(modifier = Modifier.padding(14.dp)) { Row( modifier = Modifier.fillMaxWidth(), horizontalArrangement = Arrangement.SpaceBetween, verticalAlignment = Alignment.CenterVertically ) { Box( modifier = Modifier .size(36.dp) .clip(CircleShape) .background(iconTint.copy(alpha = 0.15f)), contentAlignment = Alignment.Center ) { Icon( painter = painterResource(icon), contentDescription = null, tint = iconTint, modifier = Modifier.size(18.dp) ) } Box( modifier = Modifier .clip(RoundedCornerShape(8.dp)) .background(badgeColor.copy(alpha = 0.15f)) .padding(horizontal = 6.dp, vertical = 2.dp) ) { Text( text = badge, style = MaterialTheme.typography.labelSmall.copy(fontWeight = FontWeight.Bold), color = badgeColor, fontSize = 10.sp ) } } Spacer(Modifier.height(10.dp)) Text( text = value, style = MaterialTheme.typography.titleLarge.copy(fontWeight = FontWeight.Bold), color = MaterialTheme.colorScheme.onSurface ) Text( text = title, style = MaterialTheme.typography.labelMedium.copy(fontWeight = FontWeight.Medium), color = MaterialTheme.colorScheme.onSurfaceVariant ) Text( text = subtitle, style = MaterialTheme.typography.labelSmall, color = MaterialTheme.colorScheme.onSurfaceVariant.copy(alpha = 0.6f), fontSize = 11.sp ) } } }