/* ========================================================================
   Tiptap Editor — Appfabrik Feedback
   Premium WYSIWYG editor styles (dark mode default, Tailwind-compatible)
   ======================================================================== */

/* -- Editor wrapper (border, rounded, focus ring) -- */
.tte-wrap {
  border: 1px solid #d1d5db;       /* gray-300 */
  border-radius: 0.75rem;
  overflow: hidden;
  transition: border-color 200ms ease, box-shadow 200ms ease;
  background: #fff;
}

.dark .tte-wrap {
  border-color: #4b5563;            /* gray-600 */
  background: #1f2937;              /* gray-800 */
}

.tte-wrap.tte-focused {
  border-color: #2563eb;            /* brand-600 */
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.15);
}

.dark .tte-wrap.tte-focused {
  border-color: #3b82f6;            /* brand-500 */
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.15);
}

/* -- Toolbar -- */
.tte-toolbar {
  display: flex;
  align-items: center;
  gap: 2px;
  padding: 6px 8px;
  border-bottom: 1px solid #e5e7eb; /* gray-200 */
  background: #f9fafb;              /* gray-50 */
  flex-wrap: wrap;
  user-select: none;
}

.dark .tte-toolbar {
  border-bottom-color: #374151;     /* gray-700 */
  background: #111827;              /* gray-900 */
}

/* Toolbar button */
.tte-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 30px;
  height: 30px;
  padding: 0;
  border: none;
  border-radius: 6px;
  background: transparent;
  color: #6b7280;                   /* gray-500 */
  cursor: pointer;
  transition: all 120ms ease;
  flex-shrink: 0;
}

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

.tte-btn:hover {
  background: #e5e7eb;              /* gray-200 */
  color: #111827;                   /* gray-900 */
}

.dark .tte-btn {
  color: #9ca3af;                   /* gray-400 */
}

.dark .tte-btn:hover {
  background: #374151;              /* gray-700 */
  color: #f3f4f6;                   /* gray-100 */
}

.tte-btn.tte-active {
  background: #dbeafe;              /* blue-100 */
  color: #2563eb;                   /* brand-600 */
}

.dark .tte-btn.tte-active {
  background: rgba(37, 99, 235, 0.2);
  color: #60a5fa;                   /* brand-400 */
}

/* Separator */
.tte-sep {
  width: 1px;
  height: 18px;
  background: #e5e7eb;
  margin: 0 4px;
  flex-shrink: 0;
}

.dark .tte-sep {
  background: #374151;
}

/* -- Editor content area -- */
.tte-content {
  position: relative;
}

.tte-prosemirror {
  min-height: 80px;
  max-height: 320px;
  overflow-y: auto;
  padding: 12px 14px;
  font-size: 0.875rem;
  line-height: 1.625;
  color: #111827;                   /* gray-900 */
  outline: none;
}

.dark .tte-prosemirror {
  color: #f3f4f6;                   /* gray-100 */
}

/* -- Compact mode (widget) -- */
.tte-compact .tte-toolbar {
  padding: 4px 6px;
  gap: 1px;
}

.tte-compact .tte-btn {
  width: 26px;
  height: 26px;
}

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

.tte-compact .tte-sep {
  height: 14px;
  margin: 0 3px;
}

.tte-compact .tte-prosemirror {
  min-height: 48px;
  max-height: 160px;
  padding: 8px 10px;
  font-size: 0.8125rem;
}

/* -- Placeholder -- */
.tte-prosemirror p.is-editor-empty:first-child::before {
  content: attr(data-placeholder);
  float: left;
  color: #9ca3af;                   /* gray-400 */
  pointer-events: none;
  height: 0;
  font-style: italic;
}

.dark .tte-prosemirror p.is-editor-empty:first-child::before {
  color: #6b7280;                   /* gray-500 */
}

/* -- Typography inside editor -- */
.tte-prosemirror > * + * {
  margin-top: 0.5em;
}

.tte-prosemirror h2 {
  font-size: 1.25em;
  font-weight: 700;
  line-height: 1.3;
  margin-top: 1em;
  margin-bottom: 0.25em;
}

.tte-prosemirror h3 {
  font-size: 1.1em;
  font-weight: 600;
  line-height: 1.4;
  margin-top: 0.75em;
  margin-bottom: 0.25em;
}

.tte-prosemirror strong {
  font-weight: 700;
}

.tte-prosemirror em {
  font-style: italic;
}

.tte-prosemirror s {
  text-decoration: line-through;
}

.tte-prosemirror code {
  background: #f3f4f6;
  border-radius: 4px;
  padding: 0.15em 0.35em;
  font-family: ui-monospace, SFMono-Regular, 'SF Mono', Menlo, Consolas, monospace;
  font-size: 0.85em;
  color: #dc2626;
}

.dark .tte-prosemirror code {
  background: #1f2937;
  color: #f87171;
}

.tte-prosemirror pre {
  background: #1e1e2e;
  color: #cdd6f4;
  border-radius: 8px;
  padding: 12px 16px;
  font-family: ui-monospace, SFMono-Regular, 'SF Mono', Menlo, Consolas, monospace;
  font-size: 0.8125rem;
  line-height: 1.6;
  overflow-x: auto;
  margin: 0.5em 0;
}

.tte-prosemirror pre code {
  background: none;
  color: inherit;
  padding: 0;
  border-radius: 0;
  font-size: inherit;
}

.dark .tte-prosemirror pre {
  background: #0f0f1a;
}

/* Blockquote */
.tte-prosemirror blockquote {
  border-left: 3px solid #d1d5db;
  padding-left: 1em;
  color: #6b7280;
  font-style: italic;
  margin: 0.5em 0;
}

.dark .tte-prosemirror blockquote {
  border-left-color: #4b5563;
  color: #9ca3af;
}

/* Lists */
.tte-prosemirror ul {
  list-style-type: disc;
  padding-left: 1.5em;
}

.tte-prosemirror ol {
  list-style-type: decimal;
  padding-left: 1.5em;
}

.tte-prosemirror li {
  margin: 0.15em 0;
}

.tte-prosemirror li > p {
  margin: 0;
}

/* Links */
.tte-prosemirror a,
.tte-link {
  color: #2563eb;
  text-decoration: underline;
  text-underline-offset: 2px;
  cursor: pointer;
}

.dark .tte-prosemirror a,
.dark .tte-link {
  color: #60a5fa;
}

/* Horizontal rule */
.tte-prosemirror hr {
  border: none;
  border-top: 1px solid #e5e7eb;
  margin: 1em 0;
}

.dark .tte-prosemirror hr {
  border-top-color: #374151;
}

/* Tables */
.tte-prosemirror table {
  border-collapse: collapse;
  width: 100%;
  margin: 0.5em 0;
  overflow: hidden;
  border-radius: 6px;
}

.tte-prosemirror td,
.tte-prosemirror th {
  border: 1px solid #d1d5db;
  padding: 6px 10px;
  text-align: left;
  vertical-align: top;
  min-width: 60px;
  position: relative;
}

.dark .tte-prosemirror td,
.dark .tte-prosemirror th {
  border-color: #4b5563;
}

.tte-prosemirror th {
  font-weight: 600;
  background: #f3f4f6;
}

.dark .tte-prosemirror th {
  background: #1f2937;
}

/* Selected cells highlight */
.tte-prosemirror .selectedCell::after {
  content: '';
  position: absolute;
  inset: 0;
  background: rgba(37, 99, 235, 0.12);
  pointer-events: none;
  z-index: 2;
}

/* ========================================================================
   Rendered markdown content styles (for message bubbles)
   Used with class="markdown-content" on server-rendered markdown HTML
   ======================================================================== */

.markdown-content table {
  border-collapse: collapse;
  width: 100%;
  margin: 0.5em 0;
  font-size: 0.875rem;
}

.markdown-content td,
.markdown-content th {
  border: 1px solid #d1d5db;
  padding: 6px 10px;
  text-align: left;
}

.dark .markdown-content td,
.dark .markdown-content th {
  border-color: #4b5563;
}

.markdown-content th {
  font-weight: 600;
  background: #f3f4f6;
}

.dark .markdown-content th {
  background: #1f2937;
}

.markdown-content pre {
  background: #1e1e2e;
  color: #cdd6f4;
  border-radius: 8px;
  padding: 12px 16px;
  font-family: ui-monospace, SFMono-Regular, 'SF Mono', Menlo, Consolas, monospace;
  font-size: 0.8125rem;
  line-height: 1.6;
  overflow-x: auto;
  margin: 0.5em 0;
}

.dark .markdown-content pre {
  background: #0f0f1a;
}

.markdown-content code {
  background: #f3f4f6;
  border-radius: 4px;
  padding: 0.15em 0.35em;
  font-family: ui-monospace, SFMono-Regular, 'SF Mono', Menlo, Consolas, monospace;
  font-size: 0.85em;
}

.dark .markdown-content code {
  background: #1f2937;
}

.markdown-content pre code {
  background: none;
  padding: 0;
  border-radius: 0;
}

.markdown-content blockquote {
  border-left: 3px solid #d1d5db;
  padding-left: 1em;
  color: #6b7280;
  font-style: italic;
  margin: 0.5em 0;
}

.dark .markdown-content blockquote {
  border-left-color: #4b5563;
  color: #9ca3af;
}

.markdown-content hr {
  border: none;
  border-top: 1px solid #e5e7eb;
  margin: 1em 0;
}

.dark .markdown-content hr {
  border-top-color: #374151;
}

/* Scrollbar styling for editor */
.tte-prosemirror::-webkit-scrollbar {
  width: 6px;
}

.tte-prosemirror::-webkit-scrollbar-track {
  background: transparent;
}

.tte-prosemirror::-webkit-scrollbar-thumb {
  background: rgba(0, 0, 0, 0.15);
  border-radius: 3px;
}

.dark .tte-prosemirror::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.12);
}

.tte-prosemirror {
  scrollbar-width: thin;
  scrollbar-color: rgba(0, 0, 0, 0.15) transparent;
}

.dark .tte-prosemirror {
  scrollbar-color: rgba(255, 255, 255, 0.12) transparent;
}
