:root {
    --content-width: min(60vw, 1000px);
}

*, *::before, *::after {
    box-sizing: border-box;
}

body {
    padding: 0;
    margin: 0;
    justify-content: center;
    font-family: sans-serif;
    background-color: #f5f5dc;
}

main {
    margin: 20px;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

main > form, main > table {
    margin: 12px;
}

/*PRODUCT DISPLAY*/
#product-display {
    margin-block: 20px;
    margin-inline: auto;
    display: grid;
    background-color: #9d825d;
    padding: 8px;
    grid-auto-rows: auto;
    width: var(--content-width);
    margin-inline: auto;
}

@media (min-width: 1200px) {
    #product-display {
        grid-template-columns: repeat(5, 1fr);
    }
}

@media (min-width: 768px) and (max-width: 1199px) {
    #product-display {
        grid-template-columns: repeat(3, 1fr);
    }
}

@media (max-width: 767px) {
    #product-display {
        grid-template-columns: repeat(1, 1fr);
    }
}

.product-display__item {
    box-sizing: border-box;
    display: flex;
    flex-direction: column;
    align-items: left;
    margin: 10px;
    background-color: #f5f5dc;

        /* Reduce default flex height stretching */
    height: auto;

    /* Prevent unnecessary stretching */
    gap: 4px; 
}

.product-display__item h3,
.product-display__item p {
    margin: 1px 0;       /* Much tighter spacing */
    font-size: 0.9rem;
}

.product-display__item h3 {
    align-self: center;
}

.product-display__item button {
    border: none;
    background-color: #e4d5b4;
}

.product-display__item button:hover {
    background-color: #d2b48c;
}

.product-images {
    width: 100%;
    height: 120px;
    overflow: hidden;
    background-color: #fff;
}

.product-images img {
    width: 100%;
    height: 100%;
    object-fit: contain; /* or cover */
}

/*CART*/
#cart {
    background-color: #9d825d;
    width: var(--content-width);
    margin-inline: auto;
    padding: 12px;
}

#cart__product-finder{
    width: 100%;
    box-sizing: border-box;
}

#cart button {
    width: 100%;
    border: none;
    background-color: #e4d5b4;
}

#cart button:hover {
    background-color: #d2b48c;
}

table {
    box-sizing: border-box;
    width: 100%;
    margin-top: 1vh;
    padding: 8px;
    border-collapse: collapse;
}

table th, table td {
    border: 1px solid #000;
    max-width: 120px;
    max-height: 120px;
}

/*SEARCH FORM*/
#search-form {
    display: flex;
    flex-direction: column;
    gap: 4px;
    background-color: #9d825d;
    padding: 4px;
    width: var(--content-width);
    margin-inline: auto;
}

#search-form > input {
    width: 100%;
    background-color: #f5f5dc;
    box-sizing: border-box;
}

#product-display,
#cart,
#search-form,
#page-selector {
    width: var(--content-width);
    margin-inline: auto;
}

#page-selector {
    width: var(--content-width);
    margin-inline: auto;
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 8px;
}