import SwiftUI

private let settingsCardFill = RosettaColors.adaptive(
    light: Color(hex: 0xF2F2F7),
    dark: Color(red: 28/255, green: 28/255, blue: 30/255)
)

// MARK: - Settings Card (adaptive background, no border/blur)

struct SettingsCard<Content: View>: View {
    let content: () -> Content

    init(@ViewBuilder content: @escaping () -> Content) {
        self.content = content
    }

    var body: some View {
        content()
            .background(
                RoundedRectangle(cornerRadius: 26, style: .continuous)
                    .fill(settingsCardFill)
            )
    }
}

// MARK: - Telegram Section Card (solid fill, no border/blur)

/// Telegram-parity section card: #1c1c1d dark fill, 11pt corner radius, no borders.
/// Source: DefaultDarkPresentationTheme.swift → itemBlocksBackgroundColor.
struct TelegramSectionCard<Content: View>: View {
    let cornerRadius: CGFloat
    let content: () -> Content

    init(cornerRadius: CGFloat = 11, @ViewBuilder content: @escaping () -> Content) {
        self.cornerRadius = cornerRadius
        self.content = content
    }

    var body: some View {
        content()
            .background(
                RoundedRectangle(cornerRadius: cornerRadius, style: .continuous)
                    .fill(telegramSectionFill)
            )
    }
}

/// Telegram itemBlocksBackgroundColor: dark #1c1c1d, light #F2F2F7.
let telegramSectionFill = RosettaColors.adaptive(
    light: Color(hex: 0xF2F2F7),
    dark: Color(red: 28/255, green: 28/255, blue: 29/255)
)

/// Telegram itemBlocksSeparatorColor: dark #545458 at 55%, light #3C3C43 at 36%.
let telegramSeparatorColor = RosettaColors.adaptive(
    light: Color(hex: 0x3C3C43).opacity(0.36),
    dark: Color(hex: 0x545458).opacity(0.55)
)

/// Telegram itemPlaceholderTextColor: dark #4d4d4d, light #c8c8ce.
let telegramPlaceholderColor = RosettaColors.adaptive(
    light: Color(hex: 0xC8C8CE),
    dark: Color(hex: 0x4d4d4d)
)

// MARK: - Glass Card (material blur + border)

struct GlassCard<Content: View>: View {
    let cornerRadius: CGFloat
    let fillOpacity: Double
    let content: () -> Content

    init(
        cornerRadius: CGFloat = 12,
        fillOpacity: Double = 0.06,
        @ViewBuilder content: @escaping () -> Content
    ) {
        self.cornerRadius = cornerRadius
        self.fillOpacity = fillOpacity
        self.content = content
    }

    var body: some View {
        content()
            .background {
                TelegramGlassRoundedRect(cornerRadius: cornerRadius)
            }
    }
}
