//! Windows 11 inspired theme for the CalcPad iced application.
//!
//! Provides color constants and styling functions that mirror the
//! WinUI 3 / Fluent Design aesthetic: clean backgrounds, subtle
//! separators, and the Segoe-like color palette.

use iced::widget::{container, text_editor};
use iced::{Border, Color, Theme};

// ---------------------------------------------------------------------------
// Color palette — Windows 11 Light
// ---------------------------------------------------------------------------

/// Main window background (WinUI "Layer" background).
pub const BACKGROUND: Color = Color::from_rgb(0.976, 0.976, 0.976); // #f9f9f9

/// Editor pane background — slightly lighter for contrast.
pub const EDITOR_BG: Color = Color::from_rgb(1.0, 1.0, 1.0); // #ffffff

/// Results pane background — very subtle gray tint.
pub const RESULTS_BG: Color = Color::from_rgb(0.965, 0.965, 0.969); // #f7f7f8

/// Result text color — muted dark gray, not pure black.
pub const RESULT_TEXT: Color = Color::from_rgb(0.247, 0.247, 0.247); // #3f3f3f

/// Error text color — Windows 11 system red.
pub const ERROR_TEXT: Color = Color::from_rgb(0.780, 0.173, 0.157); // #c72c28

/// Accent color — Windows 11 default blue.
pub const ACCENT: Color = Color::from_rgb(0.0, 0.471, 0.831); // #0078d4

/// Separator / rule color.
pub const SEPARATOR: Color = Color::from_rgb(0.878, 0.878, 0.878); // #e0e0e0

/// Title bar / header background.
pub const HEADER_BG: Color = Color::from_rgb(0.949, 0.949, 0.949); // #f2f2f2

/// Placeholder / dimmed text.
pub const PLACEHOLDER: Color = Color::from_rgb(0.600, 0.600, 0.600); // #999999

// ---------------------------------------------------------------------------
// Container styles
// ---------------------------------------------------------------------------

/// Style for the editor (left) pane container.
pub fn editor_pane(_theme: &Theme) -> container::Style {
    container::Style {
        background: Some(iced::Background::Color(EDITOR_BG)),
        ..Default::default()
    }
}

/// Style for the results (right) pane container.
pub fn results_pane(_theme: &Theme) -> container::Style {
    container::Style {
        background: Some(iced::Background::Color(RESULTS_BG)),
        ..Default::default()
    }
}

/// Style for the top header bar.
pub fn header_bar(_theme: &Theme) -> container::Style {
    container::Style {
        background: Some(iced::Background::Color(HEADER_BG)),
        border: Border {
            color: SEPARATOR,
            width: 0.0,
            radius: 0.0.into(),
        },
        ..Default::default()
    }
}

// ---------------------------------------------------------------------------
// Text editor style
// ---------------------------------------------------------------------------

/// Clean, borderless text editor that blends with the editor pane.
pub fn editor_style(theme: &Theme, status: text_editor::Status) -> text_editor::Style {
    let mut style = text_editor::default(theme, status);
    style.background = iced::Background::Color(EDITOR_BG);
    style.border = Border {
        color: Color::TRANSPARENT,
        width: 0.0,
        radius: 0.0.into(),
    };
    style
}
