* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    line-height: 1.6;
    color: #333;
}

/* 主导航栏样式 */
.main-header {
    background-color: #222;
    color: #ccc;
    padding: 10px 0;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 1000;
}

.main-nav {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 20px;
}

.nav-list {
    display: flex;
    list-style: none;
    justify-content: flex-start;
    align-items: center;
    position: relative;
}

.nav-item {
    margin-right: 20px;
    font-size: 16px;
    transition: color 0.3s;
}

.nav-add-btn {
    margin-left: auto;
    margin-right: 15px;
}

.nav-edit-btn {
    margin-left: 0;
    margin-right: 15px;
}

.nav-user-btn {
    margin-left: 0;
    margin-right: 0;
    background-color: #444;
    border-radius: 4px;
    padding: 4px 12px;
}

.nav-user-btn:hover {
    background-color: #555;
}

.nav-user-btn a {
    color: #fff;
}

.nav-item a {
    color: #ccc;
    text-decoration: none;
    display: flex;
    align-items: center;
}

.nav-item:hover a {
    color: #fff;
}

.nav-item i {
    margin-right: 5px;
}

.nav-item.active a {
    color: #fff;
    font-weight: bold;
}

/* 主容器样式 */
.container {
    display: grid;
    grid-template-areas: "header header" "aside main";
    grid-template-columns: 250px 1fr;
    grid-template-rows: auto 1fr;
    height: 100vh;
    padding-top: 56px; /* 为固定导航栏预留空间 */
}

.main-content {
    grid-area: main;
    padding: 1rem;
    overflow-y: auto;
    height: calc(100vh - 56px); /* 减去导航栏高度 */
}
/* Dialog Styles */
.dialog {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.5);
    z-index: 2000;
}

.dialog.active {
    display: flex;
    justify-content: center;
    align-items: center;
}

.dialog-content {
    background-color: white;
    padding: 2rem;
    border-radius: 8px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
    width: 90%;
    max-width: 600px;
    max-height: 90vh;
    overflow-y: auto;
}

body.dialog-open {
    overflow: hidden;
}

/* Form Styles */
.form-group {
    margin-bottom: 1rem;
}

.form-group label {
    display: block;
    margin-bottom: 0.5rem;
    font-weight: bold;
}

.form-group input,
.form-group textarea,
.form-group select {
    width: 100%;
    padding: 0.5rem;
    border: 1px solid #dee2e6;
    border-radius: 4px;
    font-family: inherit;
}

.form-group textarea {
    resize: vertical;
}

/* Button Styles */
.btn-primary {
    background-color: #0d6efd;
    color: white;
    border: none;
    padding: 0.5rem 1rem;
    border-radius: 4px;
    cursor: pointer;
    transition: background-color 0.2s;
}

.btn-primary:hover {
    background-color: #0b5ed7;
}

.btn-secondary {
    background-color: #6c757d;
    color: white;
    border: none;
    padding: 0.5rem 1rem;
    border-radius: 4px;
    cursor: pointer;
    transition: background-color 0.2s;
}

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

.dialog-buttons {
    display: flex;
    justify-content: flex-end;
    gap: 1rem;
    margin-top: 1rem;
}

.article-list {
    grid-area: aside;
    border-right: 1px solid #dee2e6;
    padding: 0.5rem;
    overflow-y: auto;
    position: fixed;
    left: 0;
    top: 56px; /* 导航栏高度 + 间距 */
    bottom: 0;
    width: 250px;
    background-color: white;
    display: flex;
    flex-direction: column;
}

/* 创建文章按钮样式 */
.article-create-btn {
    margin-top: 1rem;
    width: calc(100% - 1rem);
    margin-left: auto;
    margin-right: auto;
}

.article-content {
    grid-area: main;
    padding: 2rem;
    overflow-y: visible;
    scroll-behavior: smooth;
    position: relative;
}

.content-header {
    display: none;
}

.article-actions {
    display: flex;
    gap: 0.5rem;
}

.action-btn {
    padding: 0.5rem 1rem;
    border: 1px solid #dee2e6;
    border-radius: 4px;
    background-color: white;
    cursor: pointer;
    font-size: 0.875rem;
    transition: all 0.2s;
}

.action-btn:hover {
    background-color: #f8f9fa;
}

.action-btn.edit-btn:hover {
    border-color: #0d6efd;
    color: #0d6efd;
}

.action-btn.delete-btn:hover {
    border-color: #dc3545;
    color: #dc3545;
}




/* Article List Styles */
.article-item {
    padding: 0.5rem;
    border-bottom: 1px solid #eee;
    cursor: pointer;
    transition: background-color 0.2s;
}

.article-info {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    width: 100%;
    position: relative;
}

.article-title-info {
    flex-grow: 1;
    min-width: 0;
    padding-right: 24px;
}

.article-title-info h3 {
    font-size: 0.875rem;
    word-break: keep-all;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    margin-bottom: 0.25rem;
}

/* 文章选项菜单样式 */
.article-menu-btn {
    background: none;
    border: none;
    cursor: pointer;
    width: 20px;
    height: 20px;
    padding: 4px;
    display: flex;
    flex-direction: column;
    justify-content: center;
    gap: 3px;
    opacity: 0;
    transition: opacity 0.2s;
    position: absolute;
    right: 4px;
    top: 50%;
    transform: translateY(-50%);
}

.article-info:hover .article-menu-btn {
    opacity: 1;
}

.article-menu-btn span {
    width: 4px;
    height: 4px;
    background-color: #666;
    border-radius: 50%;
    margin: 0 auto;
    transition: background-color 0.2s;
}

.article-menu-btn:hover span {
    background-color: #333;
}

.article-menu {
    position: absolute;
    right: 4px;
    top: 100%;
    background: white;
    border: 1px solid #dee2e6;
    border-radius: 4px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
    display: none;
    z-index: 1000;
}

.article-menu.active {
    display: block;
}

.article-menu-item {
    padding: 8px 16px;
    cursor: pointer;
    white-space: nowrap;
    transition: background-color 0.2s;
}

.article-menu-item:hover {
    background-color: #f8f9fa;
}

.article-menu-item.delete {
    color: #dc3545;
}

.article-item:hover {
    background-color: #f8f9fa;
}

.article-info small {
    font-size: 0.75rem;
    color: #6c757d;
    display: block;
}

.article-item:hover {
    background-color: #f8f9fa;
}

.article-item.active {
    background-color: #e9ecef;
}


/* Markdown Content Styles */
.article-content h1 {
    font-size: 2rem;
    margin: 1.5rem 0;
}

.article-content h2 {
    font-size: 1.5rem;
    margin: 1.2rem 0;
}

.article-content h3 {
    font-size: 1.25rem;
    margin: 1rem 0;
}

.article-content p {
    margin: 1rem 0;
}

.article-content code {
    background-color: #f8f9fa;
    padding: 0.2rem 0.4rem;
    border-radius: 3px;
    font-family: monospace;
}

.article-content pre {
    background-color: #f8f9fa;
    padding: 1rem;
    border-radius: 5px;
    overflow-x: auto;
    margin: 1rem 0;
}

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

/* Error Message Styles */
.error-message {
    color: #dc3545;
    background-color: #f8d7da;
    border: 1px solid #f5c6cb;
    border-radius: 4px;
    padding: 1rem;
    margin: 1rem 0;
    text-align: center;
}

/* 内联编辑样式 */
.editing {
    padding: 1rem;
}

.edit-container {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.article-title-container {
    margin-bottom: 1rem;
}

/* 原地编辑样式 */
.article-title-display.editing,
.article-content-display.editing {
    padding: 0.5rem;
    margin-bottom: 1rem;
}

.article-title-display.editing {
    margin-top: 1rem;
}

.article-content-display.editing {
    position: relative;
}

.edit-title {
    font-size: 1.5rem;
    padding: 0.5rem;
    border: 1px solid #dee2e6;
    border-radius: 4px;
    width: 100%;
    font-family: inherit;
    margin-bottom: 1rem;
}

.editor-container {
    display: flex;
    gap: 2rem;
    height: calc(100vh - 250px);
}

.edit-content {
    flex: 1;
    padding: 1rem;
    font-family: monospace;
    font-size: 16px;
    line-height: 1.6;
    resize: none;
    outline: none;
    border: none;
    background-color: transparent;
    overflow-y: auto;
}

.preview-content {
    flex: 1;
    padding: 1rem;
    background-color: transparent;
    overflow-y: auto;
}

.edit-buttons {
    display: flex;
    gap: 1rem;
    justify-content: flex-end;
    margin-top: 1rem;
}

/* 分类标签样式 */
.category-tag {
    display: inline-block;
    padding: 0.2rem 0.5rem;
    font-size: 0.75rem;
    border-radius: 3px;
    margin-right: 0.5rem;
    color: white;
}

.category-tutorials { background-color: #0d6efd; }
.category-software { background-color: #6610f2; }
.category-news { background-color: #dc3545; }
.category-savings { background-color: #198754; }
.category-resources { background-color: #fd7e14; }
