/* =========================================================
   书友之家 全局排版样式
   依赖: Bootstrap 3.3.7 (在 bootstrap.min.css 之后引入)
   ========================================================= */

html {
    -webkit-text-size-adjust: 100%;
}

body {
    background: #f5f6f8;
    color: #333;
    font-family: "Helvetica Neue", Helvetica, "PingFang SC", "Hiragino Sans GB",
        "Microsoft YaHei", Arial, sans-serif;
}

a {
    color: #2f6fce;
}

a:hover,
a:focus {
    color: #1f4f9e;
    text-decoration: none;
}

img {
    border: 0;
}

/* ---------- 顶部导航（吸顶固定） ---------- */
.site-nav {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 1030;
    background: rgba(255, 255, 255, .96);
    -webkit-backdrop-filter: blur(8px);
    backdrop-filter: blur(8px);
    border: none;
    border-bottom: 1px solid #e8eaed;
    box-shadow: 0 1px 4px rgba(0, 0, 0, .06);
}

/* 使用该导航的页面在 body 预留顶部空间，避免内容被遮挡 */
body.site-body {
    padding-top: 76px;
}

.site-nav .navbar-brand {
    display: flex;
    align-items: center;
    gap: 8px;
    height: 50px;
    padding: 4px 15px;
}

.site-nav .navbar-brand img {
    height: 34px;
    max-height: 34px;
    width: auto;
    border-radius: 6px;
}

.site-nav .navbar-brand .brand-name {
    font-size: 18px;
    font-weight: 600;
    letter-spacing: 1px;
    color: #222;
}

.site-nav .navbar-nav > li {
    margin: 9px 4px 0 4px;
}

/* 常规按钮：描边胶囊 */
.site-nav .navbar-nav > li > a.btn {
    padding: 6px 18px;
    border: 1px solid #d9dee5;
    border-radius: 20px;
    background: #fff;
    color: #444;
    font-size: 14px;
    transition: all .15s ease;
}

.site-nav .navbar-nav > li > a.btn:hover,
.site-nav .navbar-nav > li > a.btn:focus {
    border-color: #2f6fce;
    color: #2f6fce;
    background: #f4f8ff;
}

/* 主操作按钮（创建图书）：实心强调色 */
.site-nav .navbar-nav > li > a.btn-cta {
    border: 1px solid #2f6fce;
    background: #2f6fce;
    color: #fff;
}

.site-nav .navbar-nav > li > a.btn-cta:hover,
.site-nav .navbar-nav > li > a.btn-cta:focus {
    border-color: #2560c4;
    background: #2560c4;
    color: #fff;
}

/* 登录后下拉菜单 */
.site-nav .navbar-nav .dropdown-toggle {
    padding-top: 13px;
    padding-bottom: 13px;
    color: #444;
}

.site-nav .navbar-nav .dropdown-menu {
    border-radius: 8px;
    box-shadow: 0 4px 14px rgba(0, 0, 0, .12);
    padding: 6px 0;
}

/* 导航搜索框：圆角，放大镜按钮内嵌右侧 */
.site-nav .nav-search {
    display: flex;
    align-items: center;
    float: right;
    height: 34px;
    margin: 8px 12px 0 0;
    border: 1px solid #d9dee5;
    border-radius: 20px;
    background: #f2f4f7;
    overflow: hidden;
}

.site-nav .nav-search input {
    width: 150px;
    height: 100%;
    padding: 0 4px 0 14px;
    border: none;
    outline: none;
    background: transparent;
    font-size: 13px;
    color: #333;
}

.site-nav .nav-search input:focus {
    background: #fff;
}

.site-nav .nav-search .nav-search-btn {
    flex-shrink: 0;
    width: 34px;
    height: 100%;
    border: none;
    background: transparent;
    color: #7c8794;
    cursor: pointer;
    font-size: 14px;
    line-height: 1;
    transition: color .15s ease;
}

.site-nav .nav-search .nav-search-btn:hover {
    color: #2f6fce;
}

/* ---------- 书架网格（列数随屏幕宽度自适应） ---------- */
.book-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
    gap: 24px 16px;
    margin: 0;
}

.book-card {
    padding: 0;
    text-align: center;
}

.book-card .cover {
    display: block;
    overflow: hidden;
    border-radius: 6px;
    background: #fff;
    box-shadow: 0 2px 8px rgba(0, 0, 0, .10);
    transition: box-shadow .2s ease, transform .2s ease;
}

.book-card .cover:hover {
    box-shadow: 0 8px 20px rgba(0, 0, 0, .18);
    transform: translateY(-3px);
}

.book-card .cover img {
    display: block;
    width: 100%;
    height: auto;
    min-height: 180px;
    background: #eceff3;
}

.book-card .title {
    margin-top: 10px;
    font-size: 15px;
    line-height: 1.4;
}

.book-card .title a {
    color: #333;
    font-weight: 600;
}

.book-card .title a:hover {
    color: #2f6fce;
}

/* ---------- 侧栏面板 ---------- */
.side-panel {
    margin-bottom: 22px;
    padding: 16px 18px 10px;
    background: #fff;
    border: 1px solid #e8eaed;
    border-radius: 6px;
}

.side-panel .panel-title {
    margin: 0 0 12px;
    padding-bottom: 10px;
    border-bottom: 1px solid #f0f1f3;
    font-size: 16px;
    color: #333;
    font-weight: 600;
}

.side-panel .update-list {
    margin: 0;
    padding: 0;
    list-style: none;
}

.side-panel .update-list li {
    padding: 10px 0;
    border-bottom: 1px dashed #eef0f2;
}

.side-panel .update-list li:last-child {
    border-bottom: none;
}

.side-panel .update-list a {
    display: block;
    color: #444;
    font-size: 14px;
    line-height: 1.5;
}

.side-panel .update-list a:hover {
    color: #2f6fce;
}

/* ---------- 分页 ---------- */
.page-wrap {
    margin: 8px 0 32px;
    text-align: center;
}

.page-wrap .pagination {
    margin: 0;
}

/* ---------- 滚动加载提示 ---------- */
.load-more-tip {
    padding: 26px 0 30px;
    text-align: center;
    color: #9aa2ab;
    font-size: 13px;
}

/* ---------- 图书 / 文章 模式切换 ---------- */
.mode-switch {
    display: flex;
    gap: 8px;
    margin: 4px 0 22px;
}

.mode-switch a {
    padding: 6px 22px;
    border: 1px solid #d9dee5;
    border-radius: 20px;
    background: #fff;
    color: #555;
    font-size: 14px;
    text-decoration: none;
    transition: all .15s ease;
}

.mode-switch a:hover {
    border-color: #2f6fce;
    color: #2f6fce;
}

.mode-switch a.active {
    background: #2f6fce;
    border-color: #2f6fce;
    color: #fff;
}

/* ---------- 文章列表 ---------- */
.article-list {
    padding: 6px 20px;
    background: #fff;
    border: 1px solid #e8eaed;
    border-radius: 8px;
}

.article-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    padding: 14px 4px;
    border-bottom: 1px dashed #eef0f2;
}

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

.article-item .article-name {
    flex: 1;
    min-width: 0;
    overflow: hidden;
    white-space: nowrap;
    text-overflow: ellipsis;
    color: #333;
    font-size: 15px;
}

.article-item .article-name:hover {
    color: #2f6fce;
}

.article-item .article-time {
    flex-shrink: 0;
    color: #9aa2ab;
    font-size: 13px;
}

.article-item .article-book {
    flex-shrink: 0;
    max-width: 220px;
    margin-right: 14px;
    padding: 2px 10px;
    overflow: hidden;
    white-space: nowrap;
    text-overflow: ellipsis;
    border-radius: 12px;
    background: #eef4ff;
    color: #2f6fce;
    font-size: 12px;
}

.article-item .article-book:hover {
    background: #dce9ff;
}

/* 夜间模式 */
body.night-mode .mode-switch a {
    background: #1c1f22;
    border-color: #33373c;
    color: #c6ccd2;
}

body.night-mode .mode-switch a.active {
    background: #2f6fce;
    border-color: #2f6fce;
    color: #fff;
}

body.night-mode .article-list {
    background: #1c1f22;
    border-color: #2a2e33;
}

body.night-mode .article-item {
    border-color: #2a2e33;
}

body.night-mode .article-item .article-name {
    color: #c6ccd2;
}

body.night-mode .article-item .article-time {
    color: #7a828a;
}

body.night-mode .article-item .article-book {
    background: #23272b;
    color: #6ea0f0;
}

body.night-mode .article-item .article-book:hover {
    background: #2a2e33;
}

/* ---------- 页脚 ---------- */
.site-footer {
    margin-top: 36px;
    padding: 28px 16px 32px;
    background: #fff;
    border-top: 1px solid #e8eaed;
    color: #666;
    text-align: center;
    font-size: 13px;
    line-height: 1.9;
}

.site-footer a {
    color: #2f6fce;
}

/* ---------- 模态框 / 表单 ---------- */
.modal-content {
    border-radius: 8px;
    box-shadow: 0 8px 30px rgba(0, 0, 0, .16);
}

.modal-header {
    border-bottom: 1px solid #f0f1f3;
}

.modal-title {
    font-size: 18px;
    font-weight: 600;
}

.auth-form .form-group {
    margin-bottom: 18px;
}

.auth-form label {
    display: block;
    margin-bottom: 6px;
    color: #555;
    font-weight: 500;
    text-align: left;
}

.auth-form .captcha-row {
    display: flex;
    align-items: center;
    gap: 10px;
}

.auth-form .captcha-row input {
    flex: 1;
}

.auth-form .captcha-row img {
    height: 38px;
    width: auto;
    border: 1px solid #e0e3e8;
    border-radius: 4px;
    cursor: pointer;
}

/* ---------- 用户主页头部 ---------- */
.user-head {
    margin: 4px 0 26px;
    padding: 24px 20px;
    background: #fff;
    border: 1px solid #e8eaed;
    border-radius: 8px;
    text-align: center;
}

.user-head img {
    width: 72px;
    height: 72px;
    border-radius: 50%;
    border: 3px solid #fff;
    box-shadow: 0 2px 8px rgba(0, 0, 0, .12);
}

.user-head .user-name {
    display: block;
    margin-top: 10px;
    font-size: 20px;
    font-weight: 600;
    color: #222;
}

/* ---------- 书籍阅读页 ---------- */
.reading-topbar {
    position: absolute;
    top: 10px;
    left: 10px;
    z-index: 20;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 10px;
    background: rgba(255, 255, 255, .92);
    border: 1px solid #e4e7eb;
    border-radius: 20px;
    box-shadow: 0 2px 6px rgba(0, 0, 0, .08);
}

.reading-topbar img {
    height: 26px;
    width: auto;
}

.reading-topbar .tool-btn {
    display: inline-block;
    padding: 3px 10px;
    color: #555;
    cursor: pointer;
    border-left: 1px solid #e4e7eb;
    font-size: 14px;
    line-height: 20px;
    text-decoration: none;
}

.reading-topbar .tool-btn:hover {
    color: #2f6fce;
}

/* 左侧目录栏 */
.chapter-pane {
    background: #fbfcfe;
}

.chapter-pane .book-head {
    padding: 16px 20px 10px;
    text-align: center;
    border-bottom: 1px solid #edf0f3;
}

.chapter-pane .book-head .cover {
    display: inline-block;
    margin-bottom: 12px;
    border-radius: 6px;
    box-shadow: 0 4px 14px rgba(0, 0, 0, .16);
    background: #fff;
    overflow: hidden;
}

.chapter-pane .book-head .cover img {
    display: block;
    max-height: 300px;
    width: auto;
}

.chapter-pane .book-head h1 {
    margin: 0 0 10px;
    font-size: 22px;
    line-height: 1.35;
    color: #222;
    word-break: break-all;
}

.chapter-pane .book-head .meta {
    color: #666;
    font-size: 13px;
    line-height: 1.8;
    word-break: break-all;
}

.chapter-pane .book-head .meta b {
    color: #444;
    font-weight: 600;
}

.chapter-pane .book-head .actions {
    margin-top: 12px;
}

.chapter-pane .book-head .actions .btn {
    margin: 3px 4px;
    font-size: 12px;
    padding: 4px 12px;
}

/* 章节树 */
.tree-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin: 0 16px 4px;
    padding: 12px 2px 8px;
    border-bottom: 1px solid #edf0f3;
}

.tree-head .tree-head-title {
    font-size: 13px;
    font-weight: 600;
    letter-spacing: 2px;
    color: #98a1ac;
}

.tree-head .tree-head-tools a {
    margin-left: 10px;
    font-size: 12px;
    color: #98a1ac;
}

.tree-head .tree-head-tools a:hover {
    color: #2f6fce;
}

.chapter-tree {
    margin: 0;
    padding: 4px 0 30px;
    list-style: none;
}

/* 层级缩进 + 虚线引导线 */
.chapter-tree ul {
    margin: 0 0 0 18px;
    padding-left: 14px;
    list-style: none;
    border-left: 1px dashed #e2e6eb;
}

.chapter-tree li {
    position: relative;
    margin: 1px 0;
}

/* 行式布局：箭头 | 链接 | 操作 */
.chapter-tree .tree-row {
    display: flex;
    align-items: center;
}

.chapter-tree .tree-toggle {
    flex-shrink: 0;
    width: 16px;
    margin-right: 2px;
    font-size: 10px;
    text-align: center;
    color: #a8b0ba;
    cursor: pointer;
    user-select: none;
    transition: transform .15s ease;
}

.chapter-tree li.has-child > .tree-row .tree-toggle {
    color: #7c8794;
}

.chapter-tree li.leaf > .tree-row .tree-toggle {
    visibility: hidden;
    cursor: default;
}

.chapter-tree li.collapsed > .tree-row .tree-toggle {
    transform: rotate(-90deg);
}

.chapter-tree li.collapsed > ul {
    display: none;
}

.chapter-tree .tree-link {
    flex: 1;
    display: flex;
    align-items: center;
    min-width: 0;
    padding: 5px 8px 5px 4px;
    color: #444;
    font-size: 14px;
    line-height: 1.5;
    border-radius: 4px;
}

.chapter-tree .link-text {
    overflow: hidden;
    white-space: nowrap;
    text-overflow: ellipsis;
}

.chapter-tree .tree-link:hover {
    background: #eef4ff;
    color: #2f6fce;
}

/* 编辑操作：悬停显示 */
.chapter-tree .tree-actions {
    flex-shrink: 0;
    padding-right: 8px;
    opacity: 0;
    transition: opacity .15s ease;
}

.chapter-tree li:hover > .tree-row .tree-actions {
    opacity: 1;
}

.chapter-tree .tree-actions a {
    margin-left: 6px;
    font-size: 12px;
    color: #8a97a8;
}

.chapter-tree .tree-actions a:hover {
    color: #2f6fce;
}

/* 当前章节高亮 */
.chapter-tree li.current > .tree-row .tree-link {
    background: #eaf1ff;
    color: #2f6fce;
    font-weight: 600;
}

.chapter-tree li.current > .tree-row .tree-toggle {
    color: #2f6fce;
}

/* 正文上下章导航 */
.article-nav {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 34px;
    padding-top: 18px;
    border-top: 1px solid #f0f1f3;
}

.article-nav .btn {
    min-width: 96px;
}

/* 字号调节 */
.article-content {
    transition: font-size .15s ease;
}

/* 未选择章节时的占位提示 */
.article-empty {
    padding: 80px 0;
    text-align: center;
    color: #b0b6bd;
}

.article-empty .glyphicon {
    display: block;
    margin-bottom: 16px;
    font-size: 44px;
}

.article-empty p {
    margin: 0;
    font-size: 15px;
    text-indent: 0;
}

body.night-mode .article-empty {
    color: #6b7280;
}

/* ---------- 夜间模式 ---------- */
body.night-mode .article-pane {
    background: #17191c;
}

body.night-mode .article-box h1 {
    color: #e6e8ea;
}

body.night-mode .article-meta {
    color: #7a828a;
    border-color: #2a2e33;
}

body.night-mode .article-content {
    color: #c6ccd2;
}

body.night-mode .article-nav {
    border-color: #2a2e33;
}

body.night-mode .chapter-pane {
    background: #1c1f22;
}

body.night-mode .book-head {
    border-color: #2a2e33;
}

body.night-mode .book-head h1 {
    color: #e6e8ea;
}

body.night-mode .book-head .meta {
    color: #9aa2aa;
}

body.night-mode .tree-head {
    border-color: #2a2e33;
}

body.night-mode .tree-head .tree-head-title,
body.night-mode .tree-head .tree-head-tools a {
    color: #7a828a;
}

body.night-mode .tree-head .tree-head-tools a:hover {
    color: #6ea0f0;
}

body.night-mode .chapter-tree ul {
    border-color: #2f343a;
}

body.night-mode .chapter-tree .tree-toggle {
    color: #6b7280;
}

body.night-mode .chapter-tree li.has-child > .tree-row .tree-toggle {
    color: #9aa2aa;
}

body.night-mode .chapter-tree .tree-link {
    color: #c6ccd2;
}

body.night-mode .chapter-tree .tree-link:hover {
    background: #23272b;
    color: #6ea0f0;
}

body.night-mode .chapter-tree li.current > .tree-row .tree-link {
    background: #23272b;
    color: #6ea0f0;
}

body.night-mode .chapter-tree .tree-actions a {
    color: #6b7280;
}

body.night-mode .chapter-tree .tree-actions a:hover {
    color: #6ea0f0;
}

body.night-mode .reading-topbar {
    background: rgba(28, 31, 34, .94);
    border-color: #33373c;
}

body.night-mode .reading-topbar .tool-btn {
    color: #c6ccd2;
    border-color: #33373c;
}

body.night-mode .reading-topbar .tool-btn:hover {
    color: #6ea0f0;
}

body.night-mode .pane-divider {
    background: #33373c !important;
    border-color: #33373c !important;
}

/* 右侧正文 */
.article-pane {
    background: #fff;
}

.article-pane .article-box {
    max-width: 780px;
    margin: 0 auto;
    padding: 40px 32px 60px;
}

.article-pane h1 {
    margin: 0 0 6px;
    text-align: center;
    font-size: 26px;
    color: #222;
    line-height: 1.4;
    word-break: break-all;
}

.article-pane .article-meta {
    text-align: center;
    color: #999;
    font-size: 13px;
    padding-bottom: 18px;
    border-bottom: 1px solid #f0f1f3;
    margin-bottom: 26px;
}

.article-pane .article-content {
    font-size: 16px;
    line-height: 1.9;
    color: #333;
    word-break: break-word;
}

.article-pane .article-content p {
    margin: 0 0 14px;
    text-indent: 2em;
}

.article-pane .article-content img {
    display: block;
    max-width: 100%;
    margin: 12px auto;
    border-radius: 4px;
}

/* 分隔条 */
.pane-divider {
    background: #d8dce2 !important;
    border-color: #d8dce2 !important;
}

/* ---------- 通用页面容器（表单页等） ---------- */
.page-shell {
    max-width: 860px;
    margin: 0 auto 40px;
    padding: 28px 30px;
    background: #fff;
    border: 1px solid #e8eaed;
    border-radius: 8px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, .05);
}

.page-shell h1 {
    margin: 0 0 24px;
    text-align: center;
    font-size: 24px;
    color: #222;
}

/* ---------- 小屏适配 ---------- */
@media (max-width: 767px) {
    body.site-body {
        padding-top: 62px;
    }

    .site-nav .navbar-brand {
        height: 46px;
    }

    .site-nav .navbar-brand img {
        height: 30px;
    }

    .site-nav .navbar-brand .brand-name {
        font-size: 16px;
    }

    .site-nav .navbar-nav > li {
        margin: 4px 0;
        text-align: center;
    }

    .site-nav .navbar-nav > li > a.btn {
        display: block;
        margin: 0 12px;
    }

    /* 搜索框移动端：占满一行 */
    .site-nav .nav-search {
        float: none;
        margin: 4px 12px 8px;
    }

    .site-nav .nav-search input {
        flex: 1;
        width: auto;
    }

    .article-pane .article-box {
        padding: 24px 16px 40px;
    }

    .article-pane h1 {
        font-size: 21px;
    }

    .article-pane .article-content {
        font-size: 15px;
        line-height: 1.8;
    }
}
