/* Block Editor Styles */

/* ProseMirror 기본 스타일 (Tiptap 필수) */
.ProseMirror {
  outline: none;
  white-space: pre-wrap;
  word-wrap: break-word;
}

.ProseMirror[contenteditable="true"] {
  cursor: text;
}

.ProseMirror:focus {
  outline: none;
}

/* 에디터 컨테이너 */
.block-editor {
  position: relative;
  min-height: 300px;
  width: 100%;
}

.block-editor__prose {
  outline: none;
  min-height: 200px;
  padding: var(--spacing-md, 16px);
  font-family: var(--font-family-body, system-ui, -apple-system, sans-serif);
  font-size: var(--font-size-md, 16px);
  line-height: 1.7;
  color: var(--color-text-primary, #18181b);
}

.block-editor__prose:focus {
  outline: none;
}

/* Typography */
.block-editor__prose h1 {
  font-size: 2em;
  font-weight: 700;
  margin: 1.5em 0 0.5em;
  line-height: 1.3;
}

.block-editor__prose h2 {
  font-size: 1.5em;
  font-weight: 600;
  margin: 1.25em 0 0.5em;
  line-height: 1.35;
}

.block-editor__prose h3 {
  font-size: 1.25em;
  font-weight: 600;
  margin: 1em 0 0.5em;
  line-height: 1.4;
}

.block-editor__prose p {
  margin: 0.75em 0;
}

.block-editor__prose ul,
.block-editor__prose ol {
  padding-left: 1.5em;
  margin: 0.75em 0;
}

.block-editor__prose li {
  margin: 0.25em 0;
}

.block-editor__prose blockquote {
  border-left: 3px solid var(--color-border-strong, #a1a1aa);
  padding-left: 1em;
  margin: 1em 0;
  color: var(--color-text-secondary, #71717a);
  font-style: italic;
}

.block-editor__prose pre {
  background-color: var(--color-bg-muted, #f4f4f5);
  padding: 1em;
  border-radius: var(--radius-md, 8px);
  overflow-x: auto;
  font-family: var(--font-family-mono, ui-monospace, monospace);
  font-size: 0.9em;
  margin: 1em 0;
}

.block-editor__prose code {
  background-color: var(--color-bg-muted, #f4f4f5);
  padding: 0.15em 0.4em;
  border-radius: var(--radius-sm, 4px);
  font-family: var(--font-family-mono, ui-monospace, monospace);
  font-size: 0.9em;
}

.block-editor__prose pre code {
  background: none;
  padding: 0;
}

.block-editor__prose hr {
  border: none;
  border-top: 2px solid var(--color-border, #e5e7eb);
  margin: 2em 0;
}

.block-editor__prose a,
.block-editor__link {
  color: var(--color-primary-main, #8b5cf6);
  text-decoration: underline;
  text-underline-offset: 2px;
}

.block-editor__prose a:hover {
  color: var(--color-primary-dark, #7c3aed);
}

/* 플레이스홀더 */
.block-editor__prose p.is-editor-empty:first-child::before {
  content: attr(data-placeholder);
  color: var(--color-text-tertiary, #a1a1aa);
  pointer-events: none;
  float: left;
  height: 0;
}

/* 드래그 핸들 - 호버 시에만 표시 */
.block-editor__prose > * {
  position: relative;
  transition: padding-left 0.15s ease;
}

.block-editor__prose > *.block-editor--hover {
  padding-left: 28px;
}

.block-editor__prose > *::before {
  content: "";
  position: absolute;
  left: 0;
  top: 50%;
  transform: translateY(-50%);
  width: 20px;
  height: 20px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='20' height='20' viewBox='0 0 24 24' fill='none' stroke='%23a1a1aa' stroke-width='2'%3E%3Ccircle cx='9' cy='6' r='1.5'/%3E%3Ccircle cx='15' cy='6' r='1.5'/%3E%3Ccircle cx='9' cy='12' r='1.5'/%3E%3Ccircle cx='15' cy='12' r='1.5'/%3E%3Ccircle cx='9' cy='18' r='1.5'/%3E%3Ccircle cx='15' cy='18' r='1.5'/%3E%3C/svg%3E");
  background-size: contain;
  background-repeat: no-repeat;
  background-position: center;
  cursor: grab;
  opacity: 0;
  transition: opacity 0.15s ease;
}

.block-editor__prose > *.block-editor--hover::before {
  opacity: 1;
}

/* 스트리밍 모드 */
.block-editor.streaming .block-editor__prose {
  cursor: default;
  user-select: none;
}

.block-editor.streaming .block-editor__prose > *::before {
  display: none !important;
}

.block-editor.streaming .block-editor__prose > * {
  padding-left: 0 !important;
}

/* 스트리밍 인디케이터 */
.block-editor.streaming::after {
  content: "";
  display: inline-block;
  width: 8px;
  height: 16px;
  background-color: var(--color-primary-main, #8b5cf6);
  animation: blink 1s infinite;
  margin-left: 2px;
  vertical-align: text-bottom;
}

@keyframes blink {
  0%, 50% { opacity: 1; }
  51%, 100% { opacity: 0; }
}

/* 저장 상태 */
.block-editor__status {
  position: absolute;
  bottom: var(--spacing-sm, 8px);
  right: var(--spacing-md, 16px);
  font-size: var(--font-size-sm, 12px);
  color: var(--color-text-tertiary, #a1a1aa);
  transition: color 0.15s ease;
}

.block-editor__status[data-status="saving"] {
  color: var(--color-warning-main, #f59e0b);
}

.block-editor__status[data-status="saved"] {
  color: var(--color-success-main, #22c55e);
}

.block-editor__status[data-status="error"] {
  color: var(--color-danger-main, #ef4444);
}

/* 하이라이트 색상 */
.block-editor__prose mark {
  background-color: #fef3c7;
  padding: 0.1em 0.2em;
  border-radius: 2px;
}

.block-editor__prose mark[data-color="#fef3c7"] { background-color: #fef3c7; }
.block-editor__prose mark[data-color="#d1fae5"] { background-color: #d1fae5; }
.block-editor__prose mark[data-color="#cffafe"] { background-color: #cffafe; }
.block-editor__prose mark[data-color="#fce7f3"] { background-color: #fce7f3; }
.block-editor__prose mark[data-color="#ede9fe"] { background-color: #ede9fe; }

/* BubbleMenu 래퍼 - 클릭 이벤트 통과 */
.bubble-menu-wrapper {
  position: absolute;
  top: 0;
  left: 0;
  pointer-events: none;
  z-index: 100;
}

/* BubbleMenu / Tippy.js 스타일 오버라이드 */
/* Tippy가 요소를 body로 이동시키므로 tippy-box 내부 선택자 사용 */
.tippy-box .selection-toolbar,
.tippy-content .selection-toolbar,
.bubble-menu-wrapper .selection-toolbar {
  opacity: 1 !important;
  visibility: visible !important;
  transform: none !important;
  position: static !important;
  pointer-events: auto; /* 툴바 자체는 클릭 가능 */
}

/* Tippy 박스 스타일 */
.tippy-box[data-theme~='light-border'] {
  background: transparent;
  border: none;
  box-shadow: none;
}

.tippy-box {
  background: transparent !important;
  border: none !important;
  box-shadow: none !important;
}

.tippy-content {
  padding: 0 !important;
}

/* 빈 에디터 스타일 */
.block-editor--empty .block-editor__prose {
  display: flex;
  align-items: flex-start;
  justify-content: flex-start;
}

/* 반응형 */
@media (max-width: 768px) {
  .block-editor__prose {
    padding: var(--spacing-sm, 12px);
    font-size: var(--font-size-sm, 14px);
  }

  .block-editor__prose > *::before {
    display: none;
  }

  .block-editor__prose > *.block-editor--hover {
    padding-left: 0;
  }
}
