/* ===== Harness UI — 스크롤/렌더 최적화 커스텀 CSS ===== */

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Apple SD Gothic Neo', 'Malgun Gothic', 'Noto Sans KR', sans-serif;
}

/* 카드 — shadow 최소화 (compositor layer 폭주 방지) */
.card {
  background: white;
  border-radius: 16px;
  border: 1px solid rgba(0, 0, 0, 0.04);
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.03);
  /* 스크롤 시 독립 레이아웃 컨테인 — 페인트 영역 축소 */
  contain: content;
  /* 뷰포트 밖 요소는 레이아웃 스킵 (최신 브라우저만 적용) */
  content-visibility: auto;
  contain-intrinsic-size: 1px 200px;
}
.card:hover {
  box-shadow: 0 4px 8px rgba(0, 0, 0, 0.05);
}

/* 중첩된 카드 요소들이 shadow를 이중 계산하지 않도록 transition 제거 대신 짧게 */
.card, .card:hover {
  transition: box-shadow 0.12s ease-out;
}

.ring-progress {
  transform: rotate(-90deg);
}
.ring-progress circle {
  transition: stroke-dashoffset 0.4s;
}

.nav-active {
  background: linear-gradient(135deg, #8b5cf6 0%, #7c3aed 100%);
  color: white;
}
.nav-active svg {
  color: white;
}

.grad-purple {
  background: linear-gradient(135deg, #8b5cf6 0%, #6d28d9 100%);
}

.tag {
  display: inline-flex;
  align-items: center;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 500;
  white-space: nowrap;
}

/* Drawer — GPU 가속 + snappy */
.drawer {
  transform: translate3d(100%, 0, 0);
  transition: transform 0.16s cubic-bezier(0.2, 0, 0, 1);
  will-change: transform;
  backface-visibility: hidden;
}
.drawer.open {
  transform: translate3d(0, 0, 0);
}

#drawer-backdrop {
  transition: opacity 0.16s ease;
}
#drawer-backdrop.show {
  opacity: 1;
  pointer-events: auto;
}

/* Toast */
#toast.show {
  opacity: 1;
  transition: opacity 0.2s ease;
}

/* 페이지 전환 — 짧은 fade-in만 */
.page {
  animation: fadeIn 0.1s ease-out;
}
@keyframes fadeIn {
  from { opacity: 0.5; }
  to { opacity: 1; }
}

/* 클릭 피드백 */
.clickable {
  cursor: pointer;
  transition: transform 0.08s ease, background-color 0.1s ease;
}
.clickable:active {
  transform: scale(0.98);
}

/* 스크롤바 */
::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}
::-webkit-scrollbar-thumb {
  background: #d1d5db;
  border-radius: 4px;
}
::-webkit-scrollbar-track {
  background: transparent;
}

/* 리스트 아이템 — 가상화 힌트 */
.list-item {
  contain: layout style;
  content-visibility: auto;
  contain-intrinsic-size: 1px 80px;
}

/* 스켈레톤 로더 */
.skeleton {
  background: linear-gradient(90deg, #f3f4f6 25%, #e5e7eb 50%, #f3f4f6 75%);
  background-size: 200% 100%;
  animation: shimmer 1.2s infinite linear;
  border-radius: 8px;
}
@keyframes shimmer {
  from { background-position: -200% 0; }
  to { background-position: 200% 0; }
}

/* 유틸: line clamp */
.line-clamp-1 { display: -webkit-box; -webkit-line-clamp: 1; -webkit-box-orient: vertical; overflow: hidden; }
.line-clamp-2 { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }

/* Brand color utilities (tailwind safelist 보완) */
.text-brand-600 { color: #7c3aed; }
.text-brand-700 { color: #6d28d9; }
.bg-brand-50 { background-color: #f5f3ff; }
.bg-brand-500 { background-color: #8b5cf6; }
.border-brand-500 { border-color: #8b5cf6; }
.text-brand { color: #8b5cf6; }

/* ===== Wizard Steps ===== */
.wizard-steps {
  display: flex;
  gap: 0;
  margin-bottom: 24px;
  position: relative;
}
.wizard-step {
  flex: 1;
  text-align: center;
  position: relative;
  padding: 12px 8px 8px;
}
.wizard-step::before {
  content: '';
  position: absolute;
  top: 22px;
  left: 0;
  right: 0;
  height: 2px;
  background: #e5e7eb;
  z-index: 0;
}
.wizard-step:first-child::before { left: 50%; }
.wizard-step:last-child::before { right: 50%; }
.wizard-dot {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: #e5e7eb;
  color: #9ca3af;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  font-weight: 600;
  position: relative;
  z-index: 1;
  transition: background 0.2s, color 0.2s;
}
.wizard-step.active .wizard-dot {
  background: #8b5cf6;
  color: white;
}
.wizard-step.done .wizard-dot {
  background: #10b981;
  color: white;
}
.wizard-step.error .wizard-dot {
  background: #ef4444;
  color: white;
}
.wizard-step.done::before,
.wizard-step.active::before {
  background: #8b5cf6;
}
.wizard-label {
  display: block;
  font-size: 11px;
  color: #9ca3af;
  margin-top: 6px;
}
.wizard-step.active .wizard-label { color: #7c3aed; font-weight: 600; }
.wizard-step.done .wizard-label { color: #10b981; }

/* ===== State Badges ===== */
.state-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 10px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 600;
}
.state-idle { background: #f3f4f6; color: #6b7280; }
.state-selected { background: #ede9fe; color: #7c3aed; }
.state-ready { background: #d1fae5; color: #065f46; }
.state-running { background: #fef3c7; color: #92400e; }
.state-success { background: #d1fae5; color: #065f46; }
.state-error { background: #fee2e2; color: #991b1b; }

/* ===== Confirm Dialog ===== */
.confirm-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.4);
  z-index: 40;
  display: flex;
  align-items: center;
  justify-content: center;
}
.confirm-box {
  background: white;
  border-radius: 16px;
  padding: 24px;
  max-width: 440px;
  width: 90%;
  box-shadow: 0 20px 60px rgba(0,0,0,0.15);
}
.confirm-box .warn-banner {
  background: #fef2f2;
  border: 1px solid #fecaca;
  border-radius: 12px;
  padding: 12px;
  margin-bottom: 16px;
  color: #991b1b;
  font-size: 13px;
}

/* ===== Form Elements ===== */
.form-label {
  display: block;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: #9ca3af;
  margin-bottom: 6px;
}
.form-input {
  width: 100%;
  padding: 8px 12px;
  border: 1px solid #e5e7eb;
  border-radius: 8px;
  font-size: 14px;
  transition: border-color 0.15s;
}
.form-input:focus {
  outline: none;
  border-color: #8b5cf6;
  box-shadow: 0 0 0 3px rgba(139,92,246,0.1);
}
.form-input.error {
  border-color: #ef4444;
  box-shadow: 0 0 0 3px rgba(239,68,68,0.1);
}
.form-error {
  font-size: 12px;
  color: #ef4444;
  margin-top: 4px;
}
.form-select {
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 20 20'%3E%3Cpath stroke='%236b7280' stroke-linecap='round' stroke-linejoin='round' stroke-width='1.5' d='M6 8l4 4 4-4'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 8px center;
  background-size: 16px;
  padding-right: 32px;
}

/* ===== Button States ===== */
.btn-primary {
  padding: 10px 20px;
  background: linear-gradient(135deg, #8b5cf6, #6d28d9);
  color: white;
  border-radius: 10px;
  font-size: 14px;
  font-weight: 500;
  transition: opacity 0.15s, transform 0.08s;
}
.btn-primary:hover { opacity: 0.9; }
.btn-primary:active { transform: scale(0.98); }
.btn-primary:disabled {
  opacity: 0.4;
  cursor: not-allowed;
  transform: none;
}
.btn-secondary {
  padding: 10px 20px;
  background: #f3f4f6;
  color: #374151;
  border-radius: 10px;
  font-size: 14px;
  font-weight: 500;
  transition: background 0.15s;
}
.btn-secondary:hover { background: #e5e7eb; }
.btn-danger {
  padding: 10px 20px;
  background: #ef4444;
  color: white;
  border-radius: 10px;
  font-size: 14px;
  font-weight: 500;
}
.btn-danger:hover { background: #dc2626; }

/* ===== Log Output ===== */
.log-output {
  background: #1f2937;
  color: #d1d5db;
  font-family: 'SF Mono', 'Menlo', monospace;
  font-size: 12px;
  padding: 16px;
  border-radius: 12px;
  max-height: 400px;
  overflow-y: auto;
  white-space: pre-wrap;
  word-break: break-all;
  line-height: 1.6;
}

/* ===== Chip Checkbox ===== */
.chip-check {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 14px;
  border: 1.5px solid #e5e7eb;
  border-radius: 999px;
  font-size: 13px;
  cursor: pointer;
  transition: all 0.15s;
  user-select: none;
}
.chip-check:hover { border-color: #c4b5fd; background: #faf5ff; }
.chip-check.selected {
  border-color: #8b5cf6;
  background: #ede9fe;
  color: #6d28d9;
  font-weight: 500;
}
.chip-check .chip-warn {
  font-size: 10px;
  color: #f59e0b;
}

/* ===== Spinner ===== */
.spinner {
  width: 20px;
  height: 20px;
  border: 2px solid #e5e7eb;
  border-top-color: #8b5cf6;
  border-radius: 50%;
  animation: spin 0.6s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ===== Pipeline Bar ===== */
.pipeline-bar {
  position: relative;
}
.pipeline-step {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  position: relative;
  min-width: 0;
}
.pipeline-dot {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: #e5e7eb;
  position: relative;
  z-index: 1;
  flex-shrink: 0;
  transition: background 0.3s, box-shadow 0.3s;
}
.pipeline-dot.done {
  background: #10b981;
}
.pipeline-dot.active {
  background: #8b5cf6;
  box-shadow: 0 0 0 4px rgba(139,92,246,0.2);
  animation: pulse-dot 1.5s ease infinite;
}
.pipeline-dot.error {
  background: #ef4444;
  box-shadow: 0 0 0 4px rgba(239,68,68,0.2);
}
@keyframes pulse-dot {
  0%, 100% { box-shadow: 0 0 0 4px rgba(139,92,246,0.2); }
  50% { box-shadow: 0 0 0 8px rgba(139,92,246,0.1); }
}
.pipeline-line {
  position: absolute;
  top: 5px;
  right: 50%;
  left: -50%;
  height: 2px;
  background: #e5e7eb;
  z-index: 0;
  transition: background 0.3s;
}
.pipeline-line.done {
  background: #10b981;
}
.pipeline-line.active {
  background: linear-gradient(90deg, #10b981, #8b5cf6);
}
.pipeline-step-label {
  font-size: 9px;
  color: #9ca3af;
  margin-top: 4px;
  white-space: nowrap;
  text-overflow: ellipsis;
  overflow: hidden;
  max-width: 100%;
  text-align: center;
}
.pipeline-step-label.active {
  color: #7c3aed;
  font-weight: 600;
}

/* Pipeline bar height variants */
.pipeline-bar.h-6 .pipeline-dot { width: 8px; height: 8px; }
.pipeline-bar.h-6 .pipeline-line { top: 3px; height: 2px; }
.pipeline-bar.h-6 .pipeline-step-label { display: none; }
.pipeline-bar.h-10 .pipeline-dot { width: 14px; height: 14px; }
.pipeline-bar.h-10 .pipeline-line { top: 6px; height: 2px; }

/* ===== Pipeline Pulse (active step) ===== */
.pipeline-pulse {
  animation: pipe-pulse 1.5s ease infinite;
}
@keyframes pipe-pulse {
  0%, 100% { box-shadow: 0 0 0 3px rgba(139, 92, 246, 0.25); }
  50% { box-shadow: 0 0 0 6px rgba(139, 92, 246, 0.1); }
}

/* ===== Sidebar Section Labels ===== */
nav .text-\[9px\] {
  line-height: 1;
}

/* ===== Plan Tab Switcher ===== */
.plan-tab {
  padding: 4px 14px;
  font-size: 12px;
  font-weight: 500;
  border-radius: 6px;
  color: #6b7280;
  cursor: pointer;
  transition: all 0.15s;
}
.plan-tab.active {
  background: white;
  color: #1f2937;
  box-shadow: 0 1px 3px rgba(0,0,0,0.08);
}

/* ===== Plan Viewer Modal ===== */
.plan-modal {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: flex;
  align-items: stretch;
  justify-content: center;
  background: rgba(0, 0, 0, 0.5);
  padding: 24px;
  animation: fadeIn 0.15s ease-out;
}
.plan-modal-inner {
  background: white;
  border-radius: 16px;
  width: 100%;
  max-width: 900px;
  display: flex;
  flex-direction: column;
  box-shadow: 0 25px 50px rgba(0, 0, 0, 0.2);
  overflow: hidden;
}
.plan-modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 24px;
  border-bottom: 1px solid #f3f4f6;
  flex-shrink: 0;
}
.plan-modal-body {
  flex: 1;
  overflow-y: auto;
  padding: 24px;
  display: flex;
  flex-direction: column;
  min-height: 0;
}
.plan-modal-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 24px;
  border-top: 1px solid #f3f4f6;
  flex-shrink: 0;
  gap: 12px;
}
.plan-edit-area {
  flex: 1;
  width: 100%;
  height: 100%;
  min-height: 300px;
  font-family: 'SF Mono', 'Menlo', 'Consolas', monospace;
  font-size: 13px;
  line-height: 1.7;
  border: 1px solid #e5e7eb;
  border-radius: 8px;
  padding: 16px;
  resize: none;
  box-sizing: border-box;
}
body.modal-open { overflow: hidden; }
.plan-inline-preview {
  max-height: 360px;
  overflow-y: auto;
  content-visibility: auto;
  contain-intrinsic-size: 300px;
  padding: 12px 14px;
  border: 1px solid #e5e7eb;
  border-radius: 10px;
  background: #fafbfc;
}
.plan-edit-area:focus {
  outline: none;
  border-color: #8b5cf6;
  box-shadow: 0 0 0 3px rgba(139, 92, 246, 0.1);
}

/* ===== Plan Markdown Rendered Styles ===== */
.plan-rendered { line-height: 1.7; color: #1f2937; }
.plan-h1 { font-size: 20px; font-weight: 700; margin: 20px 0 8px; padding-bottom: 6px; border-bottom: 2px solid #8b5cf6; color: #1f2937; }
.plan-h2 { font-size: 16px; font-weight: 600; margin: 16px 0 6px; padding-bottom: 4px; border-bottom: 1px solid #e5e7eb; color: #374151; }
.plan-h3 { font-size: 14px; font-weight: 600; margin: 12px 0 4px; color: #4b5563; }
.plan-h4 { font-size: 13px; font-weight: 600; margin: 8px 0 4px; color: #6b7280; }
.plan-p { margin: 4px 0; font-size: 13px; }
.plan-quote {
  margin: 8px 0;
  padding: 8px 12px;
  border-left: 3px solid #8b5cf6;
  background: #f5f3ff;
  color: #6d28d9;
  font-size: 12px;
  border-radius: 0 8px 8px 0;
}
.plan-list { margin: 4px 0 4px 16px; font-size: 13px; }
.plan-list li { margin: 2px 0; list-style: disc; }
.plan-list li::marker { color: #8b5cf6; }
.plan-checklist { margin: 4px 0; padding: 0; list-style: none; }
.plan-check-item { margin: 3px 0; font-size: 13px; display: flex; align-items: baseline; gap: 6px; }
.plan-checkbox { font-size: 14px; flex-shrink: 0; }
.plan-check-item.checked { color: #10b981; text-decoration: line-through; opacity: 0.7; }
.plan-hr { border: none; border-top: 1px solid #e5e7eb; margin: 12px 0; }
.plan-inline-code {
  background: #f3f4f6;
  color: #7c3aed;
  padding: 1px 5px;
  border-radius: 4px;
  font-size: 12px;
  font-family: 'SF Mono', 'Menlo', monospace;
}
.plan-code {
  background: #1f2937;
  color: #e5e7eb;
  border-radius: 8px;
  padding: 12px;
  margin: 8px 0;
  font-size: 12px;
  overflow-x: auto;
}
.plan-table-wrap { overflow-x: auto; margin: 8px 0; }
.plan-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12px;
}
.plan-table th {
  background: #f9fafb;
  padding: 8px 10px;
  text-align: left;
  font-weight: 600;
  border-bottom: 2px solid #e5e7eb;
  color: #374151;
  white-space: nowrap;
}
.plan-table td {
  padding: 6px 10px;
  border-bottom: 1px solid #f3f4f6;
  color: #4b5563;
}
.plan-table tr:hover td { background: #f9fafb; }
