def test_ui_modules_import_without_creating_root_window() -> None:
    import ccma.app  # noqa: F401
    import ccma.ui.claim_tab  # noqa: F401
    import ccma.ui.main_window  # noqa: F401
    import ccma.ui.member_tab  # noqa: F401
    import ccma.ui.splash  # noqa: F401


def test_splash_position_centers_on_pointer_and_stays_on_screen() -> None:
    from ccma.ui.splash import centered_position

    assert centered_position(
        width=620,
        height=330,
        pointer_x=2500,
        pointer_y=600,
        screen_x=0,
        screen_y=0,
        screen_width=3840,
        screen_height=1080,
    ) == (2190, 435)
    assert centered_position(
        width=620,
        height=330,
        pointer_x=10,
        pointer_y=10,
        screen_x=0,
        screen_y=0,
        screen_width=1920,
        screen_height=1080,
    ) == (0, 0)


def test_splash_minimum_time_only_waits_for_remaining_duration() -> None:
    from ccma.ui.splash import (
        _member_delay_for_splash,
        _progress_value,
        _remaining_minimum_ms,
    )

    assert _remaining_minimum_ms(100.0, 5.0, 102.25) == 2750
    assert _remaining_minimum_ms(100.0, 5.0, 106.0) == 0
    assert _remaining_minimum_ms(100.0, 0.0, 100.0) == 0
    assert _progress_value(2.5, 5.0, startup_finished=False) == 47.5
    assert _progress_value(5.0, 5.0, startup_finished=False) == 95.0
    assert _progress_value(2.5, 5.0, startup_finished=True) == 50.0
    assert _progress_value(5.0, 5.0, startup_finished=True) == 100.0
    assert _member_delay_for_splash(5.0, 10) == 0.5
    assert _member_delay_for_splash(5.0, 0) == 0.0
    assert _member_delay_for_splash(0.0, 10) == 0.0


def test_event_labels_hide_board_actor_but_keep_automatic_marker() -> None:
    from ccma.domain.models import Event
    from ccma.ui.member_tab import _event_label

    user_event = Event("1", "2026-01-01T00:00:00+01:00", "comment", "Kommentar", "user", "Vorstand")
    system_event = Event("2", "2026-01-01T00:00:00+01:00", "automatic", "Automatisch")
    assert _event_label(user_event) == "Kommentar"
    assert _event_label(system_event) == "[AUTO] Automatisch"


def test_housekeeper_details_are_multiline() -> None:
    from datetime import date

    from ccma.domain.models import HousekeeperFinding
    from ccma.ui.work_tabs import _finding_details

    finding = HousekeeperFinding(
        severity="error",
        member_id="member-1",
        code="invalid_member_record",
        title="Mitgliederakte beschädigt",
        detail="Die JSON-Datei ist leer und wird nicht automatisch überschrieben.",
        due_date=date(2026, 7, 31),
    )

    rendered = _finding_details(finding)
    assert rendered.splitlines()[0] == "ERROR · invalid_member_record"
    assert "Mitgliederakte beschädigt\nFällig:" in rendered
    assert rendered.endswith("nicht automatisch überschrieben.")


def test_german_ui_labels_round_trip_to_english_storage_keys() -> None:
    from ccma.domain.models import MEMBERSHIP_STATUS_LABELS
    from ccma.ui.labels import (
        CLAIM_ITEM_TYPE_LABELS,
        THEME_LABELS,
        display_label,
        storage_key,
    )

    assert display_label(THEME_LABELS, "dark") == "Dunkel"
    assert storage_key(THEME_LABELS, "Hell") == "light"
    assert display_label(CLAIM_ITEM_TYPE_LABELS, "credit") == "Gutschrift"
    assert storage_key(CLAIM_ITEM_TYPE_LABELS, "Dienstleistung") == "service"
    assert display_label(MEMBERSHIP_STATUS_LABELS, "active") == "AKTIV"
    assert storage_key(MEMBERSHIP_STATUS_LABELS, "EHRENMITGLIED") == "honorary"
