/* 定义CSS变量 */
:root {
    --primary-color: #4e73df;
    --secondary-color: #858796;
    --success-color: #1cc88a;
    --light-bg: #f8f9fc;
    --dark-bg: #2e59d9;
    --text-color: #333;
    --border-color: #e3e6f0;
    --sidebar-bg: white;
    --editor-bg: white;
    --navbar-bg: white;
}

/* 暗色主题变量 */
[data-theme="dark"] {
    --light-bg: #1a1a1a;
    --text-color: #fff;
    --border-color: #444;
    --sidebar-bg: #2d2d2d;
    --editor-bg: #2d2d2d;
    --navbar-bg: #2d2d2d;
}

/* 全局样式 */
body {
    font-family: 'Nunito', 'Segoe UI', 'Microsoft YaHei', sans-serif;
    background-color: var(--light-bg);
    color: var(--text-color);
    height: 100vh;
    overflow: hidden;
    transition: background-color 0.3s ease, color 0.3s ease;
}

/* 顶部导航栏 (白色背景,底部阴影)*/
.top-navbar {
    background-color: var(--navbar-bg);
    box-shadow: 0 0.15rem 1.75rem 0 rgba(58, 59, 69, 0.15);
    height: 60px;
    transition: background-color 0.3s ease;
}

/* 主容器布局 (flex布局 + 视口高度减去导航栏高度) */
.main-container {
    display: flex;
    height: calc(100vh - 60px);
}

/* 左侧列表 (子元素垂直排列,右侧分割线浅灰色)*/
.notes-sidebar {
    width: 300px;
    background-color: var(--sidebar-bg);
    border-right: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    transition: background-color 0.3s ease, border-color 0.3s ease;
}

/* 编辑容器 (剩余空间白色flex布局,元素垂直排列) */
.editor-container {
    flex-grow: 1;
    display: flex;
    flex-direction: column;
    background-color: var(--editor-bg);
    transition: background-color 0.3s ease;
}

/* 侧边栏头部样式 (底部边框与列表区分隔) */
.sidebar-header {
    padding: 15px;
    border-bottom: 1px solid var(--border-color);
    transition: border-color 0.3s ease;
}

/* 笔记列表区域 */
.notes-list {
    overflow-y: auto;
    flex-grow: 1;
}

/* 笔记项样式 */
.note-item {
    border-bottom: 1px solid var(--border-color);
    padding: 15px;
    cursor: pointer;
    transition: background-color 0.2s, border-color 0.3s ease;
}

.note-item:hover {
    background-color: rgba(78, 115, 223, 0.1);
}

.note-item.active {
    background-color: rgba(78, 115, 223, 0.15);
    border-left: 4px solid var(--primary-color);
}

/* 编辑器标题区 (底部边框，与内容区分隔) */
.editor-header {
    padding: 15px 20px;
    border-bottom: 1px solid var(--border-color);
    transition: border-color 0.3s ease;
}

/* 编辑器内容区域 */
.editor-body {
    flex-grow: 1;
    display: flex;
    flex-direction: column;
    padding: 20px;
    position: relative;
}

/* 笔记输入框 (字体加粗变大,去默认边框,调布局) */
.note-title-input {
    border: none;
    font-size: 1.5rem;
    font-weight: 700;
    padding: 10px 0;
    margin-bottom: 15px;
    border-bottom: 1px solid var(--border-color);
    background-color: transparent;
    color: var(--text-color);
    transition: border-color 0.3s ease, color 0.3s ease;
}

/* 移除输入框焦点时的默认轮廓 */
.note-title-input:focus {
    outline: none;
    border-bottom: 2px solid var(--primary-color);
}

/* 笔记内容文本区域 (移除边框 + 禁止调大小 + 布局)*/
.note-content-textarea {
    flex-grow: 1;
    border: none;
    resize: none;
    line-height: 1.6;
    font-size: 1rem;
    background-color: transparent;
    color: var(--text-color);
    transition: color 0.3s ease;
    display: block;
    overflow-y: auto; /* 添加滚动条 */
    max-height: calc(100vh - 200px); /* 限制最大高度 */
}

/* 移除文本区域焦点时候的默认轮廓 (移除蓝色轮廓线)*/
.note-content-textarea:focus {
    outline: none;
}

/* Markdown预览区域 */
.markdown-preview {
    flex-grow: 1;
    overflow-y: auto;
    background-color: transparent;
    color: var(--text-color);
    display: none;
    max-height: calc(100vh - 200px); /* 限制最大高度并启用滚动 */
}

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

.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;
}

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

.markdown-preview code {
    background-color: rgba(135, 131, 120, 0.15);
    border-radius: 3px;
    padding: 0.2em 0.4em;
    font-size: 0.85em;
}

.markdown-preview pre {
    background-color: rgba(135, 131, 120, 0.15);
    border-radius: 5px;
    padding: 1rem;
    overflow-x: auto;
    margin-bottom: 1rem;
}

.markdown-preview pre code {
    background: none;
    padding: 0;
}

.markdown-preview blockquote {
    border-left: 4px solid #ddd;
    padding-left: 1rem;
    margin-left: 0;
    color: #666;
}

/* 搜索框样式 */
.search-box {
    border-radius: 20px;
    border: 1px solid var(--border-color);
    padding: 0.35rem 1rem;
    background-color: transparent;
    color: var(--text-color);
    transition: border-color 0.3s ease, color 0.3s ease;
}

.search-box:focus {
    border-color: var(--primary-color);
    box-shadow: 0 0 0 0.2rem rgba(78, 115, 223, 0.25);
}

/* 新建笔记按钮 */
.btn-new-note {
    background-color: var(--primary-color);
    color: white;
    border-radius: 35px;
    padding: 0.5rem 1.5rem;
    font-weight: 600;
    border: none;
}

.btn-new-note:hover {
    background-color: #2e59d9;
    color: white;
}

/* 状态栏样式 */
.stats-bar {
    padding: 10px 20px;
    background-color: var(--light-bg);
    border-top: 1px solid var(--border-color);
    font-size: 0.85rem;
    color: var(--secondary-color);
    transition: background-color 0.3s ease, border-color 0.3s ease;
}

/* 删除按钮样式 */
.delete-note-btn {
    padding: 0.15rem 0.5rem;
    font-size: 0.75rem;
}

/* 响应式设计 */
@media (max-width: 768px) {
    .notes-sidebar {
        width: 100%;
        position: absolute;
        z-index: 100;
        height: 100%;
        display: none;
    }
    .notes-sidebar.active {
        display: flex;
    }
    .btn-toggle-sidebar {
        display: block;
    }
    
    /* 移动端调整编辑器区域高度 */
    .note-content-textarea,
    .markdown-preview {
        max-height: calc(100vh - 250px);
    }
}

/* 下拉菜单暗色主题适配 */
[data-theme="dark"] .dropdown-menu {
    background-color: #2d2d2d;
    border-color: #444;
}

[data-theme="dark"] .dropdown-item {
    color: #fff;
}

[data-theme="dark"] .dropdown-item:hover {
    background-color: #3d3d3d;
    color: #fff;
}

[data-theme="dark"] .form-control {
    background-color: #3d3d3d;
    border-color: #555;
    color: #fff;
}

[data-theme="dark"] .input-group-text {
    background-color: #3d3d3d;
    border-color: #555;
    color: #ccc;
}

/* 修复暗黑主题文字颜色 */
[data-theme="dark"] .note-item h6,
[data-theme="dark"] .note-item p,
[data-theme="dark"] .note-item small {
    color: #e0e0e0 !important;
}

[data-theme="dark"] .note-item .text-muted {
    color: #a0a0a0 !important;
}

[data-theme="dark"] .note-item.active {
    background-color: rgba(78, 115, 223, 0.3);
}

[data-theme="dark"] .btn-outline-danger {
    color: #ff6b6b;
    border-color: #ff6b6b;
}

[data-theme="dark"] .btn-outline-danger:hover {
    background-color: #ff6b6b;
    color: #2d2d2d;
}

/* 标签样式 */
.badge {
    font-size: 0.75rem;
    padding: 0.35em 0.65em;
    cursor: pointer; /* 添加指针样式表示可点击 */
}

.editor-tags {
    background-color: var(--light-bg);
    border-top: 1px solid var(--border-color);
    transition: background-color 0.3s ease, border-color 0.3s ease;
}

/* 字体大小设置 */
.font-small {
    font-size: 0.9rem;
}

.font-small .note-content-textarea,
.font-small .markdown-preview {
    font-size: 0.9rem;
}

.font-medium {
    font-size: 1rem;
}

.font-medium .note-content-textarea,
.font-medium .markdown-preview {
    font-size: 1rem;
}

.font-large {
    font-size: 1.1rem;
}

.font-large .note-content-textarea,
.font-large .markdown-preview {
    font-size: 1.1rem;
}

/* 笔记标签标识 */
.note-tag {
    display: inline-block;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    margin-right: 5px;
}

.tag-work { background-color: #4e73df; }
.tag-study { background-color: #1cc88a; }
.tag-life { background-color: #f6c23e; }
.tag-idea { background-color: #e74a3b; }

/* 搜索高亮 */
.highlight {
    background-color: #ffeb3b;
    color: #000;
    padding: 0 2px;
    border-radius: 2px;
}

/* 无结果提示 */
.no-results {
    padding: 20px;
    text-align: center;
    color: var(--secondary-color);
    font-style: italic;
}

/* 模态框暗色主题适配 */
[data-theme="dark"] .modal-content {
    background-color: #2d2d2d;
    color: #fff;
}

[data-theme="dark"] .modal-header,
[data-theme="dark"] .modal-footer {
    border-color: #444;
}

[data-theme="dark"] .btn-close {
    filter: invert(1);
}

/* 回收站笔记项样式 */
.trash-note-item {
    border-bottom: 1px solid var(--border-color);
    padding: 15px;
    transition: background-color 0.2s, border-color 0.3s ease;
}

.trash-note-item:hover {
    background-color: rgba(78, 115, 223, 0.05);
}

/* 图片插入提示 */
.image-insert-tip {
    font-size: 0.8rem;
    color: var(--secondary-color);
    margin-top: 5px;
}

/* 标签徽章样式 - 在笔记列表中显示标签 */
.note-tag-badge {
    font-size: 0.7rem;
    margin-right: 5px;
    cursor: pointer;
}