/* 全局样式 */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background-color: #f5f7fa;
    color: #333;
    line-height: 1.6;
    height: 100vh;
    overflow: hidden;
}

.container {
    display: flex;
    flex-direction: column;
    height: 100vh;
}

/* 头部样式 */
.header {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    padding: 1rem 2rem;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
    z-index: 1000;
}

.header h1 {
    margin-bottom: 0.5rem;
    font-size: 1.5rem;
    font-weight: 600;
}

.toolbar {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
}

.toolbar-btn {
    background: rgba(255, 255, 255, 0.2);
    border: 1px solid rgba(255, 255, 255, 0.3);
    color: white;
    padding: 0.5rem 0.75rem;
    border-radius: 5px;
    cursor: pointer;
    font-size: 0.875rem;
    transition: all 0.2s ease;
    backdrop-filter: blur(10px);
}

.toolbar-btn:hover {
    background: rgba(255, 255, 255, 0.3);
    border-color: rgba(255, 255, 255, 0.5);
    transform: translateY(-1px);
}

.toolbar-btn:active {
    transform: translateY(0);
}

/* 主内容区域 */
.main-content {
    flex: 1;
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

.editor-container {
    display: flex;
    height: 100%;
    gap: 0;
}

/* 编辑器面板 */
.editor-panel {
    flex: 1;
    display: flex;
    flex-direction: column;
    background: white;
    border-right: 1px solid #e0e0e0;
}

.preview-panel {
    flex: 1;
    display: flex;
    flex-direction: column;
    background: white;
}

.panel-header {
    background: #f8f9fa;
    padding: 1rem;
    border-bottom: 1px solid #e0e0e0;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.panel-header h3 {
    font-size: 1rem;
    font-weight: 600;
    color: #495057;
}

.char-count, .sync-status {
    font-size: 0.875rem;
    color: #6c757d;
}

/* 编辑器样式 */
.markdown-editor {
    flex: 1;
    width: 100%;
    padding: 1.5rem;
    border: none;
    outline: none;
    font-family: 'Consolas', 'Monaco', 'Courier New', monospace;
    font-size: 0.9375rem;
    line-height: 1.6;
    resize: none;
    background: #fafbfc;
    color: #24292e;
}

.markdown-editor::placeholder {
    color: #959da5;
    font-style: italic;
}

/* 预览区域样式 */
.markdown-preview {
    flex: 1;
    padding: 1.5rem;
    overflow-y: auto;
    background: white;
}

.preview-placeholder {
    color: #959da5;
    font-style: italic;
    text-align: center;
    margin-top: 2rem;
}

.error {
    color: #dc3545;
    background: #f8d7da;
    padding: 1rem;
    border-radius: 5px;
    border: 1px solid #f5c6cb;
}

/* Markdown预览样式 */
.markdown-preview h1,
.markdown-preview h2,
.markdown-preview h3,
.markdown-preview h4,
.markdown-preview h5,
.markdown-preview h6 {
    margin-top: 1.5rem;
    margin-bottom: 1rem;
    font-weight: 600;
    line-height: 1.25;
}

.markdown-preview h1 {
    font-size: 2rem;
    border-bottom: 2px solid #e0e0e0;
    padding-bottom: 0.5rem;
}

.markdown-preview h2 {
    font-size: 1.5rem;
    border-bottom: 1px solid #e0e0e0;
    padding-bottom: 0.3rem;
}

.markdown-preview h3 {
    font-size: 1.25rem;
}

.markdown-preview h4 {
    font-size: 1rem;
}

.markdown-preview p {
    margin-bottom: 1rem;
}

.markdown-preview ul,
.markdown-preview ol {
    margin-bottom: 1rem;
    padding-left: 2rem;
}

.markdown-preview li {
    margin-bottom: 0.25rem;
}

.markdown-preview blockquote {
    margin: 1rem 0;
    padding: 0.5rem 1rem;
    border-left: 4px solid #667eea;
    background: #f8f9fa;
    color: #495057;
}

.markdown-preview code {
    background: #f1f3f4;
    padding: 0.2rem 0.4rem;
    border-radius: 3px;
    font-family: 'Consolas', 'Monaco', 'Courier New', monospace;
    font-size: 0.875rem;
}

.markdown-preview pre {
    background: #f6f8fa;
    border-radius: 6px;
    padding: 1rem;
    overflow-x: auto;
    margin-bottom: 1rem;
}

.markdown-preview pre code {
    background: none;
    padding: 0;
    font-size: 0.875rem;
}

.markdown-preview table {
    border-collapse: collapse;
    width: 100%;
    margin-bottom: 1rem;
}

.markdown-preview th,
.markdown-preview td {
    border: 1px solid #e0e0e0;
    padding: 0.5rem;
    text-align: left;
}

.markdown-preview th {
    background: #f8f9fa;
    font-weight: 600;
}

.markdown-preview a {
    color: #667eea;
    text-decoration: none;
}

.markdown-preview a:hover {
    text-decoration: underline;
}

.markdown-preview img {
    max-width: 100%;
    height: auto;
    border-radius: 6px;
    margin: 1rem 0;
}

/* 代码高亮主题补充 */
.hljs {
    background: #f6f8fa !important;
    border-radius: 6px;
    padding: 1rem !important;
}

/* 底部样式 */
.footer {
    background: #343a40;
    color: white;
    text-align: center;
    padding: 1rem;
    font-size: 0.875rem;
    border-top: 1px solid #495057;
}

/* 响应式设计 */
@media (max-width: 768px) {
    .header {
        padding: 1rem;
    }

    .header h1 {
        font-size: 1.25rem;
    }

    .toolbar {
        gap: 0.25rem;
    }

    .toolbar-btn {
        padding: 0.4rem 0.6rem;
        font-size: 0.75rem;
    }

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

    .editor-panel {
        border-right: none;
        border-bottom: 1px solid #e0e0e0;
    }

    .markdown-editor,
    .markdown-preview {
        padding: 1rem;
        font-size: 0.875rem;
    }

    .panel-header {
        padding: 0.75rem 1rem;
    }

    .panel-header h3 {
        font-size: 0.875rem;
    }
}

@media (max-width: 480px) {
    .header {
        padding: 0.75rem;
    }

    .toolbar-btn span {
        display: none;
    }

    .markdown-editor,
    .markdown-preview {
        padding: 0.75rem;
        font-size: 0.8rem;
    }

    .footer {
        padding: 0.75rem;
        font-size: 0.75rem;
    }
}

/* 滚动条样式 */
::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

::-webkit-scrollbar-track {
    background: #f1f1f1;
}

::-webkit-scrollbar-thumb {
    background: #c1c1c1;
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: #a8a8a8;
}

/* 动画效果 */
@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.markdown-preview > * {
    animation: fadeIn 0.3s ease-out;
}

/* 打印样式 */
@media print {
    .header,
    .footer,
    .toolbar {
        display: none;
    }

    .editor-container {
        height: auto;
        display: block;
    }

    .editor-panel {
        display: none;
    }

    .preview-panel {
        width: 100%;
        height: auto;
    }

    .markdown-preview {
        overflow: visible;
    }
}