/* ========================================
   speech-to-text-web — 字幕样式
   ======================================== */

/* ---- Reset & Base ---- */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

:root {
  --bg-primary: #0f0f1a;
  --bg-secondary: #1a1a2e;
  --bg-card: #16213e;
  --text-primary: #e8e8f0;
  --text-secondary: #9a9ab0;
  --accent: #4fc3f7;
  --accent-hover: #29b6f6;
  --green: #66bb6a;
  --red: #ef5350;
  --orange: #ffa726;
  --border: #2a2a40;
  --radius: 10px;
  --shadow: 0 4px 24px rgba(0,0,0,0.4);
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'PingFang SC',
               'Microsoft YaHei', sans-serif;
  background: var(--bg-primary);
  color: var(--text-primary);
  min-height: 100vh;
  display: flex;
  justify-content: center;
  align-items: center;
}

/* ---- Layout ---- */
.app-container {
  width: 100%;
  max-width: 860px;
  margin: 20px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

/* ---- Header ---- */
.app-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 20px;
  background: var(--bg-secondary);
  border-radius: var(--radius);
  border: 1px solid var(--border);
}

.app-title {
  font-size: 18px;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 8px;
}

.app-title .icon {
  font-size: 22px;
}

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

.badge {
  font-size: 12px;
  padding: 4px 10px;
  border-radius: 20px;
  font-weight: 500;
}

.badge-idle {
  background: var(--border);
  color: var(--text-secondary);
}

.badge-recording {
  background: rgba(239, 83, 80, 0.2);
  color: var(--red);
  animation: pulse 1.5s infinite;
}

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.6; }
}

/* ---- Subtitle Display (类视频字幕) ---- */
.subtitle-stage {
  position: relative;
  background: #000;
  border-radius: var(--radius);
  min-height: 220px;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  align-items: center;
  padding: 24px 30px 50px;
  border: 1px solid var(--border);
  overflow: hidden;
}

.subtitle-stage::before {
  content: '🎬';
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  font-size: 48px;
  opacity: 0.12;
  pointer-events: none;
  transition: opacity 0.4s;
}

.subtitle-stage.active::before {
  opacity: 0.04;
}

#subtitle-box {
  text-align: center;
  width: 100%;
  min-height: 80px;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  gap: 6px;
}

.subtitle-item {
  background: rgba(0, 0, 0, 0.7);
  color: #fff;
  padding: 6px 16px;
  border-radius: 4px;
  font-size: 22px;
  line-height: 1.5;
  display: inline-block;
  align-self: center;
  max-width: 95%;
  text-shadow: 1px 1px 2px rgba(0,0,0,0.8);
  animation: fadeIn 0.3s ease;
}

.subtitle-item:first-child {
  font-size: 18px;
  opacity: 0.7;
}

.subtitle-item:last-child {
  font-size: 26px;
  font-weight: 500;
}

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

#interim-line {
  min-height: 28px;
  font-size: 20px;
  color: rgba(255, 255, 255, 0.5);
  text-align: center;
  margin-top: 12px;
  font-style: italic;
}

/* ---- Controls ---- */
.controls {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 14px 20px;
  background: var(--bg-secondary);
  border-radius: var(--radius);
  border: 1px solid var(--border);
  flex-wrap: wrap;
}

.btn {
  padding: 10px 20px;
  border: none;
  border-radius: 8px;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  white-space: nowrap;
}

.btn:active { transform: scale(0.97); }

.btn-start {
  background: var(--green);
  color: #fff;
}

.btn-start:hover { background: #57b85b; }

.btn-stop {
  background: var(--red);
  color: #fff;
  animation: pulse 1.5s infinite;
}

.btn-stop:hover { background: #e53935; }

.btn-secondary {
  background: var(--bg-card);
  color: var(--text-primary);
  border: 1px solid var(--border);
}

.btn-secondary:hover {
  background: #1e2a4a;
  border-color: var(--accent);
}

.btn-danger {
  background: transparent;
  color: var(--text-secondary);
  border: 1px solid var(--border);
}

.btn-danger:hover {
  color: var(--red);
  border-color: var(--red);
}

select.lang-select {
  background: var(--bg-card);
  color: var(--text-primary);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px 12px;
  font-size: 14px;
  cursor: pointer;
  outline: none;
}

select.lang-select:focus {
  border-color: var(--accent);
}

.spacer { flex: 1; }

/* ---- History Panel ---- */
.history-panel {
  background: var(--bg-secondary);
  border-radius: var(--radius);
  border: 1px solid var(--border);
  max-height: 320px;
  display: flex;
  flex-direction: column;
}

.panel-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 20px;
  border-bottom: 1px solid var(--border);
  font-size: 13px;
  color: var(--text-secondary);
}

.panel-header strong {
  color: var(--text-primary);
}

#history-list {
  flex: 1;
  overflow-y: auto;
  padding: 4px 0;
}

#history-list:empty::after {
  content: '暂无字幕记录，点击「开始录音」...';
  display: block;
  text-align: center;
  color: var(--text-secondary);
  padding: 40px 20px;
  font-size: 14px;
}

.history-item {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 8px 20px;
  border-bottom: 1px solid rgba(255,255,255,0.04);
  transition: background 0.15s;
}

.history-item:hover {
  background: rgba(79, 195, 247, 0.05);
}

.history-time {
  font-size: 12px;
  color: var(--text-secondary);
  font-family: 'Courier New', monospace;
  min-width: 70px;
  flex-shrink: 0;
  padding-top: 2px;
}

.history-text {
  flex: 1;
  font-size: 14px;
  line-height: 1.5;
}

.history-del {
  background: none;
  border: none;
  color: var(--text-secondary);
  cursor: pointer;
  font-size: 13px;
  padding: 2px 4px;
  opacity: 0;
  transition: opacity 0.15s, color 0.15s;
  flex-shrink: 0;
}

.history-item:hover .history-del {
  opacity: 1;
}

.history-del:hover {
  color: var(--red);
}

/* ---- Toast ---- */
.toast {
  position: fixed;
  bottom: 30px;
  left: 50%;
  transform: translateX(-50%) translateY(20px);
  padding: 12px 28px;
  border-radius: 8px;
  font-size: 14px;
  font-weight: 500;
  opacity: 0;
  transition: all 0.3s;
  pointer-events: none;
  z-index: 999;
}

.toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

.toast-success { background: var(--green); color: #fff; }
.toast-error   { background: var(--red); color: #fff; }
.toast-warn    { background: var(--orange); color: #000; }
.toast-info    { background: var(--accent); color: #000; }

/* ---- Dep Status Banner ---- */
.dep-status {
  background: rgba(239, 83, 80, 0.15);
  border: 1px solid var(--red);
  color: var(--red);
  padding: 12px 20px;
  border-radius: var(--radius);
  font-size: 14px;
  line-height: 1.6;
  display: none;
}

/* ---- Scrollbar ---- */
#history-list::-webkit-scrollbar { width: 6px; }
#history-list::-webkit-scrollbar-track { background: transparent; }
#history-list::-webkit-scrollbar-thumb {
  background: var(--border);
  border-radius: 3px;
}

/* ========================================
   模式切换标签
   ======================================== */
.tab-bar {
  display: flex;
  gap: 4px;
  padding: 4px;
  background: var(--bg-secondary);
  border-radius: var(--radius);
  border: 1px solid var(--border);
}

.tab-btn {
  flex: 1;
  padding: 10px 16px;
  border: none;
  border-radius: 8px;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  background: transparent;
  color: var(--text-secondary);
  transition: all 0.2s;
}

.tab-btn:hover {
  color: var(--text-primary);
  background: rgba(255,255,255,0.04);
}

.tab-btn.active {
  background: var(--accent);
  color: #000;
}

/* ========================================
   面板基础
   ======================================== */
.panel {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.ctrl-label {
  color: var(--text-secondary);
  font-size: 13px;
  white-space: nowrap;
}

.accent { color: var(--accent); }
.hint { color: var(--text-secondary); font-size: 12px; }

/* ========================================
   文件模式 — 拖放区域
   ======================================== */
.dropzone {
  border: 2px dashed var(--border);
  border-radius: var(--radius);
  padding: 50px 20px;
  text-align: center;
  cursor: pointer;
  transition: all 0.25s;
  background: rgba(255,255,255,0.01);
}

.dropzone:hover,
.dropzone.dragover {
  border-color: var(--accent);
  background: rgba(79, 195, 247, 0.05);
}

.dropzone-icon {
  font-size: 48px;
  margin-bottom: 12px;
}

.dropzone-text {
  font-size: 16px;
  color: var(--text-primary);
  margin-bottom: 8px;
}

.dropzone-text strong {
  color: var(--accent);
}

.dropzone-hint {
  font-size: 13px;
  color: var(--text-secondary);
}

/* ========================================
   文件信息
   ======================================== */
.file-info {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 18px;
  background: var(--bg-card);
  border-radius: 8px;
  border: 1px solid var(--border);
}

.file-name {
  font-weight: 600;
  font-size: 14px;
  color: var(--text-primary);
  word-break: break-all;
}

.file-size {
  font-size: 12px;
  color: var(--text-secondary);
  white-space: nowrap;
}

/* ========================================
   服务器状态指示
   ======================================== */
.server-status {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  color: var(--text-secondary);
  padding: 6px 0;
}

.server-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  display: inline-block;
}

.server-dot.online {
  background: var(--green);
  box-shadow: 0 0 6px var(--green);
}

.server-dot.offline {
  background: var(--text-secondary);
}

.server-dot.checking {
  background: var(--orange);
  animation: pulse 1s infinite;
}

/* ========================================
   预览区域 + 视频播放器
   ======================================== */
.preview-area {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.player-wrapper {
  background: #000;
  border-radius: var(--radius);
  overflow: hidden;
  border: 1px solid var(--border);
  max-height: 400px;
}

.file-player {
  width: 100%;
  max-height: 400px;
  display: block;
  background: #000;
}

/* ========================================
   文件模式按钮变体
   ======================================== */
.btn-primary {
  background: var(--accent);
  color: #000;
}

.btn-primary:hover { background: var(--accent-hover); }

.btn-primary:disabled,
.btn-success:disabled,
.btn-secondary:disabled {
  opacity: 0.4;
  cursor: not-allowed;
  transform: none !important;
}

.btn-success {
  background: var(--green);
  color: #fff;
}

.btn-success:hover { background: #57b85b; }

.btn-sm {
  padding: 6px 12px;
  font-size: 13px;
}

.file-controls {
  flex-wrap: wrap;
}

/* ========================================
   进度条
   ======================================== */
.progress-area {
  display: flex;
  align-items: center;
  gap: 12px;
}

.progress-bar-bg {
  flex: 1;
  height: 6px;
  background: var(--border);
  border-radius: 3px;
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, var(--accent), var(--green));
  border-radius: 3px;
  transition: width 0.3s ease;
}

.progress-text {
  font-size: 13px;
  color: var(--text-secondary);
  white-space: nowrap;
  min-width: 100px;
  text-align: right;
}

/* ========================================
   转录结果预览
   ======================================== */
.transcript-list {
  max-height: 240px;
  overflow-y: auto;
  padding: 4px 0;
}

.transcript-list:empty::after {
  content: '暂无转录结果';
  display: block;
  text-align: center;
  color: var(--text-secondary);
  padding: 30px;
  font-size: 14px;
}

.transcript-item {
  display: flex;
  gap: 10px;
  padding: 6px 20px;
  font-size: 13px;
  border-bottom: 1px solid rgba(255,255,255,0.03);
}

.transcript-time {
  font-family: 'Courier New', monospace;
  color: var(--accent);
  min-width: 76px;
  flex-shrink: 0;
  padding-top: 1px;
}

.transcript-text {
  color: var(--text-primary);
  line-height: 1.4;
}

/* ========================================
   底部提示
   ======================================== */
.footer-hint {
  text-align: center;
  font-size: 12px;
  color: var(--text-secondary);
  padding: 8px 0 4px;
}

/* ========================================
   响应式适配
   ======================================== */
@media (max-width: 600px) {
  .app-container { margin: 10px; }
  .app-title { font-size: 15px; }
  .subtitle-stage { min-height: 160px; padding: 16px 16px 40px; }
  .subtitle-item { font-size: 18px; }
  .subtitle-item:last-child { font-size: 20px; }
  .controls { gap: 6px; }
  .btn { padding: 8px 14px; font-size: 13px; }
  .history-item { padding: 6px 14px; }
  .dropzone { padding: 30px 16px; }
  .dropzone-icon { font-size: 36px; }
  .file-player { max-height: 280px; }
}
