from reportlab.platypus import SimpleDocTemplate, Paragraph, Spacer, ListFlowable
from reportlab.lib.styles import getSampleStyleSheet

def generate_jd_pdf(data: dict, file_path: str):
    styles = getSampleStyleSheet()
    doc = SimpleDocTemplate(file_path)

    elements = []

    title = data.get("job_title", "Job Description")
    summary = data.get("summary", "")
    responsibilities = data.get("responsibilities", [])
    requirements = data.get("requirements", [])

    elements.append(Paragraph(f"<b>{title}</b>", styles["Title"]))
    elements.append(Spacer(1, 10))

    elements.append(Paragraph("<b>Summary</b>", styles["Heading2"]))
    elements.append(Paragraph(summary, styles["Normal"]))
    elements.append(Spacer(1, 10))

    elements.append(Paragraph("<b>Responsibilities</b>", styles["Heading2"]))
    elements.append(ListFlowable(
        [Paragraph(r, styles["Normal"]) for r in responsibilities]
    ))
    elements.append(Spacer(1, 10))

    elements.append(Paragraph("<b>Requirements</b>", styles["Heading2"]))
    elements.append(ListFlowable(
        [Paragraph(r, styles["Normal"]) for r in requirements]
    ))

    doc.build(elements)