/* ===== 任务/会话行上下文菜单 + 相对时间（N1，INTERACT-SPEC §2.8） =====
 * 加载顺序：styles.css → menus.css → states.css → 本文件
 * 所有选择器只命中 context-menu.js 首次交互后惰性创建的节点（.cm-*）或
 * 编码模式（seg:changed 后）才存在的 .sb-code-session —— 初始视图像素基线零命中。
 * 菜单容器复用 A7 .am-menu 体系（SPEC §2.4-4 规格），此处只做上下文菜单专属覆盖。
 */

/* --- 定位上下文（position:relative 无偏移，不改布局） --- */
.task-row { position: relative; }
.sb-code-session { position: relative; }

/* --- 本模块接管后隐藏 sidebar.js 遗留的三点按钮，避免同一行两枚「…」 --- */
html[data-am-context-menu] .task-row > .am-task-more { display: none; }

/* --- hover 浮现「…」按钮：right 4 / 垂直居中 / 20×20 圆形 --- */
.cm-more {
  position: absolute; top: 50%; right: 4px; z-index: 1;
  transform: translateY(-50%);
  display: inline-flex; align-items: center; justify-content: center;
  width: 20px; height: 20px; padding: 2px; margin: 0;
  border: 0; border-radius: 999px;
  background: transparent; color: var(--text-2);
  cursor: default; line-height: 0;
  opacity: 0; pointer-events: none;
  transition: opacity .12s ease, background-color .12s ease;
}
.cm-hover > .cm-more,
.cm-open > .cm-more,
.task-row:hover > .cm-more,
.sb-code-session:hover > .cm-more,
.task-row:focus-within > .cm-more,
.sb-code-session:focus-within > .cm-more { opacity: 1; pointer-events: auto; }
.cm-more:hover { background: rgba(0,0,0,.06); color: var(--text); }
.cm-more:active, .cm-more[aria-expanded="true"] { background: rgba(0,0,0,.1); color: var(--text); }
.cm-more:focus-visible { outline: 2px solid rgba(0,0,0,.25); outline-offset: 1px; }
.cm-more svg { width: 16px; height: 16px; display: block; }
.cm-more circle { fill: currentColor; stroke: none; }

/* hover/菜单打开时，行文字给按钮让位（任务行 padding-right 由 8 → 28，仅在悬停态） */
.task-row.cm-hover, .task-row.cm-open { padding-right: 28px; }
/* 会话行：右侧相对时间被「…」覆盖时隐藏（保持行高不变） */
.sb-code-session.cm-hover .sb-code-session-time,
.sb-code-session.cm-open .sb-code-session-time { visibility: hidden; }

/* --- 菜单容器（§1.4 antd sidebar-action-menu 皮肤【实证 · dtcoder-glass-react.css】）：
 *    bg #fcfcfc（--color-gray-1）/ 圆角 12px（--radius-12）/ padding 8px /
 *    边框 rgba(20,22,28,.1)（--model-selector-border）/ 阴影 0 2px 6px -1px #14161c1f /
 *    width:max-content、min-width:0 —— 覆盖 .am-menu 通用项（§2.4-4） */
.cm-menu {
  position: absolute;
  width: max-content; min-width: 0;
  padding: 8px;
  background: #fcfcfc;
  border: 1px solid rgba(20, 22, 28, .1);
  border-radius: 12px;
  box-shadow: 0 2px 6px -1px #14161c1f;
  z-index: 1000;
  transform-origin: top right;
  user-select: none;
}
/* 项：高 32px / radius 4px / padding 6px 8px / 14px medium（§1.4 .ant-dropdown-menu-item） */
.cm-menu .am-menu-item {
  height: 32px; padding: 6px 8px; gap: 8px;
  border-radius: 4px; font-size: var(--type-body-size); font-weight: 500; color: var(--text);
 line-height: var(--type-body-line); }
/* 图标 14px（§1.2 lucide size=14 / §1.3 h-3.5 w-3.5 实证；stroke-width 1.75 §1.4） */
.cm-menu .am-menu-item svg {
  width: 14px; height: 14px; flex: none;
  stroke: currentColor; stroke-width: 1.75; fill: none;
  stroke-linecap: round; stroke-linejoin: round;
  color: var(--text-2);
}
.cm-menu .am-menu-item:hover,
.cm-menu .am-menu-item.kbd-focus { background: #0000000d; }
.cm-menu .am-menu-item:hover svg,
.cm-menu .am-menu-item.kbd-focus svg { color: var(--text); }
.cm-menu .am-menu-item-label { white-space: nowrap; }
.cm-menu .am-menu-sep { height: 1px; background: var(--border); margin: 4px 6px; }

/* 危险项（§1.4 --destructive → #c00900cf；hover 为 destructive 10% 底的 rgba 近似） */
.cm-menu .am-menu-item.danger,
.cm-menu .am-menu-item.danger svg { color: #c00900cf; }
.cm-menu .am-menu-item.danger:hover,
.cm-menu .am-menu-item.danger.kbd-focus { background: rgba(192, 9, 0, .1); color: #c00900cf; }
.cm-menu .am-menu-item.danger:hover svg,
.cm-menu .am-menu-item.danger.kbd-focus svg { color: #c00900cf; }

/* --- toast（菜单项反馈） --- */
.cm-toast {
  position: fixed; top: 18px; left: 50%; transform: translateX(-50%);
  z-index: 9999;
  max-width: min(420px, calc(100vw - 32px));
  padding: 7px 14px;
  background: #1e1e1e; color: #fff;
  font-size: var(--type-body-size);  border-radius: 8px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  box-shadow: 0 4px 16px rgba(0,0,0,.2);
  pointer-events: none;
  animation: cm-toast-in .18s ease-out;
 line-height: var(--type-body-line); }
.cm-toast.danger { background: #c00900; }
@keyframes cm-toast-in {
  from { opacity: 0; transform: translateX(-50%) translateY(-6px); }
  to   { opacity: 1; transform: translateX(-50%) translateY(0); }
}

/* --- 相对时间 + 状态绿点（供会话行调用方使用；reltime.apply 写入 data-ts/title） --- */
.cm-reltime, [data-ts] { font-variant-numeric: tabular-nums; }
.cm-status-dot {
  display: inline-block; width: 8px; height: 8px; flex: none;
  border-radius: 50%; background: #28c840; margin-right: 6px;
}
.cm-status-dot.idle { background: #ccc; }

@media (prefers-reduced-motion: reduce) {
  .cm-more { transition: none; }
  .cm-toast { animation: none; }
}
