/* 主题变量定义 */
:root {
    /* 默认主题 - 浅色主题 */
    --bg-primary: #f8f9fa;
    --bg-secondary: #ffffff;
    --bg-tertiary: #e9ecef;
    --text-primary: #333333;
    --text-secondary: #6c757d;
    --text-muted: #999999;
    --border-color: #dee2e6;
    --primary-color: #007bff;
    --primary-hover: #0056b3;
    --secondary-color: #6c757d;
    --success-color: #28a745;
    --danger-color: #dc3545;
    --warning-color: #ffc107;
    --info-color: #17a2b8;
    --card-shadow: 0 0.125rem 0.25rem rgba(0, 0, 0, 0.075);
    --card-hover-shadow: 0 0.5rem 1rem rgba(0, 0, 0, 0.15);
    --navbar-bg: #212529;
    --navbar-text: #ffffff;
    --sidebar-header-gradient: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    --footer-gradient: linear-gradient(135deg, #2c3e50 0%, #34495e 100%);
}

/* 深色主题 */
body.dark-theme {
    --bg-primary: #1a1a1a;
    --bg-secondary: #2d2d2d;
    --bg-tertiary: #404040;
    --text-primary: #ffffff;
    --text-secondary: #cccccc;
    --text-muted: #999999;
    --border-color: #404040;
    --primary-color: #4dabf7;
    --primary-hover: #339af0;
    --secondary-color: #adb5bd;
    --success-color: #51cf66;
    --danger-color: #ff6b6b;
    --warning-color: #ffd43b;
    --info-color: #339af0;
    --card-shadow: 0 0.125rem 0.25rem rgba(0, 0, 0, 0.3);
    --card-hover-shadow: 0 0.5rem 1rem rgba(0, 0, 0, 0.5);
    --navbar-bg: #121212;
    --navbar-text: #ffffff;
    --sidebar-header-gradient: linear-gradient(135deg, #373b44 0%, #4286f4 100%);
    --footer-gradient: linear-gradient(135deg, #121212 0%, #1e1e1e 100%);
}

/* 自定义样式 */
body {
    font-family: 'Noto Sans SC', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background-color: var(--bg-primary);
    color: var(--text-primary);
    line-height: 1.6;
    transition: background-color 0.3s ease, color 0.3s ease;
}

/* 导航栏样式 */
.navbar {
    background-color: var(--navbar-bg) !important;
    box-shadow: 0 2px 4px rgba(0,0,0,.1);
    transition: background-color 0.3s ease;
    position: relative;
    z-index: 1000;
}

.navbar-brand {
    color: var(--navbar-text) !important;
    font-weight: bold;
    font-size: 1.5rem;
    white-space: nowrap; /* 防止品牌名称换行 */
    transition: color 0.3s ease;
    flex-shrink: 0;
}

/* 确保导航栏在各种屏幕尺寸下都能正确排列 */
.navbar-collapse {
    flex-grow: 1;
    justify-content: flex-start;
}

.navbar-nav {
    flex-direction: row;
    align-items: center;
    margin: 0;
    padding: 0;
}

.navbar-nav .nav-item {
    margin-right: 1rem;
    white-space: nowrap;
}

.navbar-nav .nav-link {
    color: var(--navbar-text) !important;
    transition: color 0.3s ease;
}

.navbar-nav .nav-link:hover {
    color: var(--primary-color) !important;
}

/* 搜索表单优化 */
.form-inline {
    flex-shrink: 0;
    margin-left: auto;
}

.form-inline .form-control {
    width: auto;
    min-width: 200px;
    background-color: var(--bg-secondary) !important;
    border-color: var(--border-color) !important;
    color: var(--text-primary) !important;
}

/* 用户菜单优化 */
.navbar-nav.ml-3 {
    margin-left: 1rem !important;
}

/* 卡片样式 */
.card {
    background-color: var(--bg-secondary) !important;
    border: none;
    border-radius: 10px;
    box-shadow: var(--card-shadow);
    transition: box-shadow 0.3s ease-in-out, background-color 0.3s ease;
}

.card:hover {
    box-shadow: var(--card-hover-shadow);
}

.card-header {
    background-color: var(--bg-secondary) !important;
    border-bottom: 1px solid var(--border-color);
    color: var(--text-primary);
    font-weight: 600;
    border-top-left-radius: 10px !important;
    border-top-right-radius: 10px !important;
    transition: background-color 0.3s ease, border-color 0.3s ease;
}

/* 文章列表样式 */
.content-section {
    background-color: var(--bg-secondary);
    border-radius: 10px;
    box-shadow: var(--card-shadow);
    transition: box-shadow 0.3s ease-in-out, background-color 0.3s ease;
    padding: 25px;
}

.content-section:hover {
    box-shadow: var(--card-hover-shadow);
}

.article-title {
    color: var(--text-primary);
    transition: color 0.3s ease;
    font-size: 1.8rem;
    font-weight: 600;
    margin-bottom: 12px;
}

.article-title:hover {
    color: var(--primary-color);
    text-decoration: none;
}

.article-metadata {
    padding-bottom: 10px;
    margin-bottom: 15px;
    border-bottom: 1px solid var(--border-color);
    font-size: 0.9rem;
    color: var(--text-secondary);
}

.article-content {
    line-height: 1.8;
    font-size: 16px;
    margin-bottom: 20px;
}

/* 优化文章内段落和标题 */
.article-content p {
    margin-bottom: 1.2rem;
    text-align: justify;
}

.article-content h1, 
.article-content h2, 
.article-content h3, 
.article-content h4, 
.article-content h5, 
.article-content h6 {
    margin-top: 2rem;
    margin-bottom: 1rem;
    font-weight: 600;
    line-height: 1.3;
    color: var(--text-primary);
}

.article-content h1 {
    font-size: 2rem;
}

.article-content h2 {
    font-size: 1.75rem;
    border-bottom: 2px solid #e9ecef;
    padding-bottom: 0.3rem;
}

.article-content h3 {
    font-size: 1.5rem;
}

.article-content ul, 
.article-content ol {
    margin-bottom: 1.2rem;
    padding-left: 1.5rem;
}

.article-content li {
    margin-bottom: 0.5rem;
}

.article-content blockquote {
    border-left: 4px solid #007bff;
    padding: 1rem 1.5rem;
    margin: 1.5rem 0;
    background-color: #f8f9fa;
    border-radius: 0 8px 8px 0;
    font-style: italic;
    color: #555;
}

.article-content code {
    background-color: #f8f9fa;
    padding: 0.2rem 0.4rem;
    border-radius: 4px;
    font-family: 'Consolas', 'Monaco', 'Courier New', monospace;
    font-size: 0.9rem;
    color: #e83e8c;
}

/* 按钮样式 */
.btn {
    border-radius: 6px;
    font-weight: 500;
    transition: all 0.3s ease;
}

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

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

.btn-outline-primary {
    color: var(--primary-color);
    border-color: var(--primary-color);
}

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

/* 表单样式 */
.form-control {
    background-color: var(--bg-secondary);
    color: var(--text-primary);
    border-radius: 6px;
    border: 1px solid var(--border-color);
    transition: border-color 0.3s ease, background-color 0.3s ease;
}

.form-control:focus {
    border-color: var(--primary-color);
    box-shadow: 0 0 0 0.2rem rgba(0, 123, 255, 0.25);
    background-color: var(--bg-secondary);
    color: var(--text-primary);
}

/* 分页样式 */
.pagination .page-link {
    background-color: var(--bg-secondary);
    color: var(--primary-color);
    border-color: var(--border-color);
    border-radius: 6px;
    margin: 0 2px;
    transition: all 0.3s ease;
}

.pagination .page-item.active .page-link {
    background-color: var(--primary-color);
    border-color: var(--primary-color);
    color: white;
}

.pagination .page-link:hover {
    color: var(--primary-hover);
    background-color: var(--bg-tertiary);
    border-color: var(--primary-color);
}

/* 侧边栏样式 */
.sidebar-widget {
    margin-bottom: 25px;
    overflow: hidden;
}

.sidebar-widget:last-child {
    margin-bottom: 0;
}

/* 优化侧边栏标题样式 */
.sidebar-widget .card-header {
    background: var(--sidebar-header-gradient);
    color: white;
    font-weight: 600;
    font-size: 1rem;
    text-align: center;
    padding: 12px 15px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    border-bottom: none;
}

/* 优化侧边栏内容区 */
.sidebar-widget .card-body {
    padding: 15px;
    background-color: var(--bg-secondary);
    transition: background-color 0.3s ease;
}

/* 优化分类列表样式 */
.sidebar-widget ul.list-unstyled li {
    padding: 8px 0;
    border-bottom: 1px solid var(--border-color);
    transition: all 0.2s ease;
}

.sidebar-widget ul.list-unstyled li:last-child {
    border-bottom: none;
}

.sidebar-widget ul.list-unstyled li:hover {
    padding-left: 8px;
    background-color: var(--bg-tertiary);
}

.sidebar-widget ul.list-unstyled li a {
    color: var(--text-primary);
    text-decoration: none;
    display: block;
    transition: color 0.3s ease;
}

.sidebar-widget ul.list-unstyled li a:hover {
    color: var(--primary-color);
}

/* 优化标签云样式 */
.sidebar-widget .btn-group .btn {
    font-size: 0.875rem;
    margin: 4px;
    padding: 6px 12px;
    border-radius: 20px;
    transition: all 0.3s ease;
    text-transform: capitalize;
    background-color: var(--bg-tertiary);
    color: var(--text-primary);
    border-color: var(--border-color);
}

.sidebar-widget .btn-group .btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 3px 6px rgba(0, 0, 0, 0.1);
    background-color: var(--primary-color);
    color: white;
    border-color: var(--primary-color);
}

/* 优化查看更多按钮 */
.sidebar-widget .btn-outline-secondary {
    margin-top: 10px;
    width: 100%;
    font-size: 0.875rem;
    transition: all 0.3s ease;
    color: var(--secondary-color);
    border-color: var(--secondary-color);
}

.sidebar-widget .btn-outline-secondary:hover {
    background-color: var(--secondary-color);
    color: white;
    transform: translateY(-1px);
}

/* 标签样式 */
.badge {
    font-weight: 500;
    padding: 6px 10px;
    border-radius: 20px;
    background-color: var(--primary-color);
    color: white;
}

.badge-info {
    background-color: var(--info-color);
}

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

/* 评论样式 */
.comment {
    border-left: 3px solid var(--primary-color);
    background-color: var(--bg-secondary);
    transition: background-color 0.3s ease;
}

.comment.reply {
    border-left: 2px solid var(--secondary-color);
}

.comment-header {
    border-bottom: 1px dashed var(--border-color);
    padding-bottom: 8px;
    margin-bottom: 10px;
}

/* 页脚样式 */
footer {
    background: var(--footer-gradient);
    color: #fff;
    padding: 40px 0 20px;
    margin-top: 60px;
    box-shadow: 0 -2px 10px rgba(0, 0, 0, 0.1);
}

/* 优化页脚标题样式 */
footer h5 {
    font-weight: 600;
    margin-bottom: 1.2rem;
    font-size: 1.1rem;
    color: #fff;
    position: relative;
    padding-bottom: 8px;
}

footer h5::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 0;
    width: 40px;
    height: 2px;
    background: var(--sidebar-header-gradient);
}

/* 优化页脚内容样式 */
footer p {
    color: #ddd;
    font-size: 0.95rem;
    line-height: 1.6;
    margin-bottom: 0;
}

/* 优化页脚链接样式 */
footer ul.list-unstyled li {
    margin-bottom: 0.8rem;
}

footer ul.list-unstyled li a {
    color: #ddd;
    text-decoration: none;
    font-size: 0.95rem;
    transition: all 0.3s ease;
    display: inline-block;
}

footer ul.list-unstyled li a:hover {
    color: #fff;
    transform: translateX(5px);
}

/* 优化社交媒体图标样式 */
footer .social-icon {
    margin-right: 10px;
    margin-bottom: 10px;
    background-color: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.2);
    transition: all 0.3s ease;
}

footer .social-icon:hover {
    background-color: rgba(255, 255, 255, 0.2);
    border-color: rgba(255, 255, 255, 0.4);
    transform: translateY(-3px);
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.2);
}

/* 优化页脚分隔线 */
footer hr {
    background-color: rgba(255, 255, 255, 0.1);
    margin: 20px 0;
}

/* 优化版权信息 */
footer .text-center {
    padding-top: 20px;
    border-top: 1px solid rgba(255, 255, 255, 0.1);
    font-size: 0.9rem;
    color: #ccc;
}

/* 响应式调整 */
@media (max-width: 768px) {
    .container {
        padding: 0 15px;
    }
    
    .content-section {
        padding: 20px 15px;
    }
    
    .article-content {
        font-size: 15px;
    }
    
    /* 移动端导航栏优化 */
    .navbar-nav {
        margin-top: 15px;
        flex-direction: column !important; /* 确保在移动端垂直堆叠 */
    }
    
    .navbar-nav .nav-item {
        margin-bottom: 8px;
        margin-right: 0 !important; /* 移除移动端的右侧间距 */
    }
    
    /* 确保移动端导航栏不换行 */
    .navbar {
        flex-wrap: wrap;
    }
    
    /* 移动端导航栏容器优化 */
    .container {
        padding-right: 15px;
        padding-left: 15px;
    }
    
    /* 移动端搜索表单优化 */
    .form-inline {
        margin: 15px 0;
        width: 100%;
        flex-direction: row;
    }
    
    .form-inline .form-control {
        width: calc(100% - 80px);
        margin-right: 8px;
        min-width: 0; /* 移除最小宽度限制 */
    }
    
    .form-inline .btn {
        width: 72px;
        padding: 6px 12px;
    }
    
    /* 移动端文章标题优化 */
    .article-title {
        font-size: 1.5rem;
    }
    
    /* 移动端侧边栏优化 */
    .sidebar-widget {
        margin-top: 30px;
    }
    
    /* 移动端页脚优化 */
    footer .col-md-6,
    footer .col-md-3 {
        margin-bottom: 30px;
    }
    
    footer .col-md-6:last-child,
    footer .col-md-3:last-child {
        margin-bottom: 0;
    }
    
    /* 移动端按钮优化 */
    .btn {
        padding: 8px 16px;
        font-size: 0.95rem;
    }
    
    /* 移动端标签优化 */
    .badge {
        font-size: 0.85rem;
        padding: 5px 8px;
    }
    
    /* 移动端评论优化 */
    .comment {
        padding: 15px;
        margin-bottom: 20px;
    }
    
    /* 移动端表单优化 */
    .form-group {
        margin-bottom: 15px;
    }
    
    .form-control {
        padding: 10px 15px;
    }
}

/* 更小屏幕的额外优化 */
@media (max-width: 480px) {
    body {
        font-size: 15px;
    }
    
    .article-title {
        font-size: 1.35rem;
    }
    
    .article-content h1 {
        font-size: 1.75rem;
    }
    
    .article-content h2 {
        font-size: 1.5rem;
    }
    
    .article-content h3 {
        font-size: 1.35rem;
    }
    
    /* 优化移动端导航栏品牌 */
    .navbar-brand {
        font-size: 1.25rem;
    }
    
    /* 优化移动端搜索表单 */
    .form-inline {
        flex-direction: column;
        align-items: stretch;
    }
    
    .form-inline .form-control {
        width: 100%;
        margin-right: 0;
        margin-bottom: 10px;
    }
    
    .form-inline .btn {
        width: 100%;
    }
}

/* 动画效果 */
.fade-in {
    animation: fadeIn 0.5s ease-in;
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

/* 加载动画 */
.loading {
    display: inline-block;
    width: 20px;
    height: 20px;
    border: 3px solid rgba(0,0,0,.3);
    border-radius: 50%;
    border-top-color: #007bff;
    animation: spin 1s ease-in-out infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* 社交媒体图标 */
.social-icon {
    display: inline-block;
    width: 36px;
    height: 36px;
    background-color: #007bff;
    color: white;
    border-radius: 50%;
    text-align: center;
    line-height: 36px;
    margin-right: 5px;
    transition: all 0.3s ease;
}

.social-icon:hover {
    background-color: #0056b3;
    transform: translateY(-2px);
}