/* Draft Editor - TipTap/ProseMirror Styles */

/* Yellow highlight for AI suggestions */
.ProseMirror mark.ai-suggestion {
  background-color: #fef08a !important;
  border-radius: 2px;
  padding: 1px 2px;
  box-decoration-break: clone;
  -webkit-box-decoration-break: clone;
}

/* Selection highlight while AI panel is open */
.ProseMirror mark.selection-highlight {
  background-color: #bfdbfe !important;
  border-radius: 2px;
  padding: 1px 2px;
  box-decoration-break: clone;
  -webkit-box-decoration-break: clone;
}

/* Agent-suggestion inline diff (track changes): red removed / green added */
.ProseMirror mark.ai-suggestion-removed {
  background-color: #fecaca !important;
  color: #b91c1c;
  text-decoration: line-through;
  border-radius: 2px;
  padding: 1px 2px;
  box-decoration-break: clone;
  -webkit-box-decoration-break: clone;
}

.ProseMirror mark.ai-suggestion-added {
  background-color: #bbf7d0 !important;
  color: #166534;
  border-radius: 2px;
  padding: 1px 2px;
  box-decoration-break: clone;
  -webkit-box-decoration-break: clone;
}

/* Apply prose styling to TipTap editor */
.ProseMirror {
  outline: none;
}

/* Let the component's min_height value control ProseMirror height
   instead of the base controller's hardcoded min-h-[200px] */
[data-tiptap--editor-target="editor"] > .ProseMirror {
  min-height: inherit !important;
}

/* Offset for scrollIntoView to clear sticky navbar + toolbar */
.ProseMirror > * {
  scroll-margin-top: 12rem;
}

.ProseMirror > * + * {
  margin-top: 0.75em;
}

/* Talking-points docs: keep the slide image tight under its "Slide N" heading. */
.ProseMirror :is(h1, h2, h3) + img,
.ProseMirror :is(h1, h2, h3) + p:has(> img) {
  margin-top: 0.35em;
}

.ProseMirror p {
  margin-bottom: 0;
}

/* Ensure empty paragraphs (blank lines) are visible */
.ProseMirror p:empty::before,
.ProseMirror p:has(br:only-child)::before {
  content: '\00a0'; /* non-breaking space */
  display: inline;
}

.ProseMirror p:empty,
.ProseMirror p:has(br:only-child) {
  min-height: 1.5em;
}

.ProseMirror h1 {
  font-size: 1.5em;
  font-weight: 700;
  margin-top: 1.5em;
  margin-bottom: 0.5em;
}

.ProseMirror h2 {
  font-size: 1.25em;
  font-weight: 600;
  margin-top: 1.5em;
  margin-bottom: 0.5em;
}

.ProseMirror h3 {
  font-size: 1.1em;
  font-weight: 600;
  margin-top: 1.25em;
  margin-bottom: 0.5em;
}

.ProseMirror ul,
.ProseMirror ol {
  padding-left: 1.5em;
  margin-top: 0.75em;
  margin-bottom: 0.75em;
}

.ProseMirror li {
  margin-top: 0.25em;
  margin-bottom: 0.25em;
}

.ProseMirror strong {
  font-weight: 600;
}

.ProseMirror em {
  font-style: italic;
}

.ProseMirror hr {
  border: none;
  border-top: 2px solid oklch(var(--b3));
  margin: 2rem 0;
}

.ProseMirror blockquote {
  border-left: 3px solid oklch(var(--p));
  padding-left: 1rem;
  margin: 1rem 0;
  color: oklch(var(--bc) / 0.8);
}

/* Task list styles */
.ProseMirror ul[data-type="taskList"] {
  list-style: none;
  padding: 0;
}

.ProseMirror ul[data-type="taskList"] li {
  display: flex;
  align-items: flex-start;
  gap: 0.5rem;
}

.ProseMirror ul[data-type="taskList"] li > label {
  flex: 0 0 auto;
  margin-top: 0.25rem;
  user-select: none;
}

.ProseMirror ul[data-type="taskList"] li > label input[type="checkbox"] {
  cursor: pointer;
}

.ProseMirror ul[data-type="taskList"] li > div {
  flex: 1 1 auto;
}

.ProseMirror ul[data-type="taskList"] li[data-checked="true"] > div {
  text-decoration: line-through;
  opacity: 0.6;
}

/* Table styles */
.ProseMirror table {
  border-collapse: collapse;
  table-layout: fixed;
  width: 100%;
  margin: 1rem 0;
  overflow: hidden;
  border-radius: 0.5rem;
  border: 1px solid oklch(var(--b3));
}

.ProseMirror td,
.ProseMirror th {
  min-width: 1em;
  border: 1px solid oklch(var(--b3));
  padding: 0.5rem 0.75rem;
  vertical-align: top;
  box-sizing: border-box;
  position: relative;
}

.ProseMirror th {
  font-weight: 600;
  text-align: left;
  background-color: oklch(var(--b2));
}

.ProseMirror .selectedCell:after {
  z-index: 2;
  position: absolute;
  content: "";
  left: 0;
  right: 0;
  top: 0;
  bottom: 0;
  background: oklch(var(--p) / 0.1);
  pointer-events: none;
}

.ProseMirror .column-resize-handle {
  position: absolute;
  right: -2px;
  top: 0;
  bottom: -2px;
  width: 4px;
  background-color: oklch(var(--p));
  pointer-events: none;
}

.ProseMirror.resize-cursor {
  cursor: col-resize;
}

/* Highlight styles */
.ProseMirror mark {
  border-radius: 0.25rem;
  padding: 0.125rem 0.25rem;
  box-decoration-break: clone;
  -webkit-box-decoration-break: clone;
}

.ProseMirror mark:not([style]) {
  background-color: #fef08a;
}

/* Selected comment card — soft shadow on all sides (incl. top), Google-Docs style. */
.comment-card-active {
  box-shadow: 0 0 16px rgba(0, 0, 0, 0.12);
}

/* Comment highlight styles — resting highlight sits at half opacity; the active
   comment's anchored text goes to full opacity (Google-Docs style). The vertical
   em padding bleeds the background into the line leading so multi-line highlights
   are continuous, with no white gaps between lines. */
.ProseMirror mark.comment-highlight {
  background-color: rgba(250, 204, 21, 0.32);
  /* One comment can be split into several <mark> fragments when its anchored text
     contains inline tags (e.g. <strong>) — tiptap can't interleave <mark> with
     <strong>, so it nests/splits. To keep the highlight reading as ONE continuous
     band (Google-Docs style), the fragments must be flush rectangles: no rounding
     and no horizontal padding (override the generic .ProseMirror mark rule), so
     adjacent fragments touch with no rounded notches or gaps. */
  border-radius: 0;
  padding-left: 0;
  padding-right: 0;
  /* Bleed the background vertically to fill the FULL line box so wrapped,
     multi-line highlights are continuous (no white gaps), regardless of the
     paragraph's line-height. The text content area is ~1.2em tall, so the leading
     to fill is (lineHeight - 1.2em); we pad half of it on each side, plus 1px so
     adjacent lines overlap rather than leave a sub-pixel seam. Inline vertical
     padding doesn't affect layout, so this is purely visual. */
  padding-top: max(1px, calc((1lh - 1.2em) / 2 + 1px));
  padding-bottom: max(1px, calc((1lh - 1.2em) / 2 + 1px));
  box-decoration-break: clone;
  -webkit-box-decoration-break: clone;
  transition: background-color 0.15s ease;
}

.ProseMirror mark.comment-highlight:hover {
  background-color: rgba(250, 204, 21, 0.55);
}

/* Active = the comment currently being viewed: a much stronger, darker amber so
   it clearly stands out from the resting light-yellow highlights. */
.ProseMirror mark.comment-highlight[data-comment-active="true"] {
  background-color: rgba(245, 158, 11, 0.95);
}

/* Code block styles */
.ProseMirror pre {
  background-color: #1e293b;
  border-radius: 0.5rem;
  padding: 1rem;
  margin: 1rem 0;
  overflow-x: auto;
}

.ProseMirror pre code {
  font-family: ui-monospace, SFMono-Regular, SF Mono, Menlo, Consolas, Liberation Mono, monospace;
  font-size: 0.875rem;
  color: #e2e8f0;
  background: none;
  padding: 0;
}

/* YouTube embed styles */
.ProseMirror div[data-youtube-video] {
  margin: 1rem 0;
}

.ProseMirror div[data-youtube-video] iframe {
  border-radius: 0.5rem;
}

/* Image styles */
.ProseMirror img {
  max-width: 100%;
  height: auto;
  border-radius: 0.5rem;
}

/* Placeholder for empty answer editor */
[data-tiptap--editor-form-actions-value] .ProseMirror > p:only-child:has(> br:only-child)::before {
  content: 'Type your answer here...' !important;
  color: oklch(var(--bc) / 0.3);
  float: left;
  height: 0;
  pointer-events: none;
}

/* ── Google-Docs-style page surface for the draft document editor ──
   The editor's scroll area gets a muted backdrop; the content body becomes a
   centered white "page" with a soft shadow, while the formatting toolbar stays a
   flush, full-width bar pinned to the top. Scoped to `.draft-doc-surface` (added
   on the editor's scroll wrapper) so it never touches the in-form/answer editors. */

/* Muted backdrop behind the floating page */
.draft-doc-surface {
  background: var(--color-base-200);
}

/* Toolbar: keep it an opaque, full-width bar over the backdrop, and pin it to the
   same height (h-14 = 3.5rem) as the chat column's top header so the two column
   headers line up exactly. */
.draft-doc-surface [data-controller="tiptap--editor"] > .sticky {
  background: var(--color-base-100) !important;
  height: 3.5rem;
}

/* Editor body: transparent so the backdrop shows through; generous gutter so the
   page floats with margin on every side */
.draft-doc-surface [data-controller="tiptap--editor"] > .tiptap-content {
  background: transparent !important;
  padding: 1.5rem 1.5rem 4rem !important;
}

/* The page itself: a centered white sheet with a soft shadow */
.draft-doc-surface [data-controller="tiptap--editor"] > .tiptap-content > [data-tiptap--editor-target="editor"] {
  background: var(--color-base-100);
  max-width: 52rem;
  margin: 0 auto;
  padding: 2rem 2.75rem !important;
  border: 1px solid color-mix(in oklch, var(--color-base-content), transparent 92%);
  border-radius: 0.5rem;
  box-shadow: 0 1px 2px color-mix(in oklch, var(--color-base-content), transparent 88%),
              0 6px 24px color-mix(in oklch, var(--color-base-content), transparent 90%);
  min-height: 60vh !important;
}

/* Markdown editor: shared metrics for gutter + textarea alignment */
.gutter,
.editor-textarea {
  font-family: ui-monospace, SFMono-Regular, SF Mono, Menlo, Consolas, monospace;
  font-size: 0.875rem;
  line-height: 1.625;
  padding-top: 0.75rem;
  padding-bottom: 0.75rem;
}

.editor-textarea {
  padding-left: 0.75rem;
  padding-right: 0.75rem;
}

/* Individual line number */
.gutter-line {
  text-align: right;
  padding-right: 0.75rem;
  color: oklch(var(--bc) / 0.2);
  pointer-events: none;
}
