/* 侧边栏。从 A2_styles.css 拆出来, 页面按顺序加载。 */

/* ---------------- 侧边栏 ---------------- */

#sidebar {
  width: 262px;
  flex: 0 0 262px;
  display: flex;
  flex-direction: column;
  padding: 14px 12px 0;
  color: var(--side-ink);
  background: linear-gradient(180deg, #262a5c 0%, #2a2557 100%);
  border-right: 1px solid rgba(0, 0, 0, 0.3);
  overflow-y: auto;
  overflow-x: hidden;
  scrollbar-width: thin;
  transition: margin-left 0.2s;
}
#sidebar.collapsed { margin-left: -262px; }

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  text-decoration: none;
  color: inherit;
}
.brand:hover .brand-name { color: var(--accent); }

.brand-mark {
  display: flex;
  align-items: flex-end;
  gap: 3px;
  height: 22px;
}
.brand-mark .bar { width: 4.5px; border-radius: 2px 2px 1px 1px; }
.brand-mark .b1 { height: 10px; background: var(--accent); }
.brand-mark .b2 { height: 19px; background: var(--accent-2); }
.brand-mark .b3 { height: 14px; background: var(--warm); }

.brand-name {
  font-size: 15.5px;
  font-weight: 650;
  letter-spacing: -0.015em;
  transition: color 0.14s;
}
.brand-sub { font-size: 11.5px; font-weight: 400; color: var(--text-muted); margin-left: 8px; }

/** 三块(数据集 / 收藏 / 分析历史)之间画条线, 否则挤在一起分不出边界 */
.panel { display: flex; flex-direction: column; min-height: 0; padding-bottom: 12px; }
.panel + .panel { padding-top: 10px; }
/**
 侧栏现在有五块(数据 / 收藏 / 看板 / 规矩 / 历史)。原来整条 overflow:hidden,
 上面几块一多, 最下面的历史就被压成一条缝 —— 用户看到标题却看不到里面有什么,
 以为历史点不开。所以: 侧栏自己能滚, 历史那块给个最小高度, 上面几块各自封顶。
 */
.panel.grow { flex: 1 1 auto; min-height: 168px; }
#history-list { min-height: 120px; }

/**
 标题是一条通到侧栏两边的浅色带子, 左边一道亮竖条。之前试过压深一点(黑色 26%),
 在这块深蓝上根本看不出来 —— 要一眼分出标题和条目, 得跟底色差开一整级, 而不是深一点点。
 */
.panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 6px 10px 6px 9px;
  margin: 0 -12px 8px;
  background: #454a94;
  border-left: 3px solid #8fbcff;
  font-size: 11.5px;
  font-weight: 700;
  color: #fff;
  letter-spacing: 0.04em;
}

/**
 每块的标题就是开关。整行都能点(不只是那个小三角), 侧栏窄, 点得准比好看重要。
 收起来时标题右边留一个数字, 否则看不出里面还有没有东西。
 */
.panel-toggle {
  flex: 1 1 auto;
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 6px;
  font: inherit;
  color: inherit;
  letter-spacing: inherit;
  text-align: left;
  background: none;
  border: 0;
  padding: 3px 4px;
  border-radius: 6px;
  cursor: pointer;
  transition: background 0.14s, color 0.14s;
}
.panel-toggle:hover { background: rgba(255, 255, 255, 0.16); color: #fff; }

.caret {
  flex: 0 0 auto;
  width: 0;
  height: 0;
  border-left: 4.5px solid currentColor;
  border-top: 3.5px solid transparent;
  border-bottom: 3.5px solid transparent;
  opacity: 0.75;
  transform: rotate(90deg);
  transition: transform 0.15s;
}
.panel.folded .caret { transform: rotate(0deg); }

.panel-count {
  margin-left: auto;
  font-size: 10.5px;
  font-weight: 600;
  letter-spacing: 0;
  color: #d7def5;
  background: rgba(0, 0, 0, 0.28);
  border-radius: 8px;
  padding: 1px 6px;
}

.panel-body { display: flex; flex-direction: column; min-height: 0; }
.panel.folded .panel-body { display: none; }
.panel.folded { padding-bottom: 6px; }
.panel.folded .panel-head { margin-bottom: 0; }
/** 收起来的历史不该再占着剩下的空间, 不然上面几块被挤成一条缝 */
.panel.folded.grow { flex: 0 0 auto; min-height: 0; }

.btn-ghost {
  font: inherit;
  font-size: 11.5px;
  font-weight: 550;
  color: #8fbcff;
  background: none;
  border: 0;
  padding: 3px 8px;
  border-radius: 6px;
  cursor: pointer;
  transition: background 0.14s, color 0.14s;
}
.btn-ghost:hover { background: var(--side-wash); color: #fff; }

.list { overflow-y: auto; display: flex; flex-direction: column; gap: 3px; min-height: 0; }

.item {
  display: flex;
  gap: 9px;
  padding: 8px 9px;
  border-radius: var(--r-sm);
  cursor: pointer;
  border: 1px solid transparent;
  transition: background 0.14s, border-color 0.14s;
}
.item:hover { background: var(--side-wash); border-color: var(--side-faint); }
.item.on { background: rgba(87, 165, 255, 0.18); border-color: transparent; }

.item-icon {
  flex: 0 0 26px;
  height: 26px;
  border-radius: 7px;
  background: rgba(87, 165, 255, 0.20);
  color: #9cc6ff;
  display: grid;
  place-items: center;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: -0.02em;
  margin-top: 1px;
}
.item-icon.fav { background: rgba(245, 196, 81, 0.18); color: #f5c451; }
.item-icon.hist { background: rgba(144, 133, 233, 0.20); color: #b9b1f5; }
.item-icon.rule { background: rgba(27, 175, 122, 0.20); color: #6fd7ae; }

/** 收藏和历史都在左边, 收藏别把历史挤没了 */
.list.short { max-height: 22vh; }

.item-main { min-width: 0; flex: 1; }
.item-title {
  font-size: 13px;
  font-weight: 500;
  color: var(--side-ink);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.item-sub {
  font-size: 11px;
  color: var(--side-dim);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.item-actions { display: flex; gap: 10px; margin-top: 4px; }
.item-actions a {
  font-size: 11px;
  color: var(--side-dim);
  text-decoration: none;
  cursor: pointer;
  transition: color 0.14s;
}
.item-actions a:hover { color: #8fbcff; }
/** 删除是不可逆的, 悬上去变红一下, 别跟「看数据」长得一模一样 */
.item-actions a.danger:hover { color: #ff8b7d; }

/**
  规矩太多拼不进 prompt 的那几条。标灰但不隐藏 —— 用户得看见它还在、只是这一轮没生效,
  才知道要去关掉别的。整条压暗, 状态字变琥珀色。
*/
.rule-dropped { opacity: 0.55; }
.rule-dropped .item-sub { color: #f0b45e; }
.rules-over {
  font-size: 11.5px;
  color: #f0b45e;
  line-height: 1.5;
  padding: 7px 8px;
  margin-bottom: 6px;
  border-left: 2px solid #f0b45e;
  background: rgba(240, 180, 94, 0.08);
  border-radius: 0 var(--r-sm) var(--r-sm) 0;
}

.hint { font-size: 11.5px; color: var(--side-dim); padding: 7px 8px; }
.empty {
  font-size: 12px;
  color: var(--side-dim);
  padding: 14px 10px;
  border: 1px dashed var(--side-faint);
  border-radius: var(--r-sm);
  text-align: center;
  line-height: 1.5;
}

.side-foot {
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 10px 10px 12px;
  margin-top: auto;
  border-top: 1px solid var(--side-faint);
  font-size: 11px;
  color: var(--side-dim);
}
.dot-live {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--good);
  box-shadow: 0 0 0 3px rgba(12, 163, 12, 0.15);
}
/* 滚动条跟侧栏同色, 只在内容真放不下时出现(测试表第 6 条: 白色滚动条压在深色侧栏上) */
#sidebar, #sidebar .list { scrollbar-color: rgba(255, 255, 255, 0.22) transparent; }
#sidebar::-webkit-scrollbar, #sidebar .list::-webkit-scrollbar { width: 6px; background: transparent; }
#sidebar::-webkit-scrollbar-thumb, #sidebar .list::-webkit-scrollbar-thumb { background: rgba(255, 255, 255, 0.22); border-radius: 3px; }
