/* --- 基础样式重置 --- */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: "Microsoft YaHei", sans-serif;
}

body {
    background-color: #f8f9fa;
    color: #333;
    line-height: 1.6;
}

/* --- 导航栏样式 (修复变形) --- */
header {
    background: white;
    box-shadow: 0 2px 10px rgba(0,0,0,0.05);
    padding: 1rem 5%;
}

nav {
    display: flex;
    justify-content: space-between;
    align-items: center;
    max-width: 1200px;
    margin: 0 auto;
}

.logo {
    font-size: 24px;
    font-weight: bold;
    color: #007bff;
}

nav ul {
    display: flex;
    list-style: none;
    gap: 20px;
}

nav ul li a {
    text-decoration: none;
    color: #555;
    font-weight: 500;
    padding: 8px 16px;
    transition: all 0.3s;
    white-space: nowrap; /* 核心修复：防止文字换行变形 */
}

nav ul li a:hover {
    color: #007bff;
    background: #e7f3ff;
    border-radius: 6px;
}

/* --- 搜索区域 --- */
.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 40px 20px;
}

.filter-section {
    text-align: center;
    margin-bottom: 40px;
}

.filter-section h1 {
    margin-bottom: 20px;
    color: #222;
}

.search-section {
    display: flex;
    justify-content: center;
    gap: 10px;
}

.search-section input {
    width: 300px;
    padding: 12px 20px;
    border: 2px solid #ddd;
    border-radius: 8px;
    outline: none;
    transition: border-color 0.3s;
}

.search-section input:focus {
    border-color: #ffb800;
}

.search-section button {
    padding: 0 25px;
    background: #ffb800;
    color: white;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    font-weight: bold;
}

/* --- 资料 Block 网格布局 --- */
.page-title {
    margin-bottom: 25px;
    padding-left: 10px;
    border-left: 5px solid #ffb800;
}

.material-grid {
    display: grid;
    /* 每行自动填充，每个 block 最小 300px */
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 25px;
}

/* 单个 Block 的样式 (对应 main.js 生成的结构) */
.data-block {
    background: white;
    border-radius: 15px;
    padding: 25px;
    border: 1px solid #eaeaea;
    display: flex;
    flex-direction: column;
    transition: transform 0.3s, box-shadow 0.3s;
}

.data-block:hover {
    transform: translateY(-8px);
    box-shadow: 0 15px 30px rgba(0,0,0,0.1);
}

.data-block h3 {
    color: #333;
    margin-bottom: 15px;
    font-size: 1.25rem;
}

.main-content {
    color: #666;
    font-size: 0.9rem;
    margin-bottom: 20px;
    flex-grow: 1; /* 自动填满空间，让底部对齐 */
}

/* 底部价格和按钮 */
.block-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-top: 1px solid #f5f5f5;
    padding-top: 15px;
}

.price-tag {
    font-size: 1.3rem;
    font-weight: bold;
    color: #e63946;
}

.price-tag.free {
    color: #2a9d8f;
}

.view-btn {
    background: #007bff;
    color: white;
    padding: 8px 20px;
    border-radius: 20px;
    text-decoration: none;
    font-size: 0.85rem;
    transition: background 0.3s;
}

.view-btn:hover {
    background: #0056b3;
}
footer {
    background: #333;
    color: #d83b3b;
    padding: 40px 5%;
    text-align: center;
    margin-top: 50px;
}

/* 预览容器自适应处理 */
#preview-container {
    max-height: 70vh; /* 限制高度，防止太长 */
    overflow-y: auto;
    border: 2px solid #eee;
    background-color: #525659; /* 模仿 PDF 阅读器的深色底 */
}

#pdf-preview-canvas {
    margin: 0 auto;
    box-shadow: 0 0 10px rgba(0,0,0,0.1);
}

#watermark-layer div {
    /* 辅助倾斜和间距 */
    user-select: none;
    font-weight: bold;
}


/* 预览区域：固定高度，负责“切掉”多余部分 */
/* 1. 窗户：大小固定 */
/* 容器：窗户大小固定 */
/* 1. 预览窗口：固定高度，负责截断 */
.preview-area {
    width: 100% !important;
    height: 160px !important;    /* 窗口高度固定 */
    background: #f0f0f0 !important;
    overflow: hidden !important;  /* 核心：切掉 160px 以下的所有内容 */
    position: relative !important;
    display: block !important;    /* 必须是 block，不能是 flex */
}

/* 2. PDF 画布：宽度铺满，高度随比例自然生长 */
.preview-area canvas {
    width: 100% !important;
    height: auto !important;      /* 核心：强制比例正常，绝不准垂直压缩 */
    display: block !important;
    position: absolute !important;
    top: 0 !important;            /* 贴紧顶部展示，确保标题清晰 */
    left: 0 !important;
}


/* 预览区域：确保比例不畸形的关键 */
.preview-area {
    width: 100%;
    height: 160px;
    background: #f0f0f0;
    overflow: hidden;    /* 切掉底部，防止看到畸形的长图 */
    position: relative;
    display: block;      /* 强制 block，避免 flex 挤压 canvas */
}

.preview-area canvas {
    width: 100% !important;
    height: auto !important; /* 强制等比缩放，绝不拉伸 */
    position: absolute;
    top: 0;
    left: 0;
}

/* 付费相关 UI 样式 */
.pay-badge {
    position: absolute;
    top: 10px;
    right: 10px;
    background: #ff4d4f;
    color: white;
    padding: 2px 8px;
    font-size: 12px;
    border-radius: 4px;
    z-index: 5;
}

.price-tag {
    color: #e63946;
    font-weight: bold;
    font-size: 1.1rem;
}

.pay-btn {
    background: #ffb800 !important; /* 付费按钮使用橙色区分 */
}