/**
 * 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);
}

/* ============================
   Alert Boxes - 警告提示框
   ============================ */

.wp-editor .wp-block-alert,
.wp-editor .alert,
.wp-editor [class*="alert-"] {
    position: relative;
    margin: 1.5em 0;
    padding: 16px 20px 16px 48px;
    border-radius: var(--nebula-radius-lg, 12px);
    font-size: 0.95rem;
    line-height: 1.6;
}

.wp-editor .alert::before {
    position: absolute;
    left: 16px;
    top: 50%;
    transform: translateY(-50%);
    font-size: 1.25rem;
}

.wp-editor .alert-info { background: #E0F2FE; color: #0369A1; border-left: 4px solid #0EA5E9; }
.wp-editor .alert-info::before { content: "💡"; }
.wp-editor .alert-success, .wp-editor .alert-tip { background: #D1FAE5; color: #065F46; border-left: 4px solid #10B981; }
.wp-editor .alert-success::before { content: "✅"; }
.wp-editor .alert-warning, .wp-editor .alert-caution { background: #FEF3C7; color: #92400E; border-left: 4px solid #F59E0B; }
.wp-editor .alert-warning::before { content: "⚠️"; }
.wp-editor .alert-error, .wp-editor .alert-danger { background: #FEE2E2; color: #991B1B; border-left: 4px solid #EF4444; }
.wp-editor .alert-error::before { content: "❌"; }

/* Callout Box - 引用提示框 */
.wp-editor .callout {
    margin: 1.5em 0;
    padding: 20px 24px;
    background: var(--nebula-bg-secondary, #F8FAFC);
    border-radius: var(--nebula-radius-lg, 12px);
    border: 1px solid var(--nebula-border, #E2E8F0);
}

/* Keyboard Keys */
.wp-editor kbd {
    display: inline-block;
    padding: 4px 8px;
    font-family: 'SF Mono', Monaco, 'Cascadia Code', monospace;
    font-size: 0.85em;
    background: var(--nebula-bg-secondary, #F1F5F9);
    border: 1px solid var(--nebula-border, #E2E8F0);
    border-radius: 4px;
    box-shadow: 0 1px 1px rgba(0,0,0,0.05);
}

/* Mark/Highlight */
.wp-editor mark,
.wp-editor .highlight {
    background: #FEF08A;
    color: #713F12;
    padding: 2px 4px;
    border-radius: 3px;
}

/* Details/Summary */
.wp-editor details {
    margin: 1.5em 0;
    padding: 16px;
    background: var(--nebula-bg-secondary, #F8FAFC);
    border-radius: var(--nebula-radius-lg, 12px);
    border: 1px solid var(--nebula-border, #E2E8F0);
}

.wp-editor summary {
    font-weight: 600;
    cursor: pointer;
    list-style: none;
}

/* Table enhancements */
.wp-editor table {
    border-radius: var(--nebula-radius-lg, 12px);
    overflow: hidden;
    box-shadow: 0 1px 3px rgba(0,0,0,0.1);
}

.wp-editor tr:hover {
    background: 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;
    }
}
