/* ============================================
   内容创作 - 生成器样式
   与学习能量站配色保持一致性
   暖橙 #FF6B35 / 草绿 #67C23A / 米白 #FFF8E7
   风格参考 textbook.css
   ============================================ */

/* ---- 视图容器 ---- */
.generate-view {
  display: flex;
  flex-direction: column;
  min-height: calc(100vh - 140px);
  padding: 28px 32px;
}

.generate-head h2 {
  font-size: 22px;
  font-weight: 700;
  color: var(--text);
  display: flex;
  align-items: center;
  gap: 8px;
}

.generate-head .generate-subtitle {
  font-size: 14px;
  color: var(--text-light);
  margin-top: 4px;
  margin-bottom: 18px;
}

/* ---- A. 积分 / 价格提示条 ---- */
.generate-credits-bar {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  background: linear-gradient(135deg, #FFF3DC, #FFF8E7);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 12px 18px;
  margin-bottom: 20px;
  box-shadow: var(--shadow);
}

.credits-balance {
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
  display: flex;
  align-items: center;
  gap: 4px;
}

.credits-balance strong {
  color: var(--primary);
  font-size: 18px;
}

.credits-prices {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-left: auto;
}

.price-tag {
  font-size: 12px;
  font-weight: 600;
  padding: 4px 12px;
  border-radius: 14px;
  white-space: nowrap;
}

.price-tag.image { background: rgba(74, 144, 217, 0.12); color: var(--blue); }
.price-tag.video { background: rgba(255, 107, 53, 0.12); color: var(--primary); }
.price-tag.music { background: rgba(155, 89, 182, 0.12); color: var(--purple); }

/* ---- B. 页签 ---- */
.generate-tabs {
  display: flex;
  gap: 8px;
  margin-bottom: 20px;
}

.gen-tab {
  flex: 1;
  padding: 12px;
  border-radius: var(--radius);
  background: var(--card);
  border: 2px solid var(--border);
  font-size: 14px;
  font-weight: 600;
  color: var(--text-light);
  cursor: pointer;
  transition: all 0.2s ease;
  font-family: inherit;
}

.gen-tab:hover {
  border-color: var(--primary);
  color: var(--primary);
}

.gen-tab.active {
  background: linear-gradient(135deg, var(--primary), var(--primary-light));
  color: #fff;
  border-color: transparent;
  box-shadow: var(--shadow);
}

/* ---- 表单 + 结果 布局（表单居中，提示作为表单下方的一句话备注） ---- */
.generate-main {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
}

.gen-form-panel {
  flex: none;
  width: 100%;
  max-width: 480px;
  background: var(--card);
  border-radius: var(--radius-lg);
  padding: 20px;
  box-shadow: var(--shadow);
  display: none;
}

.gen-form-panel.active {
  display: block;
  animation: genPanelIn 0.25s ease;
}

@keyframes genPanelIn {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: translateY(0); }
}

/* ---- 表单控件 ---- */
.gen-label {
  display: block;
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
  margin: 14px 0 6px;
}

.gen-label:first-child {
  margin-top: 0;
}

.gen-textarea {
  width: 100%;
  min-height: 96px;
  padding: 12px 14px;
  border: 2px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg);
  font-size: 14px;
  font-family: inherit;
  color: var(--text);
  line-height: 1.6;
  resize: vertical;
  outline: none;
  transition: border-color 0.2s, background 0.2s;
}

.gen-textarea:focus {
  border-color: var(--primary);
  background: #fff;
}

.gen-textarea::placeholder {
  color: #C9BCA8;
}

.gen-textarea-sm {
  min-height: 64px;
}

.gen-select {
  width: 100%;
  padding: 10px 12px;
  border: 2px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg);
  font-size: 14px;
  font-family: inherit;
  color: var(--text);
  outline: none;
  cursor: pointer;
  transition: border-color 0.2s, background 0.2s;
}

.gen-select:focus {
  border-color: var(--primary);
  background: #fff;
}

.gen-select-row {
  display: flex;
  gap: 12px;
}

.gen-select-group {
  flex: 1;
  min-width: 0;
}

.gen-select-group .gen-label {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.gen-cost-hint {
  font-size: 13px;
  color: var(--text-light);
  margin: 14px 0;
  display: flex;
  align-items: center;
  gap: 4px;
}

.gen-cost-hint strong {
  color: var(--primary);
  font-size: 15px;
}

.gen-submit {
  width: 100%;
  padding: 14px;
  border-radius: var(--radius);
  background: linear-gradient(135deg, var(--primary), var(--primary-light));
  color: #fff;
  font-weight: 700;
  font-size: 15px;
  box-shadow: var(--shadow);
  transition: transform 0.2s, box-shadow 0.2s, opacity 0.2s;
  font-family: inherit;
}

.gen-submit:hover:not(:disabled) {
  transform: translateY(-2px);
  box-shadow: var(--shadow-lg);
}

.gen-submit:active:not(:disabled) {
  transform: translateY(0);
}

.gen-submit:disabled {
  opacity: 0.6;
  cursor: wait;
}

/* ---- 结果预览区（与表单同宽，居中） ---- */
.gen-result {
  width: 100%;
  max-width: 480px;
  min-width: 0;
}

/* 一句话备注：不占大空间，作为表单下方的提示 */
.gen-result-empty {
  color: var(--text-light);
  font-size: 13px;
  text-align: center;
  padding: 4px 20px;
}

.gen-result-card {
  background: var(--card);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
  padding: 20px;
  animation: genPanelIn 0.25s ease;
}

.gen-result-head {
  font-size: 15px;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 12px;
  display: flex;
  align-items: center;
  gap: 6px;
}

.gen-image-preview {
  border-radius: var(--radius);
  overflow: hidden;
  background: var(--bg);
  text-align: center;
}

.gen-image-preview img {
  width: 100%;
  max-height: 380px;
  object-fit: contain;
  display: block;
}

.gen-video-preview video {
  width: 100%;
  max-height: 380px;
  border-radius: var(--radius);
  background: #000;
  display: block;
}

.gen-result-card audio {
  width: 100%;
  margin: 4px 0 12px;
  outline: none;
}

.gen-media-empty {
  padding: 40px 20px;
  color: var(--text-light);
  font-size: 13px;
  text-align: center;
}

.gen-result-prompt {
  font-size: 14px;
  color: var(--text);
  margin: 12px 0 6px;
  white-space: pre-wrap;
  word-break: break-word;
  background: var(--bg);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  line-height: 1.6;
}

.gen-result-meta {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  font-size: 12px;
  color: var(--text-light);
}

.gen-result-error {
  color: var(--coral);
  font-size: 14px;
  text-align: center;
  padding: 40px 20px;
}

/* ---- 音乐歌词 ---- */
.music-lyrics {
  margin-top: 14px;
  border-top: 1px dashed var(--border);
  padding-top: 12px;
  max-height: 240px;
  overflow-y: auto;
}

.lyrics-title {
  font-size: 13px;
  font-weight: 700;
  color: var(--accent);
  margin-bottom: 8px;
  display: flex;
  align-items: center;
  gap: 4px;
}

.lyric-line {
  font-size: 14px;
  color: var(--text);
  line-height: 2;
  padding: 2px 10px;
  border-radius: 6px;
  white-space: pre-wrap;
  word-break: break-word;
}

.lyric-line:nth-child(odd) {
  background: rgba(103, 194, 58, 0.06);
}

/* ---- 生成中动画 ---- */
.generating-card {
  text-align: center;
  padding: 48px 24px;
}

.gen-spinner {
  width: 40px;
  height: 40px;
  border: 4px solid var(--border);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: genSpin 0.8s linear infinite;
  margin: 0 auto 16px;
}

@keyframes genSpin {
  to { transform: rotate(360deg); }
}

.gen-generating-text {
  font-size: 15px;
  font-weight: 700;
  color: var(--text);
}

.gen-generating-sub {
  font-size: 12px;
  color: var(--text-light);
  margin-top: 6px;
}

/* ---- C. 历史记录 ---- */
.generate-history {
  margin-top: 28px;
}

.history-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 14px;
  flex-wrap: wrap;
  gap: 10px;
}

.history-head h3 {
  font-size: 17px;
  font-weight: 700;
  color: var(--text);
  display: flex;
  align-items: center;
  gap: 6px;
}

.history-filters {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

.history-filter-btn {
  padding: 6px 16px;
  border-radius: 16px;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-light);
  background: var(--card);
  border: 1px solid var(--border);
  cursor: pointer;
  transition: all 0.2s ease;
  font-family: inherit;
}

.history-filter-btn:hover {
  color: var(--primary);
  border-color: var(--primary);
}

.history-filter-btn.active {
  background: linear-gradient(135deg, var(--primary), var(--primary-light));
  color: #fff;
  border-color: transparent;
}

.history-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.history-item {
  display: flex;
  gap: 14px;
  background: var(--card);
  border-radius: var(--radius-lg);
  padding: 12px;
  box-shadow: var(--shadow);
  cursor: pointer;
  transition: transform 0.2s ease, box-shadow 0.2s ease;
  border: 2px solid transparent;
}

.history-item:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-lg);
  border-color: var(--primary);
}

.history-media {
  width: 150px;
  height: 88px;
  border-radius: var(--radius-sm);
  overflow: hidden;
  background: var(--bg);
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
}

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

.history-media video {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  background: #000;
}

.history-media audio {
  width: 100%;
  outline: none;
}

.history-media-icon {
  font-size: 28px;
  text-align: center;
}

.history-media-icon .media-status {
  display: block;
  font-size: 11px;
  color: var(--text-light);
  margin-top: 4px;
}

.history-media-icon .media-status.failed {
  color: var(--coral);
  font-weight: 600;
}

.history-info {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
}

.history-info-top {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 4px;
}

.history-type {
  font-size: 13px;
  font-weight: 700;
  color: var(--text);
}

.history-cost {
  font-size: 12px;
  font-weight: 700;
  color: var(--primary);
  background: rgba(255, 107, 53, 0.1);
  padding: 2px 8px;
  border-radius: 8px;
}

.history-prompt {
  font-size: 13px;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  line-height: 1.5;
  margin-bottom: 6px;
}

.history-meta {
  font-size: 12px;
  color: var(--text-light);
  margin-top: auto;
}

.history-empty {
  padding: 30px;
  text-align: center;
  color: var(--text-light);
  font-size: 14px;
  background: var(--card);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
}

/* ---- 历史条目操作按钮（浏览 / 保存 / 转发） ---- */
.gen-history-actions {
  display: flex;
  gap: 8px;
  margin-top: 10px;
  flex-wrap: wrap;
}

.gen-history-action {
  padding: 5px 12px;
  border-radius: 12px;
  font-size: 12px;
  font-weight: 600;
  color: var(--text);
  background: var(--bg);
  border: 1px solid var(--border);
  cursor: pointer;
  transition: all 0.2s ease;
  font-family: inherit;
}

.gen-history-action:hover {
  border-color: var(--primary);
  color: var(--primary);
  background: rgba(255, 107, 53, 0.06);
}

/* ---- 名师讲堂（精选资源占位页） ---- */
.masterclass-view {
  display: flex;
  flex-direction: column;
  min-height: calc(100vh - 140px);
  padding: 28px 32px;
}

.masterclass-empty {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  color: var(--text-light);
  padding: 60px 20px;
}

.masterclass-empty-icon {
  font-size: 56px;
  margin-bottom: 16px;
  opacity: 0.7;
}

.masterclass-empty-title {
  font-size: 16px;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 8px;
}

.masterclass-empty-sub {
  font-size: 13px;
  color: var(--text-light);
}

/* ---- 移动端适配 ---- */
@media (max-width: 900px) {
  .generate-main {
    flex-direction: column;
  }

  .gen-form-panel {
    flex: none;
    width: 100%;
  }

  .credits-prices {
    margin-left: 0;
  }
}

@media (max-width: 480px) {
  .generate-view {
    padding: 20px 16px;
  }

  .masterclass-view {
    padding: 20px 16px;
  }

  .history-media {
    width: 110px;
    height: 72px;
  }

  .gen-select-row {
    flex-direction: column;
    gap: 0;
  }

  .generate-tabs {
    gap: 6px;
  }

  .gen-tab {
    padding: 10px 6px;
    font-size: 13px;
  }
}
