/* ============================================
   Edit Article Page 样式 (edit.css)
   匹配 templates/default/edit.html 的富文本编辑器结构
   ============================================ */

/* 编辑器整体容器 */
.editor-content {
    max-width: 1000px;
    margin: 0 auto;
    padding: 8px 24px 56px;
    display: flex;
    flex-direction: column;
    gap: 20px;
}

/* 编辑器区块（元信息 / 图片 / 正文 通用外壳） */
.editor-section {
    background: var(--color-surface);
    border: 1px solid var(--color-border-light);
    border-radius: var(--radius);
    padding: 24px;
    box-shadow: var(--shadow-xs);
}

/* 区块头部：标题 + 操作/提示 */
.editor-section-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 16px;
    flex-wrap: wrap;
}

.editor-section-title {
    font-size: 15px;
    font-weight: 700;
    color: var(--color-text);
    display: flex;
    align-items: center;
    gap: 6px;
}

.editor-section-hint {
    font-size: 13px;
    color: var(--color-text-muted);
}

.editor-section-actions {
    display: flex;
    align-items: center;
    gap: 8px;
}

/* 元信息表单行 */
.editor-row {
    display: flex;
    gap: 16px;
    flex-wrap: wrap;
    margin-bottom: 16px;
}

.editor-row:last-child {
    margin-bottom: 0;
}

.editor-field {
    flex: 1;
    min-width: 160px;
}

/* 标题字段：单独整行 */
.editor-field-title {
    flex: 1 1 100%;
    min-width: 0;
}

/* 语言 / 地区等短字段：缩短宽度，不自动拉伸 */
.editor-field-short {
    flex: 0 0 auto;
    width: 130px;
    min-width: 110px;
}

/* 标题字段占更宽 */
.editor-field-lg {
    flex: 2;
    min-width: 280px;
}

/* 名称标识等字段占更窄 */
.editor-field-sm {
    flex: 1;
    min-width: 200px;
}

.editor-label {
    display: block;
    font-size: 13px;
    font-weight: 600;
    color: var(--color-text-muted);
    margin-bottom: 6px;
}

.editor-label .required {
    color: var(--color-accent);
    margin-left: 2px;
}

.editor-input,
.editor-select {
    width: 100%;
    padding: 10px 14px;
    border: 1.5px solid var(--color-border);
    border-radius: var(--radius-sm);
    font-size: 14px;
    font-family: inherit;
    color: var(--color-text);
    background: var(--color-surface);
    outline: none;
    transition: all var(--transition);
}

.editor-input:focus,
.editor-select:focus {
    border-color: var(--color-primary);
    box-shadow: 0 0 0 3px rgba(91, 94, 247, .08);
}

/* 图片管理区域 */
.editor-images-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
    gap: 12px;
    margin-bottom: 16px;
}

.editor-images-grid:empty {
    display: none;
}

.editor-image-item {
    position: relative;
    aspect-ratio: 1 / 1;
    border-radius: var(--radius-sm);
    overflow: hidden;
    border: 1px solid var(--color-border-light);
    background: var(--color-bg-alt);
}

.editor-image-item img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

.editor-image-item .img-remove {
    position: absolute;
    top: 6px;
    right: 6px;
    width: 24px;
    height: 24px;
    border-radius: 50%;
    border: none;
    background: rgba(15, 17, 33, .6);
    color: #fff;
    font-size: 14px;
    line-height: 1;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all var(--transition);
}

.editor-image-item .img-remove:hover {
    background: var(--color-accent);
}

.editor-image-upload {
    margin-top: 4px;
}

.upload-btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 10px 18px;
    border: 1.5px dashed var(--color-border);
    border-radius: var(--radius-sm);
    color: var(--color-text-secondary);
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: all var(--transition);
    background: var(--color-bg-alt);
}

.upload-btn:hover {
    border-color: var(--color-primary);
    color: var(--color-primary);
    background: var(--color-primary-light);
}

/* 正文区块 */
.editor-body-section {
    padding: 0;
    overflow: hidden;
}

.editor-body-section .editor-section-header {
    padding: 16px 24px;
    margin-bottom: 0;
    border-bottom: 1px solid var(--color-border-light);
    background: var(--color-bg-alt);
}

/* 预览切换按钮 */
.btn-preview-toggle {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 14px;
    border: 1.5px solid var(--color-border);
    border-radius: var(--radius-sm);
    background: var(--color-surface);
    color: var(--color-text-secondary);
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    transition: all var(--transition);
    font-family: inherit;
}

.btn-preview-toggle:hover,
.btn-preview-toggle.active {
    border-color: var(--color-primary);
    color: var(--color-primary);
    background: var(--color-primary-light);
}

/* 工具栏整体 */
.editor-toolbar {
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 10px 12px;
    background: var(--color-surface);
    border-bottom: 1px solid var(--color-border-light);
    flex-wrap: wrap;
}

/* 工具栏左侧容器 */
.toolbar-left {
    display: flex;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
}

/* 工具栏分组 */
.toolbar-group {
    display: flex;
    align-items: center;
    gap: 4px;
    flex-wrap: wrap;
}

.toolbar-label {
    font-size: 12px;
    font-weight: 600;
    color: var(--color-text-muted);
    padding-right: 2px;
}

.toolbar-divider {
    width: 1px;
    height: 22px;
    background: var(--color-border);
    margin: 0 6px;
}

.toolbar-btn {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    justify-content: center;
    height: 34px;
    padding: 0 10px;
    border: none;
    background: transparent;
    border-radius: var(--radius-xs);
    color: var(--color-text-secondary);
    cursor: pointer;
    transition: all var(--transition);
    font-size: 14px;
    font-weight: 600;
}

.toolbar-btn:hover {
    background: var(--color-primary-light);
    color: var(--color-primary);
}

.toolbar-btn.active {
    background: var(--color-primary-light);
    color: var(--color-primary);
}

/* 媒体类按钮（图片/视频/表格） */
.toolbar-btn-media {
    color: var(--color-primary);
}

.toolbar-btn-danger {
    color: var(--color-accent);
}

.toolbar-btn-danger:hover {
    background: var(--color-accent-light);
    color: var(--color-accent);
}

/* 颜色选择按钮及其指示块 */
.toolbar-btn-color {
    position: relative;
}

.color-indicator {
    display: inline-block;
    width: 14px;
    height: 14px;
    border-radius: 4px;
    border: 1px solid var(--color-border);
    background-color: currentColor;
}

/* 颜色选择按钮指示器初始色（也可由 JS 动态更新） */
#foreColorIndicator { background-color: #ff0000; }
#backColorIndicator { background-color: #ffff00; }
#lineBgColorIndicator { background-color: #fff3cd; }

/* 编辑 / 预览 区域外框 */
.editor-body-wrap {
    border-top: 1px solid var(--color-border-light);
    background: var(--color-surface);
    min-height: 460px;
}

/* 可编辑区域 */
.editor-body-editable {
    min-height: 460px;
    padding: 24px;
    font-size: 15px;
    line-height: 1.8;
    color: var(--color-text);
    outline: none;
    overflow-y: auto;
    background: var(--color-surface);
}

.editor-body-editable:empty:before {
    content: attr(placeholder);
    color: var(--color-text-light);
}

.editor-body-editable p {
    margin-bottom: 14px;
}

.editor-body-editable img {
    max-width: 100%;
    border-radius: var(--radius-sm);
    margin: 12px 0;
}

.editor-body-editable blockquote {
    margin: 16px 0;
    padding: 12px 20px;
    border-left: 4px solid var(--color-primary);
    background: var(--color-primary-light);
    border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
    color: var(--color-text-secondary);
}

.editor-body-editable pre {
    background: #1a1a2e;
    color: #e4e4e7;
    padding: 16px 20px;
    border-radius: var(--radius);
    overflow-x: auto;
    margin: 16px 0;
}

.editor-body-editable h1 { font-size: 28px; font-weight: 800; margin: 20px 0 12px; }
.editor-body-editable h2 { font-size: 24px; font-weight: 700; margin: 18px 0 10px; }
.editor-body-editable h3 { font-size: 20px; font-weight: 700; margin: 16px 0 8px; }
.editor-body-editable h4 { font-size: 17px; font-weight: 700; margin: 14px 0 8px; }

/* 恢复编辑区/预览区内的列表序号与圆点（覆盖 base.css 的 list-style:none 重置） */
.editor-body-editable ol,
.editor-body-preview ol {
    list-style: decimal;
    padding-left: 1.8em;
    margin: 14px 0;
}
.editor-body-editable ul,
.editor-body-preview ul {
    list-style: disc;
    padding-left: 1.8em;
    margin: 14px 0;
}
.editor-body-editable li,
.editor-body-preview li {
    margin: 4px 0;
}

/* 预览区域（detail-body 类由 detail.css 提供排版） */
.editor-body-preview {
    min-height: 460px;
    padding: 24px;
    font-size: 15px;
    line-height: 1.8;
    color: var(--color-text);
    background: var(--color-bg);
    border-top: 1px solid var(--color-border-light);
    overflow-y: auto;
}

/* 底部操作栏 */
.editor-actions-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    flex-wrap: wrap;
    background: var(--color-surface);
    border: 1px solid var(--color-border-light);
    border-radius: var(--radius);
    padding: 16px 24px;
    box-shadow: var(--shadow-xs);
}

.editor-actions-left,
.editor-actions-center,
.editor-actions-right {
    display: flex;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
}

.editor-status {
    font-size: 13px;
    color: var(--color-text-muted);
}

.edit-key-wrap {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 14px;
    border: 1.5px solid var(--color-border);
    border-radius: var(--radius-sm);
    background: var(--color-surface);
    color: var(--color-text-muted);
    transition: all var(--transition);
}

.edit-key-wrap:focus-within {
    border-color: var(--color-primary);
    box-shadow: 0 0 0 3px rgba(91, 94, 247, .08);
}

.edit-key-input {
    border: none;
    outline: none;
    font-size: 14px;
    font-family: inherit;
    color: var(--color-text);
    background: transparent;
    width: 160px;
}

.edit-key-input::placeholder {
    color: var(--color-text-light);
}

/* ============================================
   响应式
   ============================================ */
@media (max-width: 768px) {
    .editor-content {
        padding: 8px 16px 40px;
    }

    .editor-section {
        padding: 18px;
    }

    .editor-row {
        flex-direction: column;
        gap: 14px;
    }

    .editor-field,
    .editor-field-lg,
    .editor-field-sm,
    .editor-field-short,
    .editor-field-title {
        flex: 1 1 100%;
        min-width: 0;
        width: auto;
    }

    .editor-toolbar {
        gap: 2px;
        padding: 8px;
    }

    .toolbar-btn {
        height: 32px;
        padding: 0 8px;
        font-size: 13px;
    }

    .editor-body-editable,
    .editor-body-preview {
        padding: 16px;
        min-height: 320px;
    }

    .editor-actions-bar {
        flex-direction: column;
        align-items: stretch;
        padding: 16px;
    }

    .editor-actions-left,
    .editor-actions-center,
    .editor-actions-right {
        width: 100%;
        justify-content: center;
    }

    .editor-actions-bar .btn {
        flex: 1;
        justify-content: center;
    }
}

/* ============================================
   文章图集：网格 / 图片项 / 插入 / 删除
   ============================================ */
.editor-images-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
    gap: 12px;
    margin-bottom: 16px;
}

.images-empty {
    grid-column: 1 / -1;
    color: var(--color-text-muted, #8a90a2);
    font-size: 14px;
    padding: 18px;
    text-align: center;
    border: 1px dashed var(--color-border-light, #e8ebf2);
    border-radius: var(--radius, 12px);
}

.editor-image-item {
    position: relative;
    border: 1px solid var(--color-border-light, #e8ebf2);
    border-radius: 10px;
    overflow: hidden;
    background: var(--color-surface, #fff);
    aspect-ratio: 1 / 1;
    transition: box-shadow .15s ease, transform .15s ease;
}

.editor-image-item:hover {
    box-shadow: var(--shadow-md, 0 6px 18px rgba(20, 24, 48, .12));
    transform: translateY(-2px);
}

.editor-image-item img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

.editor-image-item .img-insert {
    position: absolute;
    left: 6px;
    bottom: 6px;
    padding: 4px 10px;
    font-size: 12px;
    font-weight: 600;
    color: #fff;
    background: rgba(26, 26, 46, .82);
    border: none;
    border-radius: 6px;
    cursor: pointer;
    opacity: 0;
    transition: opacity .15s ease;
}

.editor-image-item .img-remove {
    position: absolute;
    right: 6px;
    top: 6px;
    width: 22px;
    height: 22px;
    line-height: 20px;
    text-align: center;
    font-size: 16px;
    color: #fff;
    background: rgba(220, 38, 38, .85);
    border: none;
    border-radius: 50%;
    cursor: pointer;
    opacity: 0;
    transition: opacity .15s ease;
}

.editor-image-item:hover .img-insert,
.editor-image-item:hover .img-remove {
    opacity: 1;
}

.editor-image-item .img-insert:hover {
    background: var(--color-primary, #4f46e5);
}

/* 上传按钮 */
.upload-btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 10px 18px;
    font-size: 14px;
    font-weight: 600;
    color: var(--color-primary, #4f46e5);
    background: var(--color-surface, #fff);
    border: 1px dashed var(--color-primary, #4f46e5);
    border-radius: 10px;
    cursor: pointer;
    transition: background .15s ease, color .15s ease;
}

.upload-btn:hover {
    background: var(--color-primary, #4f46e5);
    color: #fff;
}

/* 正文编辑区选中的图片高亮（配合"调尺寸"按钮） */
.editor-body-editable img {
    cursor: pointer;
}

.editor-body-editable img.selected-image {
    outline: 3px solid var(--color-primary, #4f46e5);
    outline-offset: 2px;
}

/* ============================================
   图片尺寸调整弹窗
   ============================================ */
.modal-mask {
    position: fixed;
    inset: 0;
    background: rgba(15, 18, 38, .55);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
}

.modal-box {
    width: min(360px, 90vw);
    background: var(--color-surface, #fff);
    border-radius: 14px;
    padding: 22px 24px;
    box-shadow: 0 20px 50px rgba(10, 14, 30, .3);
}

.modal-title {
    font-size: 16px;
    font-weight: 700;
    color: var(--color-text, #1a1a2e);
    margin-bottom: 18px;
}

.modal-row {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 14px;
}

.modal-row > label {
    width: 48px;
    font-size: 14px;
    color: var(--color-text, #1a1a2e);
}

.modal-input {
    flex: 1;
    padding: 8px 10px;
    font-size: 14px;
    border: 1px solid var(--color-border-light, #e8ebf2);
    border-radius: 8px;
    outline: none;
}

.modal-input:focus {
    border-color: var(--color-primary, #4f46e5);
}

.modal-unit {
    font-size: 13px;
    color: var(--color-text-muted, #8a90a2);
}

.modal-row-inline {
    flex-wrap: wrap;
    gap: 18px;
}

.modal-row-inline label {
    width: auto;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 13px;
    color: var(--color-text-muted, #8a90a2);
    cursor: pointer;
}

.modal-actions {
    display: flex;
    justify-content: flex-end;
    gap: 12px;
    margin-top: 8px;
}
