#!/usr/bin/env python3
import os, re
from docx import Document

DOCX_DIR = "/root/projects/jg/2026-PM-VBS-Element3/deliverables/docx/"
FILES = sorted([f for f in os.listdir(DOCX_DIR) if f.startswith("PM_VBS03_") and f.endswith(".docx") and "QC" not in f])

for fname in FILES:
    doc = Document(os.path.join(DOCX_DIR, fname))
    full = "\n".join([p.text for p in doc.paragraphs])
    for t in doc.tables:
        for r in t.rows:
            for c in r.cells:
                full += "\n" + c.text
    
    # Check logo
    has_img = any("image" in rel.reltype for rel in doc.part.rels.values())
    
    # Check TierVerify
    has_tv = "verify" in full.lower() or "tierverify" in full.lower()
    
    # Check [n] refs
    has_refs = bool(re.search(r'\[\d+\]', full))
    has_bron = "bronnen" in full.lower() or "referenties" in full.lower() or "bronverwijzing" in full.lower()
    
    # Check footer
    has_footer = "JvG Consultancy" in full and "Governance" in full
    
    short = fname.replace("PM_VBS03_","").replace("_v1.0.docx","")
    fails = []
    if not has_img: fails.append("NO_LOGO")
    if not has_tv: fails.append("NO_TIERVERIFY")
    if not has_refs or not has_bron: fails.append(f"REFS(refs={has_refs},bron={has_bron})")
    if not has_footer: fails.append("NO_FOOTER")
    
    status = "PASS" if not fails else " | ".join(fails)
    print(f"{short}: {status}")
