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

body {
    font-family: 'Microsoft YaHei', Arial, sans-serif;
    line-height: 1.6;
    color: #333;
    background-image: url("bg_blog.jpg");
}

.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 15px;
}

/* 头部样式 */
/* 更强的立体阴影效果 */
header {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    padding: 1rem 0;
    box-shadow: 0 6px 25px rgba(0,0,0,0.2),
                0 2px 10px rgba(0,0,0,0.1),
                inset 0 1px 0 rgba(255,255,255,0.2);
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 1000;
    transition: all 0.3s ease;
}

header.scrolled {
    box-shadow: 0 8px 30px rgba(0,0,0,0.25),
                0 3px 15px rgba(0,0,0,0.15),
                inset 0 1px 0 rgba(255,255,255,0.2);
}

/* 为 body 添加顶部内边距，避免内容被固定头部遮挡 */
body {
    font-family: 'Microsoft YaHei', Arial, sans-serif;
    line-height: 1.6;
    color: #333;
    background-color: #f5f5f5;
    padding-top: 120px; /* 根据头部高度调整 */
}

.header-content {
    display: flex;
    justify-content: space-between;
    align-items: center;
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 15px;
}

.logo h1 {
    font-size: 1.8rem;
    margin-bottom: 0.2rem;
    font-weight: bold;
}

.logo p {
    font-size: 0.9rem;
    opacity: 0.9;
}

nav ul {
    display: flex;
    list-style: none;
}

nav ul li {
    margin-left: 1.5rem;
}

nav ul li a {
    color: white;
    text-decoration: none;
    padding: 0.5rem 1rem;
    border-radius: 4px;
    transition: all 0.3s;
    font-weight: 500;
    position: relative;
}

nav ul li a:hover {
    background-color: rgba(255,255,255,0.2);
    transform: translateY(-1px);
}

/* 为登录/注册按钮添加特殊样式 */
nav ul li a[href*="login"], 
nav ul li a[href*="register"] {
    background: rgba(255,255,255,0.1);
    border: 1px solid rgba(255,255,255,0.3);
}

nav ul li a[href*="login"]:hover,
nav ul li a[href*="register"]:hover {
    background: rgba(255,255,255,0.2);
    border-color: rgba(255,255,255,0.5);
}

/* 滚动时头部效果 */
header.scrolled {
    box-shadow: 0 6px 25px rgba(0,0,0,0.2);
    padding: 0.7rem 0;
}

/* 响应式设计调整 */
@media (max-width: 768px) {
    body {
        padding-top: 70px; /* 移动端调整 */
    }
    
    .header-content {
        flex-direction: column;
        text-align: center;
        padding: 0.5rem 15px;
    }
    
    nav ul {
        margin-top: 0.5rem;
        justify-content: center;
    }
    
    nav ul li {
        margin-left: 0.8rem;
        margin-right: 0.8rem;
    }
    
    header {
        padding: 0.5rem 0;
    }
    
    header.scrolled {
        padding: 0.3rem 0;
    }
}

/* 搜索区域 */
.search-section {
    padding: 3rem 0;
    color: white;
    margin: 2rem 0;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    background-size: cover;
    background-position: center;
    border-radius: 10px;
}

.search-section h1 {
    margin-bottom: 2rem;
    font-size: 2.2rem;
    text-align: center;
}

.search-form {
    display: flex;
    max-width: 600px;
    margin: 0 auto;
    background: white;
    border-radius: 50px;
    overflow: hidden;
    box-shadow: 
        0 8px 25px rgba(0,0,0,0.15),
        0 4px 12px rgba(0,0,0,0.1),
        inset 0 1px 0 rgba(255,255,255,0.8);
    border: 1px solid rgba(255,255,255,0.3);
    position: relative;
}

.search-form::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    border-radius: 50px;
    background: linear-gradient(135deg, 
        rgba(255,255,255,0.1) 0%, 
        rgba(255,255,255,0.05) 100%);
    pointer-events: none;
}

.search-form input {
    flex: 1;
    padding: 1rem 1.5rem;
    border: none;
    font-size: 1rem;
    outline: none;
    background: transparent;
    position: relative;
    z-index: 1;
}

.search-form input::placeholder {
    color: #999;
}

.search-form button {
    padding: 1rem 2rem;
    background: linear-gradient(135deg, #ff6b6b 0%, #ff5252 100%);
    color: white;
    border: none;
    cursor: pointer;
    font-size: 1rem;
    transition: all 0.3s;
    white-space: nowrap;
    position: relative;
    z-index: 1;
    font-weight: 600;
    text-shadow: 0 1px 2px rgba(0,0,0,0.2);
    box-shadow: 
        inset 0 1px 0 rgba(255,255,255,0.3),
        inset 0 -1px 0 rgba(0,0,0,0.1);
}

.search-form button:hover {
    background: linear-gradient(135deg, #ff5252 0%, #ff4040 100%);
    transform: translateY(-1px);
    box-shadow: 
        inset 0 1px 0 rgba(255,255,255,0.3),
        inset 0 -1px 0 rgba(0,0,0,0.1),
        0 4px 12px rgba(255,107,107,0.4);
}

.search-form button:active {
    transform: translateY(0);
    box-shadow: 
        inset 0 2px 4px rgba(0,0,0,0.2),
        inset 0 1px 0 rgba(255,255,255,0.1);
}

/* 统计信息区域 */
.stats-section {
    display: flex;
    justify-content: center;
    gap: 1rem;
    margin: 1.5rem 0;
}

.stat-bar-item {
    display: flex;
    align-items: center;
    background: linear-gradient(135deg, #667eea, #764ba2);
    color: white;
    padding: 0.8rem 1.5rem;
    border-radius: 25px;
    font-size: 0.95rem;
    box-shadow: 0 2px 8px rgba(0,0,0,0.15);
    transition: all 0.3s ease;
}

.stat-bar-item:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0,0,0,0.2);
}

.stat-bar-item .stat-label {
    font-weight: 500;
    margin-right: 0.5rem;
}

.stat-bar-item .stat-number {
    font-weight: bold;
    font-size: 1.1rem;
}

/* 分类区域 */
.categories {
    background: white;
    padding: 1.5rem;
    border-radius: 8px;
    margin: 1.5rem 0;
    box-shadow: 0 2px 10px rgba(0,0,0,0.1);
}

.categories h2 {
    margin-bottom: 1rem;
    color: #333;
    font-size: 1.2rem;
    padding-bottom: 0.5rem;
    border-bottom: 2px solid #667eea;
}

.category-buttons {
    display: flex;
    flex-wrap: wrap;
    gap: 0.8rem;
}

.category-btn {
    padding: 0.6rem 1.2rem;
    color: white;
    text-decoration: none;
    border-radius: 20px;
    transition: all 0.3s;
    font-size: 0.9rem;
    font-weight: 500;
    box-shadow: 0 2px 5px rgba(0,0,0,0.1);
}

.category-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0,0,0,0.2);
}

/* 最新资源区域 */
.latest-resources {
    margin: 2rem 0;
}

.section-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.5rem;
    padding-bottom: 0.5rem;
    border-bottom: 2px solid #e0e0e0;
}

.section-header h2 {
    color: #333;
    font-size: 1.3rem;
}

/* 资源网格布局 - 正确的书籍封面比例 3:4 */
.resource-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 1.5rem;
}

.resource-item {
    background: white;
    border-radius: 8px;
    overflow: hidden;
    box-shadow: 0 2px 10px rgba(0,0,0,0.1);
    transition: all 0.3s ease;
}

.resource-item:hover {
    transform: translateY(-5px);
    box-shadow: 0 8px 25px rgba(0,0,0,0.15);
}

/* 修复：正确的书籍封面比例 3:4 */
.resource-image {
    width: 100%;
    height: 0;
    padding-bottom: 133.33%; /* 3:4 比例 */
    position: relative;
    overflow: hidden;
}

.resource-image img {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform 0.3s ease;
}

.resource-item:hover .resource-image img {
    transform: scale(1.1);
}

.no-image {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: #f0f0f0;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #666;
    font-size: 0.9rem;
}

.resource-info {
    padding: 1rem;
}

.resource-info h3 {
    font-size: 0.95rem;
    margin-bottom: 0.8rem;
    line-height: 1.4;
    height: 2.8em;
    overflow: hidden;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
}

/* 修复：移除下划线 */
.resource-item a {
    text-decoration: none;
    color: inherit;
}

/* 修复：首页最新收录 - 浏览和下载数与分类标签在同一行 */
.resource-meta-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 0.5rem;
    margin-top: 0.5rem;
}

.home-category-tag {
    display: inline-block;
    padding: 0.3rem 0.8rem;
    color: white;
    border-radius: 12px;
    font-size: 0.75rem;
}

.home-resource-stats {
    display: flex;
    gap: 0.8rem;
    font-size: 0.75rem;
    color: #666;
}

.home-view-count, .home-download-count {
    display: flex;
    align-items: center;
    gap: 0.2rem;
}

/* 筛选条件 */
.filters {
    background: white;
    padding: 1.5rem;
    border-radius: 8px;
    margin: 2rem 0;
    box-shadow: 0 2px 10px rgba(0,0,0,0.1);
}

.filters h3 {
    margin-bottom: 1rem;
    color: #333;
}

.filter-options {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
}

.filter-btn {
    padding: 0.5rem 1rem;
    background: #f8f9fa;
    color: #333;
    text-decoration: none;
    border-radius: 20px;
    transition: all 0.3s;
    border: 1px solid #e9ecef;
    font-size: 0.9rem;
}

.filter-btn.active,
.filter-btn:hover {
    background: #667eea;
    color: white;
    border-color: #667eea;
}

/* 搜索结果列表 */
.search-results {
    background: white;
    border-radius: 8px;
    overflow: hidden;
    box-shadow: 0 2px 10px rgba(0,0,0,0.1);
    margin: 2rem 0;
}

.search-results h2 {
    padding: 1.5rem;
    margin: 0;
    background: #f8f9fa;
    border-bottom: 1px solid #e9ecef;
    font-size: 1.2rem;
    color: #333;
}

.result-item {
    display: flex;
    padding: 1.5rem;
    border-bottom: 1px solid #eee;
    transition: background-color 0.3s;
    gap: 1.5rem;
}

.result-item:hover {
    background-color: #f9f9f9;
}

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

/* 搜索结果图片 - 正确的书籍封面比例 3:4 */
.result-image {
    width: 90px;
    height: 120px; /* 3:4 比例 */
    flex-shrink: 0;
    border-radius: 4px;
    overflow: hidden;
    position: relative;
    background: #f0f0f0;
}

.result-image img {
    width: 100%;
    height: 100%;
    object-fit: cover; /* 保持比例，裁剪多余部分 */
}

.result-image .no-image {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: #f0f0f0;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #666;
    font-size: 0.8rem;
    text-align: center;
    padding: 0.5rem;
}

/* 搜索结果页的所有元数据在一行显示 */
.result-meta-full {
    display: flex;
    align-items: center;
    gap: 1rem;
    flex-wrap: wrap;
    margin-top: 0.5rem;
}

.search-category-tag {
    display: inline-block;
    padding: 0.3rem 0.8rem;
    color: white;
    border-radius: 12px;
    font-size: 0.75rem;
    background: #667eea;
}

.disk-type {
    display: flex;
    align-items: center;
    gap: 0.3rem;
    font-size: 0.85rem;
    color: #666;
}

.disk-type img {
    width: 16px;
    height: 16px;
}

.file-size, .update-time, .search-view-count, .search-download-count {
    color: #888;
    font-size: 0.85rem;
    white-space: nowrap;
}

.search-view-count, .search-download-count {
    display: flex;
    align-items: center;
    gap: 0.2rem;
}

.highlight {
    background-color: #ffeb3b;
    padding: 0.1rem 0.2rem;
    border-radius: 2px;
}

/* 分页 */
.pagination {
    display: flex;
    justify-content: center;
    gap: 0.5rem;
    margin: 2rem 0;
}

.pagination a {
    padding: 0.5rem 1rem;
    background: white;
    color: #333;
    text-decoration: none;
    border-radius: 4px;
    border: 1px solid #ddd;
    transition: all 0.3s;
}

.pagination a.active,
.pagination a:hover {
    background: #667eea;
    color: white;
    border-color: #667eea;
}

/* 表单样式 */
.auth-form {
    max-width: 400px;
    margin: 2rem auto;
    background: white;
    padding: 2rem;
    border-radius: 8px;
    box-shadow: 0 2px 10px rgba(0,0,0,0.1);
}

.auth-form h2 {
    text-align: center;
    margin-bottom: 1.5rem;
    color: #333;
}

.form-group {
    margin-bottom: 1rem;
}

.form-group label {
    display: block;
    margin-bottom: 0.5rem;
    font-weight: bold;
}

.form-group input,
.form-group select,
.form-group textarea {
    width: 100%;
    padding: 0.75rem;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-size: 1rem;
}

.btn {
    display: inline-block;
    padding: 0.75rem 1.5rem;
    background: #667eea;
    color: white;
    text-decoration: none;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-size: 1rem;
    transition: background-color 0.3s;
}

.btn:hover {
    background: #5a6fd8;
}

.btn-primary {
    background: #667eea;
}

.btn-success {
    background: #51cf66;
}

.btn-danger {
    background: #ff6b6b;
}

/* 警告框 */
.alert {
    padding: 1rem;
    border-radius: 4px;
    margin-bottom: 1rem;
}

.alert-success {
    background: #d4edda;
    color: #155724;
    border: 1px solid #c3e6cb;
}

.alert-error {
    background: #f8d7da;
    color: #721c24;
    border: 1px solid #f5c6cb;
}

/* 底部样式 */
footer {
    background: #333;
    color: white;
    text-align: center;
    padding: 2rem 0;
    margin-top: 3rem;
}

/* 响应式设计 */
@media (max-width: 768px) {
    .header-content {
        flex-direction: column;
        text-align: center;
    }
    
    nav ul {
        margin-top: 1rem;
        justify-content: center;
    }
    
    .search-form {
        flex-direction: column;
        border-radius: 8px;
    }
    
    .search-form input,
    .search-form button {
        width: 100%;
        border-radius: 4px;
        margin-bottom: 0.5rem;
    }
    
    .stats-section {
        flex-wrap: wrap;
        justify-content: center;
    }
    
    .stat-bar-item {
        flex: 0 0 calc(50% - 0.5rem);
        justify-content: center;
    }
    
    .section-header {
        flex-direction: column;
        gap: 1rem;
        align-items: flex-start;
    }
    
    .resource-grid {
        grid-template-columns: repeat(2, 1fr);
    }
    
    .result-item {
        flex-direction: column;
    }
    
    .result-image {
        width: 100%;
        height: 200px;
    }
    
    .result-meta-full {
        flex-direction: column;
        align-items: flex-start;
        gap: 0.5rem;
    }
    
    .resource-meta-row {
        flex-direction: column;
        align-items: flex-start;
        gap: 0.5rem;
    }
    
    .category-buttons {
        justify-content: center;
    }
}

@media (max-width: 480px) {
    .resource-grid {
        grid-template-columns: 1fr;
    }
    
    .stats-section {
        flex-direction: column;
    }
    
    .stat-bar-item {
        flex: 1;
        min-width: 100%;
    }
    
    .search-section {
        margin: 1rem -15px;
        border-radius: 0;
    }
    
    .home-resource-stats {
        flex-direction: column;
        gap: 0.3rem;
    }
}

/* 搜索结果页优化样式 - 严格单行控制 */
.result-item .result-info h3 {
    margin: 0 0 8px 0;
    line-height: 1.4;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    max-width: 100%;
    font-size: 16px;
    font-weight: 600;
    /* 确保严格单行 */
    display: block;
    width: 100%;
}

.result-item .result-info h3 a {
    display: block;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    width: 100%;
    color: #333;
    text-decoration: none;
}

.result-item .result-info h3 a:hover {
    color: #007bff;
}

.result-item .result-info .resource-description {
    margin: 0 0 10px 0;
    line-height: 1.5;
    color: #666;
    overflow: hidden;
    text-overflow: ellipsis;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    max-height: 3em;
    font-size: 14px;
    /* 确保多行省略 */
    word-wrap: break-word;
}

/* 关键词高亮优化 */
.highlight {
    background-color: #ffeb3b;
    color: #333;
    padding: 1px 2px;
    border-radius: 2px;
    font-weight: bold;
}

/* 确保在移动端也能正确显示 */
@media (max-width: 768px) {
    .result-item .result-info h3 {
        font-size: 15px;
    }
    
    .result-item .result-info .resource-description {
        font-size: 13px;
        -webkit-line-clamp: 2;
        max-height: 2.8em;
    }
}