/* style.css - H5移动端优先样式 */

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

:root {
  --primary: #6C5CE7;
  --primary-light: #a29bfe;
  --bg: #0F0F1A;
  --surface: #1A1A2E;
  --surface-2: #252540;
  --text: #E8E8F0;
  --text-dim: #8888A8;
  --success: #00CEC9;
  --warning: #FDCB6E;
  --error: #FF6B6B;
  --border: #2D2D4A;
  --radius: 12px;
}

html, body {
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Microsoft YaHei", "Segoe UI", sans-serif;
  font-size: 15px;
  line-height: 1.6;
  overscroll-behavior: none;
}

/* 顶部栏 */
#header {
  position: sticky;
  top: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  background: rgba(15, 15, 26, 0.95);
  backdrop-filter: blur(20px);
  border-bottom: 1px solid var(--border);
}
.header-left h1 {
  font-size: 18px;
  font-weight: 700;
  color: var(--text);
}

.header-right {
  display: flex;
  align-items: center;
  gap: 8px;
}
/* 全自动按钮 */
.btn-auto {
  background: linear-gradient(135deg, #6C5CE7, #00CEC9);
  color: white;
  border: none;
  padding: 8px 14px;
  border-radius: 20px;
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
  white-space: nowrap;
  display: flex;
  align-items: center;
  gap: 4px;
  transition: opacity 0.2s, transform 0.1s;
}
.btn-auto:active { transform: scale(0.95); }
.btn-auto:disabled { opacity: 0.5; }
.btn-auto.running {
  background: linear-gradient(135deg, #FF6B6B, #FDCB6E);
  animation: pulse 1.5s ease-in-out infinite;
}
@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.7; }
}

.icon-btn {
  background: none;
  border: none;
  font-size: 22px;
  color: var(--text-dim);
  cursor: pointer;
  padding: 8px;
}
.icon-btn:active { transform: scale(0.9); }

/* 步骤导航条 */
#stepNav {
  position: sticky;
  top: 56px;
  z-index: 90;
  background: rgba(15, 15, 26, 0.95);
  backdrop-filter: blur(20px);
  border-bottom: 1px solid var(--border);
  padding: 8px 0 0;
}
.nav-track {
  display: flex;
  overflow-x: auto;
  gap: 4px;
  padding: 0 12px;
  scrollbar-width: none;
  -ms-overflow-style: none;
}
.nav-track::-webkit-scrollbar { display: none; }

.nav-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  padding: 6px 8px;
  min-width: 56px;
  cursor: pointer;
  border-radius: 8px;
  transition: background 0.2s;
  flex-shrink: 0;
}
.nav-item:active { background: var(--surface-2); }

.nav-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: var(--surface-2);
  color: var(--text-dim);
  font-weight: 700;
  font-size: 13px;
  border: 2px solid transparent;
  transition: all 0.25s;
}
.nav-label {
  font-size: 11px;
  color: var(--text-dim);
  white-space: nowrap;
  transition: color 0.25s;
}

/* 未完成（待办）步骤 */
.nav-item.pending .nav-icon {
  background: var(--surface-2);
  color: var(--text-dim);
  border-color: var(--border);
}
.nav-item.pending .nav-label { color: var(--text-dim); }

/* 已完成步骤 */
.nav-item.completed .nav-icon {
  background: var(--success);
  color: var(--bg);
  border-color: var(--success);
}
.nav-item.completed .nav-label { color: var(--success); }

/* 当前步骤（高亮） */
.nav-item.current .nav-icon {
  background: var(--primary);
  color: white;
  border-color: var(--primary-light);
  box-shadow: 0 0 12px rgba(108, 92, 231, 0.5);
  transform: scale(1.1);
}
.nav-item.current .nav-label {
  color: var(--primary-light);
  font-weight: 700;
}
.nav-item.current {
  background: rgba(108, 92, 231, 0.08);
}

/* 运行中步骤 */
.nav-item.running .nav-icon {
  background: var(--warning);
  color: var(--bg);
  border-color: var(--warning);
  animation: spin 1s linear infinite;
}

/* 进度条 */
.nav-progress-bar {
  height: 3px;
  background: var(--surface-2);
  position: relative;
  overflow: hidden;
}
.nav-progress-fill {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, var(--primary), var(--success));
  border-radius: 2px;
  transition: width 0.4s ease;
}

/* 主区域 */
#main {
  padding: 0;
  max-width: 600px;
  margin: 0 auto;
  height: calc(100vh - 56px - 49px - 42px);
  overflow: hidden;
}

/* 步骤面板：整体可滚动，底部按钮sticky固定 */
.step-panel {
  display: none;
  flex-direction: column;
  height: 100%;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding: 0 12px;
  animation: fadeIn 0.3s ease;
}
.step-panel.active {
  display: flex;
}
@keyframes fadeIn {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}
.panel-header {
  margin: 12px 0 8px;
  flex-shrink: 0;
}
.panel-header h2 {
  font-size: 18px;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 4px;
}
.panel-desc {
  font-size: 13px;
  color: var(--text-dim);
}

/* 按钮 */
.btn-primary, .btn-secondary {
  display: inline-block;
  width: 100%;
  padding: 12px 20px;
  border: none;
  border-radius: var(--radius);
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  text-align: center;
  text-decoration: none;
  transition: opacity 0.2s, transform 0.1s;
}
.btn-primary {
  background: var(--primary);
  color: white;
}
.btn-primary:active { transform: scale(0.97); }
.btn-primary:disabled {
  opacity: 0.5;
}
.btn-secondary {
  background: var(--surface-2);
  color: var(--text);
}
.btn-row {
  display: flex;
  gap: 8px;
  margin: 8px -12px 0;
  padding: 8px 12px 12px;
  position: sticky;
  bottom: 0;
  background: var(--bg);
  border-top: 1px solid var(--border);
  z-index: 10;
}
.btn-row .btn-primary, .btn-row .btn-secondary {
  width: auto;
  flex: 1;
}

/* 话题卡片 */
.topic-list {
  margin-top: 12px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

/* 自定义话题输入 */
.custom-input-row {
  display: flex;
  gap: 8px;
}
.custom-topic-input {
  flex: 1;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  padding: 10px 12px;
  font-size: 14px;
  font-family: inherit;
}
.custom-topic-input:focus {
  outline: none;
  border-color: var(--primary);
}
.topic-card {
  background: var(--surface-2);
  border-radius: var(--radius);
  padding: 14px;
  border: 1px solid var(--border);
  cursor: pointer;
  transition: border-color 0.2s;
}
.topic-card:active {
  border-color: var(--primary);
}
.topic-card.selected {
  border-color: var(--primary);
  background: rgba(108, 92, 231, 0.1);
}
.topic-card .topic-title {
  font-weight: 700;
  font-size: 15px;
  margin-bottom: 4px;
}
.topic-card .topic-hook {
  color: var(--warning);
  font-size: 13px;
  margin-bottom: 6px;
}
.topic-card .topic-meta {
  display: flex;
  justify-content: space-between;
  font-size: 12px;
  color: var(--text-dim);
}
.topic-card .heat {
  color: var(--error);
}

/* 脚本展示 */
.script-display {
  background: var(--surface-2);
  border-radius: var(--radius);
  padding: 14px;
  margin-top: 12px;
}
.script-display .seg {
  margin-bottom: 12px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--border);
}
.script-display .seg:last-child { border: none; margin: 0; }
.script-display .seg-stage {
  color: var(--primary-light);
  font-weight: 700;
  font-size: 13px;
  margin-bottom: 2px;
}
.script-display .seg-time {
  color: var(--text-dim);
  font-size: 12px;
}
.script-display .seg-narration {
  margin-top: 6px;
}
.script-display .seg-visual {
  color: var(--text-dim);
  font-size: 13px;
  margin-top: 4px;
  font-style: italic;
}

/* 编辑器 */
.editor {
  width: 100%;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  padding: 12px;
  font-family: inherit;
  font-size: 14px;
  resize: vertical;
  margin-top: 12px;
}

/* 分镜表 */
.storyboard-table {
  margin-top: 12px;
}
.sb-item {
  background: var(--surface-2);
  border-radius: var(--radius);
  padding: 12px;
  margin-bottom: 8px;
  border: 1px solid var(--border);
}
.sb-item .sb-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 6px;
}
.sb-item .sb-id {
  background: var(--primary);
  color: white;
  padding: 2px 8px;
  border-radius: 6px;
  font-size: 12px;
  font-weight: 700;
}
.sb-item .sb-duration {
  color: var(--success);
  font-size: 13px;
}
.sb-item .sb-narration {
  font-size: 14px;
  margin-bottom: 4px;
}
.sb-item .sb-scene {
  color: var(--text-dim);
  font-size: 13px;
}
.sb-item .sb-camera {
  margin-top: 4px;
  font-size: 12px;
  color: var(--primary-light);
}

/* 自检报告 */
.review-report {
  background: var(--surface-2);
  border-radius: var(--radius);
  padding: 14px;
  margin-top: 12px;
  border-left: 3px solid var(--warning);
}
.review-report h4 {
  color: var(--warning);
  margin-bottom: 8px;
}
.review-report .issue {
  font-size: 13px;
  margin-bottom: 4px;
  padding-left: 16px;
  position: relative;
}
.review-report .issue::before {
  content: "⚠";
  position: absolute;
  left: 0;
}

/* 图片预览 */
.image-preview {
  margin-top: 12px;
}
.image-preview img {
  width: 100%;
  border-radius: var(--radius);
  border: 1px solid var(--border);
}
.image-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 8px;
  margin-top: 12px;
}
.image-grid .img-cell {
  position: relative;
}
.image-grid .img-cell img {
  width: 100%;
  border-radius: 8px;
  border: 1px solid var(--border);
}
.image-grid .img-cell .img-label {
  font-size: 11px;
  color: var(--text-dim);
  text-align: center;
  margin-top: 2px;
}

/* Prompt展示 */
.prompt-item {
  background: var(--surface-2);
  border-radius: var(--radius);
  padding: 10px 12px;
  margin-bottom: 8px;
  border: 1px solid var(--border);
}
.prompt-item .prompt-id {
  color: var(--primary-light);
  font-size: 12px;
  font-weight: 700;
  margin-bottom: 4px;
}
.prompt-item .prompt-text {
  font-size: 13px;
  color: var(--text);
  word-break: break-all;
}
.prompt-item .prompt-narration {
  font-size: 12px;
  color: var(--text-dim);
  margin-top: 4px;
  font-style: italic;
}

/* 进度容器 */
.progress-container {
  margin-top: 12px;
}
.progress-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 0;
  font-size: 13px;
}
.progress-item .prog-icon {
  font-size: 16px;
  width: 20px;
}
.progress-item .prog-text {
  flex: 1;
}
.progress-item .prog-status {
  color: var(--text-dim);
  font-size: 12px;
}

/* 视频网格 */
.video-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 8px;
  margin-top: 12px;
}
.video-grid video {
  width: 100%;
  border-radius: var(--radius);
  border: 1px solid var(--border);
}

/* 弹窗 */
.modal {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.7);
  z-index: 200;
  display: flex;
  align-items: flex-end;
  justify-content: center;
}
.modal-content {
  background: var(--surface);
  width: 100%;
  max-width: 600px;
  border-radius: 16px 16px 0 0;
  max-height: 85vh;
  overflow-y: auto;
}
.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 16px;
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  background: var(--surface);
}
.modal-body {
  padding: 16px;
}

/* 表单 */
.form-group {
  margin-bottom: 16px;
}
.form-group label {
  display: block;
  font-weight: 600;
  margin-bottom: 6px;
  font-size: 14px;
}
.form-group input,
.form-group select,
.form-group textarea {
  width: 100%;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text);
  padding: 10px 12px;
  font-size: 14px;
  font-family: inherit;
}
.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
  outline: none;
  border-color: var(--primary);
}
.form-group small {
  display: block;
  color: var(--text-dim);
  font-size: 12px;
  margin-top: 4px;
}

/* 配置分区 */
.config-section {
  margin-bottom: 20px;
  padding-bottom: 16px;
  border-bottom: 1px solid var(--border);
}
.config-section:last-of-type {
  border-bottom: none;
}
.config-section-title {
  font-size: 15px;
  font-weight: 700;
  color: var(--primary-light);
  margin-bottom: 12px;
}

/* 测试连接按钮 */
.btn-test {
  display: block;
  width: 100%;
  padding: 8px 14px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  margin-top: 8px;
}
.btn-test:active { transform: scale(0.97); }
.btn-test:disabled { opacity: 0.5; }

/* 测试结果 */
.test-result {
  margin-top: 6px;
  padding: 6px 10px;
  border-radius: 6px;
  font-size: 12px;
  line-height: 1.5;
  word-break: break-all;
}
.test-result.success {
  background: rgba(0, 206, 201, 0.1);
  border-left: 3px solid var(--success);
  color: var(--success);
}
.test-result.error {
  background: rgba(255, 107, 107, 0.1);
  border-left: 3px solid var(--error);
  color: var(--error);
}
.test-result.testing {
  background: rgba(253, 203, 110, 0.1);
  border-left: 3px solid var(--warning);
  color: var(--warning);
}

/* 全局Loading */
.global-loading {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.8);
  z-index: 300;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 16px;
}
.loading-spinner {
  width: 40px;
  height: 40px;
  border: 3px solid var(--surface-2);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}
@keyframes spin {
  to { transform: rotate(360deg); }
}
.global-loading p {
  color: var(--text);
  font-size: 14px;
}

/* 视图容器 */
.view-container {
  padding: 12px;
  max-width: 600px;
  margin: 0 auto;
  padding-bottom: 60px;
}

/* 项目列表视图 */
.view-header {
  margin-bottom: 16px;
}
.view-header h2 {
  font-size: 20px;
  font-weight: 700;
  margin-bottom: 4px;
}
.view-desc {
  font-size: 13px;
  color: var(--text-dim);
}

.project-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

/* 空状态 */
.empty-state {
  text-align: center;
  padding: 60px 20px;
  color: var(--text-dim);
}
.empty-icon {
  font-size: 48px;
  margin-bottom: 12px;
}

/* 项目卡片 */
.project-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px;
  cursor: pointer;
  transition: border-color 0.2s, transform 0.1s;
}
.project-card:active {
  border-color: var(--primary);
  transform: scale(0.98);
}
.project-card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 8px;
}
.project-card .project-title {
  font-size: 15px;
  font-weight: 700;
  color: var(--text);
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.badge-done {
  background: rgba(0, 206, 201, 0.15);
  color: var(--success);
  font-size: 11px;
  padding: 2px 8px;
  border-radius: 10px;
  white-space: nowrap;
  margin-left: 8px;
}
.project-card-meta {
  display: flex;
  gap: 12px;
  font-size: 12px;
  color: var(--text-dim);
  margin-bottom: 8px;
  flex-wrap: wrap;
}
.project-time {
  margin-left: auto;
}
.project-progress-bar {
  height: 4px;
  background: var(--surface-2);
  border-radius: 2px;
  overflow: hidden;
}
.project-progress-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--primary), var(--success));
  border-radius: 2px;
  transition: width 0.3s;
}

/* 项目工作台工具栏 */
.project-toolbar {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 0;
  margin-bottom: 8px;
}
.btn-back {
  background: var(--surface-2);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 6px 12px;
  border-radius: 8px;
  font-size: 13px;
  cursor: pointer;
  white-space: nowrap;
}
.btn-back:active { transform: scale(0.95); }
.project-title-display {
  flex: 1;
  font-size: 15px;
  font-weight: 700;
  color: var(--text);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* 工具类 */
.hidden { display: none !important; }

/* 滚动条 */
::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: var(--bg); }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }

/* 响应式 - 平板/桌面 */
@media (min-width: 768px) {
  #main { max-width: 700px; }
  .image-grid { grid-template-columns: repeat(3, 1fr); }
}
