//
//  OnboardingSettingsView.swift
//  SelfieCam
//
//  Basic settings personalization during onboarding.
//  Allows users to configure ring light and camera position preferences.
//  Supports landscape and iPad layouts with max width constraints.
//

import SwiftUI
import Bedrock

struct OnboardingSettingsView: View {
    @Bindable var viewModel: OnboardingViewModel
    
    var body: some View {
        OnboardingContentContainer {
            VStack(spacing: Design.Spacing.xLarge) {
                Spacer()
                
                // Header
                VStack(spacing: Design.Spacing.medium) {
                    SymbolIcon("slider.horizontal.3", size: .hero, color: AppAccent.primary)
                    
                    OnboardingSectionTitle(
                        title: String(localized: "Personalize Your Setup"),
                        subtitle: String(localized: "Set your preferences to get started quickly")
                    )
                }
                
                Spacer()
                
                // Settings cards using Bedrock components
                SettingsCard(backgroundColor: AppSurface.card, borderColor: AppBorder.subtle) {
                    // Ring Light Toggle
                    SettingsToggle(
                        title: String(localized: "Ring Light"),
                        subtitle: String(localized: "Adds flattering lighting around the camera preview"),
                        isOn: $viewModel.isRingLightEnabled,
                        accentColor: AppAccent.primary
                    )
                    
                    // Camera Position using Bedrock SettingsSegmentedPicker
                    SettingsSegmentedPicker(
                        title: String(localized: "Default Camera"),
                        subtitle: String(localized: "Choose which camera opens by default"),
                        options: [
                            (String(localized: "Front"), true),
                            (String(localized: "Back"), false)
                        ],
                        selection: $viewModel.prefersFrontCamera,
                        accentColor: AppAccent.primary
                    )
                }
                .padding(.horizontal, Design.Spacing.large)
                
                Spacer()
                
                // Continue button
                OnboardingPrimaryButton(
                    title: String(localized: "Continue"),
                    action: { viewModel.advanceToNextStep() }
                )
                .padding(.horizontal, Design.Spacing.xLarge)
                .padding(.bottom, Design.Spacing.xLarge)
            }
            .padding(.horizontal, Design.Spacing.medium)
        }
    }
}

// MARK: - Preview

#Preview {
    OnboardingSettingsView(viewModel: OnboardingViewModel())
        .background(AppSurface.primary)
        .preferredColorScheme(.dark)
}

#Preview("Landscape", traits: .landscapeLeft) {
    OnboardingSettingsView(viewModel: OnboardingViewModel())
        .background(AppSurface.primary)
        .preferredColorScheme(.dark)
}
