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.CircleShape 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.graphics.vector.ImageVector 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.RiskScoreMeter import com.example.ui.components.VerificationBadge import com.example.ui.theme.* import com.example.ui.util.Localization @Composable fun CompanyProfileScreen( company: Company?, lang: AppLanguage, onBack: () -> Unit, onReportCompany: (String) -> Unit, modifier: Modifier = Modifier ) { if (company == null) { Box( modifier = modifier.fillMaxSize(), contentAlignment = Alignment.Center ) { Text(if (lang == AppLanguage.BN) "কোম্পানির তথ্য পাওয়া যায়নি" else "Company profile not found") } return } var selectedTab by remember { mutableStateOf(0) } // 0: Overview & Reg, 1: Contact & Owner, 2: Complaints & Evidence Scaffold( containerColor = MaterialTheme.colorScheme.background, bottomBar = { Surface( color = MaterialTheme.colorScheme.surface, tonalElevation = 8.dp, border = androidx.compose.foundation.BorderStroke(1.dp, LightOutline), modifier = Modifier.fillMaxWidth() ) { Row( modifier = Modifier .fillMaxWidth() .padding(16.dp) .navigationBarsPadding(), horizontalArrangement = Arrangement.spacedBy(12.dp) ) { OutlinedButton( onClick = onBack, shape = RoundedCornerShape(12.dp), modifier = Modifier .weight(1f) .height(48.dp) ) { Text(if (lang == AppLanguage.BN) "ফিরে যান" else "Back") } Button( onClick = { onReportCompany(company.nameEn) }, colors = ButtonDefaults.buttonColors( containerColor = if (company.status == VerificationStatus.VERIFIED_SAFE) BrandNavyPrimary else StatusWarningRed ), shape = RoundedCornerShape(12.dp), modifier = Modifier .weight(1.5f) .height(48.dp) .testTag("btn_report_company_profile") ) { Icon( imageVector = Icons.Default.ReportProblem, contentDescription = null, modifier = Modifier.size(18.dp) ) Spacer(modifier = Modifier.width(6.dp)) Text( text = if (lang == AppLanguage.BN) "অভিযোগ দিন" else "Lodge Complaint", fontWeight = FontWeight.Bold ) } } } }, modifier = modifier.fillMaxSize() ) { innerPadding -> Column( modifier = Modifier .fillMaxSize() .padding(innerPadding) .verticalScroll(rememberScrollState()) ) { // Top Header Card Surface( color = MaterialTheme.colorScheme.surface, tonalElevation = 2.dp, modifier = Modifier.fillMaxWidth() ) { Column(modifier = Modifier.padding(16.dp)) { Row( modifier = Modifier.fillMaxWidth(), verticalAlignment = Alignment.CenterVertically ) { Box( modifier = Modifier .size(56.dp) .clip(RoundedCornerShape(14.dp)) .background( if (company.status == VerificationStatus.VERIFIED_SAFE) StatusVerifiedGreenBg else StatusWarningRedBg ), contentAlignment = Alignment.Center ) { Icon( imageVector = if (company.status == VerificationStatus.VERIFIED_SAFE) Icons.Default.Verified else Icons.Default.Warning, contentDescription = null, tint = if (company.status == VerificationStatus.VERIFIED_SAFE) StatusVerifiedGreen else StatusWarningRed, modifier = Modifier.size(32.dp) ) } Spacer(modifier = Modifier.width(14.dp)) Column(modifier = Modifier.weight(1f)) { Text( text = if (lang == AppLanguage.BN) company.nameBn else company.nameEn, style = MaterialTheme.typography.titleLarge.copy( fontWeight = FontWeight.Bold, fontSize = 19.sp, color = MaterialTheme.colorScheme.onSurface ) ) Spacer(modifier = Modifier.height(2.dp)) Text( text = "${company.category} • ${company.city}", style = MaterialTheme.typography.bodyMedium.copy( color = LightTextSecondary, fontSize = 13.sp ) ) } } Spacer(modifier = Modifier.height(14.dp)) Row( modifier = Modifier.fillMaxWidth(), horizontalArrangement = Arrangement.SpaceBetween, verticalAlignment = Alignment.CenterVertically ) { VerificationBadge(status = company.status, lang = lang) Text( text = company.verifiedBadgeTitle, style = MaterialTheme.typography.labelSmall.copy( color = BrandNavyPrimary, fontWeight = FontWeight.SemiBold ) ) } Spacer(modifier = Modifier.height(16.dp)) // Risk Score Meter Component RiskScoreMeter(score = company.riskScore, lang = lang) } } // Warning Banner if applicable if (company.warningNoticeEn != null || company.warningNoticeBn != null) { Surface( color = StatusWarningRedBg, border = androidx.compose.foundation.BorderStroke(1.dp, StatusWarningRed.copy(alpha = 0.4f)), shape = RoundedCornerShape(12.dp), modifier = Modifier .fillMaxWidth() .padding(16.dp) ) { Row( modifier = Modifier.padding(12.dp), verticalAlignment = Alignment.Top ) { Icon( imageVector = Icons.Default.Dangerous, contentDescription = null, tint = StatusWarningRed, modifier = Modifier.size(24.dp) ) Spacer(modifier = Modifier.width(10.dp)) Column { Text( text = if (lang == AppLanguage.BN) "সরকারি সাইবার পুলিশ ও গোয়েন্দা সতর্কতা" else "Official Cyber Security Warning", style = MaterialTheme.typography.titleSmall.copy( fontWeight = FontWeight.Bold, color = StatusWarningRed ) ) Spacer(modifier = Modifier.height(4.dp)) Text( text = (if (lang == AppLanguage.BN) company.warningNoticeBn else company.warningNoticeEn) ?: "", style = MaterialTheme.typography.bodySmall.copy( color = Color(0xFF7F1D1D), lineHeight = 17.sp ) ) } } } } // Navigation Tabs TabRow( selectedTabIndex = selectedTab, containerColor = MaterialTheme.colorScheme.surface, contentColor = BrandNavyPrimary, modifier = Modifier.padding(top = 8.dp) ) { Tab( selected = selectedTab == 0, onClick = { selectedTab = 0 }, text = { Text(if (lang == AppLanguage.BN) "রেজিস্ট্রেশন ও বিবরণ" else "Registration & Bio") } ) Tab( selected = selectedTab == 1, onClick = { selectedTab = 1 }, text = { Text(if (lang == AppLanguage.BN) "মালিক ও যোগাযোগ" else "Owners & Contact") } ) Tab( selected = selectedTab == 2, onClick = { selectedTab = 2 }, text = { Text(if (lang == AppLanguage.BN) "অভিযোগ (${company.complaintCount})" else "Complaints (${company.complaintCount})") } ) } // Tab Content when (selectedTab) { 0 -> { // Registration & Legal Info Column( modifier = Modifier .fillMaxWidth() .padding(16.dp), verticalArrangement = Arrangement.spacedBy(12.dp) ) { InfoCardItem( title = if (lang == AppLanguage.BN) "কোম্পানি সারসংক্ষেপ" else "Company Summary", value = if (lang == AppLanguage.BN) company.summaryBn else company.summaryEn, icon = Icons.Default.Description ) InfoRowCard( label = "RJSC Registration No", value = company.rjscRegNo, icon = Icons.Default.Badge ) InfoRowCard( label = "Trade License Number", value = company.tradeLicenseNo, icon = Icons.Default.FactCheck ) InfoRowCard( label = "TIN / BIN Number", value = "TIN: ${company.tinNo}\nBIN: ${company.binNo}", icon = Icons.Default.Receipt ) InfoRowCard( label = if (lang == AppLanguage.BN) "প্রতিষ্ঠার তারিখ" else "Incorporation Date", value = company.incorporationDate, icon = Icons.Default.Event ) InfoRowCard( label = if (lang == AppLanguage.BN) "নিবন্ধিত ঠিকানা" else "Registered Address", value = "${company.address}, ${company.city}", icon = Icons.Default.LocationOn ) } } 1 -> { // Owner & Contact Column( modifier = Modifier .fillMaxWidth() .padding(16.dp), verticalArrangement = Arrangement.spacedBy(12.dp) ) { Surface( color = MaterialTheme.colorScheme.surface, shape = RoundedCornerShape(12.dp), border = androidx.compose.foundation.BorderStroke(1.dp, LightOutline), modifier = Modifier.fillMaxWidth() ) { Column(modifier = Modifier.padding(14.dp)) { Text( text = if (lang == AppLanguage.BN) "মালিক / ব্যবস্থাপনা পরিচালক" else "Managing Director / Ownership", style = MaterialTheme.typography.labelMedium.copy(color = LightTextMuted) ) Spacer(modifier = Modifier.height(4.dp)) Row( verticalAlignment = Alignment.CenterVertically, horizontalArrangement = Arrangement.SpaceBetween, modifier = Modifier.fillMaxWidth() ) { Text( text = company.managingDirector, style = MaterialTheme.typography.titleMedium.copy(fontWeight = FontWeight.Bold) ) if (company.directorNidVerified) { Surface( color = StatusVerifiedGreenBg, shape = RoundedCornerShape(6.dp) ) { Text( text = "✓ NID Verified", color = StatusVerifiedGreen, style = MaterialTheme.typography.labelSmall.copy(fontWeight = FontWeight.Bold), modifier = Modifier.padding(horizontal = 6.dp, vertical = 2.dp) ) } } } } } InfoRowCard( label = if (lang == AppLanguage.BN) "যোগাযোগের ফোন নম্বর" else "Contact Phone", value = company.phone, icon = Icons.Default.Phone ) InfoRowCard( label = if (lang == AppLanguage.BN) "ইমেইল অ্যাড্রেস" else "Official Email", value = company.email, icon = Icons.Default.Email ) InfoRowCard( label = if (lang == AppLanguage.BN) "বিকাশ মার্চেন্ট / পেমেন্ট নম্বর" else "bKash / Nagad Wallet", value = company.bkashMerchantNo.ifBlank { "Not provided" }, icon = Icons.Default.AccountBalanceWallet ) InfoRowCard( label = if (lang == AppLanguage.BN) "অফিসিয়াল ওয়েবসাইট ও পেজ" else "Official Website & Page", value = "${company.website}\n${company.facebookPage}", icon = Icons.Default.Language ) } } 2 -> { // Complaints & Evidence History Column( modifier = Modifier .fillMaxWidth() .padding(16.dp), verticalArrangement = Arrangement.spacedBy(12.dp) ) { Surface( color = if (company.complaintCount == 0) StatusVerifiedGreenBg else StatusWarningRedBg, shape = RoundedCornerShape(12.dp), modifier = Modifier.fillMaxWidth() ) { Row( modifier = Modifier.padding(14.dp), verticalAlignment = Alignment.CenterVertically ) { Icon( imageVector = if (company.complaintCount == 0) Icons.Default.CheckCircle else Icons.Default.Report, contentDescription = null, tint = if (company.complaintCount == 0) StatusVerifiedGreen else StatusWarningRed, modifier = Modifier.size(24.dp) ) Spacer(modifier = Modifier.width(10.dp)) Text( text = if (company.complaintCount == 0) { if (lang == AppLanguage.BN) "এই প্রতিষ্ঠানের বিরুদ্ধে কোনো প্রতারণার রেকর্ড নেই" else "Zero active scam reports lodged against this entity" } else { if (lang == AppLanguage.BN) "মোট ${company.complaintCount} টি নথিভুক্ত নাগরিক অভিযোগ রয়েছে" else "Total ${company.complaintCount} verified citizen complaints on record" }, style = MaterialTheme.typography.bodyMedium.copy( fontWeight = FontWeight.SemiBold, color = if (company.complaintCount == 0) Color(0xFF14532D) else Color(0xFF7F1D1D) ) ) } } if (company.complaintCount > 0) { Text( text = if (lang == AppLanguage.BN) "সংযুক্ত প্রমাণের ধরন:" else "Attached Proof Types:", style = MaterialTheme.typography.titleSmall.copy(fontWeight = FontWeight.Bold) ) listOf( "📱 bKash Transaction SMS Receipts (Verified)", "💬 WhatsApp & Messenger Extortion Chats", "📄 Counterfeit Embassy Offer Letter with Fake Seal", "🚨 Gulshan Police Thana GD Copy #981/2026" ).forEach { proof -> Surface( color = MaterialTheme.colorScheme.surface, shape = RoundedCornerShape(8.dp), border = androidx.compose.foundation.BorderStroke(1.dp, LightOutline), modifier = Modifier.fillMaxWidth() ) { Text( text = proof, style = MaterialTheme.typography.bodyMedium.copy(color = MaterialTheme.colorScheme.onSurface), modifier = Modifier.padding(12.dp) ) } } } } } } Spacer(modifier = Modifier.height(24.dp)) } } } @Composable fun InfoCardItem( title: String, value: String, icon: ImageVector ) { Surface( color = MaterialTheme.colorScheme.surface, shape = RoundedCornerShape(12.dp), border = androidx.compose.foundation.BorderStroke(1.dp, LightOutline), modifier = Modifier.fillMaxWidth() ) { Column(modifier = Modifier.padding(14.dp)) { Row(verticalAlignment = Alignment.CenterVertically) { Icon( imageVector = icon, contentDescription = null, tint = BrandNavyPrimary, modifier = Modifier.size(18.dp) ) Spacer(modifier = Modifier.width(8.dp)) Text( text = title, style = MaterialTheme.typography.labelMedium.copy( color = LightTextMuted, fontWeight = FontWeight.SemiBold ) ) } Spacer(modifier = Modifier.height(6.dp)) Text( text = value, style = MaterialTheme.typography.bodyMedium.copy( color = MaterialTheme.colorScheme.onSurface, lineHeight = 20.sp ) ) } } } @Composable fun InfoRowCard( label: String, value: String, icon: ImageVector ) { 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(14.dp), verticalAlignment = Alignment.CenterVertically ) { Box( modifier = Modifier .size(36.dp) .clip(RoundedCornerShape(8.dp)) .background(LightSurfaceVariant), contentAlignment = Alignment.Center ) { Icon( imageVector = icon, contentDescription = null, tint = BrandNavyPrimary, modifier = Modifier.size(20.dp) ) } Spacer(modifier = Modifier.width(12.dp)) Column(modifier = Modifier.weight(1f)) { Text( text = label, style = MaterialTheme.typography.labelSmall.copy( color = LightTextMuted, fontSize = 11.sp ) ) Spacer(modifier = Modifier.height(2.dp)) Text( text = value, style = MaterialTheme.typography.bodyMedium.copy( fontWeight = FontWeight.SemiBold, color = MaterialTheme.colorScheme.onSurface ) ) } } } }