﻿/* 全局样式 */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Microsoft YaHei', Arial, sans-serif;
    color: #333;
    line-height: 1.6;
}

a {
    text-decoration: none;
    color: #333;
}

ul {
    list-style: none;
}

.container {
    width: 100%;
    max-width: 980px;
    margin: 0 auto;
    padding: 0 15px;
}

    .container.content-wrapper {
        max-width: 980px;
        margin: 0 auto;
        padding: 0 15px;
    }

/* 页头样式 */
header {
    width: 100%;
    background-color: #fff;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
    padding: 15px 0;
    position: sticky;
    top: 0;
    z-index: 100;
}

.header-container {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    /*height: 60px; */ /* 确保 header 有固定高度 */
}

.logo-area {
    display: flex;
    align-items: center;
    margin-right: 30px;
}

.logo {
    width: 40px;
    height: 40px;
    margin-right: 10px;
}

.site-name {
    font-size: 20px;
    font-weight: bold;
}

.nav-menu {
    display: flex;
    list-style: none;
    flex-grow: 1;
    overflow-x: auto;
    white-space: nowrap;
    padding-bottom: 5px; /* 给滚动条留空间 */
    margin: 0;
    padding: 0;
}

    .nav-menu li {
        margin-right: 10px;
    }

        .nav-menu li a {
            text-decoration: none;
            color: #333;
            font-size: 16px;
            padding: 5px 0;
            position: relative;
            line-height: 60px; /* 与 header 高度一致 */
        }

            .nav-menu li a:hover {
                color: #1e88e5;
            }

            .nav-menu li a:after {
                content: '';
                position: absolute;
                bottom: 0;
                left: 0;
                width: 0;
                height: 2px;
                background-color: #1e88e5;
                transition: width 0.3s;
            }

            .nav-menu li a:hover:after {
                width: 100%;
            }

/* 搜索区域调整 */
.search-area {
    display: flex;
    margin: 0 20px;
    min-width: 200px; /* 确保搜索框有足够宽度 */
    flex-shrink: 1; /* 允许适当缩小 */
}

.search-input {
    padding: 8px 15px;
    border: 1px solid #ddd;
    border-radius: 4px 0 0 4px;
    width: 100%;
    outline: none;
}

/* 搜索页面全宽布局 */
.search-content-full {
    width: 100%;
    padding: 20px 0;
}

    .search-content-full .container {
        max-width: 100%;
        padding: 0 15px;
    }

.search-btn {
    padding: 8px 15px;
    background-color: #1e88e5;
    color: white;
    border: none;
    border-radius: 0 4px 4px 0;
    cursor: pointer;
}

.user-area {
    display: flex;
    align-items: center;
    white-space: nowrap; /* 防止换行 */
    flex-shrink: 0; /* 防止缩小 */
}

    .user-area a, .user-area span {
        margin-left: 15px;
        padding: 5px 0;
        display: inline-block; /* 确保元素在同一行 */
    }

        .user-area a:hover {
            color: #1e88e5;
        }

.user-avatar {
    width: 30px;
    height: 30px;
    border-radius: 50%;
    margin-right: 5px;
    display: inline-block;
    vertical-align: middle;
}

.user-name {
    display: inline-block;
    vertical-align: middle;
}

#dv_IsLogin {
    display: "";
}

#dv_NotLogin {
    display: "";
}

/* 主要内容区域 */
.content-row {
    display: flex;
    gap: 30px;
    align-items: flex-start;
}

.content-main {
    flex: 1;
    min-width: 0;
    /*background: #fff;*/
    border-radius: 4px;
    /*box-shadow: 0 1px 3px rgba(0,0,0,0.1);*/
    overflow: hidden; /* 防止内容溢出 */
}

.content-sidebar {
    width: 250px;
    flex-shrink: 0;
}


.main-content {
    padding: 30px 0;
    background-color: #f9f9f9;
}

/* 内容区域布局 */
.content-wrapper {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-height: calc(100vh - 200px); /* 减去头部和底部高度 */
}

.content-row {
    display: flex;
    flex: 1;
    gap: 20px;
    margin: 20px 0;
    min-height: 500px;
}

.content-main {
    flex: 1;
    min-width: 0;
    min-height: 500px;
    background: #fff;
    border-radius: 8px;
    padding: 20px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

.content-sidebar {
    width: 250px;
    flex-shrink: 0;
    min-height: 500px;
}


.content-left {
    flex: 1;
    min-width: 0;
    margin-right: 30px;
    order: 1; /* PC端左侧优先 */
}

.content-right {
    width: 250px;
    order: 2; /* PC端右侧在后 */
}

/* 文章列表样式 */
.article-list {
    margin-bottom: 30px;
}


/* 文章项布局调整 */
.article-item {
    display: flex;
    margin-bottom: 20px;
    padding-bottom: 20px;
    border-bottom: 1px solid #eee;
}

    /* PC端：图片右对齐 */
    .article-item.has-image {
        flex-direction: row-reverse;
    }

.article-img {
    width: 150px;
    height: 100px;
    object-fit: cover;
    border-radius: 4px;
    margin-left: 20px;
    display: none; /* 默认隐藏 */
}

.article-img {
    background-color: #e0e0e0; /* 默认灰色背景 */
    transition: opacity 0.3s; /* 平滑加载效果 */
}

    .article-img[data-src] {
        opacity: 0.8; /* 未加载时的透明度 */
    }

    .article-img.loaded {
        opacity: 1; /* 加载完成后的透明度 */
    }

.article-item.has-image .article-img {
    display: block;
}

.article-info {
    flex: 1;
    min-width: 0;
}

.article-title {
    font-size: 18px;
    margin-bottom: 10px;
    line-height: 1.4;
}


    .article-title a:hover {
        color: #1e88e5;
    }

.article-meta {
    font-size: 12px;
    color: #999;
    margin-bottom: 10px;
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
}

.article-summary {
    font-size: 14px;
    color: #666;
    display: -webkit-box;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
    overflow: hidden;
    text-overflow: ellipsis;
    line-height: 1.5;
    max-height: 4.5em;
}

/* 右侧边栏样式 */
.sidebar-box {
    background-color: #f9f9f9;
    border-radius: 4px;
    padding: 15px;
    margin-bottom: 20px;
}

.sidebar-title {
    font-size: 16px;
    padding-bottom: 10px;
    margin-bottom: 15px;
    border-bottom: 1px solid #eee;
    color: #333;
}

.sidebar-list li {
    padding: 8px 0;
    border-bottom: 1px dashed #eee;
}

    .sidebar-list li:last-child {
        border-bottom: none;
    }

.sidebar-list a:hover {
    color: #1e88e5;
}

.tag-list {
    display: flex;
    flex-wrap: wrap;
}

.tag-item {
    padding: 4px 10px;
    background-color: #f0f0f0;
    border-radius: 3px;
    margin: 0 5px 5px 0;
    font-size: 12px;
}

    .tag-item:hover {
        background-color: #1e88e5;
        color: white;
    }

/* 分页样式 */
.pagination {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 5px;
    max-width: 100%;
    overflow: hidden;
}

.page-item {
    padding: 8px 12px;
    border: 1px solid #ddd;
    border-radius: 4px;
    text-align: center;
    min-width: 40px;
}

.ellipsis {
    padding: 8px 5px;
}

.page-link {
    display: block;
    padding: 8px 15px;
    border: 1px solid #ddd;
    border-radius: 4px;
}

    .page-link:hover, .page-item.active .page-link {
        background-color: #1e88e5;
        color: white;
        border-color: #1e88e5;
    }

/* 当前页样式 */
.page-item.active {
    background-color: #1e88e5;
    color: white;
    border-color: #1e88e5;
}

/* 页脚样式 */
footer {
    background-color: #333;
    color: #999;
    height: 60px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
}

/* 二级菜单样式 */
.submenu-channel {
    background-color: #f8f9fa;
    border-bottom: 1px solid #e1e1e1;
    margin-bottom: 20px;
}

.channel-list {
    display: flex;
    flex-wrap: wrap;
    list-style: none;
    padding: 10px 0;
    margin: 0;
    overflow-x: auto;
    white-space: nowrap;
}

    .channel-list li {
        margin-right: 15px;
    }

    .channel-list a {
        display: block;
        padding: 8px 15px;
        color: #555;
        text-decoration: none;
        border-radius: 4px;
        transition: all 0.3s;
    }

        .channel-list a:hover {
            background-color: #e9ecef;
            color: #333;
        }

    .channel-list .active a {
        background-color: #1e88e5;
        color: white;
    }

/* 消息弹层 */
.toast-container {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    z-index: 9999;
    max-width: 400px;
    width: 100%;
}

.toast {
    width: 100%;
    min-width: 200px;
    max-width: 100%;
    box-shadow: 0 0.5rem 1rem rgba(0,0,0,0.15);
    text-align: left;
    padding: 1rem;
}

.toast-header {
    justify-content: space-between;
    align-items: center;
    font-weight: bold; /* 标题加粗 */
}

.toast-body {
    display: flex;
    align-items: center; /* 垂直居中 */
    gap: 1rem;
    padding: 1rem;
}

    .toast-body i {
        font-size: 3rem;
        width: 3rem;
        height: 3rem;
        min-width: 3rem;
        min-height: 3rem;
        display: flex;
        align-items: center;
        justify-content: center;
    }

    .toast-body span {
        font-size: 1rem;
        line-height: 1.5;
    }
    
/* 评论列表样式 */
.comment-header {
    display: flex;
    align-items: flex-start; /* 顶部对齐 */
}

.avatar-container {
    flex: 0 0 auto; /* 固定宽度不伸缩 */
    margin-right: 10px; /* 头像右边距 */
}

.comment-content {
    flex: 1; /* 自动填充中间剩余空间 */
    margin: 0 10px; /* 左右间距 */
}

.comment-author-info {
    flex: 0 0 auto; /* 固定宽度不伸缩 */
    text-align: right; /* 文字右对齐 */
    margin-left: 10px; /* 左边距 */
}

.comment-author-info {
    display: flex;
    flex-direction: column; /* 垂直排列 */
    align-items: flex-end; /* 右对齐 */
}

.comment-author,
.comment-floor,
.text-muted {
    display: block; /* 块级元素 */
    width: 100%; /* 占满宽度 */
    text-align: right; /* 文字右对齐 */
}

/* 文字头像样式 - 完美居中版本 */
.avatar-text {
        display: inline-flex !important;
    align-items: center !important;
    justify-content: center !important;
    width: 40px !important;
    height: 40px !important;
    border-radius: 50% !important;
    background-color: #007bff !important;
    color: white !important;
    font-weight: bold !important;
    font-size: 16px !important;
    text-align: center !important;
    line-height: 1 !important;
    box-sizing: border-box !important;
    padding: 0 !important;
    margin: 0 !important;

    /*display: flex;
    align-items: center;*/ /* 垂直居中 */
    /*justify-content: center;*/ /* 水平居中 */
    /*width: 40px;
    height: 40px;
    border-radius: 50%;
    background-color: #1890ff;
    color: white;
    font-size: 16px;
    font-weight: bold;
    line-height: 1;*/ /* 去除默认行高影响 */
}

.avatar-text-sm {
    width: 30px !important;
    height: 30px !important;
    font-size: 12px !important;
}

.avatar-text-lg {
    width: 60px !important;
    height: 60px !important;
    font-size: 20px !important;
}

/* 使用Flexbox确保绝对居中 */
.avatar-text::before {
    content: none !important;
}

.avatar-text > * {
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    width: 100% !important;
    height: 100% !important;
}

/* 头像容器 */
.avatar-container {
    position: relative !important;
    display: inline-block !important;
    line-height: 1 !important;
}

    .avatar-container .user-avatar {
        border-radius: 50% !important;
        object-fit: cover !important;
        display: block !important;
    }

        /* 图片加载失败时显示文字头像 */
        .avatar-container .user-avatar.loading-error {
            display: none !important;
        }

            .avatar-container .user-avatar.loading-error + .avatar-text {
                display: inline-flex !important;
            }

/* 颜色方案 */
.avatar-bg-1 {
    background-color: #007bff !important;
}

.avatar-bg-2 {
    background-color: #28a745 !important;
}

.avatar-bg-3 {
    background-color: #dc3545 !important;
}

.avatar-bg-4 {
    background-color: #ffc107 !important;
}

.avatar-bg-5 {
    background-color: #17a2b8 !important;
}

.avatar-bg-6 {
    background-color: #6f42c1 !important;
}

.avatar-bg-7 {
    background-color: #fd7e14 !important;
}

.avatar-bg-8 {
    background-color: #20c997 !important;
}

.avatar-bg-9 {
    background-color: #e83e8c !important;
}

.avatar-bg-10 {
    background-color: #6c757d !important;
}

/* 使用table-cell布局确保完美居中 */
.avatar-text-table {
    display: table-cell !important;
    width: 40px !important;
    height: 40px !important;
    border-radius: 50% !important;
    background-color: #007bff !important;
    color: white !important;
    font-weight: bold !important;
    font-size: 16px !important;
    text-align: center !important;
    vertical-align: middle !important;
    line-height: 1 !important;
}

    .avatar-text-table.avatar-text-sm {
        width: 30px !important;
        height: 30px !important;
        font-size: 12px !important;
    }

    .avatar-text-table.avatar-text-lg {
        width: 60px !important;
        height: 60px !important;
        font-size: 20px !important;
    }
/* 确保文字头像在所有情况下都是圆形 */
.avatar-text, .avatar-text-sm, .avatar-text-lg {
    border-radius: 50% !important;
    aspect-ratio: 1 / 1; /* 确保宽高比为1:1 */
}

    /* 强制文字居中 */
    .avatar-text::before {
        content: '';
        display: inline-block;
        height: 100%;
        vertical-align: middle;
    }

    .avatar-text span {
        display: inline-block;
        vertical-align: middle;
        line-height: 1;
    }

/* 响应式设计 */
@media (max-width: 992px) {
    .header-container {
        padding: 10px 15px;
    }

    .nav-menu {
        order: 3;
    }

    .search-area {
        order: 2;
        width: 100%;
        margin: 10px 0;
        min-width: auto;
    }

    .user-area {
        order: 1;
        margin-left: auto;
        margin-bottom: 0;
    }

    .content-row {
        gap: 15px;
    }

    .content-sidebar {
        width: 250px;
    }
}

@media (max-width: 768px) {
    .content-row {
        flex-direction: column;
        gap: 20px;
        min-height: auto;
    }

    .content-main {
        min-height: auto;
        padding: 15px;
    }

    .content-sidebar {
        width: 100%;
        min-height: auto;
    }

    /* 移动端调整内容区域顺序 */
    .content-wrapper {
        flex-direction: column;
    }

    .content-left {
        margin-right: 0;
        order: 1; /* 移动端文章列表在上 */
        width: 100%;
    }

    .content-right {
        order: 2; /* 移动端边栏在下 */
        width: 100%;
        margin-top: 30px;
    }
    /* 移动端：恢复自然文档流，图片在上 */
    .article-item,
    .article-item.has-image {
        flex-direction: column;
    }

    /*    .article-img {
        margin-left: 0;
        margin-bottom: 15px;
        width: 100%;
        height: auto;
        max-height: 200px;
    }*/
    .article-img {
        width: 100%;
        height: auto;
        margin-left: 0;
        max-height: 200px;
    }
    /* 移动端边栏调整为横向排列 */
    .sidebar-container {
        display: flex;
        flex-wrap: wrap;
        gap: 15px;
    }

    .sidebar-box {
        flex: 1;
        min-width: 250px;
    }

    .pagination {
        gap: 3px;
    }

    .page-item {
        padding: 6px 8px;
        min-width: 30px;
    }

    /*二级频道*/
    .channel-list {
        padding: 8px 15px;
    }

        .channel-list li {
            margin-right: 10px;
        }

        .channel-list a {
            padding: 6px 12px;
            font-size: 14px;
        }

    /*搜索结果*/
    .search-content-full {
        padding: 10px 0;
    }

        .search-content-full .container {
            padding: 0 10px;
        }
}

@media (max-width: 576px) {
    .content-wrapper {
        padding: 0 10px;
    }

    .content-main {
        padding: 10px;
    }
}
