import SwiftUI

struct SettingsView: View {
    @Binding var theme: GameTheme
    @Binding var cardFaceStyle: CardFaceStyle
    @Binding var cardBackDesign: CardBackDesign
    @Binding var soundEnabled: Bool
    @Environment(\.dismiss) private var dismiss

    var body: some View {
        NavigationStack {
            Form {
                Section("Theme") {
                    ThemePickerView(selectedTheme: $theme)
                }

                Section("Card Style") {
                    Picker("Face Style", selection: $cardFaceStyle) {
                        ForEach(CardFaceStyle.allCases, id: \.self) { style in
                            Text(style.rawValue.capitalized).tag(style)
                        }
                    }
                    .pickerStyle(.segmented)
                }

                Section("Card Back") {
                    CardBackPickerView(selectedBack: $cardBackDesign)
                }

                Section("Sound") {
                    Toggle("Sound Effects", isOn: $soundEnabled)
                }
            }
            .navigationTitle("Settings")
            #if os(iOS)
            .navigationBarTitleDisplayMode(.inline)
            #endif
            .toolbar {
                ToolbarItem(placement: .confirmationAction) {
                    Button("Done") { dismiss() }
                }
            }
        }
    }
}
