/* ========== TipTap Editor Styles (v2) ========== */

/* ---------- 에디터 ---------- */
#btn-tiptap {
    padding: 8px 20px;
    font-size: 14px;
    cursor: pointer;
    border: 1px solid #e0e0e0;
    border-radius: 6px;
    background: #fff;
    transition: background 0.15s;
}
#btn-tiptap:hover { background: #f5f5f5; }

/* ---------- 툴바 ---------- */
#toolbar {
    display: none;
    flex-wrap: wrap;
    gap: 2px;
    padding: 6px 8px;
    border: 1px solid #e0e0e0;
    border-bottom: none;
    border-radius: 8px 8px 0 0;
    background: #fafafa;
}
#toolbar .divider {
    width: 1px;
    margin: 2px 6px;
    background: #ddd;
}
#toolbar button {
    padding: 4px 8px;
    font-size: 13px;
    cursor: pointer;
    border: none;
    border-radius: 4px;
    background: transparent;
    color: #555;
    line-height: 1.4;
}
#toolbar button:hover { background: #eee; }
#toolbar button.is-active {
    background: #e3e3e3;
    color: #000;
    font-weight: 600;
}

#toolbar .toolbar-group {
    position: relative;
}

#btn-table-tools {
    cursor: pointer;
}

#toolbar .toolbar-menu {
    position: absolute;
    top: calc(100% + 6px);
    left: 0;
    min-width: 150px;
    z-index: 30;
    border: 1px solid #ddd;
    border-radius: 8px;
    background: #fff;
    box-shadow: 0 6px 16px rgba(0, 0, 0, 0.12);
    padding: 6px;
    display: flex;
    flex-direction: column;
    gap: 2px;
}

#toolbar .toolbar-menu.hidden {
    display: none;
}

#toolbar .toolbar-menu button {
    text-align: left;
    width: 100%;
    padding: 6px 8px;
    cursor: pointer;
}

body.dark #toolbar .toolbar-menu {
    background: #2a2a2a;
    border-color: #3f3f3f;
}

body.dark #toolbar .toolbar-menu button {
    color: #ddd;
}

body.dark #toolbar .toolbar-menu button:hover {
    background: #3a3a3a;
}

/* ---------- 에디터 ---------- */
#editor-wrapper {
    display: none;
    border: 1px solid #e0e0e0;
    border-radius: 0 0 8px 8px;
    min-height: 400px;
}
#editor {
    padding: 16px 24px;
    outline: none;
}

/* ---------- 에디터 콘텐츠 스타일 ---------- */
#editor .tiptap {
    outline: none;
}
#editor .tiptap > *:first-child { margin-top: 0; }
#editor .tiptap p { margin: 4px 0; line-height: 1.6; }
#editor .tiptap h1 { font-size: 1.875em; font-weight: 700; margin: 24px 0 8px; }
#editor .tiptap h2 { font-size: 1.5em; font-weight: 600; margin: 20px 0 6px; }
#editor .tiptap h3 { font-size: 1.25em; font-weight: 600; margin: 16px 0 4px; }

#editor .tiptap ul,
#editor .tiptap ol {
    padding-left: 24px;
    margin: 4px 0;
}

#editor .tiptap blockquote {
    border-left: 3px solid #d6d6d6;
    margin: 8px 0;
    padding: 4px 16px;
    color: #6b6b6b;
}

#editor .tiptap pre {
    background: #f7f6f3;
    border-radius: 6px;
    padding: 12px 16px;
    font-family: 'SFMono-Regular', Menlo, Consolas, monospace;
    font-size: 0.9em;
    overflow-x: auto;
    margin: 8px 0;
}
#editor .tiptap pre code {
    background: none;
    padding: 0;
    font-size: inherit;
    white-space: pre;
    word-wrap: normal;
    overflow-wrap: normal;
}

#editor .tiptap code {
    background: rgba(135, 131, 120, 0.15);
    border-radius: 3px;
    padding: 2px 4px;
    font-family: 'SFMono-Regular', Menlo, Consolas, monospace;
    font-size: 0.9em;
    color: #eb5757;
}

#editor .tiptap mark {
    background: #fff3b0;
    padding: 1px 2px;
    border-radius: 2px;
}

#editor .tiptap hr {
    border: none;
    border-top: 1px solid #e0e0e0;
    margin: 16px 0;
}

#editor .tiptap table {
    width: 100%;
    border-collapse: collapse;
    margin: 12px 0;
    table-layout: fixed;
}

#editor .tiptap th,
#editor .tiptap td {
    border: 1px solid #d8d8d8;
    padding: 8px 10px;
    vertical-align: top;
}

#editor .tiptap th {
    background: #f7f7f5;
    font-weight: 600;
}

body.dark #editor .tiptap th,
body.dark #editor .tiptap td {
    border-color: #4a4a4a;
}

body.dark #editor .tiptap th {
    background: #2f2f2f;
}

body.dark #editor .tiptap pre {
    background: #2a2a2a;
}

body.dark #editor .tiptap pre code {
    color: #d4d4d4;
}

body.dark #editor .tiptap code {
    background: rgba(200, 200, 200, 0.15);
    color: #f07178;
}

/* TaskList */
#editor .tiptap ul[data-type="taskList"] {
    list-style: none;
    padding-left: 4px;
}
#editor .tiptap ul[data-type="taskList"] li {
    display: flex;
    align-items: flex-start;
    gap: 8px;
    margin: 2px 0;
}
#editor .tiptap ul[data-type="taskList"] li label {
    margin-top: 4px;
}
#editor .tiptap ul[data-type="taskList"] li label input[type="checkbox"] {
    cursor: pointer;
    width: 16px;
    height: 16px;
    accent-color: #2eaadc;
}
#editor .tiptap ul[data-type="taskList"] li div {
    flex: 1;
}
#editor .tiptap ul[data-type="taskList"] li[data-checked="true"] > div {
    text-decoration: line-through;
    color: #999;
}

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

/* Image */
#editor .tiptap img {
    max-width: 100%;
    height: auto;
    border-radius: 4px;
    margin: 8px auto;
    display: block;
}
