/**
 * 封面制作页面样式
 * =================
 *
 * 完全遵循字幕压制页面结构和间距，保持一致
 */

/* 布局 - 40:60 */
.step-layout.subtitle-burning {
  grid-template-columns: 55fr 45fr;
}

.step-layout.cover-design-variant {
  grid-template-columns: 40fr 60fr;
}

/* 左侧操作区 - 与视频生成页面统一 */
.cover-design .step-panel-left {
  display: flex;
  flex-direction: column;
  gap: var(--spacing-md);
  overflow-y: auto;
  overflow-x: hidden;
  padding-right: var(--spacing-lg);
  height: 100%;
}

/* panel-section - 和字幕压制完全一致 */
.cover-design .panel-section {
  display: flex;
  flex-direction: column;
  gap: var(--spacing-sm);
}

/* 模板标题区域头部 */
.post-edit-template-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: var(--spacing-sm);
}

.post-edit-template-header .post-edit-section-title {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.panel-label {
  font-size: var(--font-sm);
  font-weight: 600;
  color: var(--text-primary);
}

.panel-sublabel {
  font-size: var(--font-xs);
  color: var(--text-tertiary);
  font-weight: normal;
}

/* 滑块分组 */
.slider-group {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.slider-header {
  display: flex;
  justify-content: space-between;
}

.slider-label {
  font-size: var(--font-xs);
  color: var(--text-secondary);
}

/* 滑块输入样式 */
.slider-input {
  appearance: none;
  width: 100%;
  height: 6px;
  background: transparent;
  border-radius: var(--radius-sm);
  outline: none;
  cursor: pointer;
  border: none;
  padding: 0;
}

.slider-input::-webkit-slider-runnable-track {
  width: 100%;
  height: 6px;
  background: linear-gradient(
    to right,
    var(--primary) 0%,
    var(--primary) var(--slider-percent, 50%),
    var(--bg-input) var(--slider-percent, 50%),
    var(--bg-input) 100%
  );
  border-radius: var(--radius-sm);
}

.slider-input::-webkit-slider-thumb {
  appearance: none;
  width: 18px;
  height: 18px;
  background: var(--bg-card);
  border: 2px solid var(--primary);
  border-radius: var(--radius-full);
  cursor: pointer;
  box-shadow: 0 1px 4px rgb(0 0 0 / 15%);
  transition:
    transform 0.15s ease,
    box-shadow 0.15s ease;
}

.slider-input::-webkit-slider-thumb:hover {
  transform: scale(1.15);
  box-shadow: 0 2px 8px rgb(54 178 106 / 30%);
}

.slider-input:focus::-webkit-slider-thumb {
  box-shadow: 0 0 0 4px var(--primary-light);
}

/* 标题模板网格 - 和字幕压制预设样式完全一致 */
.cover-design .style-presets {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: var(--spacing-sm);
  margin-bottom: var(--spacing-sm);
}

.preset-btn {
  display: flex;
  flex: 1;
  flex-direction: column;
  align-items: center;
  gap: var(--spacing-xs);
  padding: var(--spacing-sm) var(--spacing-md);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  background: var(--bg-card);
  cursor: pointer;
  transition: all var(--transition-fast);
}

.preset-btn:hover {
  border-color: var(--primary);
  background: var(--bg-hover);
}

.preset-btn.active {
  border-color: var(--primary);
  background: var(--primary-light);
  color: var(--primary);
}

.preset-preview {
  font-size: var(--font-lg);
  font-weight: bold;
  line-height: 1;
}

.preset-name {
  font-size: var(--font-xs);
  color: var(--text-secondary);
}

.preset-btn.active .preset-name {
  color: var(--primary);
}

/* 字号区域 - 和字幕压制一致 */
.font-size-section {
  display: flex;
  flex-direction: column;
  gap: var(--spacing-sm);
  margin-bottom: var(--spacing-sm);
}

.font-size-value {
  margin-left: var(--spacing-sm);
  font-size: var(--font-sm);
  color: var(--primary);
  font-weight: 600;
}

/* 右侧预览区 - 与视频生成页面统一 */
.video-gen-right {
  display: flex;
  flex-direction: column;
  gap: var(--spacing-lg);
  padding: 0;
  overflow-y: auto;
  align-items: center;
  border-left: 1px solid var(--border-light);
  padding-left: var(--spacing-lg);
  min-height: 0;
}

.video-preview-wrapper {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* 使用更高特异性选择器，避免被其他页面 CSS 覆盖 */
.cover-design .video-preview-container {
  position: relative;
  width: calc(600px * 9 / 16);
  height: 600px;
  margin: 0 auto;
  background: linear-gradient(180deg, #1a1a2e 0%, #16213e 100%);
  border-radius: var(--radius-xl);
  overflow: hidden;
  box-shadow: 0 8px 32px rgb(0 0 0 / 30%);
  border: 1px solid var(--border-light);
}

.cover-preview-placeholder {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: var(--spacing-sm);
  color: rgba(255, 255, 255, 0.4);
  font-size: 14px;
  pointer-events: none;
}

.video-placeholder {
  width: 100%;
  height: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  color: rgba(255, 255, 255, 0.6);
  gap: var(--spacing-sm);
}

.video-placeholder .placeholder-sub {
  font-size: var(--font-xs);
  color: rgba(255, 255, 255, 0.4);
}

/* 手机框预览 - 和字幕压制一致 */
.post-edit-phone.cover-phone {
  height: auto;
  max-height: 580px;
  aspect-ratio: 9 / 16;
  width: auto;
}

.preview-video {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

/* 标题由 ASS.js 渲染在 canvas 层，无需手动 overlay */

/* 滚动条 */
.cover-config-panel::-webkit-scrollbar {
  width: 6px;
}

.cover-config-panel::-webkit-scrollbar-track {
  background: transparent;
}

.cover-config-panel::-webkit-scrollbar-thumb {
  background: var(--border-light);
  border-radius: var(--radius-sm);
}

.cover-config-panel::-webkit-scrollbar-thumb:hover {
  background: var(--text-tertiary);
}

/* 背景图网格 */
.bg-image-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: var(--spacing-sm);
  margin-bottom: var(--spacing-sm);
  width: 90%;
  margin-left: auto;
  margin-right: auto;
}

.bg-thumb {
  position: relative;
  padding: 0;
  border: 2px solid transparent;
  border-radius: var(--radius-md);
  overflow: hidden;
  cursor: pointer;
  background: none;
  aspect-ratio: 9 / 16;
}

.bg-thumb:hover {
  border-color: var(--border-color);
}

.bg-thumb.active {
  border-color: var(--primary);
}

.bg-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.bg-thumb-error {
  background: var(--bg-secondary, #f5f5f5);
  display: flex;
  align-items: center;
  justify-content: center;
}

.bg-thumb-error::after {
  content: '图片加载失败';
  font-size: 12px;
  color: #999;
  padding: 0 8px;
  text-align: center;
}

.bg-thumb-placeholder {
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg-secondary, #f5f5f5);
  font-size: 12px;
  color: #999;
  text-align: center;
  padding: 0 8px;
}


/* 标题输入框行（输入框 + 生成按钮） */
.title-input-row {
  display: flex;
  gap: var(--spacing-sm);
  align-items: center;
}

.title-input-row .input {
  flex: 1;
}

/* 副标题多行输入 */
.subtitle-textarea {
  min-height: 64px;
  resize: none;
  line-height: 1.5;
  padding: var(--spacing-md) var(--spacing-lg);
}

/* 智能生成按钮 */
.title-generate-btn {
  white-space: nowrap;
  font-size: var(--font-xs);
  padding: var(--spacing-xs) var(--spacing-sm);
  border-radius: var(--radius-md);
  flex-shrink: 0;
}

/* 视觉素材横向卡片 */
.visual-assets-row {
  display: flex;
  gap: var(--spacing-2xl);
  justify-content: center;
  flex-wrap: wrap;
}

.visual-asset-card {
  flex: 0 0 auto;
  width: 200px;
  max-width: 100%;
  display: flex;
  flex-direction: column;
  align-items: stretch;
  border-radius: 14px;
  background: #fff;
  cursor: pointer;
  transition: all 0.2s ease;
  position: relative;
  overflow: hidden;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
}

.visual-asset-card:hover {
  box-shadow: 0 8px 28px rgba(0, 0, 0, 0.14);
  transform: translateY(-2px);
}

.visual-asset-card:hover .visual-asset-overlay {
  opacity: 1;
}

.visual-asset-image-wrap {
  position: relative;
  width: 100%;
  aspect-ratio: 9 / 16;
  overflow: hidden;
  border-radius: 10px;
  margin: 8px;
  width: calc(100% - 16px);
}

.visual-asset-card img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  border-radius: 8px;
  transition: transform 0.3s ease;
}

.visual-asset-card:hover img {
  transform: scale(1.03);
}

.visual-asset-label {
  position: absolute;
  top: 8px;
  left: 8px;
  font-size: 10px;
  font-weight: 600;
  color: #fff;
  background: rgba(0, 0, 0, 0.55);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  padding: 3px 8px;
  border-radius: 6px;
  letter-spacing: 0.4px;
  pointer-events: none;
  z-index: 2;
}

.visual-asset-overlay {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0, 0, 0, 0.35);
  opacity: 0;
  transition: opacity 0.2s ease;
  border-radius: 8px;
  pointer-events: none;
}

.visual-asset-overlay-text {
  color: #fff;
  font-size: 13px;
  font-weight: 500;
  display: flex;
  align-items: center;
  gap: 4px;
}

.visual-asset-placeholder {
  width: 100%;
  height: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;
  color: var(--text-tertiary);
  font-size: var(--font-xs);
  background: var(--bg-secondary);
  border-radius: 8px;
}

/* .visual-asset-hint removed - using hover overlay instead */

/* 弹窗背景图网格 */
.modal-bg-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: var(--spacing-sm);
}

.modal-bg-thumb {
  position: relative;
  padding: 0;
  border: 2px solid transparent;
  border-radius: var(--radius-md);
  overflow: hidden;
  cursor: pointer;
  background: var(--bg-secondary);
  aspect-ratio: 9 / 16;
  transition: all var(--transition-fast);
}

.modal-bg-thumb:hover {
  border-color: var(--border-color);
  transform: scale(1.02);
}

.modal-bg-thumb.active {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-light);
}

/* 选中态勾选标记 */
.modal-bg-thumb.active::after {
  content: '';
  position: absolute;
  top: var(--spacing-sm);
  right: var(--spacing-sm);
  width: 20px;
  height: 20px;
  background: var(--primary);
  border-radius: var(--radius-full);
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='white' stroke-width='3' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='20 6 9 17 4 12'%3E%3C/polyline%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: center;
  box-shadow: var(--shadow-sm);
}

.modal-bg-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

/* 弹窗封面形象网格 */
.modal-avatar-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: var(--spacing-sm);
}

.modal-avatar-thumb {
  position: relative;
  padding: 0;
  border: 2px solid transparent;
  border-radius: var(--radius-md);
  overflow: hidden;
  cursor: pointer;
  background: var(--bg-secondary);
  aspect-ratio: 9 / 16;
  transition: all var(--transition-fast);
}

.modal-avatar-thumb:hover {
  border-color: var(--border-color);
  transform: scale(1.02);
}

.modal-avatar-thumb.active {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-light);
}

.modal-avatar-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.avatar-placeholder {
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  color: #999;
}

/* 加载失败 */
.modal-bg-error {
  background: var(--bg-tertiary);
}

.modal-bg-error::after {
  content: '加载失败';
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: var(--font-xs);
  color: var(--text-tertiary);
  pointer-events: none;
}

/* 本地上传卡片 */
.modal-bg-upload {
  border-style: dashed;
  border-color: var(--border-color);
  background: transparent;
}

.modal-bg-upload:hover {
  border-style: solid;
  border-color: var(--primary);
  background: var(--primary-light);
}

.upload-placeholder {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: var(--spacing-sm);
  width: 100%;
  height: 100%;
  color: var(--text-secondary);
  font-size: var(--font-sm);
  pointer-events: none;
}

.upload-placeholder svg {
  color: var(--text-tertiary);
  transition: color var(--transition-fast);
}

.modal-bg-upload:hover .upload-placeholder {
  color: var(--primary);
}

.modal-bg-upload:hover .upload-placeholder svg {
  color: var(--primary);
}

.avatar-thumb-error {
  background: var(--bg-secondary);
  display: flex;
  align-items: center;
  justify-content: center;
}

.avatar-thumb-error::after {
  content: '加载失败';
  font-size: 10px;
  color: #999;
}

/* 背景图片区域头部（标签 + 按钮） */
.bg-section-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: var(--spacing-sm);
  width: 90%;
  margin-left: auto;
  margin-right: auto;
}

.bg-shuffle-btn {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 4px 8px;
  font-size: var(--font-xs);
  color: var(--text-secondary);
  background: transparent;
  border: none;
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: color 0.2s, background 0.2s;
}

.bg-shuffle-btn:hover:not(:disabled) {
  color: var(--primary);
  background: var(--primary-light);
}

.bg-shuffle-btn:disabled {
  opacity: 0.4;
  cursor: default;
}
