package com.tsmobile.app.ui.screens

import androidx.compose.foundation.background
import androidx.compose.foundation.layout.*
import androidx.compose.material.icons.Icons
import androidx.compose.material.icons.filled.PersonOff
import androidx.compose.material3.*
import androidx.compose.runtime.Composable
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.unit.dp
import com.tsmobile.app.ui.theme.UiTokens

/**
 * 被踢全屏提示。
 *
 * 对应 docs/UI架构设计.md 5.3 被踢处理：
 * "全屏覆盖提示，不可通过点击外部关闭"
 */
@Composable
fun KickedScreen(
    reason: String,
    onReconnect: () -> Unit,
    onBackToHome: () -> Unit
) {
    Box(
        modifier = Modifier
            .fillMaxSize()
            .background(MaterialTheme.colorScheme.errorContainer)
            .systemBarsPadding(),
        contentAlignment = Alignment.Center
    ) {
        Surface(
            modifier = Modifier.padding(UiTokens.Spacing.ExtraLarge),
            shape = MaterialTheme.shapes.extraLarge,
            color = MaterialTheme.colorScheme.surface,
            tonalElevation = UiTokens.Elevation.Raised,
        ) {
            Column(
                modifier = Modifier.padding(UiTokens.Spacing.Huge),
                horizontalAlignment = Alignment.CenterHorizontally,
            ) {
            Icon(
                imageVector = Icons.Default.PersonOff,
                contentDescription = null,
                modifier = Modifier.size(64.dp),
                tint = MaterialTheme.colorScheme.error
            )

            Spacer(Modifier.height(24.dp))

            Text(
                text = "你已被踢出",
                style = MaterialTheme.typography.headlineMedium,
                color = MaterialTheme.colorScheme.onSurface
            )

            Spacer(Modifier.height(12.dp))

            if (reason.isNotEmpty()) {
                Text(
                    text = "原因：$reason",
                    style = MaterialTheme.typography.bodyLarge,
                    color = MaterialTheme.colorScheme.onSurfaceVariant
                )
            } else {
                Text(
                    text = "你已被服务器管理员踢出",
                    style = MaterialTheme.typography.bodyLarge,
                    color = MaterialTheme.colorScheme.onSurfaceVariant
                )
            }

            Spacer(Modifier.height(32.dp))

            Button(
                onClick = onReconnect,
                modifier = Modifier.fillMaxWidth()
            ) {
                Text("重新连接")
            }

            Spacer(Modifier.height(12.dp))

            OutlinedButton(
                onClick = onBackToHome,
                modifier = Modifier.fillMaxWidth()
            ) {
                Text("返回主页")
            }
            }
        }
    }
}
