/*
 * NovaCommerce Fuzzy Search
 * Stile compatibile con Hyva senza compilazione Tailwind.
 */

.nwc-fuzzy-host {
    position: relative !important;
}

form[data-nwc-fuzzy-active="1"] [x-show*="suggestions"]:not(.nwc-fuzzy-panel),
form[data-nwc-fuzzy-active="1"] [data-role="search-suggestions"]:not(.nwc-fuzzy-panel) {
    display: none !important;
}

.nwc-fuzzy-panel {
    position: absolute;
    z-index: 10000;
    top: calc(100% + 6px);
    left: 50%;
    width: min(760px, calc(100vw - 24px));
    max-height: min(640px, 72vh);
    overflow: auto;
    transform: translateX(-50%);

    border: 1px solid #d7ddda;
    border-radius: 10px;
    background: #fff;
    box-shadow:
        0 18px 50px rgba(20, 40, 32, 0.18),
        0 4px 14px rgba(20, 40, 32, 0.08);

    color: #1f2933;
}

.nwc-fuzzy-panel[hidden] {
    display: none !important;
}

.nwc-fuzzy-results {
    display: block;
}

.nwc-fuzzy-result {
    display: grid;
    grid-template-columns: 74px minmax(0, 1fr) auto;
    gap: 14px;
    align-items: center;

    min-height: 92px;
    padding: 10px 14px;

    border-bottom: 1px solid #edf0ee;
    color: inherit;
    text-decoration: none;
    transition:
        background-color 120ms ease,
        transform 120ms ease;
}

.nwc-fuzzy-result:hover,
.nwc-fuzzy-result:focus,
.nwc-fuzzy-result.is-active {
    background: #f2f7f4;
    color: inherit;
    outline: none;
}

.nwc-fuzzy-image {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 74px;
    height: 74px;
    overflow: hidden;
    border: 1px solid #e4e9e6;
    border-radius: 7px;
    background: #fff;
}

.nwc-fuzzy-image img {
    display: block;
    width: 100%;
    height: 100%;
    object-fit: contain;
}

.nwc-fuzzy-content {
    display: flex;
    min-width: 0;
    flex-direction: column;
    gap: 5px;
}

.nwc-fuzzy-name {
    display: block;
    overflow: hidden;
    color: #1f2933;
    font-size: 14px;
    line-height: 1.35;
    text-overflow: ellipsis;
}

.nwc-fuzzy-name strong {
    color: #173f32;
    font-weight: 750;
}

.nwc-fuzzy-sku {
    color: #728078;
    font-size: 11px;
    line-height: 1.25;
}

.nwc-fuzzy-price {
    display: flex;
    min-width: 92px;
    flex-direction: column;
    align-items: flex-end;
    gap: 3px;
    text-align: right;
    white-space: nowrap;
}

.nwc-fuzzy-price strong {
    color: #173f32;
    font-size: 14px;
    font-weight: 750;
}

.nwc-fuzzy-price del {
    color: #88938d;
    font-size: 11px;
}

.nwc-fuzzy-see-all {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 48px;
    padding: 10px 16px;

    background: #f5f7f6;
    color: #315f50;
    font-size: 13px;
    font-weight: 700;
    text-align: center;
    text-decoration: none;
    text-transform: uppercase;
    letter-spacing: 0.02em;
}

.nwc-fuzzy-see-all:hover,
.nwc-fuzzy-see-all:focus,
.nwc-fuzzy-see-all.is-active {
    background: #e6f0eb;
    color: #173f32;
    outline: none;
}

.nwc-fuzzy-message,
.nwc-fuzzy-correction {
    padding: 14px 16px;
    color: #5b6861;
    font-size: 13px;
    line-height: 1.4;
}

.nwc-fuzzy-correction {
    border-bottom: 1px solid #edf0ee;
    background: #f7faf8;
}

.nwc-fuzzy-correction strong {
    color: #173f32;
}

.nwc-fuzzy-loading {
    position: relative;
    padding-left: 42px;
}

.nwc-fuzzy-loading::before {
    position: absolute;
    top: 50%;
    left: 17px;
    width: 14px;
    height: 14px;
    margin-top: -7px;
    border: 2px solid #bad1c7;
    border-top-color: #3b7f6b;
    border-radius: 50%;
    content: "";
    animation: nwc-fuzzy-spin 650ms linear infinite;
}

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

@media (max-width: 767px) {
    .nwc-fuzzy-panel {
        position: fixed;
        z-index: 100000;
        top: 74px;
        right: 8px;
        left: 8px;
        width: auto;
        max-height: calc(100vh - 90px);
        transform: none;
        border-radius: 9px;
    }

    .nwc-fuzzy-result {
        grid-template-columns: 62px minmax(0, 1fr);
        min-height: 78px;
        gap: 10px;
        padding: 8px 10px;
    }

    .nwc-fuzzy-image {
        width: 62px;
        height: 62px;
    }

    .nwc-fuzzy-price {
        grid-column: 2;
        flex-direction: row;
        align-items: baseline;
        justify-content: flex-start;
        min-width: 0;
        text-align: left;
    }
}

@media (prefers-reduced-motion: reduce) {
    .nwc-fuzzy-result {
        transition: none;
    }

    .nwc-fuzzy-loading::before {
        animation-duration: 1.4s;
    }
}
