import SwiftUI

struct ChatSuggestions: View {
    let suggestions: [String]
    let onSuggestionTap: (String) -> Void
    
    var body: some View {
        ScrollView(.horizontal, showsIndicators: false) {
            HStack(spacing: 8) {
                ForEach(suggestions, id: \.self) { suggestion in
                    SuggestionChip(
                        text: suggestion,
                        onTap: {
                            onSuggestionTap(suggestion)
                        }
                    )
                }
            }
            .padding(.top, 8)
            .padding(.horizontal, 16)
        }
    }
}

struct SuggestionChip: View {
    let text: String
    let onTap: () -> Void
    
    var body: some View {
        Button(action: onTap) {
            Text(text)
                .font(Constants.Typography.xSmallTitle)
                .kerning(0.24)
                .foregroundColor(Constants.Colors.Foreground.primary)
                .padding(.horizontal, 16)
                .padding(.vertical, 6)
                .background(
                    RoundedRectangle(cornerRadius: 100)
                        .fill(Constants.Colors.Background.Fog.thin)
                )
        }
        .frame(height: 32)
    }
}

#Preview {
    let sampleSuggestions = [
        "Create more",
        "Extend",
        "Speed up by 2x",
        "Slow down by 2x",
        "Make it more upbeat",
        "Add a bridge section"
    ]
    
    VStack(spacing: 20) {
        ChatSuggestions(
            suggestions: sampleSuggestions,
            onSuggestionTap: { suggestion in
                print("Tapped: \(suggestion)")
            }
        )
        
        // Example with fewer suggestions
        ChatSuggestions(
            suggestions: ["Create more", "Extend"],
            onSuggestionTap: { suggestion in
                print("Tapped: \(suggestion)")
            }
        )
    }
    .padding()
    .background(Constants.Colors.Background.primary)
}
