import SwiftUI

enum BrandTheme {
    static let ink = Color(red: 0.071, green: 0.075, blue: 0.102)
    static let muted = Color(red: 0.357, green: 0.380, blue: 0.447)
    static let accent = Color(red: 0.231, green: 0.357, blue: 0.859)
    static let accentBright = Color(red: 0.659, green: 0.333, blue: 0.969)
    static let magenta = Color(red: 0.753, green: 0.149, blue: 0.827)
    static let surface = Color(red: 0.969, green: 0.973, blue: 0.988)
    static let surfaceElevated = Color.white

    static var pageBackground: LinearGradient {
        LinearGradient(
            colors: [
                Color(red: 0.910, green: 0.933, blue: 1.0),
                Color(red: 0.969, green: 0.973, blue: 0.988),
                Color(red: 0.957, green: 0.941, blue: 1.0),
            ],
            startPoint: .topLeading,
            endPoint: .bottomTrailing
        )
    }

    static var brandGradient: LinearGradient {
        LinearGradient(
            colors: [
                Color(red: 0.180, green: 0.290, blue: 0.820),
                accent,
                accentBright,
                magenta,
            ],
            startPoint: .leading,
            endPoint: .trailing
        )
    }
}

struct BrandCard<Content: View>: View {
    @ViewBuilder var content: Content

    var body: some View {
        content
            .padding(16)
            .frame(maxWidth: .infinity, alignment: .leading)
            .background(
                RoundedRectangle(cornerRadius: 20, style: .continuous)
                    .fill(BrandTheme.surfaceElevated)
                    .shadow(color: Color.black.opacity(0.06), radius: 12, y: 4)
            )
            .overlay(
                RoundedRectangle(cornerRadius: 20, style: .continuous)
                    .stroke(Color.black.opacity(0.06), lineWidth: 1)
            )
    }
}

struct BrandLogoView: View {
    var height: CGFloat = 120
    @State private var pulse = false

    var body: some View {
        Image("AppLogo")
            .resizable()
            .scaledToFit()
            .frame(height: height)
            .scaleEffect(pulse ? 1.03 : 1.0)
            .shadow(color: BrandTheme.accent.opacity(0.18), radius: pulse ? 18 : 10, y: 6)
            .onAppear {
                withAnimation(.easeInOut(duration: 1.1).repeatForever(autoreverses: true)) {
                    pulse = true
                }
            }
    }
}
