import SwiftUI
import Bedrock

struct WidgetsView: View {
    @Environment(AppState.self) private var appState

    var body: some View {
        ZStack {
            LinearGradient(
                colors: [Color.AppBackground.base, Color.AppBackground.accent],
                startPoint: .topLeading,
                endPoint: .bottomTrailing
            )
            .ignoresSafeArea()

            ScrollView {
                VStack(spacing: Design.Spacing.large) {
                    WidgetsHeroCardView()

                    if let card = appState.cardStore.selectedCard {
                        WidgetPreviewCardView(card: card)
                    } else {
                        WidgetsEmptyStateCardView()
                    }
                }
                .padding(.horizontal, Design.Spacing.large)
                .padding(.vertical, Design.Spacing.xLarge)
            }
            .scrollIndicators(.hidden)
        }
        .navigationTitle(String.localized("Widgets"))
        .navigationBarTitleDisplayMode(.inline)
    }
}

#Preview {
    WidgetsView()
}
