/* ================================================================
   Rich Text Editor Styles (TipTap)
   ================================================================ */

/* -- Editor wrapper -- */
.rt-editor {
  border: 1px solid var(--bg-2, #e4edf5);
  border-radius: var(--radius-sm, 6px);
  background: var(--surface, #fff);
  overflow: hidden;
  transition: border-color 0.15s ease;
}

.rt-editor:focus-within {
  border-color: var(--primary, #0066ff);
  box-shadow: 0 0 0 3px rgba(0, 102, 255, 0.12);
}

/* -- Toolbar -- */
.rt-toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 2px;
  padding: 6px 8px;
  background: var(--bg-1, #f0f4f8);
  border-bottom: 1px solid var(--bg-2, #e4edf5);
}

.rt-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 28px;
  height: 28px;
  padding: 0 6px;
  border: none;
  border-radius: var(--radius-xs, 4px);
  background: transparent;
  color: var(--ink-soft, #5a6a7e);
  font-size: 13px;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  transition: background 0.12s ease, color 0.12s ease;
  line-height: 1;
}

.rt-btn:hover {
  background: var(--bg-2, #e4edf5);
  color: var(--ink, #1a2332);
}

.rt-btn--active {
  background: var(--primary, #0066ff);
  color: #fff;
}

.rt-btn--active:hover {
  background: var(--primary-dark, #0052cc);
  color: #fff;
}

.rt-btn svg {
  width: 16px;
  height: 16px;
}

/* -- Content area (TipTap renders .tiptap or .ProseMirror inside) -- */
.rt-content {
  padding: 0;
}

.rt-content .tiptap,
.rt-content .ProseMirror {
  padding: 12px 14px;
  min-height: 100px;
  outline: none;
  font-size: var(--text-sm, 0.875rem);
  line-height: 1.6;
  color: var(--ink, #1a2332);
}

.rt-content .tiptap:focus,
.rt-content .ProseMirror:focus {
  outline: none;
}

/* -- Prose styles inside editor -- */
.rt-content .tiptap p,
.rt-content .ProseMirror p {
  margin: 0 0 0.5em 0;
}

.rt-content .tiptap p:last-child,
.rt-content .ProseMirror p:last-child {
  margin-bottom: 0;
}

.rt-content .tiptap h2,
.rt-content .ProseMirror h2 {
  font-size: 1.25em;
  font-weight: 700;
  margin: 0.75em 0 0.4em 0;
  color: var(--ink, #1a2332);
}

.rt-content .tiptap h3,
.rt-content .ProseMirror h3 {
  font-size: 1.1em;
  font-weight: 600;
  margin: 0.6em 0 0.3em 0;
  color: var(--ink, #1a2332);
}

.rt-content .tiptap ul,
.rt-content .ProseMirror ul,
.rt-content .tiptap ol,
.rt-content .ProseMirror ol {
  margin: 0.4em 0;
  padding-left: 1.5em;
}

.rt-content .tiptap li,
.rt-content .ProseMirror li {
  margin-bottom: 0.2em;
}

.rt-content .tiptap strong,
.rt-content .ProseMirror strong {
  font-weight: 700;
}

.rt-content .tiptap em,
.rt-content .ProseMirror em {
  font-style: italic;
}

.rt-content .tiptap a,
.rt-content .ProseMirror a {
  color: var(--primary, #0066ff);
  text-decoration: underline;
  cursor: pointer;
}

.rt-content .tiptap a:hover,
.rt-content .ProseMirror a:hover {
  color: var(--primary-dark, #0052cc);
}

/* -- Placeholder text for empty editor -- */
.rt-content .tiptap p.is-editor-empty:first-child::before,
.rt-content .ProseMirror p.is-editor-empty:first-child::before {
  content: attr(data-placeholder);
  color: var(--ink-soft, #5a6a7e);
  opacity: 0.5;
  pointer-events: none;
  float: left;
  height: 0;
}

/* -- Dark mode overrides -- */
[data-theme="dark"] .rt-editor {
  border-color: var(--bg-2, #333);
  background: var(--surface, #1e1e1e);
}

[data-theme="dark"] .rt-toolbar {
  background: var(--bg-1, #252525);
  border-bottom-color: var(--bg-2, #333);
}

[data-theme="dark"] .rt-btn {
  color: var(--ink-soft, #aaa);
}

[data-theme="dark"] .rt-btn:hover {
  background: var(--bg-2, #333);
  color: var(--ink, #eee);
}

[data-theme="dark"] .rt-content .tiptap,
[data-theme="dark"] .rt-content .ProseMirror {
  color: var(--ink, #eee);
}

/* -- RTL support -- */
[dir="rtl"] .rt-content .tiptap ul,
[dir="rtl"] .rt-content .ProseMirror ul,
[dir="rtl"] .rt-content .tiptap ol,
[dir="rtl"] .rt-content .ProseMirror ol {
  padding-left: 0;
  padding-right: 1.5em;
}

/* -- Print: show content, hide toolbar -- */
@media print {
  .rt-toolbar {
    display: none;
  }
  .rt-editor {
    border: none;
    box-shadow: none;
  }
}
