/* -----------------------------
   1. 基础样式
----------------------------- */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    --primary-color: #338AFF;
    --primary-hover: rgba(21, 65, 255, 0.5);
    --secondary-color: #f1f1f1;
    --secondary-hover: #e0e0e0;
    --text-color: #333;
    --light-text: #666;
    --lighter-text: #999;
    --bg-color: #f5f5f5;
    --border-color: #ddd;
    --hover-bg: #f0f0f0;
    --header-bg: #fff;
    --warning-color: #ff9800;
    --error-color: #f44336;
    --shadow: 0 1px 3px rgba(0,0,0,0.1);
    --radius: 4px;
}

body {
    font-family: 'Microsoft YaHei', 'PingFang SC', 'Hiragino Sans GB', sans-serif;
    line-height: 1.6;
    color: var(--text-color);
    background-color: var(--bg-color);
}

.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 2px 15px;
}

.title-container {
    /* 启用弹性布局，使图标和标题横向排列 */
    display: flex;
    align-items: center; /* 垂直居中对齐 */
    gap: 12px; /* 图标和标题之间的间距 */
    transition: color 1s; /* 平滑过渡效果，可选 */
}

.title-container:hover h1 {
    color: #338AFF; /* 半透明蓝色 */
}

.title-icon {
  width: 32px;
  height: 32px;
  transition: filter 0.3s; /* 平滑过渡 */
}

.title-icon:hover {
  filter: brightness(0.8) saturate(1.2); /* 降低亮度，增加饱和度 */
  /* 或使用半透明叠加（仅适用于支持混合模式的浏览器） */
  /* filter: sepia(1) hue-rotate(190deg) saturate(5) opacity(0.7); */
}

/*div[id^="dmermaid-"] {*/
/*  display: none !important;*/
/*}*/

/* -----------------------------
   2. 排版
----------------------------- */
h1, h2, h3, h4 {
    color: var(--text-color);
    margin-bottom: 0.5em;
}

h1 {
    font-size: 22px;
    text-align: left;
}

h2 {
    font-size: 22px;
    border-bottom: 1px solid #eee;
    padding-bottom: 10px;
}

h3 {
    font-size: 18px;
}

h4 {
    font-size: 16px;
}

.subtitle {
    font-size: 16px;
    color: var(--light-text);
    font-weight: normal;
    margin: 0;
}

p {
    margin-bottom: 1em;
}

a {
    color: var(--primary-color);
    text-decoration: none;
}

a:hover {
    text-decoration: underline;
}

/* -----------------------------
   3. 布局组件
----------------------------- */
/* 3.1 Header 区域 */
.header-content {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 10px;
    background-color: var(--header-bg);
    padding: 5px 15px;
    border-radius: var(--radius);
    box-shadow: var(--shadow);
}

.header-content .title-container {
    display: flex;
    flex-direction: row;
    align-items: center;
}

.header-content h1 {
    margin-bottom: 0;
    margin-right: 15px;
    color: #2c3e50;
}

.main-nav {
    display: flex;
    align-items: center;
    height: 100%;
}

.main-nav ul {
    display: flex;
    list-style: none;
}

.main-nav li {
    margin-left: 20px;
}

.main-nav a {
    text-decoration: none;
    color: var(--text-color);
    font-weight: 500;
    padding: 5px 10px;
    border-radius: var(--radius);
}

.main-nav li.active a,
.main-nav a:hover {
    background-color: var(--primary-color);
    color: white;
    text-decoration: none;
}

.back-button-container {
    margin-bottom: 15px;
}

.back-button {
    display: inline-block;
    color: var(--primary-color);
    font-weight: 500;
}

/* 3.2 页面容器 */
.page {
    display: none;
    background-color: white;
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 8px 20px;
    margin-bottom: 20px;
}

.page.active {
    display: block;
}

/* 页面顶部布局 */
.page-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid #eee;
    padding-bottom: 10px;
    flex-wrap: nowrap;
}

.page-header h2 {
    margin-bottom: 0;
    margin-right: 20px;
    white-space: nowrap;
    border-bottom: none;
    padding-bottom: 0;
    flex-shrink: 0;
}

.header-controls {
    display: flex;
    align-items: center;
    flex-wrap: nowrap;
    gap: 20px;
    justify-content: flex-end;
    min-width: 0;
    flex: 1;
    overflow: hidden;
}

/* 3.3 Footer */
footer {
    text-align: center;
    margin-top: 40px;
    padding: 20px 0;
    color: var(--light-text);
    font-size: 14px;
}

/* -----------------------------
   4. 进度指示器
----------------------------- */
.progress-container {
    display: flex;
    justify-content: space-between;
    margin: 30px 0;
    position: relative;
}

.progress-container::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 0;
    right: 0;
    height: 2px;
    background-color: var(--border-color);
    z-index: 1;
}

.progress-step {
    position: relative;
    z-index: 2;
    background-color: var(--bg-color);
    padding: 5px 10px;
    border-radius: 20px;
    font-size: 14px;
    color: var(--lighter-text);
    cursor: default;
}

.progress-step.active {
    background-color: var(--primary-color);
    color: white;
}

.progress-step.completed {
    background-color: var(--error-color);
    color: white;
}

/* 水平进度条 */
.progress-bar-container {
    width: 120px;
    margin: 0 5px;
}

.progress-bar {
    width: 100%;
    height: 10px;
    background-color: var(--secondary-color);
    border-radius: 5px;
    margin: 10px 0;
    position: relative;
    overflow: hidden;
}

.progress-fill {
    height: 100%;
    background-color: var(--primary-color);
    border-radius: 5px;
    width: 0%;
    transition: width 0.3s ease;
}

.progress-text {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    font-weight: bold;
    text-shadow: 0 0 2px rgba(0, 0, 0, 0.5);
}

.progress-stats {
    display: flex;
    align-items: center;
    gap: 15px;
    font-size: 14px;
    color: var(--light-text);
    white-space: nowrap;
}

.progress-stats span {
    white-space: nowrap;
}

/* -----------------------------
   5. 表单元素
----------------------------- */
/* 5.1 按钮 */
.btn-primary, .btn-secondary, .btn-small {
    padding: 10px 20px;
    border: none;
    border-radius: var(--radius);
    cursor: pointer;
    font-size: 16px;
    transition: background-color 0.3s;
}

.btn-primary {
    background-color: var(--primary-color);
    color: white;
}

.btn-primary:hover {
    background-color: var(--primary-hover);
}

.btn-secondary {
    background-color: var(--secondary-color);
    color: var(--text-color);
}

.btn-secondary:hover {
    background-color: var(--secondary-hover);
}

.btn-small {
    padding: 5px 10px;
    font-size: 14px;
}

button:disabled {
    background-color: #cccccc;
    cursor: not-allowed;
}

.action-buttons {
    display: flex;
    justify-content: space-between;
    margin-top: 20px;
}

/* 5.2 表单容器 */
.form-group {
    margin-bottom: 15px;
}

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

.form-group input,
.form-group select,
.form-group textarea {
    width: 100%;
    padding: 8px;
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
}

/* 5.3 输入框和选择框 */
select {
    padding: 8px;
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    background-color: white;
}

textarea {
    width: 100%;
    padding: 10px;
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    resize: vertical;
    font-family: inherit;
    font-size: 14px;
}

/* 5.4 复选框和单选框 */
.checkbox-container, .radio-container {
    display: flex;
    align-items: center;
    position: relative;
    padding-left: 30px;
    margin-bottom: 12px;
    cursor: pointer;
    font-size: 16px;
}

.radio-container {
    font-size: 14px;
    padding-left: 25px;
    margin-bottom: 0;
}

.checkbox-container input, .radio-container input {
    position: absolute;
    opacity: 0;
    cursor: pointer;
    height: 0;
    width: 0;
}

.checkmark, .radio-mark {
    position: absolute;
    left: 0;
    height: 20px;
    width: 20px;
    background-color: #eee;
}

.checkmark {
    border-radius: var(--radius);
}

.radio-mark {
    border-radius: 50%;
}

.checkbox-container:hover input ~ .checkmark,
.radio-container:hover input ~ .radio-mark {
    background-color: #ccc;
}

.checkbox-container input:checked ~ .checkmark,
.radio-container input:checked ~ .radio-mark {
    background-color: var(--primary-color);
}

.checkmark:after, .radio-mark:after {
    content: "";
    position: absolute;
    display: none;
}

.checkbox-container input:checked ~ .checkmark:after,
.radio-container input:checked ~ .radio-mark:after {
    display: block;
}

.checkbox-container .checkmark:after {
    left: 7px;
    top: 3px;
    width: 5px;
    height: 10px;
    border: solid white;
    border-width: 0 2px 2px 0;
    transform: rotate(45deg);
}

.radio-container .radio-mark:after {
    top: 6px;
    left: 6px;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: white;
}

/* -----------------------------
   6. 页面特定组件
----------------------------- */
/* 6.1 文件上传区域 */
.upload-area {
    margin: 20px 0;
}

.upload-box {
    border: 2px dashed var(--border-color);
    border-radius: var(--radius);
    padding: 40px;
    text-align: center;
    cursor: pointer;
    transition: border-color 0.3s;
}

.upload-box:hover {
    border-color: var(--primary-color);
}

.upload-box p {
    margin-bottom: 10px;
}

.upload-box .small {
    font-size: 14px;
    color: var(--lighter-text);
}

.file-status {
    margin: 20px 0;
    padding: 10px;
    background-color: #f9f9f9;
    border-radius: var(--radius);
}

/* 6.2 规格输入区域 */
.specs-container {
    display: flex;
    flex-wrap: wrap;
    gap: 20px;
    margin-bottom: 20px;
}

.specs-box {
    flex: 1;
    min-width: 300px;
}

/* 6.3 配置区域 */
.config-area {
    display: flex;
    flex-wrap: wrap;
    gap: 20px;
    margin-bottom: 20px;
    background-color: #f9f9f9;
    border-radius: var(--radius);
}

.config-item {
    display: flex;
    align-items: center;
    margin-right: 20px;
}

.config-item label {
    margin-right: 10px;
}

/* 6.4 大纲预览 */
.outline-preview {
    margin: 20px 0;
}

.outline-content {
    max-height: 400px;
    overflow-y: auto;
    padding: 15px;
    background-color: #f9f9f9;
    border-radius: var(--radius);
    font-family: monospace;
    white-space: pre-wrap;
}

/* 6.5 文档生成页面 */
.document-container {
    display: flex;
    gap: 20px;
    margin: 20px 0;
}

.section-list {
    flex: 1;
    min-width: 250px;
    max-width: 300px;
    padding: 15px;
    background-color: #f9f9f9;
    border-radius: var(--radius);
}

.section-tree {
    max-height: 490px;
    overflow-y: auto;
    margin-bottom: 20px;
}

.content-preview {
    flex: 3;
    padding: 15px;
    background-color: #f9f9f9;
    border-radius: var(--radius);
}

.view-mode-selector {
    display: flex;
    gap: 15px;
    font-size: 14px;
    padding-top: 0;
    white-space: nowrap;
}

.view-container {
    background-color: white;
    border-radius: var(--radius);
    padding: 15px;
    margin-bottom: 15px;
    border: 1px solid #eee;
    max-height: 500px;
    overflow-y: auto;
}

/* 6.6 章节样式 */
.section-item {
    position: relative;
    padding: 5px 0;
    border-bottom: 1px solid #eee;
    cursor: pointer;
}

.section-item:hover {
    background-color: var(--bg-color);
}

.section-item.active {
    color: var(--primary-color);
    font-weight: bold;
}

.section-item.completed {
    background-color: #f0fff0;
}

.section-item.completed:before {
    content: "✓ ";
    color: var(--primary-color);
}

.section-item.generating:before {
    content: "⟳ ";
    color: var(--warning-color);
}

.section-item.failed {
    background-color: #fff0f0;
}

.status-icon {
    position: absolute;
    right: 10px;
    top: 50%;
    transform: translateY(-50%);
    font-weight: bold;
}

.status-icon.completed {
    color: green;
}

.status-icon.failed {
    color: red;
}

.section-info {
    margin-bottom: 15px;
}

#current-section-title {
    font-size: 18px;
    padding-bottom: 10px;
    margin-bottom: 15px;
    color: var(--primary-color);
}

.section-guide {
    background-color: #f5f5f5;
    border-left: 4px solid var(--primary-color);
    padding: 12px;
    margin-bottom: 20px;
    border-radius: 2px;
}

.section-content {
    margin-bottom: 20px;
}

.section-guide h4, .section-content h4 {
    margin-top: 0;
    margin-bottom: 10px;
    font-size: 16px;
    color: #555;
}

/* 6.7 最终文档预览 */
.final-document {
    margin: 20px 0;
}

.final-preview {
    max-height: 500px;
    overflow-y: auto;
    padding: 20px;
    background-color: white;
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    margin-bottom: 20px;
}

.document-info {
    padding: 15px;
    background-color: #f9f9f9;
    border-radius: var(--radius);
}

/* 6.8 项目列表样式 */
.projects-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
}

.projects-list table {
    width: 100%;
    border-collapse: collapse;
    margin-bottom: 20px;
}

.projects-list th,
.projects-list td {
    padding: 12px 15px;
    text-align: left;
    border-bottom: 1px solid var(--border-color);
}

.projects-list th {
    background-color: #f2f2f2;
    font-weight: bold;
}

.projects-list tr:hover {
    background-color: var(--bg-color);
}

.project-actions {
    display: flex;
    gap: 10px;
}

.project-actions button {
    padding: 5px 10px;
    border: none;
    border-radius: var(--radius);
    cursor: pointer;
}

.btn-view {
    background-color: var(--primary-color);
    color: white;
}

.btn-delete {
    background-color: var(--error-color);
    color: white;
}

/* 6.9 设置中心样式 */
.settings-container {
    display: flex;
    gap: 30px;
    margin-top: 20px;
}

.settings-sidebar {
    width: 200px;
    background-color: #f2f2f2;
    border-radius: var(--radius);
    padding: 15px;
}

.settings-menu {
    list-style: none;
}

.settings-menu li {
    padding: 10px;
    cursor: pointer;
    border-radius: var(--radius);
    margin-bottom: 5px;
}

.settings-menu li:hover {
    background-color: #e0e0e0;
}

.settings-menu li.active {
    background-color: var(--primary-color);
    color: white;
}

.settings-content {
    flex: 1;
    background-color: white;
    border-radius: var(--radius);
    padding: 20px;
    box-shadow: var(--shadow);
}

.settings-tab {
    display: none;
}

.settings-tab.active {
    display: block;
}

.template-item {
    background-color: var(--bg-color);
    border-radius: var(--radius);
    padding: 15px;
    margin-bottom: 15px;
}

.template-actions {
    margin-top: 20px;
    display: flex;
    gap: 10px;
}

/* 6.10 模拟数据样式 */
.mock-data-container {
    margin-bottom: 15px;
    text-align: center;
}

.mock-data-container button {
    display: flex;
    align-items: center;
    margin: 0 auto;
    padding: 8px 16px;
    background-color: #5c6bc0;
    color: white;
    border: none;
    border-radius: var(--radius);
    cursor: pointer;
    transition: background-color 0.3s;
}

.mock-data-container button:hover {
    background-color: #3f51b5;
}

.mock-data-container button i {
    margin-right: 8px;
}

.mock-badge {
    display: inline-block;
    background-color: var(--warning-color);
    color: white;
    font-size: 12px;
    padding: 2px 8px;
    border-radius: var(--radius);
    margin-left: 10px;
    vertical-align: middle;
}

.mock-project {
    position: relative;
}

.mock-project::before {
    content: '';
    position: absolute;
    left: 0;
    top: 0;
    height: 100%;
    width: 4px;
    background-color: var(--warning-color);
}

/* -----------------------------
   7. 特殊组件
----------------------------- */
/* 7.1 Markdown样式 */
.markdown-body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Helvetica, Arial, sans-serif;
    font-size: 16px;
    line-height: 1.6;
    word-wrap: break-word;
}

.markdown-body h1 {
    font-size: 2em;
    border-bottom: 1px solid #eaecef;
    padding-bottom: 0.3em;
    text-align: left;
}

.markdown-body h2 {
    font-size: 1.5em;
    border-bottom: 1px solid #eaecef;
    padding-bottom: 0.3em;
}

.markdown-body h3 {
    font-size: 1.25em;
}

.markdown-body h4 {
    font-size: 1em;
}

.markdown-body p {
    margin-bottom: 16px;
}

.markdown-body ul, .markdown-body ol {
    padding-left: 2em;
    margin-bottom: 16px;
}

.markdown-body pre {
    padding: 16px;
    overflow: auto;
    font-size: 85%;
    line-height: 1.45;
    background-color: #f6f8fa;
    border-radius: 3px;
    margin-bottom: 16px;
}

.markdown-body code {
    padding: 0.2em 0.4em;
    margin: 0;
    font-size: 85%;
    background-color: rgba(27, 31, 35, 0.05);
    border-radius: 3px;
}

.markdown-body pre code {
    padding: 0;
    background-color: transparent;
}

.markdown-body table {
    width: 100%;
    border-collapse: collapse;
    margin: 20px 0;
}

.markdown-body table th,
.markdown-body table td {
    padding: 8px 12px;
    border: 1px solid var(--border-color);
    text-align: left;
}

.markdown-body table th {
    background-color: #f5f5f5;
    font-weight: bold;
}

.markdown-body table tr:nth-child(even) {
    background-color: #f9f9f9;
}

.markdown-body table tr:hover {
    background-color: var(--hover-bg);
}

#full-content-markdown {
    max-height: 450px;
    overflow-y: auto;
    border: 1px solid var(--border-color);
    padding: 15px;
    margin-top: 10px;
    background-color: #f9f9f9;
}

#content-markdown {
    min-height: 200px;
}

/* 7.2 Mermaid图表样式 */
.mermaid {
    display: flex;
    justify-content: center;
    margin: 20px 0;
    padding: 15px;
    background-color: #f9f9f9;
    border-radius: 6px;
    border: 1px solid #e0e0e0;
    overflow-x: auto;
}

.mermaid-placeholder {
    display: flex;
    justify-content: center;
    align-items: center;
    height: 150px;
    margin: 20px 0;
    background-color: #f5f5f5;
    border-radius: 6px;
    border: 1px dashed #ccc;
    color: #777;
    font-style: italic;
    position: relative;
}

.mermaid-placeholder::before {
    content: '';
    position: absolute;
    width: 30px;
    height: 30px;
    border: 3px solid var(--primary-color);
    border-top-color: transparent;
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin-right: 10px;
}

.mermaid svg {
    max-width: 100%;
    height: auto !important;
}

/* 7.3 消息和加载样式 */
.loading-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: rgba(0, 0, 0, 0.5);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 1000;
}

.loading-content {
    background-color: white;
    padding: 30px;
    border-radius: var(--radius);
    text-align: center;
    max-width: 80%;
}

.message-box {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background-color: white;
    padding: 20px;
    border-radius: var(--radius);
    box-shadow: 0 0 10px rgba(0, 0, 0, 0.2);
    z-index: 1000;
    text-align: center;
}

.message {
    position: fixed;
    top: 20px;
    right: 20px;
    padding: 15px 20px;
    border-radius: var(--radius);
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.2);
    transform: translateX(100%);
    opacity: 0;
    transition: all 0.3s ease;
    z-index: 1000;
    max-width: 500px;
    min-width: 300px;
    color: white;
    font-size: 14px;
    line-height: 1.5;
    word-break: break-word;
    overflow-wrap: break-word;
}

.message.show {
    transform: translateX(0);
    opacity: 1;
}

.message.error {
    background-color: var(--error-color);
}

.message.success {
    background-color: var(--primary-color);
}

.message svg {
    flex-shrink: 0;
    width: 18px;
    height: 18px;
}

.export-actions {
    margin-top: 15px;
    display: flex;
    justify-content: center;
    gap: 10px;
}

/* -----------------------------
   8. 辅助类
----------------------------- */
.hidden {
    display: none;
}

/* -----------------------------
   9. 动画
----------------------------- */
@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}
/* 隐藏Mermaid自动生成的错误信息 */
[id^="dmermaid-"] {
    /*display: none !important;*/
}