#!/usr/bin/env python3
"""
Pixelated Empathy — Couples & Family Therapy Session Generator

Fills Gap 5: couples and family therapy sessions.
7 topics × 50 sessions = 350 sessions total.
2-3 family members per session. Multi-patient format.
Vary turns 12-20. Naturalistic turn-taking.

Usage:
  python generate_couples_sessions.py [--categories all] [--sessions-per-category 50] [--resume]
"""

from session_base_multi import run_multi_generation

CATEGORIES = {
    "communication_breakdown": {
        "name": "Communication Breakdown",
        "difficulty": "medium",
        "presentations": [
            "pursuer-withdrawer cycle — one partner wants to talk, the other shuts down, pattern locked in",
            "escalation spiral — small disagreement becomes huge fight, neither knows how it happened",
            "stonewalling and contempt — Gottman's four horsemen present, couple wants to break the pattern",
            "silent treatment patterns — one partner stops talking for days after conflict, other walks on eggshells",
            "meta-communication — couple argues about how they argue, can't get to the actual issue",
        ],
        "persona_sets": [
            [
                {
                    "name": "Alex",
                    "age": "32",
                    "gender": "female",
                    "occupation": "marketing director",
                    "presenting": "Wants to talk about everything immediately, feels shut out when partner withdraws",
                },
                {
                    "name": "Ryan",
                    "age": "34",
                    "gender": "male",
                    "occupation": "software engineer",
                    "presenting": "Shuts down when conflict starts, feels overwhelmed, needs space but doesn't know how to ask",
                },
            ],
            [
                {
                    "name": "Priya",
                    "age": "38",
                    "gender": "female",
                    "occupation": "doctor",
                    "presenting": "Every small disagreement becomes a huge fight, exhausted from the cycle",
                },
                {
                    "name": "James",
                    "age": "40",
                    "gender": "male",
                    "occupation": "architect",
                    "presenting": "Doesn't understand how small things escalate, defensive when blamed for the pattern",
                },
            ],
        ],
        "therapist_techniques": [
            "Gottman method — identify and interrupt the four horsemen (criticism, contempt, defensiveness, stonewalling)",
            "soft start-up — teach the pursuer to raise issues gently instead of with criticism",
            "repair attempts — teach couples to make and receive repair attempts during conflict",
            "speaker-listener technique — structured turn-taking, one speaks at a time",
            "de-escalation — slow down the interaction, breathe, name the pattern",
            "underlying feelings — get beneath the surface conflict to the vulnerable feelings underneath",
        ],
        "therapist_prompt_addon": (
            "You work with couples using Gottman and EFT approaches. You don't take sides. You identify "
            "negative cycles (pursuer-withdrawer, attack-defend) and help both partners see the pattern, "
            "not just each other's behavior. You create safety for both — the pursuer who feels abandoned "
            "AND the withdrawer who feels overwhelmed. You slow down escalations and teach concrete "
            "communication skills in the room."
        ),
    },
    "infidelity_rebuilding": {
        "name": "Infidelity & Trust Rebuilding",
        "difficulty": "high",
        "presentations": [
            "discovery aftermath — affair just discovered, couple in crisis, raw emotion, therapist contains",
            "disclosure process — partner wants more details, affair partner doesn't want to share, therapist mediates",
            "trust rebuilding — months out, trying to rebuild, triggers keep happening, patience running thin",
            "ambivalence about staying — hurt partner not sure they want to stay, affair partner desperate to fix",
            "relapse of trust — small lie discovered, triggers affair wound, couple questions whether trust is possible",
        ],
        "persona_sets": [
            [
                {
                    "name": "Emma",
                    "age": "34",
                    "gender": "female",
                    "occupation": "teacher",
                    "presenting": "Discovered husband's affair 2 weeks ago, can't eat or sleep, alternating between rage and grief",
                },
                {
                    "name": "Mark",
                    "age": "36",
                    "gender": "male",
                    "occupation": "sales manager",
                    "presenting": "Had a 3-month affair, ended it, wants to save marriage, doesn't know how to help Emma",
                },
            ],
            [
                {
                    "name": "Sophia",
                    "age": "41",
                    "gender": "female",
                    "occupation": "lawyer",
                    "presenting": "Husband's affair was 6 months ago, trying to rebuild but every small thing triggers her",
                },
                {
                    "name": "Daniel",
                    "age": "43",
                    "gender": "male",
                    "occupation": "finance executive",
                    "presenting": "Patient with triggers but getting frustrated, questions if this will ever end, guilt and frustration coexist",
                },
            ],
        ],
        "therapist_techniques": [
            "Gottman trust rebuilding — structured process: atonement, attunement, attachment",
            "disclosure facilitation — help couple navigate what details to share, avoid re-traumatizing",
            "trigger management — identify triggers, develop coping strategies, normalize the recovery timeline",
            "empathy building — help affair partner understand the impact, move from defensiveness to empathy",
            "relationship audit — explore what was missing in the relationship without blaming the hurt partner",
            "forgiveness process — explore what forgiveness means, distinguish from forgetting or excusing",
        ],
        "therapist_prompt_addon": (
            "You work with couples healing from infidelity using the Gottman trust rebuilding framework. "
            "You hold both partners' pain — the betrayed partner's shattered trust AND the affair partner's "
            "guilt and fear. You never blame the betrayed partner for the affair. You help the affair partner "
            "move from defensiveness to empathy. You normalize the long timeline of trust rebuilding. "
            "You contain the raw emotion while allowing processing. Safety and pacing are paramount."
        ),
    },
    "parenting_conflict": {
        "name": "Parenting Conflict",
        "difficulty": "medium",
        "presentations": [
            "inconsistent discipline — parents disagree on rules, kids play them against each other, need unified front",
            "blended family challenges — stepparent wants authority, bio parent protective, kids caught in middle",
            "screen time wars — one parent permissive, other strict, kids exploit the gap, couple can't agree",
            "teenage rebellion response — parents disagree on how to handle teen's behavior, one too strict one too lenient",
            "attachment differences — one parent helicopter, other distant, kids receiving mixed signals",
        ],
        "persona_sets": [
            [
                {
                    "name": "Jen",
                    "age": "35",
                    "gender": "female",
                    "occupation": "graphic designer",
                    "presenting": "Wants gentle parenting, husband is strict, kids get away with things when she handles it",
                },
                {
                    "name": "Mike",
                    "age": "37",
                    "gender": "male",
                    "occupation": "police officer",
                    "presenting": "Thinks kids need discipline, wife is too soft, feels undermined as a parent",
                },
            ],
            [
                {
                    "name": "Rachel",
                    "age": "40",
                    "gender": "female",
                    "occupation": "nurse",
                    "presenting": "Stepparent to 2 kids, trying to build relationship but kids reject her, bio dad doesn't enforce respect",
                },
                {
                    "name": "Tom",
                    "age": "44",
                    "gender": "male",
                    "occupation": "electrician",
                    "presenting": "Protective of kids after divorce, feels caught between new wife and kids, doesn't want to force them",
                },
            ],
        ],
        "therapist_techniques": [
            "co-parenting framework — establish shared rules, clear roles, united front",
            "blended family integration — validate children's loyalty conflicts, build step-relationship at child's pace",
            "parenting style assessment — identify each parent's style, find middle ground",
            "circular questioning — explore how each parent's behavior affects the other and the kids",
            "unified boundary setting — help couple agree on core rules and present them as a team",
            "attachment-focused parenting — explore parents' own attachment histories and how they drive parenting",
        ],
        "therapist_prompt_addon": (
            "You work with parents on co-parenting and blended family dynamics. You don't take sides or "
            "label one parent 'right.' You help them find middle ground and present a unified front. "
            "You prioritize children's well-being while validating both parents' perspectives. You "
            "understand blended family complexity — loyalty conflicts, step-parent roles, bio-parent guilt. "
            "You explore how parents' own upbringings drive their parenting choices."
        ),
    },
    "family_divorce_transition": {
        "name": "Divorce & Family Transition",
        "difficulty": "medium-high",
        "presentations": [
            "telling the children — couple needs to tell kids about divorce, wants to do it well, scared of damage",
            "co-parenting after divorce — separated, struggling to co-parent, kids in the middle, communication hostile",
            "blended family formation — new partner being introduced, kids resistant, ex-spouse interfering",
            "parallel parenting — high-conflict divorce, minimal contact needed, therapist helps structure parallel parenting",
            "rebuilding after divorce — individual therapy needs surface in family session, grief and identity",
        ],
        "persona_sets": [
            [
                {
                    "name": "Karen",
                    "age": "38",
                    "gender": "female",
                    "occupation": "teacher",
                    "presenting": "Initiated divorce, husband moved out, needs to tell kids (8 and 11), wants to minimize damage",
                },
                {
                    "name": "Brian",
                    "age": "40",
                    "gender": "male",
                    "occupation": "mechanic",
                    "presenting": "Didn't want divorce, trying to co-parent, hurt and angry, struggling to be civil",
                },
            ],
            [
                {
                    "name": "Lisa",
                    "age": "36",
                    "gender": "female",
                    "occupation": "social worker",
                    "presenting": "Divorced 2 years, ex won't follow schedule, kids confused, she's exhausted",
                },
                {
                    "name": "David",
                    "age": "39",
                    "gender": "male",
                    "occupation": "contractor",
                    "presenting": "Feels alienated from kids, ex controls access, angry and desperate",
                },
                {
                    "name": "Emma",
                    "age": "13",
                    "gender": "female",
                    "occupation": "student",
                    "presenting": "Caught between parents, feels responsible for their fighting, wants everyone to stop",
                },
            ],
        ],
        "therapist_techniques": [
            "divorce coaching — structured plan for telling children, age-appropriate language",
            "co-parenting protocol — establish communication rules, custody logistics, boundary setting",
            "children's voice — create space for children's feelings without putting them in the middle",
            "parallel parenting structure — minimize direct contact, use written communication, separate routines",
            "grief processing — validate loss of family unit, allow each member's grief at their pace",
            "rebuilding identity — support each member in finding who they are in the new family structure",
        ],
        "therapist_prompt_addon": (
            "You work with families navigating divorce and restructuring. You prioritize children's well-being "
            "above parental conflict. You help co-parents communicate without the relationship baggage. "
            "You give children a voice without making them responsible for parent conflicts. You understand "
            "that divorce is grief for everyone, even the one who initiated. You don't take sides in "
            "the divorce — you support the family system through the transition."
        ),
    },
    "inlaw_family_boundaries": {
        "name": "In-Law & Extended Family Boundaries",
        "difficulty": "medium",
        "presentations": [
            "mother-in-law boundary violations — MIL drops by unannounced, criticizes parenting, partner won't set boundary",
            "cultural family expectations — extended family expects involvement in decisions, couple needs privacy",
            "enmeshed family of origin — partner too close to their family, couple identity doesn't feel separate",
            "grandparent favoritism — grandparents favor one child or one side, causing resentment",
            "holiday wars — competing family demands during holidays, couple exhausted from pleasing everyone",
        ],
        "persona_sets": [
            [
                {
                    "name": "Ashley",
                    "age": "29",
                    "gender": "female",
                    "occupation": "nurse",
                    "presenting": "Mother-in-law shows up unannounced, criticizes her cooking and parenting, husband won't say anything",
                },
                {
                    "name": "Kevin",
                    "age": "31",
                    "gender": "male",
                    "occupation": "accountant",
                    "presenting": "Loves his mom, doesn't want to hurt her, feels caught between wife and mother, avoids the conflict",
                },
            ],
            [
                {
                    "name": "Mei",
                    "age": "33",
                    "gender": "female",
                    "occupation": "pharmacist",
                    "presenting": "Her parents expect to be involved in every decision, partner feels excluded from the family unit",
                },
                {
                    "name": "James",
                    "age": "35",
                    "gender": "male",
                    "occupation": "teacher",
                    "presenting": "Feels like he married the whole family, not just Mei, struggling to be a priority",
                },
            ],
        ],
        "therapist_techniques": [
            "boundary mapping — identify where boundaries are needed, who enforces them, what the consequence is",
            "differentiation of self — help enmeshed partner distinguish family obligations from couple priorities",
            "cultural framework — explore cultural expectations about family involvement without pathologizing",
            "united front building — help couple agree on boundaries and enforce them together",
            "communication scripts — practice what to say to family members, rehearse difficult conversations",
            "enmeshment assessment — distinguish healthy closeness from enmeshment that undermines the couple",
        ],
        "therapist_prompt_addon": (
            "You work with couples on extended family boundaries. You understand cultural differences in "
            "family involvement — you don't assume independence is the goal for all families. You help "
            "the couple define their own boundary norms. You support the partner caught between spouse "
            "and family without shaming them for loyalty. You help set boundaries that preserve "
            "relationships where possible while protecting the couple's autonomy."
        ),
    },
    "sibling_family_conflict": {
        "name": "Sibling & Adult Family Conflict",
        "difficulty": "medium",
        "presentations": [
            "elder care dispute — siblings disagree on caring for aging parent, old rivalries resurface",
            "estate division — parent died, siblings fighting over inheritance, grief complicated by money",
            "estranged siblings — one sibling cut off the other, family pressure to reconcile, both defensive",
            "parental favoritism — adult children processing childhood favoritism, family gathering triggered wounds",
            "family business conflict — siblings in family business, power dynamics, old roles reasserting",
        ],
        "persona_sets": [
            [
                {
                    "name": "Sarah",
                    "age": "42",
                    "gender": "female",
                    "occupation": "teacher",
                    "presenting": "Doing all elder care for mother, siblings don't help but criticize, resentment building",
                },
                {
                    "name": "Mark",
                    "age": "45",
                    "gender": "male",
                    "occupation": "business owner",
                    "presenting": "Lives far away, sends money but feels excluded from decisions, defensive about not being there",
                },
                {
                    "name": "Lisa",
                    "age": "38",
                    "gender": "female",
                    "occupation": "nurse",
                    "presenting": "Visits weekly, critical of Sarah's care, thinks she knows better, old dynamic from childhood",
                },
            ],
            [
                {
                    "name": "James",
                    "age": "35",
                    "gender": "male",
                    "occupation": "software engineer",
                    "presenting": "Estranged from sister for 5 years, mom died, forced to interact, old wounds raw",
                },
                {
                    "name": "Rachel",
                    "age": "33",
                    "gender": "female",
                    "occupation": "marketing manager",
                    "presenting": "Cut James off after he borrowed money and never repaid, feels judged by family for the estrangement",
                },
            ],
        ],
        "therapist_techniques": [
            "family systems — identify roles (caregiver, distant one, critic), explore how they formed",
            "sibling differentiation — help siblings see each other as adults, not childhood roles",
            "grief and anger separation — untangle grief about parent from anger at siblings",
            "mediation — facilitate difficult conversations, ensure all voices heard, find compromises",
            "boundary setting in family — establish adult boundaries with parents and siblings",
            "narrative reframing — help family tell a shared story that includes everyone's perspective",
        ],
        "therapist_prompt_addon": (
            "You work with adult siblings and family systems. You understand that childhood dynamics persist "
            "into adulthood and resurface during crises. You help siblings see each other as adults, not "
            "the childhood roles they've been locked into. You don't take sides in sibling conflicts. "
            "You explore the family system that created the dynamic without assigning blame. You hold "
            "space for grief and anger simultaneously."
        ),
    },
    "intimacy_distance": {
        "name": "Intimacy & Emotional Distance",
        "difficulty": "medium",
        "presentations": [
            "emotional withdrawal — partner has emotionally checked out, other partner lonely in the marriage",
            "sexual intimacy loss — no physical intimacy for months/years, both want it back but feel stuck",
            "life transition drift — had kids, jobs changed, drifted apart, love each other but feel like roommates",
            "avoidance patterns — one partner avoids difficult conversations by staying busy, other feels shut out",
            "attachment style conflict — anxious + avoidant pairing triggering each other's core wounds",
        ],
        "persona_sets": [
            [
                {
                    "name": "Emily",
                    "age": "36",
                    "gender": "female",
                    "occupation": "physical therapist",
                    "presenting": "Husband works all the time, no emotional connection, lonely in the marriage for 2 years",
                },
                {
                    "name": "Chris",
                    "age": "38",
                    "gender": "male",
                    "occupation": "lawyer",
                    "presenting": "Knows he's withdrawn, feels overwhelmed by work and kids, doesn't know how to reconnect, feels like a failure",
                },
            ],
            [
                {
                    "name": "Maya",
                    "age": "30",
                    "gender": "female",
                    "occupation": "social worker",
                    "presenting": "Anxious attachment, needs constant reassurance, partner's independence feels like rejection",
                },
                {
                    "name": "David",
                    "age": "32",
                    "gender": "male",
                    "occupation": "graphic designer",
                    "presenting": "Avoidant attachment, feels smothered by partner's needs, withdraws when she gets close, fears engulfment",
                },
            ],
        ],
        "therapist_techniques": [
            "EFT cycle identification — identify the pursue-withdraw cycle, help couple see the pattern",
            "attachment exploration — explore each partner's attachment style and how it drives the dance",
            "emotional accessibility — help withdrawn partner identify and express emotions",
            "intimacy rebuilding — structured activities to rebuild emotional and physical connection",
            "vulnerability coaching — help both partners share fears underneath the protective behavior",
            "differentiation work — distinguish 'I need space' from 'I don't love you' — space without abandonment",
        ],
        "therapist_prompt_addon": (
            "You work with couples using Emotionally Focused Therapy (EFT). You identify the negative cycle "
            "— usually a pursue-withdraw dance — and help both partners see the pattern, not just each other. "
            "You understand attachment styles and how they interact. You create safety for the withdrawn "
            "partner to emerge AND the pursuing partner to slow down. You explore the vulnerable feelings "
            "beneath the protective behaviors. You don't rush toward behavioral solutions — you work "
            "at the emotional level."
        ),
    },
}


def main():
    run_multi_generation(
        categories_dict=CATEGORIES,
        output_dir="data/couples_sessions",
        output_filename="couples_sessions.jsonl",
        session_id_prefix="couples",
        source_family="couples_family_therapy",
        default_sessions_per_category=50,
        description="Couples & Family Therapy Session Generation",
        min_turns=12,
        max_turns=20,
        turn_pattern="naturalistic",
    )


if __name__ == "__main__":
    main()
