/* chapter-styles.css - 所有小说相关页面的完整样式 */
:root {
    /* 色彩系统 */
    --primary-color: #2c3e50;
    --secondary-color: #3498db;
    --accent-color: #e74c3c;
    --text-color: #2c3e50;
    --text-light: #7f8c8d;
    --bg-color: #ffffff;
    --bg-light: #f8f9fa;
    --border-color: #e9ecef;
    
    /* 设计系统 */
    --shadow: 0 2px 10px rgba(0,0,0,0.1);
    --shadow-lg: 0 4px 20px rgba(0,0,0,0.15);
    --shadow-xl: 0 8px 25px rgba(0,0,0,0.15);
    --radius: 8px;
    --radius-lg: 12px;
    --radius-xl: 16px;
    
    /* 间距系统 */
    --spacing-xs: 5px;
    --spacing-sm: 10px;
    --spacing-md: 20px;
    --spacing-lg: 30px;
    --spacing-xl: 40px;
    
    /* 广告相关变量 */
    --ad-min-height: 90px;
    --ad-mobile-min-height: 120px;
    --ad-max-width: 728px;
    --ad-bg: transparent;
    
    /* 字体系统 */
    --font-size-base: 1rem;
    --font-size-lg: 1.3rem;
    --font-size-xl: 1.8rem;
    --font-size-2xl: 2rem;
    --font-size-3xl: 3rem;
    
    /* 断点 */
    --breakpoint-sm: 480px;
    --breakpoint-md: 768px;
    --breakpoint-lg: 1024px;
    --breakpoint-xl: 1200px;
}

/* ============ 基础重置 ============ */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Source Sans Pro', sans-serif;
    line-height: 1.6;
    color: var(--text-color);
    background-color: var(--bg-light);
    padding-top: 80px; /* 为固定导航栏留出空间 */
}

/* 顶部导航栏样式 */
.main-navigation {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    background: rgba(255, 255, 255, 0.98);
    backdrop-filter: blur(10px);
    border-bottom: 1px solid rgba(0, 0, 0, 0.1);
    z-index: 1000;
    height: 80px;
    box-shadow: 0 2px 20px rgba(0, 0, 0, 0.1);
}

.nav-container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 20px;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.nav-logo .logo-link {
    display: flex;
    align-items: center;
    text-decoration: none;
    color: #333;
    font-weight: 700;
    font-size: 1.5rem;
    gap: 10px;
    transition: color 0.3s ease;
}

.nav-logo .logo-link:hover {
    color: #667eea;
}

.nav-logo i {
    font-size: 2rem;
    color: #667eea;
}

.nav-links {
    display: flex;
    gap: 30px;
    align-items: center;
}

.nav-link {
    display: flex;
    align-items: center;
    text-decoration: none;
    color: #666;
    font-weight: 500;
    font-size: 1rem;
    gap: 8px;
    padding: 10px 15px;
    border-radius: 25px;
    transition: all 0.3s ease;
    position: relative;
}

.nav-link:hover {
    color: #667eea;
    background: rgba(102, 126, 234, 0.1);
    transform: translateY(-1px);
}

.nav-link.active {
    color: #667eea;
    background: rgba(102, 126, 234, 0.1);
    font-weight: 600;
}

.nav-link.active::after {
    content: '';
    position: absolute;
    bottom: -2px;
    left: 50%;
    transform: translateX(-50%);
    width: 20px;
    height: 2px;
    background: #667eea;
    border-radius: 1px;
}

.nav-link i {
    font-size: 1.2rem;
}

/* ============ 通用容器 ============ */
.container {
    max-width: var(--breakpoint-xl);
    margin: 0 auto;
    padding: var(--spacing-md);
    min-height: 100vh;
    position: relative;
}

.chapter-list-container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 20px;
    min-height: 100vh;
    position: relative;
}

/* ============ 章节阅读页样式 ============ */

/* 章节头部 */
.chapter-header {
    background: var(--bg-color);
    padding: var(--spacing-lg);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    margin-bottom: var(--spacing-lg);
    text-align: center;
}

.novel-title {
    font-family: 'Merriweather', serif;
    font-size: var(--font-size-2xl);
    color: var(--primary-color);
    margin-bottom: var(--spacing-sm);
}

.chapter-title {
    font-family: 'Merriweather', serif;
    font-size: var(--font-size-xl);
    color: var(--primary-color);
    margin-bottom: 15px;
}

.chapter-meta {
    display: flex;
    justify-content: center;
    align-items: center;
    flex-wrap: wrap;
    gap: var(--spacing-md);
    margin-bottom: var(--spacing-md);
    color: var(--text-light);
}

.button-group {
    display: flex;
    gap: var(--spacing-sm);
    align-items: center;
    justify-content: center;
}

.nav-btn {
    background: var(--secondary-color);
    color: white;
    border: none;
    padding: 12px 20px;
    border-radius: var(--radius);
    cursor: pointer;
    font-weight: 600;
    transition: all 0.3s ease;
    text-decoration: none;
    display: flex;
    align-items: center;
    gap: 8px;
    height: 48px;
    box-sizing: border-box;
}

.nav-btn:hover {
    background: #2980b9;
    transform: translateY(-2px);
}

.nav-disabled {
    background: var(--text-light);
    cursor: not-allowed;
    height: 48px;
    box-sizing: border-box;
}

.nav-disabled:hover {
    background: var(--text-light);
    transform: none;
}

/* 章节内容 */
.chapter-content {
    background: var(--bg-color);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: var(--spacing-xl);
    font-size: var(--font-size-lg);
    line-height: 1.8;
}

.chapter-content p {
    margin-bottom: 1.5em;
    text-align: justify;
}

/* 导航组件 */
.chapter-navigation {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: var(--spacing-lg);
    padding: var(--spacing-md);
    background: var(--bg-color);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
}

/* ============ 章节列表页样式 ============ */

/* Header */
.novel-header {
    background: var(--bg-color);
    padding: 30px;
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    margin-top: 20px; /* 减小与顶部导航栏的间距 */
    margin-bottom: 30px;
    text-align: center;
    position: relative;
    min-height: 200px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: flex-start;
    padding-top: 20px;
}

.novel-title-index {
    font-family: 'Merriweather', serif;
    font-size: 3rem;
    color: var(--primary-color);
    margin-bottom: 10px;
}

.novel-subtitle {
    font-size: 1.2rem;
    color: var(--text-light);
    margin-bottom: 30px;
}

.novel-meta {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 20px;
    position: absolute;
    bottom: 10px;
    left: 0;
    right: 0;
    padding: 0 30px;
}

.author-info {
    display: flex;
    align-items: center;
    gap: 10px;
}

.author-name {
    text-align: left;
    font-weight: 600;
}

.author-avatar {
    width: 50px;
    height: 50px;
    border-radius: 50%;
    background: var(--secondary-color);
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-weight: bold;
    font-size: 1.2rem;
}

.status-badge {
    background: var(--accent-color);
    color: white;
    padding: 8px 16px;
    border-radius: 20px;
    font-size: 0.9rem;
    font-weight: 600;
}

.update-info {
    color: var(--text-light);
    font-size: 0.9rem;
}

/* Back to Games Button Styles */
.back-to-games-container {
    position: absolute;
    top: 30px;
    left: 30px;
    z-index: 10;
}

.back-to-games-btn {
    background: var(--secondary-color);
    color: white;
    border: none;
    padding: 10px 16px;
    border-radius: var(--radius);
    cursor: pointer;
    font-weight: 600;
    transition: all 0.3s ease;
    text-decoration: none;
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.9rem;
}

.back-to-games-btn:hover {
    background: #2980b9;
    transform: translateY(-2px);
}

/* Chapters Grid */
.chapters-container {
    background: var(--bg-color);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 30px;
}

.chapters-header {
    text-align: center;
    margin-bottom: 30px;
    border-bottom: 1px solid var(--border-color);
    padding-bottom: 20px;
    position: relative;
}

/* Search Function */
.search-container {
    position: absolute;
    top: 0;
    right: 0;
    display: flex;
    align-items: center;
    gap: 10px;
}

.search-input {
    padding: 8px 12px;
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    font-size: 0.9rem;
    width: 200px;
    transition: border-color 0.3s ease;
}

.search-input:focus {
    outline: none;
    border-color: var(--secondary-color);
}

.search-btn {
    background: var(--secondary-color);
    color: white;
    border: none;
    padding: 8px 16px;
    border-radius: var(--radius);
    cursor: pointer;
    font-size: 0.9rem;
    transition: background 0.3s ease;
    display: flex;
    align-items: center;
    gap: 6px;
}

.search-btn:hover {
    background: #2980b9;
}

/* Pagination Styles */
.chapters-container .pagination {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 10px;
    margin-top: 30px;
    padding: 20px 0;
    border-top: 1px solid var(--border-color);
    width: 100%;
    /* 确保即使初始隐藏时也能正确计算布局 */
    margin-left: auto;
    margin-right: auto;
    /* 使用!important覆盖任何可能的内联样式冲突 */
    box-sizing: border-box;
}

.pagination {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 10px;
    margin-top: 30px;
    padding: 20px 0;
    border-top: 1px solid var(--border-color);
    width: 100%;
    /* 确保即使初始隐藏时也能正确计算布局 */
    margin-left: auto;
    margin-right: auto;
    /* 使用!important覆盖任何可能的内联样式冲突 */
    box-sizing: border-box;
}

/* 当分页导航显示时，强制使用flex布局并居中 */
.pagination[style*="display: flex"] {
    display: flex !important;
    justify-content: center !important;
    align-items: center !important;
    width: 100% !important;
    margin-left: auto !important;
    margin-right: auto !important;
}

.page-btn {
    background: var(--secondary-color);
    color: white;
    border: none;
    padding: 8px 16px;
    border-radius: var(--radius);
    cursor: pointer;
    font-size: 0.9rem;
    transition: background 0.3s ease;
    min-width: 40px;
    text-align: center;
}

.page-btn:hover:not(:disabled) {
    background: #2980b9;
}

.page-btn:disabled {
    background: var(--text-light);
    cursor: not-allowed;
}

.page-info {
    font-size: 0.9rem;
    color: var(--text-light);
    margin: 0 15px;
}

.page-number {
    background: transparent;
    color: var(--secondary-color);
    border: 1px solid var(--secondary-color);
}

.page-number.active {
    background: var(--secondary-color);
    color: white;
}

.chapters-title {
    font-family: 'Merriweather', serif;
    font-size: 2rem;
    color: var(--primary-color);
    margin-bottom: 10px;
}

.chapters-count {
    color: var(--text-light);
    font-size: 1.1rem;
}

.chapters-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 15px;
    max-height: 1600px; /* 5行 * 280px + 4*15px间隙 */
    overflow-y: hidden;
}

.chapter-card {
    background: var(--bg-light);
    border-radius: var(--radius);
    padding: 20px;
    transition: all 0.3s ease;
    border: 1px solid var(--border-color);
    cursor: pointer;
    display: flex;
    flex-direction: column;
    height: 280px;
}

.chapter-card:hover {
    transform: translateY(-5px);
    box-shadow: var(--shadow-xl);
    border-color: var(--secondary-color);
}

.chapter-number {
    font-size: 0.8rem;
    color: var(--secondary-color);
    font-weight: 600;
    margin-bottom: 8px;
    text-transform: uppercase;
    letter-spacing: 1px;
}

.chapter-title-index {
    font-family: 'Merriweather', serif;
    font-size: 1.1rem;
    color: var(--primary-color);
    margin-bottom: 12px;
    line-height: 1.3;
}

.chapter-meta-index {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 12px;
    padding-bottom: 12px;
    border-bottom: 1px solid var(--border-color);
}

.chapter-date {
    font-size: 0.8rem;
    color: var(--text-light);
}

.chapter-stats {
    display: flex;
    gap: 12px;
}

.chapter-stat {
    font-size: 0.75rem;
    color: var(--text-light);
}

.chapter-excerpt {
    font-size: 0.85rem;
    color: var(--text-color);
    line-height: 1.5;
    margin-bottom: 12px;
    display: -webkit-box;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
    line-clamp: 3;
    overflow: hidden;
    flex-grow: 1;
}

.read-btn {
    background: var(--secondary-color);
    color: white;
    border: none;
    padding: 8px 16px;
    border-radius: var(--radius);
    cursor: pointer;
    font-weight: 600;
    transition: all 0.3s ease;
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    font-size: 0.85rem;
}

.read-btn:hover {
    background: #2980b9;
    transform: translateY(-2px);
}

.home-btn {
    background: var(--secondary-color);
    color: white;
    border: none;
    padding: 12px 20px;
    border-radius: var(--radius);
    cursor: pointer;
    font-weight: 600;
    transition: all 0.3s ease;
    text-decoration: none;
    display: flex;
    align-items: center;
    gap: 8px;
}

.home-btn:hover {
    background: #2980b9;
    transform: translateY(-2px);
}

/* Loading States */
.loading {
    text-align: center;
    padding: 60px;
    color: var(--text-light);
}

.spinner {
    border: 3px solid var(--border-color);
    border-top: 3px solid var(--secondary-color);
    border-radius: 50%;
    width: 40px;
    height: 40px;
    animation: spin 1s linear infinite;
    margin: 0 auto 20px;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* ============ 广告样式优化 ============ */
.ad-section {
    margin: 25px auto;
    width: 100%;
    max-width: var(--ad-max-width);
    position: relative;
    text-align: center;
    min-height: var(--ad-min-height);
    padding: 15px 0;
    background-color: var(--ad-bg);
    border-radius: 4px;
    overflow: hidden;
}

/* 广告标签样式 */
.ad-label {
    position: absolute;
    top: 0;
    left: 0;
    font-size: 10px;
    color: #999;
    letter-spacing: 0.5px;
    text-transform: uppercase;
    font-family: sans-serif;
    background: rgba(255, 255, 255, 0.9);
    padding: 2px 6px;
    border-radius: 0 0 3px 0;
    z-index: 1;
}

/* 确保广告不会溢出 */
.adsbygoogle {
    width: 100%;
    height: auto;
    max-width: 100%;
    display: block;
    margin: 0 auto;
}

/* 文章内嵌广告特殊样式 */
.ad-section.in-article-ad {
    margin: 30px auto;
    padding: 20px 0;
    border-top: 1px solid var(--border-color);
    border-bottom: 1px solid var(--border-color);
    background: var(--bg-light);
}

/* 特定广告位样式 */
#ad-middle-banner {
    margin-top: 0;
    margin-bottom: 30px;
}

#ad-bottom-banner {
    margin-top: 30px;
    margin-bottom: 15px;
}

#ad-in-article {
    min-height: 150px; /* 文章内广告稍高 */
}

#ad-in-content-2 {
    min-height: 180px; /* 固定尺寸广告 */
}

/* 广告加载占位符 */
.ad-placeholder {
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(90deg, #f5f5f5 25%, #eaeaea 50%, #f5f5f5 75%);
    background-size: 200% 100%;
    animation: loading 1.5s infinite;
    border-radius: 4px;
    color: #888;
    font-size: 12px;
}

@keyframes loading {
    0% { background-position: 200% 0; }
    100% { background-position: -200% 0; }
}

/* 空广告容器优化 - 本地开发环境 */
body.local-dev .ad-section:has(.adsbygoogle:empty),
.ad-section.ad-empty:has(.adsbygoogle:empty) {
    min-height: 10px !important;
    margin: 5px 0 !important;
    padding: 0 !important;
    border: none !important;
    background: transparent !important;
}

/* 隐藏未填充的广告 */
.adsbygoogle[style*="display: none"],
.adsbygoogle[style*="height: 0"],
.adsbygoogle[style*="width: 0"] {
    display: none !important;
}

.ad-section.hidden {
    display: none;
}

/* ============ 页脚样式 ============ */
#footer-container {
    margin: 0;
    width: 100%;
    padding: 0;
    background: var(--bg-light);
}

footer, .footer {
    text-align: center;
    padding: 30px;
    background: white;
    border-radius: var(--radius-xl);
    margin: 20px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.06);
    border: 1px solid #e2e8f0;
}

.footer-links {
    display: flex;
    justify-content: center;
    gap: 20px;
    margin-top: 15px;
    flex-wrap: wrap;
}

.footer-links a {
    color: #667eea;
    text-decoration: none;
    transition: color 0.3s ease;
    font-weight: 500;
}

.footer-links a:hover {
    color: #764ba2;
    text-decoration: underline;
}

.footer-info {
    margin-top: 20px;
    font-size: 0.9rem;
    color: #6b7280;
    line-height: 1.5;
}

.footer-info p {
    margin-bottom: 8px;
}

/* Accessibility */
.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

/* ============ 响应式设计 ============ */

/* 桌面端大屏幕优化 */
@media (min-width: 1200px) {
    .ad-section {
        max-width: var(--ad-max-width);
        margin-left: auto;
        margin-right: auto;
    }
}

/* 移动端优化 */
@media (max-width: 768px) {
    /* 导航栏移动端样式 */
    body {
        padding-top: 60px;
    }
    
    .main-navigation {
        height: 60px;
    }
    
    .nav-container {
        padding: 0 15px;
    }
    
    .nav-logo .logo-link {
        font-size: 1.2rem;
    }
    
    .nav-logo i {
        font-size: 1.5rem;
    }
    
    .nav-links {
        gap: 15px;
    }
    
    .nav-link {
        font-size: 0.9rem;
        padding: 8px 12px;
        gap: 5px;
    }
    
    .nav-link span {
        display: none; /* 移动端只显示图标 */
    }
    
    .nav-link i {
        font-size: 1.1rem;
    }
    
    .ad-section {
        margin: 20px 0;
        min-height: var(--ad-mobile-min-height);
        padding: 10px 0;
    }
    
    #ad-middle-banner {
        margin-bottom: 20px;
    }
    
    #ad-bottom-banner {
        margin-top: 20px;
        margin-bottom: 10px;
    }
    
    #ad-in-article {
        min-height: 120px;
    }
    
    #ad-in-content-2 {
        min-height: 150px;
    }
    
    /* 确保广告不超过屏幕宽度 */
    .adsbygoogle {
        max-width: 100% !important;
        overflow: hidden !important;
    }

    .container, .chapter-list-container {
        padding: var(--spacing-sm);
    }
    
    .chapter-header, .novel-header {
        padding: var(--spacing-md);
        margin-top: 20px; /* 减小与顶部导航栏的间距 */
    }
    
    .novel-title, .novel-title-index {
        font-size: 1.5rem;
    }
    
    .novel-title-index {
        font-size: 2rem;
        margin-bottom: 5px;
        line-height: 1.2;
    }
    
    .novel-subtitle {
        font-size: 1rem;
        margin-bottom: 20px;
        line-height: 1.3;
        text-align: center;
        padding: 0 10px;
    }
    
    .novel-meta {
        position: static;
        flex-direction: column;
        gap: 15px;
        margin-top: 20px;
        padding: 0;
        align-items: center;
        text-align: center;
    }
    
    .author-info {
        flex-direction: column;
        text-align: center;
        gap: 8px;
    }
    
    .author-avatar {
        width: 40px;
        height: 40px;
        font-size: 1rem;
    }
    
    .status-badge {
        order: -1; /* 将状态徽章移到前面 */
    }
    
    .chapter-title {
        font-size: 1.3rem;
    }
    
    .chapter-content {
        padding: var(--spacing-md);
        font-size: 1.2rem;
    }
    
    .chapter-navigation {
        flex-direction: column;
        gap: var(--spacing-sm);
    }
    
    .button-group {
        flex-direction: column;
        width: 100%;
    }
    
    .nav-btn, .home-btn {
        width: 100%;
        justify-content: center;
    }
    
    .back-to-games-container {
        top: var(--spacing-sm);
        left: var(--spacing-sm);
    }
    
    .chapters-grid {
        grid-template-columns: 1fr;
    }
    
    .chapters-container {
        padding: 20px;
    }
    
    .chapter-title-index {
        font-size: 1.1rem;
    }
    
    .chapter-meta-index {
        flex-direction: column;
        align-items: flex-start;
        gap: 10px;
    }
    
    .chapter-stats {
        justify-content: space-between;
        width: 100%;
    }
}

@media (max-width: 480px) {
    .novel-header {
        padding: 20px 15px;
        margin-top: 15px; /* 在移动端进一步减小间距 */
        min-height: auto;
    }
    
    .novel-title-index {
        font-size: 1.6rem;
        margin-bottom: 8px;
        line-height: 1.2;
        word-wrap: break-word;
    }
    
    .novel-subtitle {
        font-size: 0.9rem;
        margin-bottom: 15px;
        line-height: 1.4;
        padding: 0 5px;
    }
    
    .novel-meta {
        gap: 12px;
        margin-top: 15px;
    }
    
    .author-info {
        gap: 6px;
    }
    
    .author-avatar {
        width: 35px;
        height: 35px;
        font-size: 0.9rem;
    }
    
    .author-name {
        font-size: 0.9rem;
    }
    
    .update-info {
        font-size: 0.8rem;
    }
    
    .status-badge {
        font-size: 0.8rem;
        padding: 6px 12px;
    }
    
    .chapter-meta {
        flex-direction: column;
        gap: var(--spacing-sm);
    }
    
    .chapter-content {
        font-size: 1.1rem;
        padding: var(--spacing-sm);
    }
    
    .back-to-games-btn {
        font-size: 0.8rem;
        padding: 8px 12px;
    }
    
    .ad-section {
        min-height: 100px;
        margin: 15px 0;
    }
    
    #ad-in-article {
        min-height: 100px;
    }
    
    #ad-in-content-2 {
        min-height: 120px;
    }
    
    .chapter-card {
        padding: 15px;
    }
    
    .button-group {
        flex-direction: column;
        width: 100%;
    }
    
    .home-btn {
        width: 100%;
        justify-content: center;
    }
    
    .search-container {
        position: static;
        margin-top: 15px;
        justify-content: center;
    }
    
    .search-input {
        width: 100%;
        max-width: 200px;
    }
}

/* 暗色模式支持 */
@media (prefers-color-scheme: dark) {
    .ad-label {
        background: rgba(0, 0, 0, 0.9);
        color: #aaa;
    }
    
    .ad-placeholder {
        background: linear-gradient(90deg, #2a2a2a 25%, #333 50%, #2a2a2a 75%);
        color: #777;
    }
}