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

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    background-color: #f5f5f5;
    height: 100vh;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

/* 头部样式 */
.header {
    background-color: #1e88e5;
    color: white;
    padding: 10px 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.header h1 {
    font-size: 1.5rem;
    font-weight: 500;
}

/* 工具栏样式 */
.toolbar {
    background-color: #f9f9f9;
    padding: 10px 20px;
    border-bottom: 1px solid #e0e0e0;
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
}

/* 下拉菜单样式 */
.dropdown {
    position: relative;
}

.dropdown-toggle {
    position: relative;
    padding-right: 24px;
    min-width: 110px; /* 增加最小宽度，确保文字不被遮挡 */
}

.dropdown-toggle::after {
    content: '';
    position: absolute;
    right: 10px;
    top: 50%;
    transform: translateY(-50%);
    border-left: 5px solid transparent;
    border-right: 5px solid transparent;
    border-top: 5px solid #333;
}

/* 新代码 - 段落1 */
.dropdown-menu {
    position: absolute;
    top: 100%;
    left: 0;
    z-index: 1000;
    min-width: 180px;
    padding: 5px 0;
    margin: 2px 0 0; /* 这里可以保留边距，因为过渡效果解决了盲区问题 */
    background-color: #fff;
    border: 1px solid rgba(0,0,0,.15);
    border-radius: 4px;
    box-shadow: 0 6px 12px rgba(0,0,0,.175);
    
    /* 【核心修改点】使用 visibility 和 opacity 代替 display */
    visibility: hidden;
    opacity: 0;
    transition: opacity 0.15s ease-in-out, visibility 0.15s ease-in-out;
}

/* 新代码 - 段落2 */
/* 【需要添加】 */
/* 当父级 .dropdown 元素拥有 .active 类时，显示下拉菜单 */
.dropdown.active .dropdown-menu {
    visibility: visible;
    opacity: 1;
}

.dropdown-item {
    display: block;
    width: 100%;
    padding: 8px 15px;
    clear: both;
    font-weight: 400;
    color: #333;
    text-align: inherit;
    white-space: nowrap;
    background-color: transparent;
    border: 0;
    text-decoration: none;
}

.dropdown-item:hover {
    background-color: #f5f5f5;
    color: #262626;
}

.hidden-select {
    display: none;
}

#theme-dropdown-menu a {
    display: block;
    width: 100%;
    padding: 8px 15px;
    clear: both;
    font-weight: 400;
    color: #333;
    text-align: inherit;
    white-space: nowrap;
    background-color: transparent;
    border: 0;
    text-decoration: none;
    cursor: pointer;
}

#theme-dropdown-menu a:hover {
    background-color: #f5f5f5;
    color: #262626;
}

.btn {
    padding: 8px 12px;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-size: 14px;
    display: flex;
    align-items: center;
    gap: 5px;
    transition: background-color 0.2s, transform 0.1s;
}

.btn:active {
    transform: scale(0.98);
}

.btn-primary {
    background-color: #1e88e5;
    color: white;
}

.btn-primary:hover {
    background-color: #1976d2;
}

.btn-secondary {
    background-color: #f5f5f5;
    color: #333;
    border: 1px solid #ddd;
}

.btn-secondary:hover {
    background-color: #e0e0e0;
}

.btn-success {
    background-color: #43a047;
    color: white;
}

.btn-success:hover {
    background-color: #388e3c;
}

/* 编辑模式切换按钮样式 */
/* 【请替换这个规则】 */
.btn-mode {
    background-color: #f5f5f5;
    color: #333;
    border: 1px solid #ddd;
    position: relative;
    transition: background-color 0.3s, color 0.3s;
    min-width: 140px; /* 新增：设置最小宽度防止跳动 */
    justify-content: center; /* 新增：让文字内容居中 */
}

.btn-mode.markdown-active {
    background-color: #4caf50;
    color: white;
    border-color: #43a047;
}

.btn-mode.html-active {
    background-color: #2196f3;
    color: white;
    border-color: #1e88e5;
}

.btn-group {
    display: flex;
    gap: 5px;
}

/* 主容器样式 */
.main-container {
    display: flex;
    flex: 1;
    overflow: hidden;
}

.editor-container, .preview-container {
    flex: 1;
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

.editor-container {
    border-right: 1px solid #e0e0e0;
}

.panel-header {
    background-color: #f5f5f5;
    padding: 10px 15px;
    font-weight: 500;
    border-bottom: 1px solid #e0e0e0;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.panel-content {
    flex: 1;
    overflow: auto;
    display: flex; /* 使用flex布局 */
    flex-direction: column; /* 垂直方向排列 */
}

/* CodeMirror 编辑器样式 */
.CodeMirror {
    height: 100%;
    font-size: 14px;
    font-family: 'Consolas', 'Monaco', 'Courier New', monospace;
}

/* 预览框架样式 */
.preview-frame {
    width: 100%;
    height: 100%;
    border: none;
    background-color: rgb(255, 255, 255);
    overflow: auto; /* 允许滚动 */
}

/* 模态框样式 */
.modal {
    display: none; /* display的默认值改为none */
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.5);
    z-index: 1000;
}

.modal-content {
    position: absolute; /* <-- 新增 */
    top: 50%; /* <-- 新增 */
    left: 50%; /* <-- 新增 */
    transform: translate(-50%, -50%); /* <-- 新增 */
    background-color: white;
    padding: 20px;
    border-radius: 8px;
    width: 500px;
    max-width: 90%;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 15px;
	cursor: move;
}

.modal-title {
    font-size: 1.2rem;
    font-weight: 500;
}

.close-btn {
    background: none;
    border: none;
    font-size: 1.5rem;
    cursor: pointer;
    color: #666;
}

.form-group {
    margin-bottom: 15px;
}

.form-group label {
    display: block;
    margin-bottom: 5px;
    font-weight: 500;
}

.form-control {
    width: 100%;
    padding: 8px 12px;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-size: 14px;
}

/* 查找替换功能样式 */
.search-results-info {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 15px;
    padding: 10px;
    background-color: #f5f5f5;
    border-radius: 4px;
}

#search-results-count {
    font-size: 14px;
    color: #555;
}

.search-navigation {
    display: flex;
    align-items: center;
    gap: 8px;
}

#current-match-position {
    font-size: 14px;
    color: #555;
    min-width: 40px;
    text-align: center;
}

.btn-sm {
    padding: 4px 8px;
    font-size: 12px;
}

/* 搜索结果高亮样式 */
.cm-search-match {
    background-color: rgba(255, 255, 0, 0.3);
    outline: 1px solid #ccc;
}

.cm-search-match-current {
    background-color: rgba(255, 165, 0, 0.5);
    outline: 1px solid #f90;
}

/* 【新增】用于临时高亮新替换文本的样式 */
.cm-replaced-text {
    background-color: rgba(255, 255, 173, 0.5); /*  半透明的亮蓝色 */
  
}


.modal-footer {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    margin-top: 20px;
}

/* 模板编辑模态框样式 */
.style-editor {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 15px;
    margin-top: 15px;
}

.template-preview {
    margin-top: 10px;
    padding: 15px;
    border: 1px solid #e0e0e0;
    border-radius: 4px;
    min-height: 100px;
    background-color: #f9f9f9;
}

.color-picker {
    height: 40px;
    padding: 5px;
    border: 1px solid #ccc;
    border-radius: 4px;
}

/* 主题选择器样式 */
#theme-selector {
    padding: 8px 12px;
    border-radius: 4px;
    border: 1px solid #ccc;
    background-color: #fff;
    font-size: 14px;
    cursor: pointer;
}

/* 通知提示样式 */
.notification {
    position: fixed;
    bottom: 20px;
    left: 20px;
    padding: 15px 20px;
    background-color: #43a047;
    color: white;
    border-radius: 4px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
    transform: translateY(100px);
    opacity: 0;
    transition: transform 0.3s, opacity 0.3s;
    z-index: 1000;
}

.notification.show {
    transform: translateY(0);
    opacity: 1;
}

/* 本地历史模态框样式 */
.history-list-container {
    max-height: 400px;
    overflow-y: auto;
    margin: 15px 0;
    border: 1px solid #e0e0e0;
    border-radius: 4px;
}

#history-list {
    padding: 0;
}

.history-item {
    padding: 15px;
    border-bottom: 1px solid #e0e0e0;
    cursor: pointer;
    transition: background-color 0.2s;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.history-item:last-child {
    border-bottom: none;
}

.history-item:hover {
    background-color: #f5f5f5;
}

.history-item.active {
    background-color: #e3f2fd;
}

.history-item-time {
    font-weight: 500;
    margin-bottom: 5px;
}

.history-item-preview {
    font-size: 13px;
    color: #757575;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 300px;
}

.history-item-actions {
    display: flex;
    gap: 5px;
}

/* 微信公众号样式模拟 */
.wx-content {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    font-size: 16px;
    line-height: 1.6;
    color: #333;
    padding: 20px;
    max-width: 100%;
    word-wrap: break-word;
    background-color: rgb(255, 255, 255);
}

.wx-content img {
    max-width: 100%;
    height: auto;
    display: block;
    margin: 10px auto;
}

.wx-content h1, .wx-content h2, .wx-content h3, .wx-content h4, .wx-content h5, .wx-content h6 {
    margin-top: 20px;
    margin-bottom: 10px;
    line-height: 1.4;
    font-weight: bold;
}

.wx-content p {
    margin-bottom: 16px;
    text-indent: 0;
    margin-left: 0;
    padding-left: 0;
}

.wx-content blockquote {
    padding: 10px 15px;
    margin: 0 0 20px;
    border-left: 4px solid #ddd;
    background-color: rgba(249, 249, 249, 0.5);
}

/* 隐藏的富文本复制区域 */
#rich-text-copy-area {
    position: absolute;
    left: -9999px;
    top: 0;
    width: 1px;
    height: 1px;
    overflow: hidden;
    background-color: rgb(255, 255, 255);
    color: #333;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    font-size: 16px; /* 添加默认字体大小 */
}

/* 确保富文本复制区域中的段落不缩进，但保留其他样式 */
#rich-text-copy-area p {
    /* 移除 !important 以允许保留用户设置的样式 */
    text-indent: 0;
    margin-left: 0;
    padding-left: 0;
}

/* 确保富文本复制区域中的横线元素正确显示 */
#rich-text-copy-area hr, 
#rich-text-copy-area .wx-hr {
    display: block !important;
    height: 1px !important;
    width: 100% !important;
    margin: 20px 0 !important;
    background-color: #e0e0e0 !important;
    border-top: 1px solid #e0e0e0 !important;
    border-bottom: none !important;
    border-left: none !important;
    border-right: none !important;
    clear: both !important;
}

/* 备用横线样式（使用div模拟） */
#rich-text-copy-area .wx-hr-div {
    display: block !important;
    height: 1px !important;
    width: 100% !important;
    margin: 20px 0 !important;
    background-color: #e0e0e0 !important;
    clear: both !important;
}

/* 确保富文本复制区域中的删除线正确显示 */
#rich-text-copy-area s,
#rich-text-copy-area del,
#rich-text-copy-area strike,
#rich-text-copy-area .wx-del {
    text-decoration: line-through !important;
    text-decoration-line: line-through !important;
}

/* 确保富文本复制区域中的下划线正确显示 */
#rich-text-copy-area u,
#rich-text-copy-area ins,
#rich-text-copy-area .wx-underline {
    text-decoration: underline !important;
    text-decoration-line: underline !important;
}

/* 确保富文本复制区域中的表格正确显示 */
#rich-text-copy-area table,
#rich-text-copy-area .wx-table {
    border-collapse: collapse !important;
    width: 100% !important;
    margin: 10px 0 !important;
}

#rich-text-copy-area table th,
#rich-text-copy-area table td {
    border: 1px solid #ddd !important;
    padding: 8px !important;
    text-align: left !important;
}

/* 确保富文本复制区域中的列表正确显示 */
#rich-text-copy-area ul,
#rich-text-copy-area ol,
#rich-text-copy-area .wx-list {
    padding-left: 20px !important;
    margin: 10px 0 !important;
}

#rich-text-copy-area li {
    margin: 5px 0 !important;
}

/* 确保富文本复制区域中的图片正确显示 */
#rich-text-copy-area img,
#rich-text-copy-area .wx-image {
    max-width: 100% !important;
    border: none !important;
}

/* 响应式设计 */

/* ======================================
 * 移动端视图切换器样式
 * ====================================== */

/* 默认在桌面端隐藏切换器 */
.mobile-view-switcher {
    display: none;
    margin-bottom: 10px;
    border-radius: 6px;
    overflow: hidden;
    border: 1px solid #ccc;
}

.mobile-view-switcher .btn {
    flex: 1; /* 让两个按钮平分宽度 */
    border: none;
    border-radius: 0;
    margin: 0;
    padding: 10px;
    background-color: #f0f0f0;
    color: #333;
    transition: background-color 0.2s;
}

.mobile-view-switcher .btn.active {
    background-color: #007bff;
    color: white;
}

/* 【从这里开始是您已有的响应式设计代码，无需改动】 */
/* 响应式设计 */
@media (max-width: 768px) {
    /* ... */
}

/* 【需要完整替换的媒体查询块】 */
@media (max-width: 768px) {
    .toolbar {
        flex-wrap: wrap;
        padding: 5px;
    }

    .btn-group {
        margin: 5px;
    }
    
    .main-container {
        /* 在移动端，容器始终是 flex 布局，但方向变为垂直 */
        display: flex;
        flex-direction: column;
    }

    /* 【核心修改】显示移动端切换器 */
    .mobile-view-switcher {
        display: flex;
    }

    /* 【核心修改】移除旧的上下布局代码 */
    .editor-container, .preview-container {
        width: 100%;
        margin-left: 0;
        /* 让当前视图占满剩余空间 */
        flex: 1; 
        min-height: 0; /* flex 布局中非常重要，防止内容溢出 */
    }

    /* 【核心修改】根据父容器的类来显示或隐藏编辑/预览区 */
    .main-container.view-editor .preview-container {
        display: none;
    }

    .main-container.view-editor .editor-container {
        display: flex; /* 保持 flex 结构以正确显示内部 panel */
        flex-direction: column;
    }

    .main-container.view-preview .editor-container {
        display: none;
    }

    .main-container.view-preview .preview-container {
        display: flex; /* 保持 flex 结构以正确显示内部 panel */
        flex-direction: column;
    }

    .panel-content {
        height: auto;
        flex: 1;
        min-height: 0;
    }
    
    #preview-frame {
        height: 100%;
    }
}



/* 样式调校器侧边栏样式 */
.style-tuner-sidebar {
    position: fixed;
    top: 0;
    right: -350px; /* 默认隐藏在右侧 */
    width: 320px;
    height: 100vh;
    background-color: #f9f9f9;
    box-shadow: -2px 0 8px rgba(0,0,0,0.1);
    z-index: 1001;
    display: flex;
    flex-direction: column;
    transition: right 0.3s ease-in-out;
}

.style-tuner-sidebar.show {
    right: 0; /* 显示侧边栏 */
}

.tuner-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 15px;
    background-color: #eee;
    border-bottom: 1px solid #ddd;
}

.tuner-header h3 {
    margin: 0;
    font-size: 1rem;
}

.tuner-body {
    flex: 1;
    padding: 15px;
    overflow-y: auto;
}

.tuner-footer {
    display: flex;
    justify-content: space-between;
    padding: 10px 15px;
    border-top: 1px solid #ddd;
    background-color: #f5f5f5;
}

.preset-group {
    display: flex;
    gap: 5px;
}

.preset-group .form-control {
    flex: 1;
}

.tuned-element-info {
    font-family: 'Courier New', Courier, monospace;
    background-color: #fff;
    padding: 5px 8px;
    border-radius: 4px;
    border: 1px solid #ddd;
    font-size: 13px;
    color: #d63384;
}

#style-property-list .form-group {
    display: flex;
    align-items: center;
    gap: 5px;
    margin-bottom: 8px;
}

#style-property-list .prop-name {
    width: 100px;
    flex-shrink: 0;
    font-size: 13px;
}

#style-property-list .prop-value {
    flex-grow: 1;
    font-size: 13px;
}

#style-property-list .remove-prop-btn {
    padding: 2px 6px;
    font-size: 14px;
    line-height: 1;
    background: #f8d7da;
    color: #842029;
    border: 1px solid #f5c2c7;
    border-radius: 50%;
    cursor: pointer;
}

/* 预览区元素高亮效果 */
.element-highlight-preview {
    outline: 2px dashed #1e88e5 !important;
    box-shadow: 0 0 10px rgba(30, 136, 229, 0.5) !important;
    cursor: pointer !important;
    transition: outline 0.1s linear;
}