//
//  BusinessCardTheme.swift
//  BusinessCard
//
//  App-specific adaptive theme conforming to Bedrock's color protocols.
//  Uses warm light colors and deep slate dark colors.
//

import SwiftUI
import Bedrock

// MARK: - Surface Colors

/// Surface colors with warm off-white light tones and deep slate dark tones.
public enum BusinessCardSurfaceColors: SurfaceColorProvider {
    /// Primary background
    public static let primary = Color.AppBackground.base

    /// Secondary/elevated surface
    public static let secondary = Color.AppBackground.secondary

    /// Tertiary/card surface - most elevated
    public static let tertiary = Color.AppBackground.elevated

    /// Overlay background (for sheets/modals)
    public static let overlay = Color.AppBackground.base

    /// Card/grouped element background
    public static let card = Color.AppBackground.card

    /// Subtle fill for grouped content sections
    public static let groupedFill = Color.AppBackground.accent

    /// Section fill for list sections
    public static let sectionFill = Color.AppBackground.secondary
}

// MARK: - Text Colors

public enum BusinessCardTextColors: TextColorProvider {
    public static let primary = Color.AppText.primary
    public static let secondary = Color.AppText.secondary
    public static let tertiary = Color.AppText.tertiary
    public static let disabled = Color.AppText.tertiary.opacity(Design.Opacity.strong)
    public static let placeholder = Color.AppText.tertiary
    public static let inverse = Color.AppText.inverted
}

// MARK: - Accent Colors

public enum BusinessCardAccentColors: AccentColorProvider {
    /// Primary accent - warm red
    public static let primary = Color(red: 0.95, green: 0.33, blue: 0.28)
    
    /// Light variant
    public static let light = Color(red: 0.98, green: 0.50, blue: 0.45)
    
    /// Dark variant
    public static let dark = Color(red: 0.75, green: 0.25, blue: 0.22)
    
    /// Secondary accent - ink/dark
    public static let secondary = Color(red: 0.12, green: 0.12, blue: 0.14)
}

// MARK: - Button Colors

public enum BusinessCardButtonColors: ButtonColorProvider {
    public static let primaryLight = Color(red: 0.98, green: 0.45, blue: 0.40)
    public static let primaryDark = Color(red: 0.85, green: 0.28, blue: 0.24)
    public static let secondary = Color(red: 0.14, green: 0.14, blue: 0.17).opacity(Design.Opacity.subtle)
    public static let destructive = Color.red.opacity(Design.Opacity.heavy)
    public static let cancelText = Color(red: 0.32, green: 0.34, blue: 0.40)
}

// MARK: - Status Colors

public enum BusinessCardStatusColors: StatusColorProvider {
    public static let success = Color(red: 0.2, green: 0.75, blue: 0.4)
    public static let warning = Color(red: 0.95, green: 0.75, blue: 0.25)
    public static let error = Color(red: 0.9, green: 0.3, blue: 0.3)
    public static let info = Color(red: 0.3, green: 0.6, blue: 0.9)
}

// MARK: - Border Colors

public enum BusinessCardBorderColors: BorderColorProvider {
    public static let subtle = Color.AppText.tertiary.opacity(Design.Opacity.subtle)
    public static let standard = Color.AppText.tertiary.opacity(Design.Opacity.hint)
    public static let emphasized = Color.AppText.secondary.opacity(Design.Opacity.light)
    public static let selected = BusinessCardAccentColors.primary.opacity(Design.Opacity.medium)
}

// MARK: - Interactive Colors

public enum BusinessCardInteractiveColors: InteractiveColorProvider {
    public static let selected = BusinessCardAccentColors.primary.opacity(Design.Opacity.selection)
    public static let hover = Color(red: 0.14, green: 0.14, blue: 0.17).opacity(Design.Opacity.subtle)
    public static let pressed = Color(red: 0.14, green: 0.14, blue: 0.17).opacity(Design.Opacity.hint)
    public static let focus = BusinessCardAccentColors.light
}

// MARK: - Combined Theme

/// BusinessCard's complete color theme.
/// Note: We use the individual color provider typealiases (AppSurface, AppThemeAccent, etc.)
/// directly in views rather than going through the theme type.
///
/// This enum is not used directly but documents the theme structure.
/// The AppColorTheme conformance is omitted to avoid MainActor isolation conflicts.
public enum BusinessCardTheme {
    public typealias Surface = BusinessCardSurfaceColors
    public typealias Text = BusinessCardTextColors
    public typealias Accent = BusinessCardAccentColors
    public typealias Button = BusinessCardButtonColors
    public typealias Status = BusinessCardStatusColors
    public typealias Border = BusinessCardBorderColors
    public typealias Interactive = BusinessCardInteractiveColors
}

// 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(AppThemeAccent.primary)
/// ```
typealias AppSurface = BusinessCardSurfaceColors
typealias AppThemeText = BusinessCardTextColors
typealias AppThemeAccent = BusinessCardAccentColors
typealias AppButtonColors = BusinessCardButtonColors
typealias AppStatus = BusinessCardStatusColors
typealias AppBorder = BusinessCardBorderColors
typealias AppInteractive = BusinessCardInteractiveColors
