/* 重置和基础样式 */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

:root {
  --primary-color: #1890ff;
  --success-color: #52c41a;
  --danger-color: #ff4d4f;
  --warning-color: #faad14;
  --info-color: #13c2c2;
  --text-color: #333;
  --border-color: #d9d9d9;
  --bg-color: #f0f2f5;
  --card-bg: #ffffff;
  --shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
  background-color: var(--bg-color);
  color: var(--text-color);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  touch-action: manipulation;
}

.app-container {
  max-width: 100%;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* 头部 */
.app-header {
  background: linear-gradient(135deg, var(--primary-color), #096dd9);
  color: white;
  padding: 1rem;
  text-align: center;
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: var(--shadow);
}

.app-header h1 {
  font-size: 1.2rem;
  font-weight: 600;
  margin-bottom: 0.5rem;
}

/* 响应式头部 */
@media (max-width: 768px) {
  .app-header h1 {
    font-size: 1rem;
  }
}

/* 状态指示器 */
.status-indicator {
  display: inline-block;
  padding: 0.25rem 1rem;
  border-radius: 20px;
  font-size: 0.875rem;
  font-weight: 500;
}

.status-idle { background: rgba(255, 255, 255, 0.2); }
.status-listening { background: var(--success-color); animation: pulse 1.5s infinite; }
.status-processing { background: var(--warning-color); }
.status-error { background: var(--danger-color); }
.status-success { background: var(--success-color); }

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

/* 进度条 */
.progress-container {
  background: white;
  height: 2.5rem;
  position: relative;
  overflow: hidden;
}

.progress-bar {
  height: 100%;
  background: linear-gradient(90deg, var(--primary-color), var(--success-color));
  transition: width 0.3s ease;
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  font-weight: 600;
  font-size: 0.875rem;
}

/* 主内容 */
.main-content {
  flex: 1;
  padding: 1rem;
  overflow-y: auto;
}

/* 问题卡片 */
.question-section {
  margin-bottom: 1.5rem;
}

.question-card {
  background: var(--card-bg);
  padding: 1.5rem;
  border-radius: 12px;
  box-shadow: var(--shadow);
  border-left: 4px solid var(--primary-color);
}

.category-badge {
  display: inline-block;
  background: var(--primary-color);
  color: white;
  padding: 0.25rem 0.75rem;
  border-radius: 12px;
  font-size: 0.75rem;
  margin-bottom: 0.75rem;
}

/* 分支标记样式 */
.branch-badge {
  display: inline-block;
  background: var(--warning-color);
  color: white;
  padding: 0.25rem 0.75rem;
  border-radius: 12px;
  font-size: 0.75rem;
  margin-bottom: 0.75rem;
  margin-left: 0.5rem;
}

.question-badges {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.question-card.in-branch {
  border-left-color: var(--warning-color);
  background: linear-gradient(135deg, #fff9e6 0%, #ffffff 100%);
}

.question-card h3 {
  font-size: 1.25rem;
  color: var(--text-color);
  line-height: 1.8;
}

.completion-message {
  text-align: center;
  padding: 2rem;
  background: var(--card-bg);
  border-radius: 12px;
  box-shadow: var(--shadow);
}

.completion-message h2 {
  color: var(--success-color);
  font-size: 1.5rem;
}

.loading {
  text-align: center;
  padding: 2rem;
  color: #999;
}

/* 识别文本 */
.recognition-section {
  background: var(--card-bg);
  padding: 1rem;
  border-radius: 12px;
  margin-bottom: 1.5rem;
  box-shadow: var(--shadow);
}

.recognition-section h3 {
  font-size: 1rem;
  margin-bottom: 0.75rem;
  color: #666;
}

.recognized-text {
  min-height: 4rem;
  padding: 1rem;
  background: #fafafa;
  border-radius: 8px;
  font-size: 1.125rem;
  line-height: 1.8;
}

.interim-text {
  color: #999;
  font-style: italic;
}

.final-text {
  color: var(--text-color);
  font-weight: 500;
}

.placeholder {
  color: #bbb;
  font-size: 0.875rem;
}

/* 控制按钮 */
.controls-section {
  display: flex;
  gap: 1rem;
  margin-bottom: 1.5rem;
}

.btn {
  flex: 1;
  padding: 0.75rem 1.5rem;
  border: none;
  border-radius: 8px;
  font-size: 1rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.3s ease;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  box-shadow: var(--shadow);
}

.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.btn-large {
  padding: 1rem 2rem;
  font-size: 1.125rem;
}

.btn-primary {
  background: var(--primary-color);
  color: white;
}

.btn-primary:hover:not(:disabled) {
  background: #096dd9;
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(24, 144, 255, 0.4);
}

.btn-danger {
  background: var(--danger-color);
  color: white;
}

.btn-danger:hover:not(:disabled) {
  background: #d9363e;
}

.btn-secondary {
  background: #666;
  color: white;
}

.btn-success {
  background: var(--success-color);
  color: white;
}

.btn-info {
  background: var(--info-color);
  color: white;
}

.icon {
  font-size: 1.2em;
}

/* 历史记录 */
.history-section {
  background: var(--card-bg);
  padding: 1rem;
  border-radius: 12px;
  box-shadow: var(--shadow);
  margin-bottom: 1rem;
}

.history-section h3 {
  font-size: 1rem;
  margin-bottom: 1rem;
  color: #666;
}

.history-list {
  max-height: 400px;
  overflow-y: auto;
}

.history-item {
  padding: 1rem;
  background: #fafafa;
  border-radius: 8px;
  margin-bottom: 0.75rem;
  border-left: 3px solid var(--success-color);
}

.history-question {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 0.5rem;
  flex-wrap: wrap;
}

.history-question .category {
  background: var(--primary-color);
  color: white;
  padding: 0.125rem 0.5rem;
  border-radius: 8px;
  font-size: 0.75rem;
}

.history-question .question {
  color: #666;
  font-size: 0.875rem;
}

.history-answer {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.user-answer {
  color: var(--text-color);
  font-style: italic;
}

.arrow {
  color: #999;
}

.matched-value {
  background: var(--success-color);
  color: white;
  padding: 0.25rem 0.75rem;
  border-radius: 8px;
  font-weight: 500;
}

.confidence {
  color: #999;
  font-size: 0.75rem;
}

/* 底部操作栏 */
.app-footer {
  background: white;
  padding: 1rem;
  display: flex;
  gap: 0.75rem;
  box-shadow: 0 -2px 8px rgba(0, 0, 0, 0.05);
  position: sticky;
  bottom: 0;
}

.app-footer .btn {
  flex: 1;
  padding: 0.75rem;
  font-size: 0.875rem;
}

/* 加载动画 */
.loader {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.5);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  z-index: 1000;
}

.spinner {
  width: 50px;
  height: 50px;
  border: 4px solid rgba(255, 255, 255, 0.3);
  border-top-color: white;
  border-radius: 50%;
  animation: spin 1s linear infinite;
}

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

.loader p {
  color: white;
  margin-top: 1rem;
  font-size: 1rem;
}

/* 响应式设计 */
@media (min-width: 768px) {
  .app-container {
    max-width: 768px;
    margin: 0 auto;
    box-shadow: 0 0 20px rgba(0, 0, 0, 0.1);
  }

  .controls-section {
    max-width: 500px;
    margin-left: auto;
    margin-right: auto;
  }
}

@media (max-width: 640px) {
  .app-header h1 {
    font-size: 1.25rem;
  }

  .controls-section {
    flex-direction: column;
  }

  .app-footer {
    flex-direction: column;
  }
}

/* 快速选择建议区域 */
.suggestions-section {
  margin-bottom: 1.5rem;
}

.suggestions-section h3 {
  font-size: 1rem;
  color: var(--text-color);
  margin-bottom: 0.5rem;
  opacity: 0.7;
  font-weight: 500;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.suggestions-section h3::before {
  content: '⚡';
  font-size: 1.1rem;
}

.suggestions-list {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 1rem;
}

.no-suggestions {
  color: #999;
  font-size: 0.875rem;
  text-align: center;
  padding: 1.5rem;
  background: var(--card-bg);
  border-radius: 12px;
  border: 2px dashed #ddd;
}

.suggestion-btn {
  background: linear-gradient(135deg, #ffffff 0%, #f8f9fa 100%);
  border: none;
  border-radius: 16px;
  padding: 1rem 0.75rem;
  cursor: pointer;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  box-shadow: 0 4px 12px rgba(0, 78, 164, 0.08);
  position: relative;
  overflow: hidden;
}

.suggestion-btn::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 4px;
  background: linear-gradient(90deg, var(--primary-color), var(--success-color));
  transform: scaleX(0);
  transition: transform 0.3s ease;
}

.suggestion-btn:hover::before {
  transform: scaleX(1);
}

.suggestion-btn:hover {
  transform: translateY(-4px);
  box-shadow: 0 8px 20px rgba(0, 78, 164, 0.15);
}

.suggestion-btn:active {
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(0, 78, 164, 0.12);
}

.suggestion-value {
  font-size: 1.125rem;
  font-weight: 700;
  color: var(--primary-color);
  letter-spacing: 0.5px;
  position: relative;
  z-index: 1;
}

.suggestion-btn:hover .suggestion-value {
  color: var(--primary-color);
}

.suggestion-keywords {
  font-size: 0.75rem;
  color: #999;
  line-height: 1.4;
  position: relative;
  z-index: 1;
}

.suggestion-keywords::before {
  content: '"';
  color: #ddd;
}

.suggestion-keywords::after {
  content: '"';
  color: #ddd;
}

.suggestion-btn:hover .suggestion-keywords {
  color: rgba(102, 102, 102, 0.8);
}

/* ========== 候选问题列表 ========== */
.candidate-questions {
  background: linear-gradient(135deg, #f5f5f5, #e8f4ff);
  padding: 0.5rem;
  border-radius: 6px;
  border: 1px dashed #91d5ff;
  margin-bottom: 0.75rem;
}

.candidate-questions-header {
  display: none; /* 隐藏候选问题标题 */
}

.candidate-question-item {
  padding: 0.4rem 0.75rem;
  margin-bottom: 0.25rem;
  background: white;
  border-radius: 4px;
  cursor: pointer;
  transition: all 0.2s;
  font-size: 0.8rem;
  color: #666;
  border: 1px solid transparent;
}

.candidate-question-item:hover {
  background: #e6f7ff;
  color: #1890ff;
  border-color: #91d5ff;
  transform: translateX(4px);
  box-shadow: 0 2px 4px rgba(24, 144, 255, 0.1);
}

.show-more-btn {
  padding: 0.35rem;
  text-align: center;
  color: #1890ff;
  cursor: pointer;
  font-size: 0.8rem;
  border-radius: 4px;
  transition: background 0.2s;
}

.show-more-btn:hover {
  background: rgba(24, 144, 255, 0.1);
}

/* ========== 焦点问题 ========== */
.focus-question {
  background: linear-gradient(135deg, #ffffff, #f0f9ff);
  padding: 1.25rem;
  border-radius: 10px;
  border: 2px solid #1890ff;
  box-shadow: 0 4px 16px rgba(24, 144, 255, 0.2);
  position: relative;
  animation: focusPulse 2s infinite;
}

@keyframes focusPulse {
  0%, 100% { box-shadow: 0 4px 16px rgba(24, 144, 255, 0.2); }
  50% { box-shadow: 0 4px 20px rgba(24, 144, 255, 0.4); }
}

.focus-question h3 {
  font-size: 1.2rem;
  color: #1890ff;
  font-weight: 700;
  line-height: 1.4;
}

.focus-badge {
  display: none; /* 隐藏焦点问题标签 */
}

/* ========== 后台匹配通知 ========== */
.background-match-notification {
  position: fixed;
  top: 5rem;
  right: 1rem;
  background: #52c41a;
  color: white;
  padding: 1rem 1.5rem;
  border-radius: 8px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
  z-index: 1000;
  animation: slideIn 0.3s ease;
  max-width: 300px;
}

@keyframes slideIn {
  from { transform: translateX(100%); opacity: 0; }
  to { transform: translateX(0); opacity: 1; }
}

.background-match-notification.fade-out {
  animation: slideOut 0.3s ease forwards;
}

@keyframes slideOut {
  from { transform: translateX(0); opacity: 1; }
  to { transform: translateX(100%); opacity: 0; }
}

.background-match-notification .checkmark {
  display: inline-block;
  margin-right: 0.5rem;
  font-size: 1.25rem;
}

/* ========== 核对表单模态框 ========== */
.modal {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 9999;
}

.modal-overlay {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.5);
}

.modal-content {
  position: relative;
  background: white;
  border-radius: 12px;
  max-width: 800px;
  width: 90%;
  max-height: 90vh;
  display: flex;
  flex-direction: column;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.2);
}

.modal-header {
  padding: 1.5rem;
  border-bottom: 1px solid #e8e8e8;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.modal-header h2 {
  margin: 0;
  font-size: 1.25rem;
  color: #333;
}

.close-btn {
  background: none;
  border: none;
  font-size: 1.5rem;
  cursor: pointer;
  color: #999;
  transition: color 0.2s;
}

.close-btn:hover {
  color: #333;
}

.modal-body {
  flex: 1;
  overflow-y: auto;
  padding: 1.5rem;
}

.review-summary {
  background: #f0f9ff;
  padding: 1rem;
  border-radius: 8px;
  margin-bottom: 1.5rem;
  display: flex;
  gap: 2rem;
}

.review-summary p {
  margin: 0;
  color: #666;
}

.review-summary strong {
  color: #1890ff;
  font-size: 1.25rem;
}

.review-list {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

/* ========== 问答项 ========== */
.review-item {
  background: #fafafa;
  border: 1px solid #e8e8e8;
  border-radius: 8px;
  padding: 1rem;
}

.review-item-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 0.75rem;
}

.confidence-badge {
  padding: 0.25rem 0.75rem;
  border-radius: 12px;
  font-size: 0.75rem;
  font-weight: 600;
}

.confidence-badge.high {
  background: #f6ffed;
  color: #52c41a;
  border: 1px solid #b7eb8f;
}

.confidence-badge.medium {
  background: #fffbe6;
  color: #faad14;
  border: 1px solid #ffe58f;
}

.confidence-badge.low {
  background: #fff1f0;
  color: #ff4d4f;
  border: 1px solid #ffccc7;
}

.confidence-badge.unanswered {
  background: #f5f5f5;
  color: #999;
  border: 1px solid #d9d9d9;
}

.status-badge {
  padding: 0.25rem 0.75rem;
  border-radius: 12px;
  font-size: 0.75rem;
  font-weight: 600;
}

.status-badge.unanswered {
  background: #fff7e6;
  color: #fa8c16;
  border: 1px solid #ffd591;
}

.main-flow-badge {
  background: #e6f7ff;
  color: #1890ff;
  border: 1px solid #91d5ff;
  padding: 0.25rem 0.75rem;
  border-radius: 12px;
  font-size: 0.75rem;
  font-weight: 600;
}

.review-item.main-flow {
  border-left: 4px solid #1890ff;
  background: #f0f9ff;
}

.review-item.unanswered-item {
  background: #fffbf0;
  border-left: 4px solid #faad14;
  border-style: dashed;
}

.answered-count {
  color: #52c41a;
}

.unanswered-count {
  color: #faad14;
}

.delete-btn {
  background: none;
  border: 1px solid #ff4d4f;
  color: #ff4d4f;
  padding: 0.25rem 0.75rem;
  border-radius: 4px;
  cursor: pointer;
  font-size: 0.75rem;
  transition: all 0.2s;
}

.delete-btn:hover {
  background: #ff4d4f;
  color: white;
}

.review-item-question {
  margin-bottom: 0.75rem;
  color: #333;
}

.review-item-answer {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  margin-bottom: 0.75rem;
}

.original-answer,
.matched-answer,
.custom-answer {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.original-answer label,
.matched-answer label,
.custom-answer label {
  font-size: 0.875rem;
  color: #666;
  min-width: 80px;
}

.user-text {
  color: #999;
  font-style: italic;
}

.answer-select,
.answer-input {
  flex: 1;
  padding: 0.5rem;
  border: 1px solid #d9d9d9;
  border-radius: 4px;
  font-size: 0.875rem;
}

.answer-select:focus,
.answer-input:focus {
  outline: none;
  border-color: #1890ff;
}

.review-item-meta {
  display: flex;
  justify-content: space-between;
  font-size: 0.75rem;
  color: #999;
}

.match-type {
  background: #e6f7ff;
  color: #1890ff;
  padding: 0.125rem 0.5rem;
  border-radius: 4px;
}

.modal-footer {
  padding: 1rem 1.5rem;
  border-top: 1px solid #e8e8e8;
  display: flex;
  justify-content: flex-end;
  gap: 1rem;
}

.modal-footer .btn {
  padding: 0.5rem 1.5rem;
}

/* TTS开关按钮样式 */
.tts-toggle-container {
  display: flex;
  justify-content: center;
  margin-top: 0.5rem;
}

.tts-toggle-btn {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.5rem 1rem;
  background: rgba(255, 255, 255, 0.2);
  border: 1px solid rgba(255, 255, 255, 0.3);
  border-radius: 20px;
  color: white;
  font-size: 0.875rem;
  cursor: pointer;
  transition: all 0.3s ease;
}

.tts-toggle-btn:hover {
  background: rgba(255, 255, 255, 0.3);
  transform: translateY(-1px);
}

.tts-toggle-btn:active {
  transform: translateY(0);
}

.tts-toggle-btn .icon {
  font-size: 1rem;
}

.tts-toggle-btn .label {
  font-weight: 500;
}

.tts-toggle-btn .status {
  padding: 0.125rem 0.5rem;
  border-radius: 10px;
  font-size: 0.75rem;
  font-weight: 600;
}

.tts-toggle-btn .status.on {
  background: var(--success-color);
}

.tts-toggle-btn .status.off {
  background: rgba(255, 255, 255, 0.3);
}

/* 朗读状态动画 */
.status-indicator.speaking {
  animation: speaking 0.5s ease-in-out infinite alternate;
}

@keyframes speaking {
  from {
    transform: scale(1);
    box-shadow: 0 0 0 0 rgba(82, 196, 26, 0.7);
  }
  to {
    transform: scale(1.05);
    box-shadow: 0 0 0 10px rgba(82, 196, 26, 0);
  }
}

/* ========== TTS控制样式 ========== */

/* TTS控制容器 */
.tts-control {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 0.75rem 1rem;
  background: white;
  border-bottom: 1px solid var(--border-color);
}

/* TTS开关按钮 */
.tts-toggle-btn {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.5rem 1rem;
  border: 2px solid var(--border-color);
  border-radius: 20px;
  background: white;
  color: var(--text-color);
  font-size: 0.875rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.3s ease;
}

.tts-toggle-btn:hover {
  border-color: var(--primary-color);
  background: #f0f7ff;
}

.tts-toggle-btn.active {
  border-color: var(--success-color);
  background: #f6ffed;
  color: var(--success-color);
}

.tts-icon {
  font-size: 1.2rem;
  line-height: 1;
}

/* TTS朗读指示器 */
.tts-indicator {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.5rem 1rem;
  background: #e6f7ff;
  border: 1px solid #91d5ff;
  border-radius: 20px;
  color: var(--primary-color);
  font-size: 0.875rem;
  animation: tts-pulse 1.5s ease-in-out infinite;
}

@keyframes tts-pulse {
  0%, 100% {
    transform: scale(1);
    box-shadow: 0 0 0 0 rgba(24, 144, 255, 0.4);
  }
  50% {
    transform: scale(1.02);
    box-shadow: 0 0 0 8px rgba(24, 144, 255, 0);
  }
}

.tts-pulse {
  display: inline-block;
  width: 8px;
  height: 8px;
  background: var(--primary-color);
  border-radius: 50%;
  animation: pulse-dot 1s ease-in-out infinite;
}

@keyframes pulse-dot {
  0%, 100% {
    opacity: 1;
    transform: scale(1);
  }
  50% {
    opacity: 0.5;
    transform: scale(0.8);
  }
}

/* 响应式TTS控制 */
@media (max-width: 768px) {
  .tts-control {
    padding: 0.5rem;
    gap: 0.5rem;
  }

  .tts-toggle-btn {
    padding: 0.4rem 0.75rem;
    font-size: 0.8rem;
  }

  .tts-indicator {
    padding: 0.4rem 0.75rem;
    font-size: 0.8rem;
  }
}
