from pathlib import Path

ROOT = Path(__file__).resolve().parents[1]


def read(path: str) -> str:
    return (ROOT / path).read_text(encoding="utf-8")


def test_v486_opportunity_board_uses_clean_non_overlapping_layout():
    opportunities = read("app/admin_ui/pages/opportunities.py")
    styles = read("app/admin_ui/styles.py")

    assert "cf-opportunities-board-scroll" in opportunities
    assert "cf-opportunities-board-grid" in opportunities
    assert "cf-opportunity-stage" in opportunities
    assert "cf-opportunity-card-clean" in opportunities
    assert "cf-opportunity-next-action" in opportunities

    # Cards no longer repeat stage/priority chips inside each opportunity card.
    card_fn = opportunities.split("def _render_opportunity_card", 1)[1].split("def render_opportunities_board_partial", 1)[0]
    assert "opportunity_stage_badge" not in card_fn
    assert "opportunity_priority_chip" not in card_fn
    assert "d-flex justify-content-between" not in card_fn

    # Columns have a minimum width instead of being squeezed until badges overlap.
    assert "grid-template-columns: repeat(4, minmax(300px, 1fr))" in styles
    assert "overflow-x: auto" in styles
    assert "min-width: 1220px" in styles


def test_v486_opportunity_copy_describes_relevant_fields_only():
    opportunities = read("app/admin_ui/pages/opportunities.py")

    assert "identificação clara, assunto, próxima ação e bloqueios relevantes" in opportunities
    assert "valor e pendências" not in opportunities
