/* ============ 豆苗AI质性分析助手 - 品牌样式 ============ */

:root {
  --brand-primary: #10B981;
  --brand-secondary: #059669;
  --brand-gradient: linear-gradient(135deg, #10B981, #059669);
  --brand-light: #D1FAE5;
  --text-primary: #1F2937;
  --text-secondary: #6B7280;
  --text-light: #9CA3AF;
  --bg-page: #F9FAFB;
  --bg-card: #FFFFFF;
  --border-color: #E5E7EB;
  --shadow-card: 0 2px 8px rgba(0,0,0,0.08);
  --shadow-lg: 0 4px 16px rgba(0,0,0,0.12);
  --radius-card: 12px;
  --radius-button: 8px;
  --radius-pill: 20px;
  --font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'PingFang SC', 'Hiragino Sans GB', 'Microsoft YaHei', sans-serif;
}

/* ============ 全局重置 ============ */
* { margin: 0; padding: 0; box-sizing: border-box; }

body {
  font-family: var(--font-family);
  background: var(--bg-page);
  color: var(--text-primary);
  min-height: 100vh;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

/* ============ 顶部品牌区 ============ */
.app-header {
  background: var(--bg-card);
  border-bottom: 1px solid var(--border-color);
  padding: 12px 16px;
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: 0 1px 3px rgba(0,0,0,0.04);
}

.header-inner {
  max-width: 800px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  gap: 12px;
}

.brand-logo {
  width: 40px;
  height: 40px;
  border-radius: 10px;
  object-fit: cover;
}

.brand-title {
  font-size: 18px;
  font-weight: 700;
  background: var(--brand-gradient);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.brand-subtitle {
  font-size: 12px;
  color: var(--text-secondary);
  margin-left: auto;
}

/* ============ 主容器 ============ */
.app-container {
  max-width: 800px;
  margin: 0 auto;
  padding: 16px;
  padding-bottom: 100px;
}

/* ============ 进度条 ============ */
.progress-bar {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  padding: 24px 0 32px;
  position: relative;
}

.progress-bar::before {
  content: '';
  position: absolute;
  top: 28px;
  left: 30px;
  right: 30px;
  height: 3px;
  background: var(--border-color);
  z-index: 0;
}

.progress-bar::after {
  content: '';
  position: absolute;
  top: 28px;
  left: 30px;
  height: 3px;
  background: var(--brand-gradient);
  z-index: 0;
  transition: width 0.5s ease;
  width: 0%;
}

.progress-step {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  position: relative;
  z-index: 1;
  cursor: pointer;
  flex: 1;
}

.progress-step .step-circle {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  font-weight: 600;
  background: var(--bg-card);
  border: 2px solid var(--border-color);
  color: var(--text-light);
  transition: all 0.3s ease;
}

.progress-step .step-label {
  font-size: 11px;
  color: var(--text-light);
  text-align: center;
  transition: color 0.3s ease;
  white-space: nowrap;
}

.progress-step.active .step-circle {
  background: var(--brand-gradient);
  border-color: var(--brand-primary);
  color: white;
  box-shadow: 0 2px 8px rgba(16,185,129,0.3);
}

.progress-step.active .step-label {
  color: var(--brand-primary);
  font-weight: 600;
}

.progress-step.completed .step-circle {
  background: var(--brand-gradient);
  border-color: var(--brand-primary);
  color: white;
}

.progress-step.completed .step-label {
  color: var(--brand-secondary);
}

/* ============ 步骤内容区 ============ */
.step-content {
  display: none;
  animation: fadeIn 0.3s ease;
}

.step-content.active {
  display: block;
}

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

.step-header {
  margin-bottom: 20px;
}

.step-header h2 {
  font-size: 22px;
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: 4px;
}

.step-header p {
  font-size: 14px;
  color: var(--text-secondary);
}

/* ============ 卡片 ============ */
.card {
  background: var(--bg-card);
  border-radius: var(--radius-card);
  box-shadow: var(--shadow-card);
  padding: 20px;
  margin-bottom: 16px;
  border: 1px solid var(--border-color);
}

.card-title {
  font-size: 15px;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 12px;
}

/* ============ 按钮 ============ */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 10px 24px;
  border-radius: var(--radius-button);
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  border: none;
  transition: all 0.2s ease;
  text-decoration: none;
}

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

.btn-primary {
  background: var(--brand-gradient);
  color: white;
  box-shadow: 0 2px 8px rgba(16,185,129,0.25);
}

.btn-primary:hover {
  box-shadow: 0 4px 12px rgba(16,185,129,0.35);
  transform: translateY(-1px);
}

.btn-primary:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  transform: none;
  box-shadow: none;
}

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

.btn-secondary:hover {
  border-color: var(--brand-primary);
  color: var(--brand-primary);
}

.btn-outline {
  background: transparent;
  color: var(--brand-primary);
  border: 1px solid var(--brand-primary);
}

.btn-outline:hover {
  background: var(--brand-light);
}

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

.btn-group {
  display: flex;
  gap: 12px;
  justify-content: space-between;
  margin-top: 24px;
  padding-top: 16px;
  border-top: 1px solid var(--border-color);
}

/* ============ 文本输入区 ============ */
.text-input-area {
  width: 100%;
  min-height: 200px;
  padding: 16px;
  border: 2px solid var(--border-color);
  border-radius: var(--radius-card);
  font-size: 15px;
  line-height: 1.8;
  resize: vertical;
  font-family: var(--font-family);
  transition: border-color 0.2s ease;
  outline: none;
}

.text-input-area:focus {
  border-color: var(--brand-primary);
  box-shadow: 0 0 0 3px rgba(16,185,129,0.1);
}

.text-input-area::placeholder {
  color: var(--text-light);
}

.char-count {
  text-align: right;
  font-size: 12px;
  color: var(--text-light);
  margin-top: 6px;
}

/* ============ Tab切换 ============ */
.tabs {
  display: flex;
  gap: 0;
  margin-bottom: 16px;
  background: var(--bg-page);
  border-radius: var(--radius-button);
  padding: 3px;
}

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

.tab-btn.active {
  background: var(--bg-card);
  color: var(--brand-primary);
  font-weight: 600;
  box-shadow: 0 1px 3px rgba(0,0,0,0.08);
}

.tab-content {
  display: none;
}

.tab-content.active {
  display: block;
}

/* ============ 上传区域 ============ */
.upload-zone {
  border: 2px dashed var(--border-color);
  border-radius: var(--radius-card);
  padding: 40px 20px;
  text-align: center;
  cursor: pointer;
  transition: all 0.2s ease;
  background: var(--bg-page);
}

.upload-zone:hover,
.upload-zone.dragover {
  border-color: var(--brand-primary);
  background: var(--brand-light);
}

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

.upload-zone .upload-text {
  font-size: 15px;
  color: var(--text-secondary);
  margin-bottom: 4px;
}

.upload-zone .upload-hint {
  font-size: 12px;
  color: var(--text-light);
}

/* ============ 来源标注 ============ */
.source-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 8px;
}

.source-tag {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 4px 12px;
  background: var(--brand-light);
  color: var(--brand-secondary);
  border-radius: var(--radius-pill);
  font-size: 13px;
  font-weight: 500;
}

.source-tag .remove-tag {
  cursor: pointer;
  font-size: 14px;
  opacity: 0.6;
}

.source-tag .remove-tag:hover {
  opacity: 1;
}

/* ============ 分段预览 ============ */
.segment-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: 12px;
  max-height: 400px;
  overflow-y: auto;
}

.segment-item {
  display: flex;
  gap: 10px;
  padding: 10px 14px;
  background: var(--bg-page);
  border-radius: 8px;
  border-left: 3px solid var(--brand-primary);
  cursor: pointer;
  transition: background 0.2s;
}

.segment-item:hover {
  background: var(--brand-light);
}

.segment-item .seg-num {
  font-size: 12px;
  color: var(--brand-primary);
  font-weight: 600;
  min-width: 24px;
  line-height: 1.6;
}

.segment-item .seg-text {
  font-size: 14px;
  line-height: 1.6;
  color: var(--text-primary);
  flex: 1;
}

.segment-item.selected {
  background: var(--brand-light);
  border-left-color: var(--brand-secondary);
}

/* ============ 模式选择卡片 ============ */
.mode-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.mode-card {
  padding: 20px;
  border: 2px solid var(--border-color);
  border-radius: var(--radius-card);
  cursor: pointer;
  transition: all 0.2s ease;
  position: relative;
}

.mode-card:hover {
  border-color: var(--brand-primary);
  box-shadow: var(--shadow-card);
}

.mode-card.selected {
  border-color: var(--brand-primary);
  background: rgba(16,185,129,0.03);
}

.mode-card .mode-icon {
  font-size: 28px;
  margin-bottom: 8px;
}

.mode-card .mode-name {
  font-size: 16px;
  font-weight: 600;
  margin-bottom: 4px;
}

.mode-card .mode-desc {
  font-size: 13px;
  color: var(--text-secondary);
  line-height: 1.5;
}

.mode-card .mode-tags {
  display: flex;
  gap: 4px;
  margin-top: 8px;
  flex-wrap: wrap;
}

.mode-tag {
  font-size: 11px;
  padding: 2px 8px;
  background: var(--brand-light);
  color: var(--brand-secondary);
  border-radius: var(--radius-pill);
}

.mode-card .check-mark {
  position: absolute;
  top: 10px;
  right: 10px;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: var(--brand-primary);
  color: white;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  opacity: 0;
  transition: opacity 0.2s;
}

.mode-card.selected .check-mark {
  opacity: 1;
}

/* ============ Loading动画 ============ */
.loading-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(255,255,255,0.92);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  flex-direction: column;
  gap: 24px;
}

.loading-overlay.active {
  display: flex;
}

.loading-pulse {
  width: 60px;
  height: 60px;
  border-radius: 50%;
  background: var(--brand-gradient);
  animation: pulse 1.5s ease-in-out infinite;
}

@keyframes pulse {
  0%, 100% { transform: scale(0.8); opacity: 0.6; }
  50% { transform: scale(1.2); opacity: 1; }
}

.loading-text {
  font-size: 16px;
  font-weight: 600;
  color: var(--text-primary);
}

.loading-subtext {
  font-size: 14px;
  color: var(--text-secondary);
  text-align: center;
}

.loading-steps {
  display: flex;
  flex-direction: column;
  gap: 8px;
  align-items: center;
}

.loading-step {
  font-size: 13px;
  color: var(--text-light);
  transition: all 0.3s;
}

.loading-step.active {
  color: var(--brand-primary);
  font-weight: 600;
}

.loading-step.done {
  color: var(--brand-secondary);
}

/* ============ 编码结果 ============ */
.coding-tabs {
  display: flex;
  gap: 0;
  margin-bottom: 16px;
  border-bottom: 2px solid var(--border-color);
}

.coding-tab {
  padding: 10px 20px;
  border: none;
  background: transparent;
  color: var(--text-secondary);
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  border-bottom: 2px solid transparent;
  margin-bottom: -2px;
  transition: all 0.2s;
}

.coding-tab.active {
  color: var(--brand-primary);
  border-bottom-color: var(--brand-primary);
  font-weight: 600;
}

.coding-panel {
  display: none;
}

.coding-panel.active {
  display: block;
}

.code-item {
  padding: 12px 16px;
  border: 1px solid var(--border-color);
  border-radius: 8px;
  margin-bottom: 10px;
  transition: all 0.2s;
}

.code-item:hover {
  border-color: var(--brand-primary);
}

.code-label {
  display: inline-block;
  padding: 2px 10px;
  background: var(--brand-light);
  color: var(--brand-secondary);
  border-radius: var(--radius-pill);
  font-size: 13px;
  font-weight: 600;
  margin-bottom: 6px;
}

.code-quote {
  font-size: 13px;
  color: var(--text-secondary);
  padding: 8px 12px;
  background: var(--bg-page);
  border-left: 3px solid var(--brand-primary);
  border-radius: 4px;
  margin: 6px 0;
  line-height: 1.6;
}

.code-actions {
  display: flex;
  gap: 6px;
  margin-top: 6px;
}

.code-actions button {
  padding: 2px 10px;
  font-size: 12px;
  border: 1px solid var(--border-color);
  background: transparent;
  border-radius: 4px;
  cursor: pointer;
  color: var(--text-secondary);
  transition: all 0.2s;
}

.code-actions button:hover {
  border-color: var(--brand-primary);
  color: var(--brand-primary);
}

/* 树状编码 */
.category-item {
  border: 1px solid var(--border-color);
  border-radius: 8px;
  margin-bottom: 10px;
  overflow: hidden;
}

.category-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  background: var(--bg-page);
  cursor: pointer;
  font-weight: 600;
  font-size: 14px;
}

.category-header .cat-meta {
  display: flex;
  align-items: center;
  gap: 8px;
}

.category-header .count {
  font-size: 12px;
  color: var(--text-light);
  font-weight: 400;
}

.cat-btn {
  background: var(--card-bg);
  border: 1px solid var(--border-color);
  border-radius: 4px;
  padding: 2px 6px;
  font-size: 13px;
  cursor: pointer;
  line-height: 1;
  transition: all 0.15s;
}

.cat-btn:hover {
  border-color: var(--brand-primary);
  color: var(--brand-primary);
}

.category-codes {
  padding: 8px 16px 12px;
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

/* 核心范畴卡片 */
.core-category-card {
  background: linear-gradient(135deg, #F0FDF4, #ECFDF5);
  border: 1px solid var(--brand-primary);
  border-radius: var(--radius-card);
  padding: 20px;
  margin-bottom: 16px;
}

.core-category-card h3 {
  font-size: 18px;
  color: var(--brand-secondary);
  margin-bottom: 8px;
}

.core-category-card p {
  font-size: 14px;
  color: var(--text-secondary);
  margin-bottom: 12px;
}

/* ============ 主题分析 ============ */
.theme-cards {
  display: flex;
  gap: 12px;
  overflow-x: auto;
  padding-bottom: 8px;
  scroll-snap-type: x mandatory;
}

.theme-card {
  min-width: 260px;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-card);
  padding: 16px;
  scroll-snap-align: start;
  flex-shrink: 0;
}

.theme-card h4 {
  font-size: 15px;
  margin-bottom: 8px;
}

.bar-chart-item {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 8px;
}

.bar-chart-item .bar-label {
  font-size: 13px;
  min-width: 80px;
  text-align: right;
  color: var(--text-secondary);
}

.bar-chart-item .bar {
  height: 24px;
  background: var(--brand-gradient);
  border-radius: 4px;
  transition: width 0.5s ease;
  min-width: 4px;
}

.bar-chart-item .bar-value {
  font-size: 12px;
  color: var(--text-secondary);
  min-width: 24px;
}

.contradiction-item {
  display: flex;
  gap: 12px;
  padding: 12px;
  background: #FFF7ED;
  border: 1px solid #FED7AA;
  border-radius: 8px;
  margin-bottom: 8px;
}

.contradiction-item .vs-badge {
  background: #EF4444;
  color: white;
  padding: 2px 8px;
  border-radius: 4px;
  font-size: 11px;
  font-weight: 700;
  height: fit-content;
}

/* ============ 可视化 ============ */
.chart-card {
  background: var(--bg-card);
  border-radius: var(--radius-card);
  box-shadow: var(--shadow-card);
  padding: 16px;
  margin-bottom: 16px;
  border: 1px solid var(--border-color);
}

.chart-card .chart-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 12px;
}

.chart-card .chart-title {
  font-size: 15px;
  font-weight: 600;
}

.chart-container {
  width: 100%;
  height: 350px;
}

.chart-container.tall {
  height: 500px;
}

/* ============ 报告预览 ============ */
.report-preview {
  background: var(--bg-card);
  border-radius: var(--radius-card);
  box-shadow: var(--shadow-card);
  padding: 24px;
  border: 1px solid var(--border-color);
  max-height: 600px;
  overflow-y: auto;
  line-height: 1.8;
}

.report-preview h1 { font-size: 22px; margin: 16px 0 8px; color: var(--text-primary); }
.report-preview h2 { font-size: 18px; margin: 14px 0 6px; color: var(--text-primary); }
.report-preview h3 { font-size: 16px; margin: 12px 0 4px; color: var(--text-primary); }
.report-preview p { margin: 8px 0; color: var(--text-secondary); }
.report-preview strong { color: var(--text-primary); }

.export-buttons {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 16px;
}

/* ============ 底部品牌 ============ */
.app-footer {
  text-align: center;
  padding: 20px;
  font-size: 13px;
  color: var(--text-light);
  border-top: 1px solid var(--border-color);
  margin-top: 40px;
}

/* ============ Toast提示 ============ */
.toast {
  position: fixed;
  bottom: 80px;
  left: 50%;
  transform: translateX(-50%);
  padding: 10px 24px;
  border-radius: var(--radius-pill);
  font-size: 14px;
  font-weight: 500;
  color: white;
  z-index: 2000;
  opacity: 0;
  transition: all 0.3s ease;
  pointer-events: none;
}

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

.toast.success { background: var(--brand-primary); }
.toast.error { background: #EF4444; }
.toast.info { background: #3B82F6; }

/* ============ 响应式 ============ */
@media (max-width: 480px) {
  .app-container { padding: 12px; padding-bottom: 80px; }
  .mode-grid { grid-template-columns: 1fr; }
  .progress-step .step-label { font-size: 10px; }
  .progress-step .step-circle { width: 28px; height: 28px; font-size: 12px; }
  .step-header h2 { font-size: 20px; }
  .chart-container { height: 280px; }
  .chart-container.tall { height: 380px; }
  .theme-card { min-width: 220px; }
  .brand-title { font-size: 16px; }
  .export-buttons { flex-direction: column; }
  .btn-group { flex-direction: column; }
  .btn-group .btn { width: 100%; }
}

/* ============ 滚动条美化 ============ */
::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: #D1D5DB; border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: #9CA3AF; }

/* ============ 工具类 ============ */
.text-center { text-align: center; }
.mt-8 { margin-top: 8px; }
.mt-16 { margin-top: 16px; }
.mb-8 { margin-bottom: 8px; }
.mb-16 { margin-bottom: 16px; }
.hidden { display: none !important; }
.flex-center { display: flex; align-items: center; justify-content: center; }
.gap-8 { gap: 8px; }
.gap-12 { gap: 12px; }

/* ============ 来源对比表 ============ */
.comparison-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

.comparison-table th,
.comparison-table td {
  padding: 10px 12px;
  border: 1px solid var(--border-color);
  text-align: left;
}

.comparison-table th {
  background: var(--brand-light);
  color: var(--brand-secondary);
  font-weight: 600;
}

.comparison-table tr:nth-child(even) {
  background: var(--bg-page);
}