/* ===== 관계 네트워크 시각화 ===== */

/* --- 메인 컨테이너 --- */
.network-page {
  position: relative;
  width: 100%;
}

.network-wrapper {
  position: relative;
  width: 100%;
  height: 75vh;
  min-height: 500px;
  background: #06060c;
  border: 1px solid var(--border);
  border-radius: 12px;
  overflow: hidden;
}

.network-wrapper svg {
  width: 100%;
  height: 100%;
  display: block;
}

/* --- 노드 스타일 --- */
.node-circle {
  cursor: pointer;
  transition: filter 0.2s;
}

.node-circle:hover {
  filter: brightness(1.4);
}

.node-label {
  font-size: 10px;
  fill: var(--text-primary);
  pointer-events: none;
  text-anchor: middle;
  font-family: var(--font-sans);
  text-shadow: 0 0 4px rgba(0,0,0,0.9), 0 0 8px rgba(0,0,0,0.7);
}

.node-label.label-main { font-size: 12px; font-weight: 700; }
.node-label.label-sub { font-size: 10px; }
.node-label.label-minor { font-size: 9px; }

/* --- 엣지 스타일 --- */
.network-link {
  fill: none;
  pointer-events: none;
}

/* --- 필터 패널 --- */
.network-filters {
  position: absolute;
  top: 12px;
  left: 12px;
  background: rgba(10, 10, 15, 0.92);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 14px;
  max-width: 260px;
  max-height: calc(100% - 24px);
  overflow-y: auto;
  z-index: 10;
  backdrop-filter: blur(8px);
  transition: transform 0.3s ease, opacity 0.3s ease;
}

.network-filters.collapsed {
  transform: translateX(-100%);
  opacity: 0;
  pointer-events: none;
}

.filter-toggle-btn {
  position: absolute;
  top: 12px;
  left: 12px;
  z-index: 11;
  background: rgba(10, 10, 15, 0.85);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text-primary);
  padding: 6px 12px;
  cursor: pointer;
  font-size: 0.85rem;
  display: none;
}

.filter-section {
  margin-bottom: 14px;
}

.filter-section:last-child {
  margin-bottom: 0;
}

.filter-title {
  font-size: 0.75rem;
  color: var(--gold);
  font-weight: 700;
  margin-bottom: 8px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.filter-item {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 4px;
  cursor: pointer;
  font-size: 0.8rem;
  color: var(--text-secondary);
}

.filter-item:hover {
  color: var(--text-primary);
}

.filter-item input[type="checkbox"] {
  accent-color: var(--gold);
  cursor: pointer;
}

.filter-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  flex-shrink: 0;
}

.filter-line-sample {
  width: 24px;
  height: 3px;
  flex-shrink: 0;
  border-radius: 2px;
}

/* 검색 */
.network-search {
  width: 100%;
  padding: 6px 10px;
  background: rgba(255,255,255,0.06);
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text-primary);
  font-size: 0.85rem;
  outline: none;
}

.network-search:focus {
  border-color: var(--gold-dim);
}

.network-search::placeholder {
  color: var(--text-muted);
}

/* 슬라이더 */
.filter-slider-wrap {
  display: flex;
  align-items: center;
  gap: 8px;
}

.filter-slider-wrap input[type="range"] {
  flex: 1;
  accent-color: var(--gold);
}

.filter-slider-val {
  font-size: 0.8rem;
  color: var(--gold);
  min-width: 20px;
  text-align: center;
}

/* 레이아웃 토글 */
.layout-toggle {
  display: flex;
  gap: 4px;
}

.layout-btn {
  flex: 1;
  padding: 5px 8px;
  font-size: 0.75rem;
  background: rgba(255,255,255,0.05);
  border: 1px solid var(--border);
  border-radius: 5px;
  color: var(--text-secondary);
  cursor: pointer;
  text-align: center;
  transition: all 0.2s;
}

.layout-btn.active {
  background: var(--gold-dim);
  color: #fff;
  border-color: var(--gold);
}

/* --- 사이드 패널 (캐릭터 상세) --- */
.network-detail-panel {
  position: absolute;
  top: 0;
  right: 0;
  width: 300px;
  height: 100%;
  background: rgba(10, 10, 18, 0.95);
  border-left: 1px solid var(--border);
  overflow-y: auto;
  padding: 20px;
  transform: translateX(100%);
  transition: transform 0.3s ease;
  z-index: 20;
  backdrop-filter: blur(8px);
}

.network-detail-panel.open {
  transform: translateX(0);
}

.detail-close {
  position: absolute;
  top: 10px;
  right: 10px;
  background: none;
  border: none;
  color: var(--text-secondary);
  font-size: 1.2rem;
  cursor: pointer;
}

.detail-close:hover {
  color: var(--text-primary);
}

.detail-name {
  font-family: var(--font-serif);
  font-size: 1.4rem;
  color: var(--gold);
  margin-bottom: 4px;
}

.detail-courtesy {
  font-size: 0.9rem;
  color: var(--text-secondary);
  margin-bottom: 12px;
}

.detail-faction-badge {
  display: inline-block;
  padding: 2px 10px;
  border-radius: 10px;
  font-size: 0.75rem;
  font-weight: 700;
  color: #fff;
  margin-bottom: 16px;
}

.detail-section-title {
  font-size: 0.7rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 1px;
  margin-bottom: 8px;
  margin-top: 16px;
}

/* 능력치 바 */
.stat-row {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 6px;
}

.stat-label {
  font-size: 0.75rem;
  color: var(--text-secondary);
  width: 36px;
  flex-shrink: 0;
}

.stat-bar-bg {
  flex: 1;
  height: 6px;
  background: rgba(255,255,255,0.08);
  border-radius: 3px;
  overflow: hidden;
}

.stat-bar-fill {
  height: 100%;
  border-radius: 3px;
  transition: width 0.5s ease;
}

.stat-val {
  font-size: 0.75rem;
  color: var(--text-primary);
  width: 24px;
  text-align: right;
  flex-shrink: 0;
}

/* 관계 목록 */
.rel-list {
  list-style: none;
}

.rel-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 5px 0;
  border-bottom: 1px solid rgba(255,255,255,0.04);
  font-size: 0.8rem;
  cursor: pointer;
}

.rel-item:hover {
  background: rgba(255,255,255,0.03);
}

.rel-type-badge {
  font-size: 0.65rem;
  padding: 1px 6px;
  border-radius: 8px;
  color: #fff;
  flex-shrink: 0;
}

.rel-name {
  color: var(--text-primary);
  flex: 1;
}

.rel-sentiment {
  font-size: 0.7rem;
  font-weight: 700;
}

.rel-sentiment.positive { color: #4CAF50; }
.rel-sentiment.negative { color: #f44336; }
.rel-sentiment.neutral { color: var(--text-muted); }

.detail-link {
  display: block;
  text-align: center;
  margin-top: 16px;
  padding: 8px;
  background: rgba(212, 168, 67, 0.15);
  border: 1px solid var(--gold-dim);
  border-radius: 8px;
  color: var(--gold);
  text-decoration: none;
  font-size: 0.85rem;
  transition: background 0.2s;
}

.detail-link:hover {
  background: rgba(212, 168, 67, 0.25);
}

/* --- 범례 --- */
.network-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 16px;
  padding: 14px 16px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 10px;
  margin-top: 12px;
}

.legend-group {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
}

.legend-group-title {
  font-size: 0.7rem;
  color: var(--gold);
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-right: 4px;
}

.legend-item {
  display: flex;
  align-items: center;
  gap: 5px;
  font-size: 0.75rem;
  color: var(--text-secondary);
}

.legend-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  box-shadow: 0 0 4px currentColor;
}

.legend-line {
  width: 24px;
  height: 0;
  border-top: 3px solid;
}

.legend-line.dashed {
  border-top-style: dashed;
}

/* --- 통계 --- */
.network-stats {
  display: flex;
  gap: 16px;
  margin-top: 8px;
  font-size: 0.8rem;
  color: var(--text-muted);
}

.network-stats span {
  color: var(--text-secondary);
}

/* --- SVG glow 필터 --- */
/* defined inline in SVG defs */

/* --- 반응형 --- */
@media (max-width: 768px) {
  .network-wrapper {
    height: 60vh;
    min-height: 400px;
  }

  .network-filters {
    position: fixed;
    top: 0;
    left: 0;
    width: 260px;
    height: 100vh;
    max-height: 100vh;
    border-radius: 0;
    z-index: 1000;
  }

  .network-filters.collapsed {
    transform: translateX(-100%);
  }

  .filter-toggle-btn {
    display: block;
  }

  .network-detail-panel {
    width: 100%;
  }

  .network-legend {
    flex-direction: column;
    gap: 8px;
  }

  .network-stats {
    flex-wrap: wrap;
    gap: 8px;
  }
}

/* --- 검색 자동완성 --- */
.search-autocomplete {
  position: absolute;
  top: 100%;
  left: 0;
  right: 0;
  background: rgba(10, 10, 15, 0.96);
  border: 1px solid var(--border);
  border-radius: 0 0 6px 6px;
  max-height: 200px;
  overflow-y: auto;
  z-index: 100;
  display: none;
}

.search-autocomplete.visible {
  display: block;
}

.autocomplete-item {
  padding: 6px 10px;
  font-size: 0.82rem;
  color: var(--text-secondary);
  cursor: pointer;
  display: flex;
  justify-content: space-between;
}

.autocomplete-item:hover,
.autocomplete-item.highlighted {
  background: rgba(212, 168, 67, 0.12);
  color: var(--text-primary);
}

.autocomplete-faction {
  font-size: 0.7rem;
  color: var(--text-muted);
}

/* 검색 래퍼 */
.search-wrapper {
  position: relative;
  margin-bottom: 10px;
}

/* 흐리게 (dim) 효과 */
.node-dimmed .node-circle { opacity: 0.08 !important; }
.node-dimmed .node-label { opacity: 0.05 !important; }
.link-dimmed { opacity: 0.03 !important; }

.node-highlighted .node-circle { filter: brightness(1.5) !important; }
.link-highlighted { opacity: 1 !important; filter: brightness(1.3); }

/* Tooltip */
.network-tooltip {
  position: absolute;
  pointer-events: none;
  background: rgba(10, 10, 18, 0.92);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 6px 10px;
  font-size: 0.78rem;
  color: var(--text-primary);
  z-index: 50;
  white-space: nowrap;
  backdrop-filter: blur(4px);
  display: none;
}

.network-tooltip.visible {
  display: block;
}

.tooltip-name {
  font-weight: 700;
  color: var(--gold);
}

.tooltip-info {
  color: var(--text-secondary);
  font-size: 0.72rem;
}
