/* =====================================================
   Reading OS
   Main Global CSS

   Global style only
===================================================== */

/* ===============================
   全局变量
================================ */
:root{
    /* 侧边栏：收起 = 图标条宽度，展开 = 悬停浮出的宽度
       改这两个值，侧边栏和主内容的让位宽度会一起跟着变 */
    --rail:76px;
    --panel:260px;
    /* 主内容左边距：取展开宽度，侧栏弹出时压不到书籍栏 */
    --content-left:calc(var(--panel) + 16px);  /* 再留 16px，展开的侧栏和书籍栏之间始终有缝 */

    --bg-color:#f7f7f5;
    --card-color:#ffffff;
    --text-color:#222;
    --sub-text:#888;
    --border-color:#e8e8e8;
    --primary:#222;
    --shadow:0 10px 30px rgba(0,0,0,.06);
    --radius:18px;
    --transition:.3s ease;
}

/* ===============================
   深色变量
================================ */
body.dark{
    --bg-color:#111;
    --card-color:#1c1c1c;
    --text-color:#eee;
    --sub-text:#999;
    --border-color:#333;
    --primary:#eee;
}

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

html{
    width:100%;
    height:100%;
}

body{
    width:100%;
    min-height:100vh;
    background:var(--bg-color);
    color:var(--text-color);
    font-family:"Inter","PingFang SC","Microsoft YaHei",sans-serif;
    transition:background .3s,color .3s;
}

a{
    text-decoration:none;
    color:inherit;
}

button{
    border:none;
    outline:none;
    cursor:pointer;
    font-family:inherit;
}

img{
    max-width:100%;
    display:block;
}

/* ===============================
   通用隐藏类
   （用于视图切换 view-panel / stats-subview 等）
================================ */
.hidden{
    display:none !important;
}

/* ===============================
   页面基础布局
   index.html 结构为 aside.sidebar + main.main-content
================================ */
.app{
    display:flex;
    min-height:100vh;
    width:100%;
}

.main-content{
    flex:1;
    min-width:0;
    padding:35px;
    margin-left:var(--content-left, 260px); /* 让位到侧栏展开后的宽度，弹出时不会盖住内容 */
    transition:margin-left .3s ease;
}

/* 兼容旧类名 .main，二者行为一致 */
.main{
    flex:1;
    min-width:0;
    padding:35px;
}

/* 视图容器：view-panel 之间用 .hidden 切换显示 */
.view-panel{
    animation:fadeIn .4s ease;
}

/* ===============================
   顶部栏（书库页顶部 / 各视图通用顶部）
================================ */
.topbar,
.view-header{
    display:flex;
    justify-content:space-between;
    align-items:flex-start;
    margin-bottom:35px;
    flex-wrap:wrap;
    gap:15px;
}

.page-title{
    font-size:32px;
    font-weight:700;
    letter-spacing:-1px;
}

.page-sub{
    margin-top:8px;
    color:var(--sub-text);
    font-size:14px;
}

.header-actions{
    display:flex;
    align-items:center;
    gap:14px;
}

/* 简单的 detail 页顶部条（book-detail.html 使用 .top-bar） */
.top-bar{
    display:flex;
    align-items:center;
    gap:18px;
    padding:20px 35px;
    background:var(--card-color);
    border-bottom:1px solid var(--border-color);
}

.top-bar h2{
    font-size:18px;
    font-weight:600;
}

.back-button{
    width:38px;
    height:38px;
    border-radius:50%;
    background:transparent;
    font-size:18px;
    color:var(--text-color);
    transition:.25s;
}

.back-button:hover{
    background:var(--border-color);
}

/* ===============================
   搜索框
================================ */
.search-box{
    width:260px;
    height:42px;
    border-radius:30px;
    border:1px solid var(--border-color);
    background:var(--card-color);
    padding:0 20px;
    color:var(--text-color);
    font-size:14px;
    transition:.3s;
}

.search-box:focus{
    border-color:#999;
    box-shadow:0 0 0 4px rgba(0,0,0,.05);
}

body.dark .search-box:focus{
    box-shadow:0 0 0 4px rgba(255,255,255,.08);
}

/* ===============================
   通用卡片
================================ */
.card{
    background:var(--card-color);
    border-radius:var(--radius);
    border:1px solid var(--border-color);
    box-shadow:var(--shadow);
}

/* ===============================
   通用按钮
================================ */
.btn,
.add-button{
    height:42px;
    padding:0 25px;
    border-radius:30px;
    font-size:14px;
    transition:var(--transition);
    background:var(--primary);
    color:var(--card-color);
    font-weight:600;
}

.btn:hover,
.add-button:hover{
    opacity:.8;
    transform:translateY(-2px);
}

.btn-primary{
    background:var(--primary);
    color:var(--card-color);
}

.btn-primary:hover{
    opacity:.8;
    transform:translateY(-2px);
}

.btn-secondary{
    background:transparent;
    color:var(--text-color);
    border:1px solid var(--border-color);
}

.btn-secondary:hover{
    background:var(--border-color);
}

/* ===============================
   标签
================================ */
.tag{
    display:inline-flex;
    align-items:center;
    padding:5px 14px;
    border-radius:20px;
    background:#f1f1f1;
    font-size:12px;
    color:#666;
}

body.dark .tag{
    background:#333;
    color:#ccc;
}

/* ===============================
   分割线
================================ */
.divider{
    height:1px;
    background:var(--border-color);
    margin:25px 0;
}

/* ===============================
   滚动条
================================ */
::-webkit-scrollbar{
    width:8px;
}

::-webkit-scrollbar-track{
    background:transparent;
}

::-webkit-scrollbar-thumb{
    background:#ccc;
    border-radius:10px;
}

body.dark ::-webkit-scrollbar-thumb{
    background:#444;
}

/* ===============================
   空状态
================================ */
.empty-state{
    display:flex;
    flex-direction:column;
    justify-content:center;
    align-items:center;
    min-height:300px;
    color:var(--sub-text);
}

.empty-state h3{
    margin-bottom:10px;
    font-size:20px;
}

/* 更大号的空状态（书评视图等使用） */
.empty-state-large{
    display:flex;
    flex-direction:column;
    justify-content:center;
    align-items:center;
    min-height:400px;
    color:var(--sub-text);
    text-align:center;
    gap:8px;
}

.empty-state-large .empty-icon{
    font-size:48px;
    margin-bottom:10px;
}

.empty-state-large h3{
    color:var(--text-color);
    font-size:20px;
}

/* ===============================
   加载动画
================================ */
.loading{
    display:flex;
    justify-content:center;
    align-items:center;
    padding:50px;
    color:var(--sub-text);
}

.loading::after{
    content:"";
    width:25px;
    height:25px;
    border-radius:50%;
    border:3px solid #ddd;
    border-top-color:#222;
    animation:rotate 1s linear infinite;
}

@keyframes rotate{
    from{transform:rotate(0deg);}
    to{transform:rotate(360deg);}
}

/* ===============================
   页面进入动画
================================ */
.fade-in{
    animation:fadeIn .4s ease;
}

@keyframes fadeIn{
    from{
        opacity:0;
        transform:translateY(15px);
    }
    to{
        opacity:1;
        transform:none;
    }
}

/* ===============================
   响应式
================================ */
@media(max-width:900px){
    .main-content,
    .main{
        padding:25px;
        margin-left:0;
        /* 底部标签栏是浮层，给它留出高度，最后一行不会被压住 */
        padding-bottom:calc(86px + env(safe-area-inset-bottom, 0px));
    }

    .page-title{
        font-size:26px;
    }
}

@media(max-width:600px){
    .main-content,
    .main{
        padding:18px;
    }

    .topbar,
    .view-header{
        flex-direction:column;
        align-items:flex-start;
        gap:20px;
    }

    .search-box{
        width:100%;
    }

    .header-actions{
        width:100%;
        flex-direction:column;
        align-items:stretch;
    }
}
