/* =======================================================================
   Aveo Custom Whitelist Search – Frontend Styles
   ======================================================================= */

/*— 1. Search box wrapper —*/
.aveo-search-box {
    position: relative;
    overflow: visible !important;
}

/*— 2. The input itself —*/
#aveo-search-field {
    width: 100%;
    min-width: 300px;
    max-width: 400px;
    padding: 0.55rem 2.5rem 0.55rem 0.9rem;
    border: 1px solid #ccc;
    border-radius: 9999px;
    font-size: 15px;
    transition: border 0.15s ease;
}

#aveo-search-field:focus {
    border-color: #007cba;
    outline: none;
}

/*— 3. Icon-only button —*/
.aveo-search-btn {
    position: absolute;
    top: 50%;
    right: -2.75rem;
    transform: translateY(-20%);
    border: none;
    background: transparent;
    font-family: "dashicons";
    font-size: 24px;
    color: #666;
    cursor: pointer;
}

.aveo-search-btn:before {
    content: "\f179";
}

.aveo-search-btn:hover:before,
.aveo-search-btn:focus:before {
    color: #000;
}

/*— 4. Dropdown base —*/
.aveo-search-dropdown {
    list-style: none;
    margin: 0;
    padding: 0.5rem 0;
    background: #fff;
    border: 1px solid #ddd;
    border-radius: 4px;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.1);
    max-height: clamp(260px, 70vh, 720px);
    overflow-y: auto;
    overscroll-behavior: contain;
    -webkit-overflow-scrolling: touch;
    z-index: 100000;
    width: 200%;
}

.aveo-search-dropdown.is-hidden {
    display: none !important;
}

@media (max-width: 600px) {
    .aveo-search-dropdown {
        max-height: calc(100dvh - 80px);
        touch-action: pan-y;
        background: #fff;
        padding: 0;
        border-radius: 0;
    }

    body.aveo-search-lock-scroll {
        overflow: hidden;
        touch-action: none;
    }
}

/*— 5. Mobile close row —*/
/* Kräver att JS lägger till .aveo-mobile-close-row / .aveo-mobile-close-btn */
.aveo-mobile-close-row {
    display: none;
}

@media (max-width: 600px) {
    .aveo-mobile-close-row {
        display: block;
        position: sticky;
        top: 0;
        z-index: 5;
        list-style: none;
        background: #fff;
        border-bottom: 1px solid #ddd;
        padding: 8px;
    }

    .aveo-mobile-close-btn {
        width: 100%;
        padding: 10px 12px;
        border: 1px solid #999;
        border-radius: 6px;
        background: #f7f7f7;
        color: #222;
        font-size: 14px;
        font-weight: 700;
        cursor: pointer;
    }

    .aveo-mobile-close-btn:hover,
    .aveo-mobile-close-btn:focus {
        background: #eee;
    }
}

/*— 6. Each result item (li) —*/
.aveo-search-dropdown .aveo-item {
    display: flex;
    flex-direction: column;
    padding: 0;
    border-bottom: 1px solid #eee;
    white-space: normal;
}

.aveo-search-dropdown .aveo-item:last-child {
    border-bottom: none;
}

.aveo-show-all {
    padding: 0.5rem 1rem 0.25rem;
}

.aveo-show-all-btn {
    width: 100%;
    border: 1px solid #007cba;
    border-radius: 4px;
    background: #fff;
    color: #007cba;
    font-weight: 600;
    padding: 0.65rem 0.75rem;
    cursor: pointer;
}

.aveo-show-all-btn:hover,
.aveo-show-all-btn:focus {
    background: #f0f8fc;
}

/* Main clickable row */
.aveo-search-dropdown .aveo-item>a {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    width: 100%;
    text-decoration: none;
    color: inherit;
    transition: background 0.15s;
    padding: 0.5rem 1rem;
    background: transparent !important;
}

/* Remove grey background on hover */
.aveo-search-dropdown .aveo-item>a:hover,
.aveo-search-dropdown .aveo-item>a:focus {
    background: transparent !important;
}

/*— 7. Thumbnail —*/
.aveo-search-dropdown img {
    width: 48px;
    height: 48px;
    object-fit: contain;
    object-position: center center;
    background: #fff;
    flex: 0 0 48px;
    border-radius: 4px;
}

/*— 8. SKU + title block —*/
.aveo-details {
    display: flex;
    flex-direction: column;
    gap: 0.2rem;
    flex: 1;
    min-width: 0;
}

.aveo-sku {
    font-size: 12px;
    color: #666;
}

.aveo-title {
    font-weight: 600;
    line-height: 1.2;
    word-break: break-word;
}

/*— 9. Price —*/
.aveo-price {
    margin-left: auto;
    white-space: nowrap;
    font-size: 13px;
    color: #007cba;
    flex: 0 0 auto;
}

.aveo-result-meta {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 10px;
    margin-left: auto;
    flex: 0 0 auto;
}

.aveo-result-meta .aveo-price {
    margin-left: 0;
    font-weight: 700;
}

.aveo-login-price-note {
    display: inline-flex;
    align-items: center;
    justify-content: flex-end;
    max-width: 150px;
    color: #007cba;
    font-size: 12px;
    font-weight: 600;
    line-height: 1.25;
    text-align: right;
    text-decoration: underline;
    white-space: normal;
    cursor: pointer;
}

.aveo-login-price-note:hover,
.aveo-login-price-note:focus {
    color: #005f8d;
}

.aveo-login-price-note.is-popup {
    display: block;
    max-width: none;
    margin: 0 0 8px 0;
    text-align: left;
}

/*— 10. Popup card —*/
.aveo-popup {
    z-index: 100000;
    width: 260px;
    padding: 1rem;
    background: #fff;
    border: 1px solid #ccc;
    border-radius: 6px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

.aveo-popup-thumb {
    width: 100%;
    height: auto;
    border-radius: 4px;
}

.aveo-popup-title {
    margin: 0.5rem 0 0.25rem;
    font-size: 16px;
}

.aveo-popup-desc {
    margin: 0.5rem 0;
    font-size: 14px;
    line-height: 1.4;
    color: #555;
}

.aveo-popup-stock {
    margin: 0 0 0.75rem;
    font-size: 14px;
    color: #666;
}

/* Controls in popup */
.aveo-popup-controls {
    display: flex;
    flex-direction: column;
    gap: 8px;
    align-items: flex-start;
}

.aveo-popup-qty {
    width: 60px;
    max-width: 110px;
}

.aveo-popup-atc {
    flex: 1;
    padding: 0.4rem 0.75rem;
    background-color: var(--fs-color-secondary);
    color: #fff;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-size: 14px;
}

.aveo-popup-atc[disabled] {
    opacity: 0.9;
    cursor: not-allowed;
}

.aveo-popup.select-open {
    padding-bottom: 160px;
}

/* Variable form inside popup */
.aveo-var-form {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    margin: 0.75rem 0;
}

.aveo-var-form label {
    font-size: 13px;
}

.aveo-var-form select {
    width: 100%;
    padding: 0.25rem;
    border: 1px solid #ccc;
    border-radius: 4px;
}

/*— 11. Mobile main-row layout —*/
@media (max-width: 600px) {
    .aveo-search-dropdown .aveo-item>a {
        display: grid !important;
        grid-template-columns: 48px minmax(0, 1fr) minmax(82px, 112px);
        grid-template-rows: auto auto;
        column-gap: 10px;
        row-gap: 3px;
        align-items: center;
        padding: 10px;
    }

    .aveo-search-dropdown .aveo-item>a>img {
        grid-column: 1 / 2;
        grid-row: 1 / 3;
        width: 48px !important;
        height: 48px !important;
        object-fit: contain;
        background: #fff;
    }

    .aveo-search-dropdown .aveo-details {
        grid-column: 2 / 3;
        grid-row: 1 / 3;
        display: grid;
        grid-template-rows: auto auto auto;
        row-gap: 2px;
        min-width: 0 !important;
        overflow: visible;
    }

    .aveo-search-dropdown .aveo-sku {
        grid-row: 1;
        display: block;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
        max-width: 100%;
    }

    .aveo-search-dropdown .aveo-title {
        grid-row: 2;
        display: block;
        white-space: normal;
        overflow-wrap: anywhere;
    }

    .aveo-search-dropdown .aveo-result-meta {
        grid-column: 3 / 4;
        grid-row: 1 / 3;
        display: flex !important;
        flex-direction: column;
        align-items: flex-end;
        justify-content: center;
        gap: 4px;
        justify-self: end;
        align-self: center;
        min-width: 82px;
        max-width: 112px;
        margin: 0 !important;
    }

    .aveo-search-dropdown .aveo-result-meta .aveo-stock-badge.is-main,
    .aveo-search-dropdown .aveo-result-meta .aveo-price,
    .aveo-search-dropdown .aveo-result-meta .aveo-login-price-note {
        display: inline-flex !important;
        visibility: visible !important;
        opacity: 1 !important;
        margin: 0 !important;
        max-width: 112px;
    }

    .aveo-search-dropdown .aveo-result-meta .aveo-stock-badge.is-main,
    .aveo-search-dropdown .aveo-result-meta .aveo-price {
        white-space: nowrap;
    }

    .aveo-search-dropdown .aveo-result-meta .aveo-price {
        min-width: 72px;
        text-align: right;
        justify-content: flex-end;
        overflow: hidden;
        text-overflow: ellipsis;
        color: #007cba;
        font-size: 13px;
        font-weight: 700;
        line-height: 1.3;
    }
}

/* Popup meta */
.aveo-popup-sku-simple {
    font-size: 12px;
    color: #666;
    margin-top: 0.5rem;
    text-align: center;
}

.aveo-popup-sku {
    font-size: 12px;
    color: #666;
    margin-top: 0.5rem;
    margin-bottom: 0;
}

.aveo-popup-meta {
    font-size: 12px;
    color: #666;
    margin-top: 0.5rem;
    margin-bottom: 0;
}

.aveo-popup-meta.colors {
    padding-left: 0;
    padding-top: 0;
    margin-top: 0.5rem;
}

/* Spinner */
.spin {
    display: inline-block;
    vertical-align: middle;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    from {
        transform: rotate(0deg);
    }

    to {
        transform: rotate(360deg);
    }
}

/* optional: center the li and give it some padding */
.aveo-search-dropdown .aveo-loading {
    padding: 0.5em 1em;
    text-align: center;
    cursor: default;
}

/* dashicon search */
.aveo-search-btn:before {
    content: "\f179";
}

/* loading state */
.aveo-search-btn.loading:before {
    content: "\f463";
    animation: spin 1s linear infinite;
}

/* Qty margin resets */
.aveo-popup .aveo-qty-row {
    margin-left: 0 !important;
    padding-left: 0 !important;
}

.aveo-popup .aveo-popup-qty {
    margin-left: 0 !important;
}

.aveo-popup .qty {
    margin-left: 0 !important;
}

/* Taxonomy chips */
.aveo-chip {
    display: inline-block;
    padding: 2px 8px;
    border: 1px solid rgba(0, 0, 0, 0.15);
    border-radius: 999px;
    text-decoration: none;
    line-height: 1.8;
    margin-right: 6px;
    margin-bottom: 4px;
}

.aveo-chip:hover {
    text-decoration: underline;
}

.aveo-link-sku {
    text-decoration: none;
}

.aveo-link-sku:hover {
    text-decoration: underline;
}

.aveo-meta-label {
    opacity: 0.8;
}

/* ===== Stock colors in popup ===== */
.aveo-popup-stock.is-out-of-stock {
    color: #d63638;
    font-weight: 600;
}

.aveo-popup-stock.is-low-stock {
    color: #d98500;
    font-weight: 600;
}

.aveo-popup-stock.is-in-stock {
    color: #2e7d32;
    font-weight: 600;
}

/* ===== Stock badge generic ===== */
.aveo-stock-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 2px 8px;
    border-radius: 999px;
    font-size: 12px;
    line-height: 1.6;
    border: 1px solid rgba(0, 0, 0, 0.12);
    white-space: nowrap;
}

.aveo-stock-badge.is-out-of-stock {
    color: #d63638;
    border-color: rgba(214, 54, 56, 0.35);
}

.aveo-stock-badge.is-low-stock {
    color: #d98500;
    border-color: rgba(217, 133, 0, 0.35);
}

.aveo-stock-badge.is-in-stock {
    color: #2e7d32;
    border-color: rgba(46, 125, 50, 0.35);
}

/* Main badge before price: push it right on desktop */
.aveo-stock-badge.is-main {
    margin-left: auto;
    margin-right: 10px;
}

.aveo-result-meta .aveo-stock-badge.is-main {
    margin-left: 0;
    margin-right: 0;
}

/* =======================================================================
   Variant list in dropdown
   Structure: thumb + link + .aveo-variant-right
   ======================================================================= */

.aveo-variant-list {
    margin: 0;
    padding: 6px 14px 10px 72px;
    display: block;
    font-size: 12px;
    opacity: 0.98;
    background: #fff;
}

.aveo-variant-list.is-hidden {
    display: none;
}

/* Desktop: grid row with right column */
.aveo-variant-row {
    display: grid;
    grid-template-columns: 28px minmax(0, 1fr) max-content;
    column-gap: 10px;
    align-items: start;
    padding: 6px 8px;
    border-radius: 6px;
}

.aveo-variant-row:hover {
    background: #f2f6ff;
}

/* Variant image */
.aveo-variant-thumb {
    width: 28px;
    height: 28px;
    border-radius: 4px;
    object-fit: contain;
    background: rgba(0, 0, 0, 0.04);
    grid-column: 1 / 2;
    grid-row: 1;
}

.aveo-variant-thumb.placeholder {
    display: inline-block;
    width: 28px;
    height: 28px;
    border-radius: 4px;
    background: rgba(0, 0, 0, 0.06);
    grid-column: 1 / 2;
    grid-row: 1;
}

/* Variant link */
.aveo-variant-link {
    grid-column: 2 / 3;
    grid-row: 1;
    min-width: 0;
    text-decoration: none;
    color: inherit;
    display: block;
}

.aveo-variant-link:hover {
    text-decoration: underline;
}

.aveo-variant-link .aveo-variant-sku {
    display: block;
    font-size: 12px;
    color: #666;
    line-height: 1.2;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.aveo-variant-link .aveo-variant-label {
    display: block;
    font-size: 12px;
    line-height: 1.2;
    white-space: normal;
    overflow-wrap: anywhere;
}

/* Right column: badge + price */
.aveo-variant-right {
    display: flex;
    flex-direction: row;
    align-items: center;
    justify-content: flex-end;
    gap: 8px;
    min-width: 110px;
}

.aveo-stock-badge.is-variant {
    margin: 0 !important;
    white-space: nowrap;
}

.aveo-variant-price {
    white-space: nowrap;
    text-align: right;
}

/* Mobile variants */
@media (max-width: 600px) {
    .aveo-stock-badge.is-main {
        margin-left: 0 !important;
        margin-right: 0 !important;
    }

    .aveo-variant-list {
        padding: 0 10px 10px 64px;
        background: #fff;
    }

    .aveo-variant-list:not(.is-hidden) {
        display: block !important;
    }

    .aveo-variant-row {
        display: grid !important;
        grid-template-columns: 24px minmax(0, 1fr) max-content;
        column-gap: 8px;
        align-items: center;
        padding: 7px 0;
    }

    .aveo-variant-thumb,
    .aveo-variant-thumb.placeholder {
        width: 24px;
        height: 24px;
        object-fit: contain;
        background: #fff !important;
    }

    .aveo-variant-link {
        min-width: 0;
    }

    .aveo-variant-link .aveo-variant-sku {
        max-width: 100%;
    }

    .aveo-variant-right {
        display: flex !important;
        flex-direction: column;
        align-items: flex-end;
        justify-content: center;
        gap: 4px;
        min-width: 72px;
        max-width: 125px;
    }

    .aveo-variant-price,
    .aveo-variant-right .aveo-stock-badge,
    .aveo-stock-badge.is-variant,
    .aveo-variant-right .aveo-login-price-note {
        display: inline-flex !important;
        visibility: visible !important;
        opacity: 1 !important;
    }

    .aveo-variant-price,
    .aveo-variant-right .aveo-stock-badge,
    .aveo-stock-badge.is-variant {
        white-space: nowrap;
    }

    .aveo-variant-price {
        min-width: 72px;
        max-width: 125px;
        text-align: right;
        justify-content: flex-end;
        overflow: hidden;
        text-overflow: ellipsis;
        font-weight: 700;
        line-height: 1.3;
    }

    .aveo-stock-badge.is-variant {
        max-width: 125px;
    }
}

/* FORCE: variant thumbnails must never crop */
.aveo-search-dropdown img.aveo-variant-thumb {
    width: 28px !important;
    height: 28px !important;
    display: block;
    object-fit: contain !important;
    object-position: center center !important;
    background: #fff !important;
    border-radius: 4px;
}

@media (max-width: 600px) {
    .aveo-search-dropdown img.aveo-variant-thumb {
        width: 24px !important;
        height: 24px !important;
    }
}

.aveo-variant-row.is-selected {
    background: #f2f6ff;
}

/* Popup: tighten spacing around price */
.aveo-popup .aveo-popup-price {
    margin: 0 0 4px 0 !important;
    line-height: 1.2;
}

/* Popup: tighten spacing around stock line */
.aveo-popup .aveo-popup-stock {
    margin: 0 0 8px 0 !important;
    line-height: 1.2;
}

/* Woo price HTML can contain <ins>/<del> with extra spacing */
.aveo-popup .aveo-popup-price ins,
.aveo-popup .aveo-popup-price del {
    margin: 0 !important;
    padding: 0 !important;
}

/* Sometimes price HTML renders as <p class="price"> with margin */
.aveo-popup .aveo-popup-price p,
.aveo-popup .aveo-popup-price .price {
    margin: 0 !important;
}

/* Popup: make image height consistent across products */
.aveo-popup .aveo-popup-thumb {
    display: block;
    width: 100%;
    height: 180px;
    object-fit: contain;
    background: #fff;
    border-radius: 4px;
}

/* =======================================================================
   Infinite scroll loading row
   ======================================================================= */

.aveo-loading-more {
    padding: 12px;
    text-align: center;
    font-size: 13px;
    color: #666;
    list-style: none;
    background: #fff;
    border-top: 1px solid #eee;
}
