/* AI Search: top-bar toggle + drop-down strip */

.top-header-wrapper {
    position: relative;
}

/* --- Toggle (styled like the other top-bar links) --- */
.ai-search-toggle {
    background: none;
    border: 0;
    padding: 0;
    margin-right: 20px;
    color: #ccc;
    font: inherit;
    font-weight: 400;
    cursor: pointer;
    transition: color 0.2s ease;
}

.ai-search-toggle i {
    color: #84C44C;
}

.ai-search-toggle:hover,
.ai-search-toggle[aria-expanded="true"] {
    color: #fff;
    text-shadow: 0 0 5px rgba(255, 255, 255, 0.5);
}

.ai-search-toggle:focus-visible,
.ai-search-close:focus-visible {
    outline: 2px solid #84C44C;
    outline-offset: 3px;
    border-radius: 4px;
}

/* --- Strip --- */
.ai-search-strip {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    z-index: 10001; /* above .main-header (10000 !important, product-search.css); drawer (10001) is later in DOM so still wins; sidebars are 10005 */
    background-color: #131921;
    border-top: 1px solid rgba(255, 255, 255, 0.1);
    padding: 12px 40px;
    box-shadow: 0 8px 20px rgba(0, 0, 0, 0.25);
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
    transform: translateY(-6px);
    transition: opacity 0.2s cubic-bezier(0.16, 1, 0.3, 1),
                transform 0.2s cubic-bezier(0.16, 1, 0.3, 1),
                visibility 0s linear 0.2s;
}

.ai-search-strip.is-open {
    opacity: 1;
    visibility: visible;
    pointer-events: auto;
    transform: none;
    transition: opacity 0.2s cubic-bezier(0.16, 1, 0.3, 1),
                transform 0.2s cubic-bezier(0.16, 1, 0.3, 1),
                visibility 0s;
}

.ai-search-form {
    display: flex;
    align-items: center;
    gap: 14px;
    max-width: 820px;
    margin: 0 auto;
}

.ai-search-form .search-container {
    flex: 1;
}

.ai-search-label {
    color: #fff;
    font-family: var(--font-heading);
    font-weight: 600;
    font-size: 15px;
    white-space: nowrap;
}

.ai-search-label i {
    color: #84C44C;
    margin-right: 4px;
}

.ai-search-close {
    flex-shrink: 0;
    width: 44px;
    height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: none;
    border: 0;
    border-radius: 50%;
    color: #ccc;
    font-size: 18px;
    cursor: pointer;
    transition: color 0.2s ease, background-color 0.2s ease;
}

.ai-search-close:hover {
    color: #fff;
    background-color: rgba(255, 255, 255, 0.08);
}

/* Desktop: match the centered top-bar width (see global.css @1200px) */
@media (min-width: 1200px) {
    .ai-search-strip {
        left: 50%;
        right: auto;
        width: min(1400px, calc(100% - 180px));
        transform: translate(-50%, -6px);
    }

    .ai-search-strip.is-open {
        transform: translate(-50%, 0);
    }
}

@media (max-width: 1200px) {
    .ai-search-toggle {
        font-size: 10px;
    }
}

@media (max-width: 767px) {
    .ai-search-strip {
        padding: 10px;
    }

    .ai-search-form {
        gap: 6px;
    }

    .ai-search-label {
        display: none;
    }
}

@media (prefers-reduced-motion: reduce) {
    .ai-search-strip,
    .ai-search-strip.is-open {
        transition: none;
    }
}

/* --- Results panel (reuses the live-search .search-suggestions item styles) --- */
.ai-search-strip .ai-search-results {
    position: static;
    max-width: 820px;
    margin: 10px auto 0;
    max-height: min(70vh, 560px);
    overflow-y: auto;
    overscroll-behavior: contain;
    z-index: auto !important;
}

.ai-answer,
.ai-notice {
    display: flex;
    gap: 10px;
    align-items: flex-start;
    padding: 12px 14px;
    font-size: 14px;
    line-height: 1.5;
    color: #222;
    border-bottom: 1px solid #f0f0f0;
}

.ai-answer {
    background: #f4faee;
}

.ai-answer > i {
    color: #84C44C;
    margin-top: 3px;
}

.ai-notice {
    background: #f8f9fa;
    color: #444;
    font-size: 13px;
}

.ai-notice > i {
    color: #00afef;
    margin-top: 2px;
}

.ai-notice a {
    color: #00afef;
    font-weight: 600;
    text-decoration: underline;
}

.ai-notice--error {
    background: #fff5f5;
    color: #b42318;
}

.ai-notice--error > i {
    color: #b42318;
}

.ai-price-locked {
    font-size: 12px;
    font-weight: 500;
    color: #777;
}

.ai-price-locked i {
    font-size: 10px;
    margin-right: 3px;
}

.ai-qty {
    color: #2f7d12;
    font-weight: 600;
}

.ai-unmatched {
    padding: 10px 14px;
    font-size: 13px;
    color: #555;
    background: #fffaf0;
    border-bottom: 1px solid #f0f0f0;
}

.ai-search-results .ai-add-all {
    width: 100%;
    border: 0;
    cursor: pointer;
    font-family: inherit;
    gap: 8px;
}

.ai-search-results .ai-add-all:disabled {
    cursor: default;
    opacity: 0.8;
}

/* Loading skeleton */
.ai-skeleton {
    pointer-events: none;
}

.ai-sk {
    display: block;
    border-radius: 4px;
    background: linear-gradient(90deg, #f0f0f0 25%, #f8f8f8 50%, #f0f0f0 75%);
    background-size: 200% 100%;
    animation: aiShimmer 1.2s ease-in-out infinite;
}

.ai-sk-img {
    width: 100%;
    height: 100%;
    border-radius: 6px;
}

.ai-sk-line {
    height: 12px;
    width: 80%;
    margin: 4px 0;
}

.ai-sk-short {
    width: 45%;
}

@keyframes aiShimmer {
    from { background-position: 200% 0; }
    to { background-position: -200% 0; }
}

@media (max-width: 767px) {
    .ai-search-strip .ai-search-results {
        max-height: 65vh;
        margin-top: 8px;
    }

    /* Keep product titles readable: let the guest price label wrap into a narrow column */
    .ai-price-locked {
        display: inline-block;
        max-width: 64px;
        white-space: normal;
        text-align: right;
        line-height: 1.25;
        font-size: 11px;
    }
}

@media (prefers-reduced-motion: reduce) {
    .ai-sk {
        animation: none;
    }
}
