/* ===== SessionItem 组件样式 ===== */

/* 卡片容器 */
.wk-session-card {
  display: flex;
  flex-direction: column;
  border: 1px solid rgba(0, 0, 0, 0.08);
  border-radius: 12px;
  background: #fff;
  overflow: hidden;
  transition: all 0.15s ease;
}

.wk-session-card:hover {
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.04);
  border-color: rgba(113, 113, 238, 0.3);
}

/* AC-6: 状态视觉标记（running=绿 / done=灰 / failed|killed|timeout=红） */
.wk-session-card.wk-session-card--running {
  border-left: 4px solid #22c55e;
  box-shadow: 0 2px 12px rgba(34, 197, 94, 0.12);
  background: linear-gradient(90deg, rgba(34, 197, 94, 0.03), #fff 40%);
}

.wk-session-card.wk-session-card--running .wk-session-head {
  background: rgba(34, 197, 94, 0.05);
}

.wk-session-card.wk-session-card--done {
  border-left: 4px solid #9ca3af;
}

.wk-session-card.wk-session-card--done .wk-session-head {
  background: #f9fafb;
}

.wk-session-card.wk-session-card--failed {
  border-left: 4px solid #ef4444;
  box-shadow: 0 2px 12px rgba(239, 68, 68, 0.12);
  background: linear-gradient(90deg, rgba(239, 68, 68, 0.02), #fff 40%);
}

.wk-session-card.wk-session-card--failed .wk-session-head {
  background: rgba(239, 68, 68, 0.04);
}

/* 头部 */
.wk-session-head {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 16px;
  background: #fafafa;
  border-bottom: 1px solid rgba(0, 0, 0, 0.04);
  cursor: pointer;
  transition: background 0.15s ease;
}

.wk-session-head:hover {
  background: #f5f5f5;
}

.wk-session-card.wk-session-card--running .wk-session-head:hover {
  background: rgba(34, 197, 94, 0.08);
}

.wk-session-card.wk-session-card--failed .wk-session-head:hover {
  background: rgba(239, 68, 68, 0.06);
}

/* 状态徽章 */
.wk-status-badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 10px;
  font-weight: 700;
  padding: 3px 10px;
  border-radius: 100px;
  color: #fff;
  letter-spacing: 0.5px;
}

.wk-status-badge::before {
  content: "";
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #fff;
}

/* RUNNING 状态（绿） */
.wk-status-badge--running {
  background: #22c55e;
  animation: runningPulse 1.6s ease-in-out infinite;
}

.wk-status-badge--running::before {
  animation: runningDot 1.2s ease-in-out infinite;
}

/* DONE 状态（灰） */
.wk-status-badge--done {
  background: #9ca3af;
}

/* FAILED / KILLED / TIMEOUT 状态（红） */
.wk-status-badge--failed {
  background: #ef4444;
  animation: failedPulse 2s ease-in-out infinite;
}

@keyframes runningPulse {
  0%,
  100% {
    box-shadow: 0 0 0 0 rgba(34, 197, 94, 0.6);
  }
  50% {
    box-shadow: 0 0 0 6px rgba(34, 197, 94, 0);
  }
}

@keyframes runningDot {
  0%,
  100% {
    opacity: 1;
    transform: scale(1);
  }
  50% {
    opacity: 0.5;
    transform: scale(0.7);
  }
}

@keyframes failedPulse {
  0%,
  100% {
    box-shadow: 0 0 0 0 rgba(239, 68, 68, 0.4);
  }
  50% {
    box-shadow: 0 0 0 4px rgba(239, 68, 68, 0);
  }
}

/* 渠道标签 */
.wk-channel-chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 11px;
  font-weight: 500;
  padding: 2px 8px;
  border-radius: 4px;
  background: rgba(113, 113, 238, 0.1);
  color: #7171ee;
}

.wk-channel-chip.wk-channel-octo {
  background: rgba(113, 113, 238, 0.12);
  color: #7171ee;
}

.wk-channel-chip.wk-channel-discord {
  background: rgba(88, 101, 242, 0.12);
  color: #5865f2;
}

.wk-channel-chip.wk-channel-飞书,
.wk-channel-chip.wk-channel-feishu {
  background: rgba(0, 136, 136, 0.12);
  color: #008888;
}

.wk-channel-chip.wk-channel-slack {
  background: rgba(74, 21, 75, 0.12);
  color: #4a154b;
}

.wk-channel-chip.wk-channel-web,
.wk-channel-chip.wk-channel-web-ui {
  background: rgba(0, 0, 0, 0.06);
  color: rgba(0, 0, 0, 0.45);
}

.wk-channel-chip.wk-channel-localhost {
  background: rgba(59, 130, 246, 0.12);
  color: #2563eb;
}

/* Session Key（在 body 中显示） */
.wk-session-key {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 12px;
  color: rgba(0, 0, 0, 0.75);
  font-weight: 600;
}

/* 对话方（在 head 中显示） */
.wk-session-party {
  font-size: 12.5px;
  color: rgba(0, 0, 0, 0.75);
  max-width: 420px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.wk-session-party-id {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 11px;
  background: rgba(0, 0, 0, 0.04);
  padding: 1px 5px;
  border-radius: 3px;
  color: rgba(0, 0, 0, 0.45);
  margin-left: 2px;
}

/* AC-7: 展开/收起箭头 */
.wk-session-chevron {
  margin-left: auto;
  color: rgba(0, 0, 0, 0.35);
  transition: transform 0.2s ease;
}

.wk-session-card.collapsed .wk-session-chevron {
  transform: rotate(-90deg);
}

/* 主体 */
.wk-session-body {
  padding: 12px 16px;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px 16px;
}

/* 字段 */
.wk-session-field {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

/* 上下文窗口占满 3 列 */
.wk-session-field--full {
  grid-column: span 3;
}

.wk-session-field__label {
  font-size: 10px;
  letter-spacing: 0.3px;
  color: rgba(0, 0, 0, 0.35);
  font-weight: 500;
}

.wk-session-field__value {
  font-size: 12.5px;
  line-height: 1.5;
  color: rgba(0, 0, 0, 0.75);
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  word-break: break-all;
}

.wk-session-field__value--normal {
  font-family: "Inter", "Noto Sans SC", ui-sans-serif, -apple-system,
    sans-serif;
}

/* AC-8: 上下文进度条 */
.wk-context-bar {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 6px;
}

.wk-context-bar__track {
  flex: 1;
  height: 6px;
  background: #e5e7eb;
  border-radius: 3px;
  overflow: hidden;
}

.wk-context-bar__fill {
  height: 100%;
  background: linear-gradient(90deg, #22c55e, #7171ee);
  border-radius: 3px;
  transition: width 0.3s ease;
}

/* > 70% 警告色 */
.wk-context-bar__fill.warn {
  background: linear-gradient(90deg, #f59e0b, #ef4444);
}

.wk-context-bar__text {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 11px;
  color: rgba(0, 0, 0, 0.45);
  white-space: nowrap;
}

/* 最近消息 */
.wk-session-msg {
  padding: 8px 16px 10px;
  font-size: 12px;
  color: rgba(0, 0, 0, 0.45);
  border-top: 1px dashed rgba(0, 0, 0, 0.06);
}

.wk-session-msg__label {
  font-weight: 600;
  color: rgba(0, 0, 0, 0.45);
  margin-right: 6px;
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.wk-session-msg__content {
  color: rgba(0, 0, 0, 0.75);
  line-height: 1.6;
}
