/**
 * 富文本编辑器样式
 */

/* 编辑器包装器 */
.rich-editor-wrapper {
    border: 2px solid #e2e8f0;
    border-radius: 12px;
    background: #fff;
    overflow: hidden;
    transition: all 0.3s;
}

.rich-editor-wrapper:focus-within {
    border-color: #4f46e5;
    box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.1);
}

/* 工具栏 */
.rich-editor-toolbar {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 4px;
    padding: 10px 12px;
    background: #f8fafc;
    border-bottom: 1px solid #e2e8f0;
}

.toolbar-group {
    display: flex;
    align-items: center;
    gap: 2px;
    position: relative;
}

/* 工具栏强制换行：插入类按钮（图片/视频/附件/链接）固定第二排 */
.toolbar-break {
    flex-basis: 100%;
    height: 0;
    padding: 0;
    margin: 0;
    border: none;
}

.toolbar-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 34px;
    height: 34px;
    border: none;
    background: transparent;
    border-radius: 6px;
    cursor: pointer;
    color: #64748b;
    font-size: 0.85rem;
    font-weight: 500;
    transition: all 0.2s;
}

.toolbar-btn:hover {
    background: #e2e8f0;
    color: #4f46e5;
}

.toolbar-btn.active {
    background: #4f46e5;
    color: #fff;
}

/* 编辑区域 */
.rich-editor-content {
    padding: 16px;
    outline: none;
    overflow-y: auto;
    line-height: 1.7;
    font-size: 1rem;
    color: #1e293b;
    position: relative;
}

.rich-editor-content:empty:before {
    content: attr(data-placeholder);
    color: #94a3b8;
    pointer-events: none;
}

/* 编辑器内图片 */
.editor-image {
    max-width: 100%;
    border-radius: 8px;
    margin: 12px 0;
    cursor: pointer;
    transition: transform 0.2s;
}

.editor-image:hover {
    transform: scale(1.01);
}

/* 编辑器内视频包装 */
.editor-video-wrapper {
    max-width: 100%;
    margin: 12px 0;
    border-radius: 8px;
    overflow: hidden;
    background: #000;
}

.editor-video {
    width: 100%;
    max-height: 400px;
    display: block;
}

.editor-iframe {
    width: 100%;
    height: 400px;
    display: block;
}

/* 编辑器内链接 */
.editor-link {
    color: #4f46e5;
    text-decoration: underline;
    cursor: pointer;
}

.editor-link:hover {
    color: #7c3aed;
}

/* 底部统计 */
.rich-editor-footer {
    display: flex;
    gap: 20px;
    padding: 10px 16px;
    background: #f8fafc;
    border-top: 1px solid #e2e8f0;
    font-size: 0.85rem;
    color: #64748b;
}

.rich-editor-footer i {
    margin-right: 4px;
    color: #94a3b8;
}

.rich-editor-footer strong {
    color: #4f46e5;
    font-weight: 600;
}

/* 插入面板（下拉列表：链接 / 本地上传） */
.insert-panel {
    position: absolute;
    top: calc(100% + 6px);
    left: 0;
    min-width: 160px;
    background: #fff;
    border-radius: 8px;
    box-shadow: 0 6px 24px rgba(0, 0, 0, 0.16);
    padding: 6px;
    z-index: 100;
    display: none;
    animation: panelSlideIn 0.2s ease;
}

.insert-panel.show {
    display: block;
}

.insert-panel-small {
    min-width: 180px;
}

@keyframes panelSlideIn {
    from {
        opacity: 0;
        transform: translateY(-10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.insert-panel-title {
    font-weight: 600;
    color: #1e293b;
    margin-bottom: 8px;
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 0.8rem;
}

.insert-panel-title i {
    color: #4f46e5;
}

/* 插入方式下拉列表（点击图片/视频/附件按钮弹出，含"链接 / 本地上传"两项） */
.insert-tabs {
    display: flex;
    flex-direction: column;
    gap: 3px;
    margin-bottom: 6px;
}

.insert-tabs::before {
    content: '选择插入方式';
    display: block;
    font-size: 0.68rem;
    color: #94a3b8;
    margin-bottom: 1px;
    padding-left: 3px;
}

.insert-tab {
    display: flex;
    align-items: center;
    gap: 7px;
    width: 100%;
    padding: 5px 9px;
    border: 1px solid #e2e8f0;
    background: #fff;
    border-radius: 5px;
    cursor: pointer;
    font-size: 0.75rem;
    font-weight: 500;
    color: #475569;
    transition: all 0.2s;
    text-align: left;
    font-family: inherit;
}

.insert-tab i {
    width: 14px;
    text-align: center;
    color: #94a3b8;
    transition: color 0.2s;
}

.insert-tab:hover {
    border-color: #4f46e5;
    background: #f0f4ff;
    color: #4f46e5;
}

.insert-tab:hover i { color: #4f46e5; }

.insert-tab.active {
    background: #4f46e5;
    border-color: #4f46e5;
    color: #fff;
}

.insert-tab.active i { color: #fff; }

.insert-tab-content {
    display: none;
}

.insert-tab-content.active {
    display: block;
}

/* 表单控件 */
.form-control {
    width: 100%;
    padding: 10px 12px;
    border: 2px solid #e2e8f0;
    border-radius: 8px;
    font-size: 0.9rem;
    font-family: inherit;
    transition: all 0.3s;
}

.form-control:focus {
    outline: none;
    border-color: #4f46e5;
    box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.1);
}

/* 按钮 */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 10px 16px;
    border-radius: 8px;
    font-size: 0.9rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.3s;
    border: none;
    font-family: inherit;
}

.btn-primary {
    background: linear-gradient(135deg, #4f46e5, #7c3aed);
    color: #fff;
}

.btn-primary:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(79, 70, 229, 0.3);
}

.btn-sm {
    padding: 6px 12px;
    font-size: 0.8rem;
}

/* 图片链接输入 */
.image-link-input,
.video-link-input,
.link-input-group {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.link-hint {
    font-size: 0.75rem;
    color: #64748b;
    padding: 6px 0;
}

.link-hint i {
    margin-right: 4px;
    color: #4f46e5;
}

/* 媒体预览 */
.media-preview {
    position: relative;
    margin-top: 12px;
    border-radius: 8px;
    overflow: hidden;
    background: #f1f5f9;
}

.media-preview img {
    width: 100%;
    max-height: 150px;
    object-fit: contain;
    display: block;
}

.media-preview .remove-btn {
    position: absolute;
    top: 8px;
    right: 8px;
    width: 28px;
    height: 28px;
    border-radius: 50%;
    background: rgba(0, 0, 0, 0.6);
    color: #fff;
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
}

.media-preview .remove-btn:hover {
    background: rgba(239, 68, 68, 0.9);
    transform: scale(1.1);
}

/* 上传区域样式已移除：
   本地上传改为"点下拉项直接弹出系统文件选择框"，进度用顶部小提示显示，
   不再显示拖拽上传框 */

/* ============================ 附件卡片 ============================ */

.editor-attachment {
    display: flex;
    align-items: center;
    gap: 12px;
    max-width: 480px;
    margin: 12px 0;
    padding: 12px 16px;
    background: #f8fafc;
    border: 2px solid #e2e8f0;
    border-radius: 10px;
    text-decoration: none;
    transition: all 0.2s;
    cursor: pointer;
}

.editor-attachment:hover {
    border-color: #4f46e5;
    background: #f0f4ff;
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(79, 70, 229, 0.12);
}

.editor-attachment .att-icon {
    width: 42px;
    height: 42px;
    flex-shrink: 0;
    border-radius: 8px;
    background: linear-gradient(135deg, #eef2ff, #e0e7ff);
    color: #4f46e5;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.2rem;
}

.editor-attachment .att-info {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.editor-attachment .att-name {
    font-size: 0.9rem;
    font-weight: 600;
    color: #1e293b;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.editor-attachment .att-size {
    font-size: 0.75rem;
    color: #94a3b8;
}

.editor-attachment .att-download {
    flex-shrink: 0;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 12px;
    border-radius: 6px;
    background: #4f46e5;
    color: #fff;
    font-size: 0.8rem;
    font-weight: 500;
}

.editor-attachment:hover .att-download {
    background: linear-gradient(135deg, #4f46e5, #7c3aed);
}

/* ============================ 颜色面板 ============================ */

.insert-panel-color {
    min-width: 220px;
}

.color-palette {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    gap: 8px;
}

.color-swatch {
    width: 30px;
    height: 30px;
    border-radius: 6px;
    cursor: pointer;
    border: 2px solid #e2e8f0;
    transition: all 0.15s;
}

.color-swatch:hover {
    transform: scale(1.15);
    border-color: #4f46e5;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
}

/* ============================ 代码块 ============================ */

.rich-editor-content pre.editor-code {
    background: #1e293b;
    color: #e2e8f0;
    padding: 16px;
    border-radius: 8px;
    font-family: 'Monaco', 'Menlo', 'Consolas', monospace;
    font-size: 0.85rem;
    line-height: 1.6;
    overflow-x: auto;
    margin: 12px 0;
    white-space: pre-wrap;
}

.rich-editor-content pre.editor-code code {
    background: transparent;
    color: inherit;
    padding: 0;
}

/* 简化模式样式 */
.rich-editor-simple .rich-editor-toolbar {
    padding: 8px 10px;
}

.rich-editor-simple .toolbar-btn {
    width: 30px;
    height: 30px;
    font-size: 0.8rem;
}

.rich-editor-simple .rich-editor-content {
    padding: 12px;
    font-size: 0.95rem;
}

.rich-editor-simple .rich-editor-footer {
    font-size: 0.8rem;
    gap: 15px;
}

/* 响应式 */
@media (max-width: 640px) {
    .rich-editor-toolbar {
        padding: 8px;
    }
    
    .toolbar-btn {
        width: 30px;
        height: 30px;
        font-size: 0.8rem;
    }
    
    .insert-panel {
        position: fixed;
        left: 16px !important;
        right: 16px;
        top: 50% !important;
        transform: translateY(-50%);
        min-width: auto;
        max-height: 80vh;
        overflow-y: auto;
    }
    
    .rich-editor-footer {
        flex-wrap: wrap;
        gap: 10px;
    }
}

/* 内容样式（编辑后的展示） */
.rich-editor-content h1 {
    font-size: 2rem;
    margin: 16px 0 8px;
    color: #1e293b;
}

.rich-editor-content h2 {
    font-size: 1.5rem;
    margin: 14px 0 6px;
    color: #1e293b;
}

.rich-editor-content h3 {
    font-size: 1.25rem;
    margin: 12px 0 4px;
    color: #1e293b;
}

.rich-editor-content p {
    margin: 8px 0;
}

.rich-editor-content blockquote {
    margin: 12px 0;
    padding: 12px 16px;
    border-left: 4px solid #4f46e5;
    background: #f8fafc;
    border-radius: 0 8px 8px 0;
    color: #475569;
}

.rich-editor-content ul,
.rich-editor-content ol {
    margin: 8px 0;
    padding-left: 24px;
}

.rich-editor-content li {
    margin: 4px 0;
}

.rich-editor-content hr {
    border: none;
    height: 2px;
    background: linear-gradient(to right, transparent, #e2e8f0, transparent);
    margin: 16px 0;
}
