/**
 * @copyright Copyright © Tuinmaximaal. All rights reserved.
 *
 * Tuinmaximaal look for Search Ultimate 2.9 (#270), matching what we had with 2.7 and its Hyvä package:
 * - Autocomplete: products first as cards (wide image, bold name, orange price label), then plain text lists for
 *   categories, information pages and blog posts, sections divided by a line, no result counts.
 * - Results page: categories as cards with a large image and the path underneath, no yellow highlight.
 * Plain CSS on purpose (no Tailwind), so it works with any theme build. Every selector is one class or
 * pseudo-class more specific than Mirasvit's own rules, so the load order doesn't matter.
 */

.mst-searchautocomplete__autocomplete {
    --tmx-ac-ink: #003017;
    --tmx-ac-line: #e3e3e3;
    --tmx-ac-price: #ff8000;
    border: 0;
    border-radius: 0 0 4px 4px;
    color: var(--tmx-ac-ink);
}

/* Sections: products first, divided by a line */
.mst-searchautocomplete__autocomplete .mst-dd-1col {
    padding: 0;
}

.mst-searchautocomplete__autocomplete .mst-dd-1col .mst-dd-section {
    padding: 8px 16px 16px;
    border-top: 1px solid var(--tmx-ac-line);
}

.mst-searchautocomplete__autocomplete .mst-dd-1col .mst-dd-section + .mst-dd-section {
    margin-top: 0;
}

.mst-searchautocomplete__autocomplete .mst-dd-1col .mst-dd-section.magento_catalog_product {
    order: -1;
    border-top: 0;
}

.mst-searchautocomplete__autocomplete .mst-dd-sectitle {
    margin: 8px 0;
    padding: 0;
    border: 0;
}

.mst-searchautocomplete__autocomplete .mst-dd-sectitle__name {
    font-size: 14px;
    font-weight: 700;
    line-height: 20px;
    color: var(--tmx-ac-ink);
}

.mst-searchautocomplete__autocomplete .mst-dd-sectitle__count {
    display: none;
}

.mst-searchautocomplete__autocomplete .mst-searchautocomplete__highlight {
    font-weight: inherit;
    color: inherit;
}

/* Product cards */
.mst-searchautocomplete__autocomplete .mst-dd-card.magento_catalog_product {
    flex-wrap: nowrap;
    gap: 0;
    padding: 0;
    overflow: hidden;
    border: 1px solid var(--tmx-ac-line);
    border-radius: 8px;
    background: #fff;
    color: var(--tmx-ac-ink);
}

.mst-searchautocomplete__autocomplete .mst-dd-card.magento_catalog_product:hover,
.mst-searchautocomplete__autocomplete .mst-dd-card.magento_catalog_product._active {
    background: #fff;
    border-color: var(--tmx-ac-line);
    box-shadow: 0 0 0 1px var(--tmx-ac-line);
}

.mst-searchautocomplete__autocomplete .mst-dd-card.magento_catalog_product .mst-dd-card__thumb {
    width: 128px;
    height: 72px;
    border-radius: 0;
}

.mst-searchautocomplete__autocomplete .mst-dd-card.magento_catalog_product .mst-dd-card__thumb img {
    width: 100%;
    height: 100%;
    max-width: none;
    max-height: none;
    object-fit: cover;
}

.mst-searchautocomplete__autocomplete .mst-dd-card.magento_catalog_product .mst-dd-card__meta {
    padding: 0 12px;
}

.mst-searchautocomplete__autocomplete .mst-dd-card .mst-dd-card__title {
    color: var(--tmx-ac-ink);
}

.mst-searchautocomplete__autocomplete .mst-dd-card.magento_catalog_product .mst-dd-card__title {
    font-size: 14px;
    font-weight: 600;
    line-height: 20px;
    white-space: normal;
}

.mst-searchautocomplete__autocomplete .mst-dd-card:hover .mst-dd-card__title,
.mst-searchautocomplete__autocomplete .mst-dd-card._active .mst-dd-card__title {
    text-decoration: underline;
}

.mst-searchautocomplete__autocomplete .mst-dd-card.magento_catalog_product .mst-dd-pricecol {
    padding-right: 12px;
}

.mst-searchautocomplete__autocomplete .mst-dd-pricecol .price {
    display: inline-block;
    padding: 4px 8px;
    background: var(--tmx-ac-price);
    color: #fff;
    font-size: 16px;
    font-weight: 900;
    line-height: 24px;
    white-space: nowrap;
    transform: rotate(-2deg);
}

.mst-searchautocomplete__autocomplete .mst-dd-pricecol .old-price .price {
    background: none;
    color: var(--tmx-ac-ink);
    font-size: 14px;
    font-weight: 400;
    text-decoration: line-through;
    transform: none;
}

/* Categories, information pages, blog posts: plain text links */
.mst-searchautocomplete__autocomplete .mst-dd-ogrid {
    display: flex;
    flex-direction: column;
    gap: 0;
}

.mst-searchautocomplete__autocomplete .mst-dd-aside-card {
    padding: 0;
    border: 0;
    border-radius: 0;
    background: none;
    box-shadow: none;
}

.mst-searchautocomplete__autocomplete .mst-dd-aside-card:hover,
.mst-searchautocomplete__autocomplete .mst-dd-aside-card._active {
    background: none;
    box-shadow: none;
}

.mst-searchautocomplete__autocomplete .mst-dd-aside-card .mst-dd-card__thumb,
.mst-searchautocomplete__autocomplete .mst-dd-aside-card .mst-dd-card__desc {
    display: none;
}

.mst-searchautocomplete__autocomplete .mst-dd-aside-card .mst-dd-card__title {
    display: block;
    font-size: 14px;
    font-weight: 400;
    line-height: 24px;
    white-space: normal;
}

/* "View all results" */
.mst-searchautocomplete__autocomplete .mst-dd-viewall,
.mst-searchautocomplete__autocomplete .mst-dd-viewall:hover {
    color: var(--tmx-ac-ink);
}

/* Mobile: price label under the name, next to the image */
@media (max-width: 767px) {
    .mst-searchautocomplete__autocomplete .mst-dd-card.magento_catalog_product {
        display: grid;
        grid-template-columns: 128px minmax(0, 1fr);
        grid-template-rows: auto auto;
        align-items: start;
        column-gap: 12px;
        row-gap: 8px;
        padding: 12px;
    }

    .mst-searchautocomplete__autocomplete .mst-dd-card.magento_catalog_product .mst-dd-card__thumb {
        grid-row: 1 / span 2;
        width: 128px;
        height: 72px;
        border-radius: 4px;
    }

    .mst-searchautocomplete__autocomplete .mst-dd-card.magento_catalog_product .mst-dd-card__meta {
        padding: 0;
    }

    .mst-searchautocomplete__autocomplete .mst-dd-card.magento_catalog_product .mst-dd-pricecol {
        grid-column: 2;
        width: auto;
        padding: 0;
        align-items: flex-start;
        justify-content: flex-start;
    }
}

/* ---------------------------------------------------------------------------------------------------------------
 * Search results page
 * ------------------------------------------------------------------------------------------------------------- */

/* No yellow marker on the search word (results page and product names) */
:root .mst-search__highlight {
    background: none;
    color: inherit;
    font-weight: inherit;
}

/* Categories tab: large image on top, path underneath (2.9 floats a 50px thumbnail next to it) */
:root .mst-search__index-magento-catalog-category .mst-search__index-image {
    float: none;
    margin: 0 0 8px;
}

:root .mst-search__index-magento-catalog-category .mst-search__index-image img {
    display: block;
    width: auto;
    height: auto;
    max-width: 100%;
    max-height: 360px;
}
