/**
 * Nebula Theme - Editor Stylesheet
 * Version: 2.0.0
 * 使文章编辑器内容预览与前端保持一致
 */

/* ============================
   Editor Container
   ============================ */

body.wp-editor {
    font-family: var(--nebula-font-sans, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif);
    font-size: 16px;
    line-height: 1.6;
    color: var(--nebula-text, #1E293B);
    background-color: #fff;
}

/* ============================
   Typography in Editor
   ============================ */

.wp-editor h1,
.wp-editor h2,
.wp-editor h3,
.wp-editor h4,
.wp-editor h5,
.wp-editor h6 {
    font-family: var(--nebula-font-heading, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif);
    font-weight: 600;
    line-height: 1.25;
    color: var(--nebula-secondary, #0F172A);
    margin-top: 1.5em;
    margin-bottom: 0.5em;
}

.wp-editor h1 { font-size: 2rem; }
.wp-editor h2 { font-size: 1.75rem; border-bottom: 1px solid var(--nebula-border, #E2E8F0); padding-bottom: 0.3em; }
.wp-editor h3 { font-size: 1.5rem; }
.wp-editor h4 { font-size: 1.25rem; }
.wp-editor h5 { font-size: 1.125rem; }
.wp-editor h6 { font-size: 1rem; }

.wp-editor p {
    margin: 0 0 1em;
    line-height: 1.7;
}

/* ============================
   Links
   ============================ */

.wp-editor a {
    color: var(--nebula-primary, #0EA5E9);
    text-decoration: underline;
    text-underline-offset: 2px;
}

.wp-editor a:hover {
    color: var(--nebula-primary-hover, #0284C7);
}

/* ============================
   Images
   ============================ */

.wp-editor img {
    max-width: 100%;
    height: auto;
    border-radius: var(--nebula-radius-lg, 12px);
    margin: 1.5em 0;
}

/* ============================
   Code Inline
   ============================ */

.wp-editor code {
    background-color: var(--nebula-bg-secondary, #F1F5F9);
    padding: 2px 6px;
    border-radius: var(--nebula-radius-sm, 4px);
    font-family: 'SF Mono', Monaco, 'Cascadia Code', 'Roboto Mono', Consolas, 'Courier New', monospace;
    font-size: 0.875em;
    color: var(--nebula-accent, #0EA5E9);
}

/* Dark mode code */
.wp-editor.mce-content-body[data-theme="dark"],
body.wp-editor[data-theme="dark"] {
    background-color: #1E293B;
    color: #F8FAFC;
}

.wp-editor.mce-content-body[data-theme="dark"] code,
body.wp-editor[data-theme="dark"] code {
    background-color: #334155;
    color: #38BDF8;
}

/* ============================
   Code Blocks (Pre)
   ============================ */

.wp-editor pre {
    background-color: #1E293B;
    color: #F8FAFC;
    padding: 1em;
    border-radius: var(--nebula-radius-lg, 12px);
    overflow-x: auto;
    margin: 1.5em 0;
    font-family: 'SF Mono', Monaco, 'Cascadia Code', 'Roboto Mono', Consolas, 'Courier New', monospace;
    font-size: 0.875rem;
    line-height: 1.6;
}

.wp-editor pre code {
    background: none;
    padding: 0;
    color: inherit;
    font-size: inherit;
}

/* ============================
   Blockquote
   ============================ */

.wp-editor blockquote {
    margin: 1.5em 0;
    padding: 1em 1.5em;
    border-left: 4px solid var(--nebula-primary, #0EA5E9);
    background-color: var(--nebula-bg-secondary, #F8FAFC);
    color: var(--nebula-text-secondary, #64748B);
    font-style: italic;
}

.wp-editor blockquote p:last-child {
    margin-bottom: 0;
}

.wp-editor blockquote cite {
    display: block;
    margin-top: 0.5em;
    font-size: 0.875em;
    font-style: normal;
}

/* Dark mode blockquote */
[data-theme="dark"] .wp-editor blockquote {
    background-color: #1E293B;
    border-left-color: #38BDF8;
    color: #94A3B8;
}

/* ============================
   Lists
   ============================ */

.wp-editor ul,
.wp-editor ol {
    margin: 1em 0;
    padding-left: 1.5em;
}

.wp-editor ul {
    list-style-type: disc;
}

.wp-editor ol {
    list-style-type: decimal;
}

.wp-editor li {
    margin-bottom: 0.5em;
    line-height: 1.6;
}

.wp-editor li > ul,
.wp-editor li > ol {
    margin-top: 0.5em;
    margin-bottom: 0.5em;
}

/* ============================
   Tables
   ============================ */

.wp-editor table {
    width: 100%;
    border-collapse: collapse;
    margin: 1.5em 0;
    font-size: 0.9375rem;
}

.wp-editor th,
.wp-editor td {
    padding: 0.75em 1em;
    border: 1px solid var(--nebula-border, #E2E8F0);
    text-align: left;
}

.wp-editor th {
    background-color: var(--nebula-bg-secondary, #F8FAFC);
    font-weight: 600;
}

.wp-editor tr:nth-child(even) {
    background-color: var(--nebula-bg-secondary, #F8FAFC);
}

/* Dark mode table */
[data-theme="dark"] .wp-editor th,
[data-theme="dark"] .wp-editor td {
    border-color: #334155;
}

[data-theme="dark"] .wp-editor th {
    background-color: #334155;
}

[data-theme="dark"] .wp-editor tr:nth-child(even) {
    background-color: #1E293B;
}

/* ============================
   Horizontal Rule
   ============================ */

.wp-editor hr {
    border: none;
    border-top: 1px solid var(--nebula-border, #E2E8F0);
    margin: 2em 0;
}

/* ============================
   Alignment Classes
   ============================ */

.wp-editor .alignleft {
    float: left;
    margin-right: 1.5em;
    margin-bottom: 1em;
}

.wp-editor .alignright {
    float: right;
    margin-left: 1.5em;
    margin-bottom: 1em;
}

.wp-editor .aligncenter {
    display: block;
    margin-left: auto;
    margin-right: auto;
}

.wp-editor .alignwide {
    max-width: 100%;
    margin-left: 0;
    margin-right: 0;
}

.wp-editor .alignfull {
    max-width: none;
    margin-left: -1em;
    margin-right: -1em;
}

/* ============================
   Caption (Images with captions)
   ============================ */

.wp-editor .wp-caption {
    max-width: 100%;
    margin: 1.5em 0;
}

.wp-editor .wp-caption-text {
    margin-top: 0.5em;
    font-size: 0.875em;
    color: var(--nebula-text-secondary, #64748B);
    text-align: center;
}

/* ============================
   Gutenberg Specific Styles
   ============================ */

/* WordPress block editor color palette integration */
.wp-editor.has-background {
    padding: 1em;
}

.wp-editor.has-border {
    border: 1px solid var(--nebula-border, #E2E8F0);
}

/* ============================
   Editor Toolbar Fixes
   ============================ */

.mce-toolbar .mce-btn {
    border-radius: var(--nebula-radius-md, 8px);
}

.mce-toolbar .mce-btn:hover {
    background-color: var(--nebula-bg-secondary, #F1F5F9);
}

/* ============================
   Classic Editor Styles
   ============================ */

.editor-styles-wrapper {
    font-family: var(--nebula-font-sans, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif);
    padding: 1em 2em;
}

.editor-styles-wrapper h1,
.editor-styles-wrapper h2,
.editor-styles-wrapper h3,
.editor-styles-wrapper h4,
.editor-styles-wrapper h5,
.editor-styles-wrapper h6 {
    font-family: var(--nebula-font-heading, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif);
}

/* ============================
   Dark Mode in Editor
   ============================ */

@media (prefers-color-scheme: dark) {
    body.wp-editor.auto-dark {
        background-color: #1E293B;
        color: #F8FAFC;
    }
}

/* ============================
   Responsive in Editor Preview
   ============================ */

@media (max-width: 768px) {
    .wp-editor {
        font-size: 14px;
    }

    .wp-editor h1 { font-size: 1.75rem; }
    .wp-editor h2 { font-size: 1.5rem; }
    .wp-editor h3 { font-size: 1.25rem; }

    .wp-editor pre {
        padding: 0.75em;
        font-size: 0.8125rem;
    }
}
