/* Tiptap Editor Styles */

/* ProseMirror base */
.ProseMirror {
  outline: none;
  min-height: 300px;
  padding: 1rem;
  flex: 1;
}

.ProseMirror p.is-editor-empty:first-child::before {
  content: attr(data-placeholder);
  float: left;
  color: #9B958C;
  pointer-events: none;
  height: 0;
  font-style: italic;
}

/* Typography in editor */
.tiptap-content h1 {
  font-family: "Newsreader", Georgia, serif;
  font-size: 1.75rem;
  font-weight: 600;
  line-height: 1.3;
  margin-bottom: 0.75rem;
  margin-top: 1.5rem;
  color: #2D2A26;
}

.tiptap-content h2 {
  font-family: "Newsreader", Georgia, serif;
  font-size: 1.35rem;
  font-weight: 500;
  line-height: 1.35;
  margin-bottom: 0.5rem;
  margin-top: 1.25rem;
  color: #2D2A26;
}

.tiptap-content h3 {
  font-family: "Newsreader", Georgia, serif;
  font-size: 1.15rem;
  font-weight: 500;
  line-height: 1.4;
  margin-bottom: 0.5rem;
  margin-top: 1rem;
  color: #2D2A26;
}

.tiptap-content p {
  margin-bottom: 0.5rem;
  line-height: 1.65;
}

.tiptap-content ul:not([data-type="taskList"]) {
  list-style-type: disc;
  padding-left: 1.5rem;
  margin-bottom: 0.5rem;
}

.tiptap-content ol {
  list-style-type: decimal;
  padding-left: 1.5rem;
  margin-bottom: 0.5rem;
}

.tiptap-content li {
  margin-bottom: 0.25rem;
}

.tiptap-content blockquote {
  border-left: 3px solid #D4835E;
  padding-left: 1rem;
  margin-left: 0;
  margin-bottom: 0.75rem;
  color: #6B6560;
  font-style: italic;
}

.tiptap-content hr {
  border: none;
  border-top: 1px solid #E2DCD4;
  margin: 1.5rem 0;
}

.tiptap-content code {
  font-family: "JetBrains Mono", monospace;
  background: #F3EFE9;
  padding: 0.15rem 0.35rem;
  border-radius: 4px;
  font-size: 0.875em;
  color: #D4835E;
}

.tiptap-content pre {
  font-family: "JetBrains Mono", monospace;
  background: #2D2A26;
  color: #FAF8F5;
  padding: 1rem;
  border-radius: 10px;
  margin-bottom: 0.75rem;
  overflow-x: auto;
}

.tiptap-content pre code {
  background: none;
  color: inherit;
  padding: 0;
  border-radius: 0;
  font-size: 0.85em;
}

/* Highlight */
.tiptap-content mark {
  background-color: rgba(212, 131, 94, 0.2);
  padding: 0.1rem 0.15rem;
  border-radius: 2px;
}

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

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

.tiptap-content ul[data-type="taskList"] li label {
  display: flex;
  align-items: center;
  margin-top: 0.15rem;
}

.tiptap-content ul[data-type="taskList"] li label input[type="checkbox"] {
  appearance: none;
  width: 1rem;
  height: 1rem;
  border: 1.5px solid #D6D0C8;
  border-radius: 4px;
  cursor: pointer;
  transition: all 0.15s;
  flex-shrink: 0;
}

.tiptap-content ul[data-type="taskList"] li label input[type="checkbox"]:checked {
  background: #D4835E;
  border-color: #D4835E;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 16 16' fill='white' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M12.207 4.793a1 1 0 010 1.414l-5 5a1 1 0 01-1.414 0l-2-2a1 1 0 011.414-1.414L6.5 9.086l4.293-4.293a1 1 0 011.414 0z'/%3E%3C/svg%3E");
  background-size: 100% 100%;
}

.tiptap-content ul[data-type="taskList"] li[data-checked="true"] > div > p {
  text-decoration: line-through;
  color: #9B958C;
}

/* Tables */
.tiptap-content table {
  border-collapse: collapse;
  width: 100%;
  margin-bottom: 1rem;
  table-layout: fixed;
}

.tiptap-content th,
.tiptap-content td {
  border: 1px solid #E2DCD4;
  padding: 0.5rem 0.75rem;
  min-width: 80px;
  vertical-align: top;
}

.tiptap-content th {
  background: #F3EFE9;
  font-weight: 500;
  text-align: left;
}

.tiptap-content td {
  background: #FFFFFF;
}

/* Selected cell */
.tiptap-content .selectedCell::after {
  content: "";
  position: absolute;
  inset: 0;
  background: rgba(212, 131, 94, 0.1);
  pointer-events: none;
  z-index: 1;
}

.tiptap-content th,
.tiptap-content td {
  position: relative;
}

/* Column resize handle */
.column-resize-handle {
  position: absolute;
  right: -2px;
  top: 0;
  bottom: 0;
  width: 4px;
  background: #D4835E;
  cursor: col-resize;
  z-index: 10;
}

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

/* Ghost content overlay */
.tiptap-ghost .ProseMirror {
  opacity: 0.4;
  user-select: none;
}

.tiptap-ghost .ProseMirror * {
  pointer-events: none;
}

/* Bubble menu */
.tiptap-bubble-menu {
  /* Bubble menu disabled — formatting via slash commands and toolbar only */
  display: none !important;
  position: absolute;
  background: #FFFFFF;
  border: 1px solid #E2DCD4;
  border-radius: 10px;
  box-shadow: 0 8px 30px rgba(45, 42, 38, 0.12), 0 2px 8px rgba(45, 42, 38, 0.06);
  padding: 0.25rem;
  gap: 0.125rem;
  z-index: 50;
}

.tiptap-bubble-menu button {
  width: 2rem;
  height: 2rem;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 6px;
  color: #6B6560;
  transition: all 0.15s;
}

.tiptap-bubble-menu button:hover {
  background: #F3EFE9;
  color: #2D2A26;
}

.tiptap-bubble-menu button.is-active {
  background: rgba(212, 131, 94, 0.12);
  color: #D4835E;
}

/* Slash command menu */
.tiptap-slash-menu {
  position: absolute;
  background: #FFFFFF;
  border: 1px solid #E2DCD4;
  border-radius: 10px;
  box-shadow: 0 8px 30px rgba(45, 42, 38, 0.12), 0 2px 8px rgba(45, 42, 38, 0.06);
  padding: 0.375rem;
  min-width: 220px;
  max-height: 300px;
  overflow-y: auto;
  z-index: 50;
}

/* Table toolbar */
.tiptap-table-toolbar {
  position: absolute;
  background: #FFFFFF;
  border: 1px solid #E2DCD4;
  border-radius: 10px;
  box-shadow: 0 8px 30px rgba(45, 42, 38, 0.12), 0 2px 8px rgba(45, 42, 38, 0.06);
  padding: 0.25rem;
  display: flex;
  align-items: center;
  gap: 0.125rem;
  z-index: 50;
}

.tiptap-table-toolbar button {
  width: 2rem;
  height: 2rem;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 6px;
  color: #6B6560;
  transition: all 0.15s;
}

.tiptap-table-toolbar button:hover {
  background: #F3EFE9;
  color: #2D2A26;
}

.tiptap-table-toolbar-danger:hover {
  background: rgba(220, 38, 38, 0.08) !important;
  color: #DC2626 !important;
}

.tiptap-table-toolbar-divider {
  width: 1px;
  height: 1.25rem;
  background: #E2DCD4;
  margin: 0 0.125rem;
}

/* Status indicator */
.tiptap-status {
  font-size: 0.75rem;
  transition: opacity 0.3s, color 0.3s;
}

/* =============================================================================
   Read-only timeline preview.
   Renders the same Tiptap JSON but tighter — used in the client history
   timeline so notes keep their tables, headings, lists and marks without
   eating half the viewport.
   ============================================================================= */
.tiptap-timeline .tiptap-content h1,
.tiptap-timeline .tiptap-content h2,
.tiptap-timeline .tiptap-content h3 {
  margin-top: 0.5rem;
  margin-bottom: 0.25rem;
}

.tiptap-timeline .tiptap-content h1 { font-size: 1.1rem; }
.tiptap-timeline .tiptap-content h2 { font-size: 1rem; }
.tiptap-timeline .tiptap-content h3 { font-size: 0.9rem; }

.tiptap-timeline .tiptap-content p,
.tiptap-timeline .tiptap-content ul,
.tiptap-timeline .tiptap-content ol,
.tiptap-timeline .tiptap-content blockquote,
.tiptap-timeline .tiptap-content pre {
  margin-top: 0;
  margin-bottom: 0.35rem;
  font-size: 0.8125rem;
  line-height: 1.55;
}

.tiptap-timeline .tiptap-content p:last-child,
.tiptap-timeline .tiptap-content ul:last-child,
.tiptap-timeline .tiptap-content ol:last-child {
  margin-bottom: 0;
}

.tiptap-timeline .tiptap-content blockquote {
  padding-left: 0.75rem;
  margin-bottom: 0.5rem;
}

.tiptap-timeline .tiptap-content hr {
  margin: 0.5rem 0;
}

.tiptap-timeline .tiptap-content table {
  font-size: 0.75rem;
  margin-bottom: 0.5rem;
}

.tiptap-timeline .tiptap-content th,
.tiptap-timeline .tiptap-content td {
  padding: 0.3rem 0.5rem;
}
