package com.iscs.bozzys.ui.pages.compose

import androidx.compose.foundation.background
import androidx.compose.foundation.border
import androidx.compose.foundation.clickable
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.ExperimentalLayoutApi
import androidx.compose.foundation.layout.FlowRow
import androidx.compose.foundation.layout.Row
import androidx.compose.foundation.layout.Spacer
import androidx.compose.foundation.layout.fillMaxHeight
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.RoundedCornerShape
import androidx.compose.material3.Icon
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.res.painterResource
import androidx.compose.ui.text.font.FontWeight
import androidx.compose.ui.text.style.TextAlign
import androidx.compose.ui.unit.dp
import androidx.compose.ui.unit.sp
import com.iscs.bozzys.R
import com.iscs.bozzys.ui.theme.Text

@OptIn(ExperimentalLayoutApi::class)
@Composable
fun JobListItem() {
    Column(
        Modifier
            .padding(bottom = 15.dp)
            .fillMaxWidth()
            .height(156.dp)
            .border(1.dp, color = Color(0xFFEEEEEE), shape = RoundedCornerShape(12.dp))
            .clip(RoundedCornerShape(12.dp))
            .background(Color(0xFFF8F9FA))
            .clickable(onClick = {})
            .padding(16.dp)
    ) {
        Row {
            Text("1号配电箱停电检查作业", fontSize = 15.sp, fontWeight = FontWeight.Medium, color = Text)
            Spacer(Modifier.weight(1f))
            Text(
                "紧急", modifier = Modifier
                    .height(24.dp)
                    .clip(RoundedCornerShape(12.dp))
                    .background(Color(0xFFFF4500))
                    .padding(horizontal = 10.dp),
                fontSize = 12.sp,
                lineHeight = 24.sp,
                color = Color.White
            )
        }
        FlowRow(Modifier.padding(top = 10.dp)) {
            Row(Modifier.padding(end = 12.dp), verticalAlignment = Alignment.CenterVertically) {
                Icon(
                    painterResource(R.drawable.location), contentDescription = null, modifier = Modifier
                        .padding(end = 5.dp)
                        .size(13.dp),
                    tint = Color(0xFF1E90FF)
                )
                Text("车间A区", fontSize = 13.sp, color = Color(0xFF666666))
            }
            Row(Modifier.padding(end = 12.dp), verticalAlignment = Alignment.CenterVertically) {
                Icon(
                    painterResource(R.drawable.user), contentDescription = null, modifier = Modifier
                        .padding(end = 5.dp)
                        .size(13.dp),
                    tint = Color(0xFF666666)
                )
                Text("负责人：张三", fontSize = 13.sp, color = Color(0xFF666666))
            }
            Row(Modifier.padding(end = 12.dp), verticalAlignment = Alignment.CenterVertically) {
                Icon(
                    painterResource(R.drawable.jobs), contentDescription = null, modifier = Modifier
                        .padding(end = 5.dp)
                        .size(13.dp),
                    tint = Color(0xFF666666)
                )
                Text("WO-2025-1210", fontSize = 13.sp, color = Color(0xFF666666))
            }
            Text("作业内容：切断电源", fontSize = 13.sp, color = Color(0xFF666666))
        }
        Spacer(Modifier.weight(1f))
        Row(
            Modifier
                .fillMaxWidth()
                .height(36.dp), verticalAlignment = Alignment.CenterVertically
        ) {
            Text("工作描述内容", fontSize = 12.sp, color = Color(0xFF999999))
            Spacer(Modifier.weight(1f))
            Text(
                "立即处理",
                modifier = Modifier
                    .fillMaxHeight()
                    .clip(RoundedCornerShape(4.dp))
                    .background(Color(0xFF1E90FF))
                    .padding(horizontal = 10.dp),
                fontSize = 13.sp,
                lineHeight = 36.sp,
                fontWeight = FontWeight.Bold,
                color = Color.White,
                textAlign = TextAlign.Center
            )
        }
    }
}