/* ========== Rich Editor 样式 ========== */

/* 工具栏 */
.re-toolbar {
    display: flex;
    align-items: center;
    gap: 2px;
    padding: 6px 8px;
    background: #f8fafc;
    border-bottom: 1px solid #e2e8f0;
    flex-wrap: wrap;
}
.re-toolbar.re-compact {
    padding: 4px 6px;
    gap: 1px;
}
.re-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 30px;
    height: 28px;
    border: none;
    background: transparent;
    border-radius: 6px;
    cursor: pointer;
    font-size: 13px;
    color: #475569;
    transition: all 0.15s;
}
.re-btn:hover {
    background: #e2e8f0;
    color: #1e293b;
}
.re-compact .re-btn {
    width: 26px;
    height: 24px;
    font-size: 12px;
}
.re-bold { font-weight: 700; }
.re-italic { font-style: italic; }
.re-code { font-family: Consolas, monospace; font-size: 11px; }
.re-sep {
    width: 1px;
    height: 18px;
    background: #e2e8f0;
    margin: 0 4px;
}
.re-dropdown-wrap {
    position: relative;
}

/* 面板通用 */
.re-panel {
    position: absolute;
    top: 100%;
    left: 0;
    z-index: 100;
    background: white;
    border: 1px solid #e2e8f0;
    border-radius: 12px;
    box-shadow: 0 10px 40px -4px rgba(0,0,0,0.12);
    margin-top: 4px;
}
/* 颜色面板 */
.re-color-panel {
    padding: 10px;
    display: grid;
    grid-template-columns: repeat(10, 1fr);
    gap: 4px;
    width: 240px;
}
.re-swatch {
    width: 20px;
    height: 20px;
    border-radius: 4px;
    border: none;
    cursor: pointer;
    transition: transform 0.15s;
}
.re-swatch:hover {
    transform: scale(1.3);
    box-shadow: 0 2px 8px rgba(0,0,0,0.2);
}

/* 字体面板 */
.re-font-panel {
    padding: 6px;
    width: 180px;
    max-height: 320px;
    overflow-y: auto;
}
.re-font-item {
    display: block;
    width: 100%;
    text-align: left;
    padding: 6px 10px;
    border: none;
    background: transparent;
    border-radius: 6px;
    cursor: pointer;
    font-size: 13px;
    color: #334155;
    transition: background 0.15s;
}
.re-font-item:hover {
    background: #f1f5f9;
}

/* Emoji 面板 */
.re-emoji-panel {
    width: 300px;
    padding: 0;
}
.re-emoji-tabs {
    display: flex;
    gap: 0;
    border-bottom: 1px solid #e2e8f0;
    overflow-x: auto;
    padding: 0 4px;
}
.re-emoji-tab {
    padding: 8px 10px;
    border: none;
    background: transparent;
    font-size: 12px;
    color: #64748b;
    cursor: pointer;
    white-space: nowrap;
    border-bottom: 2px solid transparent;
    transition: all 0.15s;
}
.re-emoji-tab:hover { color: #334155; }
.re-emoji-tab.active {
    color: #3b82f6;
    border-bottom-color: #3b82f6;
}
.re-emoji-body {
    display: grid;
    grid-template-columns: repeat(10, 1fr);
    gap: 2px;
    padding: 8px;
}
.re-emoji-item {
    width: 28px;
    height: 28px;
    display: flex;
    align-items: center;
    justify-content: center;
    border: none;
    background: transparent;
    border-radius: 6px;
    cursor: pointer;
    font-size: 16px;
    transition: all 0.15s;
}
.re-emoji-item:hover {
    background: #f1f5f9;
    transform: scale(1.2);
}

/* 数学公式面板 */
.re-math-panel {
    width: 380px;
    padding: 0;
    max-height: 420px;
    overflow-y: auto;
}
.re-math-hint {
    font-size: 11px;
    color: #94a3b8;
    padding: 8px 10px 4px;
}
.re-math-panel .re-emoji-tabs {
    padding: 0 4px;
}
.re-math-grid {
    display: grid;
    grid-template-columns: repeat(6, 1fr);
    gap: 4px;
    padding: 8px;
}
.re-math-item {
    padding: 6px 4px;
    border: 1px solid #e2e8f0;
    background: white;
    border-radius: 6px;
    cursor: pointer;
    font-size: 13px;
    text-align: center;
    color: #334155;
    transition: all 0.15s;
}
.re-math-item:hover {
    background: #eff6ff;
    border-color: #93c5fd;
    color: #1d4ed8;
}
.re-math-wrap-btn {
    display: block;
    width: calc(100% - 16px);
    margin: 0 8px 8px;
    padding: 6px;
    border: 1px dashed #93c5fd;
    background: #eff6ff;
    border-radius: 8px;
    cursor: pointer;
    font-size: 12px;
    color: #3b82f6;
    text-align: center;
    transition: all 0.15s;
}
.re-math-wrap-btn:hover {
    background: #dbeafe;
}
.re-math-preview {
    background: #f8fafc;
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    padding: 8px;
    margin: 0 8px 8px;
}
.re-math-preview-label {
    font-size: 11px;
    color: #94a3b8;
    margin-bottom: 4px;
}
.re-math-preview-content {
    min-height: 24px;
    font-size: 14px;
    color: #334155;
    overflow-x: auto;
}

/* 行内代码样式 */
.re-inline-code {
    background: #f1f5f9;
    border: 1px solid #e2e8f0;
    border-radius: 4px;
    padding: 1px 5px;
    font-family: Consolas, 'Courier New', monospace;
    font-size: 0.9em;
    color: #e11d48;
}

/* 隐藏类 */
.re-panel.hidden {
    display: none !important;
}

/* 实时预览面板 */
.re-live-preview {
    border-top: 1px solid #e2e8f0;
    background: #f8fafc;
    padding: 0;
    max-height: 180px;
    overflow-y: auto;
}
.re-pv-label {
    font-size: 11px;
    color: #94a3b8;
    padding: 6px 10px 2px;
    font-weight: 500;
    user-select: none;
}
.re-pv-body {
    padding: 4px 10px 8px;
    font-size: 14px;
    color: #334155;
    line-height: 1.7;
    word-break: break-word;
    white-space: pre-wrap;
}
.re-pv-body img {
    max-width: 100%;
    max-height: 120px;
    border-radius: 6px;
}
.re-pv-body strong { font-weight: 700; }
.re-pv-body em { font-style: italic; }
.re-pv-body .katex { font-size: 1.05em; }

/* ========== 数学公式编辑器弹窗 ========== */
.re-math-editor-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.5);
    z-index: 9990;
    display: flex;
    align-items: center;
    justify-content: center;
    animation: reMathFadeIn 0.2s ease;
}
.re-math-editor-overlay.hidden {
    display: none !important;
}
@keyframes reMathFadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}
@keyframes reMathScaleIn {
    from { opacity: 0; transform: scale(0.92); }
    to { opacity: 1; transform: scale(1); }
}
.re-math-editor-modal {
    background: white;
    border-radius: 16px;
    box-shadow: 0 20px 60px -12px rgba(0,0,0,0.25);
    width: 100%;
    max-width: 672px;
    max-height: 90vh;
    display: flex;
    flex-direction: column;
    animation: reMathScaleIn 0.25s ease;
}
.re-math-editor-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 20px;
    border-bottom: 1px solid #e2e8f0;
}
.re-math-editor-close {
    width: 32px;
    height: 32px;
    border: none;
    background: transparent;
    border-radius: 8px;
    font-size: 20px;
    color: #94a3b8;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.15s;
}
.re-math-editor-close:hover {
    background: #f1f5f9;
    color: #475569;
}
.re-math-editor-body {
    padding: 16px 20px;
    overflow-y: auto;
    flex: 1;
}
.re-math-editor-input {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    font-family: Consolas, 'Courier New', monospace;
    font-size: 14px;
    color: #334155;
    resize: vertical;
    transition: border-color 0.15s;
    box-sizing: border-box;
}
.re-math-editor-input:focus {
    outline: none;
    border-color: #93c5fd;
    box-shadow: 0 0 0 3px rgba(59,130,246,0.1);
}
.re-math-editor-preview {
    min-height: 60px;
    padding: 14px 16px;
    background: #f8fafc;
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow-x: auto;
    font-size: 16px;
    color: #334155;
}
.re-math-editor-preview .katex-display {
    margin: 0;
}
.re-math-editor-templates {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 8px;
}
.re-math-editor-tpl-card {
    padding: 10px 8px;
    border: 1px solid #e2e8f0;
    background: white;
    border-radius: 8px;
    cursor: pointer;
    text-align: center;
    transition: all 0.15s;
}
.re-math-editor-tpl-card:hover {
    border-color: #93c5fd;
    background: #eff6ff;
    box-shadow: 0 2px 8px rgba(59,130,246,0.1);
}
.re-math-editor-tpl-tex {
    font-size: 13px;
    color: #334155;
    overflow: hidden;
    min-height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
}
.re-math-editor-tpl-tex .katex {
    font-size: 0.85em;
}
.re-math-editor-tpl-label {
    font-size: 11px;
    color: #94a3b8;
    margin-top: 4px;
}
.re-math-editor-footer {
    display: flex;
    justify-content: flex-end;
    gap: 8px;
    padding: 12px 20px;
    border-top: 1px solid #e2e8f0;
}
.re-math-editor-btn-cancel {
    padding: 8px 20px;
    border: 1px solid #e2e8f0;
    background: white;
    border-radius: 8px;
    font-size: 14px;
    color: #64748b;
    cursor: pointer;
    transition: all 0.15s;
}
.re-math-editor-btn-cancel:hover {
    background: #f1f5f9;
}
.re-math-editor-btn-confirm {
    padding: 8px 20px;
    border: none;
    background: #3b82f6;
    border-radius: 8px;
    font-size: 14px;
    color: white;
    cursor: pointer;
    font-weight: 500;
    transition: all 0.15s;
}
.re-math-editor-btn-confirm:hover {
    background: #2563eb;
}
.re-fx-btn {
    font-family: Georgia, 'Times New Roman', serif;
    font-style: italic;
    font-weight: 700;
    font-size: 12px;
}
