#products-block {
    margin: 20px 0;
}

#products-form {
    margin-bottom: 20px;
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    background: #f5f5f5;
    padding: 20px;
    border-radius: 8px;
    border: 1px solid #ddd; /* Consistent border */
}

#products-form select,
#products-form input,
#products-form button {
    flex: 1 1 auto;
    min-width: 150px;
    padding: 10px;
    font-size: 1em;
    border: 1px solid #ddd; /* Consistent border */
    border-radius: 4px;
}

#products-form select:focus,
#products-form input:focus,
#products-form button:focus {
    outline: none;
}

#products-form input {
    flex: 2 1 auto;
}

#products-form button {
    color: #fff;
    cursor: pointer;
    transition: background 0.3s ease, border-color 0.3s ease;
}

#products-results {
    display: grid;
    grid-template-columns: repeat(3, 1fr); /* 3 items per row on desktop */
    gap: 20px;
}

.product-item {
    background-color: white;
    border: 1px solid #ddd;
    border-radius: 8px;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    box-sizing: border-box; /* Include padding and border in element's total width and height */
}

.product-image-wrapper {
    position: relative;
    width: 100%;
    padding-top: 56.25%; /* 16:9 Aspect Ratio */
    background-color: #f5f5f5; /* Fallback for empty state */
    box-sizing: border-box; /* Include padding and border in element's total width and height */
}

.product-image {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 1.5rem;
}

.product-image img {
    max-width: 100%;
    max-height: 100%;
    width: auto;
    height: auto;
    display: block;
}

.product-image .flag-icon-wrapper {
    position: absolute;
    bottom: 0.5rem;
    left: 1rem;
    border-radius: 3px;
    --CountryFlagIcon-height: 1.5rem;
}

.product-image .flag-icon-wrapper span[class^='flag:'] {
    --CountryFlagIcon-height: 1.5rem;
    border-radius: 3px;
    border: 1px solid white;;
}

.product-image .flag-icon-wrapper a {
    display: inline-block;
    margin-right: 0.5rem;
}

.product-image .flag-icon-wrapper a:last-child {
    margin-right: 0;
}

.product-content-wrapper {
    display: flex;
    flex-direction: column;
    padding: 15px;
    flex-grow: 1;
    box-sizing: border-box; /* Include padding and border in element's total width and height */
}

.product-content {
    display: flex;
    justify-content: space-between;
    align-items: center;
    width: 100%;
    box-sizing: border-box; /* Include padding and border in element's total width and height */
    gap: 10px;
    margin-top: auto; /* Push content to the bottom */
}

.product-info {
    display: flex;
    flex-direction: column;
    justify-content: flex-start;
    flex-grow: 1;
    overflow: hidden;
}

.product-categories {
    font-size: 0.875em;
    color: silver;
    margin-bottom: 5px;
}

.product-category {
    text-decoration: none;
    color: var(--wp--preset--color--primary);
    margin-right: 5px;
}

.product-category:hover {
    text-decoration: underline;
}

.product-title {
    font-size: 1.25em;
    margin: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap; /* Prevent text from wrapping */
}

.product-title a {
    text-decoration: none;
    color: #333;
}

.product-title a:hover {
    color: var(--wp--preset--color--primary);
}

.pagination-footer {
    margin-top: 20px;
    text-align: left; /* Left align the pagination */
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 0.875em; /* Smaller font size for pagination */
}

.custom-pagination {
    display: inline-flex;
    list-style: none;
    padding: 0;
    margin: 0;
}

.custom-pagination a {
    text-decoration: none;
    padding: 5px 10px;
    border: 1px solid #ddd;
    border-radius: 3px;
    color: var(--wp--preset--color--primary);
    transition: background-color 0.3s ease, color 0.3s ease;
    margin-right: 0.5rem;
}

.custom-pagination a.disabled {
    color: #ccc;
    pointer-events: none; /* Disable pointer events on disabled page */
}

.custom-pagination a:hover {
    background-color: var(--wp--preset--color--primary);
    color: #fff;
}

.custom-pagination .active {
    background-color: var(--wp--preset--color--primary);
    color: #fff;
    pointer-events: none; /* Disable pointer events on active page */
}

.pagination-info {
    flex-grow: 1;
    font-size: 0.875em;
    color: #333;
}

.another-block {
    background-color: #f5f5f5;
    padding: 20px;
    border: 1px solid #ddd;
}

/* Responsive design */
@media (max-width: 1200px) {
    #products-results {
        grid-template-columns: repeat(2, 1fr); /* 2 items per row on tablet */
    }
}

@media (max-width: 768px) {
    #products-results {
        grid-template-columns: 1fr; /* 1 item per row on mobile */
        gap: 10px;
    }
    .product-content {
        flex-direction: row; /* Keep content in a row */
        align-items: center;
    }
    .product-info {
        max-width: calc(100% - 120px); /* Adjusted to ensure the button fits */
    }
    .product-content .aft-button-subtle {
        align-self: flex-start; /* Align button to the start */
    }
}

@media (max-width: 500px) {
    #products-results {
        grid-template-columns: 1fr; /* 1 item per row */
    }
    
    .product-item {
        flex-direction: row; /* Arrange image and content side by side */
        align-items: center; /* Align items vertically in the center */
    }
    
    .product-image-wrapper {
        width: 150px; /* Set a fixed width for the image container */
        padding-top: 0; /* Remove the padding-top used for the aspect ratio */
        flex-shrink: 0; /* Prevent the image from shrinking */
        background-color: #f5f5f5;
        height: 100%;
    }
    
    .product-image {
        position: relative;
        width: 100%;
        height: 100%;
        padding: 0; /* Remove padding to fit the image within the new container size */
    }

    .product-image img {
        max-height: 80%;
    }
    
    .product-content-wrapper {
        flex-grow: 1;
        padding: 15px;
        display: flex;
        flex-direction: column;
        justify-content: space-between;
    }
    
    .product-content {
        flex-direction: column;
        align-items: flex-start; /* Align content to the start */
        margin-top: 0;
    }
    
    .product-info {
        max-width: 100%; /* Ensure full width for content */
        margin-bottom: 10px; /* Add some spacing between content and button */
    }
    
    .view-more {
        align-self: flex-start; /* Align button to the start */
    }
}


/* Loading Indicator */
.loading-indicator {
    display: flex;
    justify-content: center;
    align-items: center;
    height: 100%;
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(255, 255, 255, 0.8);
    z-index: 1000;
}

.loading-indicator .spinner {
    border: 4px solid rgba(0, 0, 0, 0.1);
    border-left-color: var(--wp--preset--color--primary);
    border-radius: 50%;
    width: 50px;
    height: 50px;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* Placeholder Elements */
.placeholder-item {
    background: #f5f5f5;
    border: 1px solid #ddd;
    border-radius: 8px;
    padding: 15px;
    margin-bottom: 20px;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
}

.placeholder-item .placeholder-image {
    background: #e0e0e0;
    height: 150px;
    border-radius: 8px;
    margin-bottom: 10px;
}

.placeholder-item .placeholder-title {
    background: #e0e0e0;
    height: 20px;
    width: 60%;
    border-radius: 4px;
    margin-bottom: 10px;
}

.placeholder-item .placeholder-button {
    background: #e0e0e0;
    height: 30px;
    width: 80px;
    border-radius: 4px;
    align-self: flex-end;
}
