/*==================== 重置与基础样式 ====================*/
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  font-family: Arial, sans-serif;
  line-height: 1.6;
  min-width: 610px;
  background-color: #f8f9fa;
  color: #333;
  display: flex;
  justify-content: center;
  align-items: center;
  min-height: 100vh;
  margin: 0;
  padding: 0px;
}

/*==================== 布局容器 ====================*/
.container {
  width: 95%;
  max-width: 1200px;
  min-width: 600px;
  margin: 0 auto;
  padding: 20px;
  display: flex;
  flex-direction: column;
  align-items: center;
}

.content-wrapper {
  background-color: white;
  border-radius: 12px;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.05);
  overflow: hidden;
  margin-bottom: 20px;
  width: 100%;
  max-width: 1000px;
  margin: 0 auto;
}

/*==================== 滚动条样式 ====================*/
::-webkit-scrollbar {
  width: 4px;
  height: 4px;
}

::-webkit-scrollbar-track {
  background: #f1f1f1;
  border-radius: 2px;
}

::-webkit-scrollbar-thumb {
  background: #888;
  border-radius: 2px;
}

::-webkit-scrollbar-thumb:hover {
  background: #555;
}

/* Firefox滚动条 */
html {
  scrollbar-width: thin;
  scrollbar-color: #888 #f1f1f1;
}

/*==================== 标题区域 ====================*/
header {
  text-align: center;
  margin-bottom: 0;
  background-color: white;
  padding: 15px;
  border-radius: 12px 12px 0 0;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
}

header h1 {
  font-size: 24px;
  margin-bottom: 5px;
  color: #1a1a1a;
}

header h1 small {
  font-size: 12px;
  font-weight: normal;
  opacity: 0.8;
}

header p {
  font-size: 12px;
  font-weight: normal;
  color: #666;
}

/*==================== 导航区域 ====================*/
.score-nav {
  display: flex;
  justify-content: flex-start;
  align-items: center;
  max-width: 605px;
  padding: 12px;
  padding-bottom: 0;
  position: relative;
  flex-wrap: nowrap;
  background: none;
  font-weight: bold;
}

/* 将 score-nav-item 改为 nav-btn */
.nav-btn {
  display: inline-block;
  padding: 4px 8px;
  margin: 0 6px;
  border-radius: 20px; /* 50%圆角效果 */
  background-color: #f5f5f5;
  color: #666;
  cursor: pointer;
  font-size: 14px;
  transition: all 0.3s ease;
  border: none;
  position: relative;
  /* 自动适应内容宽度 */
  min-width: fit-content;
}

.nav-btn:hover {
  background-color: #e9e9e9;
}

/* 选中状态 */
.nav-btn.active {
  background-color: #f0f8ff;
  color: #007bff;
}

/* 选中状态下的底部指示器 */
.nav-btn.active::after {
  content: "";
  position: absolute;
  bottom: -10px; /* 确保与chart-container上边框重合 */
  left: 0;
  width: 100%;
  height: 3px;
  background-color: #007bff;
  border-radius: 3px 3px 0 0;
}

/* 确保适当间距 */
.filter-container + .chart-container {
  margin-top: 0;
}

/*==================== 图表容器 ====================*/
#chart-container {
  width: 100%;
  max-width: 1000px;
  height: 450px;
  margin-left: 0;
  margin-right: auto;
  margin-top: 0;
  border: none;
  border-top: 1px solid #e0e0e0;
  border-bottom: 1px solid #ddd;
  border-radius: 0 0 10px 10px;
  background-color: white;
  box-shadow: none;
  overflow: hidden;
  margin-top: 10px; /* 与score-nav保持一定距离 */
  position: relative;
  z-index: 1; /* 确保在指示器之下 */
}

/*==================== 筛选区域 ====================*/
/* 全局变量 */
:root {
  --active-color: #4caf50;
  --hover-color: #e8e8e8;
  --bg-color: #f8f8f8;
  --border-color: #ddd;
}

/* 筛选区域布局 */
.filter-container {
  width: 100%;
  margin-top: 0;
  padding: 12px;
  border-radius: 8px;
  background-color: var(--bg-color);
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
  font-weight: bold;
}

/* 筛选行 */
.filter-row {
  display: flex;
  align-items: center;
  margin-bottom: 10px;
  flex-wrap: wrap;
}

/* 年份筛选行 */
.year-filter-row {
  border-bottom: 1px solid #e0e0e0;
  padding-bottom: 10px;
  font-size: 12px;
}

/* 品牌筛选行 */
.brand-filter-row {
  padding: 6px 0;
  border-bottom: 1px solid #f0f0f0;
}

.brand-filter-row:last-child {
  border-bottom: none;
}

/* 筛选组 */
.filter-group {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
}

/* 分隔线 */
.separator {
  height: 28px;
  border-left: 1px dashed #ccc;
  margin: 0 12px;
}

/* 全选/全不选按钮容器 */
.select-all-group {
  position: relative;
  display: flex;
  border-radius: 14px;
  overflow: hidden;
  box-sizing: border-box;
  border: 1px solid #ddd;
}

/* 进度条背景 - 实现选中比例显示 */
.select-all-group::before {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  height: 100%;
  width: var(--select-ratio, 0%); /* 默认0%, 通过JS动态设置 */
  background-color: #007bff;
  transition: width 0.3s ease;
  z-index: 0; /* 确保在边框下方 */
  clip-path: inset(0); /* 确保在容器内部，避免溢出导致毛刺 */
  pointer-events: none; /* 确保点击事件穿透到按钮 */
}

/* 全选按钮样式 */
.select-all-btn {
  flex: auto;
  padding: 4px 2px 4px 10px;
  background-color: transparent;
  border: none;
  cursor: pointer;
  position: relative;
  color: #333;
  font-size: 12px; /* 调整为12px */
  transition: color 0.2s ease;
  z-index: 1; /* 确保按钮在进度条上方 */
}

/* 全不选按钮样式 */
.deselect-all-btn {
  flex: auto;
  padding: 4px 10px 4px 2px;
  background-color: transparent;
  border: none;
  cursor: pointer;
  position: relative;
  color: #333;
  font-size: 12px; /* 调整为12px */
  transition: color 0.2s ease;
  z-index: 1; /* 确保按钮在进度条上方 */
}

/* 当选中比例超过35%时，左侧按钮文字变白 */
.select-all-group[data-ratio-over-half="true"] .select-all-btn {
  color: white;
}

/* 当选中比例为87%时，两侧按钮文字都变白 */
.select-all-group[data-ratio-full="true"] .deselect-all-btn {
  color: white;
}

.select-all-btn:hover,
.deselect-all-btn:hover {
  background-color: #005bdf;
  color: white;
}

/* 年份按钮样式 */
.year-btn {
  padding: 4px 10px;
  border-radius: 14px;
  border: 1px solid var(--border-color);
  background-color: #f0f0f0;
  margin: 3px;
  cursor: pointer;
  transition: all 0.3s ease;
  font-size: 12px;
}

/* 品牌按钮样式 */
.brand-btn {
  min-width: 80px;
  padding: 6px 12px;
  border-radius: 15px;
  border: 1px solid var(--border-color);
  background-color: #f0f0f0;
  cursor: pointer;
  transition: all 0.3s ease;
  margin-right: 15px;
  font-size: 14px;
}

/* SOC按钮容器 */
.soc-buttons-container {
  display: flex;
  flex-wrap: wrap;
  flex: 1;
  gap: 6px;
}

/* SOC按钮样式 */
.soc-btn {
  padding: 4px 8px;
  border-radius: 12px;
  border: 1px solid var(--border-color);
  background-color: #f8f8f8;
  cursor: pointer;
  transition: all 0.3s ease;
  font-size: 12px;
}

/* 按钮悬停效果 */
.year-btn:hover,
.brand-btn:hover,
.soc-btn:hover {
  background-color: var(--hover-color);
}

/* 选中状态 - 高通 */
.brand-btn[data-brand="高通"].active,
.soc-buttons-container[data-brand="高通"] .soc-btn.active {
  background-color: #2929e6;
  color: white;
  border-color: #2929e6;
}

/* 选中状态 - 联发科 */
.brand-btn[data-brand="联发科"].active,
.soc-buttons-container[data-brand="联发科"] .soc-btn.active {
  background-color: #f39a1e;
  color: white;
  border-color: #f39a1e;
}

/* 选中状态 - 华为海思 */
.brand-btn[data-brand="华为海思"].active,
.soc-buttons-container[data-brand="华为海思"] .soc-btn.active {
  background-color: #e20004;
  color: white;
  border-color: #e20004;
}

/* 选中状态 - 苹果 */
.brand-btn[data-brand="苹果"].active,
.soc-buttons-container[data-brand="苹果"] .soc-btn.active {
  background-color: #323232;
  color: white;
  border-color: #323232;
}

/* 选中状态 - 其他 */
.brand-btn[data-brand="其他"].active,
.soc-buttons-container[data-brand="其他"] .soc-btn.active {
  background-color: #9c27b0;
  color: white;
  border-color: #9c27b0;
}

/* 年份按钮和全选按钮选中状态 */
.year-btn.active,
.select-all-btn.active,
.deselect-all-btn.active {
  background-color: var(--active-color);
  color: white;
  border-color: var(--active-color);
}

/* 当全选按钮激活时，保持分隔线可见 */
.select-all-btn.active {
  border-right-color: var(--border-color);
}

/* 当全不选按钮激活时，也保持分隔线可见 */
.deselect-all-btn.active {
  border-left: 1px solid var(--border-color);
}

/* 部分选中状态 */
.brand-btn.partial,
.year-btn.partial,
.select-all-btn.partial,
.deselect-all-btn.partial {
  position: relative;
  overflow: hidden;
  color: #888;
}

/* 响应式设计 */
@media (max-width: 600px) {
  .soc-buttons-container {
    width: 100%;
    margin-top: 5px;
    padding-left: 10px;
  }
}
