/* ============================================
   HtmlRenderer - HTML 渲染器样式
   类名前缀: wk-file-preview-html-renderer
   ============================================ */

.wk-file-preview-html-renderer {
  position: relative;
  width: 100%;
  height: 100%;
  overflow: hidden;
  background: var(--wk-bg-surface);
}

/* 预览模式 */
.wk-file-preview-html-renderer--preview {
  display: flex;
  flex-direction: column;
}

/* 源码模式 */
.wk-file-preview-html-renderer--source {
  display: flex;
  flex-direction: column;
}

/* ============================================
   iframe 预览样式
   ============================================ */

.wk-file-preview-html-renderer__iframe {
  width: 100%;
  height: 100%;
  border: none;
  display: block;
  background: var(--wk-bg-surface);
  flex: 1;
}

.wk-file-preview-html-renderer__iframe--hidden {
  visibility: hidden;
}

/* ============================================
   加载中遮罩层
   ============================================ */

.wk-file-preview-html-renderer__loading-overlay {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: var(--wk-sp-3);
  background: var(--wk-bg-surface);
  z-index: 10;
}

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

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

/* 消息文本 */
.wk-file-preview-html-renderer__message {
  color: var(--wk-text-secondary);
  font-size: var(--wk-text-size-md);
}

/* ============================================
   安全策略命中后的禁用预览页
   ============================================ */

.wk-file-preview-html-renderer__disabled-preview {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  width: 100%;
  height: 100%;
  padding: var(--wk-sp-8);
  box-sizing: border-box;
  text-align: center;
  background: var(--wk-bg-surface);
}

.wk-file-preview-html-renderer__disabled-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: var(--wk-sp-5);
  color: var(--wk-color-warning);
}

.wk-file-preview-html-renderer__disabled-content {
  display: flex;
  flex-direction: column;
  gap: var(--wk-sp-2);
}

.wk-file-preview-html-renderer__disabled-title {
  margin: 0;
  color: var(--wk-text-primary);
  font-size: var(--wk-text-size-xl);
  font-weight: var(--wk-font-semibold);
  line-height: 1.4;
}

.wk-file-preview-html-renderer__disabled-message,
.wk-file-preview-html-renderer__disabled-submessage {
  margin: 0;
  color: var(--wk-text-secondary);
  font-size: var(--wk-text-size-sm);
  line-height: 1.7;
}

.wk-file-preview-html-renderer__disabled-submessage {
  color: var(--wk-text-tertiary);
}

.wk-file-preview-html-renderer__disabled-actions {
  display: flex;
  gap: var(--wk-sp-3);
  margin-top: var(--wk-sp-6);
}

.wk-file-preview-html-renderer__disabled-action {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--wk-sp-2);
  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-html-renderer__disabled-action:hover {
  background: var(--wk-bg-hover);
  border-color: var(--wk-border-strong);
}

.wk-file-preview-html-renderer__disabled-action--primary {
  border-color: var(--wk-brand-primary);
  background: var(--wk-brand-primary);
  color: var(--wk-text-inverse);
}

.wk-file-preview-html-renderer__disabled-action--primary:hover {
  border-color: var(--wk-brand-primary-hover);
  background: var(--wk-brand-primary-hover);
}

/* ============================================
   错误提示条
   ============================================ */

.wk-file-preview-html-renderer__error-bar {
  display: flex;
  align-items: center;
  gap: var(--wk-sp-2);
  padding: var(--wk-sp-2) var(--wk-sp-4);
  background: var(--wk-color-danger-bg);
  border-bottom: 1px solid var(--wk-color-danger-border);
  color: var(--wk-color-danger);
  font-size: var(--wk-text-size-sm);
  flex-shrink: 0;
}

.wk-file-preview-html-renderer__error-icon {
  font-size: 14px;
  line-height: 1;
}

.wk-file-preview-html-renderer__error-text {
  flex: 1;
}

.wk-file-preview-html-renderer__retry-preview {
  padding: var(--wk-sp-1) var(--wk-sp-3);
  border: 1px solid var(--wk-color-danger-border);
  background: transparent;
  color: var(--wk-color-danger);
  border-radius: var(--wk-r-sm);
  cursor: pointer;
  font-size: var(--wk-text-size-xs);
  transition: background 0.15s ease;
  white-space: nowrap;
}

.wk-file-preview-html-renderer__retry-preview:hover {
  background: var(--wk-color-danger-hover);
}

.wk-file-preview-html-renderer__retry-preview:active {
  background: var(--wk-color-danger-active);
}

/* ============================================
   源码容器
   ============================================ */

.wk-file-preview-html-renderer__source-container {
  flex: 1;
  overflow: auto;
  background: var(--wk-bg-base);
}

/* 源码容器内的 SyntaxHighlighter 样式 */
.wk-file-preview-html-renderer__source-container pre {
  margin: 0;
  padding: var(--wk-sp-4);
  min-height: 100%;
  box-sizing: border-box;
}

.wk-file-preview-html-renderer__source-container code {
  font-family: "Fira Code", "JetBrains Mono", "SF Mono", Menlo, Monaco, Consolas,
    "Liberation Mono", "Courier New", monospace;
  font-size: var(--wk-text-size-sm);
  line-height: 1.6;
}

/* 纯文本模式提示条 */
.wk-file-preview-html-renderer__plain-hint {
  padding: var(--wk-sp-2) var(--wk-sp-4);
  background: var(--wk-color-warning-bg);
  border-bottom: 1px solid var(--wk-color-warning-border);
  color: var(--wk-color-warning);
  font-size: var(--wk-text-size-sm);
  flex-shrink: 0;
}

/* 大文件纯文本源码样式 */
.wk-file-preview-html-renderer__plain-source {
  margin: 0;
  padding: var(--wk-sp-4);
  min-height: 100%;
  box-sizing: border-box;
  background: var(--wk-bg-base);
  color: var(--wk-text-primary);
  white-space: pre-wrap;
  word-break: break-all;
  overflow-wrap: break-word;
}

.wk-file-preview-html-renderer__plain-source code {
  font-family: "Fira Code", "JetBrains Mono", "SF Mono", Menlo, Monaco, Consolas,
    "Liberation Mono", "Courier New", monospace;
  font-size: var(--wk-text-size-sm);
  line-height: 1.6;
}

/* ============================================
   加载/错误/空状态容器
   ============================================ */

.wk-file-preview-html-renderer--loading,
.wk-file-preview-html-renderer--error,
.wk-file-preview-html-renderer--empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  height: 100%;
  gap: var(--wk-sp-3);
}

.wk-file-preview-html-renderer--error .wk-file-preview-html-renderer__message {
  color: var(--wk-color-danger);
}

/* 重试按钮 */
.wk-file-preview-html-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-html-renderer__retry:hover {
  background: var(--wk-bg-hover);
  border-color: var(--wk-border-strong);
}

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

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

body[theme-mode="dark"] .wk-file-preview-html-renderer {
  background: var(--wk-bg-surface);
}

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

body[theme-mode="dark"] .wk-file-preview-html-renderer__error-bar {
  background: var(--wk-color-danger-bg);
  border-bottom-color: var(--wk-color-danger-border);
  color: var(--wk-color-danger);
}

body[theme-mode="dark"] .wk-file-preview-html-renderer__retry-preview {
  border-color: var(--wk-color-danger-border);
  color: var(--wk-color-danger);
}

body[theme-mode="dark"] .wk-file-preview-html-renderer__retry-preview:hover {
  background: var(--wk-color-danger-hover);
}

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