/* 基础样式 */
body {
    margin: 0;
    padding: 0;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", "Helvetica Neue", Helvetica, Arial, sans-serif;
    background-color: #f4f5f5;
    min-height: 100vh;
    overflow-x: hidden;
}

/* 图片延迟加载样式 */
.preview-section img {
    opacity: 0;
    transition: opacity 0.2s ease-in-out;
    transform: translateZ(0);
    backface-visibility: hidden;
    perspective: 1000px;
}

.preview-section img.loaded {
    opacity: 1;
}

/* 图片加载错误样式 */
.preview-section img[alt="图片加载失败"] {
    opacity: 1;
    min-height: 50px;
    background: #f5f5f5 url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="red" stroke-width="2"><path d="M10.29 3.86L1.82 18a2 2 0 0 0 1.71 3h16.94a2 2 0 0 0 1.71-3L13.71 3.86a2 2 0 0 0-3.42 0z"></path><line x1="12" y1="9" x2="12" y2="13"></line><line x1="12" y1="17" x2="12.01" y2="17"></line></svg>') center center no-repeat;
    display: flex;
    align-items: flex-end;
    justify-content: center;
    padding-bottom: 10px;
    font-size: 12px;
    color: #666;
    font-style: italic;
}

/* 添加懒加载占位符 */
.preview-section img:not(.loaded):not([alt="图片加载失败"]) {
    min-height: 50px;
    background: #f5f5f5 url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" width="38" height="38" viewBox="0 0 38 38"><g fill="none" fill-rule="evenodd"><g transform="translate(1 1)" stroke-width="2"><circle stroke-opacity=".5" cx="18" cy="18" r="18"/><path d="M36 18c0-9.94-8.06-18-18-18"><animateTransform attributeName="transform" type="rotate" from="0 18 18" to="360 18 18" dur="1s" repeatCount="indefinite"/></path></g></g></svg>') center center no-repeat;
}

/* 布局 */
.container {
    display: flex;
    min-height: 100vh;
    padding: 1rem;
    gap: 1rem;
    box-sizing: border-box;
    background: linear-gradient(135deg, #f4f5f5 0%, #fff 100%);
    flex-direction: column;
    max-width: 1920px;
    margin: 0 auto;
    width: 100%;
}

.main-content {
    display: flex;
    gap: 1rem;
    flex: 1;
    min-height: 500px;
    margin-bottom: 2rem;
}

/* 响应式布局 */
@media screen and (max-width: 768px) {
    .container {
        padding: 0.5rem;
        gap: 0.5rem;
    }

    .main-content {
        flex-direction: column;
        min-height: auto;
    }

    .editor-section, .preview-section {
        min-height: auto;
    }
    
    .editor-container, .CodeMirror, #nice {
        min-height: 300px;
    }

    .theme-selector {
        flex-direction: column;
        align-items: stretch;
        gap: 0.5rem;
    }

    .code-style-selector {
        margin-left: 0;
    }

    .toolbar {
        flex-wrap: wrap;
    }

    .toolbar button {
        flex: 1;
        min-width: 120px;
    }

    .header {
        flex-direction: column;
        gap: 0.5rem;
        text-align: center;
    }

    .logo-section {
        justify-content: center;
    }

    #nice {
        padding: 20px !important;
    }
}

@media screen and (min-width: 769px) and (max-width: 1200px) {
    .container {
        padding: 1rem;
    }

    .main-content {
        min-height: calc(100vh - 280px);
    }
}

@media screen and (min-width: 1201px) {
    .container {
        padding: 1.5rem;
    }
}

/* 编辑区域 */
.editor-section {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 15px;
    min-width: 0;
    background: #fff;
    border-radius: 12px;
    box-shadow: 0 2px 12px rgba(0,0,0,0.08);
    overflow: hidden;
    height: auto;
}

.editor-container {
    flex: 1;
    overflow: visible;
    border-top: 1px solid #eee;
    min-height: 500px;
}

/* CodeMirror自定义样式 */
.CodeMirror {
    height: auto !important;
    min-height: 500px !important;
    font-size: 15px;
    font-family: "JetBrains Mono", Consolas, Monaco, "Andale Mono", monospace;
    line-height: 1.6;
    padding: 20px;
}

.CodeMirror-gutters {
    border-right: 1px solid #eee;
    background-color: #fff;
}

.CodeMirror-linenumber {
    color: #ccc;
}

/* 预览区域 */
.preview-section {
    flex: 1;
    background-color: #fff;
    border-radius: 12px;
    overflow: visible;
    box-shadow: 0 2px 12px rgba(0,0,0,0.08);
    min-width: 0;
    max-height: none;
    display: flex;
    flex-direction: column;
    height: auto;
}

/* 预览内容容器 */
#nice {
    flex: 1;
    overflow: visible;
    padding: 40px;
    word-break: break-word;
    line-height: 1.75;
    font-weight: 400;
    font-size: 15px;
    will-change: transform;
    height: auto;
    min-height: 500px;
}

/* 工具栏 */
.toolbar {
    padding: 15px 20px;
    display: flex;
    gap: 12px;
    background: #fff;
}

.toolbar button {
    padding: 8px 16px;
    font-size: 14px;
    color: #fff;
    background: #1e80ff;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    gap: 6px;
    box-shadow: 0 2px 6px rgba(30,128,255,0.2);
}

.toolbar button:hover {
    background: #1b72e8;
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(30,128,255,0.3);
}

.toolbar button:active {
    transform: translateY(0);
    box-shadow: 0 2px 6px rgba(30,128,255,0.2);
}

/* 加载动画 */
.loading {
    display: none;
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    padding: 15px 25px;
    background: rgba(0,0,0,0.8);
    color: #fff;
    border-radius: 8px;
    font-size: 14px;
    z-index: 1000;
    box-shadow: 0 4px 12px rgba(0,0,0,0.2);
}

/* 复制成功提示 */
.copy-success {
    position: fixed;
    top: 20px;
    right: 20px;
    padding: 10px 20px;
    background: rgba(0,0,0,0.8);
    color: #fff;
    border-radius: 6px;
    font-size: 14px;
    opacity: 0;
    transform: translateY(-10px);
    transition: all 0.3s ease;
    z-index: 1000;
}

.copy-success.show {
    opacity: 1;
    transform: translateY(0);
}

/* 滚动条样式 */
::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

::-webkit-scrollbar-track {
    background: #f1f1f1;
    border-radius: 4px;
}

::-webkit-scrollbar-thumb {
    background: #ccc;
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: #999;
}

/* 主题选择器 */
.theme-selector {
    margin-bottom: 20px;
    padding: 20px;
    background: #fff;
    border-radius: 12px;
    box-shadow: 0 2px 12px rgba(0,0,0,0.08);
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 20px;
}

.theme-selector label {
    font-size: 14px;
    color: #666;
}

.theme-selector select {
    padding: 6px 12px;
    border: 1px solid #e4e6eb;
    border-radius: 6px;
    font-size: 14px;
    color: #333;
    background: #fff;
    cursor: pointer;
    outline: none;
    transition: all 0.3s ease;
}

.theme-selector select:hover {
    border-color: #1e80ff;
}

.theme-selector select:focus {
    border-color: #1e80ff;
    box-shadow: 0 0 0 2px rgba(30,128,255,0.1);
}

/* 代码块样式选择器 */
.code-style-selector {
    display: flex;
    align-items: center;
    gap: 8px;
}

.code-style-selector select {
    padding: 6px 12px;
    border: 1px solid #e4e6eb;
    border-radius: 6px;
    font-size: 14px;
    color: #333;
    background: #fff;
    cursor: pointer;
    outline: none;
    transition: all 0.3s ease;
}

.code-style-selector select:hover {
    border-color: #1e80ff;
}

/* 页眉样式 */
.header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem 2rem;
    background: #fff;
    box-shadow: 0 2px 8px rgba(0,0,0,0.05);
    border-radius: 8px;
    margin-bottom: 2rem;
}

.logo-section {
    display: flex;
    align-items: center;
}

.logo-image {
    height: 40px;
    width: auto;
    max-width: 180px;
    margin-right: 0.5rem;
}

.logo {
    width: 40px;
    height: 40px;
    background: #1e80ff;
    color: #fff;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 24px;
    font-weight: bold;
    margin-right: 0.5rem;
}

.logo-text {
    font-size: 1.2rem;
    font-weight: bold;
    color: #333;
}

.header-nav {
    display: flex;
    align-items: center;
    gap: 20px;
}

.header-nav a {
    color: #666;
    text-decoration: none;
    font-size: 14px;
    transition: all 0.3s ease;
    padding: 5px 10px;
    border-radius: 4px;
}

.header-nav a:hover {
    color: #1e80ff;
    background: rgba(30,128,255,0.1);
}

.header-nav a.active {
    color: #1e80ff;
    background: rgba(30,128,255,0.1);
    font-weight: 500;
}

.header-right {
    color: #666;
    font-size: 14px;
}

/* 页脚样式 */
.footer {
    background: #fff;
    padding: 15px 20px;
    border-radius: 12px;
    margin-top: 20px;
    box-shadow: 0 2px 12px rgba(0,0,0,0.08);
    text-align: center;
    color: #666;
    font-size: 14px;
}

.footer a {
    color: #1e80ff;
    text-decoration: none;
    transition: opacity 0.3s;
}

.footer a:hover {
    opacity: 0.8;
}

/* 拖放区域高亮样式 */
.CodeMirror.drag-over {
    border: 2px dashed #1e80ff;
    background-color: rgba(30, 128, 255, 0.05);
}

/* 粘贴按钮样式 */
.toolbar button.paste-button {
    background-color: #28a745;
}

.toolbar button.paste-button:hover {
    background-color: #218838;
}

/* Markdown编辑器通用样式 */
#nice p {
    margin: 1.5em 0;
    padding: 0;
    line-height: 1.75;
    color: #333;
    font-size: 15px;
    text-align: justify;
    word-spacing: 0.1em;
    letter-spacing: 0.1em;
}

#nice h1, #nice h2, #nice h3, #nice h4, #nice h5, #nice h6 {
    margin: 1.2em 0 1em;
    font-weight: bold;
}

#nice ul, #nice ol {
    margin: 1em 0;
    padding-left: 2em;
}

#nice li {
    margin: 0.5em 0;
}

#nice blockquote {
    margin: 1em 0;
    padding: 15px 20px;
    background: #f8f9fa;
    border-left: 4px solid #1e80ff;
    border-radius: 4px;
    color: #666;
}

#nice a {
    color: #1e80ff;
    text-decoration: none;
    border-bottom: 1px solid #1e80ff;
    opacity: 0.8;
    transition: all 0.3s ease;
}

#nice code {
    padding: 2px 4px;
    font-size: 13px;
    background: rgba(30,128,255,0.1);
    border-radius: 3px;
    color: #1e80ff;
    font-family: "JetBrains Mono", Consolas, Monaco, "Andale Mono", monospace;
}

#nice pre {
    margin: 1em 0;
    padding: 15px;
    background: #f8f9fa;
    border-radius: 6px;
    overflow-x: auto;
}

#nice pre code {
    padding: 0;
    background: none;
    color: #333;
    font-size: 13px;
    line-height: 1.6;
}

#nice table {
    width: 100%;
    margin: 1em 0;
    border-collapse: collapse;
    border: 1px solid #eee;
    border-radius: 6px;
    overflow: hidden;
}

#nice table th, #nice table td {
    padding: 10px 15px;
    border: 1px solid #eee;
    font-size: 14px;
}

#nice table th {
    background: #f8f9fa;
    font-weight: 500;
    color: #333;
}

#nice table tr:nth-child(even) {
    background: #f8f9fa;
}

/* 提示框样式 */
.note {
    padding: 1rem;
    background: #f0f7ff;
    border-left: 4px solid #1e80ff;
    border-radius: 4px;
    margin: 1rem 0;
    font-size: 14px;
    color: #555;
}

.note p {
    margin: 0.5em 0 !important;
}

.note strong {
    color: #1e80ff;
}

/* 加载中状态 */
.loading-content {
    position: relative;
}

.loading-content:after {
    content: "";
    position: absolute;
    top: 8px;
    right: 8px;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    border: 2px solid rgba(30,128,255,0.2);
    border-top-color: #1e80ff;
    animation: spin 0.8s infinite linear;
    z-index: 10;
}

@keyframes spin {
    from {transform: rotate(0deg);}
    to {transform: rotate(360deg);}
} 
