import SwiftUI
import Bedrock

struct RitualFocusCardView: View {
    private let title: String
    private let theme: String
    private let dayLabel: String
    private let completionSummary: String
    private let progress: Double
    private let iconName: String

    init(
        title: String,
        theme: String,
        dayLabel: String,
        completionSummary: String,
        progress: Double,
        iconName: String = "sparkles"
    ) {
        self.title = title
        self.theme = theme
        self.dayLabel = dayLabel
        self.completionSummary = completionSummary
        self.progress = progress
        self.iconName = iconName
    }

    var body: some View {
        VStack(alignment: .leading, spacing: Design.Spacing.medium) {
            HStack(spacing: Design.Spacing.medium) {
                Image(systemName: iconName)
                    .font(.title2)
                    .foregroundStyle(AppAccent.primary)
                    .accessibilityHidden(true)
                VStack(alignment: .leading, spacing: Design.Spacing.xxxSmall) {
                    Text(title)
                        .font(.title3)
                        .foregroundStyle(AppTextColors.primary)
                        .bold()
                    Text(theme)
                        .font(.subheadline)
                        .foregroundStyle(AppTextColors.secondary)
                }
                Spacer(minLength: Design.Spacing.medium)
                Text(dayLabel)
                    .font(.caption)
                    .foregroundStyle(AppTextColors.secondary)
                    .padding(.horizontal, Design.Spacing.small)
                    .padding(.vertical, Design.Spacing.xxxSmall)
                    .background(AppAccent.light.opacity(Design.Opacity.light))
                    .clipShape(.rect(cornerRadius: Design.CornerRadius.medium))
                    .accessibilityLabel(Text(dayLabel))
            }

            VStack(alignment: .leading, spacing: Design.Spacing.xSmall) {
                ProgressView(value: progress)
                    .tint(AppAccent.primary)
                Text(completionSummary)
                    .font(.caption)
                    .foregroundStyle(AppTextColors.secondary)
            }
        }
        .padding(Design.Spacing.large)
        .background(AppSurface.card)
        .clipShape(.rect(cornerRadius: Design.CornerRadius.large))
        .shadow(color: AppBorder.subtle.opacity(Design.Opacity.medium), radius: AppMetrics.Shadow.radiusSmall, x: AppMetrics.Shadow.xOffsetNone, y: AppMetrics.Shadow.yOffsetSmall)
        .accessibilityElement(children: .combine)
        .accessibilityLabel(Text(title))
    }
}
