import { Stack } from 'expo-router'
import { View } from 'react-native'
import { StatusBar } from 'expo-status-bar'
import { ThemeProvider, useTheme } from '../constants/ThemeContext'

/*
 * ITMS 루트 레이아웃 — ThemeProvider + 스택.
 * 스플래시는 이미지 자산 없이 BrandSplash(순수 View)로 대체(index 게이트에서 표시).
 */
function ItmsStack() {
  const { t, resolved } = useTheme()
  return (
    <View style={{ flex: 1, backgroundColor: t.bg }}>
      <StatusBar style={resolved === 'dark' ? 'light' : 'dark'} />
      <Stack
        screenOptions={{
          headerStyle: { backgroundColor: t.bg },
          headerTintColor: t.text,
          headerTitleStyle: { fontWeight: '800', fontSize: 16 },
          contentStyle: { backgroundColor: t.bg },
          headerShadowVisible: false,
        }}
      >
        <Stack.Screen name="index" options={{ headerShown: false }} />
        <Stack.Screen name="(auth)/login" options={{ headerShown: false }} />
        <Stack.Screen name="(tabs)" options={{ headerShown: false }} />
        <Stack.Screen name="request-detail" options={{ title: '요청 상세' }} />
        <Stack.Screen name="request-new" options={{ title: '서비스 요청 등록' }} />
        <Stack.Screen name="incident-detail" options={{ title: '인시던트 상세' }} />
        <Stack.Screen name="notice-detail" options={{ title: '공지 상세' }} />
        <Stack.Screen name="assets" options={{ title: '자산 조회' }} />
        <Stack.Screen name="asset-detail" options={{ title: '자산 상세' }} />
      </Stack>
    </View>
  )
}

export default function RootLayout() {
  return (
    <ThemeProvider>
      <ItmsStack />
    </ThemeProvider>
  )
}
