@media print {
    body {
        font-family: "PingFang SC", "Helvetica Neue", Helvetica, "Hiragino Sans GB", "Microsoft YaHei", Arial, sans-serif;
        font-size: 12pt;
        line-height: 1.5;
        color: #000;
        background: #fff;
        margin: 0;
        padding: 0;
    }
    
    .container {
        max-width: 100%;
        margin: 0;
        padding: 0;
        box-shadow: none;
    }
    
    h1 {
        font-size: 24pt;
        margin: 20pt 0 10pt;
        padding-bottom: 5pt;
        border-bottom: 1pt solid #000;
        page-break-after: avoid;
    }
    
    h2 {
        font-size: 18pt;
        margin: 15pt 0 10pt;
        padding-bottom: 3pt;
        border-bottom: 0.5pt solid #000;
        page-break-after: avoid;
    }
    
    h3 {
        font-size: 14pt;
        margin: 10pt 0 5pt;
        page-break-after: avoid;
    }
    
    p {
        margin: 0 0 5pt;
    }
    
    table {
        width: 100%;
        border-collapse: collapse;
        margin: 10pt 0;
        page-break-inside: auto;
    }
    
    tr {
        page-break-inside: avoid;
        page-break-after: auto;
    }
    
    th, td {
        padding: 5pt;
        text-align: left;
        border: 0.5pt solid #000;
    }
    
    th {
        background-color: #f5f5f5;
        font-weight: bold;
    }
    
    .section {
        margin-bottom: 15pt;
    }
    
    /* 代码块样式优化 */
    .code-block, pre.code-block {
        background-color: #f8f8f8;
        padding: 8pt;
        margin: 8pt 0;
        border: 0.5pt solid #ccc;
        font-family: Consolas, Monaco, 'Andale Mono', monospace;
        font-size: 9pt;
        white-space: pre-wrap;
        page-break-inside: avoid;
        overflow-x: visible;
        line-height: 1.4;
        border-radius: 3pt;
    }
    
    .code-wrap {
        white-space: pre-wrap;
        word-wrap: break-word;
    }
    
    /* 代码高亮颜色 */
    .http, .php, .json {
        color: #333;
    }
    .comment { color: #555; }
    .keyword { color: #222; font-weight: bold; }
    .string { color: #484; }
    .number { color: #555; }
    .operator { color: #666; }
    .function { color: #333; font-weight: bold; }
    
    /* 修正长行代码 */
    .code-block.code-wrap {
        word-break: break-all;
    }
    
    .note, .warning {
        padding: 5pt;
        margin: 5pt 0;
        border-left: 4pt solid #2d8cf0;
        page-break-inside: avoid;
    }
    
    .warning {
        border-left-color: #f56c6c;
    }
    
    /* 添加页码 */
    @page {
        margin: 2cm;
        @bottom-center {
            content: "第 " counter(page) " 页，共 " counter(pages) " 页";
            font-family: "PingFang SC", "Helvetica Neue", Helvetica, "Hiragino Sans GB", "Microsoft YaHei", Arial, sans-serif;
        }
    }
    
    /* 设置首页不显示页码 */
    @page :first {
        @bottom-center {
            content: "";
        }
    }
    
    /* 章节分页 */
    .section {
        page-break-before: auto;
    }
    
    h2 {
        page-break-before: always;
    }
    
    h2:first-of-type {
        page-break-before: avoid;
    }
    
    /* 保证代码块不会溢出页面 */
    pre {
        max-width: 100%;
        overflow-x: hidden;
    }
    
    /* 适配代码样式 */
    code {
        font-family: Consolas, Monaco, 'Andale Mono', monospace;
        font-size: 9pt;
        background-color: #f5f5f5;
        padding: 1pt 2pt;
        border-radius: 2pt;
    }
    
    /* 确保链接在PDF中可点击 */
    a {
        text-decoration: none !important;
        color: #2d8cf0 !important;
    }
    
    /* 确保目录在PDF中正确显示 */
    .toc {
        page-break-after: always;
        background: #f8f9fa !important;
        -webkit-print-color-adjust: exact;
        print-color-adjust: exact;
    }
    
    /* 确保标题在PDF中正确显示 */
    h1, h2, h3 {
        page-break-after: avoid;
        break-after: avoid;
    }
    
    /* 确保内容不会在标题前分页 */
    .section {
        page-break-inside: avoid;
        break-inside: avoid;
    }
    
    /* 优化表格打印 */
    table {
        page-break-inside: auto;
    }
    
    tr {
        page-break-inside: avoid;
        page-break-after: auto;
    }
    
    /* 确保代码块完整显示 */
    .code-block {
        page-break-inside: avoid;
        break-inside: avoid;
        white-space: pre-wrap;
        word-wrap: break-word;
    }
} 