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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    background-color: #f8f9fa;
    min-height: 100vh;
    padding: 40px 20px;
}

.container {
    max-width: 1200px;
    margin: 0 auto;
}

.header {
    text-align: center;
    margin-bottom: 40px;
}

.logo {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    margin-bottom: 6px;
}

.logo-icon {
    width: 24px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.logo-icon img {
    width: 40px;
    height: 40px;
    object-fit: contain;
}

.logo-text {
    font-size: 24px;
    font-weight: 700;
    color: #2d3748;
    padding-left: 5px;
}

.subtitle {
    font-size: 16px;
    color: #718096;
    margin-bottom: 30px;
}

.search-container {
    position: relative;
    max-width: 500px;
    margin: 0 auto 40px;
    display: flex;
}

.search-box {
    flex: 1;
    padding: 16px 20px;
    border: 2px solid #e2e8f0;
    border-radius: 12px 0 0 12px;
    font-size: 16px;
    outline: none;
    transition: all 0.3s ease;
    background: white;
}

.search-box:focus {
    border-color: #667eea;
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

.search-btn {
    padding: 16px 20px;
    background: #667eea;
    color: white;
    border: none;
    border-radius: 0 12px 12px 0;
    cursor: pointer;
    font-size: 16px;
    transition: all 0.3s ease;
}

.search-btn:hover {
    background: #5a67d8;
}

.stats {
    text-align: center;
    margin-bottom: 40px;
    color: #4a5568;
    font-size: 14px;
}

/* Thay đổi books-grid để giữ kích thước cố định */
.books-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, 300px); /* Thay auto-fit bằng auto-fill và kích thước cố định */
    gap: 24px;
    margin-bottom: 40px;
    justify-content: center; /* Căn giữa các card khi có ít card */
}

.book-card {
    background: white;
    border-radius: 16px;
    padding: 24px;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.05);
    transition: all 0.3s ease;
    border: 1px solid #e2e8f0;
    text-align: center;
    width: 300px; /* Đảm bảo width cố định */
}

.book-card:hover {
    transform: translateY(-4px);
    box-shadow: 0 12px 24px rgba(0, 0, 0, 0.1);
}

/* Cải thiện hiển thị ảnh bìa sách */
.book-cover {
    width: 140px;
    height: 200px;
    margin: 0 auto 20px;
    border-radius: 12px;
    overflow: hidden;
    position: relative;
    box-shadow: 0 8px 20px rgba(0, 0, 0, 0.15);
    background: linear-gradient(135deg, #f7fafc 0%, #edf2f7 100%);
    display: flex;
    align-items: center;
    justify-content: center;
}

.book-cover img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    object-position: center;
    border-radius: 12px;
    transition: transform 0.3s ease;
}

.book-cover:hover img {
    transform: scale(1.05);
}

/* Icon sách khi không có ảnh */
.book-icon {
    width: 50px;
    height: 50px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-weight: bold;
    font-size: 24px;
    z-index: 1;
    position: relative;
}

.book-title {
    font-size: 18px;
    font-weight: 600;
    color: #2d3748;
    margin-bottom: 12px;
    text-align: center;
    line-height: 1.4;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    text-overflow: ellipsis;
    min-height: 48px;
}

.book-meta {
    text-align: center;
    color: #667eea;
    font-size: 14px;
    margin-bottom: 20px;
}

.view-btn {
    display: block;
    width: 100%;
    padding: 12px 24px;
    background: #2d3748;
    color: white;
    text-decoration: none;
    text-align: center;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 500;
    transition: all 0.3s ease;
}

.view-btn:hover {
    background: #1a202c;
    transform: translateY(-1px);
    text-decoration: none;
    color: white;
}

/* No books found */
.no-books {
    grid-column: 1 / -1;
    text-align: center;
    padding: 60px 20px;
    background: white;
    border-radius: 16px;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.05);
}

.no-books-icon {
    font-size: 64px;
    margin-bottom: 20px;
}

.no-books h3 {
    font-size: 24px;
    color: #2d3748;
    margin-bottom: 12px;
}

.no-books p {
    color: #718096;
    font-size: 16px;
}

.no-books a {
    color: #667eea;
    text-decoration: none;
}

.no-books a:hover {
    text-decoration: underline;
}

/* Pagination */
.pagination {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 12px;
    margin-top: 40px;
    flex-wrap: wrap;
}

.pagination-btn {
    padding: 12px 20px;
    background: white;
    color: #4a5568;
    text-decoration: none;
    border-radius: 8px;
    border: 1px solid #e2e8f0;
    font-weight: 500;
    transition: all 0.3s ease;
}

.pagination-btn:hover {
    background: #667eea;
    color: white;
    text-decoration: none;
    border-color: #667eea;
}

.pagination-numbers {
    display: flex;
    gap: 4px;
}

.pagination-number {
    padding: 8px 12px;
    background: white;
    color: #4a5568;
    text-decoration: none;
    border-radius: 6px;
    border: 1px solid #e2e8f0;
    min-width: 40px;
    text-align: center;
    transition: all 0.3s ease;
}

.pagination-number:hover {
    background: #f7fafc;
    text-decoration: none;
}

.pagination-number.active {
    background: #667eea;
    color: white;
    border-color: #667eea;
}

/* Responsive */
@media (max-width: 992px) {
    .books-grid {
        grid-template-columns: repeat(auto-fill, 280px);
    }
    
    .book-card {
        width: 280px;
    }
}

@media (max-width: 768px) {
    .books-grid {
        grid-template-columns: repeat(auto-fill, 260px);
        gap: 16px;
    }
    
    .book-card {
        width: 260px;
        padding: 20px;
    }
    
    .book-cover {
        width: 120px;
        height: 180px;
    }
    
    .logo-text {
        font-size: 24px;
    }
    
    .search-box {
        padding: 14px 16px;
        font-size: 14px;
    }

    .search-btn {
        padding: 14px 16px;
    }

    .pagination {
        gap: 8px;
    }

    .pagination-btn {
        padding: 10px 16px;
        font-size: 14px;
    }
}

@media (max-width: 480px) {
    .books-grid {
        grid-template-columns: repeat(auto-fill, 250px);
    }
    
    .book-card {
        width: 250px;
    }
    
    .book-cover {
        width: 100px;
        height: 150px;
    }
}

/* Loading animation */
.loading-animation {
    opacity: 0;
    animation: fadeInUp 0.6s ease forwards;
}

.book-card:nth-child(1) { animation-delay: 0.3s; }
.book-card:nth-child(2) { animation-delay: 0.4s; }
.book-card:nth-child(3) { animation-delay: 0.5s; }
.book-card:nth-child(4) { animation-delay: 0.6s; }
.book-card:nth-child(5) { animation-delay: 0.7s; }
.book-card:nth-child(6) { animation-delay: 0.8s; }
.book-card:nth-child(7) { animation-delay: 0.9s; }
.book-card:nth-child(8) { animation-delay: 1s; }
.book-card:nth-child(9) { animation-delay: 1.1s; }

@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(30px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Lazy loading cho ảnh */
.book-cover img[data-src] {
    opacity: 0;
    transition: opacity 0.3s ease;
}

.book-cover img.loaded {
    opacity: 1;
}

.book-cover.loading::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(90deg, #f0f0f0 25%, #e0e0e0 50%, #f0f0f0 75%);
    background-size: 200% 100%;
    animation: shimmer 1.5s infinite;
}

@keyframes shimmer {
    0% {
        background-position: -200% 0;
    }
    100% {
        background-position: 200% 0;
    }
}