import SwiftUI

struct ContentView: View {
    @Environment(AuthManager.self) private var authManager

    var body: some View {
        Group {
            if authManager.isCheckingAuth {
                LoadingView(message: "Checking session...")
            } else if authManager.isAuthenticated {
                MainTabView()
            } else {
                LoginView()
            }
        }
        .task {
            await authManager.checkAuth()
        }
    }
}

struct MainTabView: View {
    var body: some View {
        TabView {
            HomeView()
                .tabItem {
                    Label("Home", systemImage: "house.fill")
                }

            FitnessTabView()
                .tabItem {
                    Label("Fitness", systemImage: "flame.fill")
                }
        }
        .tint(Color.accentWarm)
    }
}
