/* === Consolidated base styles from root styles.css === */
/* Local font declarations - only declare fonts that exist in ./fonts */
@font-face {
  font-family: 'Roboto Slab';
  src: url('../fonts/Roboto-Slab-Regular.woff2') format('woff2');
  font-weight: normal;
  font-style: normal;
  font-display: swap;
}

@font-face {
  font-family: 'Ubuntu Mono';
  src: url('../fonts/UbuntuMono-Regular.ttf') format('truetype');
  font-weight: normal;
  font-style: normal;
  font-display: swap;
}

@font-face {
  font-family: 'Sofia Sans';
  src: url('../fonts/sofia-pro.woff2') format('woff2');
  font-weight: normal;
  font-style: normal;
  font-display: swap;
}

@font-face {
  font-family: 'Sailec Light';
  src: url('../fonts/sailec-light.woff2') format('woff2');
  font-weight: normal;
  font-style: normal;
  font-display: swap;
}

/* CSS Variables */
:root {
  --primary: hsl(210, 60%, 70%);
  --background: hsl(0, 0%, 96%);
  --accent: hsl(270, 30%, 85%);
  --text: hsl(0, 0%, 20%);
  --border: hsl(0, 0%, 80%);
  --hover: hsl(210, 60%, 80%);


}

/* Reset and base styles */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  font-family: 'Sofia Sans', 'Roboto Slab', 'Ubuntu Mono', 'Sailec Light', sans-serif;
  background: var(--background);
  color: var(--text);
  line-height: 1.6;
}

/* Editor container */
.editor-container {
  max-width: 1200px;
  margin: 20px auto;
  background: white;
  border-radius: 8px;
  box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
  overflow: hidden;
}

/* Toolbar */
.toolbar {
  background: var(--primary);
  padding: 12px;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  border-bottom: 2px solid var(--border);
  height: 48px;
  /* Match tree header height */
  box-sizing: border-box;
}

.toolbar-group {
  display: flex;
  gap: 4px;
  align-items: center;
  padding: 0 8px;
  border-right: 1px solid rgba(255, 255, 255, 0.3);
}

.toolbar-group:last-child {
  border-right: none;
}

.toolbar button,
.toolbar select {
  background: white;
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 6px 12px;
  cursor: pointer;
  font-size: 14px;
  transition: all 0.2s;
  position: relative;
}

.toolbar button:hover,
.toolbar select:hover {
  background: var(--hover);
  color: white;
}

.toolbar button.active {
  background: var(--accent);
  color: white;
}

/* Color picker */
.color-picker-container {
  position: relative;
  display: inline-block;
}

/* List popover specific styling */
#listPopover {
  min-width: 200px;
  max-width: 250px;
  z-index: 1001;
  /* Higher than default popover z-index */
}

#listPopover .popover-content {
  padding: 8px;
}

.list-type-item {
  display: block;
  width: 100%;
  padding: 8px 12px;
  margin: 2px 0;
  background: white;
  border: 1px solid var(--border);
  border-radius: 4px;
  cursor: pointer;
  font-size: 14px;
  text-align: left;
  transition: all 0.2s;
}

.list-type-item:hover {
  background: var(--hover);
  color: white;
}

.color-picker {
  width: 30px;
  height: 30px;
  border: none;
  border-radius: 4px;
  cursor: pointer;
}

.popover {
  position: absolute;
  top: 100%;
  left: 0;
  background: white;
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 12px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
  z-index: 1000;
  display: none;
}

.popover.show {
  display: block;
}

/* Table picker */
.table-picker-container {
  position: relative;
  display: inline-block;
}

.table-picker {
  width: 240px;
  padding: 12px;
}

.table-grid {
  display: grid;
  grid-template-columns: repeat(10, 20px);
  grid-template-rows: repeat(8, 20px);
  gap: 1px;
  background: var(--border);
  padding: 4px;
  margin-bottom: 8px;
}

.table-cell {
  background: white;
  cursor: pointer;
  transition: background 0.1s;
  border: 1px solid transparent;
}

.table-cell:hover,
.table-cell.selected {
  background: var(--primary);
  border-color: var(--primary);
}

.table-size-display {
  text-align: center;
  font-size: 12px;
  color: var(--text);
  font-weight: 500;
}

/* Current entry display */
.current-entry-display {
  background: #f8f9fa;
  border: 1px solid #e9ecef;
  border-bottom: none;
  padding: 8px 16px;
  font-size: 13px;
  color: #6c757d;
  display: flex;
  align-items: center;
  justify-content: center;
}

.entry-title-input {
  background: transparent;
  border: none;
  outline: none;
  color: #007bff;
  font-weight: 500;
  font-style: italic;
  text-align: center;
  width: 100%;
  font-size: 13px;
  cursor: pointer;
}

.entry-title-input:not([readonly]) {
  background: white;
  border: 1px solid #007bff;
  border-radius: 3px;
  padding: 4px 8px;
  cursor: text;
}

/* Editor content */
.editor-content {
  min-height: 400px;
  padding: 20px;
  border: none;
  font-family: "Sofia Sans", sans-serif;
  outline: none;
  font-family: inherit;
  font-size: 16px;
  line-height: 1.6;
  resize: vertical;
  width: 100%;
}

.html-view {
  min-height: 400px;
  padding: 20px;
  font-family: 'Ubuntu Mono', monospace;
  font-size: 14px;
  border: none;
  outline: none;
  background: #f8f9fa;
  width: 100%;
  resize: vertical;
}

/* Modals */
.modal {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.5);
  display: none;
  justify-content: center;
  align-items: center;
  z-index: 2000;
}

.modal.show {
  display: flex;
}

.modal-content {
  background: white;
  padding: 24px;
  border-radius: 8px;
  width: 90%;
  max-width: 500px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.2);
}

.modal h3 {
  margin-bottom: 16px;
  color: var(--text);
}

.modal input,
.modal textarea {
  width: 100%;
  padding: 8px 12px;
  border: 1px solid var(--border);
  border-radius: 4px;
  margin-bottom: 12px;
  font-size: 14px;
}

.modal-buttons {
  display: flex;
  gap: 8px;
  justify-content: flex-end;
}

.modal button {
  padding: 8px 16px;
  border: 1px solid var(--border);
  border-radius: 4px;
  cursor: pointer;
  font-size: 14px;
}

.modal .btn-primary {
  background: var(--primary);
  color: white;
  border-color: var(--primary);
}

/* Fullscreen */
.fullscreen {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  max-width: none;
  margin: 0;
  border-radius: 0;
  z-index: 1500;
}

.fullscreen .editor-content {
  height: calc(100vh - 80px);
}

/* Rich text styling */
.editor-content h1 {
  font-size: 2.5em;
  font-weight: bold;
  margin: 0.67em 0;
}

.editor-content h2 {
  font-size: 2em;
  font-weight: bold;
  margin: 0.75em 0;
}

.editor-content h3 {
  font-size: 1.5em;
  font-weight: bold;
  margin: 0.83em 0;
}

.editor-content h4 {
  font-size: 1.2em;
  font-weight: bold;
  margin: 1em 0;
}

.editor-content h5 {
  font-size: 1em;
  font-weight: bold;
  margin: 1.17em 0;
}

.editor-content h6 {
  font-size: 0.83em;
  font-weight: bold;
  margin: 1.33em 0;
}

.editor-content blockquote {
  margin: 1em 0;
  padding: 16px 20px 16px 40px;
  border-left: 4px solid var(--primary);
  background: rgba(74, 144, 226, 0.05);
  font-style: italic;
  color: #555;
  border-radius: 0 4px 4px 0;
  position: relative;
  min-height: 40px;
}

.editor-content blockquote::before {
  content: '"';
  font-size: 3em;
  color: var(--primary);
  position: absolute;
  left: 12px;
  top: -5px;
  font-family: Georgia, serif;
  opacity: 0.3;
  line-height: 1;
}

.editor-content blockquote p {
  margin: 0;
  padding-left: 0;
}

.editor-content blockquote p:first-child {
  margin-top: 0;
}

.editor-content blockquote p:last-child {
  margin-bottom: 0;
}

/* Table styling (single source of truth) */
.editor-content table {
  border-collapse: collapse;
  table-layout: fixed;
  width: 100%;
  margin: 16px 0;
  border-radius: 8px;
  overflow: visible;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
  position: relative;
}

.editor-content th {
  background: var(--primary);
  color: white;
  padding: 12px;
  text-align: left;
  font-weight: 600;
  border-right: 1px solid rgba(255, 255, 255, 0.2);
  position: relative;
}

.editor-content td {
  padding: 12px;
  border-right: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
  position: relative;
}

.editor-content tr:nth-child(even) {
  background: #f8f9fa;
}

.editor-content hr {
  background: #dedede;
  border: 0;
  height: 4px;
  margin: 15px 0;
}

.page-break {
  height: 20px;
  margin: 20px 0;
  border-top: 2px dashed #c4c4c4;
  position: relative;
}

.page-break::after {
  content: "Page Break";
  background: #fff;
  border: 1px solid #c4c4c4;
  border-radius: 2px;
  box-shadow: 2px 2px 1px rgba(0, 0, 0, .15);
  color: #333;
  display: block;
  font-family: 'Sofia Sans', sans-serif;
  font-size: .75em;
  font-weight: 700;
  left: 50%;
  padding: .3em .6em;
  position: absolute;
  text-transform: uppercase;
  top: 50%;
  transform: translate(-50%, -50%);
  user-select: none;
  z-index: 1;
}

.blocks-visible * {
  outline: 1px dashed rgba(0, 123, 255, 0.3) !important;
}

/* Tooltip */
.tooltip {
  position: absolute;
  background: rgba(0, 0, 0, 0.8);
  color: white;
  padding: 4px 8px;
  border-radius: 4px;
  font-size: 12px;
  z-index: 1001;
  pointer-events: none;
  opacity: 0;
}

.tooltip.show {
  opacity: 1;
}

/* Image hover menu */
.image-container {
  position: relative;
  display: inline-block;
  margin: 10px 0;
}

.image-container img {
  display: block;
  max-width: 100%;
  height: auto;
  border-radius: 4px;
  transition: all 0.2s;
}

.image-container img:hover {
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

.image-menu {
  position: absolute;
  top: 8px;
  right: 8px;
  background: rgba(0, 0, 0, 0.8);
  border-radius: 6px;
  padding: 8px;
  display: none;
  flex-direction: column;
  gap: 4px;
  z-index: 100;
}

.image-container:hover .image-menu {
  display: flex;
}

.image-menu button {
  background: rgba(255, 255, 255, 0.9);
  border: none;
  border-radius: 4px;
  padding: 4px 8px;
  font-size: 11px;
  cursor: pointer;
  transition: background 0.2s;
}

.image-menu button:hover {
  background: white;
}

/* Removed duplicate - using the one below */

/* Table container and toolbar rules */
.table-container {
  position: relative;
  display: block;
  margin: 16px auto;
  clear: both;
  text-align: center;
  user-select: none;
  -webkit-user-select: none;
  -moz-user-select: none;
  -ms-user-select: none;
  overflow: visible;
  padding: 2px;
  isolation: isolate;
  -webkit-user-drag: none;
}

.table-container table {
  border: 1px double #b3b3b3;
  border-collapse: collapse;
  border-spacing: 0;
  overflow: hidden;
  display: inline-table;
  border-radius: 4px;
  transition: all 0.2s ease;
  position: relative;
  user-select: text;
  -webkit-user-select: text;
  -moz-user-select: text;
  -ms-user-select: text;
  -webkit-user-drag: none;
}

/* Resize handles */
.table-container table::after,
.editable-table::after {
  content: '';
  position: absolute;
  right: -2px;
  top: 0;
  bottom: 0;
  width: 4px;
  cursor: col-resize;
  background: transparent;
  z-index: 10;
}

.table-container table::before,
.editable-table::before {
  content: '';
  position: absolute;
  bottom: -2px;
  left: 0;
  right: 0;
  height: 4px;
  cursor: row-resize;
  background: transparent;
  z-index: 10;
}

/* Corner handle */
.table-container .table-resize-corner,
.editable-table>.table-resize-corner {
  position: absolute;
  bottom: -2px;
  right: -2px;
  width: 8px;
  height: 8px;
  cursor: nw-resize;
  background: transparent;
  z-index: 15;
  pointer-events: none;
}

/* By default, prevent resize handles from intercepting clicks outside table; enable only on hover */
.editable-table::after,
.editable-table::before {
  pointer-events: none;
}

/* Hover cues */
.table-container:hover table::after,
.editable-table:hover::after {
  background: rgba(74, 144, 226, 0.3);
  pointer-events: auto;
}

.table-container:hover table::before,
.editable-table:hover::before {
  background: rgba(74, 144, 226, 0.3);
  pointer-events: auto;
}

.table-container:hover .table-resize-corner,
.editable-table:hover>.table-resize-corner {
  background: var(--primary);
  border-radius: 2px;
  pointer-events: auto;
}

/* Selection outline */
.table-container.table-selected table,
.editable-table.table-selected {
  outline: 2px solid var(--primary);
  outline-offset: 2px;
  box-shadow: 0 0 0 4px rgba(74, 144, 226, 0.1);
}

.table-container table td,
.table-container table th {
  border: 1px solid #bfbfbf;
  min-width: 2em;
  padding: 0.4em;
  overflow-wrap: break-word;
  position: relative;
  font-size: 16px;
  font-family: inherit;
  line-height: 1.6;
  -webkit-user-drag: none;
}

.table-container table th {
  background: rgba(0, 0, 0, 0.05);
  font-weight: 700;
  color: #000;
}

/* Toolbar */
.table-toolbar {
  position: absolute;
  bottom: 100%;
  left: 0;
  right: 0;
  background: var(--primary);
  border-radius: 6px 6px 0 0;
  padding: 6px;
  display: none;
  flex-wrap: wrap;
  gap: 4px;
  z-index: 200;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
  justify-content: center;
  white-space: nowrap;
  user-select: none;
  -webkit-user-select: none;
  -moz-user-select: none;
  -ms-user-select: none;
  pointer-events: auto;
  margin-bottom: 1px;
  overflow: hidden;
}

.table-toolbar *,
.table-toolbar *::before,
.table-toolbar *::after {
  user-select: none !important;
  -webkit-user-select: none !important;
  -moz-user-select: none !important;
  -ms-user-select: none !important;
}

.table-container:hover .table-toolbar,
.table-container.table-selected .table-toolbar,
.editable-table:hover .table-toolbar,
.editable-table.table-selected .table-toolbar,
.table-toolbar:hover {
  display: flex;
}

.table-toolbar button {
  background: rgba(255, 255, 255, 0.9);
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: 4px;
  padding: 6px;
  cursor: pointer;
  transition: all 0.2s;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  position: relative;
}

.table-toolbar button:hover {
  background: white;
  transform: translateY(-1px);
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.table-toolbar button svg {
  width: 14px;
  height: 14px;
  stroke: #333;
  fill: none;
}

.table-toolbar .toolbar-separator {
  width: 1px;
  height: 20px;
  background: rgba(255, 255, 255, 0.3);
  margin: 0 4px;
}

.table-toolbar .toolbar-group {
  display: flex;
  gap: 2px;
}

/* Selection states for direct tables */
.editor-content td.selected,
.editor-content th.selected {
  background: rgba(0, 123, 255, 0.2) !important;
  outline: 2px solid var(--primary);
}

.editor-content td.column-selected,
.editor-content th.column-selected {
  background: rgba(0, 123, 255, 0.1) !important;
}

.editor-content tr.row-selected td,
.editor-content tr.row-selected th {
  background: rgba(0, 123, 255, 0.1) !important;
}

/* Table properties modal */
.table-props-modal .modal-content {
  max-width: 600px;
}

.props-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  margin-bottom: 16px;
}

.props-group h4 {
  margin-bottom: 8px;
  color: var(--text);
  font-size: 14px;
}

.props-group label {
  display: block;
  margin-bottom: 4px;
  font-size: 12px;
  color: #666;
}

.props-group input,
.props-group select {
  width: 100%;
  padding: 6px 8px;
  border: 1px solid var(--border);
  border-radius: 4px;
  font-size: 12px;
  margin-bottom: 8px;
}

/* Table and Cell Properties Popovers */
.table-props-popover {
  width: 280px;
  max-height: 400px;
  overflow-y: auto;
}

.table-props-popover .popover-content {
  padding: 15px;
}

.table-props-popover h4 {
  margin: 0 0 15px 0;
  font-size: 14px;
  font-weight: 600;
  color: #333;
}

.table-props-popover .form-group {
  margin-bottom: 12px;
}

.table-props-popover .form-group label {
  display: block;
  font-size: 12px;
  font-weight: 500;
  color: #555;
  margin-bottom: 4px;
}

.table-props-popover .form-group input,
.table-props-popover .form-group select {
  width: 100%;
  padding: 6px 8px;
  border: 1px solid #ddd;
  border-radius: 4px;
  font-size: 12px;
  box-sizing: border-box;
}

.table-props-popover .popover-buttons {
  display: flex;
  gap: 8px;
  margin-top: 15px;
  padding-top: 12px;
  border-top: 1px solid #eee;
}

.table-props-popover .popover-buttons button {
  flex: 1;
  padding: 6px 12px;
  border: 1px solid #ddd;
  border-radius: 4px;
  background: #f8f9fa;
  color: #333;
  font-size: 12px;
  cursor: pointer;
  transition: all 0.2s;
}

.table-props-popover .popover-buttons button:hover {
  background: #e9ecef;
  border-color: #adb5bd;
}

.table-props-popover .popover-buttons button:first-child {
  background: #007bff;
  color: white;
  border-color: #007bff;
}

.table-props-popover .popover-buttons button:first-child:hover {
  background: #0056b3;
  border-color: #0056b3;
}

/* Cell Properties Popover */
.cell-props-popover {
  width: 280px;
  max-height: 400px;
  overflow-y: auto;
}

.cell-props-popover .popover-content {
  padding: 15px;
}

.cell-props-popover h4 {
  margin: 0 0 15px 0;
  font-size: 14px;
  font-weight: 600;
  color: #333;
}

.cell-props-popover .form-group {
  margin-bottom: 12px;
}

.cell-props-popover .form-group label {
  display: block;
  font-size: 12px;
  font-weight: 500;
  color: #555;
  margin-bottom: 4px;
}

.cell-props-popover .form-group input,
.cell-props-popover .form-group select {
  width: 100%;
  padding: 6px 8px;
  border: 1px solid #ddd;
  border-radius: 4px;
  font-size: 12px;
  box-sizing: border-box;
}

.cell-props-popover .popover-buttons {
  display: flex;
  gap: 8px;
  margin-top: 15px;
  padding-top: 12px;
  border-top: 1px solid #eee;
}

.cell-props-popover .popover-buttons button {
  flex: 1;
  padding: 6px 12px;
  border: 1px solid #ddd;
  border-radius: 4px;
  background: #f8f9fa;
  color: #333;
  font-size: 12px;
  cursor: pointer;
  transition: all 0.2s;
}

.cell-props-popover .popover-buttons button:hover {
  background: #e9ecef;
  border-color: #adb5bd;
}

.cell-props-popover .popover-buttons button:first-child {
  background: #007bff;
  color: white;
  border-color: #007bff;
}

.cell-props-popover .popover-buttons button:first-child:hover {
  background: #0056b3;
  border-color: #0056b3;
}

/* Font utility classes */
.font-roboto-slab {
  font-family: 'Roboto Slab', serif;
}

.font-ubuntu-mono {
  font-family: 'Ubuntu Mono', monospace;
}

.font-sofia-sans {
  font-family: 'Sofia Sans', sans-serif;
}

.font-sailec-light {
  font-family: 'Sailec Light', sans-serif;
}

/* Text alignment utilities */
.text-left {
  text-align: left;
}

.text-center {
  text-align: center;
}

.text-right {
  text-align: right;
}



/* Two-sided container styles */
.main-container {
  display: flex;
  height: 100vh;
  width: 100%;
}

.left-panel {
  width: 250px;
  /* Adjust width as needed */
  background-color: #f5f5f5;
  /* Light background for visibility */
  border-right: 1px solid var(--border);
}

.right-panel {
  flex: 1;
  /* Takes remaining space */
  display: flex;
  flex-direction: column;
}

#editorApp {
  width: 100%;
  height: 100%;
}

/* Override editor container styles to fill the right panel */
.editor-container {
  max-width: none;
  margin: 0;
  height: 100%;
  border-radius: 0;
  display: flex;
  flex-direction: column;
}

/* Make editor content expand to fill available space */
.editor-content {
  flex: 1;
  min-height: 0;
  /* Allows flex item to shrink below min-height */
  overflow-y: auto;
  /* Add scrollbar if content overflows */
}

.html-view {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
}

/* Tree Navigation Styles */
.tree-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px;
  background: var(--primary);
  color: white;
  border-bottom: 2px solid var(--border);
  height: 48px;
  /* Match toolbar height */
  box-sizing: border-box;
  min-width: 250px;
}

.header-buttons {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-shrink: 0;
}

.tree-header h3 {
  margin: 0;
  font-size: 16px;
  font-weight: 600;
}

.add-root-btn {
  background: rgba(255, 255, 255, 0.2);
  border: 1px solid rgba(255, 255, 255, 0.3);
  color: white;
  border-radius: 4px;
  width: 28px;
  height: 28px;
  cursor: pointer;
  font-size: 16px;
  font-weight: bold;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.2s;
  flex-shrink: 0;
}

.add-root-btn:hover {
  background: rgba(255, 255, 255, 0.3);
}

.tree-footer {
  padding: 12px;
  background: var(--primary);
  border-top: 1px solid rgba(255, 255, 255, 0.1);
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 12px;
}

.vacuum-btn,
.logout-btn {
  background: rgba(255, 255, 255, 0.2);
  border: 1px solid rgba(255, 255, 255, 0.3);
  color: white;
  border-radius: 4px;
  padding: 8px 16px;
  cursor: pointer;
  font-size: 12px;
  font-weight: bold;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.2s;
  text-decoration: none;
  gap: 6px;
}

.vacuum-btn:hover,
.logout-btn:hover {
  background: rgba(255, 255, 255, 0.3);
}

.vacuum-btn:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

.tree-container {
  flex: 1;
  overflow-y: auto;
  padding: 8px 0;
}

.tree-item {
  position: relative;
}

.tree-item-content {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 6px 12px;
  margin: 1px 0;
  cursor: pointer;
  transition: all 0.2s ease;
  border-radius: 4px;
  margin-left: 4px;
  margin-right: 4px;
  border: 2px solid transparent;
  background: rgba(74, 144, 226, 0.1);
  border-color: rgba(74, 144, 226, 0.2);
}

.tree-item-content:hover {
  background: rgba(74, 144, 226, 0.1);
  border-color: rgba(74, 144, 226, 0.2);
  border-left: 4px solid rgba(74, 144, 226, 0.8);
  padding-left: 10px;
}

.tree-item-content.selected {
  background: var(--primary);
  color: white;
  border-color: var(--primary);
  box-shadow: 0 2px 8px rgba(74, 144, 226, 0.3);
  font-weight: 500;
}

.tree-title {
  flex: 1;
  font-size: 15px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-right: 0;
}

.tree-controls {
  display: flex;
  align-items: center;
  gap: 0;
  opacity: 0;
  transition: opacity 0.2s;
  flex-shrink: 0;
}

.tree-item-content:hover .tree-controls,
.tree-item-content.selected .tree-controls {
  opacity: 1;
}

.tree-controls button {
  background: rgba(255, 255, 255, 0.8);
  border: 1px solid rgba(0, 0, 0, 0.1);
  border-radius: 3px;
  width: 20px;
  height: 20px;
  font-size: 11px;
  font-weight: bold;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s;
}

.tree-controls button:hover {
  background: white;
  transform: scale(1.1);
}

.tree-item-content.selected .tree-controls button {
  background: rgba(255, 255, 255, 0.9);
  color: #333;
}

.collapse-btn {
  color: #666;
}

.info-btn {
  color: #17a2b8;
}

.edit-btn {
  color: #007bff;
}

.add-btn {
  color: #28a745;
}

.delete-btn {
  color: #dc3545;
}

.no-collapse {
  width: 20px;
  height: 20px;
  display: inline-block;
}

.tree-children {
  border-left: 1px dashed rgba(74, 144, 226, 0.3);
  margin-left: 10px;
}

/* Drag and drop styles */
.tree-item[draggable="true"] {
  cursor: move;
}

.tree-item.drag-over {
  border-top: 2px solid var(--primary);
}

/* Left panel specific styles */
.left-panel {
  display: flex;
  flex-direction: column;
  background: #fafafa;
  border-right: 2px solid var(--border);
}

/* Imag
e Hover Menu Styles */
.image-hover-menu {
  position: absolute;
  top: 0;
  left: 50%;
  transform: translate(-50%, -100%);
  background: white;
  border: 1px solid #ddd;
  border-radius: 6px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
  z-index: 1000;
  padding: 8px;
  opacity: 0;
  visibility: hidden;
  transition: all 0.2s ease;
  margin-bottom: 5px;
}

.image-container:hover .image-hover-menu {
  opacity: 1;
  visibility: visible;
}

.hover-menu-content {
  display: flex;
  gap: 8px;
  align-items: center;
  white-space: nowrap;
}

.menu-section {
  display: flex;
  gap: 4px;
  padding: 0 4px;
  border-right: 1px solid #eee;
}

.menu-section:last-child {
  border-right: none;
}

.menu-btn {
  background: white;
  border: 1px solid #ddd;
  border-radius: 4px;
  padding: 6px 8px;
  cursor: pointer;
  font-size: 11px;
  font-weight: 500;
  color: #666;
  transition: all 0.2s ease;
  display: flex;
  align-items: center;
  justify-content: center;
  min-width: 32px;
  height: 28px;
}

.menu-btn:hover {
  background: #f5f5f5;
  border-color: #bbb;
  color: #333;
}

.menu-btn.active {
  background: #4a90e2;
  border-color: #4a90e2;
  color: white;
}

.menu-btn svg {
  width: 14px;
  height: 14px;
}

.size-btn {
  min-width: 40px;
  font-size: 10px;
  font-weight: 600;
}

/* Image Container Styles */
.image-container {
  margin: 15px 0;
  position: relative;
  display: block;
  /* Ensure block display for proper alignment */
  /* Allow width to be controlled by JavaScript for proper alignment */
  width: auto;
}

.image-container img {
  transition: all 0.3s ease;
  border-radius: 4px;
}

.image-container img:hover {
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.image-caption {
  margin-top: 8px;
  padding: 4px 8px;
  border-radius: 4px;
  background: #f9f9f9;
  border: 1px dashed #ddd;
  outline: none;
  transition: all 0.2s ease;
  box-sizing: border-box !important;
  display: block;
  font-style: italic;
  font-size: 0.9em;
  color: #666;
  /* Ensure caption respects width constraints */
  word-wrap: break-word;
  overflow-wrap: break-word;
}

.image-caption:focus {
  background: white;
  border-color: #4a90e2;
  box-shadow: 0 0 0 2px rgba(74, 144, 226, 0.1);
}

.image-caption:empty:before {
  content: "Enter caption...";
  color: #999;
  font-style: italic;
}

/* Image Alignment Classes - Applied to image-container */
.image-container.align-left {
  float: left;
  margin-right: 20px;
  margin-bottom: 10px;
  text-align: left;
  clear: left;
  display: block;
}

.image-container.align-right {
  float: right;
  margin-left: 20px;
  margin-bottom: 10px;
  text-align: right;
  clear: right;
  display: block;
}

.image-container.align-center {
  display: block;
  margin-left: auto;
  margin-right: auto;
  text-align: center;
  float: none;
  clear: both;
}

/* Ensure images within aligned containers behave properly */
.image-container.align-left img,
.image-container.align-right img {
  display: block;
  margin: 0;
}

.image-container.align-center img {
  display: block;
  margin: 0 auto;
}

/* Caption alignment within containers - let JavaScript handle margins and width */
.image-container.align-left .image-caption {
  text-align: left;
}

.image-container.align-right .image-caption {
  text-align: right;
}

.image-container.align-center .image-caption {
  text-align: center;
}

/*
 Image Selection Styles */
.image-container img.selected {
  outline: 2px solid #4a90e2;
  outline-offset: 2px;
  box-shadow: 0 0 0 4px rgba(74, 144, 226, 0.1);
}

/* Ensure hover menu is positioned relative to editor */
.editor-content {
  position: relative;
}

/* Improve hover menu positioning */
.image-hover-menu {
  z-index: 1001;
  margin-bottom: 5px;
}

/* Better image container positioning for menu attachment - merged with main definition above */

.image-container img {
  cursor: pointer;
  user-select: none;
}

.image-container img:hover {
  opacity: 0.9;
}

/* Li
nk Styles */
.editor-content a {
  color: #4a90e2;
  text-decoration: underline;
  cursor: pointer;
  transition: color 0.2s ease;
}

.editor-content a:hover {
  color: #357abd;
  text-decoration: underline;
}

.editor-content a:visited {
  color: #6b46c1;
}

/* Link editing indicator */
.editor-content a:focus {
  outline: 2px solid #4a90e2;
  outline-offset: 2px;
  border-radius: 2px;
}

/* Modal improvements for better UX */
.modal input:focus {
  border-color: #4a90e2;
  box-shadow: 0 0 0 2px rgba(74, 144, 226, 0.1);
  outline: none;
}

.modal .btn-primary:hover {
  background: #357abd;
  transform: translateY(-1px);
}

.modal .btn-primary:active {
  transform: translateY(0);
}

/* Link modal specific styles */
#linkModal .modal-content {
  min-width: 400px;
}

#linkModal input {
  margin-bottom: 12px;
}

#linkModal input:last-of-type {
  margin-bottom: 16px;
}