.search-page {
    display: flex;
    gap: 30px;
    padding: 20px;
    align-items: flex-start; /* QUAN TRỌNG */
}
.filter-sidebar {
    width: 260px;
    background: #fff;
    border-radius: 10px;
    padding: 18px;
    border: 1px solid #eee;

    position: sticky;
    top: 20px;
    align-self: flex-start;

    max-height: calc(100vh - 40px);
    overflow-y: auto;
}

.filter-block {
    margin-bottom: 25px;
    display: flex;
    flex-direction: column;
    max-height: 300px;
}

.filter-header {
    font-weight: 600;
    margin-bottom: 12px;
    display: flex;
    flex-shrink: 0;
    align-items: center;
    gap: 6px;
}
.filter-list {
    overflow-y: auto;
    flex: 1;
}
.filter-item {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 8px;
    cursor: pointer;
    font-size: 14px;
}

.category-tree {
    list-style: none;
    padding-left: 0;
    overflow-y: auto;
    flex: 1;
}
.filter-list,
.category-tree {
    scroll-behavior: smooth;
}
.filter-list,
.category-tree {
    padding-right: 4px;
}

.category-parent {
    flex: 1;
    display: flex;
    align-items: center;
    gap: 6px;
    margin: 0px 0px 4px 8px;
}

.category-parent .filter-count {
    margin-left: auto;
}

.category-name {
    flex: 1;
    cursor: pointer;
}

.toggle-icon {
    width: 14px;
}

.children {
    padding-left: 18px;
}

.book-area {
    flex: 1;
    min-width: 0; 
}

.search-header {
    margin-bottom: 15px;
    display: flex;
    gap: 10px;
}

.search-input {
    flex: 1;
    padding: 8px 12px;
    border-radius: 6px;
    border: 1px solid #ddd;
}

.search-btn {
    border: none;
    background: #ff7a00;
    color: #fff;
    padding: 8px 16px;
    border-radius: 6px;
    cursor: pointer;
    font-weight: 600;
}

/* @author: trong.lq */
/* @date: 11/03/2026 */
/* CSS cho component books_section (carousel variant) - Giống với _books_section.html.erb */

/* Suggested Section */
.suggested-section {
    margin-top: 0;
    width: 100%;
    box-sizing: border-box;
    background: #fff;
}

.suggested-section .container {
    max-width: 1140px;
    margin: 0 auto;
}

.suggested-section .section-heading {
    margin-bottom: 40px;
}

.section-heading {
    font-size: 28px;
    font-weight: 700;
    color: #c24914;
    text-align: center;
    margin-bottom: 30px;
}

.section-heading--primary {
    color: #c24914;
}

.section-heading--center {
    text-align: center;
}

.section-heading--lg {
    font-size: 32px;
}

/* Carousel Wrapper */
.carousel-wrapper {
    position: relative;
    max-width: 1140px;
    margin: 0 auto;
}

/* Books Carousel */
.books-carousel {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    gap: 20px;
    padding: 20px 0;
    overflow: hidden;
    align-items: stretch;
}

/* Book Card */
.book-card {
    background: #fff;
    border-radius: 8px;
    overflow: hidden;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    transition: transform 0.3s;
    cursor: pointer;
    display: flex;
    flex-direction: column;
    height: 100%;
    min-height: 454px;
}

.book-card:hover {
    transform: translateY(-5px);
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.15);
}

.book-card img,
.book-card .book-card-image {
    width: 100%;
    height: 340px;
    object-fit: cover;
    background: #f0f0f0;
    transition: opacity 0.3s ease;
    flex-shrink: 0;
}

.book-card-content {
    padding: 15px;
    display: flex;
    flex-direction: column;
    flex: 1;
    min-height: 114px;
}

.book-card-title {
    font-size: 14px;
    font-weight: 600;
    color: #333;
    margin-bottom: 8px;
    line-height: 1.4;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    min-height: 40px;
    flex-shrink: 0;
}

.book-card-author {
    font-size: 12px;
    color: #666;
    margin-bottom: 8px;
    min-height: 18px;
    flex-shrink: 0;
}

.book-card-stats {
    display: flex;
    align-items: center;
    justify-content: space-between;
    font-size: 14px;
    font-family: "Inter", sans-serif;
    font-weight: 500;
    color: #333;
    gap: 20px;
    margin-top: auto;
    padding-top: 8px;
    height: auto;
    line-height: 1;
    min-height: 24px;
}

.book-card-stats span {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    font-size: 14px;
    font-family: "Inter", sans-serif;
    font-weight: 500;
    color: #333;
    line-height: 1;
    vertical-align: middle;
    flex-shrink: 0;
}

.book-card-stats .favorite-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    vertical-align: middle;
}

.book-card-stats i {
    color: #333;
    font-size: 14px;
    width: 14px;
    height: 14px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    line-height: 1;
}

.favorite-icon {
    font-size: 16px;
    color: #999;
    cursor: pointer;
    flex-shrink: 0;
}

.favorite-icon.active {
    color: #c24914;
}

/* Responsive */
@media (max-width: 1200px) {

    .suggested-section .container,
    .carousel-wrapper {
        max-width: 100%;
        padding: 0 20px;
    }

    .books-carousel {
        grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
        justify-content: center;
    }

    .book-card {
        width: 100%;
    }
}

@media (max-width: 980px) {

    .books-carousel {
        display: grid;
        grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
        gap: 20px;
        overflow: visible;
    }

    .book-card {
        width: 100%;
        min-height: 420px;
    }

}

@media (max-width: 768px) {

    .books-carousel {
        grid-template-columns: repeat(2, 1fr);
        gap: 15px;
    }

    .book-card {
        width: 100%;
        min-height: auto;
    }

}

@media (max-width: 480px) {
    .books-carousel {
        grid-template-columns: 1fr;
    }

    .book-card {
        max-width: none;
        /* bỏ giới hạn 270px */
        width: 100%;
    }

    .book-card .book-card-image {
        height: 250px;
    }

    .book-card-content {
        padding: 12px;
    }

    .book-card-title {
        font-size: 13px;
    }

    .book-card-author {
        font-size: 11px;
    }
}

.pagination {
    margin-top: 25px;
    display: flex;
    gap: 6px;
    justify-content: center;
}

.page-btn {
    border: none;
    background: #eee;
    padding: 6px 12px;
    border-radius: 6px;
    cursor: pointer;
}

.page-btn.active {
    background: #ff7a00;
    color: #fff;
}

.filter-item input[type="checkbox"],
.filter-item input[type="radio"] {
    appearance: auto !important;
    -webkit-appearance: auto !important;
    -moz-appearance: auto !important;
    width: 16px;
    height: 16px;
    display: inline-block !important;
    opacity: 1 !important;
    cursor: pointer;
}

.scroll-hint {
    text-align: center;
    margin: 30px 0;
    font-size: 14px;
    color: #888;
    animation: bounce 1.8s infinite;
}

@keyframes bounce {
    0% {
        transform: translateY(0)
    }

    50% {
        transform: translateY(6px)
    }

    100% {
        transform: translateY(0)
    }
}

/* =========================
   FILTER SIDEBAR SCROLL
========================= */



/* mỗi block giới hạn chiều cao */
.filter-block {
    display: flex;
    flex-direction: column;
    max-height: 300px;
}

/* phần header cố định */
.filter-header {
    flex-shrink: 0;
}


/* riêng category tree */
.category-tree {
    overflow-y: auto;
}

/* style scrollbar cho đẹp */
.filter-sidebar::-webkit-scrollbar,
.filter-block>*::-webkit-scrollbar {
    width: 6px;
}

.filter-sidebar::-webkit-scrollbar-thumb,
.filter-block>*::-webkit-scrollbar-thumb {
    background: #ddd;
    border-radius: 10px;
}

.filter-sidebar::-webkit-scrollbar-thumb:hover,
.filter-block>*::-webkit-scrollbar-thumb:hover {
    background: #bbb;
}

/* ngành */
.filter-block:nth-child(1) {
    max-height: 250px;
}

/* category */
.filter-block:nth-child(2) {
    max-height: 350px;
}

/* tag */
.filter-block:nth-child(3) {
    max-height: 250px;
}


/* =========================
   RESPONSIVE SEARCH PAGE
========================= */

/* Tablet */
@media (max-width: 1024px) {

    .search-page {
        flex-direction: column;
        gap: 20px;
        padding: 15px;
    }

    .filter-sidebar {
        width: 100%;
        display: grid;
        grid-template-columns: repeat(3, 1fr);
        gap: 15px;
    }

    .filter-block {
        margin-bottom: 0;
    }

}


/* Mobile */
@media (max-width: 768px) {

    .filter-sidebar {
        display: block;
    }

    .filter-block {
        background: #fff;
        border: 1px solid #eee;
        border-radius: 8px;
        padding: 12px;
        margin-bottom: 12px;
    }

    .filter-header {
        font-size: 14px;
    }

    .filter-item {
        font-size: 13px;
    }

}

@media (max-width:768px) {

    .category-tree {
        font-size: 13px;
    }

    .children {
        padding-left: 14px;
    }

}

@media (max-width:768px) {

    .book-card {
        min-height: auto;
    }

    .book-card img {
        height: 260px;
    }

}

.mobile-filter-btn {
    display: none;
    width: 100%;
    padding: 10px;
    border: none;
    background: #ff7a00;
    color: #fff;
    border-radius: 6px;
    margin-bottom: 10px;
}

@media (max-width:768px) {

    .mobile-filter-btn {
        display: block;
    }

    .filter-sidebar {
        display: none;
    }

    .filter-sidebar.show {
        display: block;
    }

}

.filter-count {
    margin-left: auto;
    background: #eee;
    color: #666;
    font-size: 12px;
    padding: 2px 10px;
    border-radius: 12px;
    min-width: 28px;
    text-align: center;
    font-weight: 700;
}

/* khi checkbox được chọn */
.filter-item.active .filter-count {
    background: #ffd9bf;
    color: #ff7a00;
}

/* =========================
   TEXT ELLIPSIS FILTER
========================= */

/* áp dụng cho tất cả text trong filter */
.filter-name,
.category-name {

    display: block;
    max-width: 100%;

    overflow: hidden;
    white-space: nowrap;
    text-overflow: ellipsis;
}

/* đảm bảo layout không bị vỡ */
.filter-item,
.category-parent {
    min-width: 0;
}

/* fix flex bị tràn */
.category-parent {
    flex: 1;
    display: flex;
    align-items: center;
    gap: 6px;
}

.category-name {
    flex: 1;
    min-width: 0;
    /* QUAN TRỌNG */
}