package id.ac.ubharajaya.panicbutton

import androidx.compose.foundation.Image
import androidx.compose.foundation.clickable
import androidx.compose.foundation.layout.*
import androidx.compose.foundation.shape.RoundedCornerShape
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.res.painterResource
import androidx.compose.ui.unit.dp
import androidx.compose.ui.unit.sp
import androidx.navigation.NavController

@Composable
fun EvacuationMapsScreen(navController: NavController, onBack: () -> Unit) {
    Column(modifier = Modifier.fillMaxSize().padding(16.dp)) {
        Text(text = "Peta Jalur Evakuasi", style = MaterialTheme.typography.titleLarge, modifier = Modifier.padding(bottom = 12.dp))

        // Card 1 - Selatan
        Card(modifier = Modifier.fillMaxWidth().padding(bottom = 12.dp).clickable { navController.navigate("evac_map/selatan") }, shape = RoundedCornerShape(12.dp), elevation = CardDefaults.cardElevation(defaultElevation = 6.dp)) {
            Row(verticalAlignment = Alignment.CenterVertically, modifier = Modifier.padding(12.dp)) {
                Image(painter = painterResource(id = R.drawable.lantai_1_selatan), contentDescription = "Selatan", modifier = Modifier.size(120.dp))
                Spacer(modifier = Modifier.width(12.dp))
                Column {
                    Text(text = "Jalur Evakuasi Selatan", fontSize = 18.sp)
                    Spacer(modifier = Modifier.height(6.dp))
                    Text(text = "Lihat detail jalur evakuasi lantai selatan.")
                }
            }
        }

        // Card 2 - Utara
        Card(modifier = Modifier.fillMaxWidth().padding(bottom = 12.dp).clickable { navController.navigate("evac_map/utara") }, shape = RoundedCornerShape(12.dp), elevation = CardDefaults.cardElevation(defaultElevation = 6.dp)) {
            Row(verticalAlignment = Alignment.CenterVertically, modifier = Modifier.padding(12.dp)) {
                Image(painter = painterResource(id = R.drawable.lantai_1_utara), contentDescription = "Utara", modifier = Modifier.size(120.dp))
                Spacer(modifier = Modifier.width(12.dp))
                Column {
                    Text(text = "Jalur Evakuasi Utara", fontSize = 18.sp)
                    Spacer(modifier = Modifier.height(6.dp))
                    Text(text = "Lihat detail jalur evakuasi lantai utara.")
                }
            }
        }
    }
}

@Composable
fun EvacuationMapDetailScreen(drawableResId: Int, onBack: () -> Unit) {
    Column(modifier = Modifier.fillMaxSize().padding(12.dp)) {
        Text(text = "Detail Peta", style = MaterialTheme.typography.titleLarge, modifier = Modifier.padding(bottom = 12.dp))
        Image(painter = painterResource(id = drawableResId), contentDescription = "Map Detail", modifier = Modifier.fillMaxWidth().heightIn(max = 600.dp))
    }
}
