/* --- Cài đặt chung & Reset CSS --- */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: Arial, sans-serif;
    line-height: 1.6;
    background-color: #f9f9f9;
    color: #333;
}

/* --- Header --- */
#main-header {
    background-color: green;
    color: white;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    z-index: 1000;
    height: 70px; /* Chiều cao ban đầu */
    transition: height 0.3s ease-in-out;
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 0 20px;
}

#main-header.scrolled {
    height: 50px; /* Chiều cao khi cuộn */
    box-shadow: 0 2px 5px rgba(0,0,0,0.1);
}

.header-content {
    display: flex;
    align-items: center;
    gap: 15px; /* Khoảng cách giữa logo và tiêu đề */
}

.header-content .logo-link img {
    height: 50px; /* Chiều cao logo ban đầu */
    transition: height 0.3s ease-in-out;
}

#main-header.scrolled .logo-link img {
    height: 40px; /* Chiều cao logo khi cuộn */
}

.header-content h1 {
    font-size: 1.8rem;
    font-weight: bold;
    transition: font-size 0.3s ease-in-out;
}

#main-header.scrolled h1 {
    font-size: 1.5rem;
}

/* --- Main Content --- */
main {
    padding-top: 90px; /* Tạo khoảng trống cho header cố định */
    padding-bottom: 20px;
}

/* --- Khu vực điều khiển (dropdown & search) --- */
.controls-container {
    display: flex;
    justify-content: center;
    align-items: center;
    flex-wrap: wrap;
    gap: 20px;
    padding: 20px;
    margin-bottom: 20px;
    background-color: #fff;
    border-bottom: 1px solid #eee;
}

.control-item {
    min-width: 250px;
}

#category-filter, #search-input {
    width: 100%;
    padding: 12px 15px;
    border: 1px solid #ccc;
    border-radius: 5px;
    font-size: 1rem;
    background-color: #fff;
}

/* Style cho mũi tên của dropdown */
#category-filter {
    appearance: none;
    -webkit-appearance: none;
    -moz-appearance: none;
    background-image: url('data:image/svg+xml;charset=US-ASCII,%3Csvg%20xmlns%3D%22http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%22%20width%3D%22292.4%22%20height%3D%22292.4%22%3E%3Cpath%20fill%3D%22%23007CB2%22%20d%3D%22M287%2069.4a17.6%2017.6%200%200%200-13-5.4H18.4c-5%200-9.3%201.8-12.9%205.4A17.6%2017.6%200%200%200%200%2082.2c0%205%201.8%209.3%205.4%2012.9l128%20127.9c3.6%203.6%207.8%205.4%2012.8%205.4s9.2-1.8%2012.8-5.4L287%2095c3.5-3.5%205.4-7.8%205.4-12.8%200-5-1.9-9.2-5.5-12.8z%22%2F%3E%3C%2Fsvg%3E');
    background-repeat: no-repeat;
    background-position: right 15px top 50%;
    background-size: 10px auto;
}

/* --- Lưới hiển thị sách --- */
.book-grid-container {
    display: grid;
    /* Hiển thị 5 cột trên màn hình lớn */
    grid-template-columns: repeat(5, 1fr); 
    gap: 25px;
    padding: 0 25px; /* Thêm padding 2 bên */
}

.book-item {
    background-color: #fff;
    border-radius: 8px;
    overflow: hidden;
    box-shadow: 0 4px 8px rgba(0,0,0,0.1);
    transition: transform 0.2s ease, box-shadow 0.2s ease;
    text-align: center;
}

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

.book-item a {
    text-decoration: none;
    color: inherit;
}

.book-item img {
    width: 100%;
    height: auto;
    display: block;
    aspect-ratio: 2 / 3; /* Giữ tỷ lệ bìa sách thông dụng */
    object-fit: cover;
}

/* --- Responsive Design --- */

/* Màn hình Tablet */
@media (max-width: 1024px) {
    .book-grid-container {
        grid-template-columns: repeat(4, 1fr);
    }
}

@media (max-width: 768px) {
    .header-content h1 {
        font-size: 1.3rem;
    }
    .book-grid-container {
        grid-template-columns: repeat(3, 1fr);
        gap: 20px;
        padding: 0 20px;
    }
}

/* Màn hình Mobile */
@media (max-width: 480px) {
    .header-content h1 {
       font-size: 1.1rem; /* Thay vì ẩn, ta thu nhỏ chữ lại */
    }
    .book-grid-container {
        grid-template-columns: repeat(2, 1fr); /* Hiển thị 2 cột */
        gap: 15px;
        padding: 0 15px;
    }
}

/* --- Footer --- */
footer {
    text-align: center;
    padding: 25px;
    margin-top: 30px;
    background-color: #333;
    color: #f4f4f4;
    font-size: 0.9rem;
}