//
//  CozyIconButton.swift
//  lichunWebsocket
//
//  Icon button with soft cozy background
//

import SwiftUI

struct CozyIconButton: View {
    let icon: String
    var color: Color = AppColors.primary
    var size: CGFloat = 44
    let action: () -> Void

    var body: some View {
        Button(action: {
            hapticFeedback(style: .light)
            action()
        }) {
            Image(systemName: icon)
                .font(.system(size: size * 0.45, weight: .semibold))
                .foregroundColor(.white)
                .frame(width: size, height: size)
                .background(
                    Circle()
                        .fill(
                            LinearGradient(
                                colors: [color, color.darker(by: 0.1)],
                                startPoint: .topLeading,
                                endPoint: .bottomTrailing
                            )
                        )
                )
                .shadow(color: color.opacity(0.4), radius: 6, x: 0, y: 3)
        }
        .buttonStyle(SquishButtonStyle())
    }
}

// MARK: - Preview
#if DEBUG
struct CozyIconButton_Previews: PreviewProvider {
    static var previews: some View {
        HStack(spacing: 20) {
            CozyIconButton(icon: "heart.fill", color: AppColors.primary) {}
            CozyIconButton(icon: "xmark", color: AppColors.error, size: 60) {}
            CozyIconButton(icon: "message.fill", color: AppColors.accent) {}
        }
        .padding()
        .background(AppColors.background)
    }
}
#endif
