//
//  GlassEffect.swift
//  vibes
//
//  Created by Kaveh Anvaripour on 11/6/25.
//

import SwiftUI

enum VibesGlassStyle {
    case thin
    case medium
    case dense
    case blur
    
    var backgroundColor: Color {
        switch self {
        case .thin:
            return Constants.Colors.Background.Glass.thin
        case .medium:
            return Constants.Colors.Background.Glass.thick
        case .dense:
            return Constants.Colors.Background.Glass.dense
        case .blur:
            return Color.clear
        }
    }
    
    var borderColor: Color {
        return Constants.Colors.Border.primary
    }
    
    var useBlur: Bool {
        return self == .blur
    }
}

extension View {
    func glassEffect<S: Shape>(_ style: VibesGlassStyle, in shape: S) -> some View {
        self
            .background(
                Group {
                    if style.useBlur {
                        shape
                            .fill(.ultraThinMaterial)
                            .stroke(style.borderColor, lineWidth: 0.5)
                            .environment(\.colorScheme, .dark)
                    } else {
                        shape
                            .fill(style.backgroundColor)
                            .stroke(style.borderColor, lineWidth: 0.5)
                    }
                }
            )
    }
    
}