/* ============================================
   NOTED - Editor Area
   ============================================ */

#editor-area {
  flex: 1;
  overflow-y: auto;
  padding: 24px 32px;
  display: flex;
  flex-direction: column;
  gap: 20px;
}

/* Page Card */
.page-card {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
  transition: box-shadow var(--transition);
  box-shadow: var(--shadow-sm);
}

.page-card:hover {
  box-shadow: var(--shadow);
}

.page-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 16px;
  background: var(--glass);
  border-bottom: 1px solid var(--border);
  font-size: 12px;
  color: var(--text-muted);
}

.page-card-header .page-number {
  font-weight: 600;
  letter-spacing: 0.5px;
}

.page-card-header .page-actions {
  display: flex;
  gap: 4px;
}

.page-card-header .page-actions button {
  width: 24px;
  height: 24px;
  padding: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  border: none;
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
  border-radius: 4px;
  font-size: 12px;
  transition: all var(--transition-fast);
}

.page-card-header .page-actions button:hover {
  background: var(--glass-strong);
  color: var(--text-primary);
}

/* Page Editor (contenteditable) */
.page-editor {
  min-height: 200px;
  padding: 20px 24px;
  outline: none;
  font-size: 15px;
  line-height: 1.8;
  color: var(--text-primary);
  word-wrap: break-word;
  overflow-wrap: break-word;
  transition: background var(--transition);
}

.page-editor:empty::before {
  content: attr(data-placeholder);
  color: var(--text-muted);
  pointer-events: none;
}

.page-editor:focus {
  background: rgba(255, 255, 255, 0.01);
}

/* Editor Typography */
.page-editor h1 {
  font-size: 28px;
  font-weight: 700;
  margin-top: 24px;
  margin-bottom: 8px;
  color: var(--text-primary);
  line-height: 1.3;
}

.page-editor h2 {
  font-size: 22px;
  font-weight: 600;
  margin-top: 20px;
  margin-bottom: 6px;
  line-height: 1.35;
}

.page-editor h3 {
  font-size: 18px;
  font-weight: 600;
  margin-top: 16px;
  margin-bottom: 4px;
  line-height: 1.4;
}

.page-editor h4 {
  font-size: 16px;
  font-weight: 600;
  margin-top: 14px;
  margin-bottom: 4px;
}

.page-editor a {
  color: var(--accent);
  text-decoration: underline;
  text-underline-offset: 2px;
}

.page-editor a:hover {
  color: var(--accent-hover);
}

/* Lists */
.page-editor ul,
.page-editor ol {
  padding-left: 24px;
  margin: 8px 0;
}

.page-editor li {
  margin: 4px 0;
}

/* Blockquote */
.page-editor blockquote {
  border-left: 3px solid var(--accent);
  padding-left: 16px;
  margin: 12px 0;
  color: var(--text-secondary);
  font-style: italic;
}

/* Code */
.page-editor pre {
  background: var(--bg-base);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  overflow-x: auto;
  font-family: var(--font-mono);
  font-size: 13px;
  line-height: 1.5;
  margin: 12px 0;
}

.page-editor code {
  background: var(--bg-elevated);
  padding: 2px 6px;
  border-radius: 4px;
  font-family: var(--font-mono);
  font-size: 13px;
}

.page-editor pre code {
  background: none;
  padding: 0;
  border-radius: 0;
}

/* Images */
.page-editor img {
  max-width: 100%;
  border-radius: var(--radius);
  margin: 8px 0;
  cursor: pointer;
  transition: box-shadow var(--transition);
}

.page-editor img:hover {
  box-shadow: var(--shadow);
}

/* Tables */
.page-editor table {
  width: 100%;
  border-collapse: collapse;
  margin: 12px 0;
}

.page-editor table td,
.page-editor table th {
  border: 1px solid var(--border-strong);
  padding: 8px 12px;
  text-align: left;
}

.page-editor table th {
  background: var(--bg-elevated);
  font-weight: 600;
}

.page-editor table tr:hover td {
  background: var(--glass);
}

/* Selected Block */
.selected-block {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  border-radius: var(--radius-sm);
}

/* Drag Over State */
.page-editor.drag-over {
  background: var(--accent-muted);
  border: 2px dashed var(--accent);
  border-radius: var(--radius);
}

/* Note Link Chip */
.note-link-chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  background: var(--accent-muted);
  color: var(--accent);
  padding: 2px 8px;
  border-radius: 12px;
  font-size: 13px;
  cursor: pointer;
  transition: all var(--transition-fast);
  text-decoration: none;
  border: none;
  font-family: inherit;
}

.note-link-chip:hover {
  background: var(--accent);
  color: #fff;
  text-decoration: none;
}

.note-link-chip .chip-icon {
  font-size: 11px;
}

/* No Note Selected State */
#no-note-selected {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  color: var(--text-muted);
  gap: 12px;
  font-size: 16px;
  user-select: none;
}

/* Bottom Panels */
#bottom-panels {
  border-top: 1px solid var(--border);
  flex-shrink: 0;
}

.panel {
  overflow: hidden;
  transition: all var(--transition);
}

.panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 16px;
  cursor: pointer;
  transition: background var(--transition-fast);
  user-select: none;
}

.panel-header:hover {
  background: var(--glass);
}

.panel-header span {
  font-size: 13px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.panel-body {
  padding: 12px 16px;
  max-height: 300px;
  overflow-y: auto;
}

.panel.collapsed .panel-body {
  display: none;
}

.panel-toggle-icon {
  width: 24px;
  height: 24px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: none;
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
  border-radius: var(--radius-sm);
  font-size: 12px;
  transition: transform var(--transition-fast);
}

.panel.collapsed .panel-toggle-icon {
  transform: rotate(-90deg);
}

/* Links List in Panel */
#links-list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

#links-list:empty::after {
  content: 'No linked notes yet';
  color: var(--text-muted);
  font-size: 13px;
}

/* Image Resize */
.page-editor img {
  transition: outline 0.15s ease, box-shadow 0.15s ease;
  cursor: grab;
}

.page-editor img:active {
  cursor: grabbing;
}

.page-editor img.img-resize-active {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  box-shadow: var(--shadow-glow);
}

/* Inline note link (wrapped text) */
.note-link-inline {
  color: var(--accent) !important;
  text-decoration: underline dotted !important;
  background: transparent !important;
  padding: 0 !important;
  border-radius: 0 !important;
  cursor: pointer;
}

.note-link-inline:hover {
  text-decoration: underline solid !important;
  color: var(--accent-hover) !important;
}

/* Tag chips */
.tag-chip {
  display: inline-flex;
  align-items: center;
  padding: 1px 8px;
  border-radius: 10px;
  background: rgba(99, 102, 241, 0.12);
  color: #818cf8;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.15s;
  vertical-align: baseline;
  margin: 0 2px;
}

.tag-chip:hover {
  background: rgba(99, 102, 241, 0.25);
  color: #a5b4fc;
}

/* Gap between components - clickable area to insert content */
.page-editor > [data-component] + [data-component],
.page-editor > [contenteditable="false"] + [contenteditable="false"] {
  margin-top: 4px;
}

.page-editor > [data-component]::after {
  content: '';
  display: block;
  height: 4px;
  cursor: text;
}

/* Templates next to floats */
.page-editor [data-component="template"] {
  overflow: hidden;
}

/* YouTube Embed */
.youtube-embed {
  margin: 12px 0;
  border-radius: var(--radius);
  overflow: hidden;
  position: relative;
  background: var(--bg-base);
  border: 1px solid var(--border);
}

.youtube-embed iframe {
  display: block;
  max-width: 100%;
  border-radius: var(--radius);
}

/* Inline Rename Input */
.inline-rename-input {
  width: 100%;
  background: var(--bg-overlay);
  color: inherit;
  border: 1px solid var(--accent);
  border-radius: 4px;
  padding: 2px 6px;
  font-size: inherit;
  font-family: inherit;
  outline: none;
}

.inline-rename-input:focus {
  box-shadow: 0 0 0 2px var(--accent-muted);
}
