/* ProseMirror Editor Styles */

/* Editor container */
.ProseMirror {
  outline: none;
  word-wrap: break-word;
  white-space: pre-wrap;
  white-space: break-spaces;
  -webkit-font-variant-ligatures: none;
  font-variant-ligatures: none;
}

.ProseMirror:focus {
  outline: none;
}

/* Placeholder */
.ProseMirror p.is-editor-empty:first-child::before {
  color: var(--color-text-muted);
  content: attr(data-placeholder);
  float: left;
  height: 0;
  pointer-events: none;
}

.prosemirror-editor-container[data-placeholder]::before {
  content: attr(data-placeholder);
  color: var(--color-text-muted);
  pointer-events: none;
  position: absolute;
  top: 1rem;
  left: 1rem;
}

.prosemirror-editor-container:has(.ProseMirror > p:not(:empty))::before,
.prosemirror-editor-container:has(.ProseMirror > *:not(p):first-child)::before {
  display: none;
}

/* Empty editor placeholder */
.ProseMirror>.is-empty::before {
  color: var(--color-text-muted);
  content: attr(data-placeholder);
  float: left;
  height: 0;
  pointer-events: none;
}

/* Selection */
.ProseMirror-selectednode {
  outline: 2px solid #68cef8;
}

/* Gap cursor */
.ProseMirror-gapcursor {
  display: none;
  pointer-events: none;
  position: absolute;
}

.ProseMirror-gapcursor:after {
  content: "";
  display: block;
  position: absolute;
  top: -2px;
  width: 20px;
  border-top: 1px solid var(--color-text-primary);
  animation: ProseMirror-cursor-blink 1.1s steps(2, start) infinite;
}

@keyframes ProseMirror-cursor-blink {
  to {
    visibility: hidden;
  }
}

.ProseMirror-focused .ProseMirror-gapcursor {
  display: block;
}

/* Drop cursor */
.ProseMirror-dropcursor {
  position: absolute;
  z-index: 40;
  pointer-events: none;
  background: #2563eb;
}

/* Toolbar styles */
.prosemirror-toolbar {
  position: sticky;
  top: 0;
  z-index: 10;
  background: var(--color-bg-base);
}

.prosemirror-toolbar button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 2rem;
  min-height: 2rem;
  color: var(--color-text-primary);
  border: none;
  background: transparent;
  cursor: pointer;
}

.prosemirror-toolbar button:hover {
  background-color: var(--color-bg-elevated);
}

.prosemirror-toolbar button.active,
.prosemirror-toolbar button[aria-pressed="true"] {
  background-color: var(--color-accent-muted);
  color: var(--color-accent);
}

.prosemirror-toolbar button:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

/* Editor wrapper */
.prosemirror-wrapper {
  display: flex;
  flex-direction: column;
  background: var(--color-bg-surface);
}

/* Darker editor background in dark mode */
@media (prefers-color-scheme: dark) {
  .prosemirror-wrapper {
    background: #1a1a1a;
  }
}

.prosemirror-editor-container {
  position: relative;
  flex: 1;
  overflow-y: auto;
}

/* Ensure proper spacing for editor content */
.prosemirror-editor-container .ProseMirror {
  min-height: 200px;
  padding: 1rem;
}

/* Typography within editor - matches prose utility */
.ProseMirror p {
  margin: 1em 0;
}

.ProseMirror p:first-child {
  margin-top: 0;
}

.ProseMirror p:last-child {
  margin-bottom: 0;
}

.ProseMirror h1 {
  font-size: 2em;
  font-weight: 700;
  margin: 0.67em 0;
  line-height: 1.2;
}

.ProseMirror h2 {
  font-size: 1.5em;
  font-weight: 600;
  margin: 0.83em 0;
  line-height: 1.3;
}

.ProseMirror h3 {
  font-size: 1.17em;
  font-weight: 600;
  margin: 1em 0;
  line-height: 1.4;
}

.ProseMirror h4,
.ProseMirror h5,
.ProseMirror h6 {
  font-weight: 600;
  margin: 1.33em 0;
}

.ProseMirror strong {
  font-weight: 700;
}

.ProseMirror em {
  font-style: italic;
}

.ProseMirror code {
  background-color: var(--color-bg-base);
  border-radius: 0.25rem;
  padding: 0.125rem 0.375rem;
  font-family: ui-monospace, monospace;
  font-size: 0.875em;
}

.ProseMirror pre {
  background-color: #1f2937;
  color: #f9fafb;
  padding: 1rem;
  border-radius: 0.5rem;
  overflow-x: auto;
  margin: 1em 0;
}

.ProseMirror pre code {
  background: none;
  padding: 0;
  color: inherit;
}

.ProseMirror blockquote {
  border-left: 4px solid var(--color-border);
  padding-left: 1rem;
  margin: 1em 0;
  color: var(--color-text-secondary);
  font-style: italic;
}

.ProseMirror ul,
.ProseMirror ol {
  padding-left: 1.5em;
  margin: 1em 0;
}

.ProseMirror ul {
  list-style-type: disc;
}

.ProseMirror ol {
  list-style-type: decimal;
}

.ProseMirror li {
  margin: 0.25em 0;
}

.ProseMirror li>p {
  margin: 0;
}

.ProseMirror a {
  color: var(--color-accent);
  text-decoration: underline;
}

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

.ProseMirror hr {
  border: none;
  border-top: 1px solid var(--color-border);
  margin: 2em 0;
}

/* Inline editor specific styles (for Notes) */
.inline-editor .prosemirror-wrapper {
  border: none;
  border-radius: 0;
}

.inline-editor .prosemirror-toolbar {
  border-bottom: 1px solid var(--color-border);
  border-radius: 0;
}

.inline-editor .prosemirror-editor-container {
  min-height: 300px;
}