/* ===== 全局 ===== */
:root {
  --bg: #f4f6fa;
  --card-bg: #fff;
  --primary: #2563eb;
  --primary-light: #dbeafe;
  --accent: #ef4444;
  --success: #22c55e;
  --text: #1e293b;
  --text-muted: #64748b;
  --border: #e2e8f0;
  --shadow: 0 2px 12px rgba(0,0,0,0.08);
  --radius: 12px;
}

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

body {
  font-family: -apple-system, "PingFang SC", "Microsoft YaHei", sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  padding-bottom: 40px;
}

/* ===== 顶部导航 ===== */
.topbar {
  background: linear-gradient(135deg, #1e40af, #3b82f6);
  color: #fff;
  padding: 0 20px;
  height: 56px;
  display: flex;
  align-items: center;
  gap: 12px;
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: 0 2px 8px rgba(0,0,0,0.2);
}

.logo {
  font-size: 22px;
  font-weight: 700;
  letter-spacing: -0.5px;
}

.topbar-actions {
  display: flex;
  gap: 8px;
  margin-left: auto;
}

.topbar-actions button {
  background: rgba(255,255,255,0.15);
  border: none;
  color: #fff;
  width: 36px;
  height: 36px;
  border-radius: 8px;
  cursor: pointer;
  font-size: 16px;
  transition: background 0.2s;
}
.topbar-actions button:hover { background: rgba(255,255,255,0.3); }

.update-time {
  font-size: 12px;
  opacity: 0.8;
  white-space: nowrap;
}

/* ===== 标签页 ===== */
.tabs {
  display: flex;
  background: #fff;
  padding: 0 16px;
  border-bottom: 1px solid var(--border);
}

.tab {
  padding: 12px 20px;
  border: none;
  background: none;
  font-size: 15px;
  color: var(--text-muted);
  cursor: pointer;
  border-bottom: 3px solid transparent;
  transition: all 0.2s;
}
.tab.active {
  color: var(--primary);
  border-bottom-color: var(--primary);
  font-weight: 600;
}
.tab:hover:not(.active) { color: var(--text); }

/* ===== 通用布局 ===== */
.tab-content { display: none; padding: 20px 16px; }
.tab-content.active { display: block; }

/* ===== 搜索栏 ===== */
.search-bar {
  display: flex;
  gap: 8px;
  margin-bottom: 20px;
}
.search-bar input {
  flex: 1;
  padding: 10px 14px;
  border: 2px solid var(--border);
  border-radius: var(--radius);
  font-size: 15px;
  transition: border-color 0.2s;
  outline: none;
}
.search-bar input:focus { border-color: var(--primary); }

.btn-search {
  padding: 10px 20px;
  background: var(--primary);
  color: #fff;
  border: none;
  border-radius: var(--radius);
  font-size: 15px;
  cursor: pointer;
  white-space: nowrap;
  transition: background 0.2s;
}
.btn-search:hover { background: #1d4ed8; }

/* ===== 搜索结果 ===== */
.search-result {
  background: var(--card-bg);
  border-radius: var(--radius);
  padding: 16px;
  margin-bottom: 20px;
  box-shadow: var(--shadow);
}
.search-result h3 { font-size: 15px; color: var(--text-muted); margin-bottom: 12px; }

/* ===== 区块标题 ===== */
.section-header {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 24px 0 14px;
}
.section-header h2 { font-size: 17px; font-weight: 600; }
.car-count {
  background: var(--primary-light);
  color: var(--primary);
  padding: 2px 10px;
  border-radius: 20px;
  font-size: 13px;
  font-weight: 600;
}
#carTotal { font-size: 13px; color: var(--text-muted); margin-left: auto; }

/* ===== 车型卡片 ===== */
.car-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 14px;
}

.car-card {
  background: var(--card-bg);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
  transition: transform 0.2s, box-shadow 0.2s;
  border: 2px solid transparent;
}
.car-card:hover { transform: translateY(-3px); box-shadow: 0 6px 20px rgba(0,0,0,0.12); }
.car-card.in-compare { border-color: var(--primary); }

.car-img {
  width: 100%;
  height: 140px;
  object-fit: cover;
  background: linear-gradient(135deg, #e2e8f0, #f1f5f9);
  display: flex;
  align-items: center;
  justify-content: center;
  color: #94a3b8;
  font-size: 40px;
}
.car-img img { width: 100%; height: 100%; object-fit: cover; }

.car-body { padding: 12px 14px; }
.car-name {
  font-size: 16px;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 4px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.car-brand { font-size: 12px; color: var(--text-muted); margin-bottom: 8px; }
.car-price {
  font-size: 18px;
  font-weight: 800;
  color: var(--accent);
  margin-bottom: 4px;
}
.car-price .unit { font-size: 13px; font-weight: 400; color: var(--text-muted); }
.car-price .range { font-size: 13px; color: var(--text-muted); font-weight: 400; }
.car-source { font-size: 11px; color: #94a3b8; }
.car-note { font-size: 12px; color: var(--text-muted); margin-top: 4px; font-style: italic; }

.car-actions {
  display: flex;
  gap: 6px;
  margin-top: 10px;
}
.btn-compare {
  flex: 1;
  padding: 7px;
  border: 2px solid var(--primary);
  background: none;
  color: var(--primary);
  border-radius: 8px;
  font-size: 13px;
  cursor: pointer;
  font-weight: 600;
  transition: all 0.2s;
}
.btn-compare:hover { background: var(--primary); color: #fff; }
.btn-compare.active { background: var(--primary); color: #fff; }

.btn-detail {
  padding: 7px 12px;
  border: none;
  background: var(--primary-light);
  color: var(--primary);
  border-radius: 8px;
  font-size: 13px;
  cursor: pointer;
  transition: background 0.2s;
}
.btn-detail:hover { background: #bfdbfe; }

/* ===== AI 分析 ===== */
.ai-analysis {
  background: linear-gradient(135deg, #f0f9ff, #e0f2fe);
  border: 1px solid #7dd3fc;
  border-radius: var(--radius);
  padding: 16px 18px;
  margin: 16px 0;
}
.ai-badge {
  font-size: 13px;
  color: #0369a1;
  font-weight: 600;
  margin-bottom: 8px;
}
.ai-analysis p { font-size: 14px; line-height: 1.7; color: #0c4a6e; }

/* ===== 空提示 ===== */
.empty-tip {
  text-align: center;
  padding: 40px;
  color: var(--text-muted);
  font-size: 15px;
}

/* ===== 资讯列表 ===== */
.news-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
}
.news-header h2 { font-size: 17px; font-weight: 600; }

.btn-sm {
  padding: 6px 14px;
  border: 1px solid var(--border);
  background: #fff;
  border-radius: 8px;
  font-size: 13px;
  cursor: pointer;
  transition: all 0.2s;
}
.btn-sm:hover { background: var(--primary-light); color: var(--primary); }

.news-list { display: flex; flex-direction: column; gap: 12px; }

.news-item {
  background: var(--card-bg);
  border-radius: var(--radius);
  padding: 14px 16px;
  box-shadow: var(--shadow);
  border-left: 4px solid var(--primary);
}
.news-item:hover { border-left-color: var(--accent); }

.news-title {
  font-size: 15px;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 6px;
  line-height: 1.4;
}
.news-title a { color: inherit; text-decoration: none; }
.news-title a:hover { color: var(--primary); }

.news-meta {
  display: flex;
  gap: 12px;
  font-size: 12px;
  color: var(--text-muted);
  margin-bottom: 6px;
}
.news-summary {
  font-size: 13px;
  color: var(--text-muted);
  line-height: 1.6;
}
.news-ai {
  margin-top: 8px;
  padding: 8px 10px;
  background: #f0f9ff;
  border-radius: 8px;
  font-size: 13px;
  color: #0369a1;
  line-height: 1.6;
}

/* ===== 说明页 ===== */
.about-card {
  background: var(--card-bg);
  border-radius: var(--radius);
  padding: 24px;
  box-shadow: var(--shadow);
}
.about-card h2 { margin-bottom: 10px; }
.about-card h3 { margin: 18px 0 8px; font-size: 15px; color: var(--primary); }
.about-card p { font-size: 14px; line-height: 1.7; color: var(--text-muted); margin-bottom: 8px; }
.about-card ul { padding-left: 20px; }
.about-card ul li { font-size: 14px; line-height: 2; color: var(--text-muted); }
.about-card code {
  background: #f1f5f9;
  padding: 2px 6px;
  border-radius: 4px;
  font-size: 13px;
  color: #d946ef;
}

/* ===== 弹窗 ===== */
.modal {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 200;
  backdrop-filter: blur(4px);
}
.modal-content {
  background: #fff;
  border-radius: var(--radius);
  padding: 24px;
  width: 90%;
  max-width: 420px;
  box-shadow: 0 20px 60px rgba(0,0,0,0.3);
}
.modal-content h3 { margin-bottom: 16px; }
.modal-content label {
  display: block;
  font-size: 13px;
  color: var(--text-muted);
  margin-bottom: 4px;
  margin-top: 12px;
}
.modal-content input,
.modal-content select,
.modal-content textarea {
  width: 100%;
  padding: 9px 12px;
  border: 1.5px solid var(--border);
  border-radius: 8px;
  font-size: 14px;
  font-family: inherit;
  outline: none;
}
.modal-content input:focus,
.modal-content select:focus,
.modal-content textarea:focus { border-color: var(--primary); }

.modal-actions {
  display: flex;
  gap: 10px;
  justify-content: flex-end;
  margin-top: 18px;
}
.btn-cancel {
  padding: 8px 18px;
  border: 1px solid var(--border);
  background: #fff;
  border-radius: 8px;
  cursor: pointer;
  font-size: 14px;
}
.btn-save {
  padding: 8px 18px;
  background: var(--primary);
  color: #fff;
  border: none;
  border-radius: 8px;
  cursor: pointer;
  font-size: 14px;
}
.btn-save:hover { background: #1d4ed8; }

/* ===== 加载动画 ===== */
.loading {
  position: fixed;
  inset: 0;
  background: rgba(244,246,250,0.85);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  z-index: 300;
}
.spinner {
  width: 40px;
  height: 40px;
  border: 4px solid #e2e8f0;
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}
.loading p { margin-top: 12px; color: var(--text-muted); font-size: 14px; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ===== 加载更多 ===== */
.load-more {
  grid-column: 1 / -1;
  text-align: center;
  padding: 12px;
}

/* ===== 响应式 ===== */
@media (max-width: 600px) {
  .car-grid { grid-template-columns: 1fr; }
  .topbar { padding: 0 12px; }
  .tabs { padding: 0 8px; }
  .tab { padding: 10px 12px; font-size: 14px; }
}
