//! Style provider trait for markdown rendering.

use ratatui::style::{Color, Modifier, Style};

/// Style provider for each markdown element type.
pub trait MarkdownTheme {
    fn h1(&self) -> Style;
    fn h2(&self) -> Style;
    fn h3(&self) -> Style;
    fn text(&self) -> Style;
    fn code(&self) -> Style;
    fn code_border(&self) -> Style;
    fn link(&self) -> Style;
    fn link_url(&self) -> Style;
    fn quote(&self) -> Style;
    fn list(&self) -> Style;
    fn table_header_bg(&self) -> Color;
    fn table_row_even(&self) -> Color;
    fn table_row_odd(&self) -> Color;
}

/// Fallback theme with hardcoded terminal colors, used in tests.
pub struct DefaultTheme;

impl MarkdownTheme for DefaultTheme {
    fn h1(&self) -> Style {
        Style::new()
            .fg(Color::Cyan)
            .add_modifier(Modifier::BOLD | Modifier::UNDERLINED)
    }

    fn h2(&self) -> Style {
        Style::new().fg(Color::Blue).add_modifier(Modifier::BOLD)
    }

    fn h3(&self) -> Style {
        Style::new().fg(Color::Magenta).add_modifier(Modifier::BOLD)
    }

    fn text(&self) -> Style {
        Style::new().fg(Color::White)
    }

    fn code(&self) -> Style {
        Style::new().fg(Color::Yellow)
    }

    fn code_border(&self) -> Style {
        Style::new().fg(Color::DarkGray)
    }

    fn link(&self) -> Style {
        Style::new()
            .fg(Color::Blue)
            .add_modifier(Modifier::UNDERLINED)
    }

    fn link_url(&self) -> Style {
        Style::new().fg(Color::DarkGray)
    }

    fn quote(&self) -> Style {
        Style::new().fg(Color::Gray)
    }

    fn list(&self) -> Style {
        Style::new().fg(Color::White)
    }

    fn table_header_bg(&self) -> Color {
        Color::DarkGray
    }

    fn table_row_even(&self) -> Color {
        Color::Reset
    }

    fn table_row_odd(&self) -> Color {
        Color::Reset
    }
}
