/* 页面基础 */
:root {
  --bg-start: #0a0e27;
  --bg-end: #1a0f3d;
  --card-bg: rgba(15, 18, 45, 0.85);
  --text: #f0f4ff;
  --muted: rgba(240, 244, 255, 0.72);
  --accent: #4f7fff;
  --accent-2: #a855ff;
  --accent-3: #ff6b6b;
  --shadow: 0 24px 48px rgba(0, 0, 0, 0.6);
  --border: rgba(255, 255, 255, 0.1);
  --radius: 16px;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: "Inter", system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: radial-gradient(circle at 20% 25%, rgba(79, 127, 255, 0.4), transparent 45%),
    radial-gradient(circle at 80% 35%, rgba(168, 85, 255, 0.35), transparent 50%),
    radial-gradient(circle at 50% 90%, rgba(255, 107, 107, 0.2), transparent 50%),
    linear-gradient(135deg, var(--bg-start), var(--bg-end));
  color: var(--text);
  overflow-x: hidden;
}

.page {
  min-height: 100vh;
  width: 100%;
  display: block;
  padding: 0;
}

.scene {
  position: relative;
  width: 100%;
  min-height: 100vh;
  padding: 0;
}

.glow {
  position: absolute;
  inset: 0;
  pointer-events: none;
  background: radial-gradient(circle at 35% 40%, rgba(79, 127, 255, 0.3), transparent 50%),
    radial-gradient(circle at 65% 25%, rgba(168, 85, 255, 0.25), transparent 50%),
    radial-gradient(circle at 50% 85%, rgba(255, 107, 107, 0.15), transparent 45%);
  filter: blur(28px);
  animation: drift 20s ease-in-out infinite;
  border-radius: 0;
}

@keyframes drift {
  0%, 100% {
    transform: translate(0, 0) scale(1);
  }
  50% {
    transform: translate(8px, -14px) scale(1.03);
  }
}

.card {
  position: relative;
  width: 100%;
  min-height: 100vh;
  padding: 40px;
  border-radius: 0;
  background: var(--card-bg);
  box-shadow: none;
  border: 0;
  backdrop-filter: blur(16px);
  overflow: hidden;
  z-index: 1;
}

.header {
  position: relative;
  margin-bottom: 32px;
  text-align: center;
  min-height: 40px;
}

.back-button {
  position: absolute;
  top: 0;
  left: 0;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 14px;
  border-radius: 999px;
  border: 1px solid rgba(79, 127, 255, 0.45);
  background: linear-gradient(135deg, rgba(79, 127, 255, 0.22), rgba(168, 85, 255, 0.16));
  color: var(--text);
  text-decoration: none;
  font-size: 0.88rem;
  font-weight: 600;
  line-height: 1;
  transition: transform 180ms ease, box-shadow 180ms ease, border-color 180ms ease;
}

.back-button:hover {
  transform: translateY(-1px);
  box-shadow: 0 10px 20px rgba(79, 127, 255, 0.28);
  border-color: rgba(79, 127, 255, 0.75);
}

.back-button:active {
  transform: translateY(0);
}

.back-icon {
  font-size: 1rem;
}

.title {
  margin: 0;
  font-size: clamp(2rem, 5vw, 2.5rem);
  letter-spacing: -0.02em;
  background: linear-gradient(135deg, #4f7fff, #a855ff);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.subtitle {
  margin: 8px 0 0;
  font-size: clamp(0.95rem, 2.4vw, 1.1rem);
  color: var(--muted);
}

.section {
  margin-bottom: 24px;
}

/* 提示框 */
.prompt-box {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 16px 20px;
  border-radius: 12px;
  background: linear-gradient(135deg, rgba(79, 127, 255, 0.15), rgba(168, 85, 255, 0.1));
  border: 1px solid rgba(79, 127, 255, 0.3);
  animation: pulse-border 3s ease-in-out infinite;
}

.prompt-icon {
  font-size: 1.6rem;
  animation: bounce 2s ease-in-out infinite;
}

.prompt-text {
  margin: 0;
  font-size: 1rem;
  font-weight: 500;
  color: var(--text);
}

@keyframes pulse-border {
  0%, 100% {
    box-shadow: 0 0 0 0 rgba(79, 127, 255, 0.4);
  }
  50% {
    box-shadow: 0 0 0 8px rgba(79, 127, 255, 0);
  }
}

@keyframes bounce {
  0%, 100% {
    transform: translateY(0);
  }
  50% {
    transform: translateY(-4px);
  }
}

/* 按钮样式 */
.action-button {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  width: 100%;
  padding: 16px 24px;
  border-radius: 12px;
  border: none;
  font-family: inherit;
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 200ms ease;
  overflow: hidden;
  color: var(--text);
}

.action-button::before {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.2), transparent);
  transform: translateX(-100%);
  transition: transform 300ms ease;
}

.action-button:hover::before {
  transform: translateX(100%);
}

.select-btn {
  background: linear-gradient(135deg, rgba(79, 127, 255, 0.35), rgba(79, 127, 255, 0.2));
  border: 2px solid rgba(79, 127, 255, 0.5);
}

.select-btn:hover:not(:disabled) {
  transform: translateY(-2px);
  box-shadow: 0 12px 28px rgba(79, 127, 255, 0.3);
  border-color: rgba(79, 127, 255, 0.8);
}

.select-btn:active:not(:disabled) {
  transform: translateY(0);
}

.start-btn {
  background: linear-gradient(135deg, var(--accent-2), #ff6b9d);
  border: 2px solid var(--accent-2);
  position: relative;
}

.start-btn:not(:disabled):hover {
  transform: translateY(-2px);
  box-shadow: 0 16px 36px rgba(168, 85, 255, 0.4);
  border-color: #ff6b9d;
}

.start-btn:not(:disabled):active {
  transform: translateY(0);
}

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

.button-icon {
  font-size: 1.2rem;
}

.button-text {
  position: relative;
  z-index: 2;
}

.button-shimmer {
  position: absolute;
  inset: 0;
  background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.15), transparent);
  animation: shimmer 2s infinite;
}

@keyframes shimmer {
  0% {
    background-position: -1000px 0;
  }
  100% {
    background-position: 1000px 0;
  }
}

/* 文件树容器 */
.file-tree-container {
  border-radius: 12px;
  background: rgba(0, 0, 0, 0.3);
  border: 1px solid rgba(79, 127, 255, 0.2);
  overflow: hidden;
  transition: all 300ms ease;
}

.tree-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 16px 20px;
  background: linear-gradient(90deg, rgba(79, 127, 255, 0.15), rgba(168, 85, 255, 0.1));
  border-bottom: 1px solid rgba(79, 127, 255, 0.2);
}

.tree-title {
  font-weight: 600;
  color: var(--text);
  font-size: 0.95rem;
}

.tree-count {
  padding: 4px 12px;
  border-radius: 6px;
  background: rgba(79, 127, 255, 0.2);
  color: var(--accent);
  font-size: 0.85rem;
  font-weight: 600;
}

.tree-content {
  padding: 20px;
  max-height: 300px;
  overflow-y: auto;
  min-height: 100px;
}

.empty-state {
  margin: 0;
  text-align: center;
  color: var(--muted);
  padding: 40px 20px;
  font-size: 0.95rem;
}

.file-item {
  margin: 8px 0;
  padding: 10px 14px;
  border-radius: 8px;
  background: rgba(79, 127, 255, 0.08);
  border-left: 3px solid var(--accent);
  font-size: 0.9rem;
  color: var(--text);
  word-break: break-all;
  animation: slideInFile 300ms ease forwards;
  opacity: 0;
}

.file-item:nth-child(1) { animation-delay: 50ms; }
.file-item:nth-child(2) { animation-delay: 100ms; }
.file-item:nth-child(3) { animation-delay: 150ms; }
.file-item:nth-child(4) { animation-delay: 200ms; }
.file-item:nth-child(5) { animation-delay: 250ms; }

@keyframes slideInFile {
  from {
    opacity: 0;
    transform: translateX(-10px);
  }
  to {
    opacity: 1;
    transform: translateX(0);
  }
}

/* 进度条 */
.progress-container {
  margin-top: 32px;
  padding: 24px;
  border-radius: 12px;
  background: rgba(0, 0, 0, 0.3);
  border: 1px solid rgba(255, 107, 107, 0.3);
}

.progress-bar {
  width: 100%;
  height: 8px;
  border-radius: 4px;
  background: rgba(255, 255, 255, 0.1);
  overflow: hidden;
  margin-bottom: 12px;
}

.progress-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--accent-2), #ff6b9d);
  border-radius: 4px;
  width: 0%;
  transition: width 300ms ease;
  box-shadow: 0 0 20px rgba(255, 107, 107, 0.5);
}

.progress-text {
  margin: 0;
  font-size: 0.9rem;
  color: var(--muted);
  text-align: center;
}

.version-info {
  margin-bottom: 12px;
  padding: 8px 12px;
  background: rgba(76, 175, 80, 0.1);
  border: 1px solid rgba(76, 175, 80, 0.35);
  border-radius: 10px;
}

.privacy-section {
  margin-top: 8px;
  margin-bottom: 0;
}

.privacy-note {
  margin: 0;
  padding: 12px 16px;
  border-radius: 10px;
  border: 1px solid rgba(79, 127, 255, 0.2);
  background: rgba(255, 255, 255, 0.03);
  color: rgba(240, 244, 255, 0.66);
  font-size: 0.82rem;
  line-height: 1.55;
  text-align: center;
}

/* 滚动条美化 */
.tree-content::-webkit-scrollbar {
  width: 6px;
}

.tree-content::-webkit-scrollbar-track {
  background: rgba(255, 255, 255, 0.05);
}

.tree-content::-webkit-scrollbar-thumb {
  background: rgba(79, 127, 255, 0.3);
  border-radius: 3px;
}

.tree-content::-webkit-scrollbar-thumb:hover {
  background: rgba(79, 127, 255, 0.5);
}

/* 预解析结果容器 */
.parse-result-container {
  border-radius: 12px;
  background: rgba(0, 0, 0, 0.3);
  border: 1px solid rgba(76, 175, 80, 0.3);
  overflow: hidden;
  transition: all 300ms ease;
  animation: slideUp 400ms ease;
}

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

.result-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 16px 20px;
  background: linear-gradient(90deg, rgba(76, 175, 80, 0.15), rgba(56, 142, 60, 0.1));
  border-bottom: 1px solid rgba(76, 175, 80, 0.2);
}

.result-title {
  font-weight: 600;
  color: var(--text);
  font-size: 0.95rem;
}

.result-close {
  cursor: pointer;
  color: rgba(243, 244, 255, 0.6);
  font-size: 1.2rem;
  transition: color 200ms ease, transform 200ms ease;
  user-select: none;
}

.result-close:hover {
  color: var(--text);
  transform: scale(1.2);
}

.result-content {
  padding: 20px;
}

/* CSV 预览容器 - 整合进结果区域 */
#csvPreviewContainer {
  margin: 20px -20px -20px -20px;
  padding: 20px;
  background: rgba(0, 0, 0, 0.2);
  border-top: 1px solid rgba(79, 127, 255, 0.2);
  overflow: hidden;
}

.result-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 0;
  border-bottom: 1px solid rgba(79, 127, 255, 0.1);
  font-size: 0.9rem;
}

.result-item:last-of-type {
  border-bottom: none;
}

.result-label {
  color: var(--muted);
  font-weight: 500;
}

.result-value {
  color: var(--accent);
  font-weight: 600;
  padding: 4px 12px;
  background: rgba(79, 127, 255, 0.15);
  border-radius: 6px;
}

/* 数据字段提取区域 */
.result-fields-section {
  margin-top: 20px;
  padding-top: 16px;
  border-top: 2px solid rgba(76, 175, 80, 0.3);
}

.fields-title {
  margin: 0 0 16px;
  color: rgba(76, 175, 80, 0.9);
  font-weight: 600;
  font-size: 0.95rem;
}

.field-item {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 14px;
  padding: 12px;
  background: rgba(76, 175, 80, 0.08);
  border-left: 4px solid rgba(76, 175, 80, 0.5);
  border-radius: 6px;
}

.field-item:last-child {
  margin-bottom: 0;
}

.field-name {
  color: rgba(76, 175, 80, 0.8);
  font-weight: 600;
  font-size: 0.85rem;
}

.field-value {
  color: var(--text);
  font-family: 'Courier New', monospace;
  font-size: 0.85rem;
  word-break: break-all;
  padding: 8px;
  background: rgba(0, 0, 0, 0.2);
  border-radius: 4px;
  max-height: 80px;
  overflow-y: auto;
}

.result-preview {
  margin-top: 20px;
  padding-top: 16px;
  border-top: 1px solid rgba(79, 127, 255, 0.2);
}

/* 0xA6过滤结果区域 */
.result-a6-section {
  margin-top: 20px;
  padding: 16px;
  background: rgba(74, 222, 128, 0.08);
  border: 2px solid rgba(74, 222, 128, 0.3);
  border-radius: 8px;
}

.a6-title {
  margin: 0 0 12px;
  color: rgba(74, 222, 128, 0.9);
  font-weight: 600;
  font-size: 0.95rem;
}

/* 导出部分容器 */
.export-section {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-bottom: 14px;
  padding: 12px;
  background: rgba(74, 222, 128, 0.05);
  border-radius: 6px;
}

.export-section:last-child {
  margin-bottom: 0;
}

.export-label {
  color: rgba(74, 222, 128, 0.8);
  font-weight: 600;
  font-size: 0.85rem;
}

.export-btn {
  display: block;
  padding: 12px 20px;
  background: linear-gradient(135deg, rgba(74, 222, 128, 0.3), rgba(52, 211, 153, 0.2));
  border: 2px solid rgba(74, 222, 128, 0.5);
  border-radius: 8px;
  color: rgba(74, 222, 128, 0.95);
  font-family: inherit;
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 200ms ease;
  position: relative;
  overflow: hidden;
  text-align: center;
  width: 100%;
}

.export-btn:hover {
  background: linear-gradient(135deg, rgba(74, 222, 128, 0.4), rgba(52, 211, 153, 0.3));
  border-color: rgba(74, 222, 128, 0.8);
  transform: translateY(-2px);
  box-shadow: 0 12px 28px rgba(74, 222, 128, 0.2);
}

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

/* 按钮容器 - 支持并排显示 */
.export-buttons-container {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  margin-top: 24px;
}

.export-buttons-container .export-btn {
  flex: 1;
  min-width: 150px;
}

.export-btn-a6 {
  background: linear-gradient(135deg, rgba(74, 222, 128, 0.3), rgba(34, 197, 94, 0.2));
  border-color: rgba(74, 222, 128, 0.5);
  color: rgba(74, 222, 128, 0.95);
}

.export-btn-a6:hover {
  background: linear-gradient(135deg, rgba(74, 222, 128, 0.4), rgba(34, 197, 94, 0.3));
  box-shadow: 0 12px 28px rgba(74, 222, 128, 0.25);
}

.export-btn-all {
  background: linear-gradient(135deg, rgba(79, 172, 254, 0.3), rgba(59, 130, 246, 0.2));
  border-color: rgba(79, 172, 254, 0.5);
  color: rgba(79, 172, 254, 0.95);
}

.export-btn-all:hover {
  background: linear-gradient(135deg, rgba(79, 172, 254, 0.4), rgba(59, 130, 246, 0.3));
  border-color: rgba(79, 172, 254, 0.8);
  box-shadow: 0 12px 28px rgba(79, 172, 254, 0.25);
}

.preview-title {
  margin: 0 0 12px;
  color: var(--text);
  font-weight: 600;
  font-size: 0.9rem;
}

.preview-content {
  margin: 0;
  padding: 12px 16px;
  background: rgba(0, 0, 0, 0.4);
  border: 1px solid rgba(79, 127, 255, 0.2);
  border-radius: 8px;
  color: rgba(79, 200, 100, 0.9);
  font-size: 0.8rem;
  font-family: 'Courier New', monospace;
  overflow-x: auto;
  max-height: 150px;
  overflow-y: auto;
  word-break: break-all;
  white-space: pre-wrap;
}

.preview-content::-webkit-scrollbar {
  width: 4px;
  height: 4px;
}

.preview-content::-webkit-scrollbar-track {
  background: rgba(255, 255, 255, 0.05);
}

.preview-content::-webkit-scrollbar-thumb {
  background: rgba(79, 127, 255, 0.3);
  border-radius: 2px;
}

.preview-content::-webkit-scrollbar-thumb:hover {
  background: rgba(79, 127, 255, 0.5);
}

/* 响应式设计 */
@media (max-width: 500px) {
  .card {
    padding: 32px 24px;
  }

  .header {
    min-height: 36px;
  }

  .back-button {
    padding: 7px 12px;
    font-size: 0.82rem;
  }

  .title {
    font-size: 1.8rem;
  }

  .tree-content {
    max-height: 250px;
  }

  .action-button {
    font-size: 0.95rem;
    padding: 14px 20px;
  }

  .result-item {
    flex-direction: column;
    align-items: flex-start;
  }

  .result-value {
    margin-top: 8px;
    width: 100%;
    text-align: right;
  }

  .field-item {
    margin-bottom: 12px;
  }

  .field-value {
    font-size: 0.8rem;
  }
}

/* ============================================ */
/* CSV 预览容器 - A6 Parser 集成样式优化 */
/* ============================================ */

/* 预览容器的优化 */
#csvPreviewContainer .csv-preview-container {
  background: transparent;
  border: none;
  padding: 0;
  margin: 0;
}

/* 搜索框优化 */
#csvPreviewContainer .csv-search-container {
  margin-bottom: 16px;
  padding: 12px 0;
  border-bottom: 1px solid rgba(79, 127, 255, 0.2);
}

#csvPreviewContainer .csv-search-input {
  background: rgba(255, 255, 255, 0.08);
  border-color: rgba(255, 255, 255, 0.15);
  font-size: 13px;
}

#csvPreviewContainer .csv-search-input::placeholder {
  color: rgba(243, 244, 255, 0.4);
}

#csvPreviewContainer .csv-search-input:focus {
  background: rgba(255, 255, 255, 0.12);
  border-color: rgba(92, 111, 255, 0.6);
}

/* 统计信息优化 */
#csvPreviewContainer .csv-stats {
  background: rgba(92, 111, 255, 0.08);
  border-color: rgba(92, 111, 255, 0.2);
  border-left: 3px solid rgba(92, 111, 255, 0.5);
  padding: 12px;
  margin-bottom: 16px;
  font-size: 12px;
  gap: 12px;
}

#csvPreviewContainer .csv-stats .stat-item {
  gap: 4px;
}

/* 表格容器优化 */
#csvPreviewContainer .csv-table-wrapper {
  border: 1px solid rgba(79, 127, 255, 0.2);
  border-radius: 8px;
  margin-bottom: 16px;
  box-shadow: inset 0 0 8px rgba(0, 0, 0, 0.2);
}

/* 表格优化 */
#csvPreviewContainer .csv-table {
  font-size: 12px;
  width: max-content;
  min-width: 100%;
  table-layout: auto;
}

#csvPreviewContainer .csv-table thead {
  background: rgba(92, 111, 255, 0.12);
  border-bottom: 2px solid rgba(92, 111, 255, 0.2);
}

#csvPreviewContainer .csv-header-cell {
  padding: 10px 12px;
  font-size: 12px;
  font-weight: 600;
  color: rgba(243, 244, 255, 0.9);
  white-space: nowrap;
  min-width: 140px;
  line-height: 1.3;
}

#csvPreviewContainer .header-text {
  display: inline-block;
  vertical-align: middle;
  max-width: 220px;
}

#csvPreviewContainer .csv-cell {
  padding: 7px 12px;
  line-height: 1.35;
  font-size: 12px;
  color: rgba(243, 244, 255, 0.75);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  min-width: 140px;
  max-width: 320px;
}

#csvPreviewContainer .csv-row:hover {
  background: rgba(92, 111, 255, 0.06);
}

/* 分页优化 */
#csvPreviewContainer .csv-pagination {
  border-top: 1px solid rgba(79, 127, 255, 0.2);
  padding-top: 12px;
  margin-top: 12px;
  gap: 6px;
  justify-content: center;
}

#csvPreviewContainer .pagination-btn {
  padding: 6px 12px;
  background: rgba(92, 111, 255, 0.15);
  border: 1px solid rgba(92, 111, 255, 0.3);
  color: rgba(243, 244, 255, 0.8);
  font-size: 12px;
}

#csvPreviewContainer .pagination-btn:hover:not(:disabled) {
  background: rgba(92, 111, 255, 0.25);
  border-color: rgba(92, 111, 255, 0.5);
}

#csvPreviewContainer .page-number {
  padding: 4px 8px;
  font-size: 11px;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(92, 111, 255, 0.2);
}

#csvPreviewContainer .page-number.active {
  background: rgba(92, 111, 255, 0.4);
  color: rgba(243, 244, 255, 0.95);
}

/* 空状态 */
#csvPreviewContainer .csv-empty {
  padding: 32px;
  text-align: center;
  color: rgba(243, 244, 255, 0.5);
}

/* 响应式调整 */
@media (max-width: 768px) {
  #csvPreviewContainer {
    margin: 20px -10px -20px -10px;
    padding: 12px;
  }

  #csvPreviewContainer .csv-header-cell {
    padding: 8px 8px;
    font-size: 11px;
    min-width: 110px;
  }

  #csvPreviewContainer .header-text {
    max-width: 120px;
  }

  #csvPreviewContainer .csv-cell {
    padding: 6px 8px;
    font-size: 11px;
    min-width: 110px;
    max-width: 160px;
  }

  #csvPreviewContainer .csv-stats {
    flex-direction: column;
    gap: 6px;
    font-size: 11px;
  }

  #csvPreviewContainer .csv-pagination {
    flex-wrap: wrap;
  }
}
