//
//  DarkModeStylesTests.swift
//  Tests iOS
//
//  TC-022: Day view styles render correctly in dark mode.
//

import XCTest

final class DarkModeStylesTests: BaseUITestCase {
    override var seedFixture: String? { "single_mood" }

    /// TC-022: Day view styles render without crash in dark mode.
    func testDayViewStyles_DarkMode_NoCrash() {
        let tabBar = TabBarScreen(app: app)
        let customizeScreen = CustomizeScreen(app: app)

        // First, switch to dark mode via the theme mode selector
        let settingsScreen = tabBar.tapSettings()
        settingsScreen.assertVisible()
        settingsScreen.tapCustomizeTab()

        // Try to select the "Dark" theme mode
        let darkButton = customizeScreen.themeButton(named: "Dark")
        if darkButton.waitForExistence(timeout: 3) || app.swipeUntilExists(darkButton, direction: .up, maxSwipes: 3) {
            darkButton.tapWhenReady()
        }

        // Navigate to Day tab to verify dark mode renders correctly
        tabBar.tapDay()
        assertDayContentVisible()

        captureScreenshot(name: "day_view_dark_mode_default_style")

        // Try a few different day view styles in dark mode
        let sampleStyles = ["Classic", "Neon", "Glass"]

        for style in sampleStyles {
            let settings = tabBar.tapSettings()
            settings.assertVisible()
            settings.tapCustomizeTab()

            customizeScreen.selectDayViewStyle(style)

            tabBar.tapDay()
            assertDayContentVisible()
        }

        captureScreenshot(name: "day_view_dark_mode_styles_completed")
    }
}
