/* ===== CSS Variables & Reset ===== */
:root {
  --bg-primary: #0d1117;
  --bg-secondary: #161b22;
  --bg-card: #1c2333;
  --bg-hover: #21283a;
  --border: #2d3748;
  --text-primary: #e6edf3;
  --text-secondary: #8b949e;
  --text-muted: #6e7681;
  --accent: #58a6ff;
  --accent-hover: #79b8ff;
  --danger: #f85149;
  --success: #3fb950;
  --warning: #d2991d;
  --radius: 12px;
  --radius-sm: 8px;
  --radius-xs: 4px;
  --shadow: 0 2px 8px rgba(0,0,0,0.3);
  --shadow-lg: 0 8px 32px rgba(0,0,0,0.5);
  --transition: 0.2s ease;
}

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

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
  background: var(--bg-primary);
  color: var(--text-primary);
  line-height: 1.5;
  min-height: 100vh;
  overflow-x: hidden;
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ===== Header ===== */
.header {
  position: sticky;
  top: 0;
  z-index: 100;
  background: rgba(13,17,23,0.92);
  backdrop-filter: blur(16px);
  border-bottom: 1px solid var(--border);
  padding: 0 24px;
}
.header-inner {
  max-width: 1400px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  gap: 24px;
  height: 56px;
}
.logo {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 18px;
  font-weight: 700;
  letter-spacing: -0.5px;
  white-space: nowrap;
  color: var(--accent);
}
.search-box {
  flex: 1;
  max-width: 480px;
  position: relative;
}
.search-icon {
  position: absolute;
  left: 12px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-muted);
  pointer-events: none;
}
.search-box input {
  width: 100%;
  height: 36px;
  padding: 0 36px;
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: 20px;
  color: var(--text-primary);
  font-size: 14px;
  outline: none;
  transition: var(--transition);
}
.search-box input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(88,166,255,0.15);
}
.search-box input::placeholder { color: var(--text-muted); }
.clear-search {
  position: absolute;
  right: 8px;
  top: 50%;
  transform: translateY(-50%);
  background: var(--bg-hover);
  border: none;
  color: var(--text-secondary);
  width: 22px;
  height: 22px;
  border-radius: 50%;
  cursor: pointer;
  font-size: 11px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: var(--transition);
}
.clear-search:hover { color: var(--text-primary); background: var(--border); }

/* ===== Layout ===== */
.main-container {
  max-width: 1400px;
  margin: 0 auto;
  display: flex;
  gap: 0;
  min-height: calc(100vh - 56px);
}

/* ===== Sidebar ===== */
.sidebar {
  width: 240px;
  flex-shrink: 0;
  padding: 20px 16px;
  border-right: 1px solid var(--border);
  position: sticky;
  top: 56px;
  height: calc(100vh - 56px - 100px);
  overflow-y: auto;
}
.sidebar-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 12px;
}
.sidebar-header h3 {
  font-size: 13px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-secondary);
}
.btn-text {
  background: none;
  border: none;
  color: var(--accent);
  cursor: pointer;
  font-size: 12px;
  padding: 2px 6px;
  border-radius: var(--radius-xs);
  transition: var(--transition);
}
.btn-text:hover { background: var(--bg-hover); }

.brand-list {
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.brand-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 12px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: background 0.2s ease, border-color 0.2s ease, color 0.2s ease, transform 0.15s ease;
  font-size: 14px;
  border: 1px solid transparent;
}
.brand-item:hover { background: var(--bg-hover); transform: translateX(3px); }
.brand-item.active {
  background: rgba(88,166,255,0.1);
  border-color: var(--accent);
  color: var(--accent);
  transform: translateX(2px);
}
.brand-item .brand-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
}
.brand-item .brand-count {
  margin-left: auto;
  font-size: 12px;
  color: var(--text-muted);
  background: var(--bg-hover);
  padding: 1px 6px;
  border-radius: 10px;
}

.sidebar-footer {
  margin-top: 20px;
  padding-top: 16px;
  border-top: 1px solid var(--border);
}
.type-filter .label {
  display: block;
  font-size: 12px;
  color: var(--text-secondary);
  margin-bottom: 8px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}
.type-filter .chip {
  display: inline-block;
  margin: 0 4px 6px 0;
  padding: 4px 10px;
  font-size: 12px;
  border-radius: 14px;
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  cursor: pointer;
  transition: background 0.2s ease, border-color 0.2s ease, color 0.2s ease, transform 0.15s ease;
  color: var(--text-secondary);
}
.type-filter .chip:hover { border-color: var(--accent); color: var(--text-primary); transform: scale(1.05); }
.type-filter .chip:has(input:checked) {
  background: rgba(88,166,255,0.15);
  border-color: var(--accent);
  color: var(--accent);
  transform: scale(1.02);
}
.type-filter .chip input { display: none; }

/* ===== Content ===== */
.content {
  flex: 1;
  padding: 20px 24px;
  min-width: 0;
}

.status-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 16px;
  font-size: 13px;
  color: var(--text-secondary);
}
#resultCount { transition: color 0.3s ease; }

/* ===== Device Grid ===== */
.device-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 16px;
}

.device-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  transition: transform 0.25s ease, box-shadow 0.25s ease, border-color 0.25s ease, opacity 0.3s ease;
  cursor: pointer;
  position: relative;
  opacity: 1;
  animation: cardIn 0.35s ease backwards;
}
.device-card:hover {
  transform: translateY(-3px);
  box-shadow: var(--shadow-lg);
  border-color: var(--accent);
}
@keyframes cardIn {
  from { opacity: 0; transform: translateY(16px); }
  to   { opacity: 1; transform: translateY(0); }
}
.device-card:nth-child(1)  { animation-delay: 0.00s; }
.device-card:nth-child(2)  { animation-delay: 0.02s; }
.device-card:nth-child(3)  { animation-delay: 0.04s; }
.device-card:nth-child(4)  { animation-delay: 0.06s; }
.device-card:nth-child(5)  { animation-delay: 0.08s; }
.device-card:nth-child(6)  { animation-delay: 0.10s; }
.device-card:nth-child(7)  { animation-delay: 0.12s; }
.device-card:nth-child(8)  { animation-delay: 0.14s; }
.device-card:nth-child(9)  { animation-delay: 0.16s; }
.device-card:nth-child(10) { animation-delay: 0.18s; }
.device-card:nth-child(11) { animation-delay: 0.20s; }
.device-card:nth-child(12) { animation-delay: 0.22s; }
.device-card:nth-child(n+13) { animation-delay: 0.24s; }

.card-image {
  height: 200px;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  overflow: hidden;
}
.card-image .device-img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  padding: 24px;
  transition: transform 0.3s ease;
}
.device-card:hover .device-img { transform: scale(1.05); }

.card-image .device-placeholder {
  width: 100%;
  height: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  font-size: 48px;
}
.card-image .device-placeholder .brand-name {
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 1px;
  text-transform: uppercase;
}

.card-type-badge {
  position: absolute;
  top: 10px;
  right: 10px;
  font-size: 11px;
  padding: 2px 8px;
  border-radius: 10px;
  background: rgba(0,0,0,0.6);
  backdrop-filter: blur(4px);
  color: #ccc;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.card-body {
  padding: 16px;
}
.card-brand {
  font-size: 11px;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 1px;
  margin-bottom: 2px;
}
.card-name {
  font-size: 17px;
  font-weight: 600;
  margin-bottom: 12px;
  line-height: 1.3;
}

.card-specs {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 13px;
}
.spec-row {
  display: flex;
  gap: 8px;
  color: var(--text-secondary);
}
.spec-row .spec-label {
  color: var(--text-muted);
  min-width: 40px;
  flex-shrink: 0;
}
.spec-row .spec-value {
  color: var(--text-primary);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.card-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 16px;
  border-top: 1px solid var(--border);
}
.card-price {
  font-size: 14px;
  font-weight: 700;
  color: var(--warning);
  display: flex;
  align-items: baseline;
  gap: 4px;
}
.card-price .price-unit {
  font-size: 13px;
  font-weight: 500;
  color: var(--text-secondary);
}
.compare-toggle {
  display: flex;
  align-items: center;
  gap: 4px;
  font-size: 12px;
  padding: 5px 10px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--bg-secondary);
  color: var(--text-secondary);
  cursor: pointer;
  transition: var(--transition);
  white-space: nowrap;
}
.compare-toggle:hover { border-color: var(--accent); color: var(--accent); }
.compare-toggle.active {
  background: rgba(88,166,255,0.15);
  border-color: var(--accent);
  color: var(--accent);
}

/* ===== Empty State ===== */
.empty-state {
  text-align: center;
  padding: 80px 20px;
  color: var(--text-secondary);
}
.empty-state p { margin-top: 16px; font-size: 15px; }
.empty-state span { font-size: 13px; color: var(--text-muted); }

/* ===== Compare Bar ===== */
.compare-bar {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  background: var(--bg-secondary);
  border-top: 2px solid var(--accent);
  z-index: 200;
  padding: 12px 24px;
  animation: slideUp 0.3s ease;
}
@keyframes slideUp {
  from { transform: translateY(100%); }
  to { transform: translateY(0); }
}
.compare-bar-inner {
  max-width: 1400px;
  margin: 0 auto;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
}
.compare-slots {
  display: flex;
  gap: 10px;
  flex: 1;
}
.compare-slot {
  width: 100px;
  height: 56px;
  border: 2px dashed var(--border);
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  color: var(--text-muted);
  position: relative;
  transition: var(--transition);
}
.compare-slot.filled {
  border-style: solid;
  border-color: var(--accent);
  background: var(--bg-card);
  cursor: default;
}
.compare-slot .slot-content {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 4px 8px;
  max-width: 100%;
}
.compare-slot .slot-name {
  font-size: 11px;
  font-weight: 600;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--text-primary);
}
.compare-slot .slot-remove {
  position: absolute;
  top: -6px;
  right: -6px;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: var(--danger);
  color: #fff;
  border: none;
  cursor: pointer;
  font-size: 11px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: var(--transition);
}
.compare-slot .slot-remove:hover { transform: scale(1.1); }
.compare-actions {
  display: flex;
  gap: 8px;
  align-items: center;
}
.btn-primary {
  padding: 8px 20px;
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: var(--radius-sm);
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: var(--transition);
}
.btn-primary:hover:not(:disabled) { background: var(--accent-hover); }
.btn-primary:disabled { opacity: 0.4; cursor: not-allowed; }

/* ===== Modal ===== */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.7);
  backdrop-filter: blur(4px);
  z-index: 300;
  display: none;
  align-items: center;
  justify-content: center;
}
.modal-overlay.open {
  display: flex;
  animation: fadeIn 0.2s ease;
}
@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}
.modal {
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  max-height: 90vh;
  overflow-y: auto;
  position: relative;
  box-shadow: var(--shadow-lg);
}
.modal-close {
  position: sticky;
  top: 12px;
  float: right;
  z-index: 10;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: rgba(0,0,0,0.5);
  border: 1px solid var(--border);
  color: var(--text-primary);
  font-size: 16px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: var(--transition);
  margin-right: 12px;
}
.modal-close:hover { background: var(--danger); border-color: var(--danger); }

/* Detail Modal */
.detail-modal {
  width: 680px;
  max-width: 95vw;
}
.detail-content { padding: 24px; }
.detail-header {
  display: flex;
  gap: 20px;
  margin-bottom: 24px;
  padding-bottom: 24px;
  border-bottom: 1px solid var(--border);
}
.detail-img {
  width: 140px;
  height: 180px;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  font-size: 64px;
}
.detail-meta h2 {
  font-size: 22px;
  margin-bottom: 4px;
}
.detail-meta .brand-tag {
  display: inline-block;
  font-size: 12px;
  padding: 2px 8px;
  border-radius: 10px;
  background: var(--bg-hover);
  margin-bottom: 8px;
}
.detail-meta .meta-row {
  font-size: 13px;
  color: var(--text-secondary);
  margin-bottom: 4px;
}
.detail-meta .detail-price {
  font-size: 20px;
  font-weight: 700;
  color: var(--warning);
  margin-top: 8px;
}

.detail-section {
  margin-bottom: 20px;
}
.detail-section h4 {
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--accent);
  margin-bottom: 8px;
}
.detail-section .spec-table {
  width: 100%;
  border-collapse: collapse;
}
.detail-section .spec-table td {
  padding: 6px 8px;
  font-size: 13px;
  border-bottom: 1px solid rgba(255,255,255,0.04);
}
.detail-section .spec-table td:first-child {
  color: var(--text-muted);
  width: 100px;
  white-space: nowrap;
}
.detail-section .spec-table td:last-child {
  color: var(--text-primary);
}
.config-list {
  display: flex;
  flex-direction: column;
  gap: 4px;
  margin-top: 4px;
}
.config-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 4px 0;
}
.config-chip {
  display: inline-block;
  padding: 4px 10px;
  font-size: 12px;
  font-weight: 600;
  border-radius: 6px;
  background: var(--bg-hover);
  border: 1px solid var(--border);
  color: var(--text-primary);
  min-width: 110px;
  text-align: center;
}
.config-price {
  font-size: 13px;
  font-weight: 600;
  color: var(--warning);
}

.detail-source {
  margin-top: 16px;
  font-size: 12px;
  color: var(--text-muted);
}
.detail-actions {
  margin-top: 20px;
  display: flex;
  gap: 8px;
}

/* Compare Modal */
.compare-modal {
  width: 95vw;
  max-width: 1200px;
}
.compare-modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 16px 24px;
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  background: var(--bg-secondary);
  z-index: 5;
}
.compare-modal-header h2 { font-size: 18px; }
.compare-table-wrapper {
  overflow-x: auto;
  padding: 16px 24px 24px;
}
.compare-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}
/* compare-table styles moved to index.html inline */

/* ===== Responsive ===== */
@media (max-width: 900px) {
  .main-container { flex-direction: column; }
  /* 侧边栏 — 可横向滚动品牌条 */
  .sidebar {
    width: 100%; height: auto; position: static;
    padding: 8px 12px; border-right: none;
    border-bottom: 1px solid var(--border);
    display: flex; gap: 8px; overflow-x: auto; align-items: center;
    -webkit-overflow-scrolling: touch;
  }
  .sidebar-header { display: none; }
  .brand-list { flex-direction: row; gap: 4px; flex-wrap: nowrap; }
  .brand-item { white-space: nowrap; padding: 5px 8px; font-size: 11px; border-radius: 16px; }
  .brand-item .brand-dot { width: 6px; height: 6px; }
  .brand-item .brand-count { display: none; }
  .sidebar-footer { display: none; }
  .content { padding: 10px 12px; }
  .device-grid { grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 10px; }
  /* 卡片紧凑 */
  .card-image { height: 150px; }
  .card-body { padding: 10px; }
  .card-name { font-size: 15px; margin-bottom: 8px; }
  .card-specs { font-size: 12px; gap: 4px; }
  .card-footer { padding: 8px 10px; }
  .card-price { font-size: 13px; }
  .compare-toggle { font-size: 11px; padding: 4px 8px; }
  /* 搜索框 */
  .search-box { max-width: 100%; }
  .header-inner { gap: 10px; }
  /* 详情弹窗 */
  .detail-modal { width: 100vw; max-width: 100vw; border-radius: 0; max-height: 100vh; }
  .detail-content { padding: 16px; }
  .detail-header { flex-direction: column; align-items: center; text-align: center; gap: 12px; }
  .detail-img { width: 100px; height: 130px; font-size: 48px; }
  .detail-meta h2 { font-size: 18px; }
  /* 对比弹窗 — 全屏 */
  .compare-modal { width: 100vw; max-width: 100vw; border-radius: 0; max-height: 100vh; }
  .compare-modal-header { padding: 10px 14px; }
  .compare-modal-header h2 { font-size: 16px; }
  .compare-table-wrapper { padding: 8px; }
  .compare-table th, .compare-table td { padding: 6px 8px; font-size: 11px; min-width: 120px; }
  .compare-table td.param-col { min-width: 70px; max-width: 70px; }
  /* 对比栏 */
  .compare-bar { padding: 8px 10px; }
  .compare-slots { gap: 4px; }
  .compare-slot { width: 70px; height: 40px; font-size: 10px; }
  .compare-slot .slot-name { font-size: 10px; }
  .btn-primary { padding: 6px 14px; font-size: 12px; }
}

@media (max-width: 560px) {
  .header { padding: 0 8px; }
  .header-inner { gap: 6px; height: 48px; }
  .logo { font-size: 15px; }
  .logo span { display: none; }
  .search-box input { height: 32px; font-size: 13px; padding: 0 32px; }
  .device-grid { grid-template-columns: 1fr; gap: 8px; }
  .card-image { height: 140px; }
  .card-body { padding: 8px; }
  .card-name { font-size: 14px; }
  .card-specs { font-size: 11px; }
  .status-bar { flex-direction: column; align-items: flex-start; gap: 4px; }
  /* 对比栏 — 更紧凑 */
  .compare-bar-inner { flex-direction: column; gap: 6px; }
  .compare-slots { justify-content: center; }
  .compare-slot { width: 60px; height: 36px; }
  .compare-actions { justify-content: center; width: 100%; }
  /* 详情弹窗 */
  .detail-content { padding: 10px; }
  .detail-section h4 { font-size: 11px; }
  .detail-section .spec-table td { font-size: 11px; padding: 4px 6px; }
  /* 对比表 */
  .compare-table th, .compare-table td { padding: 4px 6px; font-size: 10px; min-width: 100px; }
  .compare-table td.param-col { min-width: 55px; max-width: 55px; }
  /* 品牌条 */
  .brand-item { padding: 4px 6px; font-size: 10px; }
  /* 配置列表 */
  .config-row { flex-direction: column; align-items: flex-start; gap: 2px; }
  /* 类型筛选chip带过来 */
  .sidebar { padding: 6px 8px; gap: 4px; }
}

/* Scrollbar */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--text-muted); }
