package com.example.ui.screens import androidx.compose.foundation.background import androidx.compose.foundation.border import androidx.compose.foundation.layout.* import androidx.compose.foundation.rememberScrollState import androidx.compose.foundation.shape.RoundedCornerShape import androidx.compose.foundation.verticalScroll import androidx.compose.material.icons.Icons import androidx.compose.material.icons.filled.* import androidx.compose.material.icons.outlined.* import androidx.compose.material3.* import androidx.compose.runtime.* 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.platform.testTag import androidx.compose.ui.text.font.FontWeight import androidx.compose.ui.unit.dp import androidx.compose.ui.unit.sp import com.example.data.model.* import com.example.ui.components.StatusStepper import com.example.ui.theme.* import com.example.ui.util.Localization @Composable fun ReportTrackingScreen( reports: List, searchTrackingId: String, onSearchTrackingIdChange: (String) -> Unit, lang: AppLanguage, onBack: () -> Unit, onOpenHelpline: () -> Unit, modifier: Modifier = Modifier ) { val currentReport = remember(reports, searchTrackingId) { reports.find { it.id.equals(searchTrackingId.trim(), ignoreCase = true) } ?: reports.firstOrNull() } Scaffold( containerColor = MaterialTheme.colorScheme.background, modifier = modifier.fillMaxSize() ) { innerPadding -> Column( modifier = Modifier .fillMaxSize() .padding(innerPadding) .verticalScroll(rememberScrollState()) .padding(16.dp) ) { // Search Input for Tracking ID Surface( color = MaterialTheme.colorScheme.surface, shape = RoundedCornerShape(12.dp), border = androidx.compose.foundation.BorderStroke(1.dp, LightOutline), modifier = Modifier.fillMaxWidth() ) { Row( modifier = Modifier .fillMaxWidth() .padding(8.dp), verticalAlignment = Alignment.CenterVertically ) { OutlinedTextField( value = searchTrackingId, onValueChange = onSearchTrackingIdChange, placeholder = { Text("BD-SCAM-XXXX") }, label = { Text(if (lang == AppLanguage.BN) "ট্র্যাকিং আইডি দিয়ে খুঁজুন" else "Search by Tracking ID") }, leadingIcon = { Icon( imageVector = Icons.Default.Search, contentDescription = null, tint = BrandNavyPrimary ) }, singleLine = true, shape = RoundedCornerShape(10.dp), modifier = Modifier .weight(1f) .testTag("input_tracking_id") ) } } Spacer(modifier = Modifier.height(16.dp)) if (currentReport != null) { // Report Header Card Surface( color = BrandNavyPrimary, shape = RoundedCornerShape(16.dp), modifier = Modifier.fillMaxWidth() ) { Column(modifier = Modifier.padding(16.dp)) { Row( modifier = Modifier.fillMaxWidth(), horizontalArrangement = Arrangement.SpaceBetween, verticalAlignment = Alignment.CenterVertically ) { Text( text = currentReport.id, style = MaterialTheme.typography.titleLarge.copy( fontWeight = FontWeight.Black, color = Color.White, letterSpacing = 1.sp ) ) Surface( color = when (currentReport.status) { ReportStatus.LEGAL_ESCALATION -> StatusWarningRed ReportStatus.VERIFIED_WARNING_ISSUED -> StatusAmber ReportStatus.RESOLVED -> StatusVerifiedGreen else -> BrandBlueAccent }, shape = RoundedCornerShape(8.dp) ) { Text( text = Localization.getReportStatusText(currentReport.status, lang), style = MaterialTheme.typography.labelSmall.copy( color = Color.White, fontWeight = FontWeight.Bold ), modifier = Modifier.padding(horizontal = 8.dp, vertical = 4.dp) ) } } Spacer(modifier = Modifier.height(12.dp)) Text( text = currentReport.targetEntityName, style = MaterialTheme.typography.titleMedium.copy( fontWeight = FontWeight.Bold, color = Color.White ) ) Text( text = "${currentReport.scamCategory} • ${currentReport.city}", style = MaterialTheme.typography.bodySmall.copy( color = Color.White.copy(alpha = 0.8f) ) ) Spacer(modifier = Modifier.height(12.dp)) Row( modifier = Modifier.fillMaxWidth(), horizontalArrangement = Arrangement.SpaceBetween ) { Text( text = "${if (lang == AppLanguage.BN) "ক্ষতি:" else "Loss:"} ${Localization.formatCurrency(currentReport.moneyLostBdt, lang)}", style = MaterialTheme.typography.bodyMedium.copy( fontWeight = FontWeight.Bold, color = Color(0xFFFCA5A5) ) ) Text( text = "${if (lang == AppLanguage.BN) "দাখিল:" else "Date:"} ${currentReport.dateReported}", style = MaterialTheme.typography.bodySmall.copy( color = Color.White.copy(alpha = 0.7f) ) ) } } } Spacer(modifier = Modifier.height(20.dp)) // Status Timeline Stepper Surface( color = MaterialTheme.colorScheme.surface, shape = RoundedCornerShape(14.dp), border = androidx.compose.foundation.BorderStroke(1.dp, LightOutline), modifier = Modifier.fillMaxWidth() ) { Column(modifier = Modifier.padding(16.dp)) { Text( text = if (lang == AppLanguage.BN) "তদন্ত ও আইনি অগ্রগতি" else "Investigation & Legal Progress", style = MaterialTheme.typography.titleMedium.copy( fontWeight = FontWeight.Bold, color = MaterialTheme.colorScheme.onSurface ) ) Spacer(modifier = Modifier.height(12.dp)) StatusStepper(currentStatus = currentReport.status, lang = lang) } } // Official Investigator / Admin Note if (currentReport.adminNotes != null) { Spacer(modifier = Modifier.height(16.dp)) Surface( color = Color(0xFFEFF6FF), shape = RoundedCornerShape(12.dp), border = androidx.compose.foundation.BorderStroke(1.dp, Color(0xFFBFDBFE)), modifier = Modifier.fillMaxWidth() ) { Column(modifier = Modifier.padding(14.dp)) { Row(verticalAlignment = Alignment.CenterVertically) { Icon( imageVector = Icons.Default.Security, contentDescription = null, tint = BrandNavyPrimary, modifier = Modifier.size(18.dp) ) Spacer(modifier = Modifier.width(6.dp)) Text( text = if (lang == AppLanguage.BN) "তদন্তকারী টিমের মন্তব্য ও রেফারেন্স" else "Official Cyber Cell Remark", style = MaterialTheme.typography.labelMedium.copy( fontWeight = FontWeight.Bold, color = BrandNavyPrimary ) ) } Spacer(modifier = Modifier.height(6.dp)) Text( text = currentReport.adminNotes, style = MaterialTheme.typography.bodyMedium.copy( color = MaterialTheme.colorScheme.onSurface, lineHeight = 18.sp ) ) } } } Spacer(modifier = Modifier.height(20.dp)) // Action Buttons Row( modifier = Modifier.fillMaxWidth(), horizontalArrangement = Arrangement.spacedBy(10.dp) ) { OutlinedButton( onClick = onOpenHelpline, shape = RoundedCornerShape(12.dp), modifier = Modifier.weight(1f) ) { Icon( imageVector = Icons.Default.Call, contentDescription = null, tint = StatusWarningRed, modifier = Modifier.size(16.dp) ) Spacer(modifier = Modifier.width(6.dp)) Text( text = if (lang == AppLanguage.BN) "জরুরি সাইবার পুলিশ" else "Cyber Helpline", style = MaterialTheme.typography.labelSmall.copy(fontWeight = FontWeight.Bold) ) } FilledTonalButton( onClick = onBack, shape = RoundedCornerShape(12.dp), modifier = Modifier.weight(1f) ) { Text( text = if (lang == AppLanguage.BN) "হোমে যান" else "Go to Home", style = MaterialTheme.typography.labelSmall.copy(fontWeight = FontWeight.Bold) ) } } } else { Box( modifier = Modifier .fillMaxWidth() .padding(32.dp), contentAlignment = Alignment.Center ) { Text( text = if (lang == AppLanguage.BN) "কোনো রিপোর্ট পাওয়া যায়নি।" else "No report matching ID.", color = LightTextMuted ) } } Spacer(modifier = Modifier.height(24.dp)) } } }