/* ================================================================
   mindmap_workspace.css  — 마인드맵 작업실 전용 스타일
   역할: 레이아웃 / 패널 / 툴바 / 편집 폼 / 관계 편집 / 검색 / 필터
   ================================================================ */

/* ── 레이아웃 ── */
.mw-page { padding: 20px; }

.mw-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 16px;
  flex-wrap: wrap;
  margin-bottom: 14px;
}
.mw-title  { font-size: 22px; font-weight: 900; color: #0f172a; margin: 0 0 4px; }
.mw-sub    { font-size: 12px; color: #64748b; margin: 0; }

.mw-toolbar { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.mw-advanced-tools {
  border: 1px solid #d1d5db;
  border-radius: 8px;
  background: #fff;
}
.mw-advanced-tools summary {
  list-style: none;
  cursor: pointer;
  padding: 7px 12px;
  font-size: 12px;
  color: #475569;
}
.mw-advanced-tools summary::-webkit-details-marker { display: none; }
.mw-advanced-tools-body {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  padding: 0 8px 8px;
}

/* ── 공통 버튼 ── */
.mw-btn {
  padding: 7px 12px;
  border: 1px solid #d1d5db;
  border-radius: 8px;
  background: #f8fafc;
  cursor: pointer;
  font-size: 12px;
  color: #374151;
  white-space: nowrap;
  line-height: 1;
}
.mw-btn:hover      { background: #f1f5f9; }
.mw-btn-primary    { background: #1565ff; color: #fff; border-color: #1565ff; }
.mw-btn-primary:hover { background: #1251d4; }
.mw-btn-danger     { background: #fff1f2; color: #dc2626; border-color: #fca5a5; }
.mw-btn-danger:hover  { background: #ffe4e6; }
.mw-btn-recover    { background: #fffbeb; color: #92400e; border-color: #fcd34d; }
.mw-btn-recover:hover { background: #fef3c7; }
.mw-btn-sm         { padding: 4px 9px; font-size: 11px; }

/* ── 검색 / 필터 바 ── */
.mw-searchbar {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  align-items: center;
  padding: 8px 12px;
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  border-radius: 10px;
  margin-bottom: 10px;
}
.mw-search-input {
  flex: 1;
  min-width: 140px;
  padding: 6px 10px;
  border: 1px solid #d1d5db;
  border-radius: 7px;
  font-size: 12px;
}
.mw-sel {
  padding: 6px 8px;
  border: 1px solid #d1d5db;
  border-radius: 7px;
  font-size: 12px;
  background: #fff;
}
.mw-storage-state {
  padding: 6px 10px;
  border: 1px solid #dbe4f0;
  border-radius: 999px;
  background: #fff;
  font-size: 11px;
  color: #475569;
  white-space: nowrap;
}
.mw-search-results {
  position: absolute;
  top: 100%;
  left: 0;
  right: 0;
  z-index: 100;
  background: #fff;
  border: 1px solid #e2e8f0;
  border-radius: 8px;
  box-shadow: 0 8px 24px rgba(15,23,42,.10);
  max-height: 280px;
  overflow-y: auto;
  margin-top: 4px;
  display: none;
}
.mw-search-results.open { display: block; }
.mw-search-result-item {
  padding: 8px 12px;
  cursor: pointer;
  display: flex;
  gap: 8px;
  align-items: flex-start;
  border-bottom: 1px solid #f1f5f9;
  font-size: 12px;
}
.mw-search-result-item:hover { background: #f1f5f9; }
.mw-search-result-item:last-child { border-bottom: none; }
.mw-sri-title { font-weight: 700; color: #0f172a; }
.mw-sri-meta  { font-size: 11px; color: #64748b; }
.mw-sri-cat   {
  display: inline-block;
  padding: 1px 6px;
  border-radius: 999px;
  font-size: 10px;
  font-weight: 700;
  flex-shrink: 0;
}

/* ── 본문 그리드 ── */
.mw-body {
  display: grid;
  grid-template-columns: 1fr 320px;
  gap: 14px;
  align-items: start;
}
.mw-map-wrap {
  height: 720px;
  border: 1px solid #dbe4f0;
  border-radius: 16px;
  overflow: hidden;
  background: #fafcff;
  position: relative;
}

/* ── 우측 패널 ── */
.mw-panel {
  border: 1px solid #e5e7eb;
  border-radius: 14px;
  background: #f8fafc;
  padding: 14px;
  max-height: 720px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 0;
}
.mw-recent-panel {
  margin-bottom: 12px;
  padding: 10px;
  border: 1px solid #e2e8f0;
  border-radius: 10px;
  background: #fff;
}
.mw-recent-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 8px;
  margin-bottom: 8px;
}
.mw-recent-title {
  font-size: 12px;
  font-weight: 800;
  color: #0f172a;
}
.mw-recent-sub {
  margin-top: 3px;
  font-size: 11px;
  color: #64748b;
  line-height: 1.4;
}
.mw-recent-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.mw-recent-item {
  width: 100%;
  text-align: left;
  padding: 8px 9px;
  border: 1px solid #e2e8f0;
  border-radius: 8px;
  background: #f8fafc;
  cursor: pointer;
}
.mw-recent-item:hover {
  background: #eef2ff;
}
.mw-recent-item-topic {
  font-size: 12px;
  font-weight: 700;
  color: #0f172a;
}
.mw-recent-item-meta {
  margin-top: 2px;
  font-size: 11px;
  color: #64748b;
}
.mw-recent-empty {
  padding: 8px 0;
  font-size: 11px;
  color: #94a3b8;
}

/* 힌트 (미선택 상태) */
.mw-panel-hint { padding: 24px 12px; text-align: center; color: #64748b; }
.mw-hint-icon  { font-size: 32px; margin-bottom: 10px; }
.mw-panel-hint p { font-size: 13px; margin: 0 0 14px; line-height: 1.7; }
.mw-shortcut-grid {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 5px 10px;
  align-items: center;
  font-size: 12px;
  max-width: 200px;
  margin: 0 auto;
}
kbd {
  display: inline-block;
  padding: 2px 7px;
  border: 1px solid #d1d5db;
  border-radius: 4px;
  background: #fff;
  font-size: 10px;
  font-weight: 700;
  color: #334155;
  font-family: inherit;
  white-space: nowrap;
}

/* 편집기 */
.mw-editor { display: flex; flex-direction: column; gap: 9px; }
.mw-panel-title { font-size: 15px; font-weight: 800; color: #0f172a; }
.mw-panel-meta  { font-size: 11px; color: #64748b; margin: 3px 0 8px; padding-bottom: 10px; border-bottom: 1px solid #e2e8f0; }

.mw-editor-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 4px;
}
.mw-editor-label { font-size: 13px; font-weight: 700; color: #0f172a; }
.mw-dirty-badge  {
  font-size: 10px;
  color: #b45309;
  background: #fef3c7;
  padding: 2px 8px;
  border-radius: 999px;
}

/* 폼 필드 */
.mw-field-label { font-size: 11px; font-weight: 600; display: grid; gap: 3px; color: #374151; }
.mw-field-label input,
.mw-field-label select,
.mw-field-label textarea {
  width: 100%;
  padding: 7px 8px;
  border: 1px solid #d1d5db;
  border-radius: 7px;
  font-size: 12px;
  box-sizing: border-box;
  font-family: inherit;
  background: #fff;
}
.mw-field-label input:focus,
.mw-field-label select:focus,
.mw-field-label textarea:focus { outline: 2px solid #3b82f6; border-color: #3b82f6; }
.mw-field-label textarea { resize: vertical; }
.mw-grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }

/* 저장/액션 버튼 영역 */
.mw-editor-actions {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
  padding-top: 6px;
  border-top: 1px solid #e2e8f0;
}
.mw-msg { font-size: 12px; color: #334155; min-height: 14px; }

/* ── 관계 편집기 ── */
.mw-rel-section { margin-top: 2px; }
.mw-rel-section-title {
  font-size: 11px;
  font-weight: 700;
  color: #64748b;
  text-transform: uppercase;
  letter-spacing: .05em;
  margin-bottom: 6px;
}
.mw-rel-row {
  display: grid;
  grid-template-columns: 1fr 90px auto;
  gap: 5px;
  align-items: center;
  padding: 5px;
  background: #fff;
  border: 1px solid #e2e8f0;
  border-radius: 6px;
  margin-bottom: 4px;
}
.mw-rel-row select { padding: 4px 5px; border: 1px solid #d1d5db; border-radius: 5px; font-size: 11px; width: 100%; }
.mw-rel-add-row { display: flex; gap: 5px; align-items: center; margin-top: 5px; flex-wrap: wrap; }
.mw-rel-add-row select { flex: 1; min-width: 80px; padding: 5px 6px; border: 1px solid #d1d5db; border-radius: 6px; font-size: 11px; }
.mw-related-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.mw-related-section {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.mw-related-title {
  font-size: 11px;
  font-weight: 700;
  color: #475569;
}
.mw-related-item {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  width: 100%;
  text-align: left;
  padding: 8px 10px;
  border-radius: 8px;
  border: 1px solid #dbe4f0;
  background: #fff;
  cursor: pointer;
}
.mw-related-item:hover {
  background: #f8fafc;
}
.mw-related-item-outgoing {
  border-color: rgba(16, 185, 129, 0.25);
}
.mw-related-item-incoming {
  border-color: rgba(249, 115, 22, 0.25);
}
.mw-related-badge {
  flex: 0 0 auto;
  font-size: 10px;
  font-weight: 700;
  color: #334155;
  background: #eef2ff;
  border-radius: 999px;
  padding: 3px 7px;
}
.mw-related-main {
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
  flex: 1;
}
.mw-related-meta {
  display: flex;
  gap: 4px;
  flex-wrap: wrap;
  margin-bottom: 1px;
}
.mw-related-chip {
  display: inline-flex;
  align-items: center;
  padding: 2px 6px;
  border-radius: 999px;
  font-size: 10px;
  font-weight: 700;
  line-height: 1.2;
}
.mw-related-chip-cat {
  background: #e2e8f0;
  color: #334155;
}
.mw-related-chip-status {
  background: #fef3c7;
  color: #92400e;
}
.mw-related-topic {
  font-size: 12px;
  font-weight: 700;
  color: #0f172a;
}
.mw-related-summary {
  font-size: 11px;
  color: #64748b;
  line-height: 1.5;
}
.mw-related-empty {
  padding: 10px;
  border: 1px dashed #d1d5db;
  border-radius: 8px;
  font-size: 12px;
  color: #94a3b8;
  background: #f8fafc;
}
.mw-related-remove {
  flex: 0 0 auto;
  align-self: center;
  padding: 4px 8px;
  border: 1px solid #fecaca;
  border-radius: 999px;
  background: #fff1f2;
  color: #be123c;
  font-size: 11px;
  cursor: pointer;
}
.mw-related-remove:hover {
  background: #ffe4e6;
}

/* ── 템플릿 패널 ── */
.mw-tpl-panel {
  background: #fff;
  border: 1px solid #e2e8f0;
  border-radius: 10px;
  padding: 10px;
  margin-bottom: 10px;
}
.mw-tpl-title { font-size: 11px; font-weight: 700; color: #64748b; margin-bottom: 7px; text-transform: uppercase; letter-spacing:.05em; }
.mw-tpl-btns  { display: flex; flex-wrap: wrap; gap: 5px; }
.mw-tpl-btn {
  padding: 5px 10px;
  border: 1px solid #e2e8f0;
  border-radius: 7px;
  background: #f8fafc;
  cursor: pointer;
  font-size: 11px;
  color: #374151;
  white-space: nowrap;
}
.mw-tpl-btn:hover { background: #f1f5f9; }
.mw-tpl-btn[data-cat="work"]     { border-color: #fcd34d; color: #78350f; background: #fef9c3; }
.mw-tpl-btn[data-cat="code"]     { border-color: #c4b5fd; color: #4c1d95; background: #ede9fe; }
.mw-tpl-btn[data-cat="material"] { border-color: #86efac; color: #14532d; background: #dcfce7; }
.mw-tpl-btn[data-cat="problem"]  { border-color: #fda4af; color: #881337; background: #ffe4e6; }
.mw-tpl-btn[data-cat="idea"]     { border-color: #93c5fd; color: #1e3a8a; background: #dbeafe; }
.mw-site-sync-wrap {
  margin-top: 10px;
  padding-top: 10px;
  border-top: 1px dashed #dbe4f0;
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}
.mw-site-sync-help {
  font-size: 11px;
  color: #64748b;
}
.mw-quick-panel {
  background: #fff;
  border: 1px solid #dbe4f0;
  border-radius: 10px;
  padding: 10px;
  margin-bottom: 10px;
}
.mw-quick-title {
  font-size: 12px;
  font-weight: 800;
  color: #0f172a;
}
.mw-quick-help {
  margin-top: 4px;
  font-size: 11px;
  color: #64748b;
  line-height: 1.5;
}
.mw-quick-row {
  display: flex;
  gap: 6px;
  margin-top: 8px;
  align-items: center;
}
.mw-quick-inline-help {
  font-size: 11px;
  color: #64748b;
  line-height: 1.4;
}
.mw-quick-row .mw-search-input {
  margin: 0;
}
.mw-advanced-toggle {
  margin-top: 8px;
}
.mw-advanced-wrap {
  margin-top: 8px;
}

/* ── 보관 목록 ── */
.mw-archive-btn {
  width: 100%;
  padding: 8px;
  border: 1px dashed #cbd5e1;
  border-radius: 8px;
  background: transparent;
  cursor: pointer;
  font-size: 11px;
  color: #64748b;
  margin-top: 8px;
}
.mw-archive-btn:hover { background: #f8fafc; }
.mw-archive-list {
  margin-top: 8px;
  border: 1px solid #e2e8f0;
  border-radius: 8px;
  overflow: hidden;
  display: none;
}
.mw-archive-list.open { display: block; }
.mw-archive-item {
  padding: 8px 10px;
  border-bottom: 1px solid #f1f5f9;
  font-size: 12px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: #fff;
}
.mw-archive-item:last-child { border-bottom: none; }
.mw-archive-item-title { color: #475569; text-decoration: line-through; }

/* ── 탭 (편집 / 관계 / 보관) ── */
.mw-tabs {
  display: flex;
  gap: 0;
  border-bottom: 1px solid #e2e8f0;
  margin-bottom: 12px;
  flex-shrink: 0;
}
.mw-tab {
  padding: 7px 12px;
  font-size: 12px;
  font-weight: 600;
  color: #64748b;
  cursor: pointer;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
  white-space: nowrap;
}
.mw-tab.active { color: #1565ff; border-bottom-color: #1565ff; }
.mw-tab-pane   { display: none; }
.mw-tab-pane.active { display: block; }

/* ── 관계 하이라이트 ── */
#mwMap me-parent.mw-rel-current me-tpc,
#mwMap me-root.mw-rel-current me-tpc {
  box-shadow: 0 0 0 3px rgba(21, 101, 255, 0.32), 0 8px 24px rgba(21, 101, 255, 0.18);
}
#mwMap me-parent.mw-rel-outgoing me-tpc,
#mwMap me-root.mw-rel-outgoing me-tpc {
  box-shadow: 0 0 0 3px rgba(16, 185, 129, 0.28), 0 6px 18px rgba(16, 185, 129, 0.14);
}
#mwMap me-parent.mw-rel-incoming me-tpc,
#mwMap me-root.mw-rel-incoming me-tpc {
  box-shadow: 0 0 0 3px rgba(249, 115, 22, 0.28), 0 6px 18px rgba(249, 115, 22, 0.14);
}
#mwMap.mw-rel-focus-on me-parent.mw-rel-muted,
#mwMap.mw-rel-focus-on me-root.mw-rel-muted {
  opacity: 0.22;
  filter: saturate(0.25);
}
#mwMap.mw-rel-focus-on me-parent:not(.mw-rel-muted),
#mwMap.mw-rel-focus-on me-root:not(.mw-rel-muted) {
  opacity: 1;
}

/* ── 내용 미리보기 모달 ── */
.mw-preview-modal {
  position: fixed;
  inset: 0;
  z-index: 1400;
}
.mw-preview-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(15, 23, 42, .45);
}
.mw-preview-dialog {
  position: relative;
  width: min(920px, calc(100vw - 32px));
  margin: 40px auto;
  background: #fff;
  border-radius: 16px;
  border: 1px solid #dbe4f0;
  box-shadow: 0 18px 60px rgba(15, 23, 42, .18);
  padding: 16px;
}
.mw-preview-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
  margin-bottom: 12px;
}
.mw-preview-title {
  font-size: 16px;
  font-weight: 800;
  color: #0f172a;
}
.mw-preview-sub {
  font-size: 12px;
  color: #64748b;
  margin-top: 4px;
}
.mw-preview-actions {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}
.mw-preview-output {
  width: 100%;
  min-height: 68vh;
  padding: 14px;
  border: 1px solid #d1d5db;
  border-radius: 12px;
  background: #f8fafc;
  color: #111827;
  font-size: 13px;
  line-height: 1.7;
  font-family: "Malgun Gothic", sans-serif;
  resize: vertical;
  box-sizing: border-box;
  white-space: pre-wrap;
}
.mw-preview-tree {
  min-height: 68vh;
  max-height: 72vh;
  overflow: auto;
  padding: 8px;
  border: 1px solid #d1d5db;
  border-radius: 12px;
  background: #f8fafc;
}
.mw-pv-node {
  margin-bottom: 6px;
}
.mw-pv-row {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  padding: 6px 8px;
  border-radius: 8px;
}
.mw-pv-row:hover {
  background: #eef2ff;
}
.mw-pv-toggle {
  width: 24px;
  height: 24px;
  flex: 0 0 24px;
  border: 1px solid #cbd5e1;
  border-radius: 6px;
  background: #fff;
  color: #334155;
  cursor: pointer;
  font-size: 12px;
  line-height: 1;
}
.mw-pv-toggle.is-leaf {
  opacity: .45;
  cursor: default;
}
.mw-pv-content {
  min-width: 0;
  flex: 1;
}
.mw-pv-title {
  font-size: 13px;
  font-weight: 700;
  color: #0f172a;
}
.mw-pv-text {
  margin-top: 2px;
  font-size: 12px;
  color: #475569;
  line-height: 1.6;
  white-space: pre-wrap;
}
.mw-pv-children {
  margin-left: 28px;
  padding-left: 10px;
  border-left: 1px dashed #cbd5e1;
}
.mw-pv-children.is-collapsed {
  display: none;
}

/* ── 반응형 ── */
@media (max-width: 1200px) {
  .mw-body { grid-template-columns: 1fr; }
  .mw-map-wrap { height: 500px; }
  .mw-panel { max-height: none; }
}
@media (max-width: 680px) {
  .mw-header  { flex-direction: column; }
  .mw-toolbar { gap: 4px; }
  .mw-search-input { min-width: 100px; }
  .mw-storage-state { width: 100%; border-radius: 8px; }
  .mw-quick-row { flex-direction: column; align-items: stretch; }
  .mw-preview-dialog { width: calc(100vw - 16px); margin: 12px auto; padding: 12px; }
  .mw-preview-head { flex-direction: column; }
  .mw-preview-tree { min-height: 72vh; }
}
