//! Inline search bar with active/inactive styling.

use ratatui::layout::Rect;
use ratatui::style::Style;
use ratatui::text::{Line, Span};
use ratatui::widgets::Paragraph;
use ratatui::Frame;

use crate::theme;

/// Render a `/query` search bar.
pub fn render_search_bar(frame: &mut Frame, area: Rect, query: &str, active: bool) {
    let theme = theme::get();
    let style = if active {
        Style::new().fg(theme.search.active)
    } else {
        Style::new().fg(theme.search.inactive)
    };
    let cursor = if active { "_" } else { "" };
    let text = format!(" /{query}{cursor}");
    let line = Line::from(Span::styled(text, style));
    frame.render_widget(Paragraph::new(vec![line]), area);
}
