/* 基础样式 */
body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    line-height: 1.6;
    color: #333;
    background-color: #f5f5f5;
    margin: 0;
    padding: 0;
}

.container {
    max-width: 1000px;
    margin: 0 auto;
    padding: 0 20px;
}

h1, h2, h3 {
    color: #2c3e50;
    margin: 30px 0;
    line-height: 1.2;
}

h2 {
    font-size: 1.25rem;
}
h3 {
    font-size: 1.15rem;
}

table {
    width: 100%;
    border-collapse: collapse;
    margin-top: 15px;
}

th, td {
    padding: 10px;
    text-align: left;
    border-bottom: 1px solid #eee;
}

.d-flex {
    display: flex;
    gap: 20px;
}

.col {
    flex: 1;
}

/* 导航样式 */
.main-nav {
    display: flex;
    gap: 10px;
    margin-bottom: 20px;
    padding-top: 30px;
    padding-bottom: 20px;
    border-bottom: 1px solid #D9D9D6;
    overflow-x: auto;
}

.main-nav a {
    flex: 0 0 auto;
    text-decoration: none;
    color: #3498db;
    padding: 5px 10px;
    border-radius: 4px;
}

.main-nav a:hover {
    background-color: #f0f0f0;
}

.main-nav a.active {
    background-color: #3498db;
    color: white;
}

/* 表单样式 */
#mdForm {
    padding-bottom: 30px;
}

.form-control {
    margin-bottom: 15px;
}

.form-group {
    display: flex;
}

.form-group input[type="text"] {
    flex: 1;
    border-radius: 4px 0 0 4px;
}
.form-group button {
    flex: none;
    border-radius: 0 4px 4px 0;
}

label {
    font-size: .875rem;
    margin-bottom: 5px;
    font-weight: bold;
}

.checkbox-group label {
    font-weight: normal;
}

input[type="text"],
input[type="password"],
input[type="datetime-local"],
textarea,
select {
    width: 100%;
    padding: 8px;
    border: 1px solid #ddd;
    border-radius: 4px;
    box-sizing: border-box;
}

input#title {
    font-size: 1.1rem;
    font-weight: bold;
}

textarea {
    min-height: 200px;
    resize: vertical;
    font-family: monospace;
    line-height: 1.6;
}

select[multiple] {
    height: auto;
    min-height: 100px;
}

/* 按钮样式 */
button, .btn {
    padding: 5px 15px;
    background: #3498db;
    color: white;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    transition: background 0.3s;
    text-decoration: none;
    display: inline-block;
    font-size: 14px;
}

button:hover, .btn:hover {
    background: #2980b9;
}

.btn.delete {
    background: #e74c3c;
}

.btn.delete:hover {
    background: #c0392b;
}

.btn.edit {
    background: #2ecc71;
}

.btn.edit:hover {
    background: #27ae60;
}

.form-actions {
    margin: 15px 0;
    display: flex;
    gap: 10px;
    justify-content: flex-end;
}

/* 标签输入样式 */
.tags-container {
    margin-bottom: 10px;
}

.tags-input-container {
    position: relative;
    margin-bottom: 10px;
}

.tag-suggestions {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: white;
    border: 1px solid #ddd;
    border-radius: 0 0 4px 4px;
    z-index: 10;
    display: none;
}

.tag-suggestions.show {
    display: block;
}

.tag-suggestion {
    padding: 5px 10px;
    cursor: pointer;
}

.tag-suggestion:hover {
    background-color: #f0f0f0;
}

.selected-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 5px;
    margin-top: 10px;
}

.tag {
    display: inline-flex;
    align-items: center;
    background: #e0e0e0;
    padding: 3px 8px;
    border-radius: 15px;
    font-size: 14px;
}

.remove-tag {
    margin-left: 5px;
    cursor: pointer;
    font-weight: bold;
}

.editor ul {
    list-style-type: none;
    margin: 15px 0 10px;
    padding: 0;
    overflow: hidden;
}
.editor li {
    display: inline-block;
    margin-right: 3px
}
.editor li span {
    display: block;
    font-size: .875rem;
    padding: 3px 8px;
    line-height: 25px;
    text-align: center;
    color: #444;
    border-radius: 4px;
}
.editor li span:hover {
    cursor: pointer;
    background-color: #f0f0f0;
}
/* 文章列表样式 */
.article-list {
    margin-top: 20px;
}

.article-item {
    padding: 15px;
    border: 1px solid #eee;
    border-radius: 4px;
    margin-bottom: 15px;
    overflow: hidden;
}

.article-header {
    flex: 1;
}
.article-header h3 {
    margin: 0 0 10px;
    font-size: 1.5rem;
    font-weight: normal;
}
.article-header a {
    text-decoration: none;
    color: #333;
    font-size: 1.2rem;
}

.article-meta {
    font-size: 14px;
    color: #666;
    display: flex;
    gap: 15px;
    align-items: center;
}
.article-meta span {
    flex: 0 0 auto;
}

.category, .tag {
    background: #e0e0e0;
    padding: 2px 8px;
    border-radius: 12px;
    font-size: 12px;
}

.article-actions {
    display: flex;
    gap: 10px;
    justify-content: flex-end;
}

.delete-form {
    margin: 0;
}
.btn.sync {
    background: #f39c12;
}

.btn.sync:hover {
    background: #e67e22;
}

/* 分类和标签管理样式 */
.category-form, .tag-form {
    margin-bottom: 30px;
    padding-bottom: 20px;
    border-bottom: 1px solid #eee;
}

.tag-list .tags-container {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin-top: 15px;
}

.tag-item {
    display: flex;
    align-items: center;
    background: #e0e0e0;
    border-radius: 15px;
}
.tag-item span {
    padding-left: 12px;
    font-size: 0.875rem;
}
.tag-item button {
    padding: 8px 12px 8px 10px;
    border-radius: 0 15px 15px 0;
}

.tag-item form {
    margin-left: 5px;
}

/* 模态框样式 */
.modal {
    display: none;
    position: fixed;
    z-index: 1;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    overflow: auto;
    background-color: rgba(0,0,0,0.4);
}

.modal-content {
    background-color: #fefefe;
    margin: 10% auto;
    padding: 20px;
    border: 1px solid #888;
    width: 80%;
    max-width: 800px;
    border-radius: 8px;
}
.login-container {
    max-width: 400px;
    margin: 100px auto;
    padding: 20px;
    background: #fff;
    border-radius: 5px;
    box-shadow: 0 2px 10px rgba(0,0,0,0.1);
}
.login-title {
    text-align: center;
    margin-bottom: 20px;
}
.error-message {
    color: #e74c3c;
    margin-bottom: 10px;
    text-align: center;
}

.close {
    color: #aaa;
    float: right;
    font-size: 22px;
    line-height: 1;
    font-weight: bold;
    cursor: pointer;
}

.close:hover {
    color: black;
}

#previewContent {
    max-height: 70vh;
    overflow-y: auto;
    padding: 10px;
    border: 1px solid #ddd;
    border-radius: 4px;
    background: white;
}
#previewContent pre {
    white-space: pre-wrap;
}
.message {
    padding: 10px 15px;
    margin: 10px 0;
    border-radius: 4px;
    position: fixed;
    top: 20px;
    right: 20px;
    z-index: 1000;
    animation: fadeOut 0.5s ease-in-out 3s forwards;
}
.message.success {
    background-color: #2ecc71;
    color: white;
}
.message.error {
    background-color: #e74c3c;
    color: white;
}
@keyframes fadeOut {
    from { opacity: 1; }
    to { opacity: 0; visibility: hidden; }
}

@media screen and (min-width: 768px) {
    .row {
        display: flex;
        gap: 20px;
    }
    .col-8 {
        width: 75%;
    }
    .col-2 {
        width: 25%;
    }
    label {
        display: block;
    }
}
@media screen and (min-width: 999px) {
    .container {
        padding: 0;
    }
}

/* 暗色模式样式 */
@media (prefers-color-scheme: dark) {
    body {
        color: #ccc;
        background-color: #121212;
    }

    .container {
        background-color: #121212;
    }

    h1, h2, h3 {
        color: #888;
    }

    th, td {
        border-color: #333;
    }

    .main-nav {
        border-bottom: 1px solid #333;
    }

    .main-nav a:hover {
        background-color: #333;
    }

    input[type="text"],
    input[type="password"],
    input[type="datetime-local"],
    textarea,
    select {
        background-color: #333;
        color: #e0e0e0;
        border-color: #555;
    }

    .btn.delete {
        background: #cf6679;
    }

    .btn.delete:hover {
        background: #b00020;
    }

    .btn.edit {
        background: #388e3c;
    }

    .btn.edit:hover {
        background: #2e7d32;
    }

    .article-header a {
        color: #cccccc;
    }

    .category, .tag {
        background: #333;
        color: #999;
    }

    .tag-item, .editor li span:hover {
        background: #333;
        color: #ccc;
    }

    .tag-item button {
        color: #121212;
    }

    .category-form, .tag-form, .article-item {
        border-color: #333;
    }

    .modal {
        background-color: rgba(255,255,255,0.05);
        backdrop-filter: blur(10px);
    }

    .modal-content {
        background-color: #121212;
        color: #ffffff;
        border-color: #333;
    }

    .login-container {
        background: #121212;
        color: #cccccc;
        border-color: #333;
        box-shadow: 0 2px 10px rgba(255,255,255,0.1);
    }

    .error-message {
        color: #cf6679;
    }

    .message.success {
        background-color: #388e3c;
    }

    .message.error {
        background-color: #cf6679;
    }

    #previewContent {
        background: #121212;
        color: #ffffff;
        border-color: #333;
    }

    input:active, input:focus,
    textarea:active, textarea:focus {
        outline: none;
        border-color: #666;
    }
}
