/* 默认主题变量 - 优化版本 */
:root {
    --primary-color: #4ab1f1;
    --primary-dark: #3498db;
    --primary-light: #87ceeb;
    --secondary-color: #2c3e50;
    --accent-color: #1abc9c;
    --success-color: #28a745;
    --warning-color: #ffc107;
    --danger-color: #dc3545;
    --text-color: #333333;
    --text-light: #666666;
    --text-lighter: #999999;
    --bg-color: #ffffff;
    --bg-light: #f8f9fa;
    --bg-lighter: #f1f3f4;
    --border-color: #e1e8ed;
    --shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
    --shadow-hover: 0 5px 20px rgba(0, 0, 0, 0.15);
    --border-radius: 8px;
    --transition: all 0.3s ease;
}

/* 基础重置和排版 - 优化版本 */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html {
    font-size: 16px;
    scroll-behavior: smooth;
    line-height: 1.6;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    line-height: 1.6;
    color: var(--text-color);
    background: linear-gradient(135deg, #f5f7fa 0%, #c3cfe2 100%);
    min-height: 100vh;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* 容器和布局 - 优化版本 */
.container {
    width: 100%;
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 15px;
}

.row {
    display: flex;
    flex-wrap: wrap;
    margin: 0 -15px;
}

.col {
    flex: 1;
    padding: 0 15px;
}

.col-12 {
    flex: 0 0 100%;
    padding: 0 15px;
}

.col-md-8 {
    flex: 0 0 66.666667%;
    padding: 0 15px;
}

.col-md-4 {
    flex: 0 0 33.333333%;
    padding: 0 15px;
}

/* 响应式网格 - 优化版本 */
@media (max-width: 768px) {
    .col-md-8, .col-md-4 {
        flex: 0 0 100%;
    }

    .container {
        padding: 0 10px;
    }
    
    html {
        font-size: 14px;
    }
}

/* 工具类 - 优化版本 */
.text-center { text-align: center; }
.text-left { text-align: left; }
.text-right { text-align: right; }
.text-muted { color: var(--text-lighter); }
.text-muted a {color: var(--text-lighter) !important; text-decoration: none; }
.text-muted a:hover {color: var(--text-lighter) !important;text-decoration: underline;}
.mb-2 { margin-bottom: 0.5rem; }
.mb-3 { margin-bottom: 1rem; }
.mb-4 { margin-bottom: 1.5rem; }
.mt-3 { margin-top: 1rem; }
.mt-4 { margin-top: 1.5rem; }
.py-5 { padding: 3rem 0; }
.lead { font-size: 1.1rem; font-weight: 300; }
.d-none { display: none; }
.d-block { display: block; }
.d-flex { display: flex; }

/* 按钮样式 - 优化版本 */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.75rem 1.5rem;
    background: var(--primary-color);
    color: white;
    text-decoration: none;
    border: none;
    border-radius: var(--border-radius);
    font-size: 0.9rem;
    font-weight: 500;
    cursor: pointer;
    transition: var(--transition);
    text-align: center;
    line-height: 1;
    position: relative;
    overflow: hidden;
}

.btn::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255,255,255,0.2), transparent);
    transition: left 0.5s ease;
}

.btn:hover::before {
    left: 100%;
}

.btn:hover {
    background: var(--primary-dark);
    transform: translateY(-2px);
    box-shadow: var(--shadow-hover);
}

.btn:active {
    transform: translateY(0);
}

.btn-primary {
    background: var(--primary-color);
    color: white;
}

.btn-success {
    background: var(--success-color);
    color: white;
}

.btn-warning {
    background: var(--warning-color);
    color: #212529;
}

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

.btn-outline-primary {
    background: transparent;
    color: var(--primary-color);
    border: 2px solid var(--primary-color);
}

.btn-outline-primary:hover {
    background: var(--primary-color);
    color: white;
}

.btn-sm {
    padding: 0.5rem 1rem;
    font-size: 0.8rem;
}

/* 头部样式 - 优化版本 */
.header {
    background: linear-gradient(135deg, var(--primary-color) 0%, var(--primary-dark) 100%);
    color: white;
    box-shadow: var(--shadow);
    position: sticky;
    top: 0;
    z-index: 1000;
    backdrop-filter: blur(10px);
}

.navbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem 0;
    flex-wrap: wrap;
}

.logo {
    font-size: 1.5rem;
    font-weight: bold;
    color: white;
    text-decoration: none;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    transition: var(--transition);
}

.logo:hover {
    color: white;
    transform: scale(1.05);
}

/* 主要内容区域 - 优化版本 */
.main-content {
    display: flex;
    gap: 2rem;
    padding: 2rem 0;
    min-height: calc(100vh - 200px);
}

.content-area {
    flex: 2;
    background: var(--bg-color);
    border-radius: var(--border-radius);
    box-shadow: var(--shadow);
    padding: 2rem;
    backdrop-filter: blur(10px);
    border: 1px solid rgba(255,255,255,0.1);
}

.sidebar {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
    min-width: 300px;
}

/* 文章列表 - 优化版本 */
.post-list {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

.post-card {
    background: var(--bg-color);
    border-radius: var(--border-radius);
    box-shadow: var(--shadow);
    padding: 1.5rem;
    transition: var(--transition);
    border-left: 4px solid var(--primary-color);
    position: relative;
    overflow: hidden;
    border: 1px solid rgba(255,255,255,0.1);
}

.post-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(74, 177, 241, 0.1), transparent);
    transition: left 0.5s ease;
}

.post-card:hover::before {
    left: 100%;
}

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

.post-title {
    font-size: 1.3rem;
    margin-bottom: 0.75rem;
    line-height: 1.3;
    color: var(--secondary-color);
}

.post-title a {
    color: var(--secondary-color);
    text-decoration: none;
    transition: var(--transition);
    background: linear-gradient(135deg, var(--secondary-color) 0%, var(--primary-color) 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.post-title a:hover {
    background: linear-gradient(135deg, var(--primary-color) 0%, var(--accent-color) 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.post-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 1rem;
    margin-bottom: 1rem;
    font-size: 0.85rem;
    color: var(--text-light);
}

.post-meta span {
    display: flex;
    align-items: center;
    gap: 0.3rem;
    padding: 0.2rem 0.5rem;
    background: var(--bg-light);
    border-radius: 15px;
}

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

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

.tag {
    background: var(--primary-light);
    color: white;
    padding: 0.3rem 0.8rem;
    border-radius: 15px;
    font-size: 0.8rem;
    text-decoration: none;
    transition: var(--transition);
    font-weight: 500;
}

.tag:hover {
    background: var(--primary-color);
    transform: scale(1.05);
    box-shadow: var(--shadow);
}

/* 侧边栏组件 - 优化版本 */
.sidebar-widget {
    background: var(--bg-color);
    border-radius: var(--border-radius);
    box-shadow: var(--shadow);
    padding: 1.5rem;
    backdrop-filter: blur(10px);
    border: 1px solid rgba(255,255,255,0.1);
    transition: var(--transition);
}

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

.widget-title {
    font-size: 1.1rem;
    font-weight: bold;
    color: var(--secondary-color);
    margin-bottom: 1rem;
    padding-bottom: 0.5rem;
    border-bottom: 2px solid var(--primary-light);
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.category-list {
    list-style: none;
}

.category-item {
    padding: 0.75rem 0;
    border-bottom: 1px solid var(--border-color);
    transition: var(--transition);
}

.category-item:hover {
    background-color: var(--bg-lighter);
    margin: 0 -1rem;
    padding: 0.75rem 1rem;
    border-radius: 4px;
}

.category-item:last-child {
    border-bottom: none;
}

.category-item a {
    color: var(--text-color);
    text-decoration: none;
    transition: var(--transition);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.category-item a:hover {
    color: var(--primary-color);
}

.category-count {
    background: var(--primary-light);
    color: white;
    padding: 0.2rem 0.6rem;
    border-radius: 12px;
    font-size: 0.75rem;
    font-weight: 500;
}

/* 列表组 - 优化版本 */
.list-group {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.list-group-item {
    padding: 0.75rem 1rem;
    background: var(--bg-light);
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius);
    text-decoration: none;
    color: var(--text-color);
    transition: var(--transition);
    display: flex;
    flex-direction: column;
    align-items: flex-start;
}

.list-group-item:hover {
    background: var(--primary-light);
    color: white;
    transform: translateX(5px);
}

.list-group-item h6 {
    margin: 0 0 0.25rem 0;
    font-size: 0.9rem;
    line-height: 1.3;
    font-weight: 600;
}

.list-group-item small {
    font-size: 0.8rem;
    opacity: 0.8;
}

/* 分页 - 优化版本 */
.pagination {
    display: flex;
    justify-content: center;
    gap: 0.5rem;
    margin-top: 2rem;
    flex-wrap: wrap;
}

.page-link {
    padding: 0.5rem 1rem;
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius);
    color: var(--text-color);
    text-decoration: none;
    transition: var(--transition);
    font-size: 0.9rem;
    font-weight: 500;
}

.page-link:hover {
    background: var(--primary-color);
    color: white;
    border-color: var(--primary-color);
    transform: translateY(-1px);
}

.page-current {
    background: var(--primary-color);
    color: white;
    border-color: var(--primary-color);
    box-shadow: var(--shadow);
}

/* 文章详情 - 关键优化部分 */
.article-header {
    margin-bottom: 2rem;
    padding-bottom: 1rem;
    border-bottom: 2px solid var(--border-color);
    text-align: center;
}

.article-title {
    font-size: 2.2rem;
    color: var(--secondary-color);
    margin-bottom: 1rem;
    line-height: 1.2;
    word-wrap: break-word;
    overflow-wrap: break-word;
    background: linear-gradient(135deg, var(--secondary-color) 0%, var(--primary-color) 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.article-body {
    line-height: 1.8;
    font-size: 1.05rem;
    max-width: 100%;
    overflow-wrap: break-word;
    word-wrap: break-word;
    word-break: break-word;
    hyphens: auto;
}

/* 文章内容中的图片自适应 */
.article-body img {
    max-width: 100%;
    height: auto;
    display: block;
    margin: 1.5rem auto;
    border-radius: var(--border-radius);
    box-shadow: var(--shadow);
    transition: var(--transition);
}

.article-body img:hover {
    transform: scale(1.02);
    box-shadow: var(--shadow-hover);
}

/* 文章中的表格自适应 */
.article-body table {
    width: 100%;
    max-width: 100%;
    border-collapse: collapse;
    margin: 1.5rem 0;
    overflow-x: auto;
    display: block;
    box-shadow: var(--shadow);
    border-radius: var(--border-radius);
}

.article-body table th,
.article-body table td {
    padding: 0.75rem;
    border: 1px solid var(--border-color);
    text-align: left;
}

.article-body table th {
    background: linear-gradient(135deg, var(--primary-color) 0%, var(--primary-dark) 100%);
    color: white;
    font-weight: 600;
}

.article-body table tr:nth-child(even) {
    background: var(--bg-light);
}

.article-body table tr:hover {
    background: var(--bg-lighter);
}

.article-body h2 {
    color: var(--secondary-color);
    margin: 2rem 0 1rem 0;
    font-size: 1.5rem;
    word-wrap: break-word;
    overflow-wrap: break-word;
    padding-bottom: 0.5rem;
    border-bottom: 2px solid var(--primary-light);
}

.article-body h3 {
    color: var(--secondary-color);
    margin: 1.5rem 0 0.75rem 0;
    font-size: 1.25rem;
    word-wrap: break-word;
    overflow-wrap: break-word;
}

.article-body p {
    margin-bottom: 1rem;
    word-wrap: break-word;
    overflow-wrap: break-word;
}

.article-body ul, .article-body ol {
    margin-bottom: 1rem;
    padding-left: 2rem;
    word-wrap: break-word;
    overflow-wrap: break-word;
}

.article-body li {
    margin-bottom: 0.5rem;
    word-wrap: break-word;
    overflow-wrap: break-word;
}

/* 代码块样式 */
.article-body pre {
    background: var(--secondary-color);
    color: white;
    padding: 1rem;
    border-radius: var(--border-radius);
    overflow-x: auto;
    margin: 1.5rem 0;
    font-size: 0.9rem;
    line-height: 1.5;
    box-shadow: var(--shadow);
}

.article-body code {
    background: var(--bg-lighter);
    padding: 0.2rem 0.4rem;
    border-radius: 4px;
    font-size: 0.9rem;
    word-break: break-all;
    font-family: 'Courier New', monospace;
}

.article-body pre code {
    background: none;
    padding: 0;
    border-radius: 0;
}

.article-footer {
    margin-top: 2rem;
    padding-top: 1rem;
    border-top: 1px solid var(--border-color);
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 1rem;
}

/* 页脚 - 优化版本 */
.footer {
    background: linear-gradient(135deg, var(--secondary-color) 0%, #1a2530 100%);
    color: white;
    padding: 2rem 0;
    margin-top: 3rem;
    backdrop-filter: blur(10px);
}

.footer-content {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 1rem;
}

.footer-links {
    display: flex;
    gap: 1.5rem;
    list-style: none;
    margin: 0;
    padding: 0;
}

.footer-links a {
    color: white;
    text-decoration: none;
    transition: var(--transition);
    padding: 0.5rem;
    border-radius: 4px;
}

.footer-links a:hover {
    background: rgba(255,255,255,0.1);
    transform: translateY(-2px);
}

/* 错误页面 - 优化版本 */
.error-container {
    text-align: center;
    padding: 4rem 2rem;
    background: var(--bg-color);
    border-radius: var(--border-radius);
    box-shadow: var(--shadow);
    margin: 2rem auto;
    max-width: 600px;
}

.error-code {
    font-size: 6rem;
    color: var(--primary-color);
    margin-bottom: 1rem;
    font-weight: bold;
    background: linear-gradient(135deg, var(--primary-color) 0%, var(--accent-color) 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.error-message {
    font-size: 1.5rem;
    color: var(--secondary-color);
    margin-bottom: 2rem;
}

/* 响应式设计 - 优化版本 */
@media (max-width: 768px) {
    .navbar {
        flex-direction: column;
        gap: 1rem;
        text-align: center;
    }

    .nav-menu {
        order: 2;
        width: 100%;
        justify-content: center;
        flex-wrap: wrap;
        gap: 1rem;
    }

    .search-form {
        order: 3;
        width: 100%;
        justify-content: center;
    }

    .search-input {
        min-width: auto;
        flex: 1;
        max-width: 300px;
    }

    .main-content {
        flex-direction: column;
    }

    .sidebar {
        min-width: auto;
    }

    .post-meta {
        flex-direction: column;
        gap: 0.5rem;
    }

    .footer-content {
        flex-direction: column;
        gap: 1rem;
        text-align: center;
    }

    .footer-links {
        justify-content: center;
    }

    .article-title {
        font-size: 1.8rem;
    }

    /* 移动端表格优化 */
    .article-body table {
        display: block;
        overflow-x: auto;
        white-space: nowrap;
    }
    
    .article-footer {
        flex-direction: column;
        text-align: center;
    }
}

@media (max-width: 480px) {
    .content-area, .sidebar-widget {
        padding: 1rem;
    }

    .post-card {
        padding: 1rem;
    }

    .post-title {
        font-size: 1.1rem;
    }

    .article-body ul, .article-body ol {
        padding-left: 1.5rem;
    }
    
    .error-code {
        font-size: 4rem;
    }
    
    .error-message {
        font-size: 1.2rem;
    }
}

/* 动画效果 - 优化版本 */
@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.fade-in {
    animation: fadeIn 0.6s ease-in-out;
}

@keyframes slideIn {
    from {
        opacity: 0;
        transform: translateX(-20px);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

.slide-in {
    animation: slideIn 0.5s ease-out;
}

@keyframes bounceIn {
    0% {
        opacity: 0;
        transform: scale(0.3);
    }
    50% {
        opacity: 1;
        transform: scale(1.05);
    }
    70% {
        transform: scale(0.9);
    }
    100% {
        opacity: 1;
        transform: scale(1);
    }
}

.bounce-in {
    animation: bounceIn 0.8s ease-out;
}

/* 滚动条样式 - 优化版本 */
::-webkit-scrollbar {
    width: 8px;
}

::-webkit-scrollbar-track {
    background: var(--bg-light);
    border-radius: 4px;
}

::-webkit-scrollbar-thumb {
    background: var(--primary-light);
    border-radius: 4px;
    transition: var(--transition);
}

::-webkit-scrollbar-thumb:hover {
    background: var(--primary-color);
}

/* 选择文本样式 */
::selection {
    background: var(--primary-light);
    color: white;
}

::-moz-selection {
    background: var(--primary-light);
    color: white;
}

/* 焦点样式 */
:focus {
    outline: 2px solid var(--primary-color);
    outline-offset: 2px;
}

/* 打印样式 */
@media print {
    .header, .sidebar, .footer {
        display: none;
    }

    .content-area {
        box-shadow: none;
        padding: 0;
    }

    body {
        background: white;
        color: black;
    }
    
    .post-card {
        break-inside: avoid;
    }
}

/* 友情链接样式 - 优化版本 */
.friend-links {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.friend-link {
    display: inline-flex;
    align-items: center;
    gap: 0.3rem;
    padding: 6px 12px;
    background: var(--bg-light);
    color: var(--text-color);
    text-decoration: none;
    border-radius: 20px;
    font-size: 0.85rem;
    transition: var(--transition);
    border: 1px solid var(--border-color);
}

.friend-link:hover {
    background: var(--primary-color);
    color: white;
    transform: translateY(-2px);
    box-shadow: var(--shadow);
}

/* 公告样式优化 */
.list-group-item {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
}

.list-group-item h6 {
    margin-bottom: 5px;
    font-weight: 600;
    color: var(--secondary-color);
}

/* 自定义数据小部件样式 - 优化版本 */
.custom-data-widget {
    margin-bottom: 1.5rem;
    background: var(--bg-color);
    border-radius: var(--border-radius);
    box-shadow: var(--shadow);
    padding: 1.5rem;
    backdrop-filter: blur(10px);
    border: 1px solid rgba(255,255,255,0.1);
    transition: var(--transition);
}

.custom-data-widget:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-hover);
}

.custom-data-widget .widget-title {
    font-size: 1.1rem;
    font-weight: bold;
    color: var(--secondary-color);
    margin-bottom: 1rem;
    padding-bottom: 0.5rem;
    border-bottom: 2px solid var(--primary-light);
}

.custom-data-widget .post-list {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.custom-data-widget .post-item {
    padding: 0.75rem;
    border-bottom: 1px solid var(--border-color);
    transition: var(--transition);
    border-radius: 4px;
}

.custom-data-widget .post-item:hover {
    background-color: var(--bg-lighter);
    transform: translateX(5px);
}

.custom-data-widget .post-item:last-child {
    border-bottom: none;
}

.custom-data-widget .post-link {
    text-decoration: none;
    color: var(--text-color);
    display: block;
}

.custom-data-widget .post-link h5 {
    margin: 0 0 0.5rem 0;
    font-size: 0.95rem;
    line-height: 1.3;
    color: var(--secondary-color);
    transition: var(--transition);
}

.custom-data-widget .post-link:hover h5 {
    color: var(--primary-color);
}

.custom-data-widget .post-meta {
    display: flex;
    gap: 1rem;
    font-size: 0.8rem;
    color: var(--text-light);
}

.custom-data-widget .category-list {
    list-style: none;
}

.custom-data-widget .category-item {
    padding: 0.5rem 0;
    border-bottom: 1px solid var(--border-color);
    transition: var(--transition);
}

.custom-data-widget .category-item:hover {
    background-color: var(--bg-lighter);
    margin: 0 -0.5rem;
    padding: 0.5rem;
    border-radius: 4px;
}

.custom-data-widget .category-item:last-child {
    border-bottom: none;
}

.custom-data-widget .category-item a {
    display: flex;
    justify-content: space-between;
    align-items: center;
    color: var(--text-color);
    text-decoration: none;
    transition: var(--transition);
}

.custom-data-widget .category-item a:hover {
    color: var(--primary-color);
}

.custom-data-widget .category-count {
    background: var(--primary-light);
    color: white;
    padding: 0.1rem 0.5rem;
    border-radius: 10px;
    font-size: 0.7rem;
}

/* 广告样式 */
.header-ad, .sidebar-ad, .post-ad {
    margin: 1rem 0;
    text-align: center;
    padding: 1rem;
    background: var(--bg-light);
    border-radius: var(--border-radius);
    border: 1px solid var(--border-color);
}

.header-ad {
    margin: 0;
    border-radius: 0;
    border-left: none;
    border-right: none;
}

/* 加载动画 */
.loading {
    display: inline-block;
    width: 20px;
    height: 20px;
    border: 3px solid rgba(255,255,255,.3);
    border-radius: 50%;
    border-top-color: #fff;
    animation: spin 1s ease-in-out infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* 回到顶部按钮 */
.scroll-to-top {
    position: fixed;
    bottom: 30px;
    right: 30px;
    background: var(--primary-color);
    color: white;
    border: none;
    border-radius: 50%;
    width: 50px;
    height: 50px;
    font-size: 1.2rem;
    cursor: pointer;
    opacity: 0;
    visibility: hidden;
    transition: var(--transition);
    z-index: 1000;
    box-shadow: var(--shadow-hover);
    display: flex;
    align-items: center;
    justify-content: center;
}

.scroll-to-top.show {
    opacity: 1;
    visibility: visible;
}

.scroll-to-top:hover {
    background: var(--primary-dark);
    transform: translateY(-3px);
    box-shadow: 0 8px 25px rgba(0,0,0,0.2);
}