/* TipTap 編輯器樣式 - 新後台系統頁面編輯器使用 */

/* ===== 編輯器外框 ===== */
.tiptap-wrapper {
  background: #fff;
  overflow: hidden;
}

/* ===== 工具列 ===== */
.tiptap-toolbar {
  position: sticky;
  top: 0;
  z-index: 10;
  background: #f8f9fa;
}

.tiptap-toolbar .btn {
  min-width: 32px;
  padding: 4px 8px;
  line-height: 1;
}

.tiptap-toolbar .btn.active {
  background-color: #3b5de7;
  color: #fff;
  border-color: #3b5de7;
}

.tiptap-toolbar .btn i.mdi {
  font-size: 16px;
  line-height: 1;
}

.tiptap-toolbar .tiptap-color-input {
  position: absolute;
  width: 100%;
  height: 100%;
  top: 0;
  left: 0;
  opacity: 0;
  cursor: pointer;
}

.tiptap-toolbar label.btn {
  position: relative;
  overflow: hidden;
}

/* ===== 編輯區（ProseMirror） ===== */
.tiptap-content .tiptap-prosemirror {
  outline: none;
  min-height: inherit;
}

.tiptap-content .tiptap-prosemirror > * + * {
  margin-top: 0.75em;
}

.tiptap-content .tiptap-prosemirror h1 { font-size: 1.75rem; font-weight: 700; line-height: 1.3; }
.tiptap-content .tiptap-prosemirror h2 { font-size: 1.5rem;  font-weight: 700; line-height: 1.3; }
.tiptap-content .tiptap-prosemirror h3 { font-size: 1.25rem; font-weight: 600; line-height: 1.4; }

.tiptap-content .tiptap-prosemirror p  { line-height: 1.7; }

.tiptap-content .tiptap-prosemirror ul,
.tiptap-content .tiptap-prosemirror ol {
  padding-left: 1.5rem;
}

.tiptap-content .tiptap-prosemirror li p {
  margin: 0;
}

.tiptap-content .tiptap-prosemirror blockquote {
  border-left: 4px solid #dee2e6;
  padding-left: 1rem;
  color: #6c757d;
  font-style: italic;
  margin: 1rem 0;
}

.tiptap-content .tiptap-prosemirror pre {
  background: #0d1117;
  color: #c9d1d9;
  padding: 0.75rem 1rem;
  border-radius: 6px;
  font-family: 'SFMono-Regular', Menlo, Consolas, monospace;
  font-size: 0.875rem;
  overflow-x: auto;
}

.tiptap-content .tiptap-prosemirror code {
  background: #f6f8fa;
  color: #d63384;
  padding: 0.125rem 0.375rem;
  border-radius: 4px;
  font-family: 'SFMono-Regular', Menlo, Consolas, monospace;
  font-size: 0.875em;
}

.tiptap-content .tiptap-prosemirror pre code {
  background: transparent;
  color: inherit;
  padding: 0;
}

.tiptap-content .tiptap-prosemirror hr {
  border: 0;
  border-top: 2px solid #dee2e6;
  margin: 1.5rem 0;
}

.tiptap-content .tiptap-prosemirror img {
  max-width: 100%;
  height: auto;
  border-radius: 4px;
  display: block;
  margin: 1rem auto;
}

.tiptap-content .tiptap-prosemirror a {
  color: #3b5de7;
  text-decoration: underline;
}

/* ===== 表格 ===== */
.tiptap-content .tiptap-prosemirror table {
  border-collapse: collapse;
  table-layout: fixed;
  width: 100%;
  overflow: hidden;
  margin: 1rem 0;
}

.tiptap-content .tiptap-prosemirror table td,
.tiptap-content .tiptap-prosemirror table th {
  border: 1px solid #ced4da;
  padding: 0.5rem 0.75rem;
  vertical-align: top;
  position: relative;
  min-width: 1em;
}

.tiptap-content .tiptap-prosemirror table th {
  background: #f1f3f5;
  font-weight: 600;
}

.tiptap-content .tiptap-prosemirror .selectedCell::after {
  content: "";
  position: absolute;
  inset: 0;
  background: rgba(59, 93, 231, 0.15);
  pointer-events: none;
}

.tiptap-content .tiptap-prosemirror .column-resize-handle {
  position: absolute;
  right: -2px;
  top: 0;
  bottom: 0;
  width: 4px;
  background: #3b5de7;
  pointer-events: none;
}

/* ===== Placeholder ===== */
.tiptap-content .tiptap-prosemirror p.is-editor-empty:first-child::before {
  content: attr(data-placeholder);
  color: #adb5bd;
  float: left;
  height: 0;
  pointer-events: none;
}

/* ===== 原始碼模式 ===== */
.tiptap-wrapper.source-mode .tiptap-toolbar .btn:not([data-tiptap-cmd="source"]) {
  opacity: 0.4;
  pointer-events: none;
}

.tiptap-source {
  border: none;
  border-radius: 0;
  resize: vertical;
}

.tiptap-source:focus {
  box-shadow: none;
  outline: none;
}
