@charset "utf-8";

/* ==============================================
   基础布局样式
============================================== */
/* 主内容布局 */
.main-content {
    display: flex;
    gap: 30px;
    margin-bottom: 50px;
}

.content-section {
    flex: 1;
}

.sidebar {
    width: var(--sidebar-width);
    display: flex;
    flex-direction: column;
    gap: 30px;
    position: relative;
    height: auto;
}


/* ==============================================
   图书列表网格与卡片样式
============================================== */
.book-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr); /* 默认一行3列 */
    gap: 25px;
}

.book-card {
    background: white;
    border-radius: 10px;
    overflow: hidden;
    box-shadow: var(--shadow);
    transition: var(--transition);
    display: flex;
    flex-direction: column;
    height: 100%;
}

.book-card:hover {
    transform: translateY(-5px);
    box-shadow: 0 10px 20px rgba(0,0,0,0.1);
}

/* 图书封面容器（3:4比例） */
.book-cover-container {
    position: relative;
    width: 100%;
    padding-top: 133.33%; /* 3:4比例（高度=宽度×1.333） */
    overflow: hidden;
    background: #f5f5f5; /* 加载时背景色 */
}

.book-cover {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform 0.5s;
}

.book-card:hover .book-cover {
    transform: scale(1.05); /* 悬停放大效果 */
}

/* 图书标签（如新品、热门） */
.book-badge {
    position: absolute;
    top: 10px;
    right: 10px;
    background: var(--primary);
    color: white;
    padding: 5px 10px;
    border-radius: 20px;
    font-size: 0.8rem;
    z-index: 10;
}

/* 图书内容区域 */
.book-content {
    padding: 15px;
    flex: 1;
    display: flex;
    flex-direction: column;
}

.book-title {
    font-size: 1.1rem;
    font-weight: 600;
    margin-bottom: 8px;
    color: var(--dark);
    display: -webkit-box;
    -webkit-line-clamp: 2; /* 最多显示2行 */
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.book-author {
    color: var(--gray);
    font-size: 0.9rem;
    margin-bottom: 10px;
}

.book-rating {
    display: flex;
    align-items: center;
    margin-bottom: 15px;
}

.stars {
    color: #ffc107; /* 星级颜色（黄色） */
    margin-right: 8px;
}

.rating-value {
    font-size: 0.9rem;
    color: var(--gray);
}

.book-desc {
    color: var(--gray);
    font-size: 0.9rem;
    margin-bottom: 15px;
    display: -webkit-box;
    -webkit-line-clamp: 3; /* 最多显示3行 */
    -webkit-box-orient: vertical;
    overflow: hidden;
    flex: 1;
}

.book-meta {
    display: flex;
    justify-content: space-between;
    color: var(--gray);
    font-size: 0.85rem;
    margin-top: auto;
}

.book-actions {
    display: flex;
    gap: 10px;
    margin-top: 15px;
}

.btn-small {
    padding: 6px 15px;
    font-size: 0.85rem;
}


/* ==============================================
   侧边栏样式
============================================== */
.sidebar-card {
    background: white;
    border-radius: 10px;
    box-shadow: var(--shadow);
    padding: 20px;
    transition: var(--transition);
}

.sidebar-title {
    font-size: 1.3rem;
    margin-bottom: 15px;
    padding-bottom: 10px;
    border-bottom: 2px solid var(--light-gray);
    color: var(--primary);
    display: flex;
    align-items: center;
}

.sidebar-title i {
    margin-right: 10px;
    color: var(--secondary);
}

.sidebar-list {
    list-style: none;
}

.sidebar-list li {
    padding: 12px 0;
    border-bottom: 1px solid var(--light-gray);
    display: flex;
    align-items: center;
}

.sidebar-list li:last-child {
    border-bottom: none;
}

.sidebar-list .hot {
    color: #e74c3c; /* 热门标签颜色（红色） */
    font-size: 0.9rem;
    margin-right: 5px;
}

.sidebar-list .new {
    background: var(--primary);
    color: white;
    font-size: 0.7rem;
    padding: 2px 6px;
    border-radius: 3px;
    margin-right: 8px;
}

.sidebar-list a {
    display: flex;
    align-items: center;
    transition: var(--transition);
    width: 100%;
}

.sidebar-list a:hover,
.sidebar-list a:focus {
    color: var(--primary);
    padding-left: 5px;
}

.sidebar-list .list-meta {
    font-size: 0.8rem;
    color: var(--gray);
    margin-left: auto;
}


/* ==============================================
   专题网格样式
============================================== */
.topic-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr); /* 一行2列 */
    gap: 15px;
}

.topic-card {
    background: var(--light);
    border-radius: 8px;
    overflow: hidden;
    transition: var(--transition);
    display: flex;
    flex-direction: column;
}

.topic-card:hover,
.topic-card:focus-within {
    transform: translateY(-3px);
    box-shadow: 0 5px 15px rgba(0,0,0,0.1);
}

.topic-img {
    height: 100px;
    overflow: hidden;
}

.topic-img img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform 0.5s;
}

.topic-card:hover .topic-img img {
    transform: scale(1.05); /* 悬停放大效果 */
}

.topic-content {
    padding: 12px;
    flex: 1;
}

.topic-title {
    font-size: 0.95rem;
    font-weight: 600;
    margin-bottom: 5px;
    color: var(--dark);
}

.topic-desc {
    font-size: 0.8rem;
    color: var(--gray);
}


/* ==============================================
   图书分类筛选（TAB样式）
============================================== */
.category-tabs {
    background: white;
    border-radius: 10px;
    padding: 20px;
    margin: 20px 0;
    box-shadow: var(--shadow);
    transition: var(--transition);
    overflow: hidden;
}

.category-tabs:hover {
    box-shadow: 0 5px 15px rgba(0,0,0,0.08);
}

.tabs-header {
    display: flex;
    border-bottom: 2px solid var(--light-gray);
    margin-bottom: 20px;
    overflow-x: auto; /* 横向滚动（标签过多时） */
    scrollbar-width: none; /* 隐藏滚动条 */
    padding-bottom: 5px;
    scroll-behavior: smooth;
    -webkit-overflow-scrolling: touch; /* 移动端顺滑滚动 */
}

.tabs-header::-webkit-scrollbar {
    display: none; /* 隐藏滚动条（Chrome/Safari） */
}

.tab-item {
    padding: 10px 20px;
    cursor: pointer;
    font-weight: 500;
    white-space: nowrap; /* 文字不换行 */
    position: relative;
    transition: var(--transition);
    color: var(--gray);
    border-radius: 6px 6px 0 0;
    margin-right: 5px;
    background: transparent;
    user-select: none; /* 禁止选中文字 */
    display: flex;
    align-items: center;
    gap: 5px;
    flex-shrink: 0; /* 不压缩 */
}

.tab-item:before {
    content: '';
    position: absolute;
    bottom: -2px;
    left: 0;
    width: 0;
    height: 2px;
    background: var(--primary);
    transition: var(--transition);
}

.tab-item:hover {
    background: rgba(139, 111, 85, 0.1);
    color: var(--primary);
}

.tab-item:hover:before {
    width: 100%; /* 悬停时显示下划线 */
}

.tab-item.active {
    background: var(--primary);
    color: white;
    box-shadow: 0 2px 5px rgba(44, 110, 155, 0.2);
}

.tab-item.active:before {
    display: none; /* 激活状态不需要下划线 */
}

.tab-item.active:hover {
    background: var(--primary-light);
}

.tab-content {
    display: none;
    animation: fadeIn 0.5s cubic-bezier(0.4, 0, 0.2, 1); /* 淡入动画 */
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

.tab-content.active {
    display: block;
}


/* ==============================================
   分页样式
============================================== */
.pagination {
    display: flex;
    justify-content: center;
    margin-top: 40px;
    gap: 5px;
}

.page-item {
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%; /* 圆形按钮 */
    cursor: pointer;
    transition: var(--transition);
    font-weight: 500;
    color: var(--gray);
}

.page-item:hover:not(.disabled, .active) {
    background: rgba(44, 110, 155, 0.1);
    color: var(--primary);
}

.page-item.active {
    background: var(--primary);
    color: white;
    box-shadow: 0 2px 5px rgba(44, 110, 155, 0.2);
}

.page-item.disabled {
    color: var(--light-gray);
    cursor: not-allowed;
}


/* ==============================================
   响应式设计（按屏幕宽度从大到小排列）
============================================== */

/* 平板及小屏设备（≤992px） */
@media (max-width: 992px) {
    .mobile-menu-btn {
        display: block;
    }
    
    .nav-links,
    .user-actions {
        display: none;
    }
    
    .sidebar {
        display: none; /* 隐藏侧边栏 */
    }
    
    .main-content {
        flex-direction: column; /* 内容区垂直排列 */
    }
    
    .book-grid {
        grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); /* 自动适配列数，每列最小160px */
    }
    
    /* 容器边距调整 */
    .container {
        padding: 0 10px;
    }
    
    .category-tabs {
        padding: 15px;
    }
    
    .tabs-header {
        margin-bottom: 15px;
    }
    
    .tab-item {
        padding: 8px 15px;
        font-size: 0.9rem;
    }
    
    .section-title {
        font-size: 1.5rem;
        margin: 20px 0 15px;
    }
}


/* 手机横屏及平板竖屏（≤768px） */
@media (max-width: 768px) {
    /* 图书网格布局 */
    .book-grid {
        grid-template-columns: repeat(3, 1fr); /* 固定一行3列 */
        gap: 10px;
        margin: 10px 5px;
    }
    
    .book-card {
        margin: 0;
    }
    
    .book-cover-container {
        padding-top: 135%; /* 微调比例适配小屏 */
    }
    
    .book-content {
        padding: 8px 6px; /* 减少内边距 */
    }
    
    .book-title {
        font-size: 0.85rem;
        -webkit-line-clamp: 1; /* 只显示1行标题 */
        margin-bottom: 5px;
    }
    
    .book-author,
    .book-desc,
    .book-actions {
        display: none; /* 隐藏次要信息 */
    }
    
    .book-rating {
        margin-bottom: 8px;
    }
    
    .btn-small {
        font-size: 0.7rem;
        padding: 4px 0;
    }

    /* 容器边距 */
    .container {
        padding: 0 8px;
    }
    
    /* 分类筛选TAB样式 */
    .category-tabs {
        display: flex;
        flex-direction: column;
        padding: 0;
        background: transparent;
        box-shadow: none;
        margin: 15px 0;
    }
    
    .tabs-header {
        flex-direction: column; /* 标签垂直排列 */
        border-bottom: none;
        gap: 5px;
        padding-bottom: 5px;
    }
    
    .tab-item {
        background: white;
        border-radius: 8px;
        margin: 0 0 5px 0;
        padding: 12px 15px;
        display: flex;
        justify-content: space-between;
        align-items: center;
        box-shadow: 0 2px 5px rgba(0,0,0,0.05);
        border: 1px solid var(--light-gray);
    }
    
    .tab-item.active {
        background: var(--primary);
        color: white;
        box-shadow: 0 2px 10px rgba(44, 110, 155, 0.2);
        border-color: var(--primary);
    }
    
    .tab-content {
        order: 1; /* 内容区排在标签后 */
        margin-top: -5px;
        margin-bottom: 15px;
        border-radius: 0 0 8px 8px;
        background: white;
        box-shadow: 0 5px 15px rgba(0,0,0,0.05);
        border: 1px solid var(--light-gray);
        border-top: none;
        padding: 0;
        overflow: hidden;
        height: 0; /* 初始折叠 */
        transition: height 0.3s ease; /* 高度动画 */
    }
    
    .tab-content.active {
        height: auto; /* 展开 */
        padding: 15px; /* 显示内容 */
    }
    
    /* 圆角处理 */
    .tabs-header .tab-item:first-child {
        border-radius: 8px 8px 0 0;
    }
    
    .tab-content.active + .tab-item {
        border-radius: 0 0 8px 8px;
    }
    
    .tab-item.active {
        border-radius: 8px 8px 0 0 !important;
    }
    
    /* 分页调整 */
    .pagination {
        flex-wrap: wrap; /* 分页按钮换行 */
    }
}


/* 手机竖屏（≤480px） */
@media (max-width: 480px) {
    .book-grid {
        grid-template-columns: repeat(2, 1fr); /* 固定一行2列（更适合小屏） */
        gap: 10px;
        margin: 10px 5px;
    }
    
    /* 分类标签样式 */
    .tabs-header {
        flex-direction: column;
        border-bottom: none;
        overflow-x: visible;
        padding-bottom: 0;
    }
    
    .tab-item {
        width: 100%;
        margin-right: 0;
        margin-bottom: 5px;
        border-radius: 6px;
        border: 1px solid var(--light-gray);
        text-align: left;
        padding: 10px 15px;
        white-space: normal; /* 允许文字换行 */
    }
    
    .tab-item:before {
        display: none;
    }
    
    .tab-item.active {
        border-radius: 6px;
    }
    
    .category-tabs {
        border-radius: 0;
        margin: 10px -5px 20px;
        width: calc(100% + 10px); /* 边缘对齐屏幕 */
    }
}


/* 小屏手机（≤360px） */
@media (max-width: 360px) {
    .tab-item {
        padding: 6px 10px; /* 进一步减小内边距 */
        font-size: 0.8rem; /* 缩小字体 */
    }
}