/* ===== 全局样式 ===== */
:root {
  --primary: #6366f1;
  --primary-dark: #4f46e5;
  --secondary: #06b6d4;
  --accent: #f59e0b;
  --bg-dark: #0f172a;
  --bg-card: #1e293b;
  --bg-card-hover: #334155;
  --text-primary: #f1f5f9;
  --text-secondary: #94a3b8;
  --text-muted: #64748b;
  --border: #334155;
  --success: #22c55e;
  --warning: #f59e0b;
  --danger: #ef4444;
  --gradient-1: linear-gradient(135deg, #6366f1, #06b6d4);
  --gradient-2: linear-gradient(135deg, #f59e0b, #ef4444);
}

* { margin: 0; padding: 0; box-sizing: border-box; }

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'PingFang SC', 'Hiragino Sans GB', 'Microsoft YaHei', sans-serif;
  background: var(--bg-dark);
  color: var(--text-primary);
  line-height: 1.6;
  min-height: 100vh;
}

a { color: var(--secondary); text-decoration: none; transition: color 0.2s; }
a:hover { color: var(--primary); }

/* ===== 导航栏 ===== */
.navbar {
  background: rgba(15, 23, 42, 0.95);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 100;
  padding: 0 2rem;
}

.navbar-inner {
  max-width: 1280px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 64px;
}

.logo {
  font-size: 1.4rem;
  font-weight: 700;
  background: var(--gradient-1);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.logo-icon { font-size: 1.6rem; -webkit-text-fill-color: initial; }

.nav-links {
  display: flex;
  gap: 0.5rem;
  list-style: none;
}

.nav-links a {
  color: var(--text-secondary);
  padding: 0.5rem 1rem;
  border-radius: 8px;
  font-size: 0.9rem;
  font-weight: 500;
  transition: all 0.2s;
}

.nav-links a:hover,
.nav-links a.active {
  color: var(--text-primary);
  background: var(--bg-card);
}

.nav-links a.active {
  background: var(--primary);
  color: white;
}

/* 移动端菜单按钮 */
.menu-toggle {
  display: none;
  background: none;
  border: none;
  color: var(--text-primary);
  font-size: 1.5rem;
  cursor: pointer;
}

/* ===== 主内容 ===== */
.container {
  max-width: 1280px;
  margin: 0 auto;
  padding: 2rem;
}

.page-header {
  text-align: center;
  margin-bottom: 2.5rem;
}

.page-header h1 {
  font-size: 2.2rem;
  font-weight: 700;
  margin-bottom: 0.5rem;
  background: var(--gradient-1);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.page-header p {
  color: var(--text-secondary);
  font-size: 1.05rem;
}

/* ===== 卡片 ===== */
.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 1.5rem;
  transition: all 0.3s;
}

.card:hover {
  background: var(--bg-card-hover);
  transform: translateY(-2px);
  box-shadow: 0 8px 32px rgba(0,0,0,0.3);
}

.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1rem;
}

.card-title {
  font-size: 1.15rem;
  font-weight: 600;
}

.card-subtitle {
  color: var(--text-secondary);
  font-size: 0.85rem;
}

/* ===== 网格布局 ===== */
.grid-2 { display: grid; grid-template-columns: repeat(2, 1fr); gap: 1.5rem; }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 1.5rem; }
.grid-4 { display: grid; grid-template-columns: repeat(4, 1fr); gap: 1.5rem; }

/* ===== 统计数字 ===== */
.stat-value {
  font-size: 2rem;
  font-weight: 700;
  color: var(--primary);
}

.stat-label {
  color: var(--text-secondary);
  font-size: 0.85rem;
  margin-top: 0.25rem;
}

/* ===== 标签/徽章 ===== */
.badge {
  display: inline-block;
  padding: 0.2rem 0.6rem;
  border-radius: 20px;
  font-size: 0.75rem;
  font-weight: 600;
}

.badge-primary { background: rgba(99,102,241,0.2); color: var(--primary); }
.badge-success { background: rgba(34,197,94,0.2); color: var(--success); }
.badge-warning { background: rgba(245,158,11,0.2); color: var(--warning); }
.badge-danger { background: rgba(239,68,68,0.2); color: var(--danger); }
.badge-info { background: rgba(6,182,212,0.2); color: var(--secondary); }

/* ===== 按钮 ===== */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.6rem 1.2rem;
  border: none;
  border-radius: 8px;
  font-size: 0.9rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s;
}

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

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

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

.btn-secondary:hover { background: var(--bg-card-hover); }

.btn-sm { padding: 0.4rem 0.8rem; font-size: 0.8rem; }

/* ===== 表单 ===== */
.form-group { margin-bottom: 1rem; }

.form-label {
  display: block;
  color: var(--text-secondary);
  font-size: 0.85rem;
  margin-bottom: 0.4rem;
  font-weight: 500;
}

.form-input,
.form-select {
  width: 100%;
  padding: 0.6rem 1rem;
  background: var(--bg-dark);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text-primary);
  font-size: 0.9rem;
  transition: border-color 0.2s;
}

.form-input:focus,
.form-select:focus {
  outline: none;
  border-color: var(--primary);
}

.form-select { cursor: pointer; }
.form-select option { background: var(--bg-dark); }

/* ===== 范围滑块 ===== */
.range-slider {
  width: 100%;
  -webkit-appearance: none;
  height: 6px;
  border-radius: 3px;
  background: var(--border);
  outline: none;
}

.range-slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: var(--primary);
  cursor: pointer;
}

/* ===== 进度条 ===== */
.progress-bar {
  width: 100%;
  height: 8px;
  background: var(--border);
  border-radius: 4px;
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  border-radius: 4px;
  transition: width 0.5s ease;
}

.progress-fill.green { background: var(--success); }
.progress-fill.yellow { background: var(--warning); }
.progress-fill.red { background: var(--danger); }
.progress-fill.blue { background: var(--secondary); }
.progress-fill.purple { background: var(--primary); }

/* ===== 表格 ===== */
.table-wrapper {
  overflow-x: auto;
  border-radius: 12px;
  border: 1px solid var(--border);
}

table {
  width: 100%;
  border-collapse: collapse;
}

th, td {
  padding: 0.75rem 1rem;
  text-align: left;
  border-bottom: 1px solid var(--border);
}

th {
  background: var(--bg-card);
  color: var(--text-secondary);
  font-weight: 600;
  font-size: 0.85rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  cursor: pointer;
}

th:hover { color: var(--text-primary); }

tr:hover { background: rgba(99,102,241,0.05); }

/* ===== Pyodide 加载遮罩 ===== */
.pyodide-loading {
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(15,23,42,0.9);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  gap: 1rem;
}

.pyodide-loading.hidden { display: none; }

.pyodide-loading .spinner {
  width: 48px;
  height: 48px;
  border: 4px solid var(--border);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

.pyodide-loading .loading-text {
  color: var(--text-secondary);
  font-size: 0.95rem;
}

.pyodide-loading .loading-progress {
  width: 300px;
  height: 4px;
  background: var(--border);
  border-radius: 2px;
  overflow: hidden;
}

.pyodide-loading .loading-progress-fill {
  height: 100%;
  background: var(--gradient-1);
  border-radius: 2px;
  transition: width 0.3s;
  width: 0%;
}

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

/* ===== 评分星级 ===== */
.score-bar {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

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

.score-bar .bar-fill {
  height: 100%;
  border-radius: 3px;
  background: var(--gradient-1);
}

.score-bar .score-num {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-primary);
  min-width: 2rem;
}

/* ===== 图表容器 ===== */
.chart-container {
  position: relative;
  width: 100%;
  max-height: 400px;
}

.chart-container canvas {
  width: 100% !important;
}

/* ===== 筛选栏 ===== */
.filter-bar {
  display: flex;
  gap: 1rem;
  flex-wrap: wrap;
  align-items: end;
  margin-bottom: 1.5rem;
  padding: 1.25rem;
  background: var(--bg-card);
  border-radius: 12px;
  border: 1px solid var(--border);
}

.filter-bar .form-group { margin-bottom: 0; flex: 1; min-width: 180px; }

/* ===== 城市卡片 ===== */
.city-card {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.city-card .city-name {
  font-size: 1.1rem;
  font-weight: 600;
}

.city-card .city-country {
  color: var(--text-secondary);
  font-size: 0.85rem;
}

.city-card .city-cost {
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--accent);
}

.city-card .city-metrics {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.5rem;
}

.city-card .metric {
  display: flex;
  justify-content: space-between;
  font-size: 0.8rem;
}

.city-card .metric-label { color: var(--text-muted); }
.city-card .metric-value { font-weight: 600; }

/* ===== 对比表格 ===== */
.compare-table td:first-child {
  color: var(--text-secondary);
  font-weight: 500;
}

.compare-highlight {
  color: var(--success) !important;
  font-weight: 700 !important;
}

/* ===== 签证卡片 ===== */
.visa-card {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.visa-card .visa-country {
  font-size: 1.1rem;
  font-weight: 600;
}

.visa-card .visa-name {
  color: var(--secondary);
  font-size: 0.9rem;
}

.visa-card .visa-details {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.5rem;
  font-size: 0.85rem;
}

.visa-card .visa-requirements {
  margin-top: 0.5rem;
}

.visa-card .visa-requirements li {
  color: var(--text-secondary);
  font-size: 0.8rem;
  margin-bottom: 0.25rem;
  padding-left: 1rem;
  position: relative;
}

.visa-card .visa-requirements li::before {
  content: '✓';
  position: absolute;
  left: 0;
  color: var(--success);
}

/* ===== 搜索框 ===== */
.search-box {
  position: relative;
  max-width: 500px;
  margin: 0 auto 2rem;
}

.search-box input {
  width: 100%;
  padding: 0.8rem 1rem 0.8rem 2.5rem;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 12px;
  color: var(--text-primary);
  font-size: 1rem;
}

.search-box input:focus {
  outline: none;
  border-color: var(--primary);
}

.search-box .search-icon {
  position: absolute;
  left: 0.8rem;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-muted);
}

/* ===== Footer ===== */
.footer {
  border-top: 1px solid var(--border);
  padding: 2rem;
  text-align: center;
  color: var(--text-muted);
  font-size: 0.85rem;
  margin-top: 3rem;
}

/* ===== 空状态 ===== */
.empty-state {
  text-align: center;
  padding: 3rem;
  color: var(--text-muted);
}

.empty-state .icon { font-size: 3rem; margin-bottom: 1rem; }

/* ===== 排序指示器 ===== */
th .sort-arrow { margin-left: 0.3rem; font-size: 0.7rem; }
th.sort-asc .sort-arrow::after { content: '▲'; }
th.sort-desc .sort-arrow::after { content: '▼'; }

/* ===== 工具提示 ===== */
.tooltip {
  position: relative;
  cursor: help;
}

.tooltip::after {
  content: attr(data-tip);
  position: absolute;
  bottom: 100%;
  left: 50%;
  transform: translateX(-50%);
  background: var(--bg-card);
  color: var(--text-primary);
  padding: 0.4rem 0.8rem;
  border-radius: 6px;
  font-size: 0.8rem;
  white-space: nowrap;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s;
  border: 1px solid var(--border);
}

.tooltip:hover::after { opacity: 1; }

/* ===== 动画 ===== */
.fade-in {
  animation: fadeIn 0.4s ease;
}

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

/* ===== 响应式 ===== */
@media (max-width: 1024px) {
  .grid-4 { grid-template-columns: repeat(2, 1fr); }
  .grid-3 { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 768px) {
  .navbar { padding: 0 1rem; }

  .menu-toggle { display: block; }

  .nav-links {
    display: none;
    position: absolute;
    top: 64px;
    left: 0;
    right: 0;
    background: var(--bg-dark);
    border-bottom: 1px solid var(--border);
    flex-direction: column;
    padding: 1rem;
  }

  .nav-links.open { display: flex; }

  .container { padding: 1rem; }

  .page-header h1 { font-size: 1.6rem; }

  .grid-2, .grid-3, .grid-4 {
    grid-template-columns: 1fr;
  }

  .filter-bar {
    flex-direction: column;
  }

  .filter-bar .form-group { min-width: 100%; }

  .stat-value { font-size: 1.5rem; }
}

@media (max-width: 480px) {
  .page-header h1 { font-size: 1.3rem; }
  .card { padding: 1rem; }
}
