/* 重置和基础样式 */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'PingFang SC', 'Microsoft YaHei', sans-serif;
    line-height: 1.6;
    color: #2c3e50;
    background: #fff;
    font-size: 16px;
}

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

/* ===== 博客主页样式 ===== */

/* 头部样式 */
.header {
    padding: 3rem 0 2rem 0;
    text-align: center;
    margin-bottom: 2rem;
    border-bottom: 1px solid #f0f0f0;
    position: relative;
}

.blog-title {
    font-size: 2.2rem;
    font-weight: 700;
    margin-bottom: 0.5rem;
    letter-spacing: -0.5px;
}

.blog-title a {
    color: #2c3e50;
    text-decoration: none;
    transition: color 0.3s ease;
}

.blog-title a:hover {
    color: #3498db;
}

.blog-description {
    color: #7f8c8d;
    font-size: 1rem;
    font-weight: 400;
    margin-top: 0.5rem;
}

/* 侧边栏切换按钮 */
.sidebar-toggle {
    display: none;
    position: fixed;
    top: 20px;
    right: 20px;
    z-index: 1000;
    background: #3498db;
    color: white;
    border: none;
    border-radius: 50%;
    width: 50px;
    height: 50px;
    font-size: 1.2rem;
    cursor: pointer;
    box-shadow: 0 2px 10px rgba(0,0,0,0.2);
    transition: all 0.3s ease;
}

.sidebar-toggle:hover {
    background: #2980b9;
    transform: scale(1.1);
}

/* 主内容区 */
.main-content {
    flex: 1;
    max-width: 800px;
}

/* 侧边栏 */
.sidebar {
    width: 300px;
    flex-shrink: 0;
    transition: transform 0.3s ease;
}

/* 侧边栏遮罩 */
.sidebar-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0,0,0,0.5);
    z-index: 998;
}

/* 文章列表样式 */
.posts {
    display: flex;
    flex-direction: column;
    gap: 3rem;
}

.post {
    background: transparent;
    padding: 0;
    border-radius: 0;
    box-shadow: none;
    margin-bottom: 0;
    border-bottom: 1px solid #f0f0f0;
    padding-bottom: 3rem;
}

.post:last-child {
    border-bottom: none;
    padding-bottom: 0;
}

/* 文章内容布局 - 标题在上方，图片在内容左上角，文字环绕 */
.post-title {
    font-size: 1.6rem;
    margin-bottom: 1rem;
    line-height: 1.4;
    font-weight: 600;
}

.post-title a {
    color: #2c3e50;
    text-decoration: none;
    transition: color 0.2s ease;
}

.post-title a:hover {
    color: #3498db;
}

.post-meta {
    color: #95a5a6;
    font-size: 0.85rem;
    margin-bottom: 1.5rem;
    display: flex;
    gap: 1rem;
    align-items: center;
    flex-wrap: wrap;
}

.post-meta time {
    color: #95a5a6;
}

.category {
    background: #ecf0f1;
    color: #7f8c8d;
    padding: 0.2rem 0.6rem;
    border-radius: 12px;
    font-size: 0.75rem;
    font-weight: 500;
}

/* 修复文字环绕问题 */
.post-content-wrapper {
    position: relative;
}

.post-image {
    float: left;
    width: 35%;
    margin: 0 1.5rem 0.5rem 0;
    shape-outside: margin-box;
}

.post-image img {
    width: 100%;
    height: auto;
    border-radius: 6px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
    transition: transform 0.3s ease;
    display: block;
}

.post-image img:hover {
    transform: scale(1.02);
}

.post-content {
    /* 让内容自然环绕图片 */
}

.post-excerpt {
    color: #5a6c7d;
    line-height: 1.7;
    font-size: 0.95rem;
    margin-bottom: 1.2rem;
    text-align: justify;
}

.post-tags {
    margin: 1.2rem 0 1rem 0;
    display: flex;
    flex-wrap: wrap;
    gap: 0.4rem;
    clear: both;
}

.tag {
    display: inline-block;
    background: #f8f9fa;
    color: #6c757d;
    padding: 0.2rem 0.6rem;
    border-radius: 10px;
    font-size: 0.75rem;
    text-decoration: none;
    transition: all 0.2s ease;
    border: 1px solid #e9ecef;
}

.tag:hover {
    background: #e9ecef;
    color: #495057;
}

.read-more {
    display: inline-block;
    color: #3498db;
    text-decoration: none;
    font-size: 0.9rem;
    font-weight: 500;
    transition: color 0.2s ease;
    clear: both;
}

.read-more:hover {
    color: #2980b9;
    text-decoration: underline;
}

/* 侧边栏样式 */
.sidebar-widget {
    background: #f8f9fa;
    padding: 1.5rem;
    border-radius: 8px;
    margin-bottom: 2rem;
    border: 1px solid #e9ecef;
}

.sidebar-widget h3 {
    font-size: 1.1rem;
    margin-bottom: 1rem;
    color: #2c3e50;
    font-weight: 600;
    padding-bottom: 0.5rem;
    border-bottom: 2px solid #e9ecef;
}

/* 近期文章列表 */
.recent-posts {
    list-style: none;
}

.recent-posts li {
    margin-bottom: 0.8rem;
    padding-bottom: 0.8rem;
    border-bottom: 1px solid #e9ecef;
}

.recent-posts li:last-child {
    margin-bottom: 0;
    padding-bottom: 0;
    border-bottom: none;
}

.recent-posts a {
    color: #5a6c7d;
    text-decoration: none;
    font-size: 0.9rem;
    line-height: 1.4;
    transition: color 0.2s ease;
}

.recent-posts a:hover {
    color: #3498db;
}

/* 分类列表 */
.categories-list {
    list-style: none;
}

.categories-list li {
    margin-bottom: 0.5rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.categories-list a {
    color: #5a6c7d;
    text-decoration: none;
    font-size: 0.9rem;
    transition: color 0.2s ease;
}

.categories-list a:hover {
    color: #3498db;
}

.category-count {
    background: #e9ecef;
    color: #6c757d;
    padding: 0.1rem 0.4rem;
    border-radius: 8px;
    font-size: 0.7rem;
}

/* 标签云 */
.tag-cloud {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
}

.tag-cloud a {
    background: white;
    color: #5a6c7d;
    padding: 0.3rem 0.6rem;
    border-radius: 12px;
    text-decoration: none;
    font-size: 0.8rem;
    border: 1px solid #e9ecef;
    transition: all 0.2s ease;
}

.tag-cloud a:hover {
    background: #3498db;
    color: white;
    border-color: #3498db;
}

/* 分页样式 */
.pagination {
    text-align: center;
    margin: 3rem 0;
    display: flex;
    justify-content: center;
    gap: 0.3rem;
}

.pagination a {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0.5rem 0.8rem;
    border: 1px solid #e9ecef;
    border-radius: 4px;
    text-decoration: none;
    color: #495057;
    font-size: 0.9rem;
    transition: all 0.2s ease;
    min-width: 36px;
}

.pagination a.active {
    background: #3498db;
    color: white;
    border-color: #3498db;
}

.pagination a:hover:not(.active) {
    background: #f8f9fa;
    border-color: #3498db;
    color: #3498db;
}

/* 底部样式 */
.footer {
    border-top: 1px solid #f0f0f0;
    padding: 2rem 0 3rem 0;
    text-align: center;
    color: #95a5a6;
    margin-top: 3rem;
    background: transparent;
}

.footer a {
    color: #3498db;
    text-decoration: none;
    transition: color 0.2s ease;
}

.footer a:hover {
    color: #2980b9;
    text-decoration: underline;
}

/* ===== 响应式设计 ===== */
@media (max-width: 1024px) {
    .container {
        flex-direction: column;
        gap: 2rem;
    }
    
    .sidebar {
        position: fixed;
        top: 0;
        right: -320px;
        width: 300px;
        height: 100vh;
        background: white;
        z-index: 999;
        padding: 2rem;
        overflow-y: auto;
        box-shadow: -2px 0 10px rgba(0,0,0,0.1);
        transition: right 0.3s ease;
    }
    
    .sidebar.active {
        right: 0;
    }
    
    .sidebar-overlay.active {
        display: block;
    }
    
    .sidebar-toggle {
        display: block;
    }
    
    .sidebar-widgets {
        display: block;
    }
    
    .sidebar-widget {
        margin-bottom: 2rem;
    }
}

@media (max-width: 768px) {
    .container {
        padding: 0 15px;
    }
    
    .blog-title {
        font-size: 1.8rem;
    }
    
    .header {
        padding: 2rem 0 1.5rem 0;
        margin-bottom: 1.5rem;
    }
    
    .posts {
        gap: 2rem;
    }
    
    .post {
        padding-bottom: 2rem;
    }
    
    /* 在移动端取消文字环绕，改为垂直布局 */
    .post-image {
        float: none;
        width: 100%;
        margin: 0 0 1rem 0;
        shape-outside: none;
    }
    
    .post-image img {
        width: 100%;
    }
    
    .post-title {
        font-size: 1.4rem;
    }
    
    .post-detail .post-title {
        font-size: 1.6rem;
    }
    
    .post-detail .post-image {
        float: none;
        width: 100%;
        margin: 0 0 1.5rem 0;
        shape-outside: none;
    }
    
    /* 管理后台响应式 */
    .admin-section {
        padding: 1rem;
    }
    
    .admin-header .container {
        flex-direction: column;
        gap: 1rem;
        text-align: center;
    }
    
    .admin-header nav {
        display: flex;
        gap: 1rem;
    }
    
    .admin-header nav a {
        margin: 0;
    }
    
    .post-item {
        flex-direction: column;
        gap: 1rem;
    }
    
    .post-info {
        margin-right: 0;
        width: 100%;
    }
    
    .post-actions {
        width: 100%;
        justify-content: flex-start;
    }
    
    .form-actions {
        flex-direction: column;
    }
    
    .btn-primary, .btn-secondary {
        width: 100%;
        text-align: center;
    }
    
    .category-item {
        flex-direction: column;
        align-items: flex-start;
        gap: 0.75rem;
    }
    
    .delete-category-form {
        align-self: flex-end;
    }
}

@media (max-width: 480px) {
    .blog-title {
        font-size: 1.6rem;
    }
    
    .blog-description {
        font-size: 0.9rem;
    }
    
    .post-title {
        font-size: 1.2rem;
    }
    
    .admin-section {
        padding: 0.8rem;
    }
    
    .admin-section h2 {
        font-size: 1.1rem;
    }
    
    .pagination {
        flex-wrap: wrap;
    }
    
    .pagination a {
        flex: 1;
        min-width: 36px;
    }
    
    .sidebar {
        width: 100%;
        right: -100%;
    }
}