//
//  DesignConstants.swift
//  Blackjack
//
//  Centralized design constants for the Blackjack app.
//  Uses CasinoDesign from CasinoKit for shared values, with game-specific overrides.
//

import SwiftUI
import CasinoKit

// MARK: - Design Namespace

/// Design constants for the Blackjack app.
/// Shared constants are imported from CasinoDesign; game-specific values are defined here.
enum Design {
    // MARK: - Debug
    
    /// Set to true to show layout debug borders on views
    static let showDebugBorders = false
    
    // MARK: - Shared Constants (from CasinoKit)
    
    typealias Spacing = CasinoDesign.Spacing
    typealias CornerRadius = CasinoDesign.CornerRadius
    typealias LineWidth = CasinoDesign.LineWidth
    typealias Shadow = CasinoDesign.Shadow
    typealias Opacity = CasinoDesign.Opacity
    typealias Animation = CasinoDesign.Animation
    typealias Scale = CasinoDesign.Scale
    typealias MinScaleFactor = CasinoDesign.MinScaleFactor
    typealias BaseFontSize = CasinoDesign.BaseFontSize
    typealias IconSize = CasinoDesign.IconSize
    
    // MARK: - Blackjack-Specific Component Sizes
    
    enum Size {
        // Hand scaling factor (1.5 = 50% larger hands)
        static let handScale: CGFloat = 1.5
        
        // Cards - scaled for better visibility
        static let cardWidth: CGFloat = 60 * handScale  // 90pt at 1.5x
        static let cardWidthSmall: CGFloat = CasinoDesign.Size.cardWidthSmall
        static let cardOverlap: CGFloat = CasinoDesign.Size.cardOverlap * handScale  // Scaled overlap
        
        // Player hands container height (accommodates larger cards + labels)
        // Reduced from 180 to fit content more snugly
        static let playerHandsHeight: CGFloat = 160 * handScale  // 240pt at 1.5x
        
        // Hand label font sizes (scaled)
        static let handLabelFontSize: CGFloat = CasinoDesign.BaseFontSize.medium * handScale
        static let handNumberFontSize: CGFloat = CasinoDesign.BaseFontSize.medium * handScale  // Same as label
        static let handValueFontSize: CGFloat = CasinoDesign.BaseFontSize.xLarge * handScale
        
        // Hint font size (scaled to match hands)
        static let hintFontSize: CGFloat = CasinoDesign.BaseFontSize.small * handScale
        static let hintIconSize: CGFloat = CasinoDesign.IconSize.medium * handScale
        static let hintPaddingH: CGFloat = CasinoDesign.Spacing.medium * handScale
        static let hintPaddingV: CGFloat = CasinoDesign.Spacing.small * handScale
        
        // Hand icons (scaled)
        static let handIconSize: CGFloat = CasinoDesign.IconSize.medium * handScale
        
        // Hi-Lo count badge (scaled)
        static let countBadgeFontSize: CGFloat = CasinoDesign.BaseFontSize.xxSmall * handScale
        static let countBadgePaddingH: CGFloat = CasinoDesign.Spacing.xSmall * handScale
        static let countBadgePaddingV: CGFloat = CasinoDesign.Spacing.xxxSmall * handScale
        static let countBadgeOffset: CGFloat = CasinoDesign.Spacing.xSmall * handScale
        
        // Betting zone (chip scales, but zone height stays reasonable)
        static let bettingChipSize: CGFloat = 36 * handScale  // 54pt at 1.5x
        static let bettingZoneHeightScaled: CGFloat = CasinoDesign.Size.bettingZoneHeight  // Keep original height to save space
        
        // Card count display (scaled)
        static let cardCountLabelSize: CGFloat = CasinoDesign.BaseFontSize.xSmall * handScale
        static let cardCountValueSize: CGFloat = CasinoDesign.BaseFontSize.large * handScale
        
        // Chips - use CasinoDesign values
        static let chipBadgeSize: CGFloat = CasinoDesign.Size.chipBadge
        
        // Buttons - use CasinoDesign values
        static let actionButtonHeight: CGFloat = CasinoDesign.Size.actionButtonHeight
        static let actionButtonMinWidth: CGFloat = CasinoDesign.Size.actionButtonMinWidth
        static let bettingZoneHeight: CGFloat = CasinoDesign.Size.bettingZoneHeight
        
        // Responsive - use CasinoDesign values
        static let maxContentWidthPortrait: CGFloat = CasinoDesign.Size.maxContentWidthPortrait
        static let maxContentWidthLandscape: CGFloat = CasinoDesign.Size.maxContentWidthLandscape
        static let maxModalWidth: CGFloat = CasinoDesign.Size.maxModalWidth
        
        // Blackjack-specific
        static let tableHeight: CGFloat = 280
        
        // Settings - use CasinoDesign values
        static let checkmark: CGFloat = CasinoDesign.Size.checkmark
    }
}

// MARK: - Blackjack App Colors

extension Color {
    
    // MARK: - Table Colors (use CasinoTable from CasinoKit for consistency)
    
    /// Typealias for consistent table colors across all games.
    typealias Table = CasinoTable
    
    // MARK: - Betting Zone Colors
    
    enum BettingZone {
        static let main = Color(red: 0.2, green: 0.4, blue: 0.3)
        static let mainBorder = Color(red: 0.4, green: 0.6, blue: 0.4)
        static let insurance = Color(red: 0.5, green: 0.4, blue: 0.2)
        static let insuranceBorder = Color(red: 0.7, green: 0.6, blue: 0.3)
    }
    
    // MARK: - Hand Colors
    
    enum Hand {
        static let player = Color(red: 0.2, green: 0.5, blue: 0.8)
        static let dealer = Color(red: 0.8, green: 0.3, blue: 0.3)
        static let active = Color.yellow
        static let inactive = Color.white.opacity(CasinoDesign.Opacity.medium)
    }
    
    // MARK: - Result Colors
    
    enum Result {
        static let win = Color.green
        static let lose = Color.red
        static let push = Color.blue
        static let blackjack = Color.yellow
    }
    
    // MARK: - Action Button Colors
    
    enum Button {
        static let hit = Color(red: 0.2, green: 0.6, blue: 0.3)
        static let stand = Color(red: 0.6, green: 0.4, blue: 0.1)
        static let doubleDown = Color(red: 0.5, green: 0.3, blue: 0.6)
        static let split = Color(red: 0.3, green: 0.5, blue: 0.7)
        static let surrender = Color(red: 0.6, green: 0.3, blue: 0.3)
        static let insurance = Color(red: 0.7, green: 0.6, blue: 0.2)
        
        static let goldLight = Color(red: 1.0, green: 0.85, blue: 0.3)
        static let goldDark = Color(red: 0.9, green: 0.7, blue: 0.2)
    }
    
    // MARK: - Settings Colors
    
    enum Settings {
        static let background = Color(red: 0.08, green: 0.12, blue: 0.18)
        static let cardBackground = Color.white.opacity(CasinoDesign.Opacity.verySubtle)
        static let accent = Color(red: 0.9, green: 0.75, blue: 0.3)
    }
    
    // MARK: - Modal Colors
    
    enum Modal {
        static let background = Color(red: 0.12, green: 0.18, blue: 0.25)
        static let backgroundLight = Color(red: 0.15, green: 0.2, blue: 0.3)
        static let backgroundDark = Color(red: 0.1, green: 0.15, blue: 0.25)
    }
    
    // MARK: - TopBar Colors
    
    enum TopBar {
        static let balance = Color(red: 0.95, green: 0.85, blue: 0.4)
    }
}
