/**
 * Prestart Search
 *
 * @author    PRESTART
 * @copyright Copyright (c) PRESTART
 * @license   https://opensource.org/licenses/AFL-3.0 Academic Free License 3.0 (AFL-3.0)
 *
 * Le regole per .prestartsearch-widget/-form/-input/-submit sono duplicate da
 * search-dropdown.css: e il markup del trigger nell'header, comune a entrambi i
 * layout, ma le due modalita caricano fogli di stile diversi e mai insieme
 * (hookDisplayHeader in prestartsearch.php), quindi qui non c'era nulla a
 * disporre l'input e il pulsante di ricerca sulla stessa riga.
 */

.prestartsearch-widget {
    position: relative;
    width: 100%;
}

.prestartsearch-form {
    position: relative;
    display: flex;
    align-items: stretch;
    width: 100%;
}

/* Doppia classe per vincere su .form-control del tema (sfondo grigio, angoli vivi). */
.prestartsearch-widget .prestartsearch-input {
    flex: 1 1 auto;
    min-width: 0;
    height: 2.75rem;
    padding: 0 3rem 0 1.125rem;
    background: #fff !important;
    border: 1px solid #ababab !important;
    border-radius: 0;
    color: #333;
    font-size: .9375rem;
    box-shadow: none;
    transition: border-color .15s ease, box-shadow .15s ease;
}
@media (max-width: 991px) {
    .prestartsearch-widget .prestartsearch-input {
        height: 3.75rem !important;
    }
    .prestartsearch-searchbar-icon{
        width: 16px !important;
        height: 16px !important;
    }
}

.prestartsearch-widget .prestartsearch-input::placeholder {
    color: #777 !important;
    opacity: 1;
}

.prestartsearch-widget .prestartsearch-input:hover {
    border-color: #bdbdbd;
}

.prestartsearch-widget .prestartsearch-input:focus {
    border-color: var(--prestartsearch-accent, var(--primary, #2b6cb0));
    box-shadow: 0 0 0 3px rgba(0, 0, 0, .06);
    outline: none;
}
span.prestartsearch-hit-price {
    font-size: 16px;
}

.prestartsearch-widget .prestartsearch-submit {
    position: absolute;
    top: 50%;
    right: .375rem;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 2.25rem;
    height: 2.25rem;
    padding: 0;
    background: transparent;
    border: 0;
    border-radius: 50%;
    color: #333;
    transform: translateY(-50%);
}

.prestartsearch-widget .prestartsearch-submit:hover,
.prestartsearch-widget .prestartsearch-submit:focus-visible {
    color: var(--prestartsearch-accent, var(--primary, #2b6cb0));
    background: rgba(0, 0, 0, .04);
}

.prestartsearch-submit-icon {
    display: block;
    width: 1.125rem;
    height: 1.125rem;
}

.prestartsearch-label.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

.prestartsearch-overlay {
    position: fixed;
    z-index: 10000;
    inset: 0;
    display: flex;
    align-items: flex-start;
    justify-content: center;
    background: var(--prestartsearch-overlay-tint, rgba(0, 0, 0, .55));
}

.prestartsearch-overlay[hidden] {
    display: none;
}

.prestartsearch-overlay-inner {
    display: flex;
    flex-direction: column;
    /*width: min(1200px, 100%);*/
    /*max-height: calc(100vh - 2rem);*/
    width: 100vw;
    height: 100vh;
    background: var(--prestartsearch-surface-bg, #fff);
    /*border-radius: var(--prestartsearch-radius, 6px);*/
    overflow: hidden;
}

body.prestartsearch-overlay-open {
    overflow: hidden;
}

.prestartsearch-searchbar {
    display: flex;
    align-items: center;
    gap: .75rem;
    padding: 1.25rem 1.5rem .75rem;
    border-bottom: 2px solid var(--prestartsearch-accent, var(--primary, #2b6cb0));
}

.prestartsearch-searchbar-icon {
    flex: 0 0 auto;
    font-size: 1.125rem;
    opacity: .6;
    background: rgba(0, 0, 0, 0) url(data:image/svg+xml;utf8,%3Csvg%20xmlns%3D%22http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%22%20width%3D%2216%22%20height%3D%2216%22%20viewBox%3D%220%200%2024%2024%22%20fill%3D%22none%22%20stroke%3D%22%235a5e9a%22%20stroke-width%3D%222%22%20stroke-linecap%3D%22round%22%20stroke-linejoin%3D%22round%22%3E%3Ccircle%20cx%3D%2211%22%20cy%3D%2211%22%20r%3D%228%22%3E%3C%2Fcircle%3E%3Cline%20x1%3D%2221%22%20y1%3D%2221%22%20x2%3D%2216.65%22%20y2%3D%2216.65%22%3E%3C%2Fline%3E%3C%2Fsvg%3E) repeat scroll 0% 0%;
    content: "";
    height: 1rem;
    width: 1rem;
}

.prestartsearch-overlay-searchbox {
    flex: 1 1 auto;
    min-width: 0;
}

.prestartsearch-overlay-searchbox .ais-SearchBox-form {
    display: flex;
}
.ais-SearchBox-form::before{
    display: none;
}

.prestartsearch-overlay-searchbox .ais-SearchBox-input {
    width: 100%;
    padding: 0;
    border: 0;
    font-size: 1.25rem;
    background: transparent;
    box-shadow: none;
    color: #333 !important
}
.prestartsearch-overlay-searchbox .ais-SearchBox-input::placeholder {
    color: #999;
}
svg.ais-SearchBox-resetIcon {
    display: none;
}
.prestartsearch-overlay-searchbox .ais-SearchBox-submit {
    display: none;
}

.prestartsearch-overlay-close {
    flex: 0 0 auto;
    width: 2.25rem;
    height: 2.25rem;
    font-size: 1.5rem;
    line-height: 1;
    background: transparent;
    border: 0;
    border-radius: 50%;
    cursor: pointer;
    transition: background-color .15s ease;
}

.prestartsearch-overlay-close:hover,
.prestartsearch-overlay-close:focus-visible {
    background: rgba(0, 0, 0, .06);
    outline: none;
}

.prestartsearch-pills {
    display: flex;
    flex-wrap: wrap;
    gap: .5rem;
    padding: .75rem 1.5rem 1.25rem;
}

.prestartsearch-pills[hidden] {
    display: none;
}

.prestartsearch-pill {
    padding: .375rem .875rem;
    background: transparent;
    border: 1px solid rgba(0, 0, 0, .15);
    border-radius: 999px;
    font-size: .8125rem;
    cursor: pointer;
    transition: border-color .15s ease, color .15s ease;
}

.prestartsearch-pill:hover,
.prestartsearch-pill:focus-visible {
    border-color: var(--prestartsearch-accent, var(--primary, #2b6cb0));
    color: var(--prestartsearch-accent, var(--primary, #2b6cb0));
    outline: none;
}

.prestartsearch-pill.is-active {
    background: var(--prestartsearch-accent, var(--primary, #2b6cb0));
    border-color: var(--prestartsearch-accent, var(--primary, #2b6cb0));
    color: #fff;
}

.prestartsearch-overlay-body {
    display: grid;
    grid-template-columns: 260px minmax(0, 1fr);
    gap: 1.5rem;
    padding: 1rem 1.5rem 1.5rem;
    overflow-y: auto;
}

.prestartsearch-toggle-filters {
    display: none;
    grid-column: 1 / -1;
    padding: .5rem 1rem;
    background: transparent;
    border: 1px solid currentColor;
    border-radius: var(--prestartsearch-radius, 4px);
    cursor: pointer;
    transition: border-color .15s ease, color .15s ease;
}

.prestartsearch-toggle-filters:hover,
.prestartsearch-toggle-filters:focus-visible {
    border-color: var(--prestartsearch-accent, var(--primary, #2b6cb0));
    color: var(--prestartsearch-accent, var(--primary, #2b6cb0));
    outline: none;
}

.prestartsearch-facets {
    min-width: 0;
}

/* Solo mobile: chiude il pannello dei filtri, che restano applicati man mano (vedi bindFacetToggle). */
.prestartsearch-apply-filters {
    display: none;
    position: sticky;
    bottom: 0;
    width: 100%;
    margin-top: 1rem;
    padding: .75rem 1rem;
    background: var(--prestartsearch-accent, var(--primary, #2b6cb0));
    border: 0;
    border-radius: var(--prestartsearch-radius, 4px);
    color: #fff;
    font-size: .9375rem;
    font-weight: 600;
    cursor: pointer;
}

.prestartsearch-facet + .prestartsearch-facet {
    margin-top: 1rem;
    padding-top: 1rem;
    border-top: 1px solid rgba(0, 0, 0, .08);
}

/* Il collasso dei pannelli non e nativo in instantsearch.js: il click sull'header
   aggiunge/toglie questa classe (vedi bindFacetCollapse in search-fullscreen.js), il resto
   e solo CSS. Lo stato di default e espanso, per non nascondere i filtri al primo utilizzo. */
.prestartsearch-facet .ais-Panel-header {
    position: relative;
    padding-right: 1.25rem;
    cursor: pointer;
    user-select: none;
    color: #333;
    text-transform: none;
    font-size: 16px;
}

.prestartsearch-facet .ais-Panel-header::after {
    content: '';
    position: absolute;
    top: .35rem;
    right: 0;
    width: .5rem;
    height: .5rem;
    border-right: 2px solid currentColor;
    border-bottom: 2px solid currentColor;
    opacity: .5;
    transform: rotate(-135deg);
    transition: transform .15s ease;
}
input.ais-RefinementList-checkbox {
    box-shadow: none;
    width: 1.2rem;
    height: 1.2rem;
}
span.ais-RefinementList-count {
    margin-left: auto;
    background: none;
    border: 0;
}
/* Il tema satellite di InstantSearch da al pulsante sfondo sfumato e box-shadow in hover,
   focus e active: qui resta un link testuale. */
button.ais-RefinementList-showMore,
button.ais-RefinementList-showMore:hover,
button.ais-RefinementList-showMore:focus,
button.ais-RefinementList-showMore:active {
    border: 0;
    padding: 0;
    background: none;
    box-shadow: none;
    outline: none;
}

button.ais-RefinementList-showMore:hover,
button.ais-RefinementList-showMore:focus-visible {
    color: #000;
    text-decoration: underline;
}
/* Slider del prezzo nel colore d'accento del modulo, maniglie tonde (il tema satellite le
   disegna rettangolari e blu). */
.prestartsearch-facet .ais-RangeSlider .rheostat-progress {
    background-color: var(--prestartsearch-accent, var(--primary, #2b6cb0));
}

.prestartsearch-facet .ais-RangeSlider .rheostat-handle {
    width: 18px;
    height: 18px;
    margin-left: -9px;
    top: -7px;
    background: #fff;
    border: 2px solid var(--prestartsearch-accent, var(--primary, #2b6cb0));
    border-radius: 50%;
    box-shadow: 0 1px 3px rgba(0, 0, 0, .2);
}

.prestartsearch-facet .ais-RangeSlider .rheostat-handle::before,
.prestartsearch-facet .ais-RangeSlider .rheostat-handle::after {
    display: none;
}

.prestartsearch-facet .ais-RangeSlider .rheostat-tooltip {
    font-size: .8125rem;
    font-weight: 600;
    white-space: nowrap;
}

.prestartsearch-facet.is-collapsed .ais-Panel-header::after {
    transform: rotate(45deg);
}

.prestartsearch-facet.is-collapsed .ais-Panel-body {
    display: none;
}

.prestartsearch-overlay-main {
    min-width: 0;
}

.prestartsearch-results-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    margin-bottom: .75rem;
}

.prestartsearch-stats {
    font-size: .875rem;
    opacity: .7;
}

.prestartsearch-sort {
    display: flex;
    align-items: center;
    gap: .375rem;
    font-size: .875rem;
}

.prestartsearch-sort[hidden] {
    display: none;
}

.prestartsearch-sort-label {
    opacity: .7;
}

.prestartsearch-sort select {
    padding: .25rem 1.5rem .25rem .5rem;
    border: 0;
    background-color: transparent;
    font-size: .875rem;
    font-weight: 600;
}

.prestartsearch-pinned {
    margin-bottom: 1.25rem;
}

.prestartsearch-pinned[hidden] {
    display: none;
}

.prestartsearch-pinned-list {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
    gap: 1rem;
}

.prestartsearch-block + .prestartsearch-block {
    margin-top: 1.25rem;
}

.prestartsearch-block-title {
    margin: 0 0 .625rem;
    font-size: 1rem;
    font-weight: 600;
}

.prestartsearch-block-title a {
    color: inherit;
    text-decoration: none;
}

.prestartsearch-block-title a:hover {
    color: var(--prestartsearch-accent, var(--primary, #2b6cb0));
}

.prestartsearch-block-more {
    display: block;
    width: fit-content;
    margin: .625rem auto 0;
    text-align: center;
    font-size: .875rem;
    font-weight: 600;
    color: var(--prestartsearch-accent, var(--primary, #2b6cb0));
    text-decoration: none;
    background: var(--prestartsearch-accent);
    padding: 7px 14px;
}

.prestartsearch-block-more:hover,
.prestartsearch-block-more:focus-visible {
    text-decoration: underline;
}

/* Scorrimento infinito: il pulsante serve solo da sentinella (vedi bindInfiniteScroll). */
.prestartsearch-hits .ais-InfiniteHits-loadMore {
    display: block;
    width: 100%;
    height: 1px;
    margin: 0;
    padding: 0;
    border: 0;
    overflow: hidden;
    color: transparent;
    background: transparent;
}

/* Prodotto gia mostrato in un blocco: vedi hideDuplicates in search-fullscreen.js. */
.prestartsearch-hits .ais-InfiniteHits-item[hidden] {
    display: none;
}

.prestartsearch-hits .ais-InfiniteHits-list {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
    gap: 1rem;
    margin: 0;
    padding: 0;
    list-style: none;
}

li.ais-InfiniteHits-item {
    padding: 0;
}

.prestartsearch-hits .prestartsearch-hit-link {
    display: flex;
    flex-direction: column;
    gap: .5rem;
    height: 100%;
    padding: .75rem;
    /*border: 1px solid rgba(0, 0, 0, .08);*/
    border-radius: var(--prestartsearch-radius, 6px);
    transition: box-shadow .15s ease, transform .15s ease, border-color .15s ease;
}

/* Il pulsante "aggiungi al carrello" (vedi buildAddToCart in search-fullscreen.js) non puo
   stare dentro l'<a> del prodotto: un <button> annidato in un <a> non e HTML valido e il
   click gli farebbe comunque seguire il link. Titolo e immagine restano link separati. */
.prestartsearch-hits .prestartsearch-hit-media,
.prestartsearch-hits .prestartsearch-hit-title-link {
    display: block;
    color: inherit;
    text-decoration: none;
}

.prestartsearch-hits .prestartsearch-hit-link:hover,
.prestartsearch-hits .prestartsearch-hit-link:focus-within {
    border-color: transparent;
    box-shadow: 0 8px 20px rgba(0, 0, 0, .1);
    transform: translateY(-2px);
}

.prestartsearch-hits .prestartsearch-hit-image {
    width: 100%;
    aspect-ratio: 1 / 1;
    object-fit: contain;
}

.prestartsearch-hits .prestartsearch-hit-body {
    display: flex;
    flex-direction: column;
    gap: .25rem;
    height: 100%;
}

.prestartsearch-hits .prestartsearch-hit-title {
    font-weight: 600;
    line-height: 1.3;
}

/* "revert" mantiene lo stile nativo del browser per <mark> e per il focus finche
   l'admin non imposta un colore in "Stile personalizzato": nessuna variabile
   impostata, nessun cambio visivo rispetto a prima di questa funzione. */
.prestartsearch-hits .prestartsearch-hit-title mark,
.prestartsearch-hits .prestartsearch-hit-title em {
    background: var(--prestartsearch-accent-bg, revert);
    color: #fff;
}

.prestartsearch-hits .prestartsearch-hit-reference {
    font-size: .8125rem;
    opacity: .7;
}

.prestartsearch-hits .prestartsearch-hit-footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: .5rem;
    margin-top: auto;
}

.prestartsearch-hits .prestartsearch-hit-price {
    font-weight: 700;
    color: var(--prestartsearch-accent, var(--primary, #2b6cb0));
}

.prestartsearch-add-to-cart {
    flex: 0 0 auto;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 2rem;
    height: 2rem;
    background: var(--prestartsearch-accent, var(--primary, #2b6cb0));
    border: 0;
    border-radius: calc(var(--prestartsearch-radius, 6px) / 1.5);
    color: #fff;
    font-size: 1rem;
    line-height: 1;
    cursor: pointer;
    transition: opacity .15s ease;
}

.prestartsearch-add-to-cart-icon {
    display: block;
    width: 1rem;
    height: 1rem;
}

.prestartsearch-add-to-cart:hover,
.prestartsearch-add-to-cart:focus-visible {
    opacity: .85;
    outline: none;
}

.prestartsearch-add-to-cart[disabled] {
    opacity: .6;
    cursor: default;
}

.prestartsearch-add-to-cart.has-error {
    background: #d9534f;
}

@media (max-width: 767px) {
    .prestartsearch-overlay {
        padding: 0;
    }

    .prestartsearch-overlay-inner {
        width: 100%;
        max-height: 100vh;
        border-radius: 0;
    }

    .prestartsearch-overlay-body {
        grid-template-columns: minmax(0, 1fr);
    }

    .prestartsearch-toggle-filters {
        display: block;
    }

    .prestartsearch-facets {
        display: none;
    }

    .prestartsearch-facets.is-visible {
        display: block;
    }

    .prestartsearch-apply-filters {
        display: block;
    }
}
