/* Custom variables for easy adjustments */
:root {
    --header-height: 80px; /* Fallback; JS will override dynamically */
    --modal-padding: 20px;
    --grid-gap: 20px;
    --item-shadow: 0 2px 5px rgba(0, 0, 0, 0.1);
    --item-hover-shadow: 0 4px 10px rgba(0, 0, 0, 0.2);
    --item-hover-bg: #f5f7f6;
}

body.no-scroll {
    overflow: hidden !important; /* Prevent body scroll when modal open */
}

.header__search-button {
    background: none !important; /* No background */
    border: none !important; /* No border */
    cursor: pointer;
    padding: 0;
}

.header__search-button svg {
    vertical-align: middle; /* Center vertically */
    width: 41px; /* Larger size */
    height: 41px;
}

.header__search-button svg path {
    vector-effect: non-scaling-stroke;
}

.search-modal-backdrop {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: transparent;
    z-index: 9999;
    overflow: hidden;
}

.search-modal {
    position: fixed; /* Change to fixed for better viewport referencing; removes dependency on backdrop's positioning */
    top: var(--header-height);
    left: 0;
    width: 100%;
    height: calc(100vh - var(--header-height));
    background: white;
    box-sizing: border-box;
    display: flex;
    flex-direction: column;
    overflow-y: auto; /* Change to auto to allow overall scrolling if needed, but internal scroll should handle it */
}

.search-modal__container {
    width: 100%;
    max-width: 1150px;
    margin: 0 auto;
    padding: var(--modal-padding);
    flex: 1;
    display: flex;
    flex-direction: column;
}

.search-modal__search {
    position: sticky;
    top: 0;
    background: white;
    z-index: 10;
    padding-bottom: var(--modal-padding);
    border-bottom: 1px solid #ddd;
    text-align: center;
}

.search-modal__search input {
    width: 400px !important; /* Fixed width, no jumping */
    padding: 10px;
    box-sizing: border-box;
    font-size: 16px;
    margin: 0 auto;
    display: block;
}

.search-modal__results {
    flex: 1 1 auto;
    overflow-y: scroll;
    -webkit-overflow-scrolling: touch;
    padding-top: var(--modal-padding);
    max-height: none;
    min-height: 0; /* Add this */
}

.product__list {
    list-style: none;
    padding: 0;
    margin: 0;
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: var(--grid-gap);
}

.products__list-item {
    height: 100%;
    display: flex;
    align-items: center;
    background: white;
    border-bottom: 1px solid #eee;
    box-shadow: var(--item-shadow);
    transition: box-shadow 0.2s, background 0.2s;
    padding: 10px;
    border-radius: 8px;
}

.products__list-item:hover {
    background: var(--item-hover-bg);
}

.products__list-item a {
    text-decoration: none;
    color: inherit;
    display: flex;
    width: 100%;
    height: 100%;
}

.products__list-item--image {
    width: 50%;
    padding-right: 10px;
}

.square-img-container {
    position: relative;
    width: 150px;
    height: 150px;
    overflow: hidden;
    border-radius: 4px;
}

.square-img-container img {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    object-fit: contain;
}

.products__list-item--details {
    width: 50%;
    display: flex;
    flex-direction: column;
    justify-content: center;
}

.product__card--name {
    margin: 0 0 5px 0;
    font-weight: bold;
    font-size: 14px;
}

/* Responsive adjustments */
@media (max-width: 1024px) {
    .product__list {
        grid-template-columns: repeat(2, 1fr);
    }
}

@media (max-width: 768px) {
    .product__list {
        grid-template-columns: 1fr;
    }
    .products__list-item {
        flex-direction: column;
    }
    .products__list-item--image,
    .products__list-item--details {
        width: 100%;
    }
    .products__list-item--image {
        padding-right: 0;
        margin-bottom: 10px;
    }
    .square-img-container {
        width: 100%;
        height: 150px;
    }
}

.no-results-message {
    grid-column: 1 / -1;
    text-align: center;
    font-size: 18px;
    color: #2A6448;
    margin: 20px 0;
}

.no-results-message a {
    color: #016647;
    text-decoration: underline;
    font-weight: 600;
}

.no-results-message a:hover {
    color: #02855a;
}
