/*
 * 资源下载中心 · 文件在线预览
 * ---------------------------------------------------------------
 * 命名空间统一 pv-*，和站点现有点灯箱完全隔离，互不影响。
 * 只在 /resources/ 这一页加载，其它页面零开销。
 *
 * 配色沿用主题 design token（找不到时用后面的兜底色），保证跟整站一个调性。
 */
.pv {
	position: fixed;
	inset: 0;
	z-index: 1000;
	display: flex;
	align-items: center;
	justify-content: center;
	opacity: 0;
	transition: opacity .18s ease;
}
.pv[hidden] { display: none; }
.pv.is-open { opacity: 1; }

.pv__backdrop {
	position: absolute;
	inset: 0;
	background: rgba(12, 20, 36, .62);
	backdrop-filter: blur(2px);
}

.pv__panel {
	position: relative;
	display: flex;
	flex-direction: column;
	width: min(1120px, 94vw);
	height: min(88vh, 900px);
	background: #fff;
	border-radius: 10px 10px 0 0;
	box-shadow: 0 -8px 40px rgba(10, 18, 34, .28);
	transform: translateY(14px);
	transition: transform .2s ease;
	overflow: hidden;
}
.pv.is-open .pv__panel { transform: translateY(0); }

/* ---------- 顶栏 ---------- */
.pv__head {
	display: flex;
	align-items: center;
	gap: 14px;
	padding: 12px 14px;
	border-bottom: 1px solid var(--line, #e6e9ef);
	background: #fff;
	flex: 0 0 auto;
}
.pv__meta { min-width: 0; flex: 1 1 auto; }
.pv__name {
	font-size: 15px;
	font-weight: 600;
	color: var(--ink, #1b2436);
	line-height: 1.4;
	overflow: hidden;
	text-overflow: ellipsis;
	white-space: nowrap;
}
.pv__badges {
	display: flex;
	gap: 8px;
	margin-top: 3px;
	font-size: 12px;
	color: #6b7484;
	font-family: var(--font-num, ui-monospace, monospace);
}
.pv__ext {
	background: rgba(255, 102, 0, .1);
	color: var(--red, #ff6600);
	padding: 1px 6px;
	border-radius: 3px;
	font-weight: 600;
}
.pv__tools { display: flex; align-items: center; gap: 6px; flex: 0 0 auto; }

.pv__btn,
.pv__dl,
.pv__x {
	display: inline-flex;
	align-items: center;
	gap: 4px;
	height: 32px;
	padding: 0 10px;
	border: 1px solid var(--line, #e6e9ef);
	border-radius: 6px;
	background: #fff;
	color: var(--ink, #1b2436);
	font-size: 13px;
	cursor: pointer;
	text-decoration: none;
	transition: border-color .15s, color .15s, background .15s;
}
.pv__btn:hover, .pv__dl:hover { border-color: var(--red, #ff6600); color: var(--red, #ff6600); }
.pv__btn:disabled { opacity: .38; cursor: not-allowed; }
.pv__btn:disabled:hover { border-color: var(--line, #e6e9ef); color: var(--ink, #1b2436); }
.pv__idx {
	font-size: 12.5px;
	color: #6b7484;
	padding: 0 4px;
	font-family: var(--font-num, ui-monospace, monospace);
	white-space: nowrap;
}
.pv__dl { background: var(--navy, #16233f); color: #fff; border-color: var(--navy, #16233f); }
.pv__dl:hover { background: var(--red, #ff6600); border-color: var(--red, #ff6600); color: #fff; }
.pv__x {
	width: 32px;
	padding: 0;
	justify-content: center;
	font-size: 20px;
	line-height: 1;
	color: #6b7484;
}
.pv__x:hover { color: var(--red, #ff6600); border-color: var(--red, #ff6600); }

/* ---------- 内容区 ---------- */
.pv__body {
	flex: 1 1 auto;
	min-height: 0;
	overflow: auto;
	background: #f7f8fa;
	outline: none;
	position: relative;
}

/* ---------- 通用状态 ---------- */
.pv-state {
	display: flex;
	flex-direction: column;
	align-items: center;
	justify-content: center;
	gap: 10px;
	height: 100%;
	min-height: 260px;
	padding: 34px 24px;
	text-align: center;
}
.pv-state__icon { font-size: 34px; line-height: 1; opacity: .85; }
.pv-state__title { font-size: 15.5px; font-weight: 600; color: var(--ink, #1b2436); margin: 0; }
.pv-state__desc { font-size: 13.5px; color: #6b7484; margin: 0; max-width: 460px; line-height: 1.7; }
.pv-state__acts { display: flex; gap: 10px; margin-top: 6px; }

/* 加载中：只有旋转环时不显示文字 */
.pv-state__icon:not(:empty) + .pv-state__title { margin-top: 2px; }
.pv-body--loading .pv-state__icon { animation: pv-spin 1s linear infinite; }
@keyframes pv-spin { to { transform: rotate(360deg); } }

/* ---------- 进度条 ---------- */
.pv-prog {
	position: absolute;
	top: 0; left: 0; right: 0;
	height: 3px;
	background: rgba(22, 35, 63, .08);
	z-index: 2;
}
.pv-prog__bar {
	height: 100%;
	background: var(--red, #ff6600);
	transition: width .2s ease;
}
.pv-note {
	position: absolute;
	top: 14px; left: 50%;
	transform: translateX(-50%);
	font-size: 12.5px;
	color: #6b7484;
	background: #fff;
	border: 1px solid var(--line, #e6e9ef);
	border-radius: 20px;
	padding: 5px 14px;
}
.pv-note--warn { color: #92400e; border-color: #fcd34d; background: #fffbeb; }
.pv-body--loading { position: relative; }
.pv-body--loading .pv-note { position: static; transform: none; margin: 0; border: 0; background: transparent; }

/* ---------- 图片 ---------- */
.pv-body--image, .pv__body:has(.pv-media--img) { background: #eef0f4; }
.pv-media--img {
	display: block;
	max-width: 100%;
	max-height: 100%;
	margin: 0 auto;
	object-fit: contain;
	background: transparent;
}
/* ---------- PDF ---------- */
.pv-media--pdf {
	display: block;
	width: 100%;
	height: 100%;
	border: 0;
	background: #fff;
}
/* ---------- 音视频 ---------- */
.pv-media--video {
	display: block;
	width: 100%;
	max-height: 72vh;
	margin: 0 auto;
	background: #000;
}
.pv-media--audio {
	display: block;
	width: min(560px, 90%);
	margin: 4px auto 24px;
}
.pv-body--audio .pv-state { min-height: 180px; }
/* ---------- 纯文本 / 代码 ---------- */
.pv-body--text { padding: 16px; }
.pv-text {
	margin: 0;
	background: #fff;
	border: 1px solid var(--line, #e6e9ef);
	border-radius: 8px;
	padding: 16px 18px;
	font-family: var(--font-num, ui-monospace, SFMono-Regular, Menlo, Consolas, monospace);
	font-size: 13px;
	line-height: 1.75;
	color: var(--ink, #1b2436);
	white-space: pre-wrap;
	word-break: break-word;
}
/* ---------- DOCX ---------- */
.pv-body--doc { padding: 22px 26px; }
.pv-doc {
	max-width: 780px;
	margin: 0 auto;
	background: #fff;
	padding: 28px 34px;
	border: 1px solid var(--line, #e6e9ef);
	border-radius: 8px;
	font-size: 15px;
	line-height: 1.85;
	color: var(--ink, #1b2436);
}
.pv-doc h1, .pv-doc h2, .pv-doc h3 { margin: 1.2em 0 .5em; line-height: 1.35; }
.pv-doc p { margin: 0 0 1em; }
.pv-doc ul, .pv-doc ol { margin: 0 0 1em; padding-left: 1.6em; }
.pv-doc table { border-collapse: collapse; width: 100%; margin: 1em 0; font-size: 14px; }
.pv-doc td, .pv-doc th { border: 1px solid var(--line, #e6e9ef); padding: 7px 10px; }
.pv-doc img { max-width: 100%; height: auto; }

/* ---------- 表格（Excel） ---------- */
.pv-body--sheet { padding: 0; }
.pv-sheets {
	display: flex;
	gap: 6px;
	overflow-x: auto;
	padding: 10px 12px;
	border-bottom: 1px solid var(--line, #e6e9ef);
	background: #fff;
	position: sticky;
	top: 0;
	z-index: 1;
}
.pv-sheet {
	flex: 0 0 auto;
	height: 28px;
	padding: 0 12px;
	border: 1px solid var(--line, #e6e9ef);
	border-radius: 14px;
	background: #fff;
	font-size: 12.5px;
	color: #6b7484;
	cursor: pointer;
}
.pv-sheet.is-active { background: var(--red, #ff6600); border-color: var(--red, #ff6600); color: #fff; }
.pv-sheetstage { padding: 0; overflow: auto; }
.pv-table { border-collapse: collapse; width: 100%; font-size: 13px; background: #fff; }
.pv-table th, .pv-table td {
	border: 1px solid var(--line, #e6e9ef);
	padding: 7px 10px;
	text-align: left;
	white-space: nowrap;
}
.pv-table thead th {
	position: sticky;
	top: 0;
	background: #f2f4f8;
	font-weight: 600;
	z-index: 1;
}
.pv-table__num {
	background: #f7f8fa;
	color: #98a0b0;
	text-align: right;
	font-family: var(--font-num, ui-monospace, monospace);
}
.pv-table tbody tr:nth-child(even) td { background: #fbfcfe; }

/* ---------- PPT 提纲 ---------- */
.pv-body--ppt { padding: 20px; }
.pv-ppt {
	display: grid;
	grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
	gap: 14px;
	max-width: 1000px;
	margin: 0 auto;
}
.pv-ppt__slide {
	background: #fff;
	border: 1px solid var(--line, #e6e9ef);
	border-radius: 8px;
	padding: 16px 18px;
}
.pv-ppt__no {
	font-size: 11.5px;
	color: #98a0b0;
	font-family: var(--font-num, ui-monospace, monospace);
	margin-bottom: 8px;
}
.pv-ppt__text { font-size: 13.5px; line-height: 1.8; color: var(--ink, #1b2436); word-break: break-word; }

/* ---------- 列表里的预览按钮 ---------- */
.res-item__pv {
	display: inline-flex;
	align-items: center;
	gap: 4px;
	height: 32px;
	padding: 0 10px;
	margin-right: 8px;
	border: 1px solid var(--line, #e6e9ef);
	border-radius: 6px;
	background: #fff;
	color: #4b5563;
	font-size: 13px;
	cursor: pointer;
	text-decoration: none;
	transition: border-color .15s, color .15s;
}
.res-item__pv:hover { border-color: var(--red, #ff6600); color: var(--red, #ff6600); }
/* 文件名本体做成按钮：把浏览器默认按钮外观全部抹平，视觉上和原来一模一样，
   只多一层虚线下划线提示「这个可以点开预览」 */
.res-item__pvname {
	display: inline;
	margin: 0;
	padding: 0;
	border: 0;
	background: none;
	font: inherit;
	color: inherit;
	text-align: left;
	cursor: pointer;
	transition: color .15s;
}
.res-item__pvname.is-pv {
	text-decoration: underline;
	text-decoration-style: dashed;
	text-decoration-color: #c3c9d4;
	text-underline-offset: 3px;
}
.res-item__pvname.is-pv:hover {
	color: var(--red, #ff6600);
	text-decoration-color: var(--red, #ff6600);
}

/* ---------- 窄屏：变成贴底的抽屉 ---------- */
@media (max-width: 780px) {
	.pv__panel {
		width: 100vw;
		height: 92vh;
		border-radius: 0;
	}
	.pv__head { flex-wrap: wrap; gap: 8px; padding: 10px; }
	.pv__meta { flex: 1 1 100%; order: 1; }
	.pv__tools { flex: 1 1 100%; order: 2; justify-content: space-between; }
	.pv__name { white-space: normal; }
	.pv__idx { font-size: 12px; }
	.pv-doc { padding: 18px; }
	.pv-ppt { grid-template-columns: 1fr; }
}

@media (prefers-reduced-motion: reduce) {
	.pv, .pv__panel { transition: none; }
	.pv-body--loading .pv-state__icon { animation: none; }
}
