/* 单据预览弹层（共享组件，供核验页 / 订单上传页 / 批量上传页复用）
 *
 * 口径与「附件中心」预览一致（templates/management/_attachment_panel.html）：
 *   pdf    → iframe，交浏览器 PDF 阅读器翻页
 *   image  → 图片查看器：滚轮缩放、拖拽平移、「− / ＋ / 适应 / 1:1」缩放条、双击切换
 *   text   → 纯文本（textContent 渲染，天然免疫注入）
 *   office → doc/docx 用 mammoth、xls/xlsx 用 SheetJS 在浏览器本地解析（懒加载）
 *   其它   → 提示 + 下载入口
 */

.docpv-modal {
    position: fixed; inset: 0; z-index: 1080;
    display: flex; align-items: center; justify-content: center;
}
/* 必须显式声明：类选择器优先级高于 UA 的 [hidden] */
.docpv-modal[hidden] { display: none; }
.docpv-mask { position: absolute; inset: 0; background: rgba(0, 0, 0, 0.45); }
/* 弹层宽高**一律用百分比**，不要用 vw/vh：本站在 html（核验页 main 再叠一层）上有 zoom，
 * vw/vh 按视口 CSS px 解析后再整体缩放 —— 实测（Chrome 157，视口 1414×800）
 * `min(1040px,94vw)` 只渲染出 936 宽（约 66% 视口）、`min(86vh,900px)` 只渲染出 619 高，
 * 弹层又窄又小，多页 PDF 的可用高度白白少掉一截（旧版 Chrome 的 zoom 实现相反，会顶出视口）。
 * 父层 .docpv-modal 是 fixed + inset:0（按视口实际尺寸撑满，不受缩放影响），
 * 百分比高度在这里是确定值，flex 正文（.docpv-body）才能正确收缩。 */
.docpv-panel {
    position: relative; width: 97.5%; max-width: none; height: calc(100% - 1rem);
    display: flex; flex-direction: column; overflow: hidden;
    background: #fff; border-radius: 0.6rem; box-shadow: 0 18px 48px rgba(0, 0, 0, 0.25);
}
.docpv-head {
    display: flex; align-items: center; justify-content: space-between; gap: 1rem;
    padding: 0.55rem 0.9rem; border-bottom: 1px solid #eceff4;
}
.docpv-title {
    font-size: 0.9rem; font-weight: 600; color: #343a40;
    word-break: break-all; min-width: 0;
}
/* 缩放条 + 下载 + 关闭：窄屏允许换行，避免把标题挤没 */
.docpv-actions {
    display: flex; align-items: center; gap: 0.3rem;
    flex-wrap: wrap; justify-content: flex-end; flex-shrink: 0;
}
.docpv-btn {
    border: 0; background: none; color: #6c757d; font-size: 0.8rem; text-decoration: none;
    padding: 0.25rem 0.45rem; border-radius: 0.35rem; cursor: pointer;
}
.docpv-btn:hover { background: #f2f7ff; color: #0d6efd; }
.docpv-body { flex: 1; min-height: 0; overflow: auto; background: #fafbfd; }
/* 图片模式：不做滚动，靠 transform 缩放 + 拖拽平移 */
.docpv-body.is-image {
    overflow: hidden; display: flex; align-items: center; justify-content: center;
    background: #f2f4f7;
}
.docpv-viewer { position: relative; width: 100%; height: 100%; overflow: hidden; }
.docpv-viewer-img {
    display: block; max-width: none; max-height: none;
    transform-origin: 0 0; cursor: grab; user-select: none;
}
.docpv-viewer-img.is-dragging { cursor: grabbing; }
.docpv-zoombar { display: inline-flex; align-items: center; gap: 0.1rem; margin-right: 0.3rem; }
.docpv-zoombar[hidden] { display: none; }
.docpv-zoom-btn {
    border: 0; background: none; color: #6c757d; font-size: 0.8rem;
    padding: 0.25rem 0.4rem; border-radius: 0.35rem; cursor: pointer;
}
.docpv-zoom-btn:hover { background: #f2f7ff; color: #0d6efd; }
.docpv-zoom-scale { font-size: 0.75rem; color: #6c757d; min-width: 3.1rem; text-align: center; }
/* PDF 专用容器：宽高撑满正文区，zoom 由 base.html 的 fixPreviewZoom() 反向抵消外层缩放。
 * 背景：Chrome 内置 PDF 阅读器（iframe 里的 pdfium）按元素**布局尺寸**量自己的视口，
 * 外层 zoom 会让「布局尺寸 ≠ 可见尺寸」，阅读器以为还能再往下滚 → 最后一页底部被裁且滚不动。
 * 容器自己被缩到 1px 布局 = 1px 设备像素后，两者一致；容器可见尺寸不变。 */
.docpv-host { width: 100%; height: 100%; }
.docpv-frame { display: block; width: 100%; height: 100%; border: 0; }
.docpv-text {
    margin: 0; padding: 1rem; color: #343a40; white-space: pre-wrap; word-break: break-all;
    font-family: ui-monospace, Menlo, Consolas, monospace; font-size: 0.8rem;
}
.docpv-doc { padding: 1.2rem 1.6rem; background: #fff; color: #212529; font-size: 0.88rem; }
.docpv-doc table { border-collapse: collapse; }
.docpv-doc td, .docpv-doc th { border: 1px solid #e9edf3; padding: 0.2rem 0.4rem; }
.docpv-sheet { padding: 0.8rem; }
.docpv-sheet h6 { margin: 0.3rem 0 0.5rem; color: #6c757d; font-weight: 600; font-size: 0.8rem; }
.docpv-sheet table { width: 100%; border-collapse: collapse; background: #fff; font-size: 0.78rem; }
.docpv-sheet td { border: 1px solid #e9edf3; padding: 0.2rem 0.45rem; white-space: nowrap; }
.docpv-state { padding: 2.2rem 1rem; text-align: center; color: #6c757d; font-size: 0.85rem; }
.docpv-state a { color: #0d6efd; }

/* ===== 多文件画廊（同一单据类型可有多份）：左右箭头 + 页码 + 缩略图条 ===== */
.docpv-main { position: relative; flex: 1; min-height: 0; display: flex; }
.docpv-main > .docpv-body { flex: 1; }
.docpv-counter {
    margin-left: auto; margin-right: 0.4rem; flex-shrink: 0;
    padding: 0 0.45rem; border-radius: 999px; font-size: 0.72rem; line-height: 1.7;
    color: #4b5563; background: #f1f5f9; font-variant-numeric: tabular-nums;
}
.docpv-counter[hidden] { display: none; }
.docpv-nav {
    position: absolute; top: 50%; transform: translateY(-50%); z-index: 2;
    width: 34px; height: 60px; padding: 0; border: 0; border-radius: 0.35rem;
    display: flex; align-items: center; justify-content: center; cursor: pointer;
    color: #fff; font-size: 0.95rem;
    background: rgba(15, 23, 42, 0.35);
    transition: background 0.16s ease;
}
.docpv-nav[hidden] { display: none; }
.docpv-nav:hover { background: rgba(15, 23, 42, 0.6); }
.docpv-nav.is-prev { left: 6px; }
.docpv-nav.is-next { right: 6px; }
.docpv-strip {
    flex-shrink: 0; display: flex; align-items: center; gap: 6px;
    padding: 0.4rem 0.6rem; overflow-x: auto;
    border-top: 1px solid #eceff4; background: #fbfcfe;
}
.docpv-strip[hidden] { display: none; }
.docpv-strip-item {
    flex: 0 0 auto; width: 42px; height: 42px; padding: 0; overflow: hidden;
    display: flex; align-items: center; justify-content: center; cursor: pointer;
    border: 1px solid #e3e8ef; border-radius: 0.3rem; background: #fff;
    color: #64748b; font-size: 0.78rem;
}
.docpv-strip-item img { display: block; width: 100%; height: 100%; object-fit: cover; }
.docpv-strip-item:hover { border-color: #93b8f0; color: #0d6efd; }
.docpv-strip-item.is-active { border-color: #0d6efd; box-shadow: 0 0 0 2px rgba(13, 110, 253, 0.18); color: #0d6efd; }
.docpv-strip-idx { font-variant-numeric: tabular-nums; font-weight: 600; }

@media (max-width: 575.98px) {
    .docpv-nav { width: 28px; height: 48px; }
    .docpv-strip-item { width: 36px; height: 36px; }
}

/* 文件名旁的「可预览」小图标按钮（各页面共用同一观感） */
.docpv-open {
    border: 0; background: none; padding: 0; color: inherit; text-align: left;
    text-decoration: underline; text-underline-offset: 2px; cursor: pointer;
}
.docpv-open:hover { color: #0d6efd; }
