/* ============================================
   ImageRenderer - 图片渲染器样式
   类名前缀: wk-file-preview-image-renderer
   ============================================ */

.wk-file-preview-image-renderer {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  height: 100%;
  overflow: hidden;
  background: var(--wk-bg-base);
  padding: var(--wk-sp-6);
  box-sizing: border-box;
}

/* 图片内容容器 - 用于包裹图片和操作按钮 */
.wk-file-preview-image-renderer__content {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  height: 100%;
}

/* 图片基础样式 */
.wk-file-preview-image-renderer__img {
  border-radius: var(--wk-r-md);
  transition: opacity 0.2s ease;
  cursor: pointer;
}

/* 图片适应模式 - contain */
.wk-file-preview-image-renderer__img--contain {
  width: 100%;
  height: 100%;
  object-fit: contain;
  object-position: center;
}

/* 图片适应模式 - cover */
.wk-file-preview-image-renderer__img--cover {
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center;
}

/* 图片适应模式 - auto (宽度优先) */
.wk-file-preview-image-renderer__img--fit-width {
  width: 100%;
  height: auto;
  max-height: 100%;
  object-position: center;
}

/* 图片适应模式 - auto (高度优先) */
.wk-file-preview-image-renderer__img--fit-height {
  width: auto;
  height: 100%;
  max-width: 100%;
  object-position: center;
}

/* 图片加载状态 */
.wk-file-preview-image-renderer__img--loading {
  opacity: 0;
}

.wk-file-preview-image-renderer__img--loaded {
  opacity: 1;
}

/* 加载状态容器 */
.wk-file-preview-image-renderer__loading {
  position: absolute;
  inset: 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);
}

/* 加载文本 */
.wk-file-preview-image-renderer__loading-text {
  color: var(--wk-text-tertiary);
  font-size: var(--wk-text-size-sm);
}

/* 加载动画 */
.wk-file-preview-image-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-image-renderer-spin 0.8s linear infinite;
}

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

/* 错误状态容器 */
.wk-file-preview-image-renderer__error {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  width: 100%;
  height: 100%;
  gap: var(--wk-sp-3);
  color: var(--wk-text-tertiary);
  font-size: var(--wk-text-size-md);
  background: var(--wk-bg-subtle);
  border-radius: var(--wk-r-md);
}

.wk-file-preview-image-renderer__error-icon {
  width: 48px;
  height: 48px;
  color: var(--wk-text-quaternary);
}

.wk-file-preview-image-renderer__error-text {
  color: var(--wk-text-tertiary);
}

/* 重试按钮 */
.wk-file-preview-image-renderer__retry {
  padding: var(--wk-sp-2) var(--wk-sp-4);
  border: 1px solid var(--wk-border-default);
  background: var(--wk-bg-base);
  color: var(--wk-text-primary);
  border-radius: var(--wk-r-sm);
  cursor: pointer;
  font-size: var(--wk-text-size-sm);
  transition: background 0.15s ease, border-color 0.15s ease;
}

.wk-file-preview-image-renderer__retry:hover {
  background: var(--wk-bg-hover);
  border-color: var(--wk-border-strong);
}

.wk-file-preview-image-renderer__retry:active {
  background: var(--wk-bg-active);
}

/* 暗色模式适配 */
body[theme-mode="dark"] .wk-file-preview-image-renderer {
  background: var(--wk-bg-base);
}

body[theme-mode="dark"] .wk-file-preview-image-renderer__error {
  background: var(--wk-bg-subtle);
}
