use ely_design_system::colors;
use gpui::{AnyElement, IntoElement, ParentElement, Styled, div, px, rgb, rgba};
use gpui_component::IconName;

pub(crate) fn render_command_footer() -> AnyElement {
    div()
        .flex()
        .items_center()
        .gap(px(14.0))
        .px(px(16.0))
        .py(px(10.0))
        .border_t_1()
        .border_color(rgba(colors::divider()))
        .text_size(px(10.5))
        .text_color(rgb(colors::ink_3()))
        .bg(rgba(footer_bg()))
        // Only the shortcuts that actually do something today.
        // `⌘↵` (split-on-open) and `⇥` (filter) are real product
        // features but not yet wired through the command overlay's
        // key dispatch — listing them here would be a fake hint.
        .child(footer_chunk("↑↓", "navigate"))
        .child(footer_chunk("↵", "open"))
        .child(
            div()
                .ml_auto()
                .flex()
                .items_center()
                .gap(px(6.0))
                .child(div().text_color(rgb(colors::accent())).child(IconName::Asterisk))
                .child("Powered by ELY"),
        )
        .into_any_element()
}

fn footer_chunk(keys: &'static str, label: &'static str) -> AnyElement {
    div().flex().items_center().gap(px(4.0)).child(render_kbd(keys)).child(label).into_any_element()
}

pub(crate) fn render_kbd(label: &'static str) -> AnyElement {
    div()
        .px(px(5.0))
        .py(px(1.0))
        .rounded(px(4.0))
        .bg(rgba(kbd_bg()))
        .text_size(px(10.0))
        .text_color(rgb(colors::ink_3()))
        .child(label)
        .into_any_element()
}

fn kbd_bg() -> u32 {
    colors::pick(0xffffffd9, 0x1f1d1bd9)
}
fn footer_bg() -> u32 {
    colors::pick(0xffffff8c, 0x1f1d1b8c)
}
