import re


def highlight_segments(text: str | None, term: str) -> list[dict[str, str | bool]] | None:
    """Split text into segments marking case-insensitive matches."""
    if not text or not term:
        return None

    pattern = re.compile(re.escape(term), re.IGNORECASE)
    segments: list[dict[str, str | bool]] = []
    last = 0
    found = False

    for match in pattern.finditer(text):
        found = True
        if match.start() > last:
            segments.append({"text": text[last : match.start()], "match": False})
        segments.append({"text": match.group(), "match": True})
        last = match.end()

    if not found:
        return [{"text": text, "match": False}]

    if last < len(text):
        segments.append({"text": text[last:], "match": False})
    return segments
