/* 应用主容器 */
.app-container {
    display: flex;
    gap: 20px;
    max-width: 1400px;
    margin: 0 auto;
    padding: 20px;
    height: calc(100vh - 80px);
}

/* 侧边栏 */
.sidebar {
    width: 320px;
    display: flex;
    flex-direction: column;
    gap: 15px;
    flex-shrink: 0;
    overflow-y: auto;
    background: white;
    border-radius: 12px;
    padding: 15px;
    box-shadow: 0 4px 16px rgba(45, 74, 45, 0.08);
}

.sidebar-section {
    margin-bottom: 10px;
}

.section-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px 0;
    border-bottom: 2px solid #f0f8f0;
    margin-bottom: 10px;
}

.section-header h3 {
    font-size: 15px;
    font-weight: 600;
    color: #2d4a2d;
    display: flex;
    align-items: center;
    gap: 8px;
    margin: 0;
}

.icon-btn {
    background: none;
    border: none;
    color: #4a7c59;
    cursor: pointer;
    padding: 5px;
    border-radius: 4px;
    transition: all 0.3s;
    display: flex;
    align-items: center;
    justify-content: center;
}

.icon-btn:hover {
    background: rgba(74, 124, 89, 0.1);
    transform: scale(1.1);
}

/* 搜索区 */
.search-section {
    padding-bottom: 10px;
    border-bottom: 2px solid #f0f8f0;
}

.search-box {
    position: relative;
    display: flex;
    align-items: center;
}

.search-box i {
    position: absolute;
    left: 12px;
    color: #999;
    z-index: 1;
}

.search-box input {
    width: 100%;
    padding: 10px 40px 10px 35px;
    border: 2px solid #e0e0e0;
    border-radius: 8px;
    font-size: 14px;
    transition: border-color 0.3s;
}

.search-box input:focus {
    outline: none;
    border-color: #4a7c59;
}

.clear-search {
    position: absolute;
    right: 8px;
    background: none;
    border: none;
    color: #999;
    cursor: pointer;
    padding: 5px;
    border-radius: 50%;
    transition: all 0.3s;
}

.clear-search:hover {
    background: #f0f0f0;
    color: #666;
}

/* 分类列表 */
.categories-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.category-item {
    padding: 10px 12px;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.3s;
    display: flex;
    align-items: center;
    justify-content: space-between;
    font-size: 14px;
    color: #2d4a2d;
}

.category-item:hover {
    background: #f0f8f0;
}

.category-item.active {
    background: linear-gradient(135deg, #4a7c59 0%, #5a8c69 100%);
    color: white;
}

.category-item .category-info {
    display: flex;
    align-items: center;
    gap: 10px;
}

.category-item .category-color {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    flex-shrink: 0;
}

.category-item .category-count {
    background: rgba(0, 0, 0, 0.1);
    padding: 2px 8px;
    border-radius: 10px;
    font-size: 12px;
}

/* 笔记列表 */
.notes-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
    max-height: 400px;
    overflow-y: auto;
}

.note-item {
    padding: 12px;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.3s;
    border: 1px solid #e0e0e0;
    font-size: 13px;
}

.note-item:hover {
    border-color: #4a7c59;
    background: #f8fdf8;
}

.note-item.active {
    border-color: #4a7c59;
    background: linear-gradient(135deg, #f0f8f0 0%, #e8f5e8 100%);
}

.note-item .note-title {
    font-weight: 600;
    color: #2d4a2d;
    margin-bottom: 5px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.note-item .note-preview {
    color: #666;
    font-size: 12px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.note-item .note-meta {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-top: 8px;
    font-size: 11px;
    color: #999;
}



/* 主内容区 */
.main-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    background: white;
    border-radius: 12px;
    padding: 20px;
    box-shadow: 0 4px 16px rgba(45, 74, 45, 0.08);
    overflow-y: auto;
    overflow-x: visible;
}

.page {
    display: none;
    flex-direction: column;
    gap: 20px;
    height: 100%;
}

.page.active {
    display: flex;
}

/* 页面头部 */
.page-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding-bottom: 15px;
    border-bottom: 2px solid #f0f8f0;
}

.page-header h2 {
    font-size: 20px;
    font-weight: 600;
    color: #2d4a2d;
    margin: 0;
    display: flex;
    align-items: center;
    gap: 10px;
}

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

/* 编辑器页面 */
#editorPage {
    gap: 0;
}

.page-header .note-title-input {
    flex: 1;
    margin: 0 15px;
    padding: 10px 15px;
    border: 2px solid #e0e0e0;
    border-radius: 8px;
    font-size: 16px;
    font-weight: 600;
    transition: border-color 0.3s;
}

.page-header .note-title-input:focus {
    outline: none;
    border-color: #4a7c59;
}

.page-header .note-title-input[readonly] {
    background: #f5f5f5;
    cursor: default;
    border-color: #e0e0e0;
}

.note-actions {
    display: flex;
    gap: 10px;
    align-items: center;
}

.category-select {
    padding: 8px 12px;
    border: 2px solid #e0e0e0;
    border-radius: 6px;
    font-size: 13px;
    color: #2d4a2d;
    cursor: pointer;
    transition: border-color 0.3s;
}

.category-select:focus {
    outline: none;
    border-color: #4a7c59;
}

.category-select:disabled {
    background: #f5f5f5;
    cursor: not-allowed;
    opacity: 0.7;
}

.btn-edit {
    background: linear-gradient(135deg, #4a7c59 0%, #5a8c69 100%);
    color: white;
    border: none;
    padding: 8px 16px;
    border-radius: 6px;
    cursor: pointer;
    font-size: 13px;
    font-weight: 500;
    transition: all 0.3s;
    display: flex;
    align-items: center;
    gap: 5px;
}

.btn-edit:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(74, 124, 89, 0.3);
}

.btn-save {
    background: linear-gradient(135deg, #4a7c59 0%, #5a8c69 100%);
    color: white;
    border: none;
    padding: 8px 16px;
    border-radius: 6px;
    cursor: pointer;
    font-size: 13px;
    font-weight: 500;
    transition: all 0.3s;
    display: flex;
    align-items: center;
    gap: 5px;
}

.btn-save:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(74, 124, 89, 0.3);
}

.btn-delete {
    background: #dc3545;
    color: white;
    border: none;
    padding: 8px;
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.3s;
}

.btn-delete:hover {
    background: #c82333;
}

/* 查看模式 */
.view-mode {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 15px;
    overflow-y: auto;
    overflow-x: visible;
    padding: 20px;
    position: relative;
    transition: all 0.3s ease;
}

.view-mode.fullscreen {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 99999;
    background: linear-gradient(180deg, #ffffff 0%, #f5f9f5 100%);
    padding: 50px 60px 100px 60px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
}

.view-header {
    display: none;
}

.view-mode.fullscreen .view-header {
    display: flex;
    justify-content: flex-end;
    margin-bottom: 15px;
}

.exit-fullscreen-btn {
    background: linear-gradient(135deg, #546E7A 0%, #607D8B 100%);
    color: white;
    border: none;
    padding: 12px 24px;
    border-radius: 25px;
    cursor: pointer;
    font-size: 14px;
    font-weight: 500;
    display: flex;
    align-items: center;
    gap: 8px;
    transition: all 0.3s ease;
    box-shadow: 0 2px 8px rgba(0,0,0,0.15);
}

.exit-fullscreen-btn:hover {
    background: linear-gradient(135deg, #455A64 0%, #546E7A 100%);
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0,0,0,0.2);
}

.view-mode.fullscreen .note-view-content {
    max-height: none;
    flex: 1;
    font-size: 17px;
    line-height: 1.9;
    padding: 0 20px;
}

.view-mode.fullscreen .button-container {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background: rgba(255,255,255,0.98);
    padding: 15px 30px 25px 30px;
    margin: 0;
    z-index: 100000;
    box-shadow: 0 -2px 20px rgba(0,0,0,0.1);
    display: flex;
    justify-content: center;
}

.view-mode.fullscreen .export-buttons {
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
    justify-content: center;
}

#exportWordBtn, #exportPdfBtn, #exportExcelBtn, #exportImageBtn,
#exportWordBtnEdit, #exportPdfBtnEdit, #exportExcelBtnEdit, #exportImageBtnEdit {
    background: linear-gradient(135deg, #4a7c59 0%, #5a8c69 100%);
    color: white;
    border: none;
    padding: 10px 18px;
    border-radius: 6px;
    cursor: pointer;
    font-size: 13px;
    font-weight: 500;
    transition: all 0.3s ease;
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

#exportWordBtn:hover, #exportPdfBtn:hover, #exportExcelBtn:hover, #exportImageBtn:hover,
#exportWordBtnEdit:hover, #exportPdfBtnEdit:hover, #exportExcelBtnEdit:hover, #exportImageBtnEdit:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(74, 124, 89, 0.3);
}

.view-mode.fullscreen .note-meta-bar {
    margin-bottom: 15px;
    padding-bottom: 15px;
    border-bottom: 1px solid #e0e0e0;
}

.view-mode.fullscreen .note-view-content table {
    margin: 25px 0;
    box-shadow: 0 4px 15px rgba(0,0,0,0.1);
}

.view-mode.fullscreen .note-view-content pre {
    background: #f5f5f5;
    padding: 20px;
    border-radius: 8px;
    overflow-x: auto;
    font-size: 14px;
}

.view-mode.fullscreen .note-view-content blockquote {
    border-left: 4px solid #4a7c59;
    margin: 20px 0;
    padding: 15px 20px;
    background: #f9f9f9;
    border-radius: 0 8px 8px 0;
}

.view-mode.fullscreen .note-view-content img {
    max-width: 100%;
    height: auto;
    border-radius: 8px;
    box-shadow: 0 4px 15px rgba(0,0,0,0.1);
}

.view-mode.fullscreen .note-view-content hr {
    border: none;
    border-top: 2px solid #4a7c59;
    margin: 30px 0;
    opacity: 0.3;
}

.note-meta-bar {
    display: flex;
    gap: 10px;
    padding: 10px 0;
    border-bottom: 1px solid #e0e0e0;
}

.meta-tag {
    background: linear-gradient(135deg, #f0f8f0 0%, #e8f5e8 100%);
    color: #2d4a2d;
    padding: 4px 12px;
    border-radius: 12px;
    font-size: 12px;
    font-weight: 500;
}

.note-view-content {
    flex: 1;
    padding: 20px;
    background: white;
    border-radius: 8px;
    border: 1px solid #e0e0e0;
    overflow-y: auto;
    overflow-x: hidden;
    line-height: 1.8;
    color: #2d4a2d;
    position: relative;
    max-height: 55vh;
    min-height: 200px;
    word-wrap: break-word;
    overflow-wrap: break-word;
}

.note-view-content h1,
.note-view-content h2,
.note-view-content h3,
.note-view-content h4,
.note-view-content h5,
.note-view-content h6 {
    margin: 20px 0 10px 0;
    color: #2d4a2d;
    font-weight: 600;
}

.note-view-content h1 {
    font-size: 2em;
    border-bottom: 2px solid #4a7c59;
    padding-bottom: 10px;
}

.note-view-content h2 {
    font-size: 1.5em;
    border-bottom: 1px solid #4a7c59;
    padding-bottom: 8px;
}

.note-view-content p {
    margin: 15px 0;
}

.note-view-content ul,
.note-view-content ol {
    margin: 15px 0;
    padding-left: 25px;
}

.note-view-content li {
    margin: 8px 0;
}

.note-view-content table {
    width: 100%;
    border-collapse: collapse;
    margin: 20px 0;
    box-shadow: 0 2px 8px rgba(74, 124, 89, 0.1);
}

.note-view-content th,
.note-view-content td {
    padding: 12px;
    border: 1px solid #e0e0e0;
    text-align: left;
}

.note-view-content th {
    background: linear-gradient(135deg, #f0f8f0 0%, #e8f5e8 100%);
    font-weight: 600;
}

.note-view-content code {
    background: #f0f8f0;
    padding: 2px 6px;
    border-radius: 4px;
    font-family: 'SF Mono', 'Monaco', 'Consolas', monospace;
    font-size: 0.9em;
}

.note-view-content pre {
    background: linear-gradient(135deg, #f0f8f0 0%, #e8f5e8 100%);
    padding: 15px;
    border-radius: 8px;
    overflow-x: auto;
    margin: 15px 0;
}

.note-view-content pre code {
    background: none;
    padding: 0;
}

.note-view-content blockquote {
    border-left: 4px solid #4a7c59;
    padding-left: 15px;
    margin: 15px 0;
    color: #4a6a4a;
    font-style: italic;
}

.note-view-content img {
    max-width: 100%;
    height: auto;
    margin: 15px 0;
}

/* 编辑模式 */
.edit-mode {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 15px;
}

#editorPage .editor-container {
    flex: 1;
    display: flex;
    gap: 15px;
    overflow: visible;
}

#editorPage .editor-section {
    flex: 1;
    display: flex;
    flex-direction: column;
    border: 1px solid #e0e0e0;
    border-radius: 8px;
    overflow: hidden;
}

#editorPage .editor-header {
    padding: 12px 15px;
    background: linear-gradient(135deg, #f0f8f0 0%, #e8f5e8 100%);
    border-bottom: 1px solid #e0e0e0;
}

#editorPage .editor-header h3 {
    margin: 0;
    font-size: 14px;
    font-weight: 600;
    color: #2d4a2d;
}

#editorPage .editor {
    flex: 1;
    padding: 15px;
    overflow-y: auto;
    font-size: 13px;
    line-height: 1.6;
}

/* 笔记列表页 */
#notesGrid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 15px;
    overflow-y: auto;
}

.note-card {
    background: white;
    border: 1px solid #e0e0e0;
    border-radius: 8px;
    padding: 15px;
    cursor: pointer;
    transition: all 0.3s;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.note-card:hover {
    border-color: #4a7c59;
    box-shadow: 0 4px 12px rgba(74, 124, 89, 0.15);
    transform: translateY(-2px);
}

.note-card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.note-card-title {
    font-weight: 600;
    color: #2d4a2d;
    font-size: 15px;
    flex: 1;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.note-card-category {
    background: linear-gradient(135deg, #f0f8f0 0%, #e8f5e8 100%);
    color: #2d4a2d;
    padding: 4px 8px;
    border-radius: 4px;
    font-size: 11px;
    font-weight: 500;
}

.note-card-content {
    color: #666;
    font-size: 13px;
    overflow: hidden;
    text-overflow: ellipsis;
    display: -webkit-box;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
    line-height: 1.5;
}

.note-card-footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    font-size: 11px;
    color: #999;
    padding-top: 10px;
    border-top: 1px solid #f0f0f0;
}

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

.note-card-actions button {
    background: none;
    border: none;
    color: #999;
    cursor: pointer;
    transition: color 0.3s;
}

.note-card-actions button:hover {
    color: #4a7c59;
}

/* 管理后台页 */
.admin-content {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.admin-section {
    background: #f8fdf8;
    border: 1px solid #e8f5e8;
    border-radius: 8px;
    padding: 20px;
}

.admin-section h3 {
    font-size: 18px;
    font-weight: 600;
    color: #2d4a2d;
    margin-bottom: 15px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.settings-form,
.password-form {
    display: flex;
    flex-direction: column;
    gap: 15px;
}

.form-group {
    display: flex;
    flex-direction: column;
    gap: 5px;
}

.form-group label {
    font-size: 14px;
    font-weight: 500;
    color: #2d4a2d;
}

.form-group input[type="text"],
.form-group input[type="password"] {
    padding: 10px 12px;
    border: 2px solid #e0e0e0;
    border-radius: 6px;
    font-size: 14px;
    transition: border-color 0.3s;
}

.form-group input:focus {
    outline: none;
    border-color: #4a7c59;
}

.form-group small {
    font-size: 12px;
    color: #666;
}

.btn-secondary {
    background: #6c757d;
    color: white;
    border: none;
    padding: 10px 20px;
    border-radius: 6px;
    cursor: pointer;
    font-size: 14px;
    font-weight: 500;
    transition: all 0.3s;
}

.btn-secondary:hover {
    background: #5a6268;
}

/* 分类管理 */
.category-manager {
    display: flex;
    flex-direction: column;
    gap: 15px;
}

.category-form {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
}

.category-form input[type="text"] {
    flex: 1;
    min-width: 150px;
    padding: 10px 12px;
    border: 2px solid #e0e0e0;
    border-radius: 6px;
    font-size: 14px;
}

.category-form input[type="color"] {
    width: 50px;
    padding: 5px;
    border: 2px solid #e0e0e0;
    border-radius: 6px;
    cursor: pointer;
}

.admin-categories-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.admin-category-item {
    background: white;
    border: 1px solid #e0e0e0;
    border-radius: 6px;
    padding: 12px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 15px;
}

.admin-category-info {
    display: flex;
    align-items: center;
    gap: 12px;
    flex: 1;
}

.admin-category-color {
    width: 12px;
    height: 12px;
    border-radius: 50%;
}

.admin-category-name {
    font-weight: 600;
    color: #2d4a2d;
}

.admin-category-desc {
    color: #666;
    font-size: 13px;
}

.admin-category-actions {
    display: flex;
    gap: 8px;
}

.admin-category-actions .btn-edit-cat,
.admin-category-actions .btn-delete-cat {
    padding: 6px 12px;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-size: 12px;
    transition: all 0.3s;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 5px;
    white-space: nowrap;
}

.admin-category-actions .btn-edit-cat {
    background: linear-gradient(135deg, #4a7c59 0%, #5a8c69 100%);
    color: white;
}

.admin-category-actions .btn-edit-cat:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(74, 124, 89, 0.3);
}

.admin-category-actions .btn-delete-cat {
    background: #dc3545;
    color: white;
}

.admin-category-actions .btn-delete-cat:hover {
    background: #c82333;
}

.admin-category-actions .btn-edit-cat i,
.admin-category-actions .btn-delete-cat i {
    color: white;
    display: inline-block;
    width: 1em;
    text-align: center;
}

/* 登录弹窗 */
.login-modal {
    max-width: 400px;
}

.login-form {
    display: flex;
    flex-direction: column;
    gap: 15px;
}

.login-form .form-group {
    margin-bottom: 0;
}

/* 响应式设计 */
@media (max-width: 1024px) {
    .app-container {
        flex-direction: column;
        height: auto;
    }
    
    .sidebar {
        width: 100%;
        max-height: 300px;
    }
    
    #editorPage .editor-container {
        flex-direction: column;
        height: auto;
    }
    
    #editorPage .editor-section {
        height: 400px;
    }
    
    .notes-list {
        max-height: 200px;
    }
}

@media (max-width: 768px) {
    .app-container {
        padding: 10px;
        gap: 10px;
    }

    .sidebar {
        padding: 10px;
        max-height: none;
        height: auto;
    }

    .page-header {
        flex-direction: column;
        gap: 10px;
        align-items: flex-start;
    }

    .note-actions {
        width: 100%;
        justify-content: space-between;
    }

    .category-select {
        flex: 1;
    }

    .note-title-input {
        width: 100%;
        margin: 0;
    }

    #notesGrid {
        grid-template-columns: 1fr;
    }

    .category-form {
        flex-direction: column;
    }

    .admin-category-item {
        flex-direction: column;
        align-items: flex-start;
    }

    .admin-category-actions {
        width: 100%;
        justify-content: flex-end;
    }

    /* 按钮优化 */
    .btn-primary, .btn-secondary {
        min-height: 44px;
        font-size: 16px;
        padding: 12px 20px;
    }

    .icon-btn {
        min-width: 44px;
        min-height: 44px;
    }

    /* 字体调整 */
    body {
        font-size: 14px;
    }

    h1, h2, h3 {
        font-size: 1.2em;
    }
}

/* 手机端额外优化 */
@media (max-width: 480px) {
    .app-container {
        padding: 5px;
        gap: 5px;
    }

    .sidebar {
        padding: 8px;
    }

    .section-header h3 {
        font-size: 14px;
    }

    .btn-primary, .btn-secondary {
        width: 100%;
        margin-bottom: 10px;
    }

    .search-box input {
        font-size: 16px; /* 防止缩放 */
    }

    .note-title {
        font-size: 16px;
    }

    /* 模态框优化 */
    .modal-content {
        margin: 10px;
        max-height: 95vh;
    }

    .modal-header {
        padding: 15px 20px;
    }

    .modal-body {
        padding: 15px 20px;
    }
}

/* 滚动条美化 */
.sidebar::-webkit-scrollbar,
.notes-list::-webkit-scrollbar,
.main-content::-webkit-scrollbar,
#editorPage .editor::-webkit-scrollbar {
    width: 6px;
}

.sidebar::-webkit-scrollbar-track,
.notes-list::-webkit-scrollbar-track,
.main-content::-webkit-scrollbar-track,
#editorPage .editor::-webkit-scrollbar-track {
    background: #f1f1f1;
}

.sidebar::-webkit-scrollbar-thumb,
.notes-list::-webkit-scrollbar-thumb,
.main-content::-webkit-scrollbar-thumb,
#editorPage .editor::-webkit-scrollbar-thumb {
    background: #4a7c59;
    border-radius: 3px;
}

.sidebar::-webkit-scrollbar-thumb:hover,
.notes-list::-webkit-scrollbar-thumb:hover,
.main-content::-webkit-scrollbar-thumb:hover,
#editorPage .editor::-webkit-scrollbar-thumb:hover {
    background: #5a8c69;
}
