//! TUI mode for syntaxis management
//!
//! Provides interactive terminal UI for managing project phases and workflows.
//!
//! Implements R-WIDGET-COMPOSITION and R-STATE-SEPARATION patterns.
//!
//! Configuration can be provided via:
//! - Environment variables (TUI_*, API_*)
//! - Configuration file (.tui/config.toml)
//! - Hardcoded defaults

#![forbid(unsafe_code)]
#![warn(missing_docs)]

pub mod config;
pub mod screens;
pub mod websocket;

// Re-export screen types
pub use screens::{ChecklistScreen, PhaseScreen, ProjectsScreen};

/// Public AppState type for library interface
#[derive(Debug, Clone)]
pub struct AppState {
    /// Current phase
    pub current_phase: u32,
    /// Project name
    pub project_name: String,
    /// Items completed in current phase
    pub items_completed: usize,
}

impl AppState {
    /// Create new app state
    pub fn new() -> Self {
        AppState {
            current_phase: 1,
            project_name: String::new(),
            items_completed: 0,
        }
    }
}

impl Default for AppState {
    fn default() -> Self {
        Self::new()
    }
}

/// Public ScreenType for navigation
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub enum ScreenType {
    /// Phase management screen
    Phases,
    /// Projects list screen
    Projects,
    /// Checklist screen
    Checklist,
}

/// Prelude for common imports
pub mod prelude {
    pub use crate::screens::{ChecklistScreen, PhaseScreen, ProjectsScreen};
    pub use crate::{AppState, ScreenType};
}

#[cfg(test)]
mod tests {
    use super::*;

    #[test]
    fn test_app_state_new() {
        let state = AppState::new();
        assert_eq!(state.current_phase, 1);
        assert!(state.project_name.is_empty());
    }

    #[test]
    fn test_screen_type_variants() {
        let _ = ScreenType::Phases;
        let _ = ScreenType::Projects;
        let _ = ScreenType::Checklist;
    }
}
