/**
 * Web 笔记应用样式表
 * 
 * 包含：
 * - 基础重置和全局布局
 * - 工具栏样式
 * - 编辑器和预览区样式
 * - Markdown 内容样式优化
 */

/* ==================== 基础重置 ==================== */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html, body {
    height: 100%;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    font-size: 16px;
    line-height: 1.6;
    background-color: #f5f5f5;
    overflow: hidden;
}

/* ==================== 工具栏样式 ==================== */
.toolbar {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 20px;
    background-color: #e8f4fc;
    border-bottom: 1px solid #c5dff0;
    box-shadow: 0 2px 8px rgba(100, 160, 200, 0.15);
}

.toolbar-spacer {
    flex: 1;
}

.btn {
    padding: 8px 18px;
    font-size: 13px;
    font-weight: 500;
    color: #fff;
    background-color: #64a0c8;
    border: 1px solid #5090b8;
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.25s ease;
}

.btn:hover {
    background-color: #5090b8;
    border-color: #4080a8;
    transform: translateY(-1px);
    box-shadow: 0 4px 8px rgba(80, 144, 184, 0.3);
}

.btn:active {
    background-color: #4080a8;
    transform: translateY(0);
    box-shadow: none;
}

/* 清除按钮 - 红色调 */
#clearBtn {
    background-color: #e57373;
    border-color: #d56060;
}

#clearBtn:hover {
    background-color: #d56060;
    border-color: #c54545;
}

/* 预览按钮 - 蓝色调 */
#previewBtn {
    background-color: #5c9fd4;
    border-color: #4a8fc4;
}

#previewBtn:hover {
    background-color: #4a8fc4;
    border-color: #3a7fb4;
}

/* 输入按钮 - 绿色调 */
#inputBtn {
    background-color: #66bb6a;
    border-color: #55a55a;
}

#inputBtn:hover {
    background-color: #55a55a;
    border-color: #45954a;
}

/* 导出按钮 - 橙色调 */
#exportBtn {
    background-color: #ffa726;
    border-color: #fb8c00;
}

#exportBtn:hover {
    background-color: #fb8c00;
    border-color: #f57c00;
}

/* ==================== 主体容器布局 ==================== */
.container {
    display: flex;
    height: calc(100% - 57px - 36px); /* 减去工具栏和状态栏高度 */
}

/* ==================== 底部状态栏样式 ==================== */
.statusbar {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    padding: 8px 20px;
    height: 36px;
    font-size: 12px;
    font-weight: 500;
    color: #5a8aaa;
    background-color: #e8f4fc;
    border-top: 1px solid #c5dff0;
    box-shadow: 0 -2px 6px rgba(100, 160, 200, 0.1);
}

.statusbar #wordCount {
    padding: 4px 12px;
    background-color: rgba(90, 138, 170, 0.15);
    border-radius: 12px;
    letter-spacing: 0.5px;
}

/* ==================== 编辑器区域样式 ==================== */
.editor {
    flex: 1;
    display: flex;
    transition: flex 0.3s ease;
}

.editor textarea {
    width: 100%;
    height: 100%;
    padding: 20px;
    font-family: 'Monaco', 'Menlo', 'Ubuntu Mono', 'Consolas', monospace;
    font-size: 14px;
    line-height: 1.6;
    color: #333;
    background-color: #ffffff;
    border: none;
    outline: none;
    resize: none;
    tab-size: 4;
}

.editor textarea::placeholder {
    color: #999;
}

/* ==================== 预览区域样式 ==================== */
.preview {
    flex: 0;
    width: 0;
    padding: 0;
    overflow-y: auto;
    overflow-x: hidden;
    background-color: #ffffff;
    border-left: none;
    transition: all 0.3s ease;
}

/* ==================== 预览模式样式 ==================== */
.container.preview-mode .editor {
    flex: 1;
    border-right: 1px solid #e0e0e0;
}

.container.preview-mode .preview {
    flex: 1;
    width: auto;
    padding: 20px;
    border-left: 1px solid #e0e0e0;
}

/* ==================== 隐藏输入模式样式 ==================== */
.container.input-hidden .editor {
    flex: 0;
    width: 0;
    overflow: hidden;
}

.container.input-hidden .editor textarea {
    padding: 0;
}

.container.input-hidden.preview-mode .preview {
    flex: 1;
    border-left: none;
}

/* ==================== Markdown 内容样式 ==================== */
.preview h1,
.preview h2,
.preview h3,
.preview h4,
.preview h5,
.preview h6 {
    margin-top: 24px;
    margin-bottom: 16px;
    font-weight: 600;
    line-height: 1.25;
}

.preview h1 {
    font-size: 2em;
    padding-bottom: 0.3em;
    border-bottom: 1px solid #eaecef;
}

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

.preview h3 {
    font-size: 1.25em;
}

.preview h4 {
    font-size: 1em;
}

.preview h5 {
    font-size: 0.875em;
}

.preview h6 {
    font-size: 0.85em;
    color: #6a737d;
}

.preview p {
    margin-bottom: 16px;
}

.preview a {
    color: #0366d6;
    text-decoration: none;
}

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

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

.preview li {
    margin-bottom: 4px;
}

/* 任务列表样式 */
.preview li.task-list-item {
    list-style: none;
    margin-left: -1.5em;
}

.preview .task-checkbox {
    margin-right: 8px;
    vertical-align: middle;
    width: 16px;
    height: 16px;
    cursor: default;
}

.preview blockquote {
    margin: 0 0 16px 0;
    padding: 0 1em;
    color: #6a737d;
    border-left: 4px solid #dfe2e5;
}

.preview code {
    padding: 0.2em 0.4em;
    font-family: 'Monaco', 'Menlo', 'Ubuntu Mono', 'Consolas', monospace;
    font-size: 85%;
    background-color: rgba(27, 31, 35, 0.05);
    border-radius: 3px;
}

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

.preview pre code {
    padding: 0;
    background-color: transparent;
    border-radius: 0;
}

.preview table {
    margin-bottom: 16px;
    border-collapse: collapse;
    width: 100%;
}

.preview table th,
.preview table td {
    padding: 6px 13px;
    border: 1px solid #dfe2e5;
}

.preview table th {
    font-weight: 600;
    background-color: #f6f8fa;
}

.preview table tr:nth-child(2n) {
    background-color: #f6f8fa;
}

.preview hr {
    height: 4px;
    margin: 24px 0;
    padding: 0;
    background-color: #e1e4e8;
    border: 0;
}

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

/* ==================== Mermaid 图表样式 ==================== */
.preview .mermaid {
    margin: 16px 0;
    padding: 16px;
    background-color: #f8f9fa;
    border-radius: 6px;
    text-align: center;
    overflow-x: auto;
}

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

.preview .mermaid-error {
    margin: 16px 0;
    padding: 12px 16px;
    color: #d32f2f;
    background-color: #ffebee;
    border: 1px solid #ffcdd2;
    border-radius: 6px;
    font-size: 13px;
}
