﻿/* ==========================================================================
   Yixiang UI / 翊象 UI
   Rich Text Editor
   富文本编辑器

   Copyright (c) 2026 威海颜翊网络科技有限公司
   Licensed under the MIT License. Commercial use is permitted.
   https://www.weihaiyanyi.com  |  pinenetcn@gmail.com
   ========================================================================== */
body.yx-editor-open {
    overflow: hidden;
}

.yx-editor-overlay {
    position: fixed;
    inset: 0;
    z-index: 1015;
    display: flex;
    flex-direction: column;
    background-color: var(--yx-bg-body);
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
    transition: opacity 0.2s ease, visibility 0.2s ease;
}

.yx-editor-overlay.is-active {
    opacity: 1;
    visibility: visible;
    pointer-events: auto;
}

.yx-editor-shell {
    display: flex;
    flex-direction: column;
    height: 100%;
    min-height: 0;
}

.yx-editor-top {
    height: 64px;
    flex-shrink: 0;
    padding: 0 var(--yx-space-5);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--yx-space-4);
    background-color: var(--yx-bg-paper);
    border-bottom: 1px solid var(--yx-border-light);
}

.yx-editor-top-left,
.yx-editor-top-actions {
    display: flex;
    align-items: center;
    gap: var(--yx-space-3);
    min-width: 0;
}

.yx-editor-back {
    width: 36px;
    height: 36px;
    border: none;
    border-radius: var(--yx-radius-md);
    background: transparent;
    color: var(--yx-text-secondary);
    font-size: 22px;
    line-height: 1;
    cursor: pointer;
    flex-shrink: 0;
}
.yx-editor-back:hover {
    background-color: var(--yx-bg-hover);
    color: var(--yx-text-primary);
}

.yx-editor-heading {
    font-size: var(--yx-text-base);
    font-weight: 600;
    color: var(--yx-text-primary);
    white-space: nowrap;
}

.yx-editor-sub {
    font-size: var(--yx-text-xs);
    color: var(--yx-text-caption);
    white-space: nowrap;
}

.yx-editor-status {
    font-size: var(--yx-text-xs);
    color: var(--yx-text-caption);
    white-space: nowrap;
}

.yx-editor-status.is-saved {
    color: var(--yx-success);
}

.yx-editor-body {
    flex: 1;
    min-height: 0;
    overflow-y: auto;
    padding: var(--yx-space-6) var(--yx-space-4);
}

.yx-editor-doc {
    max-width: 900px;
    margin: 0 auto;
    padding: 40px 48px 64px;
    background-color: var(--yx-bg-paper);
    border: 1px solid var(--yx-border-light);
    border-radius: var(--yx-radius-xl);
    box-shadow: var(--yx-shadow-sm);
    min-height: calc(100% - 8px);
}

.yx-editor-title-input {
    display: block;
    width: 100%;
    border: none;
    outline: none;
    background: transparent;
    color: var(--yx-text-primary);
    font-family: inherit;
    font-size: clamp(26px, 3.4vw, 36px);
    font-weight: 800;
    line-height: 1.25;
    letter-spacing: -0.5px;
    margin-bottom: var(--yx-space-4);
}

.yx-editor-title-input::placeholder {
    color: var(--yx-text-caption);
}

.yx-editor-meta-row {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: var(--yx-space-3);
    padding-bottom: var(--yx-space-5);
    margin-bottom: var(--yx-space-4);
    border-bottom: 1px solid var(--yx-border-light);
}

.yx-editor-meta-row .yx-input {
    max-width: 280px;
    height: 36px;
    font-size: var(--yx-text-xs);
}

.yx-editor-meta-row .yx-select-trigger {
    height: 36px;
    font-size: var(--yx-text-xs);
}

/* Quill overrides */
.yx-editor-doc .ql-toolbar.ql-snow {
    border: none;
    border-bottom: 1px solid var(--yx-border-light);
    padding: 0 0 var(--yx-space-3);
    margin-bottom: var(--yx-space-4);
    position: sticky;
    top: 0;
    z-index: 3;
    background-color: var(--yx-bg-paper);
}

.yx-editor-doc .ql-container.ql-snow {
    border: none;
    font-family: var(--yx-font-sans);
    font-size: 16px;
    line-height: 1.85;
    height: auto;
}

.yx-editor-doc .ql-editor {
    min-height: 420px;
    padding: 0;
    color: var(--yx-text-secondary);
    overflow: visible;
}

.yx-editor-doc .ql-editor.ql-blank::before {
    color: var(--yx-text-caption);
    font-style: normal;
    left: 0;
    right: 0;
}

.yx-editor-doc .ql-editor h1,
.yx-editor-doc .ql-editor h2,
.yx-editor-doc .ql-editor h3 {
    color: var(--yx-text-primary);
    line-height: 1.35;
    margin: 1.2em 0 0.5em;
}
.yx-editor-doc .ql-editor h1 { font-size: 30px; }
.yx-editor-doc .ql-editor h2 { font-size: 24px; }
.yx-editor-doc .ql-editor h3 { font-size: 19px; }

.yx-editor-doc .ql-editor p {
    margin-bottom: 0.6em;
}

.yx-editor-doc .ql-editor blockquote {
    border-left: 3px solid var(--yx-brand-primary);
    padding-left: 16px;
    color: var(--yx-text-secondary);
    background-color: var(--yx-brand-primary-light);
    margin: 1em 0;
    padding-top: 8px;
    padding-bottom: 8px;
    border-radius: 0 var(--yx-radius-md) var(--yx-radius-md) 0;
}

.yx-editor-doc .ql-editor pre.ql-syntax {
    background-color: var(--yx-bg-active);
    color: var(--yx-text-primary);
    border-radius: var(--yx-radius-md);
    padding: 14px 16px;
    font-family: var(--yx-font-mono);
    font-size: 13px;
    overflow-x: auto;
}

.yx-editor-doc .ql-editor a {
    color: var(--yx-brand-primary);
}

.yx-editor-doc .ql-editor img {
    border-radius: var(--yx-radius-md);
}

.yx-editor-doc .ql-snow .ql-stroke {
    stroke: var(--yx-text-secondary);
}
.yx-editor-doc .ql-snow .ql-fill,
.yx-editor-doc .ql-snow .ql-stroke.ql-fill {
    fill: var(--yx-text-secondary);
}
.yx-editor-doc .ql-snow .ql-picker {
    color: var(--yx-text-secondary);
}
.yx-editor-doc .ql-snow .ql-picker-options {
    background-color: var(--yx-bg-paper);
    border-color: var(--yx-border-light);
    border-radius: var(--yx-radius-md);
    box-shadow: var(--yx-shadow-float);
}
.yx-editor-doc .ql-snow .ql-picker-item:hover,
.yx-editor-doc .ql-snow .ql-picker-label:hover {
    color: var(--yx-brand-primary);
}
.yx-editor-doc .ql-snow .ql-active .ql-stroke {
    stroke: var(--yx-brand-primary);
}
.yx-editor-doc .ql-snow .ql-active .ql-fill {
    fill: var(--yx-brand-primary);
}

/* Emoji picker (local coolapk-emotion) */
.yx-editor-doc .ql-emoji {
    width: auto;
    min-width: 28px;
}

.yx-editor-doc .ql-emoji .ql-emoji-button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 24px;
    font-size: 16px;
    line-height: 1;
    cursor: pointer;
}

.yx-editor-doc .ql-emoji-picker {
    z-index: 1200;
    border: 1px solid var(--yx-border-light);
    border-radius: var(--yx-radius-md);
    box-shadow: var(--yx-shadow-float);
    background-color: var(--yx-bg-paper);
    color: var(--yx-text-primary);
}

.yx-editor-doc .ql-emoji-picker .emoji-picker__header,
.yx-editor-doc .ql-emoji-picker .emoji-picker__search {
    background-color: var(--yx-bg-paper);
    color: var(--yx-text-primary);
}

.yx-editor-doc .ql-emoji-picker .emoji-picker__emoji:hover {
    background-color: var(--yx-bg-hover);
}

.yx-editor-footer {
    height: 56px;
    flex-shrink: 0;
    padding: 0 var(--yx-space-5);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--yx-space-4);
    background-color: var(--yx-bg-paper);
    border-top: 1px solid var(--yx-border-light);
    font-size: var(--yx-text-xs);
    color: var(--yx-text-caption);
}

.yx-editor-footer-left,
.yx-editor-footer-right {
    display: flex;
    align-items: center;
    gap: var(--yx-space-4);
}

.yx-editor-kbd {
    display: inline-block;
    padding: 1px 5px;
    border: 1px solid var(--yx-border-base);
    border-bottom-width: 2px;
    border-radius: 4px;
    font-family: var(--yx-font-mono);
    font-size: 11px;
    color: var(--yx-text-secondary);
}

@media (max-width: 768px) {
    .yx-editor-top {
        height: auto;
        padding: 10px 12px;
        flex-wrap: wrap;
    }
    .yx-editor-body {
        padding: 12px 8px;
    }
    .yx-editor-doc {
        padding: 24px 18px 48px;
        border-radius: var(--yx-radius-lg);
    }
    .yx-editor-title-input {
        font-size: 26px;
    }
    .yx-editor-footer {
        height: auto;
        padding: 10px 12px;
        flex-wrap: wrap;
    }
    .yx-editor-footer-left {
        display: none;
    }
}

@media (prefers-reduced-motion: reduce) {
    .yx-editor-overlay {
        transition: none;
    }
}

/* 编辑器入口卡片 / Editor launcher card */
.yx-editor-launcher {
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 20px;
    border: 1px dashed var(--yx-border-dark);
    border-radius: var(--yx-radius-md);
    background-color: var(--yx-bg-hover);
}

.yx-editor-launcher-icon {
    width: 44px;
    height: 44px;
    border-radius: var(--yx-radius-md);
    background-color: var(--yx-bg-paper);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 22px;
    flex-shrink: 0;
}

.yx-editor-launcher-text {
    flex: 1;
    min-width: 0;
}

.yx-editor-launcher-text strong {
    display: block;
    font-size: 14px;
    color: var(--yx-text-primary);
    margin-bottom: 4px;
}

.yx-editor-launcher-text p {
    margin: 0;
    font-size: 12px;
    line-height: 1.6;
    color: var(--yx-text-secondary);
}

@media (max-width: 600px) {
    .yx-editor-launcher {
        flex-wrap: wrap;
        align-items: flex-start;
    }
    .yx-editor-launcher .yx-btn {
        width: 100%;
    }
}

/* 文章元信息字段 / Article meta fields */
.yx-editor-fields {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px 16px;
    padding: 16px;
    margin-bottom: 16px;
    border: 1px solid var(--yx-border-light);
    border-radius: var(--yx-radius-md);
    background-color: var(--yx-bg-hover);
}

.yx-editor-field {
    display: flex;
    flex-direction: column;
    gap: 6px;
    min-width: 0;
    font-size: 12px;
    color: var(--yx-text-secondary);
}

.yx-editor-field--full {
    grid-column: 1 / -1;
}

.yx-editor-field .yx-input {
    height: 34px;
    font-size: 13px;
}

.yx-editor-field .yx-textarea {
    min-height: 64px;
    font-size: 13px;
    resize: vertical;
}

.yx-editor-options {
    flex-direction: row;
    align-items: center;
    gap: 20px;
    padding-top: 4px;
}

@media (max-width: 640px) {
    .yx-editor-fields {
        grid-template-columns: 1fr;
        padding: 12px;
    }
}

/* 移动端字段宽度约束 / Mobile field width constraints */
.yx-editor-field .yx-input,
.yx-editor-field .yx-textarea,
.yx-editor-field input[type="datetime-local"] {
    width: 100%;
    min-width: 0;
    max-width: 100%;
    box-sizing: border-box;
}

@media (max-width: 640px) {
    .yx-editor-field input[type="datetime-local"] {
        font-size: 13px;
    }
}

/* 本地表情面板 / Local emoji picker */
.yx-editor-doc .ql-toolbar .ql-emoji {
    width: 28px;
    padding: 3px;
    border: none;
    background: none;
    cursor: pointer;
}

.yx-editor-doc .ql-toolbar .ql-emoji svg {
    width: 18px;
    height: 18px;
    float: none;
    margin: 0;
}

.yx-emoji-picker {
    position: fixed;
    z-index: 1100;
    display: flex;
    flex-direction: column;
    max-height: 330px;
    padding: 10px;
    border: 1px solid var(--yx-border-light);
    border-radius: var(--yx-radius-md);
    background-color: var(--yx-bg-paper);
    box-shadow: var(--yx-shadow-float);
}

.yx-emoji-head {
    display: flex;
    align-items: center;
    gap: 8px;
    padding-bottom: 8px;
    border-bottom: 1px solid var(--yx-border-light);
}

.yx-emoji-search {
    flex: 1;
    min-width: 0;
    height: 30px;
    padding: 0 10px;
    border: 1px solid var(--yx-border-base);
    border-radius: var(--yx-radius-sm);
    background-color: var(--yx-bg-hover);
    color: var(--yx-text-primary);
    font-size: 12px;
    outline: none;
}

.yx-emoji-search:focus {
    border-color: var(--yx-brand-primary);
}

.yx-emoji-close {
    width: 26px;
    height: 26px;
    flex-shrink: 0;
    border: none;
    border-radius: var(--yx-radius-sm);
    background: transparent;
    color: var(--yx-text-tertiary);
    font-size: 18px;
    line-height: 1;
    cursor: pointer;
}

.yx-emoji-close:hover {
    background-color: var(--yx-bg-hover);
    color: var(--yx-text-primary);
}

.yx-emoji-grid {
    display: grid;
    grid-template-columns: repeat(8, 1fr);
    gap: 4px;
    padding-top: 8px;
    overflow-y: auto;
}

.yx-emoji-item {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    aspect-ratio: 1;
    padding: 3px;
    border: none;
    border-radius: var(--yx-radius-sm);
    background: transparent;
    cursor: pointer;
}

.yx-emoji-item:hover {
    background-color: var(--yx-bg-hover);
}

.yx-emoji-item img {
    width: 100%;
    height: 100%;
    object-fit: contain;
}

@media (max-width: 480px) {
    .yx-emoji-picker {
        max-height: 300px;
    }

    .yx-emoji-grid {
        grid-template-columns: repeat(6, 1fr);
    }
}

/* 表情图片尺寸 / Inline emoji size */
.yx-editor-doc .ql-editor img[src*="/coolapk-emotion/"],
.yx-editor-doc .ql-editor img[src*="coolapk-emotion"] {
    display: inline-block;
    width: 1.5em !important;
    height: 1.5em !important;
    margin: 0 2px;
    vertical-align: -0.3em;
    object-fit: contain;
}

