/* ============================================================
   editor.css - 本地页面编辑器（仿 Wikidot 编辑界面）
   依赖：editor.js
   说明：
     - 本机离线编辑，保存到 localStorage
     - 目前只支持标准 HTML / JS / CSS 三种文本域
     - 后期接后端时，把 editor.js 的 load/save 换成 API 即可
   ============================================================ */

/* ---- 遮罩 ---- */
.editor-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.45);
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.22s ease, visibility 0.22s;
    z-index: 4000;
}

.editor-overlay.is-open {
    opacity: 1;
    visibility: visible;
}

/* ---- 编辑器面板 ---- */
.editor-panel {
    position: fixed;
    top: 0;
    right: 0;
    width: min(96vw, 1100px);
    height: 100vh;
    background: #f4efe1;
    border-left: 1px solid rgba(184, 169, 142, 0.6);
    box-shadow: -0.8vmin 0 2.4vmin rgba(0, 0, 0, 0.25);
    transform: translateX(100%);
    transition: transform 0.28s cubic-bezier(0.4, 0, 0.2, 1);
    z-index: 4100;
    display: flex;
    flex-direction: column;
    font-family: "Microsoft YaHei", "Helvetica Neue", Arial, sans-serif;
    color: #2b2418;
}

.editor-panel.is-open {
    transform: translateX(0);
}

/* ---- 顶部工具条 ---- */
.editor-toolbar {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px 18px;
    background: #1a1a1a;
    color: #e8e8e8;
    flex-shrink: 0;
    flex-wrap: wrap;
}

.editor-title {
    font-size: 15px;
    font-weight: 700;
    letter-spacing: 0.04em;
    margin-right: auto;
}

.editor-title .editor-page-id {
    font-size: 12px;
    font-weight: 400;
    color: #b9b9b9;
    margin-left: 8px;
}

.editor-btn {
    font-family: inherit;
    font-size: 12px;
    font-weight: 600;
    letter-spacing: 0.06em;
    padding: 7px 14px;
    border: 1px solid #555;
    border-radius: 0;
    background: #2c2c2c;
    color: #e8e8e8;
    cursor: pointer;
    transition: background 0.18s ease, border-color 0.18s ease, color 0.18s ease;
}

.editor-btn:hover {
    background: #3a3a3a;
    border-color: #777;
}

.editor-btn--primary {
    background: #8a5a2b;
    border-color: #6f461f;
    color: #ffffff;
}

.editor-btn--primary:hover {
    background: #6f461f;
    border-color: #573617;
}

.editor-btn--danger:hover {
    background: #7a2f21;
    border-color: #a04a35;
    color: #ffffff;
}

/* ---- 源类型页签 ---- */
.editor-tabs {
    display: flex;
    gap: 0;
    border-bottom: 1px solid rgba(184, 169, 142, 0.6);
    background: rgba(184, 169, 142, 0.16);
    flex-shrink: 0;
}

.editor-tab {
    font-family: inherit;
    font-size: 12px;
    font-weight: 700;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    padding: 10px 22px;
    border: none;
    border-right: 1px solid rgba(184, 169, 142, 0.45);
    border-bottom: 2px solid transparent;
    background: transparent;
    color: #6b5b44;
    cursor: pointer;
    transition: background 0.18s ease, color 0.18s ease, border-color 0.18s ease;
}

.editor-tab:hover {
    background: rgba(138, 90, 43, 0.10);
    color: #2b2418;
}

.editor-tab.is-active {
    background: #f4efe1;
    color: #2b2418;
    border-bottom-color: #8a5a2b;
}

/* ---- 主体：编辑区 + 预览 ---- */
.editor-body {
    flex: 1;
    display: flex;
    min-height: 0;
}

.editor-pane {
    flex: 1;
    display: none;
    flex-direction: column;
    min-width: 0;
}

.editor-pane.is-active {
    display: flex;
}

/* ---- 文本域（无圆角、细边框、等宽字体）---- */
.editor-textarea {
    flex: 1;
    width: 100%;
    border: none;
    outline: none;
    resize: none;
    padding: 16px 18px;
    background: #fffdf7;
    color: #2b2418;
    font-family: "Cascadia Mono", "Consolas", "JetBrains Mono", "SFMono-Regular",
                 Menlo, Monaco, "Courier New", monospace;
    font-size: 13px;
    line-height: 1.65;
    tab-size: 4;
    /* 纸纹 */
    background-image:
        radial-gradient(circle at 50% 50%, rgba(138, 90, 43, 0.045) 0.5px, transparent 1.5px),
        radial-gradient(circle at 50% 50%, rgba(138, 90, 43, 0.03) 0.5px, transparent 1.5px);
    background-size: 7px 7px, 11px 11px;
    background-position: 0 0, 3px 4px;
}

/* ---- 预览框 ---- */
.editor-preview {
    flex: 1;
    min-width: 0;
    border: none;
    border-left: 1px solid rgba(184, 169, 142, 0.6);
    background: #ffffff;
}

/* ---- 状态栏 ---- */
.editor-status {
    flex-shrink: 0;
    padding: 8px 18px;
    font-size: 11.5px;
    letter-spacing: 0.04em;
    color: #5d5040;
    background: rgba(184, 169, 142, 0.18);
    border-top: 1px solid rgba(184, 169, 142, 0.5);
    display: flex;
    gap: 18px;
    flex-wrap: wrap;
}

.editor-status .is-dirty {
    color: #8a5a2b;
    font-weight: 700;
}

/* ---- 页面内「编辑」按钮（挂在每个 tab-panel 底部）---- */
.page-edit-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    margin-top: 28px;
    padding: 7px 16px;
    font-family: inherit;
    font-size: 11.5px;
    font-weight: 700;
    letter-spacing: 0.14em;
    text-transform: uppercase;
    color: #8a5a2b;
    background: transparent;
    border: 1px solid rgba(138, 90, 43, 0.45);
    border-radius: 0;
    cursor: pointer;
    transition: background 0.18s ease, color 0.18s ease, border-color 0.18s ease;
}

.page-edit-btn:hover {
    background: rgba(138, 90, 43, 0.12);
    border-color: #8a5a2b;
    color: #5d3a16;
}

.page-edit-btn:active {
    background: rgba(138, 90, 43, 0.2);
}

/* 顶栏上的「编辑模式」开关 */
.editor-mode-toggle {
    margin-left: 10px;
}

/* ---- 窄屏：编辑区与预览改为上下排布 ---- */
@media (max-width: 860px) {
    .editor-panel {
        width: 100vw;
    }

    .editor-body {
        flex-direction: column;
    }

    .editor-preview {
        border-left: none;
        border-top: 1px solid rgba(184, 169, 142, 0.6);
        min-height: 40vh;
    }

    .editor-textarea {
        font-size: 12px;
    }
}