/* SystemFlowViewer 전용 스타일 — 프로젝트 다크 테마와 일관 */

@import '@xyflow/react/dist/style.css';

html,
body,
#root {
  margin: 0;
  padding: 0;
  height: 100%;
  background: #0b1220;
  color: #e2e8f0;
  font-family: 'Inter', 'Noto Sans KR', system-ui, sans-serif;
  font-size: 13px;
}

* {
  box-sizing: border-box;
}

.system-flow-shell {
  display: grid;
  grid-template-rows: 56px 1fr;
  grid-template-columns: 332px minmax(880px, 1fr) 392px;
  grid-template-areas:
    'header header header'
    'sidebar canvas detail';
  height: 100vh;
  overflow: hidden;
}

/* Header */
.sf-header {
  grid-area: header;
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 0 20px;
  background: #0f172a;
  border-bottom: 1px solid rgba(148, 163, 184, 0.18);
}

.sf-header h1 {
  margin: 0;
  font-size: 14px;
  font-weight: 700;
  color: #f1f5f9;
  letter-spacing: 0.02em;
}

.sf-header .sf-meta {
  font-size: 11px;
  color: #94a3b8;
}

.sf-header .sf-spacer {
  flex: 1;
}

.sf-header input[type='text'] {
  background: #1e293b;
  border: 1px solid rgba(148, 163, 184, 0.24);
  color: #e2e8f0;
  padding: 6px 12px;
  border-radius: 6px;
  font-size: 12px;
  width: 240px;
}

.sf-header input[type='text']:focus {
  outline: none;
  border-color: #38bdf8;
}

.sf-header select {
  background: #1e293b;
  border: 1px solid rgba(148, 163, 184, 0.24);
  color: #e2e8f0;
  padding: 6px 10px;
  border-radius: 6px;
  font-size: 12px;
  cursor: pointer;
}

.sf-toggle {
  display: inline-flex;
  background: #1e293b;
  border: 1px solid rgba(148, 163, 184, 0.24);
  border-radius: 6px;
  overflow: hidden;
}

.sf-toggle button {
  background: transparent;
  border: 0;
  color: #94a3b8;
  padding: 6px 12px;
  font-size: 12px;
  cursor: pointer;
  transition: all 0.15s;
}

.sf-toggle button[data-active='true'] {
  background: #334155;
  color: #f1f5f9;
}

/* 좌측 사이드바 */
.sf-sidebar {
  grid-area: sidebar;
  background: #0f172a;
  border-right: 1px solid rgba(148, 163, 184, 0.18);
  overflow-y: auto;
  padding: 16px;
}

.sf-section-title {
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: #64748b;
  margin: 12px 0 8px;
}

.sf-node-card {
  display: block;
  width: 100%;
  text-align: left;
  background: #1e293b;
  border: 1px solid rgba(148, 163, 184, 0.18);
  border-left: 3px solid var(--accent, #38bdf8);
  border-radius: 6px;
  padding: 10px 12px;
  margin-bottom: 6px;
  cursor: pointer;
  transition: all 0.15s;
}

.sf-node-card:hover {
  background: #273449;
  border-color: rgba(56, 189, 248, 0.4);
}

.sf-node-card[data-active='true'] {
  background: #1e3a52;
  border-color: #38bdf8;
  box-shadow: 0 0 0 2px rgba(56, 189, 248, 0.2);
}

.sf-node-card .sf-card-stage {
  font-size: 9px;
  color: #94a3b8;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  margin-bottom: 4px;
}

.sf-node-card .sf-card-label {
  font-size: 12px;
  font-weight: 600;
  color: #f1f5f9;
  margin-bottom: 2px;
}

.sf-node-card .sf-card-desc {
  font-size: 10px;
  color: #94a3b8;
  line-height: 1.4;
}

.sf-node-card .sf-card-id {
  font-size: 9px;
  color: #64748b;
  font-family: 'Fira Code', 'Menlo', monospace;
  margin-top: 4px;
}

/* 중앙 캔버스 */
.sf-canvas {
  grid-area: canvas;
  position: relative;
  background: #0b1220;
}

.sf-focus-badge {
  position: absolute;
  top: 16px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 100;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 8px 14px;
  background: rgba(15, 23, 42, 0.95);
  border: 1px solid rgba(56, 189, 248, 0.45);
  border-radius: 8px;
  box-shadow: 0 10px 32px rgba(2, 6, 23, 0.5);
  font-size: 12px;
  color: #e2e8f0;
  -webkit-backdrop-filter: blur(8px);
  backdrop-filter: blur(8px);
}

.sf-focus-badge strong {
  color: #7dd3fc;
  font-weight: 600;
}

.sf-focus-badge button {
  background: transparent;
  border: 1px solid rgba(148, 163, 184, 0.3);
  color: #94a3b8;
  padding: 4px 10px;
  border-radius: 4px;
  font-size: 11px;
  cursor: pointer;
  transition: all 0.15s;
}

.sf-focus-badge button:hover {
  background: rgba(56, 189, 248, 0.1);
  border-color: rgba(56, 189, 248, 0.5);
  color: #7dd3fc;
}

.sf-canvas .react-flow__renderer {
  background: #0b1220;
}

.sf-canvas .react-flow__node {
  font-size: 11px;
  color: #e2e8f0;
}

.sf-canvas .react-flow__node-default {
  padding: 0;
  border-radius: 8px;
  background: linear-gradient(180deg, rgba(15, 23, 42, 0.95), rgba(15, 23, 42, 0.8));
}

.sf-canvas .react-flow__handle {
  background: #38bdf8;
  border: 1px solid #0f172a;
  width: 6px;
  height: 6px;
}

.sf-canvas .react-flow__edge-path {
  stroke-width: 1.6;
}

.sf-canvas .react-flow__edge.selected .react-flow__edge-path {
  stroke-width: 2.6;
  stroke: #f8fafc;
}

.sf-canvas .react-flow__edge-text {
  font-size: 10px;
  fill: #cbd5e1;
}

.sf-canvas .react-flow__minimap {
  background: rgba(15, 23, 42, 0.9);
  border: 1px solid rgba(148, 163, 184, 0.18);
  border-radius: 6px;
}

.sf-canvas .react-flow__controls {
  background: rgba(15, 23, 42, 0.9);
  border: 1px solid rgba(148, 163, 184, 0.18);
  border-radius: 6px;
}

.sf-canvas .react-flow__controls button {
  background: #1e293b;
  border-bottom: 1px solid rgba(148, 163, 184, 0.18);
  color: #e2e8f0;
}

.sf-canvas .react-flow__controls button:hover {
  background: #334155;
}

/* 노드 내부 컨텐츠 */
.sf-node-body {
  padding: 10px 14px;
  width: 220px;
  border: 2px solid var(--accent, #38bdf8);
  border-radius: 8px;
  background: linear-gradient(180deg, rgba(15, 23, 42, 0.96), rgba(15, 23, 42, 0.84));
}

.sf-node-body[data-status='planned'] {
  border-style: dashed;
  opacity: 0.85;
}

.sf-node-body[data-status='deprecated'] {
  border-style: dotted;
  opacity: 0.55;
}

.sf-node-body[data-trigger='user_action'] {
  box-shadow: 0 0 0 2px rgba(245, 158, 11, 0.25);
}

.sf-node-body[data-selected='true'] {
  box-shadow:
    0 0 0 4px rgba(56, 189, 248, 0.35),
    0 0 32px rgba(56, 189, 248, 0.25),
    0 12px 32px rgba(2, 6, 23, 0.4);
  transform: scale(1.02);
}

.sf-node-body[data-dimmed='true'] {
  filter: grayscale(0.8);
}

.sf-node-stage {
  font-size: 9px;
  color: #94a3b8;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  margin-bottom: 4px;
}

.sf-node-label {
  font-size: 12px;
  font-weight: 600;
  color: #f1f5f9;
  line-height: 1.3;
  margin-bottom: 4px;
}

.sf-node-id {
  font-size: 9px;
  font-family: 'Fira Code', 'Menlo', monospace;
  color: #64748b;
}

/* 우측 상세 패널 */
.sf-detail {
  grid-area: detail;
  background: #0f172a;
  border-left: 1px solid rgba(148, 163, 184, 0.18);
  overflow-y: auto;
  padding: 20px;
}

.sf-detail h2 {
  font-size: 16px;
  font-weight: 700;
  color: #f1f5f9;
  margin: 0 0 6px;
}

.sf-detail .sf-detail-id {
  font-size: 11px;
  font-family: 'Fira Code', 'Menlo', monospace;
  color: #94a3b8;
  background: #1e293b;
  padding: 4px 8px;
  border-radius: 4px;
  display: inline-block;
  margin-bottom: 12px;
}

.sf-badges {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 16px;
}

.sf-badge {
  font-size: 10px;
  padding: 3px 8px;
  border-radius: 4px;
  background: #1e293b;
  color: #cbd5e1;
  border: 1px solid rgba(148, 163, 184, 0.2);
}

.sf-badge[data-tone='accent'] {
  background: rgba(56, 189, 248, 0.15);
  color: #7dd3fc;
  border-color: rgba(56, 189, 248, 0.35);
}

.sf-badge[data-tone='warn'] {
  background: rgba(245, 158, 11, 0.15);
  color: #fcd34d;
  border-color: rgba(245, 158, 11, 0.35);
}

.sf-badge[data-tone='success'] {
  background: rgba(34, 197, 94, 0.15);
  color: #86efac;
  border-color: rgba(34, 197, 94, 0.35);
}

.sf-detail-section {
  margin-top: 16px;
}

.sf-detail-label {
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: #64748b;
  margin-bottom: 6px;
}

.sf-detail-text {
  font-size: 12px;
  color: #e2e8f0;
  line-height: 1.6;
}

.sf-code {
  font-family: 'Fira Code', 'Menlo', monospace;
  font-size: 11px;
  background: #1e293b;
  color: #7dd3fc;
  padding: 6px 10px;
  border-radius: 4px;
  word-break: break-all;
  display: block;
}

.sf-list {
  list-style: none;
  padding: 0;
  margin: 0;
}

.sf-list li {
  font-size: 11px;
  color: #cbd5e1;
  background: #1e293b;
  padding: 5px 10px;
  border-radius: 4px;
  margin-bottom: 4px;
  border-left: 2px solid var(--accent, #38bdf8);
}

.sf-link-button {
  display: block;
  width: 100%;
  text-align: left;
  background: #1e293b;
  border: 1px solid rgba(148, 163, 184, 0.18);
  color: #e2e8f0;
  padding: 6px 10px;
  border-radius: 4px;
  margin-bottom: 4px;
  cursor: pointer;
  font-size: 11px;
  transition: all 0.15s;
}

.sf-link-button:hover {
  background: #273449;
  border-color: rgba(56, 189, 248, 0.4);
}

.sf-empty {
  text-align: center;
  color: #64748b;
  font-size: 11px;
  padding: 40px 20px;
}

.sf-filter-row {
  display: flex;
  gap: 8px;
  margin-top: 8px;
  flex-wrap: wrap;
}

.sf-chip {
  font-size: 10px;
  padding: 3px 8px;
  border-radius: 999px;
  background: #1e293b;
  color: #94a3b8;
  border: 1px solid rgba(148, 163, 184, 0.2);
  cursor: pointer;
  transition: all 0.15s;
}

.sf-chip[data-active='true'] {
  background: rgba(56, 189, 248, 0.18);
  color: #7dd3fc;
  border-color: rgba(56, 189, 248, 0.4);
}

.sf-chip:hover {
  border-color: rgba(56, 189, 248, 0.4);
}
