/* ============================================
   Toolbox - 公共样式文件
   包含所有页面共享的CSS变量、工具类和组件
   ============================================ */

/* ---------- CSS 变量 ---------- */
:root {
  --bg-deep: #0c0f14;
  --bg-base: #12161e;
  --bg-card: #1a1f2b;
  --bg-elevated: #222838;
  --border: #2a3040;
  --border-active: #3d8bfd;
  --text-primary: #e8ecf4;
  --text-secondary: #8892a6;
  --text-muted: #565e72;
  --accent: #3d8bfd;
  --accent-glow: rgba(61, 139, 253, 0.15);
  --danger: #f0544f;
  --danger-bg: rgba(240, 84, 79, 0.1);
  --warning: #f5a623;
  --warning-bg: rgba(245, 166, 35, 0.1);
  --success: #27c682;
  --success-bg: rgba(39, 198, 130, 0.1);
  --info: #5bc0eb;
  --info-bg: rgba(91, 192, 235, 0.1);
  --purple: #a855f7;
  --purple-bg: rgba(168, 85, 247, 0.1);
  --orange: #f97316;
  --orange-bg: rgba(249, 115, 22, 0.1);
  --pink: #ec4899;
  --pink-bg: rgba(236, 72, 153, 0.1);
}

/* ---------- 基础重置 ---------- */
* { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: 'Noto Sans SC', sans-serif;
  background: var(--bg-deep);
  color: var(--text-primary);
  min-height: 100vh;
  overflow-x: hidden;
}

/* ---------- 工具类 ---------- */
.mono { font-family: 'JetBrains Mono', monospace; }

/* ---------- 背景光晕 ---------- */
.bg-glow {
  position: fixed;
  width: 600px;
  height: 600px;
  border-radius: 50%;
  filter: blur(150px);
  opacity: 0.07;
  pointer-events: none;
  z-index: 0;
}
.bg-glow-1 { top: -200px; left: -100px; background: var(--accent); }
.bg-glow-2 { bottom: -200px; right: -100px; background: var(--success); }
.bg-glow-3 { top: 50%; left: 50%; transform: translate(-50%, -50%); background: var(--purple); opacity: 0.04; }

/* ---------- 返回链接 ---------- */
.back-link {
  position: absolute;
  left: 24px;
  top: 32px;
  color: var(--text-secondary);
  text-decoration: none;
  font-size: 13px;
  display: flex;
  align-items: center;
  gap: 6px;
  transition: color 0.2s;
  z-index: 10;
}
.back-link:hover { color: var(--accent); }

@media (max-width: 768px) {
  .back-link { position: static; margin-bottom: 16px; justify-content: center; }
}

/* ---------- 按钮样式 ---------- */
.btn-primary {
  background: var(--accent);
  color: #fff;
  font-weight: 600;
  padding: 12px 32px;
  border-radius: 10px;
  border: none;
  cursor: pointer;
  font-size: 15px;
  transition: all 0.25s ease;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-family: inherit;
}
.btn-primary:hover:not(:disabled) {
  background: #5a9efd;
  transform: translateY(-1px);
  box-shadow: 0 6px 24px rgba(61, 139, 253, 0.3);
}
.btn-primary:disabled {
  opacity: 0.35;
  cursor: not-allowed;
}

.btn-outline {
  background: transparent;
  color: var(--text-secondary);
  font-weight: 500;
  padding: 10px 20px;
  border-radius: 8px;
  border: 1px solid var(--border);
  cursor: pointer;
  font-size: 13px;
  transition: all 0.2s;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-family: inherit;
}
.btn-outline:hover {
  border-color: var(--text-secondary);
  color: var(--text-primary);
  background: var(--bg-elevated);
}

.btn-success {
  background: var(--success);
  color: #fff;
  font-weight: 600;
  padding: 12px 32px;
  border-radius: 10px;
  border: none;
  cursor: pointer;
  font-size: 15px;
  transition: all 0.25s ease;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-family: inherit;
}
.btn-success:hover:not(:disabled) {
  background: #3bd992;
  transform: translateY(-1px);
  box-shadow: 0 6px 24px rgba(39, 198, 130, 0.3);
}

.btn {
  background: var(--bg-elevated);
  color: var(--text-secondary);
  font-weight: 500;
  padding: 8px 16px;
  border-radius: 8px;
  border: 1px solid var(--border);
  cursor: pointer;
  font-size: 13px;
  transition: all 0.2s;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-family: inherit;
}
.btn:hover {
  border-color: var(--text-muted);
  color: var(--text-primary);
}
.btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.btn-icon {
  width: 36px;
  height: 36px;
  padding: 0;
  justify-content: center;
}

/* ---------- 上传区域 ---------- */
.upload-zone {
  border: 2px dashed var(--border);
  border-radius: 16px;
  padding: 40px 24px;
  text-align: center;
  cursor: pointer;
  transition: all 0.3s ease;
  background: var(--bg-card);
  position: relative;
  overflow: hidden;
}
.upload-zone::before {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(135deg, var(--accent-glow), transparent);
  opacity: 0;
  transition: opacity 0.3s;
}
.upload-zone:hover, .upload-zone.drag-over {
  border-color: var(--accent);
  transform: translateY(-2px);
}
.upload-zone:hover::before, .upload-zone.drag-over::before { opacity: 1; }
.upload-zone.loaded {
  border-color: var(--success);
  border-style: solid;
}
.upload-zone.loaded::before {
  background: linear-gradient(135deg, var(--success-bg), transparent);
  opacity: 1;
}

/* ---------- 统计卡片 ---------- */
.stat-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 20px 24px;
  position: relative;
  overflow: hidden;
}
.stat-card::after {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 3px;
}
.stat-card.stat-total::after { background: var(--accent); }
.stat-card.stat-added::after { background: var(--success); }
.stat-card.stat-removed::after { background: var(--danger); }
.stat-card.stat-modified::after { background: var(--warning); }
.stat-card.stat-match::after { background: var(--info); }
.stat-card.stat-csv::after { background: var(--warning); }
.stat-card.stat-excel::after { background: var(--success); }
.stat-card.stat-json::after { background: var(--info); }
.stat-card.stat-rows::after { background: var(--accent); }

/* ---------- 表格样式 ---------- */
.table-scroll {
  max-height: 520px;
  overflow-y: auto;
  overflow-x: auto;
}
.table-scroll::-webkit-scrollbar { width: 6px; height: 6px; }
.table-scroll::-webkit-scrollbar-track { background: transparent; }
.table-scroll::-webkit-scrollbar-thumb {
  background: var(--border);
  border-radius: 3px;
}
.table-scroll::-webkit-scrollbar-thumb:hover { background: var(--text-muted); }

/* ---------- 文件信息 ---------- */
.file-info {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 18px;
  background: var(--bg-elevated);
  border-radius: 10px;
  margin-top: 16px;
}
.file-icon {
  width: 40px;
  height: 40px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  flex-shrink: 0;
}
.file-icon.xlsx { background: rgba(39, 198, 130, 0.15); color: var(--success); }
.file-icon.xls { background: rgba(91, 192, 235, 0.15); color: var(--info); }
.file-icon.csv { background: rgba(245, 166, 35, 0.15); color: var(--warning); }
.file-icon.json { background: rgba(91, 192, 235, 0.15); color: var(--info); }

/* ---------- 表单元素 ---------- */
.key-select, .custom-select, .select {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  color: var(--text-primary);
  padding: 8px 12px;
  border-radius: 8px;
  font-size: 13px;
  font-family: inherit;
  min-width: 140px;
  cursor: pointer;
  appearance: none;
  -webkit-appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' fill='%238892a6' viewBox='0 0 16 16'%3E%3Cpath d='M8 11L3 6h10z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 10px center;
  padding-right: 30px;
}
.key-select:focus, .custom-select:focus, .select:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-glow);
}

.input-field {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  color: var(--text-primary);
  padding: 8px 12px;
  border-radius: 8px;
  font-size: 13px;
  font-family: inherit;
  width: 80px;
}
.input-field:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-glow);
}

/* ---------- 标签/徽章 ---------- */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 10px;
  border-radius: 6px;
  font-size: 11px;
  font-weight: 600;
  white-space: nowrap;
}
.badge-added { background: var(--success-bg); color: var(--success); }
.badge-removed { background: var(--danger-bg); color: var(--danger); }
.badge-modified { background: var(--warning-bg); color: var(--warning); }
.badge-match { background: var(--info-bg); color: var(--info); }

.filter-tag, .format-tag {
  padding: 6px 16px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--bg-card);
  color: var(--text-secondary);
  cursor: pointer;
  font-size: 13px;
  font-weight: 500;
  transition: all 0.2s;
  font-family: inherit;
}
.filter-tag:hover, .format-tag:hover { border-color: var(--text-muted); color: var(--text-primary); }
.filter-tag.active, .format-tag.active {
  border-color: var(--accent);
  background: var(--accent-glow);
  color: var(--accent);
}

/* ---------- Toast 通知 ---------- */
.toast-container {
  position: fixed;
  top: 24px;
  right: 24px;
  z-index: 9999;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.toast {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  color: var(--text-primary);
  padding: 12px 20px;
  border-radius: 10px;
  font-size: 13px;
  display: flex;
  align-items: center;
  gap: 8px;
  animation: toastIn 0.3s ease, toastOut 0.3s ease 2.7s forwards;
  box-shadow: 0 8px 32px rgba(0,0,0,0.4);
}
@keyframes toastIn { from { opacity: 0; transform: translateX(40px); } to { opacity: 1; transform: translateX(0); } }
@keyframes toastOut { from { opacity: 1; } to { opacity: 0; transform: translateX(40px); } }

/* ---------- 空状态 ---------- */
.empty-state {
  text-align: center;
  padding: 60px 24px;
  color: var(--text-muted);
}
.empty-state i {
  font-size: 48px;
  margin-bottom: 16px;
  opacity: 0.4;
}

/* ---------- 进度条 ---------- */
.progress-bar {
  height: 3px;
  background: var(--border);
  border-radius: 2px;
  overflow: hidden;
}
.progress-bar-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--accent), var(--success));
  border-radius: 2px;
  transition: width 0.3s ease;
}

/* ---------- 动画 ---------- */
@keyframes fadeUp {
  from { opacity: 0; transform: translateY(30px); }
  to { opacity: 1; transform: translateY(0); }
}
.fade-up {
  animation: fadeUp 0.6s cubic-bezier(0.4, 0, 0.2, 1) forwards;
  opacity: 0;
}
.fade-up-d1 { animation-delay: 0.1s; }
.fade-up-d2 { animation-delay: 0.2s; }
.fade-up-d3 { animation-delay: 0.3s; }
.fade-up-d4 { animation-delay: 0.4s; }
.fade-up-d5 { animation-delay: 0.5s; }
.fade-up-d6 { animation-delay: 0.6s; }

@keyframes pulse-glow {
  0%, 100% { box-shadow: 0 0 20px rgba(61, 139, 253, 0.2); }
  50% { box-shadow: 0 0 40px rgba(61, 139, 253, 0.4); }
}

@keyframes pulse-ring {
  0% { box-shadow: 0 0 0 0 rgba(61, 139, 253, 0.4); }
  70% { box-shadow: 0 0 0 12px rgba(61, 139, 253, 0); }
  100% { box-shadow: 0 0 0 0 rgba(61, 139, 253, 0); }
}
.pulse { animation: pulse-ring 2s infinite; }

@keyframes spin {
  to { transform: rotate(360deg); }
}

/* ---------- 滚动条 ---------- */
::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb {
  background: var(--border);
  border-radius: 4px;
}
::-webkit-scrollbar-thumb:hover { background: var(--text-muted); }

/* ---------- 响应式 ---------- */
@media (max-width: 768px) {
  .upload-grid { grid-template-columns: 1fr !important; }
  .stats-grid { grid-template-columns: repeat(2, 1fr) !important; }
  .config-inner { flex-direction: column !important; align-items: stretch !important; }
  .config-inner .btn-primary { justify-content: center; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    transition-duration: 0.01ms !important;
  }
}
