/* ============================================================
   AI 编程实战 教程 — 统一样式表
   主色调：深蓝 + 浅灰 | 现代技术文档风格
   ============================================================ */

/* ── CSS 变量 ── */
:root {
    --primary: #1a56db;
    --primary-dark: #1e40af;
    --primary-light: #dbeafe;
    --accent: #059669;
    --accent-light: #d1fae5;
    --warning: #d97706;
    --warning-light: #fef3c7;
    --danger: #dc2626;
    --danger-light: #fee2e2;
    --bg: #f8fafc;
    --bg-card: #ffffff;
    --text: #1e293b;
    --text-secondary: #64748b;
    --border: #e2e8f0;
    --code-bg: #1e293b;
    --code-text: #e2e8f0;
    --sidebar-width: 280px;
    --content-max-width: 860px;
    --font-sans: -apple-system, BlinkMacSystemFont, "Segoe UI", "Noto Sans SC", sans-serif;
    --font-mono: "Fira Code", "Cascadia Code", "JetBrains Mono", Consolas, monospace;
}

/* ── 全局样式 ── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html { font-size: 16px; scroll-behavior: smooth; }

body {
    font-family: var(--font-sans);
    background: var(--bg);
    color: var(--text);
    line-height: 1.7;
    -webkit-font-smoothing: antialiased;
}

a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ── 布局 ── */
.layout {
    display: flex;
    min-height: 100vh;
}

/* ── 侧边栏 ── */
.sidebar {
    position: fixed;
    top: 0; left: 0;
    width: var(--sidebar-width);
    height: 100vh;
    background: var(--bg-card);
    border-right: 1px solid var(--border);
    overflow-y: auto;
    padding: 1.5rem;
    z-index: 100;
    transition: transform 0.3s ease;
}

.sidebar-header {
    padding-bottom: 1rem;
    margin-bottom: 1rem;
    border-bottom: 2px solid var(--primary);
}

.sidebar-header h3 { font-size: 1.1rem; color: var(--primary); }
.sidebar-header h3 a { color: inherit; text-decoration: none; }
.sidebar-subtitle { font-size: 0.8rem; color: var(--text-secondary); }

.toc { list-style: none; }

.toc-stage {
    margin-top: 1rem;
    font-size: 0.75rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-secondary);
}

.toc-stage ul { list-style: none; margin-top: 0.3rem; }

.toc-item { margin: 0.2rem 0; }
.toc-item a {
    display: block;
    padding: 0.35rem 0.5rem;
    border-radius: 6px;
    font-size: 0.88rem;
    color: var(--text);
    transition: all 0.15s;
}

.toc-item a:hover { background: var(--primary-light); color: var(--primary); text-decoration: none; }
.toc-item.active a { background: var(--primary); color: #fff; font-weight: 600; }

.sidebar-toggle {
    display: none;
    position: fixed; top: 1rem; left: 1rem; z-index: 200;
    background: var(--primary); color: #fff; border: none;
    padding: 0.5rem 0.8rem; border-radius: 8px;
    font-size: 1.2rem; cursor: pointer;
}

/* ── 主内容区 ── */
.content {
    margin-left: var(--sidebar-width);
    flex: 1;
    max-width: var(--content-max-width);
    padding: 3rem 2.5rem 4rem;
}

/* ── 章节头部 ── */
.chapter-header {
    margin-bottom: 2.5rem;
    padding-bottom: 1.5rem;
    border-bottom: 3px solid var(--primary);
}

.chapter-meta { display: flex; gap: 0.75rem; margin-bottom: 0.75rem; }

.stage-badge, .difficulty-badge {
    display: inline-block;
    padding: 0.2rem 0.7rem;
    border-radius: 20px;
    font-size: 0.8rem;
    font-weight: 600;
}

.stage-1 { background: #dbeafe; color: #1e40af; }
.stage-2 { background: #d1fae5; color: #065f46; }
.stage-3 { background: #fef3c7; color: #92400e; }
.stage-4 { background: #fce7f3; color: #9d174d; }
.difficulty-badge { background: #f1f5f9; color: #475569; }

.chapter-header h1 { font-size: 2rem; color: var(--text); margin: 0.5rem 0; }
.chapter-subtitle { font-size: 1.1rem; color: var(--text-secondary); }

/* ── 通用 section ── */
section { margin: 2.5rem 0; }

section h2 {
    font-size: 1.4rem;
    color: var(--primary-dark);
    margin-bottom: 1rem;
    padding-bottom: 0.4rem;
    border-bottom: 2px solid var(--primary-light);
}

section h3 { font-size: 1.15rem; margin: 1.5rem 0 0.7rem; color: var(--text); }
section h4 { font-size: 1rem; margin: 1rem 0 0.5rem; color: var(--text-secondary); }

/* ── 学习目标 ── */
.learning-objectives {
    background: var(--primary-light);
    border-left: 4px solid var(--primary);
    padding: 1.2rem 1.5rem;
    border-radius: 0 8px 8px 0;
}

.learning-objectives ol { padding-left: 1.5rem; }
.learning-objectives li { margin: 0.4rem 0; }

/* ── 提示词模板 ── */
.template-card {
    background: var(--bg-card);
    border: 2px solid var(--border);
    border-radius: 10px;
    margin: 1.2rem 0;
    overflow: hidden;
}

.template-card h3 {
    background: linear-gradient(135deg, var(--primary-dark), var(--primary));
    color: #fff;
    padding: 0.8rem 1.2rem;
    margin: 0;
    font-size: 0.95rem;
}

.template-body {
    position: relative;
    padding: 1rem;
}

.template-body pre {
    background: var(--code-bg);
    color: var(--code-text);
    padding: 1.2rem;
    border-radius: 8px;
    overflow-x: auto;
    font-family: var(--font-mono);
    font-size: 0.85rem;
    line-height: 1.6;
}

.copy-btn {
    position: absolute;
    top: 1.2rem;
    right: 1.2rem;
    background: rgba(255,255,255,0.15);
    border: 1px solid rgba(255,255,255,0.3);
    color: #fff;
    padding: 0.3rem 0.6rem;
    border-radius: 6px;
    cursor: pointer;
    font-size: 0.9rem;
    opacity: 0.7;
    transition: opacity 0.2s;
}

.copy-btn:hover { opacity: 1; }

/* 代码块 */
.content pre {
    background: var(--code-bg);
    color: var(--code-text);
    padding: 1.2rem;
    border-radius: 8px;
    overflow-x: auto;
    font-family: var(--font-mono);
    font-size: 0.85rem;
    line-height: 1.6;
    margin: 1rem 0;
}

.content code {
    font-family: var(--font-mono);
    font-size: 0.88em;
}

.content p code, .content li code {
    background: var(--primary-light);
    padding: 0.15em 0.4em;
    border-radius: 4px;
    color: var(--primary-dark);
}

/* ── 好/坏提示词框 ── */
.good-prompt, .bad-prompt {
    padding: 1rem 1.2rem;
    border-radius: 8px;
    margin: 0.8rem 0;
}

.good-prompt {
    background: var(--accent-light);
    border-left: 4px solid var(--accent);
}

.bad-prompt {
    background: var(--danger-light);
    border-left: 4px solid var(--danger);
}

.good-prompt .label, .bad-prompt .label {
    font-weight: 700;
    display: block;
    margin-bottom: 0.4rem;
}

/* ── 关键洞察 ── */
.key-insight {
    background: linear-gradient(135deg, #fffbeb, #fef3c7);
    border: 1px solid #f59e0b;
    padding: 1rem 1.2rem;
    border-radius: 8px;
    margin: 1.2rem 0;
}

/* ── 表格 ── */
.comparison-table { overflow-x: auto; margin: 1rem 0; }

table {
    width: 100%;
    border-collapse: collapse;
    background: var(--bg-card);
    border-radius: 8px;
    overflow: hidden;
    border: 1px solid var(--border);
}

th, td { padding: 0.7rem 1rem; text-align: left; border-bottom: 1px solid var(--border); }
th { background: var(--primary-light); color: var(--primary-dark); font-weight: 600; }
tr:last-child td { border-bottom: none; }

/* ── 流程图 ── */
.flow-chart {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 0.5rem;
    padding: 1rem;
    background: var(--bg-card);
    border-radius: 8px;
    margin: 1rem 0;
    font-size: 0.88rem;
}

.flow-step {
    background: var(--primary-light);
    padding: 0.4rem 0.8rem;
    border-radius: 6px;
    font-weight: 500;
}

.flow-step.highlight { background: var(--primary); color: #fff; }
.flow-arrow { color: var(--text-secondary); font-weight: bold; }

/* ── 角色卡片 ── */
.role-cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 1rem; margin: 1rem 0; }

.role-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 1.2rem;
    text-align: center;
}

.role-icon { font-size: 2rem; margin-bottom: 0.5rem; }
.role-card h4 { margin: 0.3rem 0; color: var(--primary); }

/* ── 三层模型 ── */
.three-layer-model { margin: 1rem 0; }

.layer {
    padding: 1rem 1.2rem;
    border-radius: 8px;
    margin: 0.8rem 0;
    border-left: 5px solid;
}

.layer-strategy { background: #eff6ff; border-color: var(--primary); }
.layer-tactics  { background: #f0fdf4; border-color: var(--accent); }
.layer-operation { background: #fffbeb; border-color: var(--warning); }

.layer-example {
    margin-top: 0.5rem;
    padding: 0.5rem 0.8rem;
    background: rgba(0,0,0,0.05);
    border-radius: 6px;
    font-size: 0.9rem;
}

/* ── 技能转变 ── */
.skill-shift { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; margin: 1rem 0; }

.skill-column {
    padding: 1.2rem;
    border-radius: 8px;
}

.skill-column.old { background: var(--danger-light); }
.skill-column.new { background: var(--accent-light); }

.skill-column h4 { margin-bottom: 0.8rem; }
.skill-column ul { padding-left: 1.2rem; }
.skill-column li { margin: 0.3rem 0; font-size: 0.9rem; }

/* ── 反模式 ── */
.antipattern { margin: 1rem 0; padding: 1rem; border-radius: 8px; background: var(--bg-card); border: 1px solid var(--border); }
.antipattern h3 { color: var(--danger); }
.antipattern .bad { background: var(--danger-light); padding: 0.4rem 0.8rem; border-radius: 4px; margin: 0.5rem 0; }
.antipattern .good { background: var(--accent-light); padding: 0.4rem 0.8rem; border-radius: 4px; margin: 0.5rem 0; }

/* ── 坑点 ── */
.pitfall-item {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-left: 4px solid var(--warning);
    padding: 1rem 1.2rem;
    margin: 1rem 0;
    border-radius: 0 8px 8px 0;
}

/* ── 审查清单 ── */
.review-checklist {
    background: var(--accent-light);
    padding: 1rem 1.5rem;
    border-radius: 8px;
    margin: 0.8rem 0;
}

.review-checklist ul { list-style: none; }
.review-checklist li { margin: 0.4rem 0; }

/* ── 小结 ── */
.summary-box {
    background: var(--primary-light);
    padding: 1.2rem 1.5rem;
    border-radius: 8px;
}

.summary-box ul { padding-left: 1.5rem; }
.summary-box li { margin: 0.4rem 0; }

.book-summary {
    background: linear-gradient(135deg, var(--primary-light), #ede9fe);
    border: 2px solid var(--primary);
    text-align: center;
}

.closing { font-size: 1.1rem; font-weight: 600; margin-top: 1rem; color: var(--primary-dark); }

/* ── 工作流步骤 ── */
.workflow-steps { margin: 1rem 0; }

.wf-step {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 0.8rem;
    margin: 0.5rem 0;
    background: var(--bg-card);
    border-radius: 8px;
    border: 1px solid var(--border);
}

.wf-num {
    background: var(--primary);
    color: #fff;
    width: 28px; height: 28px;
    display: flex; align-items: center; justify-content: center;
    border-radius: 50%;
    font-weight: 700;
    font-size: 0.85rem;
    flex-shrink: 0;
}

/* ── 底部导航 ── */
.chapter-footer {
    margin-top: 3rem;
    padding-top: 1.5rem;
    border-top: 2px solid var(--border);
}

.nav-links {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 0.5rem;
}

.nav-links a {
    padding: 0.6rem 1.2rem;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 8px;
    font-weight: 500;
    transition: all 0.2s;
    text-decoration: none;
}

.nav-links a:hover { background: var(--primary-light); border-color: var(--primary); text-decoration: none; }
.nav-home { color: var(--text-secondary); }
.nav-prev::before { content: "← "; }
.nav-next::after { content: " →"; }
.nav-end { color: var(--accent); font-weight: 700; }

/* ── 响应式 ── */
@media (max-width: 1024px) {
    .sidebar { transform: translateX(-100%); }
    .sidebar.open { transform: translateX(0); }
    .sidebar-toggle { display: block; }
    .content { margin-left: 0; padding: 2rem 1.2rem; }

    .skill-shift { grid-template-columns: 1fr; }
    .role-cards { grid-template-columns: 1fr; }
    .flow-chart { flex-direction: column; gap: 0.3rem; }
    .flow-arrow { display: none; }
}

/* ── 首页特殊样式 ── */
.hero {
    text-align: center;
    padding: 4rem 2rem;
    background: linear-gradient(135deg, var(--primary-dark), #312e81);
    color: #fff;
    border-radius: 16px;
    margin-bottom: 2rem;
}

.hero h1 { font-size: 2.4rem; margin-bottom: 0.8rem; }
.hero p { font-size: 1.15rem; opacity: 0.9; max-width: 600px; margin: 0 auto; }

.stage-cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 1.2rem; margin: 1.5rem 0; }

.stage-card {
    background: var(--bg-card);
    border-radius: 12px;
    padding: 1.5rem;
    border: 1px solid var(--border);
    transition: transform 0.2s, box-shadow 0.2s;
}

.stage-card:hover { transform: translateY(-3px); box-shadow: 0 8px 24px rgba(0,0,0,0.1); }

.stage-card .stage-icon { font-size: 2rem; margin-bottom: 0.5rem; }
.stage-card h3 { font-size: 1.1rem; color: var(--primary-dark); }
.stage-card p { color: var(--text-secondary); font-size: 0.9rem; }

.chapter-list { margin: 2rem 0; }

.chapter-item {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 1rem;
    margin: 0.5rem 0;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 10px;
    transition: all 0.15s;
}

.chapter-item:hover { border-color: var(--primary); background: var(--primary-light); text-decoration: none; }

.chapter-num {
    width: 44px; height: 44px;
    background: var(--primary);
    color: #fff;
    display: flex; align-items: center; justify-content: center;
    border-radius: 10px;
    font-weight: 700;
    font-size: 1rem;
    flex-shrink: 0;
}

.chapter-info { flex: 1; }
.chapter-info h4 { font-size: 1rem; margin: 0; color: var(--text); }
.chapter-info p { font-size: 0.85rem; color: var(--text-secondary); margin-top: 0.2rem; }

.prerequisites {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 1.5rem;
    margin: 2rem 0;
}

.prerequisites h3 { margin-top: 0; }
.prerequisites ul { padding-left: 1.5rem; }
.prerequisites li { margin: 0.4rem 0; }
