/* ============================================================
   LiteEditor 编辑器样式 v14
   包含：主体、工具栏、下拉、编辑区、预览、状态栏
        + 内嵌对话框、表格选择器、查找栏、代码复制按钮、帮助弹窗
   ============================================================ */

/* ---------- 编辑器外壳 ---------- */
.lite-editor {
    overflow: visible;
    border-radius: 10px;
    background: #fff;
    display: flex;
    flex-direction: column;
    font-size: 14px;
    box-shadow: 0 1px 3px rgba(15, 23, 42, .06), 0 1px 2px rgba(15, 23, 42, .04);
    position: relative;
    isolation: isolate;
}
.lite-editor.le-fullscreen {
    position: fixed;
    inset: 0;
    z-index: 9999;
    border-radius: 0;
    box-shadow: none;
}

/* ---------- 工具栏 ---------- */
.le-toolbar {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 4px;
    padding: 8px 12px;
    background: #f8fafc;
    border-bottom: 1px solid #e5e9f0;
    user-select: none;
    position: sticky;
    top: 0;
    z-index: 20;
    border-radius: 10px 10px 0 0;
    box-shadow: 0 1px 0 rgba(0, 0, 0, .02);
}
.lite-editor.le-fullscreen .le-toolbar { border-radius: 0; }

/* 按钮重置 */
.lite-toolbar button,
.le-toolbar button {
    background: transparent !important;
    border: 1px solid transparent !important;
    border-radius: 6px !important;
    min-width: 32px !important;
    height: 32px !important;
    padding: 0 6px !important;
    cursor: pointer !important;
    color: #475569 !important;
    font-size: 14px !important;
    font-weight: 600 !important;
    font-family: inherit !important;
    line-height: 1 !important;
    transition: all .15s !important;
    display: inline-flex !important;
    align-items: center !important;
    justify-content: center !important;
    box-shadow: none !important;
    box-sizing: border-box !important;
}
.lite-toolbar button:hover,
.le-toolbar button:hover {
    background: #e2e8f0 !important;
    color: #0f172a !important;
}
.lite-toolbar button:active,
.le-toolbar button:active {
    background: #cbd5e1 !important;
}
.lite-toolbar button.is-active,
.le-toolbar button.is-active {
    background: #dbeafe !important;
    color: #2563eb !important;
    border-color: #bfdbfe !important;
}

.lite-toolbar button b, .lite-toolbar button i, .lite-toolbar button u, .lite-toolbar button s,
.le-toolbar button b,   .le-toolbar button i,   .le-toolbar button u,   .le-toolbar button s {
    font-size: 15px !important;
    font-family: Georgia, serif !important;
    font-weight: 900 !important;
}

/* SVG 尺寸强制 */
.lite-toolbar button svg,
.le-toolbar button svg {
    width: 18px !important;
    height: 18px !important;
    display: block !important;
    fill: none !important;
    stroke: currentColor !important;
    stroke-width: 2 !important;
    stroke-linecap: round !important;
    stroke-linejoin: round !important;
}

.le-tb-group { display: inline-flex; align-items: center; gap: 2px; }
.le-tb-sep   { width: 1px; height: 16px; background: #cbd5e1; margin: 0 4px; display: inline-block; }
.le-toolbar .le-spacer { flex: 1; }

/* ---------- 下拉菜单 ---------- */
.le-dropdown { position: relative; display: inline-flex; }
.le-dropdown-menu {
    display: none;
    position: absolute;
    top: 100%;
    left: 0;
    margin-top: 6px;
    background: #fff;
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.1);
    padding: 10px;
    z-index: 100;
    min-width: 160px;
}
.le-dropdown-menu.show { display: block; }
.le-color-grid {
    display: grid;
    grid-template-columns: repeat(8, 1fr);
    gap: 6px;
}
.le-color-item {
    width: 20px;
    height: 20px;
    border-radius: 4px;
    cursor: pointer;
    border: 1px solid #cbd5e1;
    transition: all .12s;
}
.le-color-item:hover {
    transform: scale(1.15);
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.2);
}

/* ---------- 编辑区（三种模式共存） ---------- */
.le-body { display: flex; min-height: 0; overflow: visible; }

.le-wysiwyg, .le-textarea, .le-preview {
    flex: 1;
    min-width: 0;
    padding: 24px 30px;
    outline: 0;
    font-size: 15px;
    line-height: 1.8;
}

.le-wysiwyg {
    background: #fff;
    color: #1e293b;
    min-height: 480px;
    overflow-y: visible;
    word-wrap: break-word;
    border-radius: 0 0 10px 10px;
}
.le-wysiwyg:empty::before {
    content: attr(data-placeholder);
    color: #cbd5e1;
    pointer-events: none;
    white-space: pre-line;
}

.le-textarea {
    border: 0;
    resize: vertical;
    font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
    font-size: 14px;
    color: #1e293b;
}
.le-preview {
    background: #fbfcfe;
    border-left: 1px dashed #e5e9f0;
    line-height: 1.8;
    word-wrap: break-word;
}

/* 三种显示模式切换 */
.lite-editor .le-wysiwyg,
.lite-editor .le-textarea,
.lite-editor .le-preview { display: none; }
.le-mode-wysiwyg .le-wysiwyg { display: block; }
.le-mode-markdown .le-textarea,
.le-mode-markdown .le-preview { display: block; }
.le-mode-markdown.le-preview-off .le-preview { display: none; }
.le-mode-markdown .le-textarea { border-right: 1px dashed #e5e9f0; }

/* ---------- 富文本排版 ---------- */
.le-wysiwyg h1, .le-preview h1 {
    font-size: 24px;
    padding-bottom: 8px;
    border-bottom: 1px solid #eef1f4;
}
.le-wysiwyg h2, .le-preview h2 {
    font-size: 20px;
    padding-bottom: 6px;
    border-bottom: 1px solid #eef1f4;
}
.le-wysiwyg h3, .le-preview h3 { font-size: 17px; }
.le-wysiwyg p,   .le-preview p  { margin: 11px 0; }

.le-wysiwyg a,   .le-preview a  {
    color: #2563eb;
    text-decoration: none;
    border-bottom: 1px solid rgba(37, 99, 235, .3);
}
.le-wysiwyg img, .le-preview img {
    max-width: 100%;
    height: auto;
    border-radius: 6px;
    margin: 6px 0;
}
.le-wysiwyg code, .le-preview code {
    background: #f1f5f9;
    padding: 2px 7px;
    border-radius: 4px;
    color: #db2777;
    font-size: 13px;
    font-family: ui-monospace, Menlo, Consolas, monospace;
}
.le-wysiwyg pre, .le-preview pre {
    position: relative;
    background: #0f172a;
    color: #e2e8f0;
    padding: 14px 16px;
    border-radius: 8px;
    overflow-x: auto;
    font-size: 13px;
    line-height: 1.65;
    font-family: ui-monospace, Menlo, Consolas, monospace;
    margin: 14px 0;
}
.le-wysiwyg pre code, .le-preview pre code {
    background: none;
    color: inherit;
    padding: 0;
    font-size: inherit;
}

.le-wysiwyg blockquote, .le-preview blockquote {
    border-left: 4px solid #cbd5e1;
    padding: 6px 16px;
    color: #64748b;
    margin: 14px 0;
    background: #f8fafc;
    border-radius: 0 6px 6px 0;
}
.le-wysiwyg ul, .le-wysiwyg ol,
.le-preview ul, .le-preview ol {
    padding-left: 26px;
    margin: 11px 0;
}
.le-wysiwyg li, .le-preview li { margin: 5px 0; }

.le-wysiwyg hr, .le-preview hr {
    border: 0;
    border-top: 1px solid #e5e9f0;
    margin: 22px 0;
}

.le-wysiwyg table, .le-preview table {
    border-collapse: collapse;
    margin: 14px 0;
    width: 100%;
    font-size: 13.5px;
}
.le-wysiwyg th, .le-wysiwyg td,
.le-preview th, .le-preview td {
    border: 1px solid #e5e9f0;
    padding: 9px 14px;
    text-align: left;
}
.le-wysiwyg th, .le-preview th {
    background: #f8fafc;
    font-weight: 600;
}

.le-wysiwyg video, .le-preview video {
    max-width: 100%;
    border-radius: 8px;
    margin: 10px 0;
}

/* ---------- 代码复制按钮 ---------- */
.le-code-copy {
    position: absolute;
    top: 8px;
    right: 10px;
    background: rgba(255, 255, 255, 0.12);
    color: #e2e8f0;
    border: 0;
    border-radius: 5px;
    padding: 3px 10px;
    font-size: 11.5px;
    cursor: pointer;
    font-family: inherit;
    transition: all .15s;
    opacity: 0;
}
.le-code-copy:hover { background: rgba(255, 255, 255, 0.25); }
.le-code-copy.copied {
    background: #10b981;
    color: #fff;
    opacity: 1;
}
pre:hover .le-code-copy { opacity: 1; }

/* ---------- 状态栏 ---------- */
.le-footer {
    padding: 9px 20px;
    background: #f8fafc;
    border-top: 1px solid #e5e9f0;
    font-size: 12.5px;
    color: #94a3b8;
    display: flex;
    justify-content: space-between;
    border-radius: 0 0 10px 10px;
}
.le-status-loading { color: #2563eb !important; }

/* ---------- 查找栏 ---------- */
.le-search-bar {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 14px;
    background: #f8fafc;
    border-bottom: 1px solid #e5e9f0;
    font-size: 13px;
}
.le-search-bar input {
    flex: 1;
    min-width: 0;
    padding: 6px 10px;
    border: 1px solid #dfe3e8;
    border-radius: 6px;
    font-size: 13px;
    font-family: inherit;
    background: #fff;
}
.le-search-bar input:focus {
    outline: 0;
    border-color: #2563eb;
    box-shadow: 0 0 0 3px rgba(37, 99, 235, .12);
}
.le-search-count {
    flex-shrink: 0;
    color: #64748b;
    font-size: 12.5px;
    font-variant-numeric: tabular-nums;
    min-width: 60px;
    text-align: center;
}
.le-search-prev,
.le-search-next,
.le-search-close {
    flex-shrink: 0;
    width: 30px;
    height: 30px;
    padding: 0;
    border: 1px solid #dfe3e8;
    background: #fff;
    border-radius: 6px;
    cursor: pointer;
    color: #475569;
    font-size: 14px;
    line-height: 1;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    transition: all .15s;
}
.le-search-prev:hover,
.le-search-next:hover {
    background: #eff6ff;
    border-color: #bfdbfe;
    color: #2563eb;
}
.le-search-close {
    font-size: 18px;
    color: #94a3b8;
}
.le-search-close:hover {
    background: #fef2f2;
    border-color: #fecaca;
    color: #dc2626;
}

/* ============================================================
   通用对话框（替代 prompt）
   ============================================================ */
.le-dialog-mask {
    position: fixed;
    inset: 0;
    background: rgba(15, 23, 42, .55);
    -webkit-backdrop-filter: blur(2px);
    backdrop-filter: blur(2px);
    z-index: 10000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    animation: leFadeIn .15s ease-out;
}
.le-dialog-mask.le-hiding { animation: leFadeOut .15s ease-in forwards; }

.le-dialog {
    width: 100%;
    background: #fff;
    border-radius: 12px;
    box-shadow: 0 20px 50px rgba(15, 23, 42, .3);
    overflow: hidden;
    animation: leZoomIn .18s cubic-bezier(.2,.8,.2,1);
    max-height: calc(100vh - 40px);
    display: flex;
    flex-direction: column;
}

.le-dialog-head {
    padding: 16px 20px;
    border-bottom: 1px solid #f1f5f9;
    display: flex;
    align-items: center;
    justify-content: space-between;
}
.le-dialog-head h3 {
    margin: 0;
    font-size: 15px;
    font-weight: 700;
    color: #0f172a;
}
.le-dialog-close {
    width: 28px;
    height: 28px;
    border: 0;
    background: transparent;
    border-radius: 6px;
    font-size: 20px;
    line-height: 1;
    color: #94a3b8;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    transition: all .15s;
}
.le-dialog-close:hover {
    background: #f1f5f9;
    color: #475569;
}

.le-dialog-body {
    padding: 20px;
    overflow-y: auto;
    flex: 1;
}
.le-dialog-foot {
    padding: 14px 20px;
    border-top: 1px solid #f1f5f9;
    display: flex;
    gap: 10px;
    justify-content: flex-end;
    background: #fafbfc;
}

/* 对话框内的按钮 */
.le-btn {
    height: 36px;
    padding: 0 18px;
    border: 1px solid #dfe3e8;
    border-radius: 7px;
    background: #fff;
    color: #334155;
    font-size: 13.5px;
    font-family: inherit;
    font-weight: 500;
    cursor: pointer;
    transition: all .15s;
}
.le-btn:hover {
    background: #f8fafc;
    border-color: #cbd5e1;
}
.le-btn-primary {
    background: #2563eb;
    border-color: #2563eb;
    color: #fff;
}
.le-btn-primary:hover {
    background: #1d4ed8;
    border-color: #1d4ed8;
    color: #fff;
}

/* 对话框内表单 */
.le-form-row { margin-bottom: 14px; }
.le-form-row:last-child { margin-bottom: 0; }
.le-form-row label {
    display: block;
    font-size: 12.5px;
    color: #64748b;
    font-weight: 500;
    margin-bottom: 6px;
}
.le-input {
    width: 100%;
    padding: 9px 12px;
    border: 1px solid #dfe3e8;
    border-radius: 7px;
    font-size: 13.5px;
    font-family: inherit;
    color: #1e293b;
    background: #fff;
    box-sizing: border-box;
    transition: border-color .15s, box-shadow .15s;
    line-height: 1.5;
}
.le-input:focus {
    outline: 0;
    border-color: #2563eb;
    box-shadow: 0 0 0 3px rgba(37, 99, 235, .12);
}
textarea.le-input {
    resize: vertical;
    font-family: ui-monospace, Menlo, Consolas, monospace;
    font-size: 12.5px;
    line-height: 1.6;
    min-height: 100px;
}
select.le-input {
    appearance: none;
    -webkit-appearance: none;
    background-image: url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%2364748b' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 12px center;
    padding-right: 36px;
    cursor: pointer;
}
.le-checkbox-label {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 13px;
    color: #334155;
    cursor: pointer;
    user-select: none;
    margin-top: 4px;
}
.le-checkbox-label input { accent-color: #2563eb; margin: 0; }

.le-dialog-hint {
    margin: 0 0 12px;
    padding: 8px 12px;
    background: #eff6ff;
    border: 1px solid #dbeafe;
    border-radius: 6px;
    color: #1e40af;
    font-size: 12.5px;
    line-height: 1.6;
}

/* ---------- 表格选择器 ---------- */
.le-table-picker-hint {
    font-size: 13px;
    color: #64748b;
    margin-bottom: 10px;
    text-align: center;
}
.le-table-picker-hint b {
    color: #2563eb;
    font-weight: 700;
    font-variant-numeric: tabular-nums;
}
.le-table-picker-grid {
    display: grid;
    grid-template-columns: repeat(8, 1fr);
    gap: 3px;
    justify-content: center;
}
.le-table-picker-cell {
    aspect-ratio: 1 / 1;
    border: 1px solid #dfe3e8;
    border-radius: 4px;
    background: #fff;
    cursor: pointer;
    transition: all .1s;
}
.le-table-picker-cell.active {
    background: #dbeafe;
    border-color: #2563eb;
    box-shadow: 0 0 0 1px #2563eb inset;
}
.le-table-picker-cell:hover {
    background: #bfdbfe;
    border-color: #2563eb;
}

/* ---------- 帮助弹窗 ---------- */
.le-modal-mask {
    position: fixed;
    inset: 0;
    background: rgba(15, 23, 42, .55);
    -webkit-backdrop-filter: blur(2px);
    backdrop-filter: blur(2px);
    z-index: 10000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
}
.le-modal {
    background: #fff;
    border-radius: 12px;
    padding: 26px 28px;
    max-width: 420px;
    width: 100%;
    box-shadow: 0 20px 50px rgba(15, 23, 42, .3);
    position: relative;
}
.le-modal h3 {
    margin: 0 0 16px;
    font-size: 16px;
    font-weight: 700;
    color: #0f172a;
}
.le-modal-close {
    position: absolute;
    top: 12px;
    right: 12px;
    width: 28px;
    height: 28px;
    border: 0;
    background: transparent;
    border-radius: 6px;
    font-size: 20px;
    line-height: 1;
    color: #94a3b8;
    cursor: pointer;
}
.le-modal-close:hover {
    background: #f1f5f9;
    color: #475569;
}
.le-modal table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
}
.le-modal table td {
    padding: 8px 4px;
    border-bottom: 1px solid #f1f5f9;
    color: #475569;
}
.le-modal table tr:last-child td { border-bottom: 0; }
.le-modal kbd {
    display: inline-block;
    padding: 1px 6px;
    background: #f1f5f9;
    border: 1px solid #e2e8f0;
    border-radius: 4px;
    font-family: ui-monospace, Menlo, Consolas, monospace;
    font-size: 11.5px;
    color: #334155;
    box-shadow: 0 1px 0 #cbd5e1;
}
.le-modal-tip {
    margin: 14px 0 0;
    padding: 10px 12px;
    background: #fffbeb;
    border: 1px solid #fde68a;
    border-radius: 7px;
    color: #92400e;
    font-size: 12.5px;
    line-height: 1.6;
}

/* ---------- 动画 ---------- */
@keyframes leFadeIn {
    from { opacity: 0; }
    to   { opacity: 1; }
}
@keyframes leFadeOut {
    from { opacity: 1; }
    to   { opacity: 0; }
}
@keyframes leZoomIn {
    from { opacity: 0; transform: scale(.94) translateY(-6px); }
    to   { opacity: 1; transform: scale(1) translateY(0); }
}

/* ---------- 响应式 ---------- */
@media (max-width: 640px) {
    .le-toolbar { padding: 6px 8px; gap: 2px; }
    .le-wysiwyg, .le-textarea, .le-preview { padding: 18px 20px; font-size: 14px; }
    .le-dialog { max-width: calc(100% - 20px) !important; }
    .le-dialog-body { padding: 16px; }
    .le-dialog-head { padding: 14px 16px; }
    .le-dialog-foot { padding: 12px 16px; }
    .le-table-picker-grid { gap: 2px; }
}