/* TipTap WYSIWYG 编辑器样式 */

/* 编辑器容器 */
.forum-tiptap-editor {
    border: 1px solid var(--forum-border, #ddd);
    border-radius: 6px;
    background: #fff;
    min-height: 200px;
    max-height: 480px;
    overflow-y: auto;
}

/* 编辑器包裹层（工具栏 + 编辑区 + 状态栏），为状态栏浮动定位提供参照 */
.forum-tiptap-wrap {
    position: relative;
}

/* 行数 / 字数 状态栏：浮动在编辑区右下角 */
.forum-tiptap-statusbar {
    position: absolute;
    right: 8px;
    bottom: 4px;
    z-index: 5;
    display: flex;
    gap: 10px;
    padding: 2px 10px;
    background: rgba(255, 255, 255, 0.85);
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
    border-radius: 12px;
    box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.06);
    font-size: 12px;
    color: #999;
    pointer-events: none;
    font-variant-numeric: tabular-nums;
    user-select: none;
}

.forum-tiptap-editor .ProseMirror {
    padding: 12px 16px;
    min-height: 176px;
    outline: none;
    font-size: 14px;
    line-height: 1.6;
}

.forum-tiptap-editor .ProseMirror p {
    margin: 0 0 8px;
}

.forum-tiptap-editor .ProseMirror h1,
.forum-tiptap-editor .ProseMirror h2,
.forum-tiptap-editor .ProseMirror h3 {
    margin: 16px 0 8px;
    font-weight: 700;
}

.forum-tiptap-editor .ProseMirror h1 { font-size: 1.5em; }
.forum-tiptap-editor .ProseMirror h2 { font-size: 1.3em; }
.forum-tiptap-editor .ProseMirror h3 { font-size: 1.1em; }

.forum-tiptap-editor .ProseMirror ul,
.forum-tiptap-editor .ProseMirror ol {
    padding-left: 24px;
    margin: 0 0 8px;
}

.forum-tiptap-editor .ProseMirror blockquote {
    border-left: 3px solid var(--forum-brand, #2563eb);
    padding-left: 12px;
    margin: 0 0 8px;
    color: #666;
}

.forum-tiptap-editor .ProseMirror pre {
    background: #f5f5f5;
    border-radius: 4px;
    padding: 8px 12px;
    margin: 0 0 8px;
    overflow-x: auto;
    font-family: 'Courier New', monospace;
    font-size: 13px;
}

.forum-tiptap-editor .ProseMirror code {
    background: #f5f5f5;
    border-radius: 3px;
    padding: 1px 4px;
    font-family: 'Courier New', monospace;
    font-size: 0.9em;
}

.forum-tiptap-editor .ProseMirror pre code {
    background: none;
    padding: 0;
}

.forum-tiptap-editor .ProseMirror img {
    max-width: 100%;
    border-radius: 4px;
}

.forum-tiptap-editor .ProseMirror hr {
    border: none;
    border-top: 1px solid #e0e0e0;
    margin: 12px 0;
}

.forum-tiptap-editor .ProseMirror [data-hidden] {
    border: 2px dashed #f59e0b;
    border-radius: 4px;
    padding: 0;
    margin: 0 0 8px;
    background: #fffbeb;
    position: relative;
}

.forum-tiptap-editor .ProseMirror [data-hidden]::before {
    content: '隐藏内容';
    display: block;
    font-size: 12px;
    color: #f59e0b;
    font-weight: 600;
    margin-bottom: 4px;
}

.forum-tiptap-editor .ProseMirror [data-hidden][data-type="reply"]::before {
    content: '隐藏内容（回复可见）';
}

.forum-tiptap-editor .ProseMirror [data-hidden][data-type="login"]::before {
    content: '隐藏内容（登录可见）';
}

.forum-tiptap-editor .ProseMirror [data-hidden][data-type="purchase"]::before {
    content: '隐藏内容（付费购买）';
}

.forum-tiptap-editor .ProseMirror [data-hidden][data-type="level"]::before {
    content: '隐藏内容（用户等级）';
}

.forum-tiptap-editor .ProseMirror [data-hidden][data-type="users"]::before {
    content: '隐藏内容（指定用户）';
}

.forum-tiptap-editor .ProseMirror .forum-hidden-block-wrapper::before {
    display: none;
}

.forum-tiptap-editor .ProseMirror .forum-hidden-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 6px 12px;
    background: #fef3c7;
    border-bottom: 1px solid #f59e0b;
    border-radius: 4px 4px 0 0;
    user-select: none;
}

.forum-tiptap-editor .ProseMirror .forum-hidden-label {
    font-size: 12px;
    color: #d97706;
    font-weight: 600;
}

.forum-tiptap-editor .ProseMirror .forum-hidden-actions {
    display: flex;
    align-items: center;
    gap: 4px;
}

.forum-tiptap-editor .ProseMirror .forum-hidden-edit-btn {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 2px 8px;
    font-size: 12px;
    color: #d97706;
    background: #fff;
    border: 1px solid #f59e0b;
    border-radius: 4px;
    cursor: pointer;
    transition: background 0.15s, color 0.15s;
}

.forum-tiptap-editor .ProseMirror .forum-hidden-edit-btn:hover {
    background: #f59e0b;
    color: #fff;
}

.forum-tiptap-editor .ProseMirror .forum-hidden-del-btn {
    display: inline-flex;
    align-items: center;
    padding: 2px 8px;
    font-size: 12px;
    color: #dc2626;
    background: #fff;
    border: 1px solid #ef4444;
    border-radius: 4px;
    cursor: pointer;
    transition: background 0.15s, color 0.15s;
}

.forum-tiptap-editor .ProseMirror .forum-hidden-del-btn:hover {
    background: #ef4444;
    color: #fff;
}

.forum-tiptap-editor .ProseMirror .forum-hidden-content {
    padding: 8px 12px;
}

.forum-tiptap-editor .ProseMirror-focused [data-hidden] {
    border-color: #d97706;
}

.forum-tiptap-editor .ProseMirror .ProseMirror-selectednode {
    outline: 2px solid var(--forum-brand, #2563eb);
    outline-offset: 2px;
    border-radius: 6px;
}

.forum-tiptap-editor .ProseMirror .forum-image-wrapper {
    position: relative;
    display: inline-block;
    max-width: 100%;
}

.forum-tiptap-editor .ProseMirror .forum-image-wrapper img {
    max-width: 100%;
    border-radius: 4px;
    display: block;
}

.forum-tiptap-editor .ProseMirror .forum-image-toolbar {
    position: absolute;
    top: 4px;
    right: 4px;
    display: none;
    gap: 4px;
    padding: 2px;
    background: rgba(0, 0, 0, 0.7);
    border-radius: 4px;
    z-index: 10;
}

.forum-tiptap-editor .ProseMirror .forum-image-wrapper.ProseMirror-selectednode .forum-image-toolbar {
    display: flex;
}

.forum-tiptap-editor .ProseMirror .forum-image-toolbar button {
    padding: 4px 6px;
    font-size: 13px;
    color: #fff;
    background: transparent;
    border: none;
    border-radius: 3px;
    cursor: pointer;
    line-height: 1;
}

.forum-tiptap-editor .ProseMirror .forum-image-toolbar button:hover {
    background: rgba(255, 255, 255, 0.25);
}

.forum-link-toolbar {
    position: fixed;
    z-index: 10000;
    display: flex;
    align-items: center;
    gap: 2px;
    padding: 4px 8px;
    background: #1e293b;
    border-radius: 6px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
    max-width: 360px;
}

.forum-link-toolbar .forum-link-toolbar-href {
    font-size: 12px;
    color: #94a3b8;
    max-width: 200px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    padding-right: 4px;
    border-right: 1px solid #475569;
    margin-right: 2px;
}

.forum-link-toolbar button {
    padding: 4px 6px;
    font-size: 13px;
    color: #e2e8f0;
    background: transparent;
    border: none;
    border-radius: 3px;
    cursor: pointer;
    line-height: 1;
}

.forum-link-toolbar button:hover {
    background: rgba(255, 255, 255, 0.15);
}

.forum-tiptap-editor .ProseMirror p.is-editor-empty:first-child::before {
    content: attr(data-placeholder);
    color: #aaa;
    pointer-events: none;
    float: left;
    height: 0;
}

/* 工具栏 */
.forum-tiptap-toolbar {
    display: flex;
    flex-wrap: wrap;
    gap: 2px;
    padding: 8px;
    border-bottom: 1px solid var(--forum-border, #ddd);
    background: #f9f9f9;
    border-radius: 6px 6px 0 0;
}

.forum-tiptap-btn {
    width: 30px;
    height: 30px;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 1px solid transparent;
    border-radius: 4px;
    background: transparent;
    color: #555;
    cursor: pointer;
    font-size: 14px;
    transition: background 0.15s, border-color 0.15s;
}

.forum-tiptap-btn:hover {
    background: #e8e8e8;
    border-color: #d0d0d0;
}

.forum-tiptap-btn.is-active {
    background: var(--forum-brand, #2563eb);
    color: #fff;
}

/* 红包按钮：FontAwesome 无红包图形，用 emoji 渲染（覆盖 fa 基类 font-family） */
.forum-tiptap-btn.forum-redpacket-trigger::before {
    content: '🧧';
    font-family: inherit;
    font-style: normal;
    font-size: 15px;
    line-height: 1;
}

/* 音视频卡片（编辑器内，复用详情页样式） */
.forum-tiptap-editor .forum-audio-card,
.forum-tiptap-editor .forum-video-card {
    user-select: none;
}

/* ===== 下拉框 / 对话框 / 源码模式 ===== */

/* 全屏透明遮罩（捕获外部点击以关闭下拉/对话框） */
.forum-tiptap-overlay {
    position: fixed;
    inset: 0;
    z-index: 10000;
    background: transparent;
}

.forum-tiptap-overlay-dim {
    background: rgba(0, 0, 0, 0.3);
}

/* 下拉面板（标题、颜色、字号共用） */
.forum-tiptap-dropdown {
    position: fixed;
    z-index: 10001;
    min-width: 120px;
    max-width: 260px;
    background: #fff;
    border: 1px solid var(--forum-border, #ddd);
    border-radius: 6px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    padding: 4px;
}

/* 下拉项（文字类：标题 H1-H6） */
.forum-tiptap-dropdown-item {
    display: block;
    width: 100%;
    padding: 6px 12px;
    border: none;
    border-radius: 4px;
    background: transparent;
    color: #333;
    font-size: 14px;
    text-align: left;
    cursor: pointer;
}

.forum-tiptap-dropdown-item:hover {
    background: #f0f0f0;
}

/* 色板网格 */
.forum-tiptap-dropdown-swatches {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    gap: 4px;
    padding: 4px;
}

.forum-tiptap-dropdown-swatch {
    width: 28px;
    height: 28px;
    border: 1px solid #ddd;
    border-radius: 4px;
    cursor: pointer;
    transition: transform 0.1s;
}

.forum-tiptap-dropdown-swatch:hover {
    transform: scale(1.1);
}

.forum-tiptap-dropdown-swatch-white {
    border-color: #ccc;
    box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.05);
}

/* 自定义颜色行（色板最后一行） */
.forum-tiptap-dropdown-custom {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 8px 6px 6px;
    border-top: 1px solid #f0f0f0;
    margin-top: 4px;
}

/* 颜色选择器 + 文本输入组合成一个输入组 */
.forum-tiptap-color-input-group {
    display: flex;
    align-items: center;
    flex: 1;
    border: 1px solid #ddd;
    border-radius: 4px;
    overflow: hidden;
    background: #fff;
    transition: border-color 0.15s;
}

.forum-tiptap-color-input-group:focus-within {
    border-color: var(--forum-brand, #2563eb);
}

.forum-tiptap-color-picker {
    width: 36px;
    height: 30px;
    padding: 0;
    border: none;
    border-right: 1px solid #ddd;
    cursor: pointer;
    background: #fff;
    flex-shrink: 0;
}

.forum-tiptap-color-picker::-webkit-color-swatch-wrapper {
    padding: 3px;
}

.forum-tiptap-color-picker::-webkit-color-swatch {
    border: 1px solid #ddd;
    border-radius: 3px;
}

.forum-tiptap-color-picker::-moz-color-swatch {
    border: 1px solid #ddd;
    border-radius: 3px;
}

.forum-tiptap-color-text {
    flex: 1;
    min-width: 0;
    border: none;
    outline: none;
    padding: 0 8px;
    height: 30px;
    font-size: 13px;
    color: #333;
    background: transparent;
}

/* 应用按钮 */
.forum-tiptap-color-apply {
    padding: 6px 14px;
    border: none;
    border-radius: 4px;
    background: var(--forum-brand, #2563eb);
    color: #fff;
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    white-space: nowrap;
    transition: background 0.15s;
}

.forum-tiptap-color-apply:hover {
    background: var(--forum-brand-dark, #1d4ed8);
}

/* 字号下拉项 */
.forum-tiptap-dropdown-size {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 6px 12px;
    border: none;
    border-radius: 4px;
    background: transparent;
    color: #333;
    cursor: pointer;
    width: 100%;
    min-width: 140px;
}

.forum-tiptap-dropdown-size:hover {
    background: #f0f0f0;
}

.forum-tiptap-dropdown-size-tag {
    font-size: 11px;
    color: #999;
}

/* 对话框（链接、图片、隐藏内容） */
.forum-tiptap-dialog {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    z-index: 10001;
    min-width: 320px;
    max-width: 480px;
    background: #fff;
    border: 1px solid var(--forum-border, #ddd);
    border-radius: 8px;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.2);
    overflow: hidden;
}

.forum-tiptap-dialog-head {
    padding: 12px 16px;
    font-size: 15px;
    font-weight: 600;
    color: #333;
    border-bottom: 1px solid #eee;
    background: #f9f9f9;
}

.forum-tiptap-dialog-body {
    padding: 16px;
}

.forum-tiptap-dialog-field {
    margin-bottom: 12px;
}

.forum-tiptap-dialog-field:last-child {
    margin-bottom: 0;
}

.forum-tiptap-dialog-field label {
    display: block;
    margin-bottom: 4px;
    font-size: 13px;
    color: #555;
}

.forum-tiptap-dialog-field input {
    width: 100%;
    box-sizing: border-box;
    padding: 8px 10px;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-size: 14px;
    outline: none;
}

.forum-tiptap-dialog-field input:focus {
    border-color: var(--forum-brand, #2563eb);
}

.forum-tiptap-dialog-foot {
    display: flex;
    justify-content: flex-end;
    gap: 8px;
    padding: 12px 16px;
    border-top: 1px solid #eee;
    background: #f9f9f9;
}

.forum-tiptap-dialog-btn {
    padding: 6px 16px;
    border: 1px solid #ddd;
    border-radius: 4px;
    background: #fff;
    color: #555;
    font-size: 14px;
    cursor: pointer;
}

.forum-tiptap-dialog-btn:hover {
    background: #f0f0f0;
}

.forum-tiptap-dialog-btn-primary {
    background: var(--forum-brand, #2563eb);
    border-color: var(--forum-brand, #2563eb);
    color: #fff;
}

.forum-tiptap-dialog-btn-primary:hover {
    opacity: 0.9;
}

/* 源码模式 */
.forum-tiptap-source {
    width: 100%;
    box-sizing: border-box;
    border: 1px solid var(--forum-border, #ddd);
    border-radius: 6px;
    padding: 12px 16px;
    font-family: 'Courier New', monospace;
    font-size: 13px;
    line-height: 1.6;
    resize: vertical;
    outline: none;
    background: #fafafa;
    overflow-y: auto;
}

/* 隐藏内容对话框：下拉选择/价格行/用户选择器 */
.forum-tiptap-dialog select {
    width: 100%;
    padding: 8px 10px;
    border: 1px solid var(--forum-border, #ddd);
    border-radius: 6px;
    font-size: 14px;
    color: #333;
    background: #fff;
    box-sizing: border-box;
    outline: none;
}

.forum-tiptap-dialog select:focus {
    border-color: var(--forum-primary, #4a6cf7);
}

.forum-tiptap-dialog-field[data-show-for] {
    display: none;
}

.forum-tiptap-dialog-field.is-visible {
    display: block;
}

.forum-tiptap-price-row {
    display: flex;
    gap: 8px;
}

.forum-tiptap-price-row input {
    flex: 1;
}

.forum-tiptap-price-row select {
    width: 100px;
    flex-shrink: 0;
}

.forum-tiptap-userpicker {
    border: 1px solid var(--forum-border, #ddd);
    border-radius: 6px;
    background: #fff;
    padding: 4px;
}

.forum-tiptap-userpicker:focus-within {
    border-color: var(--forum-primary, #4a6cf7);
}

.forum-tiptap-user-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
}

.forum-tiptap-user-tags:not(:empty) {
    margin-bottom: 4px;
}

.forum-tiptap-user-tag {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 2px 4px 2px 8px;
    border-radius: 6px;
    background: rgba(74, 108, 247, 0.08);
    color: #4a6cf7;
    font-size: 12px;
    line-height: 1.5;
}

.forum-tiptap-user-tag-del {
    width: 16px;
    height: 16px;
    padding: 0;
    border: none;
    border-radius: 50%;
    background: transparent;
    color: #4a6cf7;
    font-size: 13px;
    line-height: 16px;
    text-align: center;
    cursor: pointer;
}

.forum-tiptap-user-tag-del:hover {
    background: #4a6cf7;
    color: #fff;
}

.forum-tiptap-user-search {
    width: 100%;
    border: none;
    padding: 4px 8px;
    font-size: 14px;
    background: transparent;
    box-sizing: border-box;
    outline: none;
}

.forum-tiptap-user-dropdown {
    position: fixed;
    z-index: 10002;
    max-height: 220px;
    overflow-y: auto;
    background: #fff;
    border: 1px solid var(--forum-border, #ddd);
    border-radius: 6px;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.12);
}

.forum-tiptap-user-option {
    padding: 8px 12px;
    font-size: 14px;
    color: #333;
    cursor: pointer;
}

.forum-tiptap-user-option:hover {
    background: rgba(74, 108, 247, 0.06);
}

.forum-tiptap-user-option.is-selected {
    color: #9ca3af;
    cursor: default;
}

.forum-tiptap-user-option.is-selected::after {
    content: '（已选）';
    font-size: 12px;
}

.forum-tiptap-user-empty {
    padding: 8px 12px;
    font-size: 12px;
    color: #9ca3af;
    text-align: center;
}

.forum-tiptap-dialog-tip {
    margin: 12px 0 0;
    font-size: 12px;
    color: #9ca3af;
    line-height: 1.6;
}

/* 标记浮动工具栏（颜色/背景/字号/标题） */
.forum-mark-toolbar {
    position: fixed;
    z-index: 10000;
    display: flex;
    align-items: center;
    gap: 2px;
    padding: 4px 8px;
    background: #1e293b;
    border-radius: 6px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
    max-width: 420px;
    flex-wrap: wrap;
}

.forum-mark-toolbar .forum-mark-toolbar-label {
    font-size: 12px;
    color: #94a3b8;
    padding-right: 4px;
    border-right: 1px solid #475569;
    margin-right: 2px;
    white-space: nowrap;
}

.forum-mark-toolbar .forum-mark-toolbar-label i {
    margin-right: 2px;
}

.forum-mark-toolbar button {
    padding: 4px 6px;
    font-size: 13px;
    color: #e2e8f0;
    background: transparent;
    border: none;
    border-radius: 3px;
    cursor: pointer;
    line-height: 1;
}

.forum-mark-toolbar button:hover {
    background: rgba(255, 255, 255, 0.15);
}

/* 代码块 NodeView */
.forum-tiptap-editor .ProseMirror .forum-codeblock-wrapper {
    position: relative;
    margin: 0 0 8px;
    border: 1px solid #e0e0e0;
    border-radius: 4px;
    overflow: hidden;
    background: #f5f5f5;
}

.forum-tiptap-editor .ProseMirror .forum-codeblock-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 4px 8px;
    background: #e8e8e8;
    border-bottom: 1px solid #d0d0d0;
    user-select: none;
    font-size: 12px;
}

.forum-tiptap-editor .ProseMirror .forum-codeblock-lang {
    color: #666;
    font-weight: 600;
    text-transform: uppercase;
    font-family: 'Courier New', monospace;
}

.forum-tiptap-editor .ProseMirror .forum-codeblock-header button {
    padding: 2px 8px;
    font-size: 12px;
    color: #555;
    background: transparent;
    border: 1px solid #ccc;
    border-radius: 3px;
    cursor: pointer;
    line-height: 1.5;
}

.forum-tiptap-editor .ProseMirror .forum-codeblock-header button:hover {
    background: #d8d8d8;
}

.forum-tiptap-editor .ProseMirror .forum-codeblock-wrapper pre {
    margin: 0;
    border-radius: 0;
}

/* 代码块对话框：代码输入区域 */
.forum-tiptap-dialog-code {
    width: 100%;
    box-sizing: border-box;
    padding: 10px 12px;
    border: 1px solid var(--forum-border, #ddd);
    border-radius: 6px;
    font-family: 'Courier New', monospace;
    font-size: 13px;
    line-height: 1.6;
    resize: vertical;
    outline: none;
    background: #fafafa;
    color: #333;
    min-height: 200px;
}

.forum-tiptap-dialog-code:focus {
    border-color: var(--forum-primary, #4a6cf7);
}
