/* ============================================
   PdfRenderer - PDF 渲染器样式
   类名前缀: wk-file-preview-pdf-renderer
   ============================================ */

.wk-file-preview-pdf-renderer {
  display: flex;
  flex-direction: column;
  height: 100%;
  width: 100%;
  overflow: hidden;
  outline: none;
}

/* ============================================
   工具栏
   ============================================ */

.wk-file-preview-pdf-renderer__toolbar {
  display: flex;
  align-items: center;
  gap: var(--wk-sp-4);
  padding: var(--wk-sp-3) var(--wk-sp-4);
  height: var(--wk-sp-12);
  background: var(--wk-brand-tint-04);
  border-bottom: 1px solid var(--wk-brand-tint-15);
  flex-shrink: 0;
}

/* 侧边栏切换按钮 */
.wk-file-preview-pdf-renderer__toolbar-sidebar-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: var(--wk-sp-6);
  height: var(--wk-sp-6);
  border: none;
  background: transparent;
  color: var(--wk-icon-muted);
  border-radius: var(--wk-r-xs);
  cursor: pointer;
  transition: color var(--wk-dur-fast);
  flex-shrink: 0;
}

.wk-file-preview-pdf-renderer__toolbar-sidebar-btn:hover {
  color: var(--wk-text-primary);
}

/* 分隔线 */
.wk-file-preview-pdf-renderer__toolbar-divider {
  width: 1px;
  height: var(--wk-sp-3);
  background: var(--wk-border-default);
  border-radius: var(--wk-r-full);
  flex-shrink: 0;
}

/* 中间区域 */
.wk-file-preview-pdf-renderer__toolbar-center {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex: 1;
}

/* ============================================
   页码导航
   ============================================ */

.wk-file-preview-pdf-renderer__page-nav {
  display: flex;
  align-items: center;
  gap: var(--wk-sp-1);
}

.wk-file-preview-pdf-renderer__page-label {
  font-size: var(--wk-text-size-md);
  font-weight: var(--wk-font-regular);
  line-height: var(--wk-sp-5);
  color: var(--wk-text-primary);
}

.wk-file-preview-pdf-renderer__page-input {
  width: var(--wk-sp-8);
  height: var(--wk-sp-6);
  padding: var(--wk-sp-0-5) var(--wk-sp-1-5);
  border: 1px solid var(--wk-brand-tint-10);
  border-radius: var(--wk-r-sm);
  background: var(--wk-bg-surface);
  color: var(--wk-text-primary);
  font-size: var(--wk-text-size-md);
  font-weight: var(--wk-font-regular);
  text-align: center;
  outline: none;
}

.wk-file-preview-pdf-renderer__page-input:focus {
  border-color: var(--wk-brand-primary);
}

/* ============================================
   缩放控制
   ============================================ */

.wk-file-preview-pdf-renderer__zoom-controls {
  display: flex;
  align-items: center;
  gap: var(--wk-sp-2);
}

/* 缩放胶囊按钮 */
.wk-file-preview-pdf-renderer__zoom-capsule {
  display: flex;
  align-items: center;
  gap: var(--wk-sp-1);
  height: var(--wk-sp-6);
  padding: var(--wk-sp-1-5) var(--wk-sp-3);
  background: var(--wk-bg-surface);
  border: 1px solid var(--wk-brand-tint-10);
  border-radius: var(--wk-r-full);
}

.wk-file-preview-pdf-renderer__zoom-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: var(--wk-sp-4);
  height: var(--wk-sp-4);
  border: none;
  background: transparent;
  color: var(--wk-icon-muted);
  cursor: pointer;
  padding: 0;
  transition: color var(--wk-dur-fast);
}

.wk-file-preview-pdf-renderer__zoom-btn:hover {
  color: var(--wk-text-primary);
}

.wk-file-preview-pdf-renderer__zoom-value {
  font-size: var(--wk-text-size-sm);
  font-weight: var(--wk-font-semibold);
  line-height: var(--wk-sp-5);
  color: var(--wk-text-strong);
  min-width: 36px;
  text-align: center;
}

/* 适应宽度按钮 */
.wk-file-preview-pdf-renderer__fit-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  height: var(--wk-sp-6);
  padding: var(--wk-sp-1-5) var(--wk-sp-3);
  background: var(--wk-bg-surface);
  border: 1px solid var(--wk-brand-tint-10);
  border-radius: var(--wk-r-full);
  font-size: var(--wk-text-size-sm);
  font-weight: var(--wk-font-semibold);
  line-height: var(--wk-sp-5);
  color: var(--wk-text-strong);
  cursor: pointer;
  transition: background var(--wk-dur-fast), border-color var(--wk-dur-fast);
  white-space: nowrap;
}

.wk-file-preview-pdf-renderer__fit-btn:hover {
  background: var(--wk-bg-hover);
}

.wk-file-preview-pdf-renderer__fit-btn--active {
  background: var(--wk-brand-primary-bg);
  border-color: var(--wk-brand-primary);
  color: var(--wk-brand-primary);
}

/* ============================================
   主内容区域
   ============================================ */

.wk-file-preview-pdf-renderer__content {
  display: flex;
  flex: 1;
  overflow: hidden;
}

/* ============================================
   侧边栏
   ============================================ */

.wk-file-preview-pdf-renderer__sidebar {
  width: 160px;
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  background: var(--wk-bg-base);
  border-right: 1px solid var(--wk-border-subtle);
}

/* 侧边栏 Tab 切换 */
.wk-file-preview-pdf-renderer__sidebar-tabs {
  display: flex;
  border-bottom: 1px solid var(--wk-border-subtle);
  flex-shrink: 0;
}

.wk-file-preview-pdf-renderer__sidebar-tab {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--wk-sp-1);
  padding: var(--wk-sp-2) var(--wk-sp-2);
  border: none;
  background: transparent;
  color: var(--wk-text-secondary);
  font-size: var(--wk-text-size-xs);
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
  position: relative;
}

.wk-file-preview-pdf-renderer__sidebar-tab:hover:not(:disabled) {
  background: var(--wk-bg-hover);
  color: var(--wk-text-primary);
}

.wk-file-preview-pdf-renderer__sidebar-tab--active {
  color: var(--wk-brand-primary);
  font-weight: 500;
}

.wk-file-preview-pdf-renderer__sidebar-tab--active::after {
  content: "";
  position: absolute;
  bottom: -1px;
  left: 0;
  right: 0;
  height: 2px;
  background: var(--wk-brand-primary);
}

.wk-file-preview-pdf-renderer__sidebar-tab--disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.wk-file-preview-pdf-renderer__sidebar-tab--disabled:hover {
  background: transparent;
  color: var(--wk-text-secondary);
}

/* 侧边栏内容区 */
.wk-file-preview-pdf-renderer__sidebar-content {
  flex: 1;
  overflow: hidden;
}

/* 缩略图容器 */
.wk-file-preview-pdf-renderer__thumbnails {
  height: 100%;
  overflow-y: auto;
}

/* 书签容器 */
.wk-file-preview-pdf-renderer__bookmarks {
  height: 100%;
  overflow-y: auto;
  padding: var(--wk-sp-2);
}

/* 无书签提示 */
.wk-file-preview-pdf-renderer__no-bookmarks {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 100%;
  color: var(--wk-text-tertiary);
  font-size: var(--wk-text-size-xs);
  text-align: center;
  padding: var(--wk-sp-4);
}

/* ============================================
   PDF 查看器
   ============================================ */

.wk-file-preview-pdf-renderer__viewer {
  flex: 1;
  overflow: auto;
  position: relative;
  background: var(--wk-bg-base);
}

/* ============================================
   加载状态
   ============================================ */

.wk-file-preview-pdf-renderer__loading {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: var(--wk-sp-3);
  color: var(--wk-text-secondary);
  font-size: var(--wk-text-size-md);
  background: var(--wk-bg-surface);
  z-index: 10;
}

.wk-file-preview-pdf-renderer__spinner {
  width: 32px;
  height: 32px;
  border: 3px solid var(--wk-border-subtle);
  border-top-color: var(--wk-brand-primary);
  border-radius: 50%;
  animation: wk-pdf-renderer-spin 0.8s linear infinite;
}

@keyframes wk-pdf-renderer-spin {
  to {
    transform: rotate(360deg);
  }
}

/* ============================================
   错误状态
   ============================================ */

.wk-file-preview-pdf-renderer__error {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  height: 100%;
  gap: var(--wk-sp-3);
  color: var(--wk-color-danger);
  font-size: var(--wk-text-size-md);
}

.wk-file-preview-pdf-renderer__error-detail {
  font-size: var(--wk-text-size-sm);
  margin-top: var(--wk-sp-2);
  color: var(--wk-text-tertiary);
}

/* ============================================
   覆盖 react-pdf-viewer 默认样式
   ============================================ */

.wk-file-preview-pdf-renderer .rpv-core__viewer {
  height: 100%;
}

.wk-file-preview-pdf-renderer .rpv-core__inner-pages {
  background: var(--wk-bg-base);
}

/* 缩略图样式覆盖 */
.wk-file-preview-pdf-renderer .rpv-thumbnail__container {
  padding: var(--wk-sp-2);
}

.wk-file-preview-pdf-renderer .rpv-thumbnail__item {
  margin-bottom: var(--wk-sp-2);
}

.wk-file-preview-pdf-renderer .rpv-thumbnail__item--selected {
  border-color: var(--wk-brand-primary);
}

.wk-file-preview-pdf-renderer
  .rpv-thumbnail__item--selected
  .rpv-thumbnail__label {
  color: var(--wk-brand-primary);
}

/* 书签样式覆盖 */
.wk-file-preview-pdf-renderer .rpv-bookmark__container {
  padding: 0;
}

.wk-file-preview-pdf-renderer .rpv-bookmark__title {
  color: var(--wk-text-primary);
  font-size: var(--wk-text-size-sm);
  padding: var(--wk-sp-1) var(--wk-sp-2);
  border-radius: var(--wk-r-xs);
  transition: background 0.15s;
}

.wk-file-preview-pdf-renderer .rpv-bookmark__title:hover {
  background: var(--wk-bg-hover);
}

.wk-file-preview-pdf-renderer .rpv-bookmark__toggle {
  color: var(--wk-text-secondary);
}

.wk-file-preview-pdf-renderer .rpv-bookmark__list {
  padding-left: var(--wk-sp-3);
}

/* ============================================
   暗色模式
   ============================================ */

body[theme-mode="dark"] .wk-file-preview-pdf-renderer__toolbar {
  background: var(--wk-white-alpha-04);
  border-bottom-color: var(--wk-white-alpha-07);
}

body[theme-mode="dark"] .wk-file-preview-pdf-renderer__toolbar-sidebar-btn {
  color: var(--wk-white-alpha-40);
}

body[theme-mode="dark"]
  .wk-file-preview-pdf-renderer__toolbar-sidebar-btn:hover {
  color: var(--wk-text-primary);
}

body[theme-mode="dark"] .wk-file-preview-pdf-renderer__toolbar-divider {
  background: var(--wk-white-alpha-12);
}

body[theme-mode="dark"] .wk-file-preview-pdf-renderer__page-label {
  color: var(--wk-text-primary);
}

body[theme-mode="dark"] .wk-file-preview-pdf-renderer__page-input {
  background: var(--wk-white-alpha-07);
  border-color: var(--wk-white-alpha-07);
  color: var(--wk-text-primary);
}

body[theme-mode="dark"] .wk-file-preview-pdf-renderer__zoom-capsule {
  background: var(--wk-white-alpha-07);
  border-color: var(--wk-white-alpha-07);
}

body[theme-mode="dark"] .wk-file-preview-pdf-renderer__zoom-btn {
  color: var(--wk-white-alpha-40);
}

body[theme-mode="dark"] .wk-file-preview-pdf-renderer__zoom-btn:hover {
  color: var(--wk-text-primary);
}

body[theme-mode="dark"] .wk-file-preview-pdf-renderer__zoom-value {
  color: var(--wk-white-alpha-80);
}

body[theme-mode="dark"] .wk-file-preview-pdf-renderer__fit-btn {
  background: var(--wk-white-alpha-07);
  border-color: var(--wk-white-alpha-07);
  color: var(--wk-white-alpha-80);
}

body[theme-mode="dark"] .wk-file-preview-pdf-renderer__sidebar {
  background: var(--wk-bg-base);
}

body[theme-mode="dark"] .wk-file-preview-pdf-renderer__viewer {
  background: var(--wk-bg-base);
}

body[theme-mode="dark"] .wk-file-preview-pdf-renderer .rpv-core__inner-pages {
  background: var(--wk-bg-base);
}

body[theme-mode="dark"] .wk-file-preview-pdf-renderer .rpv-bookmark__title {
  color: var(--wk-text-primary);
}

body[theme-mode="dark"]
  .wk-file-preview-pdf-renderer
  .rpv-bookmark__title:hover {
  background: var(--wk-bg-hover);
}
