#!/usr/bin/env python3
"""羚牛数智中心建设规划 — 赛博朋克风格 PPT"""

from pptx import Presentation
from pptx.util import Inches, Pt
from pptx.dml.color import RGBColor
from pptx.enum.text import PP_ALIGN, MSO_ANCHOR
from pptx.enum.shapes import MSO_SHAPE

OUT = "/Users/sylvawong/Desktop/羚牛数智中心建设规划_赛博朋克.pptx"

# 赛博朋克配色
BG_DARK = RGBColor(6, 10, 28)
BG_PANEL = RGBColor(12, 18, 48)
CYAN = RGBColor(0, 245, 255)
MAGENTA = RGBColor(255, 0, 140)
PURPLE = RGBColor(140, 80, 255)
GOLD = RGBColor(255, 210, 60)
WHITE = RGBColor(235, 245, 255)
SILVER = RGBColor(160, 180, 210)
DIM = RGBColor(90, 110, 150)

SLIDE_W = Inches(13.333)
SLIDE_H = Inches(7.5)


def set_bg(slide, color=BG_DARK):
    slide.background.fill.solid()
    slide.background.fill.fore_color.rgb = color


def add_glow_bar(slide, left, top, width, height, color):
    sh = slide.shapes.add_shape(MSO_SHAPE.RECTANGLE, left, top, width, height)
    sh.fill.solid()
    sh.fill.fore_color.rgb = color
    sh.line.fill.background()
    return sh


def add_corner_accents(slide):
    add_glow_bar(slide, Inches(0), Inches(0), Inches(0.12), SLIDE_H, CYAN)
    add_glow_bar(slide, SLIDE_W - Inches(0.08), Inches(0), Inches(0.08), SLIDE_H, MAGENTA)
    add_glow_bar(slide, Inches(0), SLIDE_H - Inches(0.06), SLIDE_W, Inches(0.06), PURPLE)


def add_header(slide, title, subtitle=None):
    add_corner_accents(slide)
    add_glow_bar(slide, Inches(0.8), Inches(1.05), Inches(3.5), Pt(4), CYAN)
    tb = slide.shapes.add_textbox(Inches(0.8), Inches(0.45), Inches(11.5), Inches(0.9))
    p = tb.text_frame.paragraphs[0]
    p.text = title
    p.font.size = Pt(32)
    p.font.bold = True
    p.font.color.rgb = WHITE
    if subtitle:
        tb2 = slide.shapes.add_textbox(Inches(0.8), Inches(1.15), Inches(11), Inches(0.5))
        p2 = tb2.text_frame.paragraphs[0]
        p2.text = subtitle
        p2.font.size = Pt(14)
        p2.font.color.rgb = CYAN


def add_bullets(slide, items, top=Inches(1.6), left=Inches(0.9), width=Inches(11.2)):
    tb = slide.shapes.add_textbox(left, top, width, Inches(5.2))
    tf = tb.text_frame
    tf.word_wrap = True
    for i, (text, accent) in enumerate(items):
        p = tf.paragraphs[0] if i == 0 else tf.add_paragraph()
        p.text = "▸  " + text
        p.font.size = Pt(16 if len(text) < 80 else 14)
        p.font.color.rgb = accent if accent else SILVER
        p.space_after = Pt(10)
        p.level = 0


def add_cards(slide, cards, top=Inches(1.7)):
    n = len(cards)
    gap = Inches(0.25)
    w = (Inches(11.5) - gap * (n - 1)) / n
    for i, (title, body, color) in enumerate(cards):
        left = Inches(0.8) + (w + gap) * i
        panel = slide.shapes.add_shape(MSO_SHAPE.ROUNDED_RECTANGLE, left, top, w, Inches(4.8))
        panel.fill.solid()
        panel.fill.fore_color.rgb = BG_PANEL
        panel.line.color.rgb = color
        panel.line.width = Pt(1.5)
        tb = slide.shapes.add_textbox(left + Inches(0.2), top + Inches(0.25), w - Inches(0.4), Inches(4.3))
        tf = tb.text_frame
        tf.word_wrap = True
        p0 = tf.paragraphs[0]
        p0.text = title
        p0.font.size = Pt(18)
        p0.font.bold = True
        p0.font.color.rgb = color
        p1 = tf.add_paragraph()
        p1.text = body
        p1.font.size = Pt(12)
        p1.font.color.rgb = SILVER
        p1.space_before = Pt(12)


def slide_title(prs):
    slide = prs.slides.add_slide(prs.slide_layouts[6])
    set_bg(slide)
    add_corner_accents(slide)
    # 装饰线网格感
    for x in range(3):
        add_glow_bar(slide, Inches(0.5 + x * 4), Inches(2.2), Inches(0.02), Inches(3), RGBColor(30, 50, 90))
    add_glow_bar(slide, Inches(1.2), Inches(3.8), Inches(10.8), Pt(2), MAGENTA)

    tb = slide.shapes.add_textbox(Inches(0.9), Inches(1.8), Inches(11.5), Inches(1.2))
    p = tb.text_frame.paragraphs[0]
    p.text = "羚牛数智中心"
    p.font.size = Pt(48)
    p.font.bold = True
    p.font.color.rgb = CYAN
    p.alignment = PP_ALIGN.CENTER

    tb2 = slide.shapes.add_textbox(Inches(0.9), Inches(2.9), Inches(11.5), Inches(0.8))
    p2 = tb2.text_frame.paragraphs[0]
    p2.text = "建设规划报告"
    p2.font.size = Pt(36)
    p2.font.color.rgb = WHITE
    p2.alignment = PP_ALIGN.CENTER

    tb3 = slide.shapes.add_textbox(Inches(0.9), Inches(4.2), Inches(11.5), Inches(0.6))
    p3 = tb3.text_frame.paragraphs[0]
    p3.text = "LINGNIU DIGITAL INTELLIGENCE CENTER  ·  V1.0"
    p3.font.size = Pt(14)
    p3.font.color.rgb = MAGENTA
    p3.alignment = PP_ALIGN.CENTER

    tb4 = slide.shapes.add_textbox(Inches(0.9), Inches(5.2), Inches(11.5), Inches(0.8))
    p4 = tb4.text_frame.paragraphs[0]
    p4.text = "羚牛氢能 One OS  ·  氢能交通的商业操作系统"
    p4.font.size = Pt(16)
    p4.font.color.rgb = GOLD
    p4.alignment = PP_ALIGN.CENTER


def build(prs):
    # 1 背景
    s = prs.slides.add_slide(prs.slide_layouts[6])
    set_bg(s)
    add_header(s, "一、报告背景与目标", "REPORT BACKGROUND & OBJECTIVES")
    add_bullets(
        s,
        [
            ("业务规模扩大，人工台账与分散系统模式难以为继", None),
            ("数据分散 · 流程依赖人工 · 单点建设难复用 · 多能源场景难支撑", MAGENTA),
            ("建设统一「数智中心」是稳定运营与战略发展的必然选择", CYAN),
        ],
    )

    # 2 痛点
    s = prs.slides.add_slide(prs.slide_layouts[6])
    set_bg(s)
    add_header(s, "现状痛点", "CURRENT CHALLENGES")
    add_cards(
        s,
        [
            ("数据孤岛", "业务数据分散\n难以形成统一视图", CYAN),
            ("流程非标", "依赖人工经验\n标准化与可追溯不足", MAGENTA),
            ("重复建设", "单点需求驱动\n难以复用与扩展", PURPLE),
            ("复杂场景", "多能源多业务并行\n现有模式难支撑", GOLD),
        ],
    )

    # 3 要解决的问题
    s = prs.slides.add_slide(prs.slide_layouts[6])
    set_bg(s)
    add_header(s, "数智中心要解决的问题", "PROBLEMS TO SOLVE")
    add_cards(
        s,
        [
            (
                "当前必须解决",
                "手工台账与人工对账比例高\n业务系统割裂，资产/能源/运维无法贯通\n任务分配追踪依赖人工\n管理决策缺乏数据支撑",
                CYAN,
            ),
            (
                "未来必须应对",
                "业务体量扩大后人效下降\n多能源多业务管理复杂度上升\n无统一平台则系统不可持续\nAI 无法在非标准数据上有效落地",
                MAGENTA,
            ),
        ],
        top=Inches(1.65),
    )

    # 4 四大目标
    s = prs.slides.add_slide(prs.slide_layouts[6])
    set_bg(s)
    add_header(s, "四大建设目标", "CORE OBJECTIVES")
    add_cards(
        s,
        [
            ("稳定运行", "解决手工台账与流程混乱\n支撑当前业务稳定运行", CYAN),
            ("持续演进", "架构灵活，支持未来5年发展\n具备扩展能力", MAGENTA),
            ("数据资产", "数据可沉淀、可复用、可变现\n以平台与数据为核心", PURPLE),
            ("对内对外", "内部降本增效\n对外输出 SaaS 能力", GOLD),
        ],
    )

    # 5 战略定位
    s = prs.slides.add_slide(prs.slide_layouts[6])
    set_bg(s)
    add_header(s, "二、战略定位", "STRATEGIC POSITIONING")
    add_bullets(
        s,
        [
            ("数智中心是羚牛未来 3–5 年最核心的数字基础设施与能力中枢", CYAN),
            ("不是单一 IT 项目，而是公司长期战略资产", WHITE),
            ("构建「羚牛氢能 One OS」— 面向氢能交通的一体化商业操作系统", GOLD),
            ("核心产品：小羚羚 — 统一运营平台与服务终端", MAGENTA),
        ],
        top=Inches(1.7),
    )

    # 6 三步走总览
    s = prs.slides.add_slide(prs.slide_layouts[6])
    set_bg(s)
    add_header(s, "战略阶段：三步走", "THREE-PHASE ROADMAP")
    add_cards(
        s,
        [
            ("Phase 01", "统一 · 标准 · 稳定\n业务在线 · 数据留痕\n筑牢数据底座", CYAN),
            ("Phase 02", "平台化 · 复用 · 协同\n用数据驱动管理\n降本增效可复制", MAGENTA),
            ("Phase 03", "智能化 · 开放 · 商业化\nAI 深度驱动生态\n利润中心转型", GOLD),
        ],
        top=Inches(1.75),
    )

    # 7 Phase 1
    s = prs.slides.add_slide(prs.slide_layouts[6])
    set_bg(s)
    add_header(s, "Phase 01  ·  统一 · 标准 · 稳定", "FOUNDATION")
    add_bullets(
        s,
        [
            ("全面迁移至线上平台：业务在线、数据留痕、流程可控", CYAN),
            ("统一：构建统一运营平台与统一服务终端（小羚羚），打破系统孤岛", None),
            ("标准：建立标准化数据结构、业务流程、接口规范，AI 辅助", None),
            ("稳定：高可用、安全合规，支撑日常业务连续运行", None),
            ("此阶段不追求先进功能，而为数字化与智能化筑牢底座", DIM),
        ],
    )

    # 8 Phase 2
    s = prs.slides.add_slide(prs.slide_layouts[6])
    set_bg(s)
    add_header(s, "Phase 02  ·  平台化 · 复用 · 协同", "PLATFORM")
    add_bullets(
        s,
        [
            ("从「有数据」走向「用数据」— 业务可复制、管理可量化、决策有依据", MAGENTA),
            ("平台化：任务调度、能源管理、资产视图等抽象为平台服务", None),
            ("复用：避免重复建设，新业务快速接入，降低边际成本", None),
            ("协同：打通资产设备、能源、运维、服务，跨部门高效协作", None),
            ("核心价值：降本增效，为规模化扩张提供可复制的运营模板", GOLD),
        ],
    )

    # 9 Phase 3
    s = prs.slides.add_slide(prs.slide_layouts[6])
    set_bg(s)
    add_header(s, "Phase 03  ·  智能化 · 开放 · 商业化", "INTELLIGENCE & ECOSYSTEM")
    add_bullets(
        s,
        [
            ("构建 AI 深度驱动、多方参与、商业闭环的绿色智能生态平台", GOLD),
            ("智能化：AI 从辅助走向决策，运维/调度/安全/财务自主优化", None),
            ("开放：通过 API、SaaS 向能源企业、物流商、装备商输出能力", None),
            ("商业化：平台+服务+数据多元收入，成本中心 → 利润中心", CYAN),
            ("成为氢能交通领域的「操作系统提供商」", MAGENTA),
        ],
    )

    # 10 演进逻辑
    s = prs.slides.add_slide(prs.slide_layouts[6])
    set_bg(s)
    add_header(s, "演进逻辑", "EVOLUTION LOGIC")
    add_cards(
        s,
        [
            ("信息化", "解决「有没有」\n从 0 到 1", CYAN),
            ("数字化", "解决「好不好」\n从 1 到 N", MAGENTA),
            ("智能化", "解决「赚不赚」\n从 N 到 ∞", GOLD),
        ],
        top=Inches(2.0),
    )
    tb = s.shapes.add_textbox(Inches(0.8), Inches(5.5), Inches(11.5), Inches(0.8))
    p = tb.text_frame.paragraphs[0]
    p.text = "成本中心  ──▶  利润中心  ·  数字基础设施驱动绿色交通变革"
    p.font.size = Pt(18)
    p.font.color.rgb = WHITE
    p.alignment = PP_ALIGN.CENTER

    # 11 建设方案
    s = prs.slides.add_slide(prs.slide_layouts[6])
    set_bg(s)
    add_header(s, "三、整体建设方案", "IMPLEMENTATION")
    add_bullets(
        s,
        [
            ("分阶段实施 — 按业务节奏推进，避免一次性重投入", CYAN),
            ("基础优先 — 系统能力先于智能能力", None),
            ("核心内控 — 需求、架构、数据由内部掌控", None),
            ("敏捷迭代 — MVP 验证，快速反馈，持续优化", None),
        ],
        top=Inches(1.65),
    )

    # 12 1+N+X
    s = prs.slides.add_slide(prs.slide_layouts[6])
    set_bg(s)
    add_header(s, "「1 + N + X」核心理念", "ARCHITECTURE PHILOSOPHY")
    add_cards(
        s,
        [
            ("1", "以车辆/设备/能源资产\n为唯一主键\n贯穿全生命周期", CYAN),
            ("N", "覆盖电、氢、充换氢\n储能等多能源形态", MAGENTA),
            ("X", "运营、物流、金融\nESG、碳管理、智能调度", GOLD),
        ],
        top=Inches(1.85),
    )
    add_bullets(
        s,
        [
            ("一车/一设备看全局  ·  一个平台管到底  ·  一套能力可复用、可扩展、可对外输出", WHITE),
        ],
        top=Inches(5.6),
    )

    # 13 封底
    s = prs.slides.add_slide(prs.slide_layouts[6])
    set_bg(s)
    add_corner_accents(s)
    add_glow_bar(s, Inches(2), Inches(3.2), Inches(9.3), Pt(3), CYAN)
    tb = s.shapes.add_textbox(Inches(0.9), Inches(2.5), Inches(11.5), Inches(1.5))
    p = tb.text_frame.paragraphs[0]
    p.text = "羚牛氢能 One OS"
    p.font.size = Pt(44)
    p.font.bold = True
    p.font.color.rgb = CYAN
    p.alignment = PP_ALIGN.CENTER
    tb2 = s.shapes.add_textbox(Inches(0.9), Inches(3.8), Inches(11.5), Inches(1))
    p2 = tb2.text_frame.paragraphs[0]
    p2.text = "连接产业各方  ·  驱动绿色交通变革"
    p2.font.size = Pt(20)
    p2.font.color.rgb = WHITE
    p2.alignment = PP_ALIGN.CENTER
    tb3 = s.shapes.add_textbox(Inches(0.9), Inches(5.0), Inches(11.5), Inches(0.6))
    p3 = tb3.text_frame.paragraphs[0]
    p3.text = "数智中心 · 氢能交通商业操作系统"
    p3.font.size = Pt(14)
    p3.font.color.rgb = MAGENTA
    p3.alignment = PP_ALIGN.CENTER


def main():
    prs = Presentation()
    prs.slide_width = SLIDE_W
    prs.slide_height = SLIDE_H
    slide_title(prs)
    build(prs)
    prs.save(OUT)
    print(f"已生成: {OUT}")
    print(f"共 {len(prs.slides)} 页")


if __name__ == "__main__":
    main()
