/* 通用样式 */
body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    margin: 0;
    padding: 0;
    background-color: #f4f5f7;
    color: #333;
    transition: background-color 0.3s, color 0.3s;
}

/* 滚动条美化（默认） */
::-webkit-scrollbar {
    width: 8px;
}

::-webkit-scrollbar-track {
    background: #f1f1f1;
}

::-webkit-scrollbar-thumb {
    background: #888;
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: #555;
}

#reader-container {
    max-width: 1200px;
    margin: 20px auto;
    background-color: #fff;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
    border-radius: 8px;
    overflow: hidden;
}

/* 头部样式 */
#reader-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px;
    border-bottom: 1px solid #eee;
    flex-wrap: wrap;
    gap: 15px;
}

#book-title {
    margin: 0;
    font-size: 1.5rem;
    font-weight: 600;
}

.controls {
    display: flex;
    align-items: center;
    gap: 10px;
}

.controls button, .file-input-label {
    padding: 8px 16px;
    border: none;
    border-radius: 4px;
    background-color: #007bff;
    color: #fff;
    cursor: pointer;
    font-size: 14px;
    transition: background-color 0.2s;
    text-decoration: none;
    display: inline-block;
}

.controls button:hover, .file-input-label:hover {
    background-color: #0056b3;
}

.controls button:disabled {
    background-color: #cccccc;
    cursor: not-allowed;
}

/* 隐藏实际的文件输入框 */
#local-file-input {
    display: none;
}

.secondary-controls {
    display: flex;
    align-items: center;
    gap: 15px;
}

.theme-buttons {
    display: flex;
    gap: 8px;
    align-items: center;
}

.theme-btn {
    padding: 8px 12px;
    border: 1px solid #ccc;
    border-radius: 4px;
    background-color: #eee;
    color: #333;
    cursor: pointer;
    font-size: 14px;
    transition: background-color 0.2s, border-color 0.2s, color 0.2s;
}

.theme-btn:hover {
    background-color: #ddd;
    border-color: #bbb;
}

.theme-btn.active {
    border-color: #007bff;
    background-color: #007bff;
    color: #fff;
    font-weight: bold;
}

/* 主要内容区布局 */
#reader-main {
    display: flex;
    transition: all 0.3s ease;
}

#chapter-list {
    width: 250px;
    border-right: 1px solid #eee;
    padding: 20px;
    overflow-y: auto;
    height: calc(100vh - 140px);
    flex-shrink: 0;
    transition: width 0.3s, padding 0.3s, border 0.3s;
}

#chapter-list h2 {
    margin: 0 0 10px 0;
    font-size: 1.2rem;
}

#chapter-menu {
    list-style: none;
    padding: 0;
    margin: 0;
}

#chapter-menu li {
    padding: 8px 0;
    cursor: pointer;
    font-size: 14px;
    border-bottom: 1px solid #f0f0f0;
    transition: background-color 0.2s;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

#chapter-menu li:hover {
    background-color: #f8f9fa;
}

#chapter-menu li.active {
    color: #007bff;
    font-weight: bold;
}

#book-content {
    flex-grow: 1;
    padding: 20px;
    line-height: 1.8;
    text-indent: 2em;
    overflow-y: auto;
    height: calc(100vh - 140px);
    transition: margin-left 0.3s;
}

/* 加载中状态样式 */
#book-content.loading::before {
    content: "正在加载，请稍候...";
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    color: #666;
    font-size: 1.2em;
}

/* 底部样式 */
#reader-footer {
    display: none; /* Hide the footer as controls are moved up */
}

.footer-controls {
    display: flex;
    align-items: center;
    gap: 15px;
}

/* 目录隐藏模式 */
body.hide-menu #chapter-list {
    width: 0;
    padding: 0;
    border-right: none;
    overflow: hidden;
}

body.hide-menu #book-content {
    flex-grow: 1;
}

/* 主题模式切换 */
body.dark {
    background-color: #2b2b2b;
    color: #e0e0e0;
}
body.dark #reader-container {
    background-color: #3c3c3c;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
}
body.dark #reader-header, body.dark #reader-main, body.dark #reader-footer {
    border-color: #555;
}
body.dark .controls button, body.dark .file-input-label {
    background-color: #555;
}
body.dark #chapter-list h2 {
    color: #e0e0e0;
}
body.dark #chapter-menu li:hover {
    background-color: #4c4c4c;
}
body.dark #chapter-menu li.active {
    color: #8ab4f8;
}
body.dark .theme-btn {
    color: #fff;
    border-color: #555;
    background-color: #444;
}
body.dark .theme-btn:hover {
    background-color: #555;
}
body.dark .theme-btn.active {
    border-color: #8ab4f8;
    background-color: #8ab4f8;
    color: #2b2b2b;
}

/* 滚动条美化（夜间模式） */
body.dark ::-webkit-scrollbar-track {
    background: #3c3c3c;
}

body.dark ::-webkit-scrollbar-thumb {
    background: #666;
}

body.dark ::-webkit-scrollbar-thumb:hover {
    background: #888;
}

body.sepia {
    background-color: #fbf0d9;
    color: #5c4b37;
}
body.sepia #reader-container {
    background-color: #fff8e8;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}
body.sepia #reader-header, body.sepia #reader-main, body.sepia #reader-footer {
    border-color: #e5d8c3;
}
body.sepia .controls button, body.sepia .file-input-label {
    background-color: #8c765f;
    color: #fff;
}
body.sepia #chapter-list h2 {
    color: #5c4b37;
}
body.sepia #chapter-menu li:hover {
    background-color: #f5eedd;
}
body.sepia #chapter-menu li.active {
    color: #8c765f;
}
body.sepia .theme-btn {
    color: #5c4b37;
    border-color: #e5d8c3;
    background-color: #f0e0c9;
}
body.sepia .theme-btn:hover {
    background-color: #e5d8c3;
}
body.sepia .theme-btn.active {
    border-color: #8c765f;
    background-color: #8c765f;
    color: #fff8e8;
}

/* 滚动条美化（护眼模式） */
body.sepia ::-webkit-scrollbar-track {
    background: #fff8e8;
}

body.sepia ::-webkit-scrollbar-thumb {
    background: #b6a48a;
}

body.sepia ::-webkit-scrollbar-thumb:hover {
    background: #8c765f;
}