//
//  SelfieCamTheme.swift
//  SelfieCam
//
//  Custom color theme for SelfieCam matching the app's branding.
//  Uses magenta/rose tinted surfaces with branded accent colors.
//

import SwiftUI
import Bedrock

// MARK: - SelfieCam Surface Colors

/// Surface colors with a subtle rose/magenta tint to match app branding.
/// Provides more visual separation than neutral grays.
public enum SelfieCamSurfaceColors: SurfaceColorProvider {
    /// Primary background - deep rose-tinted dark
    public static let primary = Color(red: 0.08, green: 0.06, blue: 0.10)
    
    /// Secondary/elevated surface - slightly lighter with rose tint
    public static let secondary = Color(red: 0.12, green: 0.08, blue: 0.14)
    
    /// Tertiary/card surface - more elevated
    public static let tertiary = Color(red: 0.16, green: 0.11, blue: 0.18)
    
    /// Overlay background (for sheets/modals) - deep with subtle rose
    public static let overlay = Color(red: 0.10, green: 0.07, blue: 0.12)
    
    /// Card/grouped element background - distinct from primary
    public static let card = Color(red: 0.14, green: 0.10, blue: 0.16)
    
    /// Subtle fill for grouped content sections
    public static let groupedFill = Color(red: 0.12, green: 0.09, blue: 0.14)
    
    /// Section fill for list sections - slightly more visible
    public static let sectionFill = Color(red: 0.16, green: 0.12, blue: 0.18)
}

// MARK: - SelfieCam Text Colors

/// Text colors optimized for rose-tinted dark backgrounds.
public enum SelfieCamTextColors: TextColorProvider {
    public static let primary = Color.white
    public static let secondary = Color.white.opacity(Design.Opacity.accent)
    public static let tertiary = Color.white.opacity(Design.Opacity.medium)
    public static let disabled = Color.white.opacity(Design.Opacity.light)
    public static let placeholder = Color.white.opacity(Design.Opacity.overlay)
    public static let inverse = Color.black
}

// MARK: - SelfieCam Accent Colors

/// Accent colors derived from the app's branding magenta/rose.
public enum SelfieCamAccentColors: AccentColorProvider {
    /// Primary accent - bright magenta/rose from branding
    public static let primary = Color(red: 0.85, green: 0.25, blue: 0.45)
    
    /// Light variant - softer pink
    public static let light = Color(red: 0.95, green: 0.45, blue: 0.60)
    
    /// Dark variant - deeper magenta
    public static let dark = Color(red: 0.65, green: 0.18, blue: 0.35)
    
    /// Secondary accent - soft cream/warm white for contrast
    public static let secondary = Color(red: 1.0, green: 0.95, blue: 0.90)
}

// MARK: - SelfieCam Button Colors

/// Button colors matching the branded theme.
public enum SelfieCamButtonColors: ButtonColorProvider {
    public static let primaryLight = Color(red: 0.95, green: 0.40, blue: 0.55)
    public static let primaryDark = Color(red: 0.75, green: 0.20, blue: 0.40)
    public static let secondary = Color.white.opacity(Design.Opacity.subtle)
    public static let destructive = Color.red.opacity(Design.Opacity.heavy)
    public static let cancelText = Color.white.opacity(Design.Opacity.strong)
}

// MARK: - SelfieCam Status Colors

/// Standard semantic status colors.
public enum SelfieCamStatusColors: StatusColorProvider {
    public static let success = Color(red: 0.2, green: 0.8, blue: 0.4)
    public static let warning = Color(red: 1.0, green: 0.75, blue: 0.2)
    public static let error = Color(red: 0.9, green: 0.3, blue: 0.3)
    public static let info = Color(red: 0.5, green: 0.7, blue: 0.95)
}

// MARK: - SelfieCam Border Colors

/// Border colors for the rose-tinted theme.
public enum SelfieCamBorderColors: BorderColorProvider {
    public static let subtle = Color.white.opacity(Design.Opacity.subtle)
    public static let standard = Color.white.opacity(Design.Opacity.hint)
    public static let emphasized = Color.white.opacity(Design.Opacity.light)
    public static let selected = SelfieCamAccentColors.primary.opacity(Design.Opacity.medium)
}

// MARK: - SelfieCam Interactive Colors

/// Interactive state colors for the theme.
public enum SelfieCamInteractiveColors: InteractiveColorProvider {
    public static let selected = SelfieCamAccentColors.primary.opacity(Design.Opacity.selection)
    public static let hover = Color.white.opacity(Design.Opacity.subtle)
    public static let pressed = Color.white.opacity(Design.Opacity.hint)
    public static let focus = SelfieCamAccentColors.light
}

// MARK: - SelfieCam Theme

/// The complete SelfieCam color theme.
///
/// Use this theme for consistent branded colors throughout the app:
/// ```swift
/// .background(SelfieCamTheme.Surface.primary)
/// .foregroundStyle(SelfieCamTheme.Accent.primary)
/// ```
public enum SelfieCamTheme: AppColorTheme {
    public typealias Surface = SelfieCamSurfaceColors
    public typealias Text = SelfieCamTextColors
    public typealias Accent = SelfieCamAccentColors
    public typealias Button = SelfieCamButtonColors
    public typealias Status = SelfieCamStatusColors
    public typealias Border = SelfieCamBorderColors
    public typealias Interactive = SelfieCamInteractiveColors
}

// MARK: - Convenience Typealiases

/// Short typealiases for cleaner usage throughout the app.
/// These avoid conflicts with Bedrock's default typealiases by using unique names.
///
/// Usage:
/// ```swift
/// .background(AppSurface.primary)
/// .foregroundStyle(AppAccent.primary)
/// ```
typealias AppSurface = SelfieCamSurfaceColors
typealias AppTextColors = SelfieCamTextColors
typealias AppAccent = SelfieCamAccentColors
typealias AppButtonColors = SelfieCamButtonColors
typealias AppStatus = SelfieCamStatusColors
typealias AppBorder = SelfieCamBorderColors
typealias AppInteractive = SelfieCamInteractiveColors
