/**
 * 文档预览保护器 - 前端样式（百度文库式）
 */

.dvp-viewer-container {
    position: relative;
    width: 100%;
    margin: 20px 0;
    border: 1px solid #e5e7eb;
    border-radius: 10px;
    overflow: hidden;
    background: #f2f3f5;
    user-select: none;
    -webkit-user-select: none;
    -moz-user-select: none;
    box-shadow: 0 1px 3px rgba(0, 0, 0, .05);
}

/* ---------- 文库式工具栏 ---------- */
.dvp-toolbar {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 14px;
    background: #fff;
    border-bottom: 1px solid #e8eaed;
}

.dvp-toolbar-icon {
    flex: none;
    width: 28px;
    height: 28px;
    border-radius: 6px;
    background: #e8f0fe;
    color: #1a56db;
    display: flex;
    align-items: center;
    justify-content: center;
}

.dvp-toolbar-title {
    flex: 1;
    min-width: 0;
    font-size: 14px;
    font-weight: 600;
    color: #1f2329;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* ---------- 工具栏页码（当前页 / 总页数，由前端渲染后回填） ---------- */
.dvp-toolbar-pages {
    flex: none;
    display: inline-flex;
    align-items: baseline;
    padding: 3px 11px;
    border-radius: 999px;
    background: #eef2f7;
    color: #6b7280;
    font-size: 12px;
    font-weight: 600;
    line-height: 1.5;
    letter-spacing: .3px;
    white-space: nowrap;
    font-variant-numeric: tabular-nums;
    font-feature-settings: "tnum";
}

/* 必须显式声明：.dvp-toolbar-pages 的 display 会盖掉 [hidden] 的默认 display:none */
.dvp-toolbar-pages[hidden] {
    display: none;
}

.dvp-page-cur {
    font-size: 15px;
    color: #1a56db;
    margin-right: 1px;
}

.dvp-page-sep {
    color: #b6bec9;
    margin: 0 2px;
}

/* ---------- 预览画布 ---------- */
.dvp-panes {
    position: relative;
}

.dvp-pane {
    display: none;
    line-height: 0;
}

.dvp-pane.is-active {
    display: block;
}

.dvp-viewer-container iframe,
.dvp-viewer-container embed,
.dvp-viewer-container object {
    width: 100%;
    height: 800px;
    display: block;
    border: none;
}

/* ---------- PDF 分页视图（PDF.js 渲染的 canvas，按需渲染） ---------- */
.dvp-pdf-scroll {
    height: 800px;
    overflow-y: auto;
    overflow-x: hidden;
    background: #f2f3f5;
    -webkit-overflow-scrolling: touch;
}

.dvp-pdf-pages {
    padding: 28px 16px 48px;
    font-size: 0;
}

/* 未渲染时是占位空块（高度已按页尺寸预留，滚动条长度从一开始就正确） */
.dvp-pdf-slot {
    display: block;
    font-size: 0;
}

.dvp-pdf-canvas {
    display: block;
    margin: 0 auto;
    background: #fff;
    box-shadow: 0 1px 2px rgba(0, 0, 0, .1), 0 6px 20px rgba(0, 0, 0, .08);
    border-radius: 2px;
}

/* ---------- 多文档标签页（序号 01/02/03） ---------- */
.dvp-tabs {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    padding: 10px 14px;
    background: #fff;
    border-bottom: 1px solid #e8eaed;
    overflow-x: auto;
}

.dvp-tab {
    min-width: 52px;
    padding: 6px 14px;
    border: 1px solid #dfe3e8;
    border-radius: 6px;
    background: #f7f8fa;
    color: #4e5969;
    font-size: 14px;
    font-weight: 600;
    line-height: 1.4;
    text-align: center;
    cursor: pointer;
    letter-spacing: .5px;
    transition: background .15s ease, color .15s ease, border-color .15s ease;
}

.dvp-tab:hover {
    border-color: #1a56db;
    color: #1a56db;
    background: #e8f0fe;
}

.dvp-tab.is-active {
    background: #1a56db;
    border-color: #1a56db;
    color: #fff;
    box-shadow: 0 2px 6px rgba(26, 86, 219, .35);
}

/* ---------- 水印 ---------- */
.dvp-watermark {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    pointer-events: none;
    z-index: 1000;
    background: repeating-linear-gradient(
        45deg,
        transparent,
        transparent 100px,
        rgba(0,0,0,0.03) 100px,
        rgba(0,0,0,0.03) 200px
    );
}

.dvp-watermark-text {
    position: absolute;
    color: rgba(0,0,0,0.07);
    font-size: 18px;
    font-weight: bold;
    transform: rotate(-30deg);
    pointer-events: none;
    white-space: nowrap;
    user-select: none;
    -webkit-user-select: none;
}

.dvp-no-copy-hint {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: rgba(0,0,0,0.85);
    color: #fff;
    padding: 15px 25px;
    border-radius: 8px;
    font-size: 16px;
    z-index: 99999;
    display: none;
    text-align: center;
    box-shadow: 0 4px 12px rgba(0,0,0,0.3);
}

/* ---------- 加载 / 错误状态 ---------- */
.dvp-loading,
.dvp-error {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 200px;
    color: #666;
    font-size: 15px;
}
.dvp-error {
    color: #b32d2e;
}

/* ---------- 夜间模式（跟随 DocBook 子主题 body.dark-theme） ---------- */
body.dark-theme .dvp-viewer-container {
    background: #1c2230;
    border-color: #2c3546;
}

body.dark-theme .dvp-toolbar {
    background: #171d29;
    border-bottom-color: #2c3546;
}

body.dark-theme .dvp-toolbar-title {
    color: #cbd5e1;
}

body.dark-theme .dvp-toolbar-icon {
    background: #1e2a44;
    color: #60a5fa;
}

body.dark-theme .dvp-toolbar-pages {
    background: #232b3b;
    color: #94a3b8;
}

body.dark-theme .dvp-page-cur {
    color: #93c5fd;
}

body.dark-theme .dvp-page-sep {
    color: #4b5a72;
}

body.dark-theme .dvp-pdf-scroll {
    background: #1c2230;
}

body.dark-theme .dvp-tabs {
    background: #171d29;
    border-bottom-color: #2c3546;
}

body.dark-theme .dvp-tab {
    background: #232b3b;
    border-color: #34405a;
    color: #cbd5e1;
}

body.dark-theme .dvp-tab:hover {
    border-color: #60a5fa;
    color: #93c5fd;
    background: #1e2a44;
}

body.dark-theme .dvp-tab.is-active {
    background: #2563eb;
    border-color: #2563eb;
    color: #fff;
}
