import SwiftUI

struct AppearanceSettingsView: View {
    @ObservedObject private var settingsController = AppSettingsController.shared

    var body: some View {
        Form {
            Section("Shadow") {
                Toggle("Enable shadow", isOn: settingsController.binding(\.appearance.enableShadow))
                if settingsController.settings.appearance.enableShadow {
                    HStack {
                        Text("Radius")
                        Slider(value: settingsController.binding(\.appearance.shadowRadius), in: 0...30, step: 1)
                        Text(String(format: "%.0f", settingsController.settings.appearance.shadowRadius))
                            .monospacedDigit()
                            .frame(width: 40)
                    }
                    HStack {
                        Text("Opacity")
                        Slider(value: settingsController.binding(\.appearance.shadowOpacity), in: 0...1, step: 0.05)
                        Text(String(format: "%.2f", settingsController.settings.appearance.shadowOpacity))
                            .monospacedDigit()
                            .frame(width: 50)
                    }
                }
            }

            Section("Shape") {
                Toggle("Scale corner radii when open", isOn: settingsController.binding(\.appearance.cornerRadiusScaling))
            }

            Section("Opacity & Blur") {
                HStack {
                    Text("Notch opacity")
                    Slider(value: settingsController.binding(\.appearance.notchOpacity), in: 0...1, step: 0.05)
                    Text(String(format: "%.2f", settingsController.settings.appearance.notchOpacity))
                        .monospacedDigit()
                        .frame(width: 50)
                }
                HStack {
                    Text("Blur radius")
                    Slider(value: settingsController.binding(\.appearance.blurRadius), in: 0...20, step: 0.5)
                    Text(String(format: "%.1f", settingsController.settings.appearance.blurRadius))
                        .monospacedDigit()
                        .frame(width: 50)
                }
            }
        }
        .formStyle(.grouped)
    }
}
