#!/usr/bin/env python3
"""
K12C 教师岗位胜任力数字化管理方案 - PPT 生成器
将 presentation.html 转换为精美专业的 PPT
"""

from pptx import Presentation
from pptx.util import Inches, Pt, Emu
from pptx.dml.color import RGBColor
from pptx.enum.text import PP_ALIGN, MSO_ANCHOR
from pptx.enum.shapes import MSO_SHAPE
from pptx.oxml.ns import nsmap
from pptx.oxml import parse_xml
import os
import re

# 路径设置
BASE_DIR = os.path.dirname(os.path.abspath(__file__))
OUTPUT_PATH = os.path.join(BASE_DIR, 'K12C-教师胜任力管理方案.pptx')

# 配色方案
COLORS = {
    'primary': RGBColor(0x25, 0x63, 0xeb),      # 蓝色 #2563eb
    'secondary': RGBColor(0x05, 0x96, 0x69),    # 绿色 #059669
    'accent': RGBColor(0x7c, 0x3a, 0xed),       # 紫色 #7c3aed
    'warning': RGBColor(0xf5, 0x9e, 0x0b),      # 橙色 #f59e0b
    'danger': RGBColor(0xef, 0x44, 0x44),       # 红色 #ef4444
    'text': RGBColor(0x0f, 0x17, 0x2a),         # 深色文字
    'muted': RGBColor(0x64, 0x74, 0x8b),        # 灰色文字
    'white': RGBColor(0xff, 0xff, 0xff),
    'light_bg': RGBColor(0xf8, 0xfa, 0xfc),
    'border': RGBColor(0xe2, 0xe8, 0xf0),
    'dark_bg': RGBColor(0x0f, 0x17, 0x2a),      # 封面背景
}


def hex_to_rgb(hex_str):
    """将 hex 颜色字符串转换为 RGBColor"""
    hex_str = hex_str.lstrip('#')
    return RGBColor(int(hex_str[0:2], 16), int(hex_str[2:4], 16), int(hex_str[4:6], 16))


def create_presentation():
    """创建演示文稿"""
    prs = Presentation()
    prs.slide_width = Inches(13.333)  # 16:9 宽屏
    prs.slide_height = Inches(7.5)
    return prs


def add_cover_slide(prs):
    """添加封面页"""
    slide_layout = prs.slide_layouts[6]  # 空白布局
    slide = prs.slides.add_slide(slide_layout)
    
    # 背景渐变（用深色矩形模拟）
    bg = slide.shapes.add_shape(
        MSO_SHAPE.RECTANGLE, 0, 0, prs.slide_width, prs.slide_height
    )
    bg.fill.solid()
    bg.fill.fore_color.rgb = COLORS['dark_bg']
    bg.line.fill.background()
    
    # 顶部装饰线
    top_line = slide.shapes.add_shape(
        MSO_SHAPE.RECTANGLE, 0, 0, prs.slide_width, Inches(0.06)
    )
    top_line.fill.solid()
    top_line.fill.fore_color.rgb = COLORS['primary']
    top_line.line.fill.background()
    
    # Logo 区域
    logo_box = slide.shapes.add_shape(
        MSO_SHAPE.ROUNDED_RECTANGLE, 
        Inches(6.0), Inches(1.5), Inches(1.2), Inches(1.2)
    )
    logo_box.fill.solid()
    logo_box.fill.fore_color.rgb = RGBColor(0x1e, 0x3a, 0x5f)
    logo_box.line.color.rgb = COLORS['border']
    
    # Logo 文字
    logo_text = slide.shapes.add_textbox(Inches(6.0), Inches(1.8), Inches(1.2), Inches(0.6))
    tf = logo_text.text_frame
    tf.paragraphs[0].text = "K12C"
    tf.paragraphs[0].font.size = Pt(24)
    tf.paragraphs[0].font.bold = True
    tf.paragraphs[0].font.color.rgb = COLORS['white']
    tf.paragraphs[0].alignment = PP_ALIGN.CENTER
    
    # 主标题
    title = slide.shapes.add_textbox(Inches(0.8), Inches(3.0), Inches(11.7), Inches(1.0))
    tf = title.text_frame
    tf.paragraphs[0].text = "教师岗位胜任力数字化管理方案"
    tf.paragraphs[0].font.size = Pt(44)
    tf.paragraphs[0].font.bold = True
    tf.paragraphs[0].font.color.rgb = COLORS['white']
    tf.paragraphs[0].alignment = PP_ALIGN.CENTER
    
    # 副标题
    subtitle = slide.shapes.add_textbox(Inches(0.8), Inches(4.0), Inches(11.7), Inches(0.6))
    tf = subtitle.text_frame
    tf.paragraphs[0].text = "深圳民办 K12 学校解决方案"
    tf.paragraphs[0].font.size = Pt(24)
    tf.paragraphs[0].font.color.rgb = RGBColor(0xa5, 0xb4, 0xfc)
    tf.paragraphs[0].alignment = PP_ALIGN.CENTER
    
    # 分隔线
    divider = slide.shapes.add_shape(
        MSO_SHAPE.RECTANGLE, Inches(5.8), Inches(4.8), Inches(1.6), Pt(3)
    )
    divider.fill.solid()
    divider.fill.fore_color.rgb = COLORS['primary']
    divider.line.fill.background()
    
    # 底部信息
    footer = slide.shapes.add_textbox(Inches(0.8), Inches(5.5), Inches(11.7), Inches(0.4))
    tf = footer.text_frame
    tf.paragraphs[0].text = "科学评估 · 精准发展 · 持续成长"
    tf.paragraphs[0].font.size = Pt(16)
    tf.paragraphs[0].font.color.rgb = RGBColor(0x8b, 0x95, 0xa5)
    tf.paragraphs[0].alignment = PP_ALIGN.CENTER
    
    # 日期
    date_box = slide.shapes.add_textbox(Inches(0.8), Inches(6.2), Inches(11.7), Inches(0.4))
    tf = date_box.text_frame
    tf.paragraphs[0].text = "2024"
    tf.paragraphs[0].font.size = Pt(14)
    tf.paragraphs[0].font.color.rgb = RGBColor(0x6b, 0x72, 0x80)
    tf.paragraphs[0].alignment = PP_ALIGN.CENTER
    
    return slide


def add_section_slide(prs, num, title, subtitle=""):
    """添加章节分隔页"""
    slide_layout = prs.slide_layouts[6]
    slide = prs.slides.add_slide(slide_layout)
    
    # 深色背景
    bg = slide.shapes.add_shape(
        MSO_SHAPE.RECTANGLE, 0, 0, prs.slide_width, prs.slide_height
    )
    bg.fill.solid()
    bg.fill.fore_color.rgb = COLORS['dark_bg']
    bg.line.fill.background()
    
    # 左侧装饰条
    left_bar = slide.shapes.add_shape(
        MSO_SHAPE.RECTANGLE, 0, 0, Inches(0.08), prs.slide_height
    )
    left_bar.fill.solid()
    left_bar.fill.fore_color.rgb = COLORS['primary']
    left_bar.line.fill.background()
    
    # 章节编号（大字背景）
    num_box = slide.shapes.add_textbox(Inches(0.5), Inches(0.8), Inches(4.0), Inches(3.0))
    tf = num_box.text_frame
    tf.paragraphs[0].text = f"0{num}" if num < 10 else str(num)
    tf.paragraphs[0].font.size = Pt(180)
    tf.paragraphs[0].font.bold = True
    tf.paragraphs[0].font.color.rgb = RGBColor(0x30, 0x41, 0x59)
    
    # 章节标题
    title_box = slide.shapes.add_textbox(Inches(1.0), Inches(3.2), Inches(11.0), Inches(1.2))
    tf = title_box.text_frame
    tf.paragraphs[0].text = title
    tf.paragraphs[0].font.size = Pt(48)
    tf.paragraphs[0].font.bold = True
    tf.paragraphs[0].font.color.rgb = COLORS['white']
    
    # 副标题
    if subtitle:
        sub_box = slide.shapes.add_textbox(Inches(1.0), Inches(4.5), Inches(11.0), Inches(0.6))
        tf = sub_box.text_frame
        tf.paragraphs[0].text = subtitle
        tf.paragraphs[0].font.size = Pt(20)
        tf.paragraphs[0].font.color.rgb = RGBColor(0x94, 0xa3, 0xb8)
    
    return slide


def add_content_slide(prs, title, icon_char="●", icon_color=None):
    """添加内容页（通用标题栏）"""
    slide_layout = prs.slide_layouts[6]
    slide = prs.slides.add_slide(slide_layout)
    
    # 白色背景
    bg = slide.shapes.add_shape(
        MSO_SHAPE.RECTANGLE, 0, 0, prs.slide_width, prs.slide_height
    )
    bg.fill.solid()
    bg.fill.fore_color.rgb = COLORS['white']
    bg.line.fill.background()
    
    # 顶部渐变条
    top_bar = slide.shapes.add_shape(
        MSO_SHAPE.RECTANGLE, 0, 0, prs.slide_width, Inches(0.06)
    )
    top_bar.fill.solid()
    top_bar.fill.fore_color.rgb = COLORS['primary']
    top_bar.line.fill.background()
    
    # 标题图标背景
    if icon_color is None:
        icon_color = COLORS['primary']
    
    icon_bg = slide.shapes.add_shape(
        MSO_SHAPE.ROUNDED_RECTANGLE, 
        Inches(0.4), Inches(0.35), Inches(0.5), Inches(0.5)
    )
    icon_bg.fill.solid()
    icon_bg.fill.fore_color.rgb = icon_color
    icon_bg.line.fill.background()
    
    # 标题文字
    title_box = slide.shapes.add_textbox(Inches(1.0), Inches(0.35), Inches(11.0), Inches(0.5))
    tf = title_box.text_frame
    tf.paragraphs[0].text = title
    tf.paragraphs[0].font.size = Pt(28)
    tf.paragraphs[0].font.bold = True
    tf.paragraphs[0].font.color.rgb = COLORS['text']
    
    # 分隔线
    line = slide.shapes.add_shape(
        MSO_SHAPE.RECTANGLE, Inches(0.4), Inches(1.0), Inches(12.5), Pt(2)
    )
    line.fill.solid()
    line.fill.fore_color.rgb = COLORS['border']
    line.line.fill.background()
    
    return slide


def add_bullet_list(slide, items, left, top, width, height, font_size=16, color=None):
    """添加项目符号列表"""
    if color is None:
        color = COLORS['muted']
    
    content_box = slide.shapes.add_textbox(
        Inches(left), Inches(top), Inches(width), Inches(height)
    )
    tf = content_box.text_frame
    tf.word_wrap = True
    
    for i, item in enumerate(items):
        if i == 0:
            p = tf.paragraphs[0]
        else:
            p = tf.add_paragraph()
        p.text = f"• {item}"
        p.font.size = Pt(font_size)
        p.font.color.rgb = color
        p.space_after = Pt(8)
    
    return content_box


def add_card(slide, left, top, width, height, title, content=None, color=None):
    """添加卡片元素"""
    if color is None:
        color = COLORS['primary']
    
    # 卡片背景
    card_bg = slide.shapes.add_shape(
        MSO_SHAPE.ROUNDED_RECTANGLE,
        Inches(left), Inches(top), Inches(width), Inches(height)
    )
    card_bg.fill.solid()
    card_bg.fill.fore_color.rgb = COLORS['white']
    card_bg.line.color.rgb = COLORS['border']
    
    # 顶部色条
    accent_bar = slide.shapes.add_shape(
        MSO_SHAPE.RECTANGLE,
        Inches(left), Inches(top), Inches(width), Inches(0.06)
    )
    accent_bar.fill.solid()
    accent_bar.fill.fore_color.rgb = color
    accent_bar.line.fill.background()
    
    # 标题
    title_box = slide.shapes.add_textbox(
        Inches(left + 0.15), Inches(top + 0.2),
        Inches(width - 0.3), Inches(0.4)
    )
    tf = title_box.text_frame
    tf.paragraphs[0].text = title
    tf.paragraphs[0].font.size = Pt(14)
    tf.paragraphs[0].font.bold = True
    tf.paragraphs[0].font.color.rgb = COLORS['text']
    
    if content:
        content_box = slide.shapes.add_textbox(
            Inches(left + 0.15), Inches(top + 0.6),
            Inches(width - 0.3), Inches(height - 0.8)
        )
        tf = content_box.text_frame
        tf.word_wrap = True
        tf.paragraphs[0].text = content
        tf.paragraphs[0].font.size = Pt(11)
        tf.paragraphs[0].font.color.rgb = COLORS['muted']
    
    return card_bg


def add_image_slide(prs, title, image_path, caption="", icon_color=None):
    """添加图片展示页"""
    slide = add_content_slide(prs, title, icon_color=icon_color)
    
    if os.path.exists(image_path):
        # 计算图片位置（居中，高度限制）
        img_height = Inches(5.0)
        img_left = Inches(1.5)
        
        slide.shapes.add_picture(
            image_path, 
            img_left, 
            Inches(1.2), 
            height=img_height
        )
    
    if caption:
        cap_box = slide.shapes.add_textbox(
            Inches(0.5), Inches(6.5), Inches(12.0), Inches(0.5)
        )
        tf = cap_box.text_frame
        tf.paragraphs[0].text = caption
        tf.paragraphs[0].font.size = Pt(14)
        tf.paragraphs[0].font.color.rgb = COLORS['muted']
        tf.paragraphs[0].alignment = PP_ALIGN.CENTER
    
    return slide


def add_cta_slide(prs):
    """添加行动召唤页"""
    slide_layout = prs.slide_layouts[6]
    slide = prs.slides.add_slide(slide_layout)
    
    # 渐变背景
    bg = slide.shapes.add_shape(
        MSO_SHAPE.RECTANGLE, 0, 0, prs.slide_width, prs.slide_height
    )
    bg.fill.solid()
    bg.fill.fore_color.rgb = COLORS['dark_bg']
    bg.line.fill.background()
    
    # 顶部装饰
    top_line = slide.shapes.add_shape(
        MSO_SHAPE.RECTANGLE, 0, 0, prs.slide_width, Inches(0.06)
    )
    top_line.fill.solid()
    top_line.fill.fore_color.rgb = COLORS['primary']
    top_line.line.fill.background()
    
    # 主标题
    title = slide.shapes.add_textbox(Inches(0.8), Inches(2.2), Inches(11.7), Inches(1.0))
    tf = title.text_frame
    tf.paragraphs[0].text = "开启教师能力管理新篇章"
    tf.paragraphs[0].font.size = Pt(44)
    tf.paragraphs[0].font.bold = True
    tf.paragraphs[0].font.color.rgb = COLORS['white']
    tf.paragraphs[0].alignment = PP_ALIGN.CENTER
    
    # 副标题
    sub = slide.shapes.add_textbox(Inches(0.8), Inches(3.3), Inches(11.7), Inches(0.6))
    tf = sub.text_frame
    tf.paragraphs[0].text = "科学评估 · 精准发展 · 持续成长"
    tf.paragraphs[0].font.size = Pt(20)
    tf.paragraphs[0].font.color.rgb = RGBColor(0xa5, 0xb4, 0xfc)
    tf.paragraphs[0].alignment = PP_ALIGN.CENTER
    
    # 按钮区域
    btn1 = slide.shapes.add_shape(
        MSO_SHAPE.ROUNDED_RECTANGLE,
        Inches(4.5), Inches(4.3), Inches(2.0), Inches(0.6)
    )
    btn1.fill.solid()
    btn1.fill.fore_color.rgb = COLORS['primary']
    btn1.line.fill.background()
    
    btn1_text = slide.shapes.add_textbox(Inches(4.5), Inches(4.4), Inches(2.0), Inches(0.4))
    tf = btn1_text.text_frame
    tf.paragraphs[0].text = "预约 Demo 演示"
    tf.paragraphs[0].font.size = Pt(14)
    tf.paragraphs[0].font.bold = True
    tf.paragraphs[0].font.color.rgb = COLORS['white']
    tf.paragraphs[0].alignment = PP_ALIGN.CENTER
    
    btn2 = slide.shapes.add_shape(
        MSO_SHAPE.ROUNDED_RECTANGLE,
        Inches(6.8), Inches(4.3), Inches(1.6), Inches(0.6)
    )
    btn2.fill.solid()
    btn2.fill.fore_color.rgb = RGBColor(0x1e, 0x3a, 0x5f)
    btn2.line.color.rgb = COLORS['border']
    
    btn2_text = slide.shapes.add_textbox(Inches(6.8), Inches(4.4), Inches(1.6), Inches(0.4))
    tf = btn2_text.text_frame
    tf.paragraphs[0].text = "了解更多"
    tf.paragraphs[0].font.size = Pt(14)
    tf.paragraphs[0].font.color.rgb = COLORS['white']
    tf.paragraphs[0].alignment = PP_ALIGN.CENTER
    
    # 联系信息
    contact = slide.shapes.add_textbox(Inches(0.8), Inches(5.5), Inches(11.7), Inches(0.4))
    tf = contact.text_frame
    tf.paragraphs[0].text = "contact@example.com  |  400-xxx-xxxx"
    tf.paragraphs[0].font.size = Pt(14)
    tf.paragraphs[0].font.color.rgb = RGBColor(0x8b, 0x95, 0xa5)
    tf.paragraphs[0].alignment = PP_ALIGN.CENTER
    
    return slide


def add_thanks_slide(prs):
    """添加感谢页"""
    slide_layout = prs.slide_layouts[6]
    slide = prs.slides.add_slide(slide_layout)
    
    # 深色背景
    bg = slide.shapes.add_shape(
        MSO_SHAPE.RECTANGLE, 0, 0, prs.slide_width, prs.slide_height
    )
    bg.fill.solid()
    bg.fill.fore_color.rgb = COLORS['dark_bg']
    bg.line.fill.background()
    
    # 装饰圆
    circle = slide.shapes.add_shape(
        MSO_SHAPE.OVAL,
        Inches(5.9), Inches(1.5), Inches(1.5), Inches(1.5)
    )
    circle.fill.solid()
    circle.fill.fore_color.rgb = RGBColor(0x1e, 0x3a, 0x5f)
    circle.line.fill.background()
    
    # 感谢文字
    title = slide.shapes.add_textbox(Inches(0.8), Inches(3.3), Inches(11.7), Inches(1.0))
    tf = title.text_frame
    tf.paragraphs[0].text = "感谢聆听"
    tf.paragraphs[0].font.size = Pt(56)
    tf.paragraphs[0].font.bold = True
    tf.paragraphs[0].font.color.rgb = COLORS['white']
    tf.paragraphs[0].alignment = PP_ALIGN.CENTER
    
    # 副标题
    sub = slide.shapes.add_textbox(Inches(0.8), Inches(4.3), Inches(11.7), Inches(0.6))
    tf = sub.text_frame
    tf.paragraphs[0].text = "期待与贵校携手，共建教师发展新生态"
    tf.paragraphs[0].font.size = Pt(20)
    tf.paragraphs[0].font.color.rgb = RGBColor(0xa5, 0xb4, 0xfc)
    tf.paragraphs[0].alignment = PP_ALIGN.CENTER
    
    # 联系信息
    contact = slide.shapes.add_textbox(Inches(0.8), Inches(5.3), Inches(11.7), Inches(1.0))
    tf = contact.text_frame
    tf.paragraphs[0].text = "contact@example.com"
    tf.paragraphs[0].font.size = Pt(16)
    tf.paragraphs[0].font.color.rgb = RGBColor(0x8b, 0x95, 0xa5)
    tf.paragraphs[0].alignment = PP_ALIGN.CENTER
    
    p2 = tf.add_paragraph()
    p2.text = "400-xxx-xxxx"
    p2.font.size = Pt(16)
    p2.font.color.rgb = RGBColor(0x8b, 0x95, 0xa5)
    p2.alignment = PP_ALIGN.CENTER
    
    return slide


def build_presentation():
    """构建完整演示文稿"""
    prs = create_presentation()
    
    # 1. 封面
    add_cover_slide(prs)
    
    # 2. 目录页
    slide = add_content_slide(prs, "目录", icon_color=COLORS['primary'])
    
    toc_items = [
        "01  项目背景与痛点分析",
        "02  解决方案概述",
        "03  核心框架：五维胜任力模型",
        "04  数据采集体系",
        "05  AI 赋能：智能分析与个性化推荐",
        "06  实施路径与预期成果"
    ]
    add_bullet_list(slide, toc_items, 1.0, 1.5, 11.0, 5.0, font_size=22, color=COLORS['text'])
    
    # ===== 第一章：项目背景 =====
    add_section_slide(prs, 1, "项目背景与痛点分析", "行业现状与核心挑战")
    
    # 痛点分析
    slide = add_content_slide(prs, "行业痛点分析", icon_color=COLORS['danger'])
    
    pain_points = [
        ("评估主观化", "缺乏客观数据支撑，评价结果公信力不足"),
        ("数据孤岛", "教学数据、评估数据、成长数据分散在多个系统"),
        ("培训低效", "培训资源投入大但效果难以量化，提升针对性弱"),
        ("人才流失", "优秀教师识别困难，缺乏有效激励与发展通道"),
    ]
    
    for i, (title, desc) in enumerate(pain_points):
        col = i % 2
        row = i // 2
        add_card(slide, 0.5 + col * 6.3, 1.3 + row * 2.8, 5.8, 2.4, title, desc, COLORS['danger'])
    
    # 解决方案概述
    slide = add_content_slide(prs, "解决方案概述", icon_color=COLORS['primary'])
    
    solutions = [
        ("五维胜任力模型", "科学的教师能力评估标准体系", COLORS['primary']),
        ("数字化管理平台", "教师端 + 管理者端双端联动", COLORS['secondary']),
        ("AI 智能分析", "自动化评估、个性化发展建议", COLORS['accent']),
        ("数据驱动决策", "管理驾驶舱、人才四象限热力图", COLORS['warning']),
    ]
    
    for i, (title, desc, color) in enumerate(solutions):
        add_card(slide, 0.5 + i * 3.1, 1.3, 2.9, 1.8, title, desc, color)
    
    # 核心价值
    slide = add_content_slide(prs, "核心价值主张", icon_color=COLORS['secondary'])
    
    values = [
        ("科学化", "基于胜任力模型的标准化评估体系", COLORS['primary']),
        ("智能化", "AI 赋能评估、分析、推荐全流程", COLORS['secondary']),
        ("可视化", "数据看板驱动管理决策", COLORS['warning']),
        ("个性化", "差异化岗位配置与成长路径", COLORS['accent']),
    ]
    
    for i, (title, desc, color) in enumerate(values):
        add_card(slide, 0.5 + i * 3.1, 1.3, 2.9, 2.0, title, desc, color)
    
    # 产品截图页
    add_image_slide(
        prs, "管理者端：管理驾驶舱",
        os.path.join(BASE_DIR, "管理驾驶舱.png"),
        "实时掌握全校教师能力分布、胜任力热力图、人才四象限",
        COLORS['primary']
    )
    
    # ===== 第二章：核心框架 =====
    add_section_slide(prs, 2, "核心框架", "五维胜任力 + 教学成果模型")
    
    # 五维胜任力
    slide = add_content_slide(prs, "五维胜任力模型", icon_color=COLORS['primary'])
    
    competencies = [
        ("1", "专业知识的深度与广度", "学科知识体系、跨学科整合、前沿动态关注", COLORS['primary']),
        ("2", "教学设计与实施能力", "教案设计、课堂管理、教学方法、反思改进", COLORS['secondary']),
        ("3", "协作沟通与家校共育", "同事协作、师生关系、家校沟通、团队贡献", COLORS['accent']),
        ("4", "数字技术应用能力", "信息化工具、多媒体制作、学情分析、线上教学", COLORS['warning']),
        ("5", "持续发展与自我成长", "职业规划、学习培训、教研成果、经验总结", COLORS['danger']),
    ]
    
    for i, (num, title, desc, color) in enumerate(competencies):
        col = i % 5
        add_card(slide, 0.3 + col * 2.5, 1.3, 2.3, 2.2, f"维度{num}: {title}", desc, color)
    
    # 能力画像
    add_image_slide(
        prs, "教师端：讲师能力画像",
        os.path.join(BASE_DIR, "讲师能力画像.png"),
        "五维胜任力雷达图，直观展示个人能力分布与成长方向",
        COLORS['accent']
    )
    
    # 教学成果颗粒化管理
    slide = add_content_slide(prs, "教学成果颗粒化管理", icon_color=COLORS['danger'])
    
    # 左侧：成果数据分层
    add_card(slide, 0.5, 1.3, 5.8, 5.5, "成果数据分层",
             "• 数量维度：课时量 | 任务量 | 产出量\n"
             "• 质量维度：学业成果 | 课堂质量 | 教研质量\n"
             "• 效率维度：进步幅度 | 投入产出比", COLORS['primary'])
    
    # 右侧：教学流程
    add_card(slide, 6.8, 1.3, 5.8, 5.5, "全链路数据采集",
             "• 备课：课件时长、原创度\n"
             "• 授课：出勤率、互动频次\n"
             "• 作业：布置量、难度系数\n"
             "• 批改：及时率、评语率\n"
             "• 反馈：满意度、督课分\n"
             "• 考核：区分度、信效度", COLORS['secondary'])
    
    # 量化公式
    slide = add_content_slide(prs, "教学成果量化公式", icon_color=COLORS['accent'])
    
    formula_box = slide.shapes.add_textbox(Inches(1.0), Inches(2.0), Inches(11.0), Inches(1.5))
    tf = formula_box.text_frame
    tf.paragraphs[0].text = "综合分 = Σ(颗粒指标 × 权重) × 岗位系数"
    tf.paragraphs[0].font.size = Pt(32)
    tf.paragraphs[0].font.bold = True
    tf.paragraphs[0].font.color.rgb = COLORS['primary']
    tf.paragraphs[0].alignment = PP_ALIGN.CENTER
    
    # 权重示例
    weights = [
        ("学业进步率", "35%", COLORS['primary']),
        ("课堂满意度", "25%", COLORS['secondary']),
        ("作业批改质量", "20%", COLORS['accent']),
        ("教研产出", "10%", COLORS['warning']),
        ("数字工具使用", "10%", COLORS['danger']),
    ]
    
    for i, (name, pct, color) in enumerate(weights):
        add_card(slide, 0.5 + i * 2.5, 3.5, 2.3, 1.5, name, pct, color)
    
    # 岗位差异化配置
    slide = add_content_slide(prs, "岗位差异化配置", icon_color=COLORS['warning'])
    
    roles = [
        ("学科教师", "教学力 60%", "学科专业发展路径", "所教班级成绩进步率", COLORS['primary']),
        ("班主任", "协作力 50%", "家校沟通看板", "班级学生满意度", COLORS['secondary']),
        ("年级组长", "发展力 40%", "团队数据分析", "年级整体进步率", COLORS['accent']),
        ("教务主任", "五维均衡", "全校胜任力热力图", "学校教学成果汇总", COLORS['warning']),
    ]
    
    for i, (role, weight, feature, metric, color) in enumerate(roles):
        add_card(slide, 0.4 + i * 3.15, 1.3, 3.0, 5.0, role, 
                 f"胜任力权重: {weight}\n\n特色功能: {feature}\n\n核心成果指标: {metric}", color)
    
    # ===== 第三章：数据采集 =====
    add_section_slide(prs, 3, "数据采集", "多维度数据来源设计")
    
    # 数据采集体系
    slide = add_content_slide(prs, "数据采集体系", icon_color=COLORS['warning'])
    
    # 数据源权重
    weights_data = [
        ("自评", "30%", COLORS['primary']),
        ("上级评价", "30%", COLORS['secondary']),
        ("同僚互评", "20%", COLORS['accent']),
        ("学生反馈", "20%", COLORS['warning']),
    ]
    
    for i, (name, pct, color) in enumerate(weights_data):
        add_card(slide, 0.5 + i * 3.1, 1.3, 2.9, 1.5, name, pct, color)
    
    # 采集流程
    flow_items = [
        ("自评", "10-15分钟", COLORS['primary']),
        ("互评", "5-8分钟/人", COLORS['secondary']),
        ("上级", "8-10分钟", COLORS['accent']),
        ("学生", "3-5分钟", COLORS['warning']),
    ]
    
    for i, (name, time, color) in enumerate(flow_items):
        add_card(slide, 0.5 + i * 3.1, 3.2, 2.9, 1.5, name, time, color)
    
    # ===== 第四章：AI赋能 =====
    add_section_slide(prs, 4, "AI 赋能", "智能分析与个性化推荐")
    
    # AI智能分析
    slide = add_content_slide(prs, "AI 智能分析", icon_color=COLORS['accent'])
    
    ai_features = [
        ("权重计算", COLORS['primary']),
        ("离群检测", COLORS['secondary']),
        ("趋势分析", COLORS['accent']),
        ("个性化推荐", COLORS['warning']),
    ]
    
    for i, (name, color) in enumerate(ai_features):
        add_card(slide, 0.5 + i * 3.1, 1.3, 2.9, 1.5, name, "", color)
    
    # 个性化建议
    add_card(slide, 0.5, 3.2, 12.3, 3.0, "个性化发展建议",
             "短板识别：协作沟通 -15% | 家校互动不足\n"
             "推荐方案：高效家校沟通课 + 跨学科教研小组\n"
             "学习资源：3个视频课程 + 2篇案例", COLORS['secondary'])
    
    # 能力-成果关联
    slide = add_content_slide(prs, "能力-成果关联矩阵", icon_color=COLORS['primary'])
    
    matrix = [
        ("能力强+成果好", "高潜教师 · 标杆培养", COLORS['primary']),
        ("能力强+成果差", "待挖掘 · 潜力未发", COLORS['warning']),
        ("能力弱+成果好", "经验型 · 补强理论", COLORS['secondary']),
        ("能力弱+成果差", "待提升 · 重点帮扶", COLORS['danger']),
    ]
    
    for i, (quadrant, desc, color) in enumerate(matrix):
        add_card(slide, 0.5 + (i % 2) * 6.3, 1.3 + (i // 2) * 2.8, 5.8, 2.4, quadrant, desc, color)
    
    # AI智能建议截图
    add_image_slide(
        prs, "教师端：AI 智能建议",
        os.path.join(BASE_DIR, "教师AI建议.png"),
        "AI 个性化发展建议，智能识别短板并推荐学习资源",
        COLORS['accent']
    )
    
    # 个人发展计划截图
    add_image_slide(
        prs, "教师端：个人发展计划",
        os.path.join(BASE_DIR, "教师个人发展.png"),
        "PDP 个人发展计划，可视化成长轨迹与阶段性目标",
        COLORS['secondary']
    )
    
    # ===== 第五章：实施路径 =====
    add_section_slide(prs, 5, "实施路径与预期成果", "落地步骤与价值实现")
    
    # 实施时间表
    slide = add_content_slide(prs, "实施时间表", icon_color=COLORS['secondary'])
    
    phases = [
        ("第一阶段（第1-2周）", "启动准备", "需求调研、岗位梳理、胜任力模型定制", COLORS['primary']),
        ("第二阶段（第3-4周）", "系统部署", "平台搭建、数据迁移、权限配置", COLORS['secondary']),
        ("第三阶段（第5-6周）", "培训推广", "管理员培训、教师培训、试运行", COLORS['accent']),
        ("第四阶段（第7-8周）", "正式上线", "学期初评估、持续追踪、效果优化", COLORS['warning']),
    ]
    
    for i, (phase, title, desc, color) in enumerate(phases):
        add_card(slide, 0.4 + i * 3.15, 1.3, 3.0, 2.5, f"{phase}\n{title}", desc, color)
    
    # 持续运营
    add_card(slide, 0.4, 4.2, 12.5, 1.8, "持续运营", 
             "数据积累：每学期评估、年度分析、持续改进", COLORS['secondary'])
    
    # 预期成果
    slide = add_content_slide(prs, "预期成果", icon_color=COLORS['primary'])
    
    results = [
        ("85%", "评估覆盖率", "全校教师能力评估全覆盖", COLORS['primary']),
        ("30%", "培训效率提升", "精准培训减少无效投入", COLORS['secondary']),
        ("50%", "人才识别率", "更精准发现高潜教师", COLORS['accent']),
    ]
    
    for i, (num, title, desc, color) in enumerate(results):
        add_card(slide, 0.5 + i * 4.1, 1.3, 3.8, 2.5, f"{num}\n{title}", desc, color)
    
    # 产品功能
    slide = add_content_slide(prs, "产品功能", icon_color=COLORS['accent'])
    
    add_card(slide, 0.5, 1.3, 5.8, 2.5, "教师端", 
             "• 五维能力雷达图\n• AI 个性化建议\n• 个人发展计划(PDP)", COLORS['primary'])
    
    add_card(slide, 6.8, 1.3, 5.8, 2.5, "管理者端", 
             "• 管理驾驶舱\n• 胜任力热力图\n• 人才四象限", COLORS['secondary'])
    
    # 合作方式
    add_card(slide, 0.5, 4.2, 12.3, 2.0, "合作方式",
             "Demo演示（免费） | 试点项目（定制报价） | 全校部署（年度授权）", COLORS['accent'])
    
    # CTA
    add_cta_slide(prs)
    
    # 感谢页
    add_thanks_slide(prs)
    
    # 保存
    prs.save(OUTPUT_PATH)
    print(f"PPT 已生成: {OUTPUT_PATH}")
    return OUTPUT_PATH


if __name__ == '__main__':
    build_presentation()