// Glassmorphism card component

use leptos::prelude::*;

/// Blur level for glassmorphism effect
#[derive(Clone, Copy, Debug, PartialEq)]
pub enum BlurLevel {
    None,
    Sm,
    Md,
    Lg,
    Xl,
}

/// Glow color for card shadow
#[derive(Clone, Copy, Debug, PartialEq)]
pub enum GlowColor {
    None,
    Cyan,
    Purple,
    Pink,
    Blue,
}

/// Glassmorphism card component
#[component]
pub fn Card(
    #[prop(default = BlurLevel::Md)] blur: BlurLevel,
    #[prop(default = GlowColor::None)] glow: GlowColor,
    #[prop(default = false)] hover_effect: bool,
    #[prop(default = "")] class: &'static str,
    children: Children,
) -> impl IntoView {
    let blur_class = match blur {
        BlurLevel::None => "",
        BlurLevel::Sm => "backdrop-blur-sm",
        BlurLevel::Md => "backdrop-blur-md",
        BlurLevel::Lg => "backdrop-blur-lg",
        BlurLevel::Xl => "backdrop-blur-xl",
    };

    let glow_class = match glow {
        GlowColor::None => "",
        GlowColor::Cyan => "shadow-lg shadow-cyan-500/40",
        GlowColor::Purple => "shadow-lg shadow-purple-500/40",
        GlowColor::Pink => "shadow-lg shadow-pink-500/40",
        GlowColor::Blue => "shadow-lg shadow-blue-500/40",
    };

    let hover_class = if hover_effect {
        "hover:border-cyan-400/70 hover:shadow-cyan-500/50 transition-all duration-300 \
         cursor-pointer"
    } else {
        ""
    };

    let combined_class = format!(
        "bg-white/8 border border-white/20 rounded-lg p-4 {} {} {} {}",
        blur_class, glow_class, hover_class, class
    );

    view! {
        <div class=combined_class>
            {children()}
        </div>
    }
}
