/* ==================== 基础重置与全局样式 ==================== */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Microsoft YaHei', "微软雅黑", "PingFang SC", -apple-system, BlinkMacSystemFont, Arial, sans-serif;
    background-color: #f5f7fa;
    color: #333;
    line-height: 1.6;
    overflow-x: hidden;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

a {
    color: #0066cc;
    text-decoration: none;
    transition: all 0.3s ease;
}

a:hover {
    color: #004499;
    text-decoration: none;
}

img {
    max-width: 100%;
    height: auto;
    display: block;
}

.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 20px;
}

/* ==================== 头部导航 ==================== */
.header {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    padding: 0;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
    position: sticky;
    top: 0;
    z-index: 1000;
    transition: all 0.3s ease;
}

.header.scrolled {
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15);
}

.header .container {
    display: flex;
    flex-direction: column;
}

.header-main {
    display: flex;
    align-items: center;
    padding: 15px 0;
    width: 100%;
}

.logo {
    display: flex;
    align-items: center;
    gap: 12px;
    text-decoration: none;
    color: white;
    flex-shrink: 0;
}

.logo-img {
    height: 48px;
    width: auto;
    border-radius: 6px;
    object-fit: contain;
}

.logo h1 {
    font-size: 32px;
    font-weight: bold;
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.3);
    margin: 0;
}

.logo h1 a {
    color: white;
    text-decoration: none;
    font-size: 24px;
    font-weight: bold;
    transition: transform 0.3s ease;
}

.logo h1 a:hover {
    transform: scale(1.05);
}

.header-actions {
    display: flex;
    gap: 10px;
    align-items: center;
    margin-left: auto;
}

.logo h1 a {
    color: white;
    text-decoration: none;
    font-size: 24px;
    font-weight: bold;
    transition: transform 0.3s ease;
}

.logo h1 a:hover {
    transform: scale(1.05);
}

.nav {
    background: rgba(0, 0, 0, 0.1);
}

.nav ul {
    list-style: none;
    display: flex;
    gap: 5px;
    align-items: center;
    flex-wrap: wrap;
}

.nav li {
    flex-shrink: 0;
}

.nav a {
    display: block;
    padding: 12px 18px;
    color: white;
    font-weight: 500;
    text-decoration: none;
    transition: all 0.3s ease;
    white-space: nowrap;
}

.nav a:hover,
.nav a.active {
    background: rgba(255, 255, 255, 0.15);
    text-decoration: none;
}

/* 顶部操作按钮 */
.btn-action {
    display: inline-block;
    padding: 8px 20px;
    color: white;
    background: rgba(255, 255, 255, 0.15);
    border: 1px solid rgba(255, 255, 255, 0.3);
    border-radius: 6px;
    font-size: 14px;
    font-weight: 500;
    text-decoration: none;
    transition: all 0.3s ease;
    cursor: pointer;
}

.btn-action:hover {
    background: rgba(255, 255, 255, 0.25);
    border-color: rgba(255, 255, 255, 0.5);
    transform: translateY(-1px);
    color: white;
    text-decoration: none;
}

.btn-register {
    background: rgba(255, 255, 255, 0.25);
    border-color: rgba(255, 255, 255, 0.5);
}

.btn-register:hover {
    background: white;
    color: #667eea;
    border-color: white;
}

/* 汉堡菜单按钮 */
.hamburger {
    display: none;
    flex-direction: column;
    cursor: pointer;
    padding: 5px;
    z-index: 1001;
}

.hamburger span {
    width: 25px;
    height: 3px;
    background: white;
    margin: 3px 0;
    transition: all 0.3s ease;
    border-radius: 2px;
}

.hamburger.active span:nth-child(1) {
    transform: rotate(45deg) translate(5px, 5px);
}

.hamburger.active span:nth-child(2) {
    opacity: 0;
}

.hamburger.active span:nth-child(3) {
    transform: rotate(-45deg) translate(7px, -6px);
}

/* ==================== 主内容区域 ==================== */
.main {
    padding: 40px 0;
    min-height: calc(100vh - 300px);
}

.main .container {
    display: flex;
    gap: 30px;
}

.content {
    flex: 1;
    min-width: 0;
}

.sidebar {
    width: 320px;
    flex-shrink: 0;
}

/* ==================== 文章卡片 ==================== */
.post-item {
    background: white;
    padding: 15px;
    margin-bottom: 0;
    border-radius: 0;
    box-shadow: none;
    border-bottom: 1px solid #f0f0f0;
    display: flex;
    gap: 15px;
    align-items: flex-start;
    transition: all 0.3s ease;
}

.post-item:last-child {
    border-bottom: none;
}

.post-item:hover {
    background: #fafafa;
}

.post-image {
    flex-shrink: 0;
    width: 200px;
}

.post-image img {
    width: 100%;
    height: 140px;
    object-fit: cover;
    border-radius: 6px;
    transition: transform 0.3s ease;
}

.post-image img:hover {
    transform: scale(1.05);
}

.post-content {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
}

.post-title {
    font-size: 15px;
    margin: 0 0 6px 0 !important;
    line-height: 1.5;
    font-weight: 600;
    padding: 0;
}

.post-title a {
    color: #333;
    text-decoration: none;
    transition: color 0.3s ease;
    display: inline-block;
}

.post-title a:hover {
    color: #667eea;
}

.post-meta {
    font-size: 12px;
    color: #999;
    margin: 0 0 6px 0;
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    padding: 0;
}

.post-meta span {
    display: flex;
    align-items: center;
    gap: 5px;
}

.post-meta i {
    font-size: 14px;
}

.post-excerpt {
    color: #666;
    margin: 0;
    line-height: 1.7;
    font-size: 14px;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    padding: 0;
}

.post-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 15px;
    padding-top: 15px;
    border-top: 1px solid #f0f0f0;
}

.read-more {
    color: #667eea;
    text-decoration: none;
    font-size: 14px;
    font-weight: 500;
    display: inline-flex;
    align-items: center;
    gap: 5px;
    transition: all 0.3s ease;
}

.read-more::after {
    content: '→';
    transition: transform 0.3s ease;
}

.read-more:hover::after {
    transform: translateX(5px);
}

.read-more:hover {
    color: #5a6fd6;
}

/* ==================== 文章详情页 ==================== */
.post-detail {
    background: white;
    padding: 35px;
    border-radius: 12px;
    box-shadow: 0 2px 12px rgba(0, 0, 0, 0.06);
    animation: fadeIn 0.5s ease;
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

.post-title-detail {
    font-size: 28px;
    margin-bottom: 15px;
    color: #333;
    line-height: 1.4;
}

.post-meta-detail {
    font-size: 14px;
    color: #888;
    margin-bottom: 25px;
    padding-bottom: 15px;
    border-bottom: 1px solid #eee;
    display: flex;
    flex-wrap: wrap;
    gap: 20px;
}

.post-meta-detail span {
    display: flex;
    align-items: center;
    gap: 5px;
}

.post-content {
    font-family: "Microsoft YaHei", "微软雅黑", "PingFang SC", "Hiragino Sans GB", "WenQuanYi Micro Hei", sans-serif;
    font-size: 17px;
    line-height: 1.9;
    color: #333;
    letter-spacing: normal;
    word-break: break-word;
}

.post-content p {
    margin-bottom: 1.5em;
    margin-top: 0;
}

.post-content h1,
.post-content h2,
.post-content h3,
.post-content h4,
.post-content h5,
.post-content h6 {
    font-weight: bold;
    margin: 1.5em 0 0.8em;
    color: #2c2c2c;
    line-height: 1.4;
}

.post-content h1 { font-size: 26px; }
.post-content h2 { font-size: 24px; }
.post-content h3 { font-size: 21px; }
.post-content h4 { font-size: 19px; }
.post-content h5,
.post-content h6 { font-size: 17px; }

/* 排除文章列表标题，避免被 .post-content h2 影响 */
.post-item .post-content .post-title {
    font-size: 15px !important;
    font-weight: 600 !important;
    margin: 0 0 6px 0 !important;
    line-height: 1.5 !important;
    padding: 0 !important;
}

.post-content img {
    max-width: 100% !important;
    width: auto !important;
    height: auto !important;
    display: block !important;
    margin: 1.5em auto !important;
    padding: 0 !important;
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

.post-content a {
    color: #0066cc;
    text-decoration: underline;
    text-underline-offset: 3px;
}

.post-content a:hover {
    color: #004499;
}

/* 排除标题链接，避免被 .post-content a 影响（必须放在 .post-content a 之后） */
.post-item .post-content .post-title a,
.post-item .post-content .post-title a:hover {
    color: #333 !important;
    text-decoration: none !important;
    text-underline-offset: 0 !important;
    font-weight: 600;
}

.post-item .post-content .post-title a:hover {
    color: #667eea !important;
}

.post-content ul,
.post-content ol {
    padding-left: 2em;
    margin-bottom: 1.5em;
}

.post-content li {
    margin-bottom: 0.5em;
    line-height: 1.8;
}

.post-content blockquote {
    border-left: 4px solid #667eea;
    padding: 15px 20px;
    margin: 1.5em 0;
    background: #f8f9ff;
    color: #555;
    font-style: italic;
    border-radius: 0 8px 8px 0;
}

.post-content code {
    background: #f5f5f5;
    padding: 2px 6px;
    border-radius: 4px;
    font-family: 'Consolas', 'Monaco', monospace;
    font-size: 0.9em;
    color: #e83e8c;
}

.post-content pre {
    background: #282c34;
    color: #abb2bf;
    padding: 20px;
    border-radius: 8px;
    overflow-x: auto;
    margin: 1.5em 0;
}

.post-content pre code {
    background: transparent;
    padding: 0;
    color: inherit;
}

.post-content hr {
    border: none;
    border-top: 2px solid #e8e8e8;
    margin: 2em 0;
}

/* 阅读进度条 */
.reading-progress {
    position: fixed;
    top: 0;
    left: 0;
    width: 0;
    height: 3px;
    background: linear-gradient(90deg, #667eea 0%, #764ba2 100%);
    z-index: 9999;
    transition: width 0.1s ease;
}

/* 点赞按钮 */
.like-btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 12px 24px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border: none;
    border-radius: 25px;
    cursor: pointer;
    font-size: 16px;
    font-weight: 500;
    transition: all 0.3s ease;
    box-shadow: 0 4px 15px rgba(102, 126, 234, 0.3);
}

.like-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(102, 126, 234, 0.4);
}

.like-btn:active {
    transform: translateY(0);
}

.like-btn.liked {
    background: linear-gradient(135deg, #f093fb 0%, #f5576c 100%);
}

.like-btn i {
    font-size: 20px;
}

/* ==================== 评论区 ==================== */
.comments-section {
    margin-top: 30px;
    padding-top: 30px;
    border-top: 2px solid #f0f0f0;
}

.comment-form {
    background: #f8f9fa;
    padding: 25px;
    border-radius: 12px;
    margin-bottom: 25px;
}

.comment-form h3 {
    margin-bottom: 20px;
    color: #333;
    font-size: 18px;
}

.form-group {
    margin-bottom: 20px;
}

.form-group label {
    display: block;
    margin-bottom: 8px;
    font-weight: 500;
    color: #555;
    font-size: 14px;
}

.form-control {
    width: 100%;
    padding: 12px 15px;
    border: 2px solid #e0e0e0;
    border-radius: 8px;
    font-size: 15px;
    transition: all 0.3s ease;
    background: white;
}

.form-control:focus {
    outline: none;
    border-color: #667eea;
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

.form-control::placeholder {
    color: #aaa;
}

textarea.form-control {
    min-height: 120px;
    resize: vertical;
    font-family: inherit;
}

.submit-btn {
    padding: 12px 30px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    font-size: 15px;
    font-weight: 500;
    transition: all 0.3s ease;
    box-shadow: 0 4px 15px rgba(102, 126, 234, 0.3);
}

.submit-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(102, 126, 234, 0.4);
}

.submit-btn:active {
    transform: translateY(0);
}

.comment-item {
    background: white;
    padding: 20px;
    margin-bottom: 15px;
    border-radius: 10px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
    transition: all 0.3s ease;
}

.comment-item:hover {
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.08);
}

.comment-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 10px;
}

.comment-author {
    font-weight: 600;
    color: #667eea;
}

.comment-date {
    font-size: 13px;
    color: #999;
}

.comment-content {
    color: #555;
    line-height: 1.7;
}

/* ==================== 侧边栏小部件 ==================== */
.widget {
    background: white;
    padding: 25px;
    margin-bottom: 20px;
    border-radius: 12px;
    box-shadow: 0 2px 12px rgba(0, 0, 0, 0.06);
    transition: all 0.3s ease;
    animation: fadeInRight 0.6s ease forwards;
    opacity: 0;
}

.widget:nth-child(1) { animation-delay: 0.1s; }
.widget:nth-child(2) { animation-delay: 0.2s; }
.widget:nth-child(3) { animation-delay: 0.3s; }
.widget:nth-child(4) { animation-delay: 0.4s; }

@keyframes fadeInRight {
    from {
        opacity: 0;
        transform: translateX(20px);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

.widget:hover {
    box-shadow: 0 4px 20px rgba(102, 126, 234, 0.12);
}

.widget-title {
    font-size: 18px;
    margin-bottom: 18px;
    padding-bottom: 12px;
    border-bottom: 2px solid #667eea;
    color: #333;
    font-weight: 600;
}

.widget-content {
    list-style: none;
}

.widget-content li {
    padding: 10px 0;
    border-bottom: 1px dashed #eee;
    transition: all 0.3s ease;
}

.widget-content li:last-child {
    border-bottom: none;
}

.widget-content li a {
    color: #555;
    text-decoration: none;
    font-size: 14px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    transition: all 0.3s ease;
}

.widget-content li a:hover {
    color: #667eea;
    padding-left: 5px;
}

.widget-content li a .count {
    background: #f0f0f0;
    padding: 2px 8px;
    border-radius: 12px;
    font-size: 12px;
    color: #888;
}

/* 搜索框 */
.search-form {
    display: flex;
    gap: 10px;
}

.search-input {
    flex: 1;
    padding: 10px 15px;
    border: 2px solid #e0e0e0;
    border-radius: 8px;
    font-size: 14px;
    transition: all 0.3s ease;
}

.search-input:focus {
    outline: none;
    border-color: #667eea;
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

.search-btn {
    padding: 10px 20px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    font-size: 14px;
    transition: all 0.3s ease;
}

.search-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 15px rgba(102, 126, 234, 0.3);
}

/* ==================== 分页 ==================== */
.pagination {
    display: flex;
    justify-content: center;
    gap: 10px;
    margin-top: 30px;
    flex-wrap: wrap;
}

.pagination a {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 40px;
    padding: 10px 15px;
    background: white;
    color: #333;
    text-decoration: none;
    border-radius: 8px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
    transition: all 0.3s ease;
    font-weight: 500;
}

.pagination a:hover,
.pagination a.active {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    transform: translateY(-2px);
    box-shadow: 0 4px 15px rgba(102, 126, 234, 0.3);
}

/* ==================== 页脚 ==================== */
.footer {
    background: linear-gradient(135deg, #2c3e50 0%, #34495e 100%);
    color: #bdc3c7;
    padding: 40px 0;
    text-align: center;
    margin-top: 50px;
}

.footer p {
    margin: 8px 0;
    font-size: 14px;
}

.footer a {
    color: #ecf0f1;
    text-decoration: none;
    transition: color 0.3s ease;
}

.footer a:hover {
    color: #667eea;
}

/* ==================== 返回顶部按钮 ==================== */
.back-to-top {
    position: fixed;
    bottom: 30px;
    right: 30px;
    width: 50px;
    height: 50px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border: none;
    border-radius: 50%;
    cursor: pointer;
    font-size: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 15px rgba(102, 126, 234, 0.4);
    transition: all 0.3s ease;
    opacity: 0;
    visibility: hidden;
    z-index: 999;
}

.back-to-top.visible {
    opacity: 1;
    visibility: visible;
}

.back-to-top:hover {
    transform: translateY(-5px);
    box-shadow: 0 6px 20px rgba(102, 126, 234, 0.5);
}

/* ==================== 加载动画 ==================== */
.loading {
    display: inline-block;
    width: 20px;
    height: 20px;
    border: 3px solid rgba(102, 126, 234, 0.3);
    border-radius: 50%;
    border-top-color: #667eea;
    animation: spin 0.8s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* ==================== 提示消息 ==================== */
.alert {
    padding: 15px 20px;
    margin-bottom: 20px;
    border-radius: 8px;
    font-size: 14px;
    animation: slideInDown 0.3s ease;
}

@keyframes slideInDown {
    from {
        opacity: 0;
        transform: translateY(-20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.alert-success {
    background: #d4edda;
    color: #155724;
    border: 1px solid #c3e6cb;
}

.alert-danger {
    background: #f8d7da;
    color: #721c24;
    border: 1px solid #f5c6cb;
}

.alert-info {
    background: #d1ecf1;
    color: #0c5460;
    border: 1px solid #bee5eb;
}

/* ==================== 响应式设计 ==================== */
@media (max-width: 992px) {
    .main .container {
        flex-direction: column;
    }
    
    .sidebar {
        width: 100%;
    }
    
    .post-detail {
        padding: 25px;
    }
}

@media (max-width: 768px) {
    .header .container {
        position: relative;
    }
    
    .logo-img {
        height: 36px;
    }
    
    .logo h1 {
        font-size: 22px;
    }
    
    .hamburger {
        display: flex;
    }
    
    .nav {
        position: fixed;
        top: 0;
        right: -100%;
        width: 280px;
        height: 100vh;
        background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
        padding: 80px 30px 30px;
        transition: right 0.3s ease;
        box-shadow: -5px 0 20px rgba(0, 0, 0, 0.2);
        z-index: 1000;
    }
    
    .nav.active {
        right: 0;
    }
    
    .nav ul {
        flex-direction: column;
        gap: 10px;
    }
    
    .nav ul li a {
        display: block;
        padding: 12px 15px;
        font-size: 16px;
    }
    
    .main {
        padding: 20px 0;
    }
    
    .post-item {
        flex-direction: column;
        padding: 15px;
        gap: 12px;
    }
    
    .post-image {
        width: 100%;
    }
    
    .post-image img {
        width: 100%;
        height: 200px;
        max-height: none;
    }
    
    .post-content {
        margin-top: 0;
        padding-top: 0;
    }
    
    .post-title {
        font-size: 15px;
        margin: 0 0 6px;
    }
    
    .post-meta {
        font-size: 12px;
        gap: 10px;
        margin: 0 0 6px;
    }
    
    .post-excerpt {
        font-size: 14px;
        line-height: 1.7;
        margin-bottom: 0;
        -webkit-line-clamp: 3;
    }
    
    .post-title-detail {
        font-size: 22px;
    }
    
    .post-meta-detail {
        flex-direction: column;
        gap: 10px;
    }
    
    .widget {
        padding: 20px;
    }
    
    .back-to-top {
        bottom: 20px;
        right: 20px;
        width: 45px;
        height: 45px;
        font-size: 18px;
    }
}

@media (max-width: 480px) {
    .container {
        padding: 0 15px;
    }
    
    .header .container {
        padding: 12px 15px;
    }
    
    .logo-img {
        height: 28px;
    }
    
    .logo h1 {
        font-size: 20px;
    }
    
    .logo h1 a {
        font-size: 20px;
    }
    
    .post-item,
    .post-detail {
        padding: 12px;
    }
    
    .post-image img {
        height: 180px;
    }
    
    .post-title {
        font-size: 15px;
        margin: 0 0 5px;
    }
    
    .post-meta {
        font-size: 11px;
        gap: 6px;
        margin: 0 0 5px;
    }
    
    .post-excerpt {
        font-size: 13px;
        line-height: 1.6;
        margin-bottom: 0;
    }
    
    .post-title-detail {
        font-size: 20px;
    }
    
    .post-content {
        font-size: 16px;
    }
    
    .comment-form {
        padding: 18px;
    }
    
    .search-form {
        flex-direction: column;
    }
    
    .pagination a {
        padding: 8px 12px;
        font-size: 14px;
    }
}

/* ==================== 触摸设备优化 ==================== */
@media (hover: none) and (pointer: coarse) {
    .post-item:hover,
    .widget:hover {
        transform: none;
    }
    
    .read-more:hover::after,
    .like-btn:hover,
    .submit-btn:hover,
    .search-btn:hover {
        transform: none;
    }
    
    .form-control:focus {
        box-shadow: none;
    }
}

/* ==================== 暗色模式支持（可选） ==================== */
@media (prefers-color-scheme: dark) {
    /* 如果将来需要支持暗色模式，可以在这里添加 */
}

/* ==================== 减少动画偏好 ==================== */
@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}
