/* ==================== 全局样式 ==================== */
:root {
    /* 浅色模式配色 */
    --bg-primary: #f8f9fa;
    --bg-secondary: #ffffff;
    --text-primary: #2c3e50;
    --text-secondary: #7f8c8d;
    --accent-blue: #3498db;
    --accent-red: #e74c3c;
    --border-color: #e0e0e0;
    --shadow-sm: 0 2px 4px rgba(0, 0, 0, 0.1);
    --shadow-md: 0 4px 6px rgba(0, 0, 0, 0.1);
    --shadow-lg: 0 10px 15px rgba(0, 0, 0, 0.1);
}

[data-theme="dark"] {
    /* 深色模式配色 */
    --bg-primary: #1a1a1a;
    --bg-secondary: #2d2d2d;
    --text-primary: #ecf0f1;
    --text-secondary: #bdc3c7;
    --accent-blue: #3498db;
    --accent-red: #e74c3c;
    --border-color: #404040;
    --shadow-sm: 0 2px 4px rgba(0, 0, 0, 0.3);
    --shadow-md: 0 4px 6px rgba(0, 0, 0, 0.3);
    --shadow-lg: 0 10px 15px rgba(0, 0, 0, 0.3);
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Merriweather', serif;
    background-color: var(--bg-primary);
    color: var(--text-primary);
    line-height: 1.6;
    transition: background-color 0.3s ease, color 0.3s ease;
}

/* ==================== 导航栏样式 ==================== */
.navbar {
    background-color: var(--bg-secondary);
    box-shadow: var(--shadow-md);
    position: sticky;
    top: 0;
    z-index: 1000;
    transition: background-color 0.3s ease;
}

.nav-container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 1rem 2rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 1rem;
}

.nav-left {
    display: flex;
    align-items: center;
    gap: 2rem;
}

.site-title {
    font-family: 'Roboto', sans-serif;
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--accent-blue);
    cursor: pointer;
    transition: color 0.3s ease;
}

.site-title:hover {
    color: var(--accent-red);
}

.nav-link {
    font-family: 'Roboto', sans-serif;
    color: var(--text-primary);
    text-decoration: none;
    font-weight: 500;
    transition: color 0.3s ease;
}

.nav-link:hover {
    color: var(--accent-blue);
}

.nav-right {
    display: flex;
    align-items: center;
    gap: 1rem;
}

/* 搜索栏样式 */
.search-container {
    display: flex;
    align-items: center;
    background-color: var(--bg-primary);
    border-radius: 25px;
    padding: 0.4rem 1rem;
    transition: box-shadow 0.3s ease;
}

.search-container:focus-within {
    box-shadow: 0 0 0 3px rgba(52, 152, 219, 0.3);
}

.search-input {
    border: none;
    background: transparent;
    font-family: 'Roboto', sans-serif;
    color: var(--text-primary);
    outline: none;
    width: 200px;
    transition: width 0.3s ease;
}

.search-input:focus {
    width: 250px;
}

.search-btn {
    background: transparent;
    border: none;
    color: var(--text-secondary);
    cursor: pointer;
    display: flex;
    align-items: center;
    transition: color 0.3s ease;
}

.search-btn:hover {
    color: var(--accent-blue);
}

/* 下拉菜单样式 */
.dropdown {
    position: relative;
}

.dropdown-btn {
    font-family: 'Roboto', sans-serif;
    background-color: var(--accent-blue);
    color: white;
    border: none;
    padding: 0.6rem 1.2rem;
    border-radius: 5px;
    cursor: pointer;
    font-weight: 500;
    transition: background-color 0.3s ease, transform 0.2s ease;
}

.dropdown-btn:hover {
    background-color: #2980b9;
    transform: translateY(-2px);
}

.dropdown-content {
    display: none;
    position: absolute;
    right: 0;
    background-color: var(--bg-secondary);
    min-width: 250px;
    max-height: 400px;
    overflow-y: auto;
    box-shadow: var(--shadow-lg);
    border-radius: 5px;
    margin-top: 0.5rem;
    z-index: 1001;
}

.dropdown:hover .dropdown-content {
    display: block;
}

.chapter-item {
    padding: 0.8rem 1.2rem;
    cursor: pointer;
    transition: background-color 0.3s ease;
    border-bottom: 1px solid var(--border-color);
    font-family: 'Roboto', sans-serif;
}

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

.chapter-item:hover {
    background-color: var(--bg-primary);
}

/* 主题切换按钮 */
.theme-toggle {
    background: transparent;
    border: none;
    color: var(--text-primary);
    cursor: pointer;
    display: flex;
    align-items: center;
    padding: 0.5rem;
    border-radius: 50%;
    transition: background-color 0.3s ease, transform 0.2s ease;
}

.theme-toggle:hover {
    background-color: var(--bg-primary);
    transform: rotate(20deg);
}

.hidden {
    display: none !important;
}

/* ==================== 搜索结果面板 ==================== */
.search-results {
    position: fixed;
    top: 80px;
    right: 2rem;
    width: 400px;
    max-height: 500px;
    background-color: var(--bg-secondary);
    box-shadow: var(--shadow-lg);
    border-radius: 10px;
    overflow: hidden;
    z-index: 1002;
    animation: slideIn 0.3s ease;
}

@keyframes slideIn {
    from {
        opacity: 0;
        transform: translateY(-20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.search-results-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem;
    border-bottom: 1px solid var(--border-color);
    background-color: var(--bg-primary);
}

.search-results-header h3 {
    font-family: 'Roboto', sans-serif;
    font-size: 1.1rem;
    color: var(--accent-blue);
}

.close-btn {
    background: transparent;
    border: none;
    color: var(--text-secondary);
    cursor: pointer;
    display: flex;
    align-items: center;
    transition: color 0.3s ease;
}

.close-btn:hover {
    color: var(--accent-red);
}

#searchResultsList {
    max-height: 400px;
    overflow-y: auto;
    padding: 1rem;
}

.search-result-item {
    padding: 1rem;
    margin-bottom: 0.5rem;
    background-color: var(--bg-primary);
    border-radius: 5px;
    cursor: pointer;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.search-result-item:hover {
    transform: translateX(5px);
    box-shadow: var(--shadow-md);
}

.search-result-title {
    font-family: 'Roboto', sans-serif;
    font-weight: 500;
    color: var(--accent-blue);
    margin-bottom: 0.5rem;
}

.search-result-excerpt {
    font-size: 0.9rem;
    color: var(--text-secondary);
    line-height: 1.5;
}

.highlight {
    background-color: rgba(241, 196, 15, 0.4);
    padding: 0 2px;
    border-radius: 2px;
}

/* ==================== 主要内容区域 ==================== */
.main-content {
    min-height: calc(100vh - 180px);
    padding: 3rem 2rem;
}

.content-container {
    max-width: 900px;
    margin: 0 auto;
}

/* 首页样式 */
.home-page {
    text-align: center;
}

.welcome-title {
    font-family: 'Roboto', sans-serif;
    font-size: 3rem;
    color: var(--accent-blue);
    margin-bottom: 1rem;
    animation: fadeInDown 0.8s ease;
}

@keyframes fadeInDown {
    from {
        opacity: 0;
        transform: translateY(-30px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.welcome-subtitle {
    font-size: 1.3rem;
    color: var(--text-secondary);
    margin-bottom: 3rem;
    animation: fadeIn 1s ease;
}

@keyframes fadeIn {
    from {
        opacity: 0;
    }
    to {
        opacity: 1;
    }
}

.chapter-cards {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 2rem;
    margin-top: 3rem;
}

.chapter-card {
    background-color: var(--bg-secondary);
    padding: 2rem;
    border-radius: 10px;
    box-shadow: var(--shadow-md);
    cursor: pointer;
    transition: transform 0.3s ease, box-shadow 0.3s ease;
    animation: fadeInUp 0.6s ease backwards;
}

.chapter-card:nth-child(1) { animation-delay: 0.1s; }
.chapter-card:nth-child(2) { animation-delay: 0.2s; }
.chapter-card:nth-child(3) { animation-delay: 0.3s; }

@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(30px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.chapter-card:hover {
    transform: translateY(-10px);
    box-shadow: var(--shadow-lg);
}

.chapter-card-title {
    font-family: 'Roboto', sans-serif;
    font-size: 1.5rem;
    color: var(--accent-blue);
    margin-bottom: 1rem;
}

.chapter-card-excerpt {
    color: var(--text-secondary);
    font-size: 0.95rem;
    line-height: 1.6;
}

/* 章节阅读页面 */
.chapter-page {
    animation: fadeIn 0.5s ease;
}

.chapter-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 2rem;
    padding-bottom: 1rem;
    border-bottom: 2px solid var(--border-color);
    flex-wrap: wrap;
    gap: 1rem;
}

.chapter-title {
    font-family: 'Roboto', sans-serif;
    font-size: 2.5rem;
    color: var(--accent-blue);
}

.bookmark-container {
    display: flex;
    align-items: center;
}

.bookmark-btn {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    background-color: transparent;
    border: 2px solid var(--accent-blue);
    color: var(--accent-blue);
    padding: 0.6rem 1.2rem;
    border-radius: 25px;
    cursor: pointer;
    font-family: 'Roboto', sans-serif;
    font-weight: 500;
    transition: all 0.3s ease;
}

.bookmark-btn:hover {
    background-color: var(--accent-blue);
    color: white;
    transform: scale(1.05);
}

.bookmark-btn.bookmarked {
    background-color: var(--accent-blue);
    color: white;
}

.bookmark-btn.bookmarked svg {
    fill: white;
}

.chapter-content {
    font-size: 1.1rem;
    line-height: 1.8;
    color: var(--text-primary);
    margin-bottom: 3rem;
    text-align: justify;
}

.chapter-content p {
    margin-bottom: 1.5rem;
    text-indent: 2em;
}

/* 章节导航按钮 */
.chapter-navigation {
    display: flex;
    justify-content: space-between;
    gap: 1rem;
    margin-top: 3rem;
    padding-top: 2rem;
    border-top: 1px solid var(--border-color);
}

.nav-btn {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    background-color: var(--accent-blue);
    color: white;
    border: none;
    padding: 0.8rem 1.5rem;
    border-radius: 5px;
    cursor: pointer;
    font-family: 'Roboto', sans-serif;
    font-size: 1rem;
    font-weight: 500;
    transition: all 0.3s ease;
}

.nav-btn:hover {
    background-color: #2980b9;
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}

.nav-btn:disabled {
    background-color: var(--text-secondary);
    cursor: not-allowed;
    opacity: 0.5;
}

.nav-btn:disabled:hover {
    transform: none;
    box-shadow: none;
}

/* ==================== 底部样式 ==================== */
.footer {
    background-color: var(--bg-secondary);
    padding: 2rem;
    text-align: center;
    color: var(--text-secondary);
    font-family: 'Roboto', sans-serif;
    box-shadow: 0 -2px 4px rgba(0, 0, 0, 0.1);
}

.footer-subtitle {
    margin-top: 0.5rem;
    font-size: 0.9rem;
    font-style: italic;
}

/* ==================== 响应式设计 ==================== */
@media (max-width: 768px) {
    .nav-container {
        padding: 1rem;
    }

    .nav-left {
        gap: 1rem;
    }

    .site-title {
        font-size: 1.2rem;
    }

    .search-input {
        width: 150px;
    }

    .search-input:focus {
        width: 180px;
    }

    .search-results {
        width: calc(100% - 2rem);
        right: 1rem;
        left: 1rem;
    }

    .welcome-title {
        font-size: 2rem;
    }

    .welcome-subtitle {
        font-size: 1rem;
    }

    .chapter-cards {
        grid-template-columns: 1fr;
        gap: 1.5rem;
    }

    .chapter-title {
        font-size: 1.8rem;
    }

    .chapter-content {
        font-size: 1rem;
    }

    .chapter-navigation {
        flex-direction: column;
    }

    .main-content {
        padding: 2rem 1rem;
    }
}

/* 滚动条美化 */
::-webkit-scrollbar {
    width: 10px;
}

::-webkit-scrollbar-track {
    background: var(--bg-primary);
}

::-webkit-scrollbar-thumb {
    background: var(--text-secondary);
    border-radius: 5px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--accent-blue);
}
