/* ===== 基础样式重置 ===== */
*, *::before, *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

:root {
    --primary: #8B4513;
    --primary-dark: #5D2F0D;
    --primary-light: #D2691E;
    --secondary: #2C3E50;
    --accent: #C9A227;
    --bg-primary: #FDF6E3;
    --bg-secondary: #F5E6D3;
    --bg-card: #FFFEF8;
    --text-primary: #2C3E50;
    --text-secondary: #5D6D7E;
    --text-light: #95A5A6;
    --border: #D5C4A1;
    --shadow: rgba(0, 0, 0, 0.1);
    --radius: 8px;
    --transition: all 0.3s ease;
}

html {
    font-size: 16px;
    scroll-behavior: smooth;
}

body {
    font-family: "Noto Serif SC", "Source Han Serif SC", "SimSun", serif;
    line-height: 1.8;
    color: var(--text-primary);
    background: var(--bg-primary);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

/* ===== 布局容器 ===== */
.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 20px;
}

/* ===== 头部导航 ===== */
.site-header {
    background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
    color: white;
    padding: 1rem 0;
    box-shadow: 0 2px 10px var(--shadow);
    position: sticky;
    top: 0;
    z-index: 1000;
}

.site-header .container {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 1rem;
}

.logo a {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    color: white;
    text-decoration: none;
    font-size: 1.5rem;
    font-weight: 700;
}

.logo-icon {
    width: 32px;
    height: 32px;
}

.main-nav ul {
    display: flex;
    list-style: none;
    gap: 2rem;
}

.main-nav a {
    color: rgba(255, 255, 255, 0.9);
    text-decoration: none;
    font-size: 1rem;
    transition: var(--transition);
    position: relative;
}

.main-nav a:hover {
    color: white;
}

.main-nav a::after {
    content: '';
    position: absolute;
    bottom: -4px;
    left: 0;
    width: 0;
    height: 2px;
    background: var(--accent);
    transition: var(--transition);
}

.main-nav a:hover::after {
    width: 100%;
}

/* ===== 搜索框 ===== */
.search-box form {
    display: flex;
    gap: 0.5rem;
}

.search-box input {
    padding: 0.5rem 1rem;
    border: none;
    border-radius: var(--radius);
    background: rgba(255, 255, 255, 0.2);
    color: white;
    width: 200px;
    transition: var(--transition);
}

.search-box input::placeholder {
    color: rgba(255, 255, 255, 0.6);
}

.search-box input:focus {
    outline: none;
    background: rgba(255, 255, 255, 0.3);
    width: 250px;
}

.search-box button {
    padding: 0.5rem;
    border: none;
    border-radius: var(--radius);
    background: var(--accent);
    color: var(--primary-dark);
    cursor: pointer;
    transition: var(--transition);
}

.search-box button:hover {
    background: #D4AF37;
}

.search-box button svg {
    width: 20px;
    height: 20px;
    display: block;
}

/* ===== 主要内容区 ===== */
.main-content {
    flex: 1;
    padding: 2rem 0;
}

/* ===== Hero 区域 ===== */
.hero {
    background: linear-gradient(135deg, var(--bg-secondary) 0%, var(--bg-primary) 100%);
    padding: 4rem 0;
    text-align: center;
    margin-bottom: 3rem;
    border-bottom: 3px solid var(--border);
}

.hero h1 {
    font-size: 2.5rem;
    color: var(--primary);
    margin-bottom: 1rem;
}

.hero p {
    font-size: 1.2rem;
    color: var(--text-secondary);
    max-width: 600px;
    margin: 0 auto 2rem;
}

.hero-stats {
    display: flex;
    justify-content: center;
    gap: 3rem;
    margin-top: 2rem;
}

.stat-item {
    text-align: center;
}

.stat-number {
    font-size: 2.5rem;
    font-weight: 700;
    color: var(--primary);
    display: block;
}

.stat-label {
    color: var(--text-secondary);
    font-size: 0.9rem;
}

/* ===== 分类卡片 ===== */
.section-title {
    font-size: 1.8rem;
    color: var(--primary);
    margin-bottom: 1.5rem;
    padding-bottom: 0.5rem;
    border-bottom: 2px solid var(--border);
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.category-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 1.5rem;
    margin-bottom: 3rem;
}

.category-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1.5rem;
    text-decoration: none;
    color: var(--text-primary);
    transition: var(--transition);
    box-shadow: 0 2px 8px var(--shadow);
}

.category-card:hover {
    transform: translateY(-4px);
    box-shadow: 0 8px 25px var(--shadow);
    border-color: var(--primary-light);
}

.category-card h3 {
    color: var(--primary);
    font-size: 1.3rem;
    margin-bottom: 0.5rem;
}

.category-card p {
    color: var(--text-secondary);
    font-size: 0.95rem;
    margin-bottom: 1rem;
}

.category-card .count {
    display: inline-block;
    background: var(--bg-secondary);
    padding: 0.25rem 0.75rem;
    border-radius: 20px;
    font-size: 0.85rem;
    color: var(--primary);
}

/* ===== 书籍列表 ===== */
.book-list {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 1.5rem;
}

.book-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1.5rem;
    transition: var(--transition);
}

.book-card:hover {
    box-shadow: 0 4px 15px var(--shadow);
    border-color: var(--primary-light);
}

.book-card h3 {
    font-size: 1.2rem;
    margin-bottom: 0.75rem;
}

.book-card h3 a {
    color: var(--primary);
    text-decoration: none;
}

.book-card h3 a:hover {
    text-decoration: underline;
}

.book-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    margin-bottom: 0.75rem;
    font-size: 0.85rem;
}

.book-meta span {
    background: var(--bg-secondary);
    padding: 0.2rem 0.6rem;
    border-radius: 4px;
    color: var(--text-secondary);
}

.book-card .juan {
    color: var(--text-secondary);
    font-size: 0.9rem;
}

/* ===== 书籍详情页 ===== */
.book-detail {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 2rem;
    margin-bottom: 2rem;
}

.book-header {
    border-bottom: 2px solid var(--border);
    padding-bottom: 1.5rem;
    margin-bottom: 2rem;
}

.book-header h1 {
    font-size: 2rem;
    color: var(--primary);
    margin-bottom: 1rem;
}

.book-info {
    display: flex;
    flex-wrap: wrap;
    gap: 1rem;
}

.book-info span {
    background: var(--bg-secondary);
    padding: 0.4rem 1rem;
    border-radius: 4px;
    font-size: 0.9rem;
}

/* ===== 卷列表 ===== */
.volume-list {
    margin-top: 2rem;
}

.volume-list h2 {
    font-size: 1.5rem;
    color: var(--primary);
    margin-bottom: 1rem;
}

.volume-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
    gap: 0.75rem;
}

.volume-item {
    background: var(--bg-secondary);
    padding: 0.75rem;
    border-radius: var(--radius);
    text-align: center;
    text-decoration: none;
    color: var(--text-primary);
    transition: var(--transition);
    border: 1px solid transparent;
}

.volume-item:hover {
    background: var(--primary);
    color: white;
    border-color: var(--primary-dark);
}

/* ===== 阅读页面 ===== */
.reader {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 2rem;
}

.reader-header {
    text-align: center;
    margin-bottom: 2rem;
    padding-bottom: 1rem;
    border-bottom: 1px solid var(--border);
}

.reader-header h1 {
    font-size: 1.5rem;
    color: var(--primary);
}

.reader-content {
    font-size: 1.1rem;
    line-height: 2;
    text-align: justify;
}

.reader-content p {
    margin-bottom: 1rem;
    text-indent: 2em;
}

.page-marker {
    text-align: center;
    color: var(--text-light);
    font-size: 0.85rem;
    margin: 2rem 0;
    padding: 0.5rem;
    border-top: 1px dashed var(--border);
    border-bottom: 1px dashed var(--border);
}

.reader-nav {
    display: flex;
    justify-content: space-between;
    margin-top: 2rem;
    padding-top: 1rem;
    border-top: 1px solid var(--border);
}

.reader-nav a {
    padding: 0.5rem 1.5rem;
    background: var(--primary);
    color: white;
    text-decoration: none;
    border-radius: var(--radius);
    transition: var(--transition);
}

.reader-nav a:hover {
    background: var(--primary-dark);
}

.reader-nav a.disabled {
    background: var(--text-light);
    pointer-events: none;
}

/* ===== 面包屑 ===== */
.breadcrumb {
    margin-bottom: 1.5rem;
    padding: 0.75rem 1rem;
    background: var(--bg-secondary);
    border-radius: var(--radius);
}

.breadcrumb ol {
    display: flex;
    list-style: none;
    flex-wrap: wrap;
    gap: 0.5rem;
}

.breadcrumb li:not(:last-child)::after {
    content: '›';
    margin-left: 0.5rem;
    color: var(--text-light);
}

.breadcrumb a {
    color: var(--primary);
    text-decoration: none;
}

.breadcrumb a:hover {
    text-decoration: underline;
}

/* ===== 分页 ===== */
.pagination {
    margin-top: 2rem;
    text-align: center;
}

.page-info {
    color: var(--text-secondary);
    margin-bottom: 1rem;
}

.page-links {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 0.5rem;
    flex-wrap: wrap;
}

.page-links a,
.page-links span {
    padding: 0.5rem 1rem;
    border-radius: var(--radius);
    text-decoration: none;
}

.page-links a {
    background: var(--bg-secondary);
    color: var(--text-primary);
    transition: var(--transition);
}

.page-links a:hover {
    background: var(--primary);
    color: white;
}

.page-links span.current {
    background: var(--primary);
    color: white;
}

.page-links span.ellipsis {
    background: transparent;
    color: var(--text-light);
}

/* ===== 搜索结果 ===== */
.search-result {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1.5rem;
    margin-bottom: 1rem;
}

.search-result h3 {
    margin-bottom: 0.5rem;
}

.search-result h3 a {
    color: var(--primary);
    text-decoration: none;
}

.search-result h3 a:hover {
    text-decoration: underline;
}

.no-results {
    text-align: center;
    padding: 3rem;
    color: var(--text-secondary);
}

/* ===== 页脚 ===== */
.site-footer {
    background: var(--secondary);
    color: rgba(255, 255, 255, 0.8);
    padding: 3rem 0 1rem;
    margin-top: 3rem;
}

.footer-content {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 2rem;
    margin-bottom: 2rem;
}

.footer-section h3,
.footer-section h4 {
    color: white;
    margin-bottom: 1rem;
}

.footer-section ul {
    list-style: none;
}

.footer-section li {
    margin-bottom: 0.5rem;
}

.footer-section a {
    color: rgba(255, 255, 255, 0.7);
    text-decoration: none;
    transition: var(--transition);
}

.footer-section a:hover {
    color: white;
}

.footer-bottom {
    text-align: center;
    padding-top: 2rem;
    border-top: 1px solid rgba(255, 255, 255, 0.1);
    font-size: 0.9rem;
}

/* ===== 响应式设计 ===== */
@media (max-width: 768px) {
    .site-header .container {
        flex-direction: column;
    }
    
    .main-nav ul {
        gap: 1rem;
    }
    
    .search-box input {
        width: 150px;
    }
    
    .hero h1 {
        font-size: 1.8rem;
    }
    
    .hero-stats {
        flex-direction: column;
        gap: 1rem;
    }
    
    .category-grid,
    .book-list {
        grid-template-columns: 1fr;
    }
    
    .book-detail {
        padding: 1rem;
    }
    
    .reader {
        padding: 1rem;
    }
    
    .reader-content {
        font-size: 1rem;
    }
}

/* ===== 打印样式 ===== */
@media print {
    .site-header,
    .site-footer,
    .breadcrumb,
    .pagination,
    .reader-nav {
        display: none;
    }
    
    .reader {
        border: none;
    }
    
    .reader-content {
        font-size: 12pt;
        line-height: 1.6;
    }
}

/* ===== 辅助类 ===== */
.text-center { text-align: center; }
.mt-1 { margin-top: 0.5rem; }
.mt-2 { margin-top: 1rem; }
.mt-3 { margin-top: 1.5rem; }
.mb-1 { margin-bottom: 0.5rem; }
.mb-2 { margin-bottom: 1rem; }
.mb-3 { margin-bottom: 1.5rem; }
