/* ====================
 * 分块对比优化样式
 * ==================== */

/* 优化后的分块容器 */
.chunk-compare-container {
  position: relative;
  /* 取消内部滚动与固定高度，改由页面整体滚动 */
  /* overflow-y: auto; */
  /* max-height: 80vh; */
  scroll-behavior: smooth;
  margin: 0;
  padding: 0;
}

/* （已移除 visible-chunks 容器，相关样式不再需要） */

/* 移除虚拟化占位符的多余空间 */
.virtual-spacer-top,
.virtual-spacer-bottom {
  margin: 0;
  padding: 0;
  line-height: 0;
  font-size: 0;
}

/* 骨架屏样式 */
.skeleton-chunk {
  margin-bottom: 16px;
  border: 1px solid #e2e8f0;
  border-radius: 8px;
  padding: 16px;
  background: #fff;
}

.skeleton-line {
  background: linear-gradient(90deg, #f0f0f0 25%, #e0e0e0 50%, #f0f0f0 75%);
  background-size: 200% 100%;
  animation: skeleton-loading 1.5s infinite;
  border-radius: 4px;
  height: 12px;
  margin-bottom: 8px;
}

.skeleton-title {
  height: 16px;
  width: 30%;
}

.skeleton-label {
  height: 10px;
  width: 20%;
  margin-bottom: 6px;
}

.skeleton-stat {
  height: 10px;
  width: 60px;
  display: inline-block;
  margin-right: 12px;
}

.skeleton-short {
  width: 60%;
}

.skeleton-content {
  margin-bottom: 12px;
}

.skeleton-button {
  height: 32px;
  width: 120px;
  background: linear-gradient(90deg, #f0f0f0 25%, #e0e0e0 50%, #f0f0f0 75%);
  background-size: 200% 100%;
  animation: skeleton-loading 1.5s infinite;
  border-radius: 6px;
  margin: 0 auto;
}

.skeleton-stats {
  display: flex;
  gap: 12px;
  align-items: center;
}

@keyframes skeleton-loading {
  0% {
    background-position: 200% 0;
  }
  100% {
    background-position: -200% 0;
  }
}

.chunk-preview-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  margin-bottom: 12px;
}

/* 分块标题栏优化 */
.chunk-compare-title-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1em;
  padding: 0.5em 0;
  border-bottom: 1px solid #e2e8f0;
}

.chunk-controls {
  display: flex;
  gap: 8px;
  align-items: center;
}

.chunk-count {
  font-size: 0.8em;
  color: #64748b;
  font-weight: normal;
}

.performance-btn {
  background: #f1f5f9;
  border: 1px solid #e2e8f0;
  border-radius: 4px;
  padding: 4px 8px;
  cursor: pointer;
  font-size: 1.2em;
  transition: all 0.2s;
}

.performance-btn:hover {
  background: #e0e7ff;
  border-color: #3b82f6;
}

.performance-btn.active {
  background: #3b82f6;
  color: white;
  border-color: #3b82f6;
}

/* 优化后的分块样式 */
.optimized-chunk {
  margin-bottom: 1.5em;
  border: 1px solid #e2e8f0;
  border-radius: 8px;
  overflow: hidden;
  transition: box-shadow 0.2s;
  background: white;
}

.optimized-chunk:hover {
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

/* 分块头部样式 */
.chunk-header {
  background: #f8fafc;
  border-bottom: 1px solid #e2e8f0;
  padding: 12px 16px;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.chunk-header h4 {
  margin: 0;
  font-size: 1.1em;
  color: #1e293b;
}

.chunk-stats {
  display: flex;
  gap: 12px;
  font-size: 0.8em;
  color: #64748b;
}

/* 分块预览容器 */
.chunk-preview-container {
  padding: 16px;
}

.chunk-preview {
  margin-bottom: 12px;
  border: 1px dashed #e2e8f0;
  border-radius: 4px;
  padding: 8px;
  background: #fafbfc;
}

.preview-label {
  font-size: 0.8em;
  color: #475569;
  font-weight: 600;
  margin-bottom: 4px;
}

.preview-content {
  font-size: 0.9em;
  line-height: 1.4;
  color: #64748b;
  max-height: 60px;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* 加载完整内容按钮 */
.load-full-content-btn {
  background: linear-gradient(135deg, #3b82f6, #1e40af);
  color: white;
  border: none;
  border-radius: 6px;
  padding: 10px 16px;
  cursor: pointer;
  font-size: 0.9em;
  font-weight: 500;
  text-align: center;
  transition: all 0.3s;
  margin-top: 12px;
  box-shadow: 0 2px 4px rgba(59, 130, 246, 0.2);
}

.load-full-content-btn:hover {
  background: linear-gradient(135deg, #2563eb, #1d4ed8);
  transform: translateY(-1px);
  box-shadow: 0 4px 8px rgba(59, 130, 246, 0.3);
}

.load-full-content-btn:active {
  transform: translateY(0);
}

/* 加载状态样式 */
.chunk-loading {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  color: #64748b;
  font-size: 0.9em;
}

.chunk-loading::before {
  content: '';
  width: 20px;
  height: 20px;
  border: 2px solid #e2e8f0;
  border-top: 2px solid #3b82f6;
  border-radius: 50%;
  animation: spin 1s linear infinite;
  margin-right: 8px;
}

@keyframes spin {
  0% { transform: rotate(0deg); }
  100% { transform: rotate(360deg); }
}

/* 错误状态样式 */
.chunk-error {
  padding: 16px;
  background: #fef2f2;
  border: 1px solid #fecaca;
  border-radius: 6px;
  color: #dc2626;
  text-align: center;
  font-size: 0.9em;
}

/* 加载指示器样式 */
.chunk-loading-indicator {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  background: rgba(255, 255, 255, 0.95);
  border: 1px solid #e2e8f0;
  border-radius: 8px;
  padding: 20px 30px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
  z-index: 1000;
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: 0.9em;
  color: #475569;
}

.loading-spinner {
  width: 20px;
  height: 20px;
  border: 2px solid #e2e8f0;
  border-top: 2px solid #3b82f6;
  border-radius: 50%;
  animation: spin 1s linear infinite;
}

/* 虚拟化容器样式 */
.virtual-spacer-top,
.virtual-spacer-bottom {
  background: transparent;
  pointer-events: none;
}

/* （已移除 visible-chunks 容器，相关样式不再需要） */

/* 性能模式样式 */
.performance-mode .chunk-preview {
  background: #f0f9ff;
  border-color: #bae6fd;
}

.performance-mode .optimized-chunk {
  border-left: 3px solid #3b82f6;
}

/* 进度条样式 */
.chunk-progress-container {
  margin: 8px 0;
  background: #f1f5f9;
  border-radius: 4px;
  overflow: hidden;
  height: 4px;
}

.chunk-progress-bar {
  height: 100%;
  background: linear-gradient(90deg, #3b82f6, #06b6d4);
  transition: width 0.3s ease;
  border-radius: 4px;
}

/* 响应式优化 */
@media (max-width: 768px) {
  .chunk-header {
    flex-direction: column;
    align-items: flex-start;
    gap: 8px;
  }
  
  .chunk-stats {
    flex-direction: column;
    gap: 4px;
  }
  
  .chunk-preview-container {
    padding: 12px;
  }
  
  .load-full-content-btn {
    padding: 8px 12px;
    font-size: 0.8em;
  }
}

/* 高对比度模式 */
@media (prefers-contrast: high) {
  .optimized-chunk {
    border: 2px solid #000;
  }
  
  .chunk-header {
    background: #f0f0f0;
    border-bottom: 2px solid #000;
  }
  
  .load-full-content-btn {
    background: #000;
    border: 2px solid #000;
  }
}

/* 减少动画偏好 */
@media (prefers-reduced-motion: reduce) {
  .optimized-chunk,
  .load-full-content-btn,
  .performance-btn {
    transition: none;
  }
  
  .loading-spinner {
    animation: none;
  }
  
  .chunk-loading::before {
    animation: none;
  }
}

/* 深色模式支持 */
@media (prefers-color-scheme: dark) {
  .optimized-chunk {
    background: #1e293b;
    border-color: #475569;
  }
  
  .chunk-header {
    background: #334155;
    border-bottom-color: #475569;
  }
  
  .chunk-header h4 {
    color: #f1f5f9;
  }
  
  .chunk-stats {
    color: #94a3b8;
  }
  
  .chunk-preview {
    background: #0f172a;
    border-color: #475569;
  }
  
  .preview-label {
    color: #cbd5e1;
  }
  
  .preview-content {
    color: #94a3b8;
  }
  
  .chunk-loading-indicator {
    background: rgba(30, 41, 59, 0.95);
    border-color: #475569;
    color: #cbd5e1;
  }
}

/* 滚动条优化 */
.chunk-compare-container::-webkit-scrollbar {
  width: 8px;
}

.chunk-compare-container::-webkit-scrollbar-track {
  background: #f1f5f9;
  border-radius: 4px;
}

.chunk-compare-container::-webkit-scrollbar-thumb {
  background: #cbd5e1;
  border-radius: 4px;
  transition: background 0.2s;
}

.chunk-compare-container::-webkit-scrollbar-thumb:hover {
  background: #94a3b8;
}

/* 焦点可访问性 */
.load-full-content-btn:focus,
.performance-btn:focus {
  outline: 2px solid #3b82f6;
  outline-offset: 2px;
}

/* 打印样式 */
@media print {
  .chunk-controls,
  .load-full-content-btn,
  .chunk-loading-indicator {
    display: none !important;
  }
  
  .optimized-chunk {
    border: 1px solid #000;
    break-inside: avoid;
    margin-bottom: 1em;
  }
  
  .chunk-preview-container {
    padding: 8px;
  }
}
