/* 基础样式 */
:root {
    --primary: #4f46e5;
    --primary-dark: #4338ca;
    --secondary: #6b7280;
    --success: #10b981;
    --danger: #ef4444;
    --warning: #f59e0b;
    --light: #f9fafb;
    --dark: #111827;
    --border: #e5e7eb;
    --radius: 8px;
    --shadow: 0 1px 3px 0 rgba(0, 0, 0, 0.1), 0 1px 2px 0 rgba(0, 0, 0, 0.06);
}

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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    line-height: 1.6;
    color: #333;
    background: var(--light);
}

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

/* 头部 */
.header {
    background: white;
    border-bottom: 1px solid var(--border);
    padding: 1rem 0;
    position: sticky;
    top: 0;
    z-index: 100;
}

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

.logo {
    font-size: 1.5rem;
    font-weight: bold;
    text-decoration: none;
    color: var(--primary);
}

.nav {
    display: flex;
    gap: 2rem;
    align-items: center;
}

.nav a {
    color: var(--secondary);
    text-decoration: none;
    padding: 0.5rem 1rem;
    border-radius: var(--radius);
    transition: all 0.2s;
}

.nav a:hover {
    color: var(--primary);
    background: var(--light);
}

.admin-link {
    background: var(--primary);
    color: white !important;
}

.admin-link:hover {
    background: var(--primary-dark) !important;
}

/* 搜索框 */
.search-box {
    background: white;
    padding: 2rem 0;
    border-bottom: 1px solid var(--border);
}

.search-box input {
    width: 400px;
    max-width: 100%;
    padding: 0.75rem 1rem;
    border: 2px solid var(--border);
    border-radius: var(--radius) 0 0 var(--radius);
    font-size: 1rem;
}

.search-box button {
    padding: 0.75rem 1.5rem;
    background: var(--primary);
    color: white;
    border: none;
    border-radius: 0 var(--radius) var(--radius) 0;
    cursor: pointer;
    font-size: 1rem;
    transition: background 0.2s;
}

.search-box button:hover {
    background: var(--primary-dark);
}

/* 文章卡片 */
.posts-grid {
    padding: 2rem 0;
    display: grid;
    gap: 1.5rem;
}

.post-card {
    background: white;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1.5rem;
    cursor: pointer;
    transition: all 0.2s;
}

.post-card:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow);
}

.post-header {
    margin-bottom: 1rem;
}

.post-header h2 {
    font-size: 1.25rem;
    margin-bottom: 0.5rem;
    color: var(--dark);
}

.post-meta {
    display: flex;
    gap: 1rem;
    font-size: 0.875rem;
    color: var(--secondary);
}

.category {
    color: var(--primary);
    font-weight: 500;
}

.post-preview {
    color: var(--secondary);
    margin-bottom: 1rem;
    line-height: 1.6;
}

.post-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.tags {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
}

.tag {
    font-size: 0.75rem;
    padding: 0.25rem 0.5rem;
    background: var(--light);
    color: var(--secondary);
    border-radius: 4px;
}

.read-more {
    color: var(--primary);
    font-weight: 500;
    font-size: 0.875rem;
}

/* 页脚 */
footer {
    text-align: center;
    padding: 2rem 0;
    color: var(--secondary);
    border-top: 1px solid var(--border);
    margin-top: 2rem;
}

/* 后台管理 */
.admin-body {
    background: #f1f5f9;
    min-height: 100vh;
}

.auth-container {
    max-width: 400px;
    margin: 100px auto;
    background: white;
    padding: 2rem;
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    text-align: center;
}

.auth-form {
    display: flex;
    gap: 0.5rem;
    margin: 1.5rem 0;
}

.auth-form input {
    flex: 1;
    padding: 0.75rem;
    border: 1px solid var(--border);
    border-radius: var(--radius);
}

.auth-form button {
    padding: 0.75rem 1.5rem;
    background: var(--primary);
    color: white;
    border: none;
    border-radius: var(--radius);
    cursor: pointer;
}

.hint {
    font-size: 0.875rem;
    color: var(--secondary);
}

/* 编辑器 */
.editor-container {
    background: white;
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    margin-bottom: 2rem;
    overflow: hidden;
}

.editor-header {
    padding: 1.5rem;
    border-bottom: 1px solid var(--border);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

#post-title {
    font-size: 1.5rem;
    border: none;
    outline: none;
    flex: 1;
    min-width: 0;
}

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

.editor-actions button {
    padding: 0.5rem 1rem;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: white;
    cursor: pointer;
}

.editor-actions .primary {
    background: var(--primary);
    color: white;
    border-color: var(--primary);
}

.editor-actions .danger {
    background: var(--danger);
    color: white;
    border-color: var(--danger);
}

.editor-meta {
    padding: 1rem 1.5rem;
    border-bottom: 1px solid var(--border);
    display: flex;
    gap: 1.5rem;
    flex-wrap: wrap;
}

.meta-item {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.meta-item label {
    font-weight: 500;
    color: var(--secondary);
}

.meta-item input,
.meta-item select {
    padding: 0.5rem;
    border: 1px solid var(--border);
    border-radius: 4px;
    min-width: 150px;
}

/* 编辑器内容 */
.editor-wrapper {
    padding: 1.5rem;
}

.editor-tabs {
    display: flex;
    gap: 0.5rem;
    margin-bottom: 1rem;
}

.editor-tabs button {
    padding: 0.5rem 1rem;
    background: var(--light);
    border: 1px solid var(--border);
    border-radius: var(--radius) var(--radius) 0 0;
    cursor: pointer;
}

.editor-tabs button.active {
    background: white;
    border-bottom-color: white;
}

.editor-tab textarea {
    width: 100%;
    min-height: 300px;
    padding: 1rem;
    border: 1px solid var(--border);
    border-radius: 0 0 var(--radius) var(--radius);
    font-family: 'Monaco', 'Menlo', monospace;
    font-size: 0.875rem;
    line-height: 1.5;
    resize: vertical;
}

.content-preview {
    min-height: 300px;
    padding: 1rem;
    border: 1px solid var(--border);
    border-radius: 0 0 var(--radius) var(--radius);
    background: white;
}

/* 文章列表 */
.posts-table {
    width: 100%;
    border-collapse: collapse;
    background: white;
    border-radius: var(--radius);
    overflow: hidden;
    box-shadow: var(--shadow);
}

.posts-table th,
.posts-table td {
    padding: 1rem;
    text-align: left;
    border-bottom: 1px solid var(--border);
}

.posts-table th {
    background: var(--light);
    font-weight: 600;
    color: var(--secondary);
}

.posts-table tr:hover {
    background: #f8fafc;
}

/* 分类下拉 */
.categories-dropdown {
    position: relative;
}

.dropdown-btn {
    background: none;
    border: none;
    padding: 0.5rem 1rem;
    color: var(--secondary);
    cursor: pointer;
    font-size: 1rem;
}

.dropdown-content {
    position: absolute;
    top: 100%;
    left: 0;
    background: white;
    min-width: 200px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    display: none;
    z-index: 100;
}

.categories-dropdown:hover .dropdown-content {
    display: block;
}

.dropdown-content a {
    display: block;
    padding: 0.75rem 1rem;
    color: var(--secondary);
    text-decoration: none;
}

.dropdown-content a:hover {
    background: var(--light);
    color: var(--primary);
}

/* 搜索页面 */
.search-page {
    padding: 2rem 0;
}

.search-header {
    display: flex;
    gap: 0.5rem;
    margin-bottom: 2rem;
}

.search-header input {
    flex: 1;
    padding: 1rem;
    border: 2px solid var(--border);
    border-radius: var(--radius);
    font-size: 1rem;
}

.search-header button {
    padding: 1rem 2rem;
    background: var(--primary);
    color: white;
    border: none;
    border-radius: var(--radius);
    cursor: pointer;
}

.search-result {
    background: white;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1.5rem;
    margin-bottom: 1rem;
    cursor: pointer;
    transition: all 0.2s;
}

.search-result:hover {
    transform: translateX(4px);
    box-shadow: var(--shadow);
}

.search-result h3 {
    margin-bottom: 0.5rem;
}

.result-meta {
    display: flex;
    gap: 1rem;
    font-size: 0.875rem;
    color: var(--secondary);
    margin-bottom: 0.5rem;
}

.search-result p {
    color: var(--secondary);
    margin-bottom: 0.5rem;
}

.result-tags {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
}

mark {
    background: #fef3c7;
    padding: 0.1rem 0.2rem;
    border-radius: 2px;
}

/* 模态框 */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
}

.modal-content {
    background: white;
    padding: 2rem;
    border-radius: var(--radius);
    max-width: 500px;
    width: 90%;
}

.modal-actions {
    display: flex;
    gap: 0.5rem;
    justify-content: flex-end;
    margin-top: 1rem;
}

/* 工具类 */
.no-posts {
    text-align: center;
    padding: 3rem;
    color: var(--secondary);
}

.danger {
    background: var(--danger) !important;
    color: white !important;
}

/* 响应式设计 */
@media (max-width: 768px) {
    .header .container {
        flex-direction: column;
        gap: 1rem;
    }
    
    .nav {
        width: 100%;
        justify-content: center;
        flex-wrap: wrap;
    }
    
    .search-box input {
        width: 100%;
        border-radius: var(--radius);
        margin-bottom: 1rem;
    }
    
    .search-box button {
        width: 100%;
        border-radius: var(--radius);
    }
    
    .editor-header,
    .editor-meta,
    .auth-form {
        flex-direction: column;
        align-items: stretch;
    }
    
    .meta-item input,
    .meta-item select {
        min-width: 0;
        width: 100%;
    }
    
    .posts-table {
        display: block;
        overflow-x: auto;
    }
}
/* 分类页面样式 */
.categories-page {
    padding: 2rem 0;
}

.categories-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
    gap: 1.5rem;
    margin: 2rem 0;
}

.category-card {
    background: white;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1.5rem;
    cursor: pointer;
    transition: all 0.2s;
}

.category-card:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow);
}

.category-card h3 {
    color: var(--primary);
    margin-bottom: 0.5rem;
}

.category-card p {
    color: var(--secondary);
    margin-bottom: 1rem;
}

.view-all {
    color: var(--primary);
    font-weight: 500;
    font-size: 0.875rem;
}

/* 文章页面样式 */
.article-meta-info {
    display: flex;
    gap: 1.5rem;
    margin: 1rem 0 2rem;
    padding-bottom: 1rem;
    border-bottom: 1px solid var(--border);
    color: var(--secondary);
    font-size: 0.875rem;
    flex-wrap: wrap;
}

.article-meta-info .category {
    color: var(--primary);
    font-weight: 500;
}

.article-body {
    margin-bottom: 3rem;
}

.error-message {
    text-align: center;
    padding: 4rem 2rem;
    color: var(--secondary);
}

.error-message h2 {
    margin-bottom: 1.5rem;
}

.error-message a {
    color: var(--primary);
    text-decoration: none;
}

/* 响应式调整 */
@media (max-width: 768px) {
    .categories-grid {
        grid-template-columns: 1fr;
    }
    
    .article-meta-info {
        flex-direction: column;
        gap: 0.5rem;
    }
    
    .edit-link {
        bottom: 1rem;
        right: 1rem;
        padding: 0.5rem 1rem;
        font-size: 0.875rem;
    }
}

/* 加载动画 */
.loading-spinner {
    display: inline-block;
    width: 40px;
    height: 40px;
    margin: 1rem auto;
    border: 3px solid #f3f3f3;
    border-top: 3px solid var(--primary);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* 分类下拉菜单优化 */
.categories-dropdown:hover .dropdown-content {
    display: block;
    max-height: 400px;
    overflow-y: auto;
}

/* 文章标签 */
.tag-more {
    font-size: 0.7rem;
    padding: 0.15rem 0.3rem;
    background: var(--light);
    color: var(--secondary);
    border-radius: 4px;
    margin-left: 0.25rem;
}

/* 无文章提示 */
.no-posts a {
    color: var(--primary);
    text-decoration: none;
    font-weight: 500;
}

.no-posts a:hover {
    text-decoration: underline;
}

/* 分页样式优化 */
.pagination {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 1rem;
    margin: 2rem 0;
    padding: 1rem;
    background: white;
    border-radius: var(--radius);
    box-shadow: var(--shadow);
}

.pagination button {
    padding: 0.5rem 1rem;
    border: 1px solid var(--border);
    background: white;
    color: var(--dark);
    border-radius: var(--radius);
    cursor: pointer;
    transition: all 0.2s;
}

.pagination button:hover:not(:disabled) {
    background: var(--primary);
    color: white;
    border-color: var(--primary);
}

.pagination button:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

#page-info {
    color: var(--secondary);
    font-size: 0.9rem;
}

#page-info span {
    color: var(--primary);
    font-weight: bold;
}