/* ========================================
   Markdown 预览工具样式
   ======================================== */

/* 主内容 */
.main-content { 
    width: 100%; 
    max-width: 1400px; /* Markdown needs wide screen */
    height: calc(100vh - 120px); 
    display: flex; 
    align-items: center; 
    padding: 0 20px; 
    padding-bottom: 50px; 
    z-index: 10; 
}
.container { width: 100%; height: 100%; }
.tool-card { 
    background: var(--bg-card); 
    border: 1px solid var(--border-color); 
    border-radius: var(--radius-xl); 
    overflow: hidden; 
    display: flex; 
    flex-direction: column; 
    width: 100%;
    height: 100%;
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.3);
}

/* 顶部工具栏 */
.toolbar { 
    display: flex; 
    justify-content: space-between; 
    align-items: center; 
    padding: 10px 16px; 
    border-bottom: 1px solid var(--border-color); 
    background: rgba(0,0,0,0.2); 
    flex-shrink: 0;
    flex-wrap: wrap;
    gap: 10px;
}
.actions-left, .actions-right { display: flex; align-items: center; gap: 10px; }
.tool-title { font-size: 14px; color: var(--text-secondary); font-weight: 600; display: flex; align-items: center; gap: 6px; }

.btn-action { 
    padding: 8px 16px; 
    border-radius: var(--radius-md); 
    border: 1px solid var(--border-color); 
    background: rgba(255,255,255,0.05); 
    color: var(--text-secondary); 
    cursor: pointer; 
    font-size: 13px; 
    display: flex; 
    align-items: center; 
    gap: 6px;
    transition: 0.2s;
}
.btn-action:hover { background: rgba(255,255,255,0.1); color: var(--text-primary); }
.btn-action.btn-green { background: var(--primary-light); border-color: var(--border-color-hover); color: var(--primary-color); }
.btn-action.btn-green:hover { background: var(--border-color-hover); }

/* 编辑器区域 */
.editor-container {
    display: flex;
    flex: 1;
    min-height: 0;
    overflow: hidden;
}
.editor-pane, .preview-pane {
    flex: 1;
    min-width: 0;
    position: relative;
    display: flex;
    flex-direction: column;
}
.editor-pane:not(:last-child) { border-right: 1px solid var(--border-color); }

/* 编辑器 */
textarea#editor {
    flex: 1;
    padding: 20px;
    background: transparent;
    border: none;
    outline: none;
    resize: none;
    font-family: var(--font-mono, 'Consolas', 'Monaco', monospace);
    font-size: 15px;
    line-height: 1.7;
    color: var(--text-primary);
    overflow: auto;
    white-space: pre-wrap;
    word-break: break-word;
}
textarea#editor::placeholder { color: var(--text-muted); }

/* 预览区 Markdown 样式 (GitHub Dark Theme adapted) */
.markdown-body {
    flex: 1;
    padding: 20px;
    overflow-y: auto;
    color: #c9d1d9;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Helvetica, Arial, sans-serif, "Apple Color Emoji", "Segoe UI Emoji";
    font-size: 15px;
    line-height: 1.7;
    word-wrap: break-word;
}
.markdown-body h1, .markdown-body h2, .markdown-body h3, 
.markdown-body h4, .markdown-body h5, .markdown-body h6 {
    margin-top: 24px; margin-bottom: 16px; font-weight: 600;
    line-height: 1.25; color: #fff;
}
.markdown-body h1 { font-size: 2em; padding-bottom: 0.3em; border-bottom: 1px solid #21262d; }
.markdown-body h2 { font-size: 1.5em; padding-bottom: 0.3em; border-bottom: 1px solid #21262d; }
.markdown-body h3 { font-size: 1.25em; }

.markdown-body p { margin-top: 0; margin-bottom: 16px; }
.markdown-body a { color: #58a6ff; text-decoration: none; }
.markdown-body a:hover { text-decoration: underline; }
.markdown-body img { max-width: 100%; box-sizing: border-box; background-color: transparent; border-radius: 4px; }

.markdown-body code {
    padding: 0.2em 0.4em; margin: 0; font-size: 85%;
    background-color: rgba(110,118,129,0.4);
    border-radius: 6px;
    font-family: ui-monospace,SFMono-Regular,SF Mono,Menlo,Consolas,Liberation Mono,monospace;
}
.markdown-body pre {
    padding: 16px; overflow: auto; font-size: 85%; line-height: 1.45;
    background-color: #0d1117; border-radius: 6px;
    margin-bottom: 16px;
}
.markdown-body pre > code {
    padding: 0; margin: 0; word-break: normal; white-space: pre;
    background: transparent; border: 0;
}

.markdown-body blockquote {
    margin: 0; margin-bottom: 16px; padding: 0 1em;
    color: #8b949e; border-left: 0.25em solid #30363d;
}
.markdown-body blockquote > :first-child { margin-top: 0; }
.markdown-body blockquote > :last-child { margin-bottom: 0; }

.markdown-body table { border-collapse: collapse; margin-bottom: 16px; width: 100%; }
.markdown-body table th, .markdown-body table td { padding: 6px 13px; border: 1px solid #30363d; }
.markdown-body table tr { background-color: #0d1117; border-top: 1px solid #21262d; }
.markdown-body table tr:nth-child(2n) { background-color: #161b22; }

.markdown-body hr { height: 0.25em; padding: 0; margin: 24px 0; background-color: #30363d; border: 0; }
.markdown-body ul, .markdown-body ol { padding-left: 2em; margin-bottom: 16px; }
.markdown-body li { margin: 0.25em 0; }

/* 响应式 */
@media (max-width: 768px) {
    .editor-container { flex-direction: column; }
    .editor-pane:not(:last-child) { border-right: none; border-bottom: 1px solid var(--border-color); }
    .editor-pane, .preview-pane { height: 50%; }
    .toolbar { flex-direction: column; align-items: stretch; }
    .actions-left, .actions-right { justify-content: space-between; }
}
