/* 全局样式 */
:root {
    --transition-speed: 0.3s;
}
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, 'Open Sans', 'Helvetica Neue', sans-serif;
    line-height: 1.6;
    color: #333;
    background-color: #f5f5f5;
}
h1{line-height: normal!important;}
.app-container {
    display: flex;
    flex-direction: column;
    height: 100vh;
    overflow: hidden;
}

/* 工具栏固定在顶部 */
.toolbar {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    height: 50px;
    background-color: #f5f5f5;
    border-bottom: 1px solid #ddd;
    display: flex;
    align-items: center;
    padding: 0 20px;
    z-index: 1000;
    min-width: 600px;
}
.special-formaturl{font-size:12px;margin-left:10px;}
.special-formaturl strong{margin-left:5px;}

.special-formaturl a{ margin-right:10px; }
.special-formaturl em{font-style: normal; font-weight: bold;}
.toolbar button {
    margin-right: 10px;
    padding: 8px 15px;
    border: none;
    border-radius: 4px;
    background-color: #007bff;
    color: white;
    cursor: pointer;
    transition: background-color 0.2s;
}

.toolbar button:hover {
    background-color: #0056b3;
}

/* 主要内容区域 */
.main-content {
    display: flex;
    height: 100vh;
    padding-top: 50px; /* 工具栏高度 */
    box-sizing: border-box;
}

.sidebar {
    width: 300px;
    height: 100%;
    background: #ffffff;
    box-shadow: 2px 0 5px rgba(0, 0, 0, 0.1);
    z-index: 2;
    display: flex;
    flex-direction: column;
    position: fixed;
    left: 0;
    top: 50px; /* 工具栏高度 */
    bottom: 0;
    transform: translateX(0);
    transition: all var(--transition-speed) ease;
    will-change: transform;
    backface-visibility: hidden; /* 添加这行 */
    -webkit-backface-visibility: hidden; /* 添加这行 */
}


/* 目录容器样式 */
.toc-container {
    flex: 1;
    padding: 20px;
    overflow-y: auto;
    background: #ffffff;
}

.toc-container h3 {
    margin: 0 0 15px 0;
    padding-bottom: 10px;
    border-bottom: 1px solid #e8eaed;
    color: #202124;
    font-size: 16px;
}

/* 目录列表样式 */
#toc {
    overflow-y: auto;
}

#toc ul {
    list-style: none;
    padding: 0;
    margin: 0;
}

#toc li {
    margin: 0;
    padding: 0;
}

#toc a {
    display: block;
    padding: 8px 15px;
    color: #333333;
    text-decoration: none;
    font-size: 14px;
    line-height: 1.4;
    border-radius: 4px;
    margin: 2px 0;
    transition: all 0.2s ease;
}

#toc a:hover {
    background-color: #f5f5f5;
    color: #1a73e8;
}

#toc a.active {
    background-color: #e8f0fe;
    color: #1a73e8;
    font-weight: 500;
}

/* 目录层级样式 */
#toc ul ul {
    margin-left: 15px;
}

#toc ul ul a {
    font-size: 13px;
    color: #5f6368;
}

/* 内容容器样式 */
.content-container {
    flex: 1;
    height: 100%;
    overflow: hidden;
    position: relative;
    transition: all var(--transition-speed) ease;
    will-change: margin-left;
    backface-visibility: hidden;
    -webkit-backface-visibility: hidden;
}

/* 遮罩层样式 */
.sidebar-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 999;
}


/* 书签容器样式 */
.bookmarks-container {
    padding: 20px;
    border-top: 1px solid #e8eaed;
}

.bookmarks-container h3 {
    margin: 0 0 15px 0;
    color: #202124;
    font-size: 16px;
}

/* 加载状态样式 */
#toc.loading {
    position: relative;
    min-height: 100px;
}

#toc.loading::after {
    content: '加载中...';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    color: #666;
    font-size: 14px;
}

/* 错误状态样式 */
.error-text {
    color: #d93025;
    text-align: center;
    padding: 20px;
    font-size: 14px;
}

/* 阅读器容器 */
#reader-container {
    position: relative;
    height: calc(100% - 60px); /* 减去底部控制栏高度 */
    overflow: auto;
    padding: 20px;
    width: 100%;
}

#content {
    max-height: 80vh; 
    overflow-y: auto; 
    padding: 10px; 
}
/* PDF容器 */
#pdf-container {
    text-align: center;
    position: absolute;
    top: 0px;
    right: 0;
    width: 100%;
    height: 100%;
    overflow: auto;
    display: none;
    background: #f0f0f0;
    text-align: center;
    padding-top:30px;
}

#pdf-canvas {
    margin: 20px auto;
    box-shadow: 0 2px 10px rgba(0,0,0,0.1);
    background: white;
}
/* 控制栏 */
.reader-controls {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    height: 60px;
    background-color: #f5f5f5;
    border-top: 1px solid #ddd;
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0 20px;
    transition: left var(--transition-speed) ease;
    z-index: 100;
}

.reader-controls .left-controls,
.reader-controls .center-controls,
.reader-controls .right-controls {
    display: flex;
    align-items: center;
    gap: 10px;
}
.pdf-only {
    display: none;
}
.is-pdf-view .pdf-only {
    display: inline-block;
}
.reader-controls .control-button {
    background: #4a90e2;
    color: white;
    border: none;
    padding: 8px 5px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 14px;
    transition: background-color 0.2s;
}

.reader-controls .control-button:hover {
    background: #357abd;
}

.reader-controls .control-button:disabled {
    background: #ccc;
    cursor: not-allowed;
}

.reader-controls .page-info {
    font-size: 14px;
    color: #333;
    margin: 0 10px;
}

/* PDF 专用按钮 */

.is-pdf .pdf-only {
    display: inline-block;
}

.text-paragraph{padding:50px 0;}


/* 桌面端样式 */
@media screen and (min-width: 769px) {
      /* 默认和打开状态 */
      .sidebar-open .content-container,
      .content-container {
          margin-left: 300px!important;
      }
  
      /* 关闭状态 */
      .sidebar-closed .sidebar {
          transform: translateX(-300px)!important;
      }
  
      .sidebar-closed .content-container {
          margin-left: 0!important;
      }
    /* 默认和打开状态 */
    .app-container .main-content .content-container {
        margin-left: 300px!important;
    }

    /* 关闭状态 */
    .app-container.sidebar-closed .main-content .sidebar {
        transform: translateX(-300px)!important;
    }

    .app-container.sidebar-closed .main-content .content-container {
        margin-left: 0!important;
    }

    /* 确保遮罩层在桌面模式下不显示 */
    .sidebar-overlay {
        display: none !important;
    }
}

/* 移动端样式 */
@media screen and (max-width: 768px) {
    .sidebar {
        transform: translateX(-300px);
        z-index: 999;
    }

    .sidebar-open .sidebar {
        transform: translateX(0);
    }

    .content-container {
        margin-left: 0;
    }
    .app-container .main-content .sidebar {
        transform: translateX(-300px);
    }

    .app-container .main-content .content-container {
        margin-left: 0;
    }

    .app-container.sidebar-open .main-content .sidebar {
        transform: translateX(0);
    }

    .app-container.sidebar-open .sidebar-overlay {
        display: block;
    }
}
/* EPUB查看器样式 */
#epub-viewer {
    width: 100%;
    height: 100%;
    overflow: auto;
    position: relative;
    background: #fff;
}

#reader-container {
    width: 100%;
    height: calc(100vh - 120px); /* Adjust based on your toolbar/controls height */
    position: relative;
    overflow: hidden;
}

/* EPUB specific styles */
.epub-container {
    width: 100%;
    height: 100%;
    overflow: hidden;
    position: relative;
    background: #fff;
}

.epub-container iframe {
    border: none;
    width: 100%;
    height: 100%;
}

/* 加载状态 */
.loading {
    cursor: wait !important;
    pointer-events: none;
    opacity: 0.6;
}

button:disabled {
    opacity: 0.5;
    cursor: not-allowed !important;
}

.loading-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(255, 255, 255, 0.9);
    z-index: 1000;
    justify-content: center;
    align-items: center;
    flex-direction: column;
}

.loading-overlay.active {
    display: flex;
}

.loading-spinner {
    width: 50px;
    height: 50px;
    border: 5px solid #f3f3f3;
    border-top: 5px solid #3498db;
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin-bottom: 20px;
}

.loading-text {
    font-size: 18px;
    color: #333;
    text-align: center;
    margin-top: 10px;
}

.progress-bar {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 3px;
    background: #f3f3f3;
    z-index: 1001;
}

.progress-bar.active {
    display: block;
}

.progress-bar-inner {
    width: 0;
    height: 100%;
    background: #3498db;
    transition: width 0.3s ease-in-out;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* 禁用状态的导航和目录 */
.disabled {
    pointer-events: none;
    opacity: 0.5;
}

#toc.loading {
    position: relative;
}

#toc.loading::after {
    content: '加载中...';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: rgba(255, 255, 255, 0.9);
    padding: 10px;
    border-radius: 4px;
    font-size: 14px;
}

/* 加载指示器 */
.loading-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: rgba(255, 255, 255, 0.9);
    z-index: 9999;
    justify-content: center;
    align-items: center;
    flex-direction: column;
}

.loading-overlay.active {
    display: flex;
}

.loading-spinner {
    width: 50px;
    height: 50px;
    border: 4px solid #f3f3f3;
    border-top: 4px solid #3498db;
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin-bottom: 15px;
}

.loading-text {
    color: #333;
    font-size: 16px;
    font-weight: 500;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* 进度条 */
.progress-bar {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 3px;
    background-color: #f3f3f3;
    z-index: 10000;
    display: none;
}

.progress-bar.active {
    display: block;
}

.progress-bar-inner {
    width: 0;
    height: 100%;
    background-color: #3498db;
    transition: width 0.3s ease;
}

/* 页面切换动画 */
.page-transition {
    opacity: 0;
    transition: opacity 0.3s ease;
}

.page-transition.active {
    opacity: 1;
}

/* 主题样式更新 */
.theme-light {
    background-color: #fff;
    color: #333;
}

.theme-dark {
    background-color: #333;
    color: #fff;
}

.theme-sepia {
    background-color: #f4ecd8;
    color: #5b4636;
}

/* 设置按钮样式 */
#toggle-settings {
    padding: 8px 15px;
    border: none;
    border-radius: 4px;
    background-color: #007bff;
    color: white;
    cursor: pointer;
    transition: background-color 0.2s;
}

#toggle-settings:hover {
    background-color: #0056b3;
}

/* 设置面板样式 */
.settings {
    position: relative;
}

.settings-panel {
    display: none;
    position: absolute;
    top: 100%;
    right: -200px;
    width: 300px;
    background-color: white;
    border: 1px solid #dee2e6;
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
    z-index: 1000;
    margin-top: 8px;
    max-height: calc(100vh - 150px); /* 防止面板过长 */
    overflow-y: auto; /* 如果内容过多，允许滚动 */
}

/* 当设置面板超出右侧边界时，向左对齐 */
@media (max-width: 500px) {
    .settings-panel {
        right: auto;
        left: 0;
    }
}

/* 确保设置面板在小屏幕上也能完全显示 */
@media (max-height: 600px) {
    .settings-panel {
        max-height: calc(100vh - 100px);
    }
}

 /* 设置面板样式 */
 .settings {
    position: relative;
}

.settings-panel.show {
    display: block;
}

.settings-content {
    padding: 20px;
}

.setting-group {
    margin-bottom: 15px;
}

.setting-group label {
    display: block;
    margin-bottom: 5px;
    font-weight: 500;
}

.setting-group select,
.setting-group input[type="range"],
.setting-group input[type="color"] {
    width: 100%;
    padding: 5px;
    border: 1px solid #ddd;
    border-radius: 4px;
}

.range-with-value {
    display: flex;
    align-items: center;
    gap: 10px;
}

.range-with-value input[type="range"] {
    flex: 1;
}

.range-with-value span {
    min-width: 50px;
    text-align: right;
}

.color-inputs {
    margin-top: 15px;
}

.color-setting {
    margin-bottom: 10px;
}

.color-setting label {
    display: inline-block;
    width: 80px;
}

.color-setting input[type="color"] {
    width: calc(100% - 90px);
    height: 30px;
    padding: 0;
    border: 1px solid #ddd;
    border-radius: 4px;
}

