import SwiftUI

struct WhatsNewFeature {
    let icon: String
    let color: Color
    let title: String
    let description: String
}

struct WhatsNewView: View {
    @Environment(\.dismiss) private var dismiss

    private let features: [WhatsNewFeature] = [
        WhatsNewFeature(
            icon: "bolt.circle.fill",
            color: .appPrimary,
            title: String(localized: "whats_new_quick_update_title"),
            description: String(localized: "whats_new_quick_update_body")
        ),
        WhatsNewFeature(
            icon: "flame.fill",
            color: .orange,
            title: String(localized: "whats_new_streak_title"),
            description: String(localized: "whats_new_streak_body")
        ),
        WhatsNewFeature(
            icon: "target",
            color: .appSecondary,
            title: String(localized: "whats_new_goals_title"),
            description: String(localized: "whats_new_goals_body")
        )
    ]

    var body: some View {
        ZStack {
            AppBackground()

            VStack(spacing: 0) {
                Spacer()

                VStack(spacing: 32) {
                    VStack(spacing: 8) {
                        Text("🎉")
                            .font(.system(size: 56))
                        Text(String(localized: "whats_new_title"))
                            .font(.title.weight(.bold))
                        Text(String(localized: "whats_new_subtitle"))
                            .font(.subheadline)
                            .foregroundColor(.secondary)
                            .multilineTextAlignment(.center)
                    }

                    VStack(spacing: 20) {
                        ForEach(features, id: \.title) { feature in
                            HStack(spacing: 16) {
                                Image(systemName: feature.icon)
                                    .font(.title2)
                                    .foregroundColor(feature.color)
                                    .frame(width: 40)
                                VStack(alignment: .leading, spacing: 2) {
                                    Text(feature.title)
                                        .font(.subheadline.weight(.semibold))
                                    Text(feature.description)
                                        .font(.caption)
                                        .foregroundColor(.secondary)
                                }
                                Spacer()
                            }
                        }
                    }
                    .padding()
                    .background(Color(.systemBackground))
                    .cornerRadius(16)
                    .shadow(color: .black.opacity(0.05), radius: 8, y: 2)
                }
                .padding()

                Spacer()

                Button {
                    dismiss()
                } label: {
                    Text(String(localized: "whats_new_continue"))
                        .font(.headline)
                        .foregroundColor(.white)
                        .frame(maxWidth: .infinity)
                        .padding()
                        .background(Color.appPrimary)
                        .cornerRadius(14)
                }
                .padding()
            }
        }
        .interactiveDismissDisabled()
    }
}
