package com.aiosman.ravenow.ui.index.tabs.profile

import android.content.Context
import android.content.Intent
import android.net.Uri
import android.util.Log
import androidx.compose.foundation.ExperimentalFoundationApi
import androidx.compose.foundation.Image
import androidx.compose.foundation.background
import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.Row
import androidx.compose.foundation.layout.Spacer
import androidx.compose.foundation.layout.WindowInsets
import androidx.compose.foundation.layout.asPaddingValues
import androidx.compose.foundation.layout.aspectRatio
import androidx.compose.foundation.layout.fillMaxSize
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.layout.systemBars
import androidx.compose.foundation.layout.width
import androidx.compose.foundation.lazy.grid.GridCells
import androidx.compose.foundation.lazy.grid.LazyVerticalGrid
import androidx.compose.foundation.lazy.grid.rememberLazyGridState
import androidx.compose.foundation.lazy.rememberLazyListState
import androidx.compose.foundation.pager.HorizontalPager
import androidx.compose.foundation.pager.rememberPagerState
import androidx.compose.foundation.shape.CircleShape
import androidx.compose.foundation.shape.RoundedCornerShape
import androidx.compose.foundation.verticalScroll
import androidx.compose.material.ExperimentalMaterialApi
import androidx.compose.material.Text
import androidx.compose.material.pullrefresh.PullRefreshIndicator
import androidx.compose.material.pullrefresh.pullRefresh
import androidx.compose.material.pullrefresh.rememberPullRefreshState
import androidx.compose.material3.ExperimentalMaterial3Api
import androidx.compose.material3.Icon
import androidx.compose.material3.ModalBottomSheet
import androidx.compose.material3.rememberModalBottomSheetState
import androidx.compose.runtime.Composable
import androidx.compose.runtime.LaunchedEffect
import androidx.compose.runtime.derivedStateOf
import androidx.compose.runtime.getValue
import androidx.compose.runtime.mutableStateOf
import androidx.compose.runtime.remember
import androidx.compose.runtime.rememberCoroutineScope
import androidx.compose.runtime.setValue
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.draw.clip
import androidx.compose.ui.draw.drawWithContent
import androidx.compose.ui.draw.shadow
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.graphics.ColorFilter
import androidx.compose.ui.graphics.graphicsLayer
import androidx.compose.ui.graphics.nativeCanvas
import androidx.compose.ui.layout.ContentScale
import androidx.compose.ui.layout.onGloballyPositioned
import androidx.compose.ui.platform.LocalContext
import androidx.compose.ui.platform.LocalDensity
import androidx.compose.ui.res.painterResource
import androidx.compose.ui.text.font.FontWeight
import androidx.compose.ui.text.style.TextOverflow
import androidx.compose.ui.unit.dp
import androidx.compose.ui.unit.sp
import com.aiosman.ravenow.AppState
import com.aiosman.ravenow.ConstVars
import com.aiosman.ravenow.GuestLoginCheckOut
import com.aiosman.ravenow.GuestLoginCheckOutScene
import com.aiosman.ravenow.LocalAppTheme
import com.aiosman.ravenow.LocalNavController
import com.aiosman.ravenow.MainActivity
import com.aiosman.ravenow.R
import com.aiosman.ravenow.entity.AccountProfileEntity
import com.aiosman.ravenow.entity.AgentEntity
import com.aiosman.ravenow.entity.MomentEntity
import com.aiosman.ravenow.ui.NavigationRoute
import com.aiosman.ravenow.ui.composables.CustomAsyncImage
import com.aiosman.ravenow.ui.composables.StatusBarSpacer
import com.aiosman.ravenow.ui.composables.pickupAndCompressLauncher
import com.aiosman.ravenow.ui.composables.toolbar.CollapsingToolbarScaffold
import com.aiosman.ravenow.ui.composables.toolbar.ScrollStrategy
import com.aiosman.ravenow.ui.composables.toolbar.rememberCollapsingToolbarScaffoldState
import com.aiosman.ravenow.ui.index.IndexViewModel
import com.aiosman.ravenow.ui.index.tabs.profile.composable.GalleryGrid
import com.aiosman.ravenow.ui.post.MenuActionItem
import com.aiosman.ravenow.ui.index.tabs.profile.composable.OtherProfileAction
import com.aiosman.ravenow.ui.index.tabs.profile.composable.SelfProfileAction
import com.aiosman.ravenow.ui.index.tabs.profile.composable.UserAgentsList
import com.aiosman.ravenow.ui.index.tabs.profile.composable.UserAgentsRow
import com.aiosman.ravenow.ui.index.tabs.profile.composable.UserContentPageIndicator
import com.aiosman.ravenow.ui.index.tabs.profile.composable.UserItem
import com.aiosman.ravenow.ui.modifiers.noRippleClickable
import com.aiosman.ravenow.ui.navigateToPost
import com.google.accompanist.systemuicontroller.rememberSystemUiController
import kotlinx.coroutines.delay
import kotlinx.coroutines.launch
import java.io.File

@OptIn(ExperimentalFoundationApi::class, ExperimentalMaterialApi::class, ExperimentalMaterial3Api::class)
@Composable
fun ProfileV3(
    onUpdateBanner: ((Uri, File, Context) -> Unit)? = null,
    profile: AccountProfileEntity? = null,
    onLogout: () -> Unit = {},
    onFollowClick: () -> Unit = {},
    onChatClick: () -> Unit = {},
    moments: List<MomentEntity>,
    agents: List<AgentEntity> = emptyList(),
    isSelf: Boolean = true,
    isMain:Boolean = false,
    isAiAccount: Boolean = false, // 新增参数判断是否为AI账户
    onLoadMore: () -> Unit = {},
    onLike: (MomentEntity) -> Unit = {},
    onComment: (MomentEntity) -> Unit = {},
    onAgentClick: (AgentEntity) -> Unit = {},
    postCount: Int? = null, // 新增参数用于传递帖子总数
) {
    val model = MyProfileViewModel
    val state = rememberCollapsingToolbarScaffoldState()
    val pagerState = rememberPagerState(pageCount = { if (isAiAccount) 1 else 2 })
    val enabled by remember { mutableStateOf(true) }
    val statusBarPaddingValues = WindowInsets.systemBars.asPaddingValues()
    var expanded by remember { mutableStateOf(false) }
    var minibarExpanded by remember { mutableStateOf(false) }
    var showAgentMenu by remember { mutableStateOf(false) }
    var contextAgent by remember { mutableStateOf<AgentEntity?>(null) }
    var showDeleteConfirmDialog by remember { mutableStateOf(false) }
    val context = LocalContext.current
    val scope = rememberCoroutineScope()
    val navController = LocalNavController.current
    val bannerHeight = 400
    val pickBannerImageLauncher = pickupAndCompressLauncher(
        context,
        scope,
        maxSize = ConstVars.BANNER_IMAGE_MAX_SIZE,
        quality = 100
    ) { uri, file ->
        onUpdateBanner?.invoke(uri, file, context)
    }
    val refreshState = rememberPullRefreshState(model.refreshing, onRefresh = {
        model.loadProfile(pullRefresh = true)
    })
    val agentMenuModalState = rememberModalBottomSheetState(skipPartiallyExpanded = true)
    var miniToolbarHeight by remember { mutableStateOf(0) }
    val density = LocalDensity.current
    val appTheme = LocalAppTheme.current
    val AppColors = appTheme
    val systemUiController = rememberSystemUiController()
    val listState = rememberLazyListState()
    val gridState = rememberLazyGridState()

    // observe list scrolling
    val reachedListBottom by remember {
        derivedStateOf {
            val lastVisibleItem = listState.layoutInfo.visibleItemsInfo.lastOrNull()
            lastVisibleItem?.index != 0 && lastVisibleItem?.index == listState.layoutInfo.totalItemsCount - 2
        }
    }

    // observe grid scrolling for load more
    val reachedGridBottom by remember {
        derivedStateOf {
            val layoutInfo = gridState.layoutInfo
            val lastVisibleItem = layoutInfo.visibleItemsInfo.lastOrNull()
            val totalItems = layoutInfo.totalItemsCount
            val visibleItemsCount = layoutInfo.visibleItemsInfo.size
            
            Log.d("ProfileV3", "滚动状态检查 - totalItems: $totalItems, visibleItems: $visibleItemsCount, lastVisibleIndex: ${lastVisibleItem?.index}, moments.size: ${moments.size}, hasNext: ${model.momentLoader.hasNext}")
            
            // 如果没有可见item，不触发加载
            if (lastVisibleItem == null || totalItems == 0) {
                Log.d("ProfileV3", "跳过加载 - 没有可见item或总数为0")
                false
            } else {
                // 检查是否滚动到最后几个item（考虑到有Spacer item）
                // 当接近底部时提前触发加载
                val triggerIndex = maxOf(0, totalItems - 2)
                val result = lastVisibleItem.index >= triggerIndex && model.momentLoader.hasNext
                Log.d("ProfileV3", "滚动检测结果 - lastVisibleIndex: ${lastVisibleItem.index}, triggerIndex: $triggerIndex, hasNext: ${model.momentLoader.hasNext}, shouldTrigger: $result")
                result
            }
        }
    }

    // load more if scrolled to bottom of list
    LaunchedEffect(reachedListBottom) {
        if (reachedListBottom) {
            onLoadMore()
        }
    }

    // load more if scrolled to bottom of grid
    LaunchedEffect(reachedGridBottom) {
        Log.d("ProfileV3", "LaunchedEffect触发 - reachedGridBottom: $reachedGridBottom")
        if (reachedGridBottom) {
            Log.d("ProfileV3", "检测到网格滚动到底部，触发加载更多")
            onLoadMore()
        }
    }



    fun switchTheme() {
        // delay
        scope.launch {
            delay(200)
            AppState.switchTheme()
            systemUiController.setStatusBarColor(Color.Transparent, darkIcons = !AppState.darkMode)
            if (AppState.darkMode) {
                (context as MainActivity).window.decorView.setBackgroundColor(android.graphics.Color.BLACK)
            } else {
                (context as MainActivity).window.decorView.setBackgroundColor(android.graphics.Color.WHITE)
            }
        }

    }
    
    // Agent菜单弹窗
    if (showAgentMenu) {
        Log.d("ProfileV3", "Showing agent menu for: ${contextAgent?.title}")
        ModalBottomSheet(
            onDismissRequest = {
                showAgentMenu = false
            },
            containerColor = AppColors.background,
            sheetState = agentMenuModalState,
            dragHandle = {},
            shape = RoundedCornerShape(topStart = 16.dp, topEnd = 16.dp),
            windowInsets = WindowInsets(0)
        ) {
            AgentMenuModal(
                agent = contextAgent,
                onDeleteClick = {
                    scope.launch {
                        agentMenuModalState.hide()
                        showAgentMenu = false
                        showDeleteConfirmDialog = true
                    }
                },
                onCloseClick = {
                    scope.launch {
                        agentMenuModalState.hide()
                        showAgentMenu = false
                    }
                },
                isSelf = isSelf
            )
        }
    }
    
    // 删除确认对话框
    if (showDeleteConfirmDialog) {
        DeleteConfirmDialog(
            agentName = contextAgent?.title ?: "",
            onConfirm = {
                // TODO: 实现删除逻辑
                contextAgent?.let { agent ->
                    // 调用删除API
                    scope.launch {
                        try {
                            // 这里应该调用删除智能体的API
                            // agentService.deleteAgent(agent.id)
                        } catch (e: Exception) {
                            e.printStackTrace()
                        }
                    }
                }
                showDeleteConfirmDialog = false
                contextAgent = null
            },
            onDismiss = {
                showDeleteConfirmDialog = false
                contextAgent = null
            }
        )
    }
    
    Box(
        modifier = Modifier.pullRefresh(refreshState)
    ) {
        CollapsingToolbarScaffold(
            modifier = Modifier
                .fillMaxSize()
                .background(AppColors.profileBackground),
            state = state,
            scrollStrategy = ScrollStrategy.ExitUntilCollapsed,
            toolbarScrollable = true,
            enabled = enabled,
            toolbar = { toolbarScrollState ->
                Column(
                    modifier = Modifier
                        .fillMaxWidth()
                        .height(miniToolbarHeight.dp)
                        // 保持在最低高度和当前高度之间
                        .background(AppColors.profileBackground)
                ) {
                }
                // header
                Box(
                    modifier = Modifier
                        .parallax(0.5f)
                        .fillMaxWidth()
                        .height(if (isAiAccount) 600.dp else 700.dp)
                        .background(AppColors.profileBackground)
                        .verticalScroll(toolbarScrollState)
                ) {
                    Box(
                        modifier = Modifier.fillMaxSize()
                    ) {
                        Column(
                            modifier = Modifier
                                .fillMaxWidth()
                                .graphicsLayer {
                                    alpha = state.toolbarState.progress
                                }
                        ) {
                            // banner
                            Box(
                                modifier = Modifier
                                    .fillMaxWidth()
                                    .height(bannerHeight.dp)
                                    .background(AppColors.profileBackground)
                            ) {
                                Box(
                                    modifier = Modifier
                                        .fillMaxWidth()
                                        .height(bannerHeight.dp - 24.dp)
                                        .let {
                                            if (isSelf&&isMain) {
                                                it.noRippleClickable {
                                                    Intent(Intent.ACTION_PICK).apply {
                                                        type = "image/*"
                                                        pickBannerImageLauncher.launch(
                                                            this
                                                        )
                                                    }
                                                }
                                            } else {
                                                it
                                            }
                                        }
                                        .shadow(
                                            elevation = 6.dp,
                                            shape = RoundedCornerShape(
                                                bottomStart = 32.dp,
                                                bottomEnd = 32.dp
                                            ),
                                        )
                                ) {
                                    val banner = profile?.banner

                                    if (banner != null) {
                                        CustomAsyncImage(
                                            LocalContext.current,
                                            banner,
                                            modifier = Modifier
                                                .fillMaxSize(),
                                            contentDescription = "",
                                            contentScale = ContentScale.Crop
                                        )
                                    } else {
                                        Image(
                                            painter = painterResource(id = R.drawable.rave_now_profile_backgrount_demo_1),
                                            modifier = Modifier
                                                .fillMaxSize(),
                                            contentDescription = "",
                                            contentScale = ContentScale.Crop
                                        )
                                    }
                                }

                            }
                            Box(
                                modifier = Modifier
                                    .fillMaxWidth()
                                    .background(AppColors.profileBackground)
                            ) {
                                // user info
                                Column(
                                    modifier = Modifier
                                        .fillMaxWidth()

                                ) {
//                                    Spacer(modifier = Modifier.height(16.dp))
                                    // 个人信息
                                    Box(
                                        modifier = Modifier.padding(horizontal = 16.dp)
                                    ) {
                                        profile?.let {
                                            UserItem(
                                                accountProfileEntity = it,
                                                postCount = postCount ?: if (isSelf) MyProfileViewModel.momentLoader.total else moments.size
                                            )
                                        }
                                    }
                                    Spacer(modifier = Modifier.height(20.dp))
                                    profile?.let {
                                        Box(
                                            modifier = Modifier.padding(horizontal = 16.dp)
                                        ) {
                                            if (isSelf) {
                                                SelfProfileAction(
                                                    onEditProfile = {
                                                        navController.navigate(
                                                            NavigationRoute.AccountEdit.route
                                                        )
                                                    },
                                                    onPremiumClick = {
                                                        navController.navigate(NavigationRoute.VipSelPage.route)
                                                    }
                                                )
                                            } else {
                                                if (it.id != AppState.UserId) {
                                                    OtherProfileAction(
                                                        it,
                                                        onFollow = {
                                                            onFollowClick()
                                                        },
                                                        onChat = {
                                                            onChatClick()
                                                        }
                                                    )
                                                }

                                            }

                                        }
                                    }

                                    // 添加用户智能体行（智能体用户不显示）
                                    if (!isAiAccount) {
                                        UserAgentsRow(
                                            userId = if (isSelf) null else profile?.id,
                                            modifier = Modifier.padding(top = 16.dp),
                                            onMoreClick = {
                                                // 导航到智能体列表页面
                                                // TODO: 实现导航逻辑
                                            },
                                            onAgentClick = { agent ->
                                                // 导航到智能体详情页面
                                                // TODO: 实现导航逻辑
                                            },
                                            onAvatarClick = { agent ->
                                                // 导航到智能体个人主页
                                                scope.launch {
                                                    try {
                                                        val userService = com.aiosman.ravenow.data.UserServiceImpl()
                                                        val profile = userService.getUserProfileByOpenId(agent.openId)
                                                        navController.navigate(
                                                            NavigationRoute.AccountProfile.route
                                                                .replace("{id}", profile.id.toString())
                                                                .replace("{isAiAccount}", "true")
                                                        )
                                                    } catch (e: Exception) {
                                                        // 处理错误
                                                    }
                                                }
                                            },
                                            onAgentLongClick = { agent ->
                                                Log.d("ProfileV3", "onAgentLongClick called for agent: ${agent.title}, isSelf: $isSelf")
                                                if (isSelf) { // 只有自己的智能体才能长按
                                                    Log.d("ProfileV3", "Setting contextAgent and showing menu")
                                                    contextAgent = agent
                                                    showAgentMenu = true
                                                }
                                            }
                                        )
                                    }
                                }

                            }

                        }
                    }


                }
                Box(modifier = Modifier.fillMaxWidth()) {
                    Column(
                        modifier = Modifier
                            .fillMaxWidth()
                            .graphicsLayer {
                                alpha = 1 - state.toolbarState.progress
                            }
                            .background(AppColors.profileBackground)
                            .onGloballyPositioned {
                                miniToolbarHeight = with(density) {
                                    it.size.height.toDp().value.toInt()
                                }
                            }
                    ) {
                        StatusBarSpacer()
                        Row(
                            modifier = Modifier.padding(
                                horizontal = 16.dp,
                                vertical = 8.dp,
                            ).noRippleClickable {

                            },

                            verticalAlignment = Alignment.CenterVertically
                        ) {
                            if (!isMain) {
                                Image(
                                    painter = painterResource(id = R.drawable.rider_pro_back_icon), // Replace with your image resource
                                    contentDescription = "Back",
                                    modifier = Modifier
                                        .noRippleClickable {
                                            navController.navigateUp()
                                        }
                                        .size(24.dp),
                                    colorFilter = ColorFilter.tint(AppColors.text)
                                )
                                Spacer(modifier = Modifier.width(8.dp))
                                CustomAsyncImage(
                                    LocalContext.current,
                                    profile?.avatar,
                                    modifier = Modifier
                                        .size(32.dp)
                                        .clip(CircleShape),
                                    contentDescription = "",
                                    contentScale = ContentScale.Crop
                                )
                                Spacer(modifier = Modifier.width(16.dp))
                                Text(
                                    text = profile?.nickName ?: "",
                                    fontSize = 16.sp,
                                    fontWeight = FontWeight.W600,
                                    color = AppColors.text
                                )

                            }
                            Spacer(modifier = Modifier.weight(1f))
                            if (isSelf&&isMain) {
                                Box(
                                    modifier = Modifier
                                        .size(24.dp)
                                        .padding(16.dp)
                                )
                            }
                        }

                        Spacer(modifier = Modifier.height(8.dp))
                    }
                    if (isSelf&&isMain) {
                        Box(
                            modifier = Modifier
                                .align(Alignment.TopEnd)
                                .padding(
                                    top = 32.dp ,
                                    end = 16.dp
                                )
                                .noRippleClickable {
                                IndexViewModel.openDrawer = true
                            }
                        ) {
                            Box(
                                modifier = Modifier
                                    .padding(16.dp)

                            ) {
                                Icon(
                                    painter = painterResource(id = R.drawable.rider_pro_more_horizon),
                                    contentDescription = "",
                                    tint = AppColors.text
                                )
                            }

                        }
                    }
                }
            }
        ) {
            Column(
                modifier = Modifier
                    .fillMaxSize()
                    .background(AppColors.profileBackground)
            ) {
                UserContentPageIndicator(
                    pagerState = pagerState,
                    showAgentTab = !isAiAccount
                )
                Spacer(modifier = Modifier.height(8.dp))
                HorizontalPager(
                    state = pagerState,
                ) { idx ->
                    when (idx) {
                        0 ->
                            GalleryGrid(moments = moments)
                        1 ->
                            UserAgentsList(
                                agents = agents,
                                onAgentClick = onAgentClick,
                                onAvatarClick = { agent ->
                                    // 导航到智能体个人主页，需要通过openId获取用户ID
                                    scope.launch {
                                        try {
                                            val userService = com.aiosman.ravenow.data.UserServiceImpl()
                                            val profile = userService.getUserProfileByOpenId(agent.openId)
                                            navController.navigate(
                                                NavigationRoute.AccountProfile.route
                                                    .replace("{id}", profile.id.toString())
                                                    .replace("{isAiAccount}", "true")
                                            )
                                        } catch (e: Exception) {
                                            // 处理错误
                                        }
                                    }
                                },
                                modifier = Modifier.fillMaxSize()
                            )
                    }
                }
            }

        }
        PullRefreshIndicator(
            model.refreshing,
            refreshState,
            Modifier.align(Alignment.TopCenter)
        )
    }

}

/**
 * Agent菜单弹窗
 */
@Composable
fun AgentMenuModal(
    agent: AgentEntity?,
    onDeleteClick: () -> Unit = {},
    onCloseClick: () -> Unit = {},
    isSelf: Boolean = true
) {
    val AppColors = LocalAppTheme.current
    
    Column(
        modifier = Modifier
            .fillMaxWidth()
            .background(AppColors.background)
            .padding(vertical = 24.dp, horizontal = 20.dp)
    ) {
        Text(
            "智能体",
            fontSize = 18.sp,
            fontWeight = FontWeight.Bold,
            color = AppColors.text
        )
        Spacer(modifier = Modifier.height(24.dp))
        
        agent?.let {
            Column(
                modifier = Modifier
                    .clip(RoundedCornerShape(8.dp))
                    .background(AppColors.nonActive)
                    .padding(8.dp)
            ) {
                Row(
                    verticalAlignment = Alignment.CenterVertically,
                ) {
                    Box(
                        modifier = Modifier
                            .size(24.dp)
                            .clip(CircleShape)
                    ) {
                        CustomAsyncImage(
                            context = LocalContext.current,
                            imageUrl = it.avatar,
                            modifier = Modifier.fillMaxSize(),
                            contentDescription = "Avatar",
                            defaultRes = R.mipmap.rider_pro_agent
                        )
                    }
                    Spacer(modifier = Modifier.width(8.dp))
                    Text(
                        it.title,
                        fontWeight = FontWeight.Bold,
                        fontSize = 16.sp,
                        color = AppColors.text
                    )
                }
                Spacer(modifier = Modifier.height(4.dp))
                Text(
                    it.desc.ifEmpty { "暂无描述" },
                    maxLines = 2,
                    modifier = Modifier
                        .fillMaxWidth()
                        .padding(start = 32.dp),
                    overflow = TextOverflow.Ellipsis,
                    color = AppColors.text,
                    fontSize = 14.sp
                )
            }
            Spacer(modifier = Modifier.height(32.dp))
        }

        Row(
            modifier = Modifier.fillMaxWidth(),
            verticalAlignment = Alignment.CenterVertically,
        ) {
            if (isSelf) {
                MenuActionItem(
                    icon = R.drawable.rider_pro_moment_delete,
                    text = "删除"
                ) {
                    onDeleteClick()
                }
                Spacer(modifier = Modifier.width(48.dp))
            }
            
            MenuActionItem(
                icon = R.drawable.rider_pro_more_horizon,
                text = "更多"
            ) {
                // TODO: 实现更多功能
                onCloseClick()
            }
        }
        Spacer(modifier = Modifier.height(48.dp))
    }
}



/**
 * 删除确认对话框
 */
@OptIn(ExperimentalMaterial3Api::class)
@Composable
fun DeleteConfirmDialog(
    agentName: String,
    onConfirm: () -> Unit,
    onDismiss: () -> Unit
) {
    val AppColors = LocalAppTheme.current
    
    androidx.compose.material3.AlertDialog(
        onDismissRequest = onDismiss,
        title = {
            Text(
                text = "确认删除",
                color = AppColors.text,
                fontSize = 18.sp,
                fontWeight = FontWeight.Bold
            )
        },
        text = {
            Text(
                text = "确定要删除智能体「$agentName」吗？删除后无法恢复。",
                color = AppColors.text,
                fontSize = 14.sp
            )
        },
        confirmButton = {
            androidx.compose.material3.TextButton(
                onClick = {
                    onConfirm()
                }
            ) {
                Text(
                    "删除",
                    color = AppColors.error,
                    fontWeight = FontWeight.Bold
                )
            }
        },
        dismissButton = {
            androidx.compose.material3.TextButton(
                onClick = onDismiss
            ) {
                Text(
                    "取消",
                    color = AppColors.text
                )
            }
        },
        containerColor = AppColors.background
    )
}
