/* =============================================================
 * 文档 PDF 工具专属共享样式（pdf-tools.css）
 * -------------------------------------------------------------
 * 仅被 /tools/pdf/* 下的工具页面引用，绝不修改公共 common.css。
 * 复用图片/音视频工具共享类的语义变量与组件类（.status/.code-area
 * /.stat-grid/.tool-btn/.opts/.form-tip/.btn-ghost/.dropzone/.progress
 * /.tab-bar 等），并补充 PDF 专属类。旧工具不引用本文件，零风险。
 * ============================================================= */

/* ---- 语义变量（与 image/media-tools.css 保持一致） ---- */
:root {
    --radius: 8px;
    --code-bg: #f6f8fa;
    --code-border: #e3e8ef;
    --tip-bg: rgba(255, 107, 0, 0.10);
    --tip-tx: #b35000;
    --wait-bg: #fff7e6;
    --wait-tx: #8a6100;
    --wait-border: #f3d98a;
    --ok-bg: #e9f8ee;
    --ok-tx: #1d7a3e;
    --ok-border: #a8e0bd;
    --err-bg: #fdecec;
    --err-tx: #c0392b;
    --err-border: #f3b7b1;
    --out-bg: #f6f8fa;
    --out-border: #e3e8ef;
    --sv-hl: #ff6b00;
    --line: #e3e8ef;
    --canvas-bg: #ffffff;
}

[data-theme="dark"] {
    --code-bg: #1b1f24;
    --code-border: #2c333c;
    --tip-bg: rgba(255, 107, 0, 0.16);
    --tip-tx: #ffae6b;
    --wait-bg: #3a3320;
    --wait-tx: #f0c869;
    --wait-border: #5c4f2a;
    --ok-bg: #1c3326;
    --ok-tx: #6bd99a;
    --ok-border: #2e5a44;
    --err-bg: #3a2424;
    --err-tx: #f08a82;
    --err-border: #5c3633;
    --out-bg: #1b1f24;
    --out-border: #2c333c;
    --sv-hl: #ff8a3d;
    --line: #2c333c;
    --canvas-bg: #16191d;
}

@media (prefers-color-scheme: dark) {
    :root:not([data-theme="light"]) {
        --code-bg: #1b1f24;
        --code-border: #2c333c;
        --tip-bg: rgba(255, 107, 0, 0.16);
        --tip-tx: #ffae6b;
        --wait-bg: #3a3320;
        --wait-tx: #f0c869;
        --wait-border: #5c4f2a;
        --ok-bg: #1c3326;
        --ok-tx: #6bd99a;
        --ok-border: #2e5a44;
        --err-bg: #3a2424;
        --err-tx: #f08a82;
        --err-border: #5c3633;
        --out-bg: #1b1f24;
        --out-border: #2c333c;
        --sv-hl: #ff8a3d;
        --line: #2c333c;
        --canvas-bg: #16191d;
    }
}

/* ---- 复用：代码 / 文本域 ---- */
.code-area {
    width: 100%; box-sizing: border-box; min-height: 200px; resize: vertical;
    padding: 12px 14px; border: 1px solid var(--code-border); border-radius: var(--radius-sm);
    background: var(--code-bg); color: var(--text-primary);
    font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, "Courier New", monospace;
    font-size: 13px; line-height: 1.6;
}
.code-area:focus { outline: none; border-color: var(--primary); }

/* ---- 复用：双栏 ---- */
.io-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; margin: 14px 0; }
.io-label { display: flex; justify-content: space-between; align-items: center; font-size: 13px; color: var(--text-secondary); margin-bottom: 6px; }
.io-label .cnt { color: var(--text-secondary); font-size: 12px; }

/* ---- 复用：表单元素 ---- */
.form-item { margin: 12px 0; }
.form-row { display: flex; flex-wrap: wrap; gap: 16px; margin: 12px 0; }
.form-input, .form-select {
    padding: 8px 11px; border: 1px solid var(--border-color); border-radius: var(--radius-sm);
    background: var(--bg-body); color: var(--text-primary); font-size: 14px; box-sizing: border-box;
}
.form-input:focus, .form-select:focus { outline: none; border-color: var(--primary); }
.check-item { display: flex; align-items: center; gap: 7px; font-size: 13px; color: var(--text-primary); cursor: pointer; }
.check-item input { width: 15px; height: 15px; accent-color: var(--primary); }
.field { margin: 12px 0; }
.field > label { display: block; font-size: 13px; color: var(--text-secondary); margin-bottom: 6px; }

/* ---- 复用：统计卡片 ---- */
.stat-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); gap: 12px; margin: 16px 0; }
.stat-card { background: var(--bg-body); border: 1px solid var(--border-color); border-radius: var(--radius-sm); padding: 12px 14px; }
.stat-card .num { font-size: 22px; font-weight: 700; color: var(--text-primary); }
.stat-card .lab { font-size: 12px; color: var(--text-secondary); margin-top: 2px; }
.st-title { font-size: 13px; color: var(--text-secondary); margin: 14px 0 6px; }
.sv { font-weight: 600; } .sv.hl { color: var(--sv-hl); }
.sl { font-size: 12px; color: var(--text-secondary); }
.row-label { font-size: 13px; color: var(--text-secondary); margin-bottom: 6px; }
.cnt { color: var(--text-secondary); font-size: 12px; }
.blue { color: var(--primary); }

/* 面包屑分隔符与当前页（common.css 未定义，分类内补充） */
.tool-breadcrumb .sep { color: var(--text-muted, #9aa4b2); margin: 0 8px; }
.tool-breadcrumb .cur { color: var(--text-primary); font-weight: 600; }

/* ---- 复用：状态提示（三色） ---- */
.status, .status-box {
    display: none; padding: 10px 14px; border-radius: var(--radius-sm);
    font-size: 13px; margin: 12px 0; border: 1px solid transparent; line-height: 1.6;
}
.status.show, .status-box.show { display: block; }
.status.wait, .status-box.wait { background: var(--wait-bg); color: var(--wait-tx); border-color: var(--wait-border); }
.status.ok, .status-box.ok { background: var(--ok-bg); color: var(--ok-tx); border-color: var(--ok-border); }
.status.err, .status-box.err { background: var(--err-bg); color: var(--err-tx); border-color: var(--err-border); }

/* ---- 复用：说明提示框 ---- */
.form-tip {
    background: var(--tip-bg); color: var(--tip-tx); border: 1px solid transparent;
    border-radius: var(--radius-sm); padding: 10px 14px; font-size: 13px; line-height: 1.6; margin: 12px 0;
}
.form-tip code { background: rgba(0,0,0,0.06); padding: 1px 5px; border-radius: 4px; font-size: 12px; }
.form-tip b { color: var(--tip-tx); }

/* ---- 复用：按钮组 / 工具按钮 ---- */
.btn-row, .btn-group { display: flex; gap: 8px; flex-wrap: wrap; margin: 14px 0; }
.btn-ghost {
    display: inline-flex; align-items: center; justify-content: center; padding: 8px 16px;
    border-radius: var(--radius-sm); font-size: 14px; font-weight: 500; cursor: pointer;
    border: 1px solid var(--border-color); background: transparent; color: var(--text-secondary); transition: all 0.2s;
}
.btn-ghost:hover { background: var(--tip-bg); color: var(--primary); border-color: var(--primary); }
.tool-btn {
    display: inline-flex; align-items: center; justify-content: center; padding: 8px 16px;
    border-radius: var(--radius-sm); font-size: 14px; font-weight: 500; cursor: pointer;
    border: 1px solid var(--border-color); background: var(--bg-body); color: var(--text-primary); transition: all 0.2s;
}
.tool-btn:hover { border-color: var(--primary); color: var(--primary); }
.tool-btn.primary { background: var(--primary); color: #fff; border-color: var(--primary); }
.tool-btn.primary:hover { background: var(--primary-dark); border-color: var(--primary-dark); color: #fff; }
.tool-btn.ghost { background: transparent; color: var(--text-secondary); border-color: var(--border-color); }
.tool-btn.ghost:hover { background: var(--tip-bg); color: var(--primary); border-color: var(--primary); }
.tool-btn:disabled { opacity: 0.5; cursor: not-allowed; }

/* ---- 复用：选项 / 模式 ---- */
.opts { display: flex; gap: 18px; margin: 14px 0 18px; padding: 12px 16px; background: var(--bg-body); border: 1px solid var(--border-color); border-radius: var(--radius-sm); flex-wrap: wrap; }
.opt { display: flex; align-items: center; gap: 7px; font-size: 13px; color: var(--text-primary); }
.opt input { width: 15px; height: 15px; accent-color: var(--primary); }
.modes { display: flex; gap: 10px; margin-bottom: 16px; flex-wrap: wrap; }
.mode-item {
    display: flex; align-items: center; gap: 8px; padding: 10px 16px; border: 1px solid var(--border-color);
    border-radius: var(--radius-sm); cursor: pointer; font-size: 14px; color: var(--text-primary);
    background: var(--bg-body); transition: 0.15s;
}
.mode-item:hover { border-color: var(--primary); }
.mode-item input { width: 15px; height: 15px; accent-color: var(--primary); }
.mode-item.checked { border-color: var(--primary); background: var(--tip-bg); color: var(--tip-tx); font-weight: 600; }

/* ---- 复用：结果 / 输出区 ---- */
.result-box {
    background: var(--out-bg); border: 1px solid var(--out-border); border-radius: var(--radius-sm);
    padding: 12px 14px; margin: 12px 0; font-size: 13px; line-height: 1.6; white-space: pre-wrap; word-break: break-all;
}
.badge { font-size: 11px; font-weight: 600; padding: 2px 8px; border-radius: 20px; background: var(--tip-bg); color: var(--tip-tx); }

/* ---- 复用：选项卡 ---- */
.tab-bar { display: flex; gap: 4px; border-bottom: 1px solid var(--border-color); margin: 14px 0 12px; }
.tab-btn { padding: 8px 14px; border: none; background: transparent; color: var(--text-secondary); cursor: pointer; font-size: 14px; border-bottom: 2px solid transparent; }
.tab-btn.active { color: var(--primary); border-bottom-color: var(--primary); font-weight: 600; }
.tab-panel { display: none; } .tab-panel.active { display: block; }
@media (max-width: 768px) {
    .tab-bar { overflow-x: auto; flex-wrap: nowrap; -webkit-overflow-scrolling: touch; scrollbar-width: none; }
    .tab-bar::-webkit-scrollbar { display: none; }
    .tab-btn { white-space: nowrap; flex-shrink: 0; font-size: 13px; padding: 8px 12px; }
}

/* ---- 复用：进度条 ---- */
.progress { height: 10px; background: var(--code-border); border-radius: 20px; overflow: hidden; margin: 14px 0 6px; }
.progress-bar { height: 100%; width: 0%; background: var(--primary); border-radius: 20px; transition: width 0.2s; }
.progress-text { font-size: 12px; color: var(--text-secondary); }

/* ---- 复用：拖拽上传区 ---- */
.dropzone {
    border: 2px dashed var(--border-color); border-radius: var(--radius); background: var(--bg-body);
    padding: 30px 20px; text-align: center; cursor: pointer; transition: 0.15s; margin: 14px 0;
}
.dropzone:hover, .dropzone.drag { border-color: var(--primary); background: var(--tip-bg); }
.dz-icon { font-size: 38px; line-height: 1; margin-bottom: 8px; }
.dz-text { font-size: 15px; color: var(--text-primary); font-weight: 500; }
.dz-text .blue { color: var(--primary); }
.dz-hint { font-size: 12px; color: var(--text-secondary); margin-top: 6px; }

/* =========================================================
 * PDF 工具专属组件
 * ========================================================= */

/* 文件列表（合并 / 拆分 / 水印 / 压缩多文件） */
.pdf-list { display: flex; flex-direction: column; gap: 10px; margin: 14px 0; }
.pdf-item {
    display: flex; align-items: center; gap: 12px; padding: 10px 14px;
    background: var(--bg-body); border: 1px solid var(--border-color); border-radius: var(--radius-sm);
}
.pdf-item .idx {
    flex: 0 0 26px; height: 26px; border-radius: 50%; background: var(--tip-bg); color: var(--tip-tx);
    display: inline-flex; align-items: center; justify-content: center; font-size: 13px; font-weight: 700;
}
.file-info { flex: 1; min-width: 0; }
.file-name { font-size: 14px; color: var(--text-primary); font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.file-meta { font-size: 12px; color: var(--text-secondary); margin-top: 2px; }
.file-actions { display: flex; gap: 6px; flex: 0 0 auto; }
.file-actions button {
    border: 1px solid var(--border-color); background: var(--bg-body); color: var(--text-secondary);
    border-radius: var(--radius-sm); padding: 4px 9px; font-size: 12px; cursor: pointer; transition: 0.15s;
}
.file-actions button:hover:not(:disabled) { border-color: var(--primary); color: var(--primary); }
.file-actions button:disabled { opacity: 0.4; cursor: not-allowed; }
.file-actions button.del:hover:not(:disabled) { border-color: var(--err-tx); color: var(--err-tx); }

/* 缩略图网格（PDF 转图片 / 拆分预览） */
.thumb-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); gap: 12px; margin: 14px 0; }
.thumb {
    border: 1px solid var(--border-color); border-radius: var(--radius-sm); overflow: hidden;
    background: var(--canvas-bg); transition: 0.15s; display: flex; flex-direction: column;
}
.thumb canvas, .thumb img { display: block; width: 100%; height: auto; background:
    linear-gradient(45deg, #e9edf2 25%, transparent 25%),
    linear-gradient(-45deg, #e9edf2 25%, transparent 25%),
    linear-gradient(45deg, transparent 75%, #e9edf2 75%),
    linear-gradient(-45deg, transparent 75%, #e9edf2 75%);
    background-size: 14px 14px; background-position: 0 0, 0 7px, 7px -7px, -7px 0; background-color: var(--canvas-bg);
}
[data-theme="dark"] .thumb canvas, [data-theme="dark"] .thumb img,
:root:not([data-theme="light"]) .thumb canvas, :root:not([data-theme="light"]) .thumb img {
    background:
    linear-gradient(45deg, #2a2f37 25%, transparent 25%),
    linear-gradient(-45deg, #2a2f37 25%, transparent 25%),
    linear-gradient(45deg, transparent 75%, #2a2f37 75%),
    linear-gradient(-45deg, transparent 75%, #2a2f37 75%);
    background-size: 14px 14px; background-position: 0 0, 0 7px, 7px -7px, -7px 0;
}
.thumb .cap { font-size: 12px; color: var(--text-secondary); text-align: center; padding: 5px 4px; border-top: 1px solid var(--border-color); }

/* 水印预览 */
.watermark-preview {
    margin: 14px 0; padding: 18px; border: 1px solid var(--line); border-radius: var(--radius-sm);
    background: var(--canvas-bg); overflow: hidden; position: relative; min-height: 160px;
    display: flex; align-items: center; justify-content: center; color: var(--text-secondary); font-size: 13px;
}

/* 范围输入（拆分） */
.range-input {
    width: 100%; padding: 8px 11px; border: 1px solid var(--border-color); border-radius: var(--radius-sm);
    background: var(--bg-body); color: var(--text-primary); font-size: 14px; box-sizing: border-box;
    font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}
.range-input:focus { outline: none; border-color: var(--primary); }
.range-hint { font-size: 12px; color: var(--text-secondary); margin-top: 6px; }

/* 页面尺寸选择行 */
.size-row { display: flex; gap: 12px; flex-wrap: wrap; align-items: center; margin: 12px 0; }
.size-row .form-select { min-width: 130px; }

/* CSV / Excel 预览表格 */
.excel-grid { margin: 14px 0; max-height: 360px; overflow: auto; border: 1px solid var(--border-color); border-radius: var(--radius-sm); }
.excel-grid table { border-collapse: collapse; width: 100%; font-size: 13px; }
.excel-grid th, .excel-grid td { border: 1px solid var(--border-color); padding: 6px 10px; text-align: left; white-space: nowrap; color: var(--text-primary); }
.excel-grid th { background: var(--code-bg); position: sticky; top: 0; font-weight: 600; }
.excel-grid td { background: var(--bg-body); }
.excel-summary { font-size: 12px; color: var(--text-secondary); margin: 6px 0; }

/* Markdown 预览（MD 转 PDF） */
.md-preview {
    margin: 14px 0; padding: 28px 32px; border: 1px solid var(--border-color); border-radius: var(--radius-sm);
    background: var(--bg-body); color: var(--text-primary); line-height: 1.75; font-size: 15px; min-height: 200px;
}
.md-preview h1, .md-preview h2, .md-preview h3 { color: var(--text-primary); line-height: 1.35; margin: 1.1em 0 0.5em; }
.md-preview h1 { font-size: 1.7em; border-bottom: 2px solid var(--border-color); padding-bottom: 0.3em; }
.md-preview h2 { font-size: 1.4em; border-bottom: 1px solid var(--border-color); padding-bottom: 0.25em; }
.md-preview h3 { font-size: 1.18em; }
.md-preview p { margin: 0.7em 0; }
.md-preview code { background: var(--code-bg); padding: 2px 6px; border-radius: 4px; font-size: 0.9em; font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; }
.md-preview pre { background: var(--code-bg); padding: 14px 16px; border-radius: var(--radius-sm); overflow: auto; }
.md-preview pre code { background: none; padding: 0; }
.md-preview blockquote { border-left: 4px solid var(--primary); margin: 0.8em 0; padding: 0.2em 1em; color: var(--text-secondary); background: var(--code-bg); }
.md-preview table { border-collapse: collapse; width: 100%; margin: 0.8em 0; }
.md-preview th, .md-preview td { border: 1px solid var(--border-color); padding: 7px 11px; }
.md-preview th { background: var(--code-bg); }
.md-preview img { max-width: 100%; }
.md-preview ul, .md-preview ol { padding-left: 1.6em; margin: 0.6em 0; }
.md-preview a { color: var(--primary); }
.md-empty { color: var(--text-secondary); font-size: 14px; }

/* 下载链接 */
.dl-link { display: inline-flex; align-items: center; gap: 6px; color: var(--primary); font-size: 13px; text-decoration: none; cursor: pointer; }
.dl-link:hover { text-decoration: underline; }

/* 文本域（通用） */
.text-area {
    width: 100%; min-height: 160px; resize: vertical; padding: 12px 14px;
    border: 1px solid var(--border-color); border-radius: var(--radius-sm);
    background: var(--bg-body); color: var(--text-primary); font-size: 14px; line-height: 1.7; box-sizing: border-box; font-family: inherit;
}
.text-area:focus { outline: none; border-color: var(--primary); }

.hidden { display: none !important; }
.full-width { width: 100%; }
.center { text-align: center; }

/* Markdown 转 PDF：打印时只保留预览区 */
@media print {
    .site-header, .sidebar, .site-footer, .tool-breadcrumb, .sidebar-toggle,
    .form-tip, .btn-row, .btn-group, .opts, .tab-bar, .dropzone, .progress, .status, .status-box {
        display: none !important;
    }
    .tool-content-card { box-shadow: none !important; border: none !important; padding: 0 !important; }
    .md-preview { border: none !important; padding: 0 !important; margin: 0 !important; }
    body { background: #fff !important; }
}

@media (max-width: 768px) {
    .io-grid { grid-template-columns: 1fr; }
}
