Feature: TUI Settings and Session Management Screens
  Implements the Settings screen and Session Management screen
  for TUI configuration and session management.

  Background:
    Given the TUI screens module is imported

  # ---------- SettingsScreen ----------

  Scenario: SettingsScreen initializes with default settings
    Given a SettingsScreen widget
    Then the theme should be "dracula"
    And the default_actor should be "default"
    And the safety_level should be "medium"

  Scenario: SettingsScreen shows and hides
    Given a SettingsScreen widget
    When I show the settings screen
    Then the settings screen should be visible
    When I hide the settings screen
    Then the settings screen should not be visible

  Scenario: SettingsScreen navigates settings
    Given a SettingsScreen widget that is visible
    When I navigate to the next setting
    Then the selected_index should be 1
    When I navigate to the previous setting
    Then the selected_index should be 0

  Scenario: SettingsScreen allows setting configuration
    Given a SettingsScreen widget
    When I set the theme to "light"
    And I set the default_actor to "admin"
    And I set the safety_level to "high"
    Then the theme should be "light"
    And the default_actor should be "admin"
    And the safety_level should be "high"

  Scenario: SettingsScreen returns current settings as dict
    Given a SettingsScreen widget
    When I set the theme to "light"
    And I set the default_actor to "admin"
    And I set the safety_level to "high"
    Then get_settings should return theme "light", default_actor "admin", safety_level "high"

  # ---------- SessionManagementScreen ----------

  Scenario: SessionManagementScreen initializes empty
    Given a SessionManagementScreen widget
    Then the sessions list should be empty
    And the current_session_id should be "default"

  Scenario: SessionManagementScreen shows and hides
    Given a SessionManagementScreen widget
    When I show the session management screen
    Then the session management screen should be visible
    When I hide the session management screen
    Then the session management screen should not be visible

  Scenario: SessionManagementScreen loads and navigates sessions
    Given a SessionManagementScreen widget
    When I load 3 sessions
    Then the sessions list should have 3 items
    When I navigate to the next session
    Then the selected_index should be 1
    When I navigate to the previous session
    Then the selected_index should be 0

  Scenario: SessionManagementScreen returns selected session
    Given a SessionManagementScreen widget with 3 sessions
    When I navigate to the next session
    Then get_selected_session should return a SessionInfo object

  Scenario: SessionManagementScreen returns None when no sessions
    Given a SessionManagementScreen widget
    Then get_selected_session should return None

  Scenario: SessionManagementScreen renders sessions when visible
    Given a SessionManagementScreen widget
    When I show the session management screen
    And I load 3 sessions
    Then the session screen rendered text should contain "Session 1"
    And the session screen rendered text should contain "10 msgs"
    And the session screen rendered text should contain "[CURRENT]"

  # ---------- TuiCommandRouter /settings route ----------

  Scenario: TuiCommandRouter routes /settings to settings command
    Given a TuiCommandRouter for settings tests
    When I call handle with raw input "settings"
    Then the handle result should be "Settings screen opened"
