/* style.css — 简单干净的两栏布局 + 高亮字幕列表 + AI 生成模态框 + AI 微调模态
   + 新：拖拽/点击 MP4 上传控件 */

*,
*::before,
*::after {
  box-sizing: border-box;
}

body {
  margin: 0;
  padding: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto,
    "Helvetica Neue", Arial, "Noto Sans SC", "Microsoft YaHei", sans-serif;
  background: #0f172a;
  color: #e5e7eb;
}

.app-container {
  max-width: 1200px;
  margin: 0 auto;
  padding: 24px 16px 40px;
}

.app-header {
  margin-bottom: 20px;
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 14px;
  flex-wrap: wrap;
}

.header-left {
  min-width: 0;
}

.header-right {
  display: flex;
  align-items: center;
  gap: 10px;
}

.app-header h1 {
  margin: 0 0 4px;
  font-size: 24px;
  color: #f9fafb;
}

.app-subtitle {
  margin: 0;
  font-size: 14px;
  color: #9ca3af;
}

/* 语言切换 */
.lang-switch {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  border: 1px solid #1f2937;
  border-radius: 9999px;
  background: rgba(2, 6, 23, 0.8);
}

.lang-label {
  font-size: 12px;
  color: #9ca3af;
  white-space: nowrap;
}

.lang-buttons {
  display: flex;
  gap: 8px;
}

.lang-btn {
  padding: 6px 12px;
  font-size: 12px;
  border-radius: 9999px;
  border: 1px solid #374151;
  background: #111827;
  color: #e5e7eb;
  box-shadow: none;
}

.lang-btn:hover {
  background: #030712;
}

.lang-btn.is-active {
  border-color: #38bdf8;
  box-shadow: 0 0 0 1px rgba(56, 189, 248, 0.5);
}

.app-main {
  display: flex;
  gap: 16px;
  align-items: flex-start;
}

/* 左右两栏 */
.left-panel,
.right-panel {
  background: #020617;
  border-radius: 12px;
  padding: 16px;
  box-shadow: 0 10px 30px rgba(15, 23, 42, 0.8);
}

.left-panel {
  flex: 3;
  min-width: 0;
}

.right-panel {
  flex: 2;
  min-width: 0;
  max-height: calc(100vh - 140px);
  overflow: hidden;
}

/* 通用块 */
.panel-block {
  margin-bottom: 16px;
}

.block-label {
  display: block;
  font-size: 13px;
  font-weight: 600;
  margin-bottom: 6px;
  color: #d1d5db;
}

/* 剧本文本框 */
.script-input {
  width: 100%;
  min-height: 160px;
  resize: vertical;
  padding: 10px 12px;
  border-radius: 8px;
  border: 1px solid #1f2937;
  background: #020617;
  color: #e5e7eb;
  font-size: 13px;
  line-height: 1.5;
}

.script-input:focus {
  outline: none;
  border-color: #38bdf8;
  box-shadow: 0 0 0 1px #38bdf8;
}

/* 隐藏原生文件input（用于弹出选择文件） */
.file-input-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  border: 0;
}

/* 新：拖拽 / 点击上传控件 */
.file-drop {
  border: 1px dashed #374151;
  background: rgba(17, 24, 39, 0.35);
  border-radius: 14px;
  padding: 14px 14px;
  display: flex;
  align-items: center;
  gap: 12px;
  cursor: pointer;
  transition: border-color 0.15s ease, background 0.15s ease,
    transform 0.1s ease, box-shadow 0.15s ease;
  user-select: none;
}

.file-drop:hover {
  border-color: rgba(56, 189, 248, 0.9);
  background: rgba(56, 189, 248, 0.06);
  transform: translateY(-1px);
}

.file-drop:focus {
  outline: none;
  border-color: rgba(56, 189, 248, 1);
  box-shadow: 0 0 0 2px rgba(56, 189, 248, 0.25);
}

.file-drop.dragover {
  border-color: #22c55e;
  background: rgba(34, 197, 94, 0.08);
  box-shadow: 0 0 0 2px rgba(34, 197, 94, 0.18);
}

.file-drop-icon {
  width: 38px;
  height: 38px;
  border-radius: 12px;
  display: grid;
  place-items: center;
  background: rgba(148, 163, 184, 0.15);
  color: #e5e7eb;
  font-weight: 700;
  flex: 0 0 auto;
}

.file-drop-main {
  min-width: 0;
  flex: 1;
}

.file-drop-title {
  font-size: 13px;
  font-weight: 700;
  color: #e5e7eb;
  line-height: 1.2;
}

.file-drop-sub {
  margin-top: 2px;
  font-size: 12px;
  color: #9ca3af;
}

.file-drop-meta {
  margin-top: 6px;
  font-size: 12px;
  color: #cbd5e1;
  font-family: "SF Mono", Menlo, Monaco, Consolas, "Liberation Mono",
    monospace;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.file-clear-btn {
  padding: 6px 12px;
  font-size: 12px;
  border-radius: 9999px;
  border: 1px solid #374151;
  background: #111827;
  color: #e5e7eb;
  flex: 0 0 auto;
  box-shadow: none;
}

.file-clear-btn:hover:not(:disabled) {
  background: #030712;
  transform: translateY(-1px);
}

/* 文件选择提示 */
.hint-text {
  margin: 8px 0 0;
  font-size: 12px;
  color: #6b7280;
}

/* 按钮行 */
.button-row {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

button {
  cursor: pointer;
  border: none;
  border-radius: 9999px;
  padding: 8px 16px;
  font-size: 13px;
  font-weight: 600;
  white-space: nowrap;
  transition: background 0.15s ease, transform 0.1s ease,
    box-shadow 0.15s ease;
}

button:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  box-shadow: none;
  transform: none;
}

.primary-btn {
  background: linear-gradient(135deg, #22c55e, #16a34a);
  color: #f9fafb;
  box-shadow: 0 10px 20px rgba(34, 197, 94, 0.4);
}

.primary-btn:hover:not(:disabled) {
  background: linear-gradient(135deg, #16a34a, #15803d);
  transform: translateY(-1px);
}

.secondary-btn {
  background: #111827;
  color: #e5e7eb;
  border: 1px solid #374151;
}

.secondary-btn:hover:not(:disabled) {
  background: #030712;
  transform: translateY(-1px);
}

/* 视频播放器 */
.video-player {
  width: 100%;
  max-height: 360px;
  background: #020617;
  border-radius: 12px;
  border: 1px solid #1f2937;
}

/* 状态栏 */
.status-area {
  margin-top: 4px;
  padding: 8px 10px;
  border-radius: 8px;
  font-size: 12px;
  min-height: 30px;
  display: flex;
  align-items: center;
}

.status-area:empty {
  padding: 0;
  min-height: 0;
}

.status-info {
  background: rgba(55, 65, 81, 0.4);
  color: #e5e7eb;
}

.status-success {
  background: rgba(22, 163, 74, 0.15);
  color: #bbf7d0;
}

.status-error {
  background: rgba(220, 38, 38, 0.18);
  color: #fecaca;
}

.status-loading {
  background: rgba(59, 130, 246, 0.18);
  color: #bfdbfe;
}

/* 右侧字幕列表 */
.subtitle-header {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 6px;
  margin-bottom: 8px;
}

.subtitle-hint {
  font-size: 11px;
  color: #6b7280;
}

.subtitle-list {
  border-radius: 8px;
  border: 1px solid #1f2937;
  background: #020617;
  padding: 4px;
  max-height: calc(100vh - 180px);
  overflow-y: auto;
  font-size: 12px;
}

.subtitle-empty {
  padding: 12px;
  text-align: center;
  color: #6b7280;
}

/* 单条字幕 */
.subtitle-item {
  padding: 8px 10px;
  border-radius: 6px;
  margin-bottom: 4px;
  cursor: pointer;
  transition: background 0.12s ease, transform 0.08s ease,
    box-shadow 0.12s ease;
}

.subtitle-item:hover {
  background: rgba(31, 41, 55, 0.8);
  transform: translateY(-1px);
}

.subtitle-item.active {
  background: rgba(56, 189, 248, 0.16);
  border: 1px solid #38bdf8;
  box-shadow: 0 0 0 1px rgba(56, 189, 248, 0.5);
}

.subtitle-time {
  font-family: "SF Mono", Menlo, Monaco, Consolas, "Liberation Mono",
    monospace;
  font-size: 11px;
  color: #9ca3af;
  margin-bottom: 2px;
}

.subtitle-text {
  white-space: pre-wrap;
  word-break: break-all;
  color: #e5e7eb;
  line-height: 1.4;
}

/* 字幕编辑按钮区域 */
.subtitle-edit-row {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 6px;
}

.subtitle-edit-btn {
  padding: 3px 10px;
  font-size: 11px;
  border-radius: 9999px;
  border: 1px dashed #374151;
  background: #020617;
  color: #9ca3af;
}

.subtitle-edit-btn:hover {
  background: #111827;
  color: #e5e7eb;
  border-style: solid;
}

/* AI 微调按钮靠最右 */
.subtitle-ai-btn {
  margin-left: auto;
  border-color: #38bdf8;
}

/* AI 生成中模态窗口 / AI 微调模态通用遮罩 */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.75);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 9999;
}

/* 加上 .show 时显示模态 */
.modal-overlay.show {
  display: flex;
}

.modal-box {
  width: 220px;
  min-height: 180px;
  border-radius: 18px;
  background: radial-gradient(circle at top left, #1d283a, #020617 60%);
  box-shadow: 0 20px 40px rgba(15, 23, 42, 0.9);
  padding: 20px 18px 18px;
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  animation: modalPopIn 0.25s ease-out;
}

/* 中间小圆环旋转动画（整体生成用） */
.modal-spinner {
  width: 42px;
  height: 42px;
  border-radius: 999px;
  border: 3px solid rgba(148, 163, 184, 0.4);
  border-top-color: #38bdf8;
  border-right-color: #22c55e;
  animation: spinnerRotate 0.9s linear infinite;
  margin-bottom: 14px;
}

.modal-title {
  margin: 0 0 6px;
  font-size: 14px;
  font-weight: 600;
  color: #e5e7eb;
}

.modal-text {
  margin: 0;
  font-size: 12px;
  color: #9ca3af;
  line-height: 1.5;
}

/* AI 微调模态的布局稍微大一点，左对齐输入 */
.ai-modal-box {
  width: 380px;
  max-width: 92vw;
  min-height: 260px;
  align-items: stretch;
  text-align: left;
}

.ai-subtitle-info {
  margin: 0 0 6px;
  font-size: 12px;
  color: #9ca3af;
}

.ai-hint-text {
  margin: 0 0 8px;
  font-size: 11px;
  color: #6b7280;
  line-height: 1.5;
}

.ai-instruction-input {
  width: 100%;
  min-height: 120px;
  resize: vertical;
  padding: 8px 10px;
  border-radius: 10px;
  border: 1px solid #1f2937;
  background: #020617;
  color: #e5e7eb;
  font-size: 12px;
  line-height: 1.5;
  margin-bottom: 10px;
}

.ai-instruction-input:focus {
  outline: none;
  border-color: #38bdf8;
  box-shadow: 0 0 0 1px #38bdf8;
}

.ai-modal-buttons {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
}

/* 模态弹出 & 旋转动画 */
@keyframes modalPopIn {
  from {
    opacity: 0;
    transform: scale(0.9) translateY(4px);
  }
  to {
    opacity: 1;
    transform: scale(1) translateY(0);
  }
}

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

/* 响应式：窄屏改为上下布局 */
@media (max-width: 900px) {
  .app-main {
    flex-direction: column;
  }

  .right-panel {
    max-height: none;
  }

  .subtitle-list {
    max-height: 260px;
  }

  .ai-modal-box {
    width: 92vw;
  }
}

/* 顶部额度条：显示 SRT & AI 微调剩余次数 */
.quota-bar {
  margin: 0 0 12px;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.quota-item {
  padding: 6px 10px;
  border-radius: 9999px;
  background: rgba(15, 23, 42, 0.9);
  border: 1px solid rgba(55, 65, 81, 0.9);
  font-size: 12px;
  color: #e5e7eb;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  box-shadow: 0 6px 18px rgba(15, 23, 42, 0.7);
}

.quota-text {
  white-space: nowrap;
}

/* 窄屏时额度条自动换行居左显示 */
@media (max-width: 900px) {
  .quota-bar {
    justify-content: flex-start;
  }
}
