/**
 * 文档阅读页（纯HTML版）样式
 * 文件：view_pdf_html.css
 * 说明：配合 view_pdf_html.php 使用，无 canvas 依赖，适合爬虫与移动端阅读
 */

:root {
    --pdf-bg: #f5f5f5;
    --pdf-page-bg: #ffffff;
    --pdf-text: #1f2937;
    --pdf-primary: #2563eb;
    --pdf-border: #d1d5db;
    --pdf-muted: #6b7280;
    --pdf-topbar-h: 48px;
}

* { box-sizing: border-box; }

body {
    margin: 0;
    background: var(--pdf-bg);
    color: var(--pdf-text);
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC",
                 "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
    font-size: 16px;
    line-height: 1.75;
    word-wrap: break-word;
    word-break: break-word;
    overflow-wrap: break-word;
}

/* ============ 顶部栏 ============ */
.pdf-topbar {
    position: sticky;
    top: 0;
    left: 0;
    width: 100%;
    height: var(--pdf-topbar-h);
    background: #fff;
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.08);
    display: flex;
    align-items: center;
    padding: 0 16px;
    gap: 10px;
    z-index: 100;
}

.pdf-topbar__title {
    flex: 1;
    min-width: 0;
    font-size: 16px;
    font-weight: 600;
    color: #1f2937;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.pdf-topbar a {
    display: inline-flex;
    align-items: center;
    height: 30px;
    padding: 0 14px;
    border-radius: 6px;
    border: 1px solid #e5e7eb;
    background: #fff;
    color: #374151;
    font-size: 13px;
    text-decoration: none;
    white-space: nowrap;
}

.pdf-topbar a:hover {
    background: #f3f4f6;
    border-color: #d1d5db;
}

.pdf-topbar a.btn-primary {
    background: var(--pdf-primary);
    color: #fff;
    border-color: var(--pdf-primary);
}

.pdf-topbar a.btn-primary:hover {
    background: #1d4ed8;
}

/* ============ 内容区 ============ */
.pdf-content {
    max-width: 820px;
    margin: 24px auto;
    padding: 32px 28px 56px;
    background: var(--pdf-page-bg);
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.06);
    border-radius: 4px;
}

.pdf-content h1,
.pdf-content h2,
.pdf-content h3,
.pdf-content h4,
.pdf-content h5,
.pdf-content h6 {
    margin: 1em 0 0.5em;
    font-weight: 700;
    line-height: 1.3;
    color: var(--pdf-text);
}

.pdf-content h1 { font-size: 1.8em; }
.pdf-content h2 { font-size: 1.5em; }
.pdf-content h3 { font-size: 1.3em; }
.pdf-content h4 { font-size: 1.15em; }
.pdf-content h5 { font-size: 1.05em; }
.pdf-content h6 { font-size: 1em; }

.pdf-content p { margin: 0.6em 0; }

.pdf-content ul,
.pdf-content ol {
    padding-left: 1.5em;
    margin: 0.6em 0;
}

.pdf-content li { margin: 0.2em 0; }

.pdf-content blockquote {
    margin: 0.8em 0;
    padding: 0.4em 0.8em;
    border-left: 4px solid var(--pdf-border);
    color: var(--pdf-muted);
    background: rgba(0, 0, 0, 0.02);
}

.pdf-content pre,
.pdf-content code {
    font-family: "SFMono-Regular", Consolas, "Liberation Mono", Menlo, monospace;
    background: rgba(0, 0, 0, 0.05);
    border-radius: 4px;
    padding: 1px 4px;
    font-size: 0.9em;
}

.pdf-content pre {
    padding: 10px;
    overflow-x: auto;
    line-height: 1.5;
}

.pdf-content img {
    max-width: 100%;
    height: auto;
    display: block;
    margin: 0.6em auto;
}

.pdf-content table {
    width: 100%;
    border-collapse: collapse;
    margin: 0.6em 0;
}

.pdf-content table th,
.pdf-content table td {
    border: 1px solid var(--pdf-border);
    padding: 6px 8px;
    text-align: left;
    vertical-align: top;
}

.pdf-content hr {
    border: none;
    border-top: 1px solid var(--pdf-border);
    margin: 1em 0;
}

.pdf-content hr.page-break {
    border-top: 1px dashed var(--pdf-border);
}

.pdf-content a {
    color: var(--pdf-primary);
    text-decoration: none;
}

.pdf-content a:hover { text-decoration: underline; }

/* 文本对齐与样式（对应 canvas-editor 内联样式 class） */
.pdf-content .text-center { text-align: center; }
.pdf-content .text-right  { text-align: right; }
.pdf-content .text-bold   { font-weight: 700; }
.pdf-content .text-italic { font-style: italic; }

/* 白色字体反色处理（原 canvas 背景可能为深色） */
.pdf-content [style*="color: rgb(255, 255, 255)"],
.pdf-content [style*="color:rgb(255,255,255)"],
.pdf-content [style*="color:#fff"],
.pdf-content [style*="color:#ffffff"],
.pdf-content [style*="color: #fff"],
.pdf-content [style*="color: #ffffff"] {
    color: #111 !important;
}

/* ============ 空状态 ============ */
.pdf-empty {
    text-align: center;
    color: var(--pdf-muted);
    padding: 60px 20px;
    font-size: 15px;
}

/* ============ 移动端适配 ============ */
@media (max-width: 768px) {
    :root { --pdf-topbar-h: 44px; }

    .pdf-topbar { padding: 0 10px; gap: 6px; }
    .pdf-topbar__title { font-size: 15px; }
    .pdf-topbar a {
        height: 28px;
        padding: 0 10px;
        font-size: 12px;
        border-radius: 5px;
    }
    .pdf-topbar a.btn-list { display: none; }

    .pdf-content {
        margin: 0;
        padding: 18px 16px 48px;
        border-radius: 0;
        box-shadow: none;
    }
}

@media (max-width: 400px) {
    .pdf-topbar__title { font-size: 14px; }
    .pdf-topbar a { padding: 0 8px; font-size: 11px; }
}

/* ============ 打印优化 ============ */
@media print {
    .pdf-topbar { display: none; }
    .pdf-content {
        margin: 0;
        padding: 0;
        box-shadow: none;
    }
}
