package cl.homelogic.platform.designsystem.components.zExperiments

import androidx.compose.foundation.layout.Arrangement
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.material3.Card
import androidx.compose.material3.CardDefaults
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.graphics.Color
import androidx.compose.ui.text.font.FontWeight
import androidx.compose.ui.unit.dp
import cl.homelogic.platform.designsystem.foundations.Shapes

@Composable
fun TemperatureCard(
    modifier: Modifier = Modifier,
    temperature: Int = 72,
    percentage: Float = 2f,
    temperatureData: List<Float> = emptyList(),
) {
    Card(
        modifier = modifier
            .fillMaxWidth()
            .padding(16.dp),
        shape = Shapes.RoundCorner.regular,
        elevation = CardDefaults.cardElevation(defaultElevation = 4.dp),
    ) {
        Column(
            modifier = Modifier
                .padding(24.dp)
                .fillMaxWidth(),
        ) {
            Text(
                text = "Temperature",
                style = MaterialTheme.typography.titleLarge,
                color = MaterialTheme.colorScheme.onSurface,
            )

            Spacer(modifier = Modifier.height(8.dp))

            Text(
                text = temperature.toString(),
                style = MaterialTheme.typography.displayLarge,
                fontWeight = FontWeight.Bold,
                color = MaterialTheme.colorScheme.onSurface,
            )

            Row(
                verticalAlignment = Alignment.CenterVertically,
                horizontalArrangement = Arrangement.spacedBy(4.dp),
            ) {
                Text(
                    text = "Now",
                    style = MaterialTheme.typography.bodyLarge,
                    color = Color.Gray,
                )
                Text(
                    text = "+${percentage.toInt()}%",
                    style = MaterialTheme.typography.bodyLarge,
                    color = Color(0xFF22C55E), // Green color
                )
            }

            Spacer(modifier = Modifier.height(32.dp))

            TemperatureGraph(
                data = temperatureData,
                modifier = Modifier
                    .fillMaxWidth()
                    .height(120.dp),
            )

            Spacer(modifier = Modifier.height(16.dp))

            Row(
                modifier = Modifier.fillMaxWidth(),
                horizontalArrangement = Arrangement.SpaceBetween,
            ) {
                Text("9AM", color = Color.Gray)
                Text("12PM", color = Color.Gray)
                Text("3PM", color = Color.Gray)
                Text("6PM", color = Color.Gray)
                Text("9PM", color = Color.Gray)
            }
        }
    }
}
