@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600&display=swap');

:root[data-theme="light"] {
  --text-50: #f4f0f4;
  --text-100: #e9e2e9;
  --text-200: #d4c4d4;
  --text-300: #bea7be;
  --text-400: #a88aa8;
  --text-500: #936c93;
  --text-600: #755775;
  --text-700: #584158;
  --text-800: #3b2b3b;
  --text-900: #1d161d;
  --text-950: #0f0b0f;

  --background-50: #f5eff5;
  --background-100: #ebdfec;
  --background-200: #d6bfd9;
  --background-300: #c29fc6;
  --background-400: #ad80b3;
  --background-500: #99609f;
  --background-600: #7a4d80;
  --background-700: #5c3960;
  --background-800: #3d2640;
  --background-900: #1f1320;
  --background-950: #0f0a10;

  --primary-50: #f6eef6;
  --primary-100: #ecddee;
  --primary-200: #d9bcdc;
  --primary-300: #c69acb;
  --primary-400: #b378ba;
  --primary-500: #a057a8;
  --primary-600: #804587;
  --primary-700: #603465;
  --primary-800: #402343;
  --primary-900: #201122;
  --primary-950: #100911;

  --secondary-50: #f7edf7;
  --secondary-100: #eedbf0;
  --secondary-200: #ddb7e1;
  --secondary-300: #cd93d2;
  --secondary-400: #bc6fc3;
  --secondary-500: #ab4bb4;
  --secondary-600: #893c90;
  --secondary-700: #672d6c;
  --secondary-800: #441e48;
  --secondary-900: #220f24;
  --secondary-950: #110812;

  --accent-50: #f8ecf9;
  --accent-100: #f0d9f2;
  --accent-200: #e1b3e6;
  --accent-300: #d28cd9;
  --accent-400: #c366cc;
  --accent-500: #b540bf;
  --accent-600: #903399;
  --accent-700: #6c2673;
  --accent-800: #48194d;
  --accent-900: #240d26;
  --accent-950: #120613;

  --border-color: var(--text-200);
  --header-bg: var(--background-50);
  --sidebar-bg: var(--background-100);
  --panel-bg: #ffffff;
  --shadow-sm: 0 1px 3px rgba(0,0,0,0.1);
  --shadow-md: 0 4px 6px rgba(0,0,0,0.1);
  --selection-color: rgba(160, 87, 168, 0.4);
}

:root[data-theme="dark"] {
  --text-50: #0f0b0f;
  --text-100: #1d161d;
  --text-200: #3a2c3a;
  --text-300: #574257;
  --text-400: #745874;
  --text-500: #916e91;
  --text-600: #a78ba7;
  --text-700: #bda8bd;
  --text-800: #d3c5d3;
  --text-900: #e9e2e9;
  --text-950: #f4f0f4;

  --background-50: #0f0a10;
  --background-100: #1f1320;
  --background-200: #3d2640;
  --background-300: #5c3960;
  --background-400: #7a4d80;
  --background-500: #99609f;
  --background-600: #ad80b3;
  --background-700: #c29fc6;
  --background-800: #d6bfd9;
  --background-900: #ebdfec;
  --background-950: #f5eff5;

  --primary-50: #100911;
  --primary-100: #201122;
  --primary-200: #402343;
  --primary-300: #603465;
  --primary-400: #804587;
  --primary-500: #a057a8;
  --primary-600: #b378ba;
  --primary-700: #c69acb;
  --primary-800: #d9bcdc;
  --primary-900: #ecddee;
  --primary-950: #f6eef6;

  --secondary-50: #110812;
  --secondary-100: #220f24;
  --secondary-200: #441e48;
  --secondary-300: #672d6c;
  --secondary-400: #893c90;
  --secondary-500: #ab4bb4;
  --secondary-600: #bc6fc3;
  --secondary-700: #cd93d2;
  --secondary-800: #ddb7e1;
  --secondary-900: #eedbf0;
  --secondary-950: #f7edf7;

  --accent-50: #120613;
  --accent-100: #240d26;
  --accent-200: #48194d;
  --accent-300: #6c2673;
  --accent-400: #903399;
  --accent-500: #b540bf;
  --accent-600: #c366cc;
  --accent-700: #d28cd9;
  --accent-800: #e1b3e6;
  --accent-900: #f0d9f2;
  --accent-950: #f8ecf9;

  --border-color: var(--text-200);
  --header-bg: var(--background-50);
  --sidebar-bg: var(--background-100);
  --panel-bg: #1f1320;
  --shadow-sm: 0 1px 3px rgba(0,0,0,0.5);
  --shadow-md: 0 4px 6px rgba(0,0,0,0.5);
  --selection-color: rgba(160, 87, 168, 0.4);
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: 'Inter', sans-serif;
  background-color: var(--background-50);
  color: var(--text-900);
  overflow: hidden;
  user-select: none;
}

/* Base Layout */
.app-container {
  display: flex;
  flex-direction: column;
  height: 100vh;
  width: 100vw;
}

/* Header */
.header {
  height: 56px;
  background-color: var(--header-bg);
  border-bottom: 1px solid var(--border-color);
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0 20px;
  z-index: 100;
  box-shadow: var(--shadow-sm);
}
.header-left, .header-right {
  display: flex;
  align-items: center;
  gap: 16px;
}
.logo {
  display: flex;
  align-items: center;
  gap: 8px;
}
.logo-icon {
  width: 24px;
  height: 24px;
  object-fit: contain;
}
.logo span {
  font-size: 24px;
  font-weight: 600;
  letter-spacing: -0.5px;
  background: linear-gradient(90deg, var(--primary-500) 0%, var(--accent-400) 100%);
  -webkit-background-clip: text;
  color: transparent;
}
.project-title {
  background: transparent;
  border: 1px solid transparent;
  color: var(--text-900);
  font-size: 16px;
  font-weight: 500;
  padding: 4px 8px;
  border-radius: 4px;
  transition: all 0.2s;
  width: 200px;
}
.project-title:hover {
  background: var(--background-100);
}
.project-title:focus {
  border-color: var(--primary-400);
  outline: none;
  background: var(--panel-bg);
}

/* Buttons */
.btn {
  padding: 8px 16px;
  border-radius: 6px;
  border: none;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s;
}
.btn-primary {
  background-color: var(--primary-500);
  color: #fff;
}
.btn-primary:hover {
  background-color: var(--primary-600);
}
.btn-success {
  background-color: var(--secondary-500);
  color: #fff;
}
.btn-success:hover {
  background-color: var(--secondary-600);
}
.btn-secondary {
  background-color: transparent;
  color: var(--text-900);
  border: 1px solid var(--border-color);
}
.btn-secondary:hover {
  background-color: var(--background-200);
}
.btn-icon {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  border: none;
  background-color: var(--text-900);
  color: var(--background-50);
  font-weight: bold;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}
.btn-icon:hover {
  background-color: var(--text-700);
}
.btn-full {
  width: 100%;
  margin-top: 16px;
}

/* Main Content */
.main-content {
  display: flex;
  flex: 1;
  overflow: hidden;
  position: relative;
}

/* Canvas Area */
.canvas-container {
  flex: 1;
  position: relative;
  background-color: var(--background-50);
  overflow: auto;
  cursor: grab;
}
.canvas-container::-webkit-scrollbar {
  width: 12px;
  height: 12px;
}
.canvas-container::-webkit-scrollbar-track {
  background: transparent;
}
.canvas-container::-webkit-scrollbar-thumb {
  background: var(--background-300);
  border-radius: 6px;
  border: 3px solid var(--background-50);
}
.canvas-container::-webkit-scrollbar-thumb:hover {
  background: var(--background-400);
}
.canvas-container:active {
  cursor: grabbing;
}
.canvas-board {
  position: absolute;
  transform-origin: 0 0;
  width: 10000px;
  height: 10000px;
}
#edges-layer {
  position: absolute;
  top: 0;
  left: 0;
  overflow: visible;
  pointer-events: none; /* Let clicks pass through to nodes */
}
#nodes-layer {
  position: absolute;
  top: 0;
  left: 0;
}

/* Mindmap Nodes */
.mind-node {
  position: absolute;
  border-radius: 15px;
  padding: 12px 24px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  min-width: 100px;
  max-width: 800px;
  word-break: break-word;
  white-space: pre-wrap;
  user-select: none;
  box-shadow: var(--shadow-sm);
  transition: box-shadow 0.2s;
  will-change: transform;
  resize: both;
  overflow: hidden;
}
.mind-node:hover {
  box-shadow: 0 0 0 3px rgba(160, 87, 168, 0.3);
}
.mind-node.selected {
  box-shadow: 0 0 0 4px var(--primary-500);
  z-index: 10;
}
/* Focus state for editing text */
.mind-node[contenteditable="true"] {
  cursor: text;
  outline: none;
  box-shadow: 0 0 0 4px var(--accent-500);
  user-select: text;
}

/* SVG Line Path */
.edge-path {
  fill: none;
  stroke: var(--text-400);
  stroke-width: 2px;
  transition: stroke 0.2s;
}
.edge-path.selected {
  stroke: var(--primary-500);
  stroke-width: 3px;
}

/* Selection Box (for multi-select) */
.selection-box {
  position: absolute;
  border: 1px solid var(--primary-400);
  background-color: var(--selection-color);
  pointer-events: none;
  z-index: 1000;
}

/* Sidebar */
.sidebar {
  width: 320px;
  background-color: var(--sidebar-bg);
  border-left: 1px solid var(--border-color);
  display: flex;
  flex-direction: column;
  overflow-y: auto;
  z-index: 50;
  box-shadow: -2px 0 5px rgba(0,0,0,0.05);
}
.sidebar-section {
  padding: 20px;
  border-bottom: 1px solid var(--border-color);
}
.section-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 16px;
}
.section-header h3 {
  font-size: 16px;
  font-weight: 600;
  color: var(--text-900);
}
.style-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.style-preset-item {
  padding: 10px;
  border-radius: 8px;
  border: 1px solid var(--border-color);
  background-color: var(--panel-bg);
  display: flex;
  align-items: center;
  justify-content: space-between;
  cursor: pointer;
  transition: all 0.2s;
}
.style-preset-item:hover {
  border-color: var(--primary-400);
}
.style-preset-item.active {
  border-color: var(--primary-500);
  box-shadow: 0 0 0 2px rgba(160, 87, 168, 0.2);
}
.style-preview-box {
  width: 60px;
  height: 30px;
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 10px;
  font-weight: 600;
  overflow: hidden;
}
.style-name {
  font-size: 14px;
  color: var(--text-800);
  flex: 1;
  margin-left: 12px;
}

/* Properties Forms */
.prop-group {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 12px;
}
.prop-group label {
  font-size: 14px;
  color: var(--text-700);
}
.prop-group input[type="number"],
.prop-group input[type="text"] {
  width: 80px;
  padding: 6px;
  border: 1px solid var(--border-color);
  border-radius: 4px;
  background-color: var(--panel-bg);
  color: var(--text-900);
  text-align: right;
}
.prop-group input[type="color"] {
  width: 40px;
  height: 28px;
  padding: 0;
  border: 1px solid var(--border-color);
  border-radius: 4px;
  cursor: pointer;
  background-color: transparent;
}

/* Floating Zoom Control */
.floating-zoom {
  position: absolute;
  right: 340px; /* 320px sidebar + 20px margin */
  bottom: 20px;
  background-color: var(--panel-bg);
  border: 1px solid var(--border-color);
  border-radius: 20px;
  display: flex;
  align-items: center;
  padding: 4px;
  box-shadow: var(--shadow-md);
  z-index: 100;
}
.zoom-btn {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  border: none;
  background-color: transparent;
  color: var(--text-900);
  font-size: 18px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}
.zoom-btn:hover {
  background-color: var(--background-100);
}
.zoom-display {
  position: relative;
  padding: 0 12px;
  font-size: 14px;
  font-weight: 500;
  color: var(--text-900);
  cursor: pointer;
  min-width: 60px;
  text-align: center;
}
.zoom-presets {
  position: absolute;
  bottom: 100%;
  left: 50%;
  transform: translateX(-50%);
  margin-bottom: 8px;
  background-color: var(--panel-bg);
  border: 1px solid var(--border-color);
  border-radius: 8px;
  list-style: none;
  padding: 4px 0;
  box-shadow: var(--shadow-md);
  min-width: 80px;
}
.zoom-presets li {
  padding: 8px 16px;
  text-align: center;
  cursor: pointer;
}
.zoom-presets li:hover {
  background-color: var(--background-100);
}

/* Context Menu */
.context-menu {
  position: absolute;
  background-color: var(--panel-bg);
  border: 1px solid var(--border-color);
  border-radius: 8px;
  box-shadow: var(--shadow-md);
  list-style: none;
  padding: 4px 0;
  min-width: 180px;
  z-index: 1000;
}
.context-menu li {
  padding: 8px 16px;
  font-size: 14px;
  color: var(--text-900);
  cursor: pointer;
  display: flex;
  justify-content: space-between;
}
.context-menu li:hover {
  background-color: var(--primary-100);
  color: var(--primary-900);
}
.context-menu li.disabled {
  color: var(--text-400);
  cursor: not-allowed;
}
.context-menu li.disabled:hover {
  background-color: transparent;
  color: var(--text-400);
}
.context-menu li span {
  color: var(--text-500);
  font-size: 12px;
}

/* Modal Overlay */
.modal-overlay {
  position: absolute;
  top: 0; left: 0; width: 100vw; height: 100vh;
  background: rgba(0,0,0,0.6);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 2000;
}
.modal-content {
  background: var(--panel-bg);
  padding: 24px;
  border-radius: 12px;
  width: 400px;
  box-shadow: var(--shadow-md);
  display: flex;
  flex-direction: column;
  gap: 16px;
}
.modal-content h3 {
  margin: 0;
  font-size: 18px;
  color: var(--text-900);
}
.modal-content textarea {
  width: 100%;
  padding: 12px;
  border-radius: 8px;
  border: 1px solid var(--border-color);
  background: var(--background-50);
  color: var(--text-900);
  font-family: inherit;
  font-size: 16px;
  resize: vertical;
}
.modal-content textarea:focus {
  outline: none;
  border-color: var(--primary-500);
}
.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
}
