/* Global Styles */
* {
    padding: 0;
    margin: 0;
    box-sizing: border-box;
    font-family: system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, 'Open Sans', 'Helvetica Neue', sans-serif;
}

body {
    background-color: #f0f0f0;
}

/* Heading */
.heading {
    text-align: center;
    background-color: #1e90ff;
    color: white;
    font-size: 40px;
    padding: 1rem;
}

/* Controls (Search, View Toggle, Sorting) */
.controls {
    width: 90%;
    max-width: 1200px;
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    align-items: center;
    margin: auto;
    padding: 1rem;
    gap: 1rem;
}

input[type="text"] {
    flex: 1;
    min-width: 250px;
    padding: 0.5rem 0.8rem;
    border: none;
    border-radius: 0.25rem;
    font-size: 16px;
    box-shadow: rgba(0, 0, 0, 0.16) 0px 1px 4px;
}

button {
    background-color: #1e90ff;
    color: white;
    padding: 0.5rem 0.8rem;
    font-size: 16px;
    font-weight: 600;
    border: none;
    border-radius: 0.25rem;
    cursor: pointer;
    box-shadow: rgba(0, 0, 0, 0.16) 0px 1px 4px;
}

button:hover {
    background-color: #5e9aff;
}

/* Book Container */
#bookContainer {
    background-color: #fff;
    width: 90%;
    max-width: 1200px;
    margin: 1rem auto;
    padding: 1rem;
    border-radius: 0.5rem;
    box-shadow: rgba(0, 0, 0, 0.16) 0px 1px 4px;
}

/* Common Book Styles */
.book {
    padding: 1rem;
    border-radius: 0.5rem;
    box-shadow: rgba(0, 0, 0, 0.1) 0px 4px 6px -1px, rgba(0, 0, 0, 0.06) 0px 2px 4px -1px;
    transition: 0.3s;
}

.book:hover {
    box-shadow: rgba(14, 30, 37, 0.12) 0px 2px 4px 0px, rgba(14, 30, 37, 0.32) 0px 2px 16px 0px;
}

/* List View */
.list-view {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.list-view .book {
    display: flex;
    flex-direction: row;
    align-items: center;
    gap: 1rem;
}

.list-view .book img {
    width: 120px;
    height: 180px;
    border-radius: 5px;
}

/* Grid View */
.grid-view {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 1rem;
}

.grid-view .book {
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    padding: 1rem;
}

.grid-view .book img {
    width: 100%;
    height: 250px;
    object-fit: cover;
    object-position: top;
    border-radius: 5px;
}

/* Ellipsis for Overflowing Text */
.book div {
    width: 100%;
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 0.5rem;
    overflow: hidden;
}

.grid-view .book div {
    align-items: center;
}

.book div h3,
.book div p {
    width: 100%;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.book div h3 {
    font-size: 18px;
    font-weight: bold;
    max-width: 90%;
}

.book div p {
    font-size: 14px;
    max-width: 90%;
    color: #555;
}

.book div p span {
    font-weight: 500;
}

.book div a {
    font-size: 14px;
    text-decoration: none;
    background-color: #1e90ff;
    color: #fff;
    font-weight: 600;
    padding: 0.4rem 0.8rem;
    border-radius: 0.25rem;
    white-space: nowrap;
}

.book div a:hover {
    background-color: #5e9aff;
}

/* Pagination */
.pagination {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 2rem;
    margin: 1rem 0;
}

/* Responsive Design */

/* Tablets */
@media (max-width: 1024px) {
    .heading {
        font-size: 36px;
    }

    .controls {
        flex-direction: column;
        align-items: stretch;
        gap:1rem;
    }

    .list-view .book img {
        width: 100px;
        height: 150px;
    }

    .grid-view {
        grid-template-columns: repeat(auto-fit, minmax(230px, 1fr));
    }
}

/* Mobile Devices */
@media (max-width: 768px) {
    .heading {
        font-size: 30px;
    }

    .controls {
        width: 100%;
    }

    input[type="text"] {
        width: 100%;
        font-size: 14px;
    }

    button {
        font-size: 14px;
        padding: 0.4rem 0.6rem;
    }

    #bookContainer {
        width: 95%;
        padding: 1rem;
    }

    /* .list-view .book {
        flex-direction: column;
        align-items: center;
        text-align: center;
    } */

    .list-view .book img {
        width: 180px;
        height: 220px;
    }

    .grid-view {
        grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    }
}

/* Small Mobile Screens */
@media (max-width: 480px) {
    .heading {
        font-size: 24px;
        padding: 0.5rem;
    }

    .controls {
        flex-direction: column;
        gap: 0.5rem;
    }

    button {
        font-size: 12px;
        padding: 0.3rem 0.5rem;
    }

    #bookContainer {
        width: 98%;
        padding: 0.5rem;
    }

    .list-view .book img {
        width: 170px;
        height: 200px;
    }

    .grid-view {
        grid-template-columns: repeat(auto-fit, minmax(130px, 1fr));
    }
}
