/* Create page styles - incorporating shared module */

/* Import shared styles for transitions and base node styling */
/* Note: In production, use @import or link separate CSS file */

/* ── 主题配色变量 (与 presenter 共享，14组) ── */
:root {
  --node-color: #183a4a;
  --link-color: rgba(42, 55, 68, 0.3);
  --bg: #ffffff;
  --text: #172033;
}

/* 1. Classic 经典 — 蓝色系，专业沉稳 */
[data-theme="classic"] {
  --node-color: #2b5ea7;
  --link-color: rgba(43, 94, 167, 0.28);
  --bg: #ffffff;
  --text: #1a2744;
}

/* 2. Deep Sea 深海 — 墨蓝深邃 */
[data-theme="deepsea"] {
  --node-color: #1a3558;
  --link-color: rgba(26, 53, 88, 0.28);
  --bg: #ffffff;
  --text: #142840;
}

/* 3. Iris 鸢尾 — 紫罗兰优雅 */
[data-theme="iris"] {
  --node-color: #5c3d7a;
  --link-color: rgba(92, 61, 122, 0.28);
  --bg: #ffffff;
  --text: #2d1a4a;
}

/* 4. Red Maple 红枫 — 秋日红棕 */
[data-theme="redmaple"] {
  --node-color: #8b3a2f;
  --link-color: rgba(139, 58, 47, 0.28);
  --bg: #ffffff;
  --text: #3a1a15;
}

/* 5. Grayscale 灰度 — 极简黑白灰 */
[data-theme="grayscale"] {
  --node-color: #333333;
  --link-color: rgba(51, 51, 51, 0.18);
  --bg: #ffffff;
  --text: #1a1a1a;
}

/* 6. Forest 森林 — 墨绿自然 */
[data-theme="forest"] {
  --node-color: #2d5a27;
  --link-color: rgba(45, 90, 39, 0.28);
  --bg: #ffffff;
  --text: #1a3a18;
}

/* 7. Wheat 麦田 — 金黄温暖 */
[data-theme="wheat"] {
  --node-color: #7a5c1e;
  --link-color: rgba(122, 92, 30, 0.28);
  --bg: #ffffff;
  --text: #3a2a0a;
}

/* 8. Gold 醇金 — 华丽金色 */
[data-theme="gold"] {
  --node-color: #8b6914;
  --link-color: rgba(139, 105, 20, 0.28);
  --bg: #ffffff;
  --text: #3a2800;
}

/* 9. Violet 紫罗兰 — 浪漫紫粉 */
[data-theme="violet"] {
  --node-color: #6b4c8a;
  --link-color: rgba(107, 76, 138, 0.28);
  --bg: #ffffff;
  --text: #2d1a40;
}

/* 10. Grass 青草 — 清新草绿 */
[data-theme="grass"] {
  --node-color: #3d7a3d;
  --link-color: rgba(61, 122, 61, 0.28);
  --bg: #ffffff;
  --text: #1a3a1a;
}

/* 11. Obsidian 黑曜石 — 暗夜神秘 */
[data-theme="obsidian"] {
  --node-color: #1a2533;
  --link-color: rgba(26, 37, 51, 0.28);
  --bg: #ffffff;
  --text: #0d1520;
}

/* 12. Flame 烈焰 — 火焰橙红 */
[data-theme="flame"] {
  --node-color: #c44a1a;
  --link-color: rgba(196, 74, 26, 0.28);
  --bg: #ffffff;
  --text: #3a1a0a;
}

/* 13. Coral 珊瑚 — 温暖珊瑚粉 */
[data-theme="coral"] {
  --node-color: #b84a5a;
  --link-color: rgba(184, 74, 90, 0.28);
  --bg: #ffffff;
  --text: #3a1a20;
}

/* 14. Rainbow 彩虹 — 层级彩色 */
[data-theme="rainbow"] {
  --node-color: #2b5ea7;
  --link-color: rgba(100, 100, 100, 0.3);
  --bg: #ffffff;
  --text: #1a1a1a;
}

/* ── Create Editor Layout ── */
.create-editor {
  display: flex;
  flex-direction: column;
  height: 100vh;
  background: var(--bg, #fff);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  color: var(--text, #0F172A);
}

/* ── Toolbar ── */
.create-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 16px;
  background: #fff;
  border-bottom: 1px solid #e2e8f0;
  box-shadow: 0 1px 3px rgba(0,0,0,0.06);
  z-index: 10;
}

.toolbar-left, .toolbar-center, .toolbar-right {
  display: flex;
  align-items: center;
  gap: 8px;
}

.toolbar-center { gap: 12px; }

.toolbar-select {
  padding: 6px 10px;
  border: 1px solid #e2e8f0;
  border-radius: 6px;
  background: #fff;
  font-size: 13px;
  color: #334155;
  cursor: pointer;
}

.toolbar-select:hover { border-color: #94a3b8; }

/* ── Buttons ── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 7px 14px;
  border: 1px solid #e2e8f0;
  border-radius: 6px;
  background: #fff;
  font-size: 13px;
  font-weight: 500;
  color: #334155;
  cursor: pointer;
  white-space: nowrap;
  transition: all 0.15s;
}

.btn:hover { background: #f8fafc; border-color: #cbd5e1; }
.btn:disabled { opacity: 0.4; cursor: not-allowed; }

.btn-primary {
  background: #2563EB;
  color: #fff;
  border-color: #2563EB;
}

.btn-primary:hover { background: #1d4ed8; }

.btn-ghost {
  border-color: transparent;
  background: transparent;
}

.btn-ghost:hover { background: #f1f5f9; }
.btn-ghost:disabled:hover { background: transparent; }

.btn-sm { padding: 4px 10px; font-size: 12px; }

a.btn {
  text-decoration: none;
}

/* ── Canvas ── */
.create-canvas {
  flex: 1;
  position: relative;
  overflow: hidden;
  background: var(--bg, #fff);
}

#createSvg {
  position: absolute;
  top: 0; left: 0;
  width: 100%; height: 100%;
}

/* ── Node Layer ── */
.node-layer {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  transform-origin: 0 0;
}

/* ── Node Transitions (from shared) ── */
.mind-node {
  position: absolute;
  border-radius: 8px;
  border: 2px solid var(--node-color, #2563EB);
  background: #fff;
  cursor: pointer;
  user-select: none;
  pointer-events: auto;
  box-sizing: border-box;
  transform-origin: center center;
  /* Smooth transitions for position and size */
  transition:
    transform 420ms cubic-bezier(0.22, 1, 0.36, 1),
    width 320ms cubic-bezier(0.22, 1, 0.36, 1),
    height 320ms cubic-bezier(0.22, 1, 0.36, 1),
    opacity 220ms ease,
    box-shadow 180ms ease,
    border-color 180ms ease,
    background-color 180ms ease;
}

.mind-node.entering {
  opacity: 0;
}

.mind-node.leaving {
  opacity: 0;
  pointer-events: none;
}

.mind-node:hover {
  box-shadow: 0 2px 12px rgba(0,0,0,0.12);
}

.mind-node.selected {
  box-shadow: 0 0 0 3px rgba(37,99,235,0.3), 0 2px 12px rgba(0,0,0,0.12);
}

.mind-node.is-root {
  border-width: 3px;
  background: var(--node-color, #2563EB);
}

/* ── Node Content ── */
.node-content {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  width: 100%;
  height: 100%;
  padding: 10px 12px;
  text-align: center;
  font-size: 14px;
  line-height: 1.4;
  color: var(--text, #0F172A);
  overflow: hidden;
  border-radius: 6px;
  transition:
    background 180ms ease,
    transform 180ms ease,
    box-shadow 180ms ease;
  box-sizing: border-box;
}

.mind-node.is-root .node-content {
  color: #fff;
  font-weight: 600;
  font-size: 16px;
}

.node-subtitle {
  display: none;
  font-size: 12px;
  color: #64748B;
  margin-bottom: 4px;
}

.node-content.has-subtitle {
  flex-direction: column;
}

.node-content.has-subtitle .node-subtitle {
  display: block;
}

.node-title {
  white-space: pre-wrap;
  word-break: break-word;
}

/* ── Editing Style (XMind-like: blue bg + white text + scale) ── */
.mind-node.editing {
  z-index: 10;
}

.mind-node.editing .node-content {
  background: var(--node-color, #2563EB);
  box-shadow: 0 4px 16px rgba(37, 99, 235, 0.25);
  transform: scale(1.08);
  /* Don't remove padding - keeps size consistent */
}

.mind-node.editing.is-root .node-content {
  box-shadow: 0 6px 20px rgba(37, 99, 235, 0.35);
}

.mind-node.editing .node-title {
  color: #fff;
  font-weight: 600;
}

.mind-node.editing .node-subtitle {
  color: rgba(255, 255, 255, 0.8);
}

/* ── Node Editor (textarea) ── */
.node-editor {
  display: none;
  width: 100%;
  height: 100%;
  border: none;
  border-radius: 6px;
  background: transparent;
  color: #fff;
  font-size: 16px;
  font-weight: 600;
  line-height: 1.4; /* ~22px for 16px font */
  resize: none;
  white-space: pre-wrap;
  overflow: hidden;
  text-align: center;
  box-sizing: border-box;
  /* Calculate padding to center text vertically:
     Node height ~40px, line-height ~22px
     padding = (40 - 22) / 2 ≈ 9px */
  padding: 9px 12px;
}

.node-editor:focus {
  outline: none;
}

/* When editing, remove node-content padding so textarea takes full space */
.mind-node.editing .node-content {
  padding: 0;
}

.mind-node.editing .node-editor {
  display: block;
}

.mind-node.editing .node-title,
.mind-node.editing .node-subtitle {
  display: none;
}

/* ── Collapse Toggle Button ── */
.collapse-toggle {
  position: absolute;
  right: -8px;
  top: 50%;
  transform: translateY(-50%);
  width: 16px;
  height: 16px;
  border-radius: 50%;
  border: 1px solid var(--node-color, #2563EB);
  background: #fff;
  color: var(--node-color, #2563EB);
  font-size: 10px;
  line-height: 16px;
  text-align: center;
  padding: 0;
  cursor: pointer;
  z-index: 5;
  transition: background 150ms ease, color 150ms ease;
}

.collapse-toggle:hover {
  background: var(--node-color, #2563EB);
  color: #fff;
}

.collapse-toggle.left-side {
  right: auto;
  left: -8px;
}

/* ── Auto save status ── */
.auto-save-status {
  font-size: 12px;
  color: #94a3b8;
  margin-right: 8px;
  opacity: 0;
  transition: opacity 0.3s;
}

/* ── Links (SVG) ── */
.mind-link {
  fill: none;
  stroke-width: 2;
  stroke-linecap: round;
  stroke: var(--link-color, #94A3B8);
  opacity: 0.6;
  /* Smooth transition for path changes */
  transition: d 520ms cubic-bezier(0.22, 1, 0.36, 1), opacity 220ms ease;
}

.mind-link.entering {
  animation: link-draw 920ms cubic-bezier(0.22, 1, 0.36, 1) both;
}

.mind-link.leaving {
  opacity: 0;
}

@keyframes link-draw {
  from {
    stroke-dashoffset: 1;
  }
  to {
    stroke-dashoffset: 0;
  }
}

/* ── Hints bar ── */
.create-hints {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 16px;
  padding: 6px 16px;
  background: #f8fafc;
  border-top: 1px solid #e2e8f0;
  font-size: 12px;
  color: #94a3b8;
}

.create-hints span {
  display: flex;
  align-items: center;
  gap: 4px;
}

/* ── Node Measurer (hidden) ── */
.node-measurer {
  position: fixed;
  top: -10000px;
  left: -10000px;
  visibility: hidden;
  pointer-events: none;
}

/* ── Responsive ── */
@media (max-width: 768px) {
  .create-toolbar { flex-wrap: wrap; gap: 6px; padding: 6px 10px; }
  .toolbar-center { order: 3; width: 100%; justify-content: center; }
  .create-hints { flex-wrap: wrap; gap: 8px; }
}