/* ========================================
   Pipeline Editor CSS — 파이프라인 편집기 스타일
   기존 style.css의 card, btn, brand-input 재사용
   ======================================== */

/* ─── 편집기 이름 카드 ─── */
.editor-name-card {
  margin-bottom: 16px;
}

.editor-name-row {
  display: flex;
  align-items: center;
  gap: 12px;
}

.editor-name-label {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--text-muted);
  white-space: nowrap;
}

.editor-name-input {
  flex: 1;
  font-weight: 600;
  font-size: 12px;
  padding: 4px;
}

/* ─── 스텝 목록 컨테이너 ─── */
.step-list {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 0;
}

.step-empty {
  text-align: center;
  padding: 48px 24px;
  color: var(--text-dim);
  font-family: var(--font-mono);
  font-size: 12px;
  background: var(--surface);
  border: 1px dashed var(--border);
  border-radius: var(--radius-lg);
}

/* ─── 스텝 카드 ─── */
.step-item {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 16px 18px;
  transition: opacity var(--transition-fast), border-color var(--transition-fast), box-shadow var(--transition-fast);
  cursor: default;
  user-select: none;
}

.step-item:hover {
  border-color: var(--accent-pipe);
  box-shadow: 0 0 0 2px rgba(225, 29, 72, 0.06);
}

/* 드래그 중 상태 */
.step-item.dragging {
  opacity: 0.45;
  border-style: dashed;
}

/* 드롭 대상 강조 */
.step-item.drag-over {
  border-color: var(--accent-pipe);
  border-style: dashed;
  background: rgba(225, 29, 72, 0.04);
  box-shadow: 0 0 0 3px rgba(225, 29, 72, 0.12);
}

/* ─── 스텝 헤더 행 ─── */
.step-header {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 12px;
}

/* 드래그 핸들 */
.drag-handle {
  font-size: 16px;
  color: var(--text-dim);
  cursor: grab;
  padding: 0 4px;
  border-radius: var(--radius-sm);
  transition: color var(--transition-fast);
  flex-shrink: 0;
}

.drag-handle:active {
  cursor: grabbing;
}

.drag-handle:hover {
  color: var(--text-muted);
}

/* 스텝 번호 */
.step-number {
  font-family: var(--font-mono);
  font-size: 10px;
  font-weight: 700;
  color: var(--text-muted);
  letter-spacing: 0.08em;
  flex-shrink: 0;
  min-width: 52px;
}

/* ─── 스텝 내 셀렉터 ─── */
.step-select {
  font-family: var(--font-sans);
  font-size: 12px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  padding: 5px 8px;
  cursor: pointer;
  transition: border-color var(--transition-fast);
  appearance: auto;
}

.step-select:hover,
.step-select:focus {
  border-color: var(--accent-pipe);
  outline: none;
}

.step-agent-select {
  font-weight: 600;
  flex: 1;
  min-width: 120px;
}

.step-model-select {
  min-width: 140px;
}

.step-rank-select {
  min-width: 90px;
}

/* 에이전트 이름 고정 표시 */
.step-agent-name {
  display: flex;
  align-items: center;
  gap: 5px;
  font-weight: 700;
  font-size: 13px;
  font-family: var(--font-mono);
  color: var(--text);
}

.step-agent-icon {
  font-size: 16px;
}

/* 에이전시 출처 뱃지 */
.step-agency-badge {
  font-family: var(--font-mono);
  font-size: 10px;
  color: var(--text-dim);
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 2px 7px;
  white-space: nowrap;
}

/* 삭제 버튼 */
.step-remove-btn {
  margin-left: auto;
  background: transparent;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-dim);
  font-size: 11px;
  font-family: var(--font-mono);
  padding: 4px 10px;
  cursor: pointer;
  transition: color var(--transition-fast), border-color var(--transition-fast), background var(--transition-fast);
  flex-shrink: 0;
  white-space: nowrap;
}

.step-remove-btn:hover {
  color: #e11d48;
  border-color: #e11d48;
  background: rgba(225, 29, 72, 0.06);
}

/* ─── 스텝 바디 (출력키 + 컨텍스트) ─── */
.step-body {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding-left: 28px; /* 핸들 너비만큼 들여쓰기 */
}

.step-field {
  display: flex;
  align-items: flex-start;
  gap: 10px;
}

.step-field-label {
  font-family: var(--font-mono);
  font-size: 10px;
  color: var(--text-dim);
  min-width: 52px;
  padding-top: 6px;
  flex-shrink: 0;
}

/* 출력 키 인풋 */
.step-output-input {
  width: 220px;
  font-family: var(--font-mono);
  font-size: 12px;
  padding: 5px 10px;
}

/* ─── 컨텍스트 체크박스 영역 ─── */
.context-checkboxes {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  padding-top: 2px;
}

.ctx-checkbox-label {
  display: flex;
  align-items: center;
  gap: 5px;
  cursor: pointer;
  font-size: 12px;
}

.ctx-checkbox-label code {
  font-family: var(--font-mono);
  font-size: 11px;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 1px 6px;
  color: var(--text-muted);
}

.ctx-checkbox {
  accent-color: var(--accent-pipe);
  width: 14px;
  height: 14px;
  cursor: pointer;
}

.ctx-empty {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--text-dim);
  font-style: italic;
}

/* ─── 스텝 간 화살표 ─── */
.step-connector-arrow {
  text-align: center;
  font-size: 18px;
  color: var(--border);
  line-height: 1;
  padding: 6px 0;
  pointer-events: none;
}

/* ─── 에이전트 추가 행 ─── */
.add-step-row {
  display: flex;
  justify-content: center;
  margin-top: 16px;
  margin-bottom: 32px;
}

.add-step-btn {
  min-width: 180px;
  width: 100%;
  border-style: dashed;
  justify-content: center;
}

/* ─── 에이전트 풀 모달 ─── */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.45);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 200;
  padding: 20px;
}

.modal-box {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  width: 100%;
  max-width: 480px;
  max-height: 70vh;
  display: flex;
  flex-direction: column;
  box-shadow: 0 16px 48px rgba(0, 0, 0, 0.18);
  overflow: hidden;
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.modal-title {
  font-weight: 700;
  font-size: 14px;
  color: var(--text);
}

.modal-close-btn {
  background: transparent;
  border: none;
  font-size: 20px;
  color: var(--text-dim);
  cursor: pointer;
  padding: 0 4px;
  line-height: 1;
}

.modal-close-btn:hover {
  color: var(--text);
}

.agent-pool-list {
  overflow-y: auto;
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.agent-pool-item {
  display: flex;
  align-items: center;
  gap: 14px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 12px 16px;
  cursor: pointer;
  text-align: left;
  transition: border-color var(--transition-fast), background var(--transition-fast);
  width: 100%;
  margin-bottom: 10px;
}

.agent-pool-item:last-child {
  margin-bottom: 0;
}

.agent-pool-item:hover {
  border-color: var(--accent-pipe);
  background: rgba(225, 29, 72, 0.04);
}

.agent-pool-icon {
  font-size: 22px;
  flex-shrink: 0;
}

.agent-pool-info {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.agent-pool-name {
  font-weight: 700;
  font-size: 13px;
  color: var(--text);
  font-family: var(--font-mono);
}

.agent-pool-desc {
  font-size: 11px;
  color: var(--text-dim);
}

/* 에이전시별 그룹 헤더 */
.agent-pool-group {
  margin-bottom: 4px;
}

.agent-pool-group-label {
  font-family: var(--font-mono);
  font-size: 10px;
  font-weight: 700;
  color: var(--text-dim);
  letter-spacing: 0.06em;
  text-transform: uppercase;
  padding: 8px 4px 4px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 4px;
}

/* ─── 커스텀 에이전트 활성 뱃지 (pipeline.js가 index.html에 주입) ─── */
.custom-pipeline-badge {
  display: inline-block;
  font-size: 11px;
  font-family: var(--font-mono);
  color: var(--text-muted);
  background: rgba(225, 29, 72, 0.07);
  border: 1px solid rgba(225, 29, 72, 0.25);
  border-radius: var(--radius-sm);
  padding: 3px 10px;
  margin-top: 6px;
}

/* ─── 토스트 알림 ─── */
.editor-toast {
  position: fixed;
  bottom: 28px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--text);
  color: var(--surface);
  font-size: 13px;
  font-family: var(--font-sans);
  padding: 10px 22px;
  border-radius: var(--radius-md);
  box-shadow: 0 4px 24px rgba(0,0,0,0.18);
  z-index: 999;
  white-space: nowrap;
  opacity: 1;
  transition: opacity 0.5s ease;
}

.editor-toast.fade-out {
  opacity: 0;
}

/* ─── 반응형: 모바일에서 헤더 셀렉터 줄바꿈 허용 ─── */
@media (max-width: 600px) {
  .step-header {
    flex-wrap: wrap;
  }

  .step-remove-btn {
    margin-left: 0;
    width: 100%;
    text-align: center;
  }

  .step-body {
    padding-left: 0;
  }

  .step-output-input {
    width: 100%;
  }
}
