#!/usr/bin/env python3
"""Generate KGS-2 Tricky Test DOCX from markdown source."""

from docx import Document
from docx.shared import Pt, Inches, Cm, RGBColor
from docx.enum.text import WD_ALIGN_PARAGRAPH
from docx.enum.section import WD_ORIENT
from docx.oxml.ns import qn
import re, os

doc = Document()

# --- Page setup
for section in doc.sections:
    section.top_margin = Cm(1.5)
    section.bottom_margin = Cm(1.5)
    section.left_margin = Cm(2)
    section.right_margin = Cm(2)

style = doc.styles['Normal']
font = style.font
font.name = 'Calibri'
font.size = Pt(11)
style.paragraph_format.space_after = Pt(4)
style.paragraph_format.space_before = Pt(0)

# --- Helpers
def add_title(text, size=22):
    p = doc.add_paragraph()
    p.alignment = WD_ALIGN_PARAGRAPH.CENTER
    run = p.add_run(text)
    run.bold = True
    run.font.size = Pt(size)
    run.font.color.rgb = RGBColor(0x1A, 0x56, 0xDB)
    p.paragraph_format.space_after = Pt(4)
    return p

def add_subtitle(text, size=12):
    p = doc.add_paragraph()
    p.alignment = WD_ALIGN_PARAGRAPH.CENTER
    run = p.add_run(text)
    run.font.size = Pt(size)
    run.font.color.rgb = RGBColor(0x55, 0x55, 0x55)
    p.paragraph_format.space_after = Pt(12)
    return p

def add_heading(text, size=14):
    p = doc.add_paragraph()
    run = p.add_run(text)
    run.bold = True
    run.font.size = Pt(size)
    run.font.color.rgb = RGBColor(0x1A, 0x56, 0xDB)
    p.paragraph_format.space_before = Pt(16)
    p.paragraph_format.space_after = Pt(8)
    return p

def add_question(qnum, stem, options):
    """Add a question with 4 options in two columns."""
    p = doc.add_paragraph()
    p.paragraph_format.space_after = Pt(2)
    run = p.add_run(f"{qnum}. ")
    run.bold = True
    run.font.size = Pt(11)
    run = p.add_run(stem)
    run.font.size = Pt(11)
    
    # Options as inline with tabs
    p_opts = doc.add_paragraph()
    p_opts.paragraph_format.space_after = Pt(10)
    p_opts.paragraph_format.left_indent = Cm(1)
    for i, (opt_letter, opt_text) in enumerate(options):
        run = p_opts.add_run(f"{opt_letter}) {opt_text}")
        run.font.size = Pt(11)
        if i < len(options) - 1:
            run = p_opts.add_run("     ")
            run.font.size = Pt(11)

def add_cloze_text(text):
    p = doc.add_paragraph()
    p.paragraph_format.space_after = Pt(8)
    run = p.add_run(text)
    run.italic = True
    run.font.size = Pt(11)
    return p

def add_reading_text(text):
    p = doc.add_paragraph()
    p.paragraph_format.space_after = Pt(10)
    p.paragraph_format.left_indent = Cm(0.5)
    run = p.add_run(text)
    run.italic = True
    run.font.size = Pt(10.5)
    return p

def add_line():
    p = doc.add_paragraph()
    p.paragraph_format.space_before = Pt(2)
    p.paragraph_format.space_after = Pt(2)
    pPr = p._p.get_or_add_pPr()
    pBdr = pPr.makeelement(qn('w:pBdr'), {})
    bottom = pBdr.makeelement(qn('w:bottom'), {
        qn('w:val'): 'single',
        qn('w:sz'): '4',
        qn('w:space'): '1',
        qn('w:color'): 'CCCCCC',
    })
    pBdr.append(bottom)
    pPr.append(pBdr)

# ===== TITLE PAGE =====
doc.add_paragraph()  # spacer
add_title("5. Sınıf KGS-2 İngilizce", size=24)
add_title("Trik Noktalı Zor Test", size=20)
doc.add_paragraph()
add_subtitle("Kapsam: Ünite 5–9 (Weather, Senses, Eating Out, Healthy Life, Places to Visit)")
add_subtitle("50 Soru • 60 Dakika • 4 Seçenekli (A/B/C/D)")
add_subtitle("Her soruda en az bir trik çeldirici bulunur.")

doc.add_paragraph()
p = doc.add_paragraph()
p.alignment = WD_ALIGN_PARAGRAPH.CENTER
run = p.add_run("Eduvia KGS Hazırlık Merkezi • Serdarlı, KKTC")
run.font.size = Pt(10)
run.font.color.rgb = RGBColor(0x88, 0x88, 0x88)

doc.add_page_break()

# ===== STUDENT INFO =====
p = doc.add_paragraph()
run = p.add_run("Adı Soyadı: ")
run.bold = True
run.font.size = Pt(12)
p.add_run("_" * 50).font.size = Pt(12)

p = doc.add_paragraph()
run = p.add_run("Tarih: ")
run.bold = True
run.font.size = Pt(12)
p.add_run("_" * 20).font.size = Pt(12)
run = p.add_run("     ")
run = p.add_run("Süre: 60 dakika")
run.font.size = Pt(11)

p = doc.add_paragraph()
p.paragraph_format.space_after = Pt(4)
run = p.add_run("Uyarı: ")
run.bold = True
run.font.size = Pt(10)
run.font.color.rgb = RGBColor(0xCC, 0x33, 0x33)
run = p.add_run("Tüm sorular dikkatlice okunmalıdır. Her soruda en az bir çeldirici (tuzak) bulunmaktadır.")
run.font.size = Pt(10)
run.italic = True

add_line()
doc.add_paragraph()

# ===== PART 1: GRAMMAR & VOCABULARY =====
add_heading("BÖLÜM 1: Grammar & Vocabulary (Soru 1–30)")

questions_p1 = [
    ("A: ______ you at the concert last night?\n    B: No, I ______ at home because I was sick.",
     [("A", "Were / was"), ("B", "Did / was"), ("C", "Was / were"), ("D", "Were / were")]),
    ("My brother ______ breakfast this morning but he ______ a big lunch.",
     [("A", "didn't eat / ate"), ("B", "didn't ate / ate"), ("C", "didn't eat / eat"), ("D", "don't eat / ate")]),
    ("There ______ a lot of people at the party last Saturday.",
     [("A", "was"), ("B", "were"), ("C", "is"), ("D", "are")]),
    ("How ______ milk do we need for the cake?",
     [("A", "many"), ("B", "much"), ("C", "any"), ("D", "some")]),
    ("I ______ go to the cinema on weekdays, but last Friday I ______ a great film.",
     [("A", "didn't / see"), ("B", "don't / saw"), ("C", "didn't / saw"), ("D", "don't / see")]),
    ("A: Can Tim cook well?\n    B: No, but he ______ learning now.",
     [("A", "can"), ("B", "is"), ("C", "does"), ("D", "has")]),
    ("There isn't ______ cheese in the fridge, but there are ______ eggs.",
     [("A", "some / any"), ("B", "any / some"), ("C", "any / any"), ("D", "some / some")]),
    ("I wanted to buy ______ at the market yesterday.",
     [("A", "any apples"), ("B", "some apple"), ("C", "some apples"), ("D", "much apples")]),
    ("Last summer my family and I ______ to Antalya. We ______ a lot of historical places.",
     [("A", "go / visit"), ("B", "went / visited"), ("C", "went / visit"), ("D", "go / visited")]),
    ("It is ______ today than it was yesterday.",
     [("A", "more cold"), ("B", "colder"), ("C", "coldest"), ("D", "cold")]),
    ("My little sister ______ to the zoo yesterday. She ______ the monkeys very much.",
     [("A", "goes / loves"), ("B", "went / loved"), ("C", "go / love"), ("D", "went / love")]),
    ("______ she ______ to finish her project last night?",
     [("A", "Did / managed"), ("B", "Did / manage"), ("C", "Was / manage"), ("D", "Does / manage")]),
    ("How does this soup ______? It ______ delicious!",
     [("A", "taste / tastes"), ("B", "tastes / taste"), ("C", "taste / taste"), ("D", "tastes / tastes")]),
    ("My grandfather ______ us interesting stories every night. Yesterday he ______ one about his childhood.",
     [("A", "tell / tell"), ("B", "tells / told"), ("C", "told / tells"), ("D", "tell / told")]),
    ("A: ______ does your mother go to the supermarket?\n    B: She goes there twice a week.",
     [("A", "How much"), ("B", "How many"), ("C", "How often"), ("D", "How long")]),
    ("There are ______ students in the classroom today because it's a holiday.",
     [("A", "a little"), ("B", "much"), ("C", "very few"), ("D", "a lot")]),
    ("A: Were you at the cinema last night?\n    B: No, I ______. I ______ to stay home and study.",
     [("A", "weren't / wanted"), ("B", "wasn't / wanted"), ("C", "wasn't / want"), ("D", "didn't / wanted")]),
    ("My brother doesn't like vegetables but he ______ fruit.",
     [("A", "like"), ("B", "is liking"), ("C", "likes"), ("D", "liked")]),
    ("This cake smells ______. Did you put cinnamon in it?",
     [("A", "like wonderful"), ("B", "wonderfully"), ("C", "like cinnamon"), ("D", "wonderful")]),
    ("My mother never ______ coffee in the morning, but yesterday she ______ two cups.",
     [("A", "drink / drank"), ("B", "drinks / drank"), ("C", "drinks / drink"), ("D", "drank / drinks")]),
    ("We ______ buy any bread because there ______ enough at home.",
     [("A", "don't have to / is"), ("B", "didn't have to / was"), ("C", "doesn't have to / were"), ("D", "didn't have to / were")]),
    ("A: Do you play any musical instruments?\n    B: No, but I ______ sing very well. I'm in the school choir.",
     [("A", "do"), ("B", "can"), ("C", "am"), ("D", "have")]),
    ("There are ______ oranges in the basket. We can make juice.",
     [("A", "a lot of"), ("B", "much"), ("C", "a little"), ("D", "any")]),
    ("She ______ her homework before she ______ to bed every night.",
     [("A", "do / go"), ("B", "does / goes"), ("C", "does / go"), ("D", "did / went")]),
    ("Yesterday the weather ______ sunny in the morning, but it ______ rainy in the afternoon.",
     [("A", "is / is"), ("B", "was / was"), ("C", "is / was"), ("D", "was / is")]),
    ("I don't have ______ money with me. Can you lend me ______?",
     [("A", "some / any"), ("B", "any / some"), ("C", "any / any"), ("D", "some / some")]),
    ("A: ______ Tim and Sue at school yesterday?\n    B: No, they ______. They went to the doctor.",
     [("A", "Was / wasn't"), ("B", "Were / weren't"), ("C", "Did / didn't"), ("D", "Were / wasn't")]),
    ("She wants ______ a doctor when she grows up.",
     [("A", "be"), ("B", "to be"), ("C", "being"), ("D", "is")]),
    ("I like ______ in the sea, but today the water is too cold.",
     [("A", "swim"), ("B", "to swimming"), ("C", "swimming"), ("D", "swam")]),
    ("How ______ students are there in your class this year?",
     [("A", "much"), ("B", "many"), ("C", "any"), ("D", "a lot")]),
]

for i, (stem, options) in enumerate(questions_p1, 1):
    add_question(i, stem, options)

doc.add_page_break()

# ===== PART 2: DIALOGUE =====
add_heading("BÖLÜM 2: Diyalog Tamamlama (Soru 31–38)")

questions_p2 = [
    ("Sarah: What did you do last weekend?\n    Tom: I ______ to the new museum with my family.",
     [("A", "go"), ("B", "went"), ("C", "did go"), ("D", "was go")]),
    ("A: ______ your sister like swimming?\n    B: Yes, she ______. She swims every morning.",
     [("A", "Do / does"), ("B", "Does / does"), ("C", "Is / is"), ("D", "Does / likes")]),
    ("Emma: ______ butter do we need for the cake?\n    Mum: About 200 grams.",
     [("A", "How much"), ("B", "How many"), ("C", "How often"), ("D", "How long")]),
    ("Dad: Who ______ the window? It's very cold in here.\n    Tom: I think Tim ______ it. He felt hot.",
     [("A", "open / open"), ("B", "opened / opened"), ("C", "opens / opened"), ("D", "opened / opens")]),
    ("Librarian: I'm sorry, but you ______ eat or drink in the library.\n    Student: I understand. I'll put my sandwich away.",
     [("A", "don't have to"), ("B", "can't"), ("C", "don't"), ("D", "mustn't")]),
    ("A: Can your brother ride a bicycle?\n    B: He ______ when he was five. Now he ______ a motorcycle.",
     [("A", "learns / rides"), ("B", "learned / rides"), ("C", "learned / rode"), ("D", "learns / rode")]),
    ("A: Does your father like cooking?\n    B: Not really. But he ______ eating at restaurants.",
     [("A", "enjoy"), ("B", "enjoys"), ("C", "is enjoying"), ("D", "enjoyed")]),
    ("A: Were you happy with your exam results?\n    B: I ______ happy about Maths, but I ______ sad about Science.",
     [("A", "were / was"), ("B", "were / were"), ("C", "was / were"), ("D", "was / was")]),
]

for i, (stem, options) in enumerate(questions_p2, 31):
    add_question(i, stem, options)

doc.add_page_break()

# ===== PART 3: CLOZE TEST =====
add_heading("BÖLÜM 3: Cloze Test (Soru 39–46)")

add_heading("Metin 1: A Day at the Animal Shelter", size=12)
add_cloze_text("Last Saturday, my friends and I (39) ______ to the animal shelter. We wanted (40) ______ the animals there. There (41) ______ a lot of cats and dogs. My best friend Amy (42) ______ a small white kitten immediately.")

cloze1 = [
    ("39.", [("A", "go"), ("B", "went"), ("C", "are going"), ("D", "were going")]),
    ("40.", [("A", "help"), ("B", "helping"), ("C", "to help"), ("D", "helped")]),
    ("41.", [("A", "was"), ("B", "were"), ("C", "is"), ("D", "are")]),
    ("42.", [("A", "love"), ("B", "loves"), ("C", "loved"), ("D", "loving")]),
]
for qnum, options in cloze1:
    add_question(qnum, "", options)

doc.add_paragraph()

add_heading("Metin 2: Healthy Eating Habits", size=12)
add_cloze_text("Do you eat (43) ______ fruit every day? Experts say we should eat at least five portions. My brother (44) ______ like vegetables at all, but he loves fruit. Yesterday he (45) ______ three apples and two bananas! I think he (46) ______ too much, but he says fruit is always healthy.")

cloze2 = [
    ("43.", [("A", "much"), ("B", "many"), ("C", "any"), ("D", "a")]),
    ("44.", [("A", "don't"), ("B", "doesn't"), ("C", "didn't"), ("D", "isn't")]),
    ("45.", [("A", "eat"), ("B", "eats"), ("C", "ate"), ("D", "eating")]),
    ("46.", [("A", "eat"), ("B", "eats"), ("C", "ate"), ("D", "eating")]),
]
for qnum, options in cloze2:
    add_question(qnum, "", options)

doc.add_page_break()

# ===== PART 4: READING =====
add_heading("BÖLÜM 4: Okuma-Anlama (Soru 47–50)")

add_heading("Metin: The School Trip", size=12)
add_reading_text("Last month, Class 5B went on a school trip to the mountains. The weather was colder than they expected. In the morning, it was sunny and warm, but in the afternoon the temperature dropped and it started to rain. Luckily, the students brought their raincoats and umbrellas.")
add_reading_text("Tom didn't bring his umbrella because he forgot it at home. He felt very cold and wet. His friend Emma gave him her extra jacket. They walked for two hours and saw many interesting plants and birds. The teacher, Mrs. White, told them about the different types of trees in the forest.")
add_reading_text("At lunchtime, they sat under a big tree and ate their sandwiches. Everyone was tired but happy. Tom said it was his favourite trip ever, even though he got wet. \"Next time I will remember my umbrella!\" he said.")

reading_qs = [
    ("47. Where did Class 5B go for their trip?",
     [("A", "To the beach"), ("B", "To the mountains"), ("C", "To a museum"), ("D", "To a zoo")]),
    ("48. What happened to Tom during the trip?",
     [("A", "He lost his jacket"), ("B", "He forgot his umbrella and got wet"), ("C", "He didn't go on the trip"), ("D", "He fell down and hurt himself")]),
    ("49. How was the weather in the afternoon?",
     [("A", "Sunny and warm"), ("B", "Cold and rainy"), ("C", "Colder but sunny"), ("D", "The same as the morning")]),
    ("50. Which of the following is TRUE about the text?",
     [("A", "Tom brought two umbrellas to the trip."), ("B", "The students didn't see any birds during the walk."),
      ("C", "Emma helped Tom by giving him her extra jacket."), ("D", "The trip was only one hour long.")]),
]

for qnum, options in reading_qs:
    add_question(qnum, "", options)

# ===== NEW QUESTION TYPES =====
doc.add_page_break()
add_heading("BÖLÜM 5: İleri Düzey Soru Tipleri (Soru 51–60)")

doc.add_paragraph()
add_heading("5A. 4-Aşamalı Diyalog Tamamlama", size=12)
p = doc.add_paragraph()
run = p.add_run("Aşağıdaki diyalogda boş bırakılan yerleri tamamlayınız.")
run.italic = True
run.font.size = Pt(10)

doc.add_paragraph()

# --- Dialogue 1 ---
add_heading("Diyalog 1: At the Restaurant", size=11)
add_cloze_text("Waiter: Good evening! (51) ____")
add_cloze_text("Emma: Yes, I'd like to see the menu, please.")
add_cloze_text("Waiter: Of course. (52) ____")
add_cloze_text("Emma: I'll have the chicken soup and a garden salad.")
add_cloze_text("Waiter: (53) ____")
add_cloze_text("Emma: Just water, thank you.")
add_cloze_text("Waiter: Great. (54) ____")

dq1 = [
    ("51.", [("A", "Are you hungry?"), ("B", "What do you want?"), ("C", "Can I help you?"), ("D", "Do you like food?")]),
    ("52.", [("A", "What would you like to order?"), ("B", "Why are you here?"), ("C", "How much do you want?"), ("D", "When did you arrive?")]),
    ("53.", [("A", "What about a drink?"), ("B", "Do you want a dessert?"), ("C", "Is the food good?"), ("D", "Can you cook?")]),
    ("54.", [("A", "Please sit anywhere."), ("B", "I'll bring your order shortly."), ("C", "Come back tomorrow."), ("D", "The restaurant is closing.")]),
]
for qnum, options in dq1:
    add_question(qnum, "", options)

doc.add_paragraph()

# --- Dialogue 2 ---
add_heading("Diyalog 2: At the Doctor's Office", size=11)
add_cloze_text("Doctor: Good morning. (55) ____")
add_cloze_text("Tom: I have a terrible headache and I feel very tired.")
add_cloze_text("Doctor: (56) ____")
add_cloze_text("Tom: Since yesterday morning. I couldn't sleep at all last night.")
add_cloze_text("Doctor: Let me check your temperature. (57) ____")
add_cloze_text("Tom: Yes, I played football in the rain on Saturday.")

dq2 = [
    ("55.", [("A", "How old are you?"), ("B", "What's the problem?"), ("C", "What's your name?"), ("D", "Where do you live?")]),
    ("56.", [("A", "How long have you felt like this?"), ("B", "Why didn't you come earlier?"), ("C", "How much does it hurt?"), ("D", "What did you eat today?")]),
    ("57.", [("A", "Did you eat breakfast?"), ("B", "Have you done your homework?"), ("C", "Did you do anything unusual at the weekend?"), ("D", "Can you play football?")]),
]
for qnum, options in dq2:
    add_question(qnum, "", options)

doc.add_paragraph()
add_heading("5B. 'Hangi Soruyu Sormuş Olabilir?'", size=12)
p = doc.add_paragraph()
run = p.add_run("Verilen cevaba göre sorulmuş olabilecek en uygun soruyu bulunuz.")
run.italic = True
run.font.size = Pt(10)

doc.add_paragraph()

reverse_qs = [
    ("58. A: ____\n    B: I usually go swimming and play tennis.",
     [("A", "What do you do at the weekends?"), ("B", "What did you do last weekend?"),
      ("C", "Where is the swimming pool?"), ("D", "Can you play tennis?")]),
    ("59. A: ____\n    B: It was cold and windy all day.",
     [("A", "What's the weather like today?"), ("B", "How was the weather yesterday?"),
      ("C", "Do you like cold weather?"), ("D", "Is it raining now?")]),
    ("60. A: ____\n    B: We went to the old castle and then walked along the river.",
     [("A", "What are you doing now?"), ("B", "Where do you usually go on holiday?"),
      ("C", "What did you do on your trip?"), ("D", "How long did you stay there?")]),
]

for qnum, options in reverse_qs:
    add_question(qnum, "", options)

# ===== ANSWER KEY =====
doc.add_page_break()
add_heading("CEVAP ANAHTARI", size=18)
doc.add_paragraph()

answers = {
    1: "A", 2: "A", 3: "B", 4: "B", 5: "B", 6: "B", 7: "B", 8: "C", 9: "B", 10: "B",
    11: "B", 12: "B", 13: "A", 14: "B", 15: "C", 16: "C", 17: "B", 18: "C", 19: "D", 20: "B",
    21: "B", 22: "B", 23: "A", 24: "B", 25: "B", 26: "B", 27: "B", 28: "B", 29: "C", 30: "B",
    31: "B", 32: "B", 33: "A", 34: "B", 35: "B", 36: "B", 37: "B", 38: "D",
    39: "B", 40: "C", 41: "B", 42: "C", 43: "C", 44: "B", 45: "C", 46: "B",
    47: "B", 48: "B", 49: "B", 50: "C",
    51: "C", 52: "A", 53: "A", 54: "B", 55: "B", 56: "A", 57: "C",
    58: "A", 59: "B", 60: "C",
}

# Table for answer key
table = doc.add_table(rows=11, cols=6)
table.style = 'Light Grid Accent 1'

# Headers
headers = ["Soru", "Cvp", "Soru", "Cvp", "Soru", "Cvp"]
for j, h in enumerate(headers):
    cell = table.rows[0].cells[j]
    cell.text = h
    for p in cell.paragraphs:
        for r in p.runs:
            r.bold = True
            r.font.size = Pt(10)

# Fill rows
rows_data = []
for r in range(0, 60, 6):
    row = []
    for c in range(6):
        q = r + c + 1
        if q <= 60:
            row.append(f"Q{q}: {answers[q]}")
        else:
            row.append("")
    rows_data.append(row)

for i, row_data in enumerate(rows_data):
    for j, val in enumerate(row_data):
        cell = table.rows[i+1].cells[j]
        cell.text = val
        for p in cell.paragraphs:
            for r in p.runs:
                r.font.size = Pt(10)

doc.add_paragraph()

# Trik noktasi summary
add_heading("Trik Nokta Dağılımı", size=13)

trik_data = [
    ("didn't + V1", "Q2, Q5, Q12"),
    ("was/were ayrımı", "Q1, Q3, Q17, Q25, Q27, Q38"),
    ("some / any / a lot of", "Q7, Q8, Q23, Q26, Q43"),
    ("How much / How many", "Q4, Q30, Q33"),
    ("Countable / Uncountable", "Q8, Q16, Q21, Q23, Q41"),
    ("Comparatives", "Q10"),
    ("Senses + like / sıfat", "Q13, Q19"),
    ("want + to + V1", "Q28, Q40"),
    ("like + Ving", "Q29"),
    ("Kalıp çakışması (diyalog)", "Q6, Q17, Q22, Q27, Q32"),
    ("Bağlaç + özne-fiil uyumu", "Q2, Q11, Q18, Q37, Q38"),
    ("Past düzensiz fiiller", "Q9, Q11, Q14, Q20, Q31, Q42, Q45"),
    ("Zaman kayması (Present → Past)", "Q5, Q14, Q20, Q25, Q36, Q46"),
    ("have to / has to", "Q21"),
    ("4-aşamalı diyalog", "Q51–Q57"),
    ("'Hangi soru?' tipi", "Q58–Q60"),
]

trik_table = doc.add_table(rows=len(trik_data)+1, cols=2)
trik_table.style = 'Light Grid Accent 1'
trik_table.rows[0].cells[0].text = "Trik Noktası"
trik_table.rows[0].cells[1].text = "Sorular"
for p in trik_table.rows[0].cells[0].paragraphs:
    for r in p.runs:
        r.bold = True
        r.font.size = Pt(10)
for p in trik_table.rows[0].cells[1].paragraphs:
    for r in p.runs:
        r.bold = True
        r.font.size = Pt(10)

for i, (trik, sorular) in enumerate(trik_data):
    trik_table.rows[i+1].cells[0].text = trik
    trik_table.rows[i+1].cells[1].text = sorular
    for cell in trik_table.rows[i+1].cells:
        for p in cell.paragraphs:
            for r in p.runs:
                r.font.size = Pt(10)

doc.add_paragraph()
p = doc.add_paragraph()
p.alignment = WD_ALIGN_PARAGRAPH.CENTER
run = p.add_run("Hazırlayan: Kuzgun 🦅 | Eduvia KGS Hazırlık Merkezi | 2026")
run.font.size = Pt(10)
run.font.color.rgb = RGBColor(0x88, 0x88, 0x88)
run.italic = True

# Save
out_path = "/root/Akademik/İngilizce/5. Sınıf/KGS2_Trik_Test_60.docx"
doc.save(out_path)
print(f"✅ DOCX saved: {out_path}")
print(f"📄 Size: {os.path.getsize(out_path):,} bytes")
