/* AIC Smart Search — frontend overlay styles */

/* ── Theme compatibility: hide native search when overlay is open ── */
/* Astra theme */
body.aic-search-open .ast-search-menu-icon,
body.aic-search-open .ast-search-menu-icon.ast-dropdown-active {
    display: none !important;
}
/* Generic fallback for other themes that toggle a search container */
body.aic-search-open .site-search.active,
body.aic-search-open .search-form-wrapper.open,
body.aic-search-open .header-search.active {
    display: none !important;
}

/* ── Overlay backdrop ─────────────────────────────────────── */
.aic-search-overlay {
    position: fixed;
    inset: 0;
    z-index: 999999;
    background: rgba(0, 0, 0, 0.50);
    display: flex;
    align-items: flex-start;
    justify-content: center;
    padding: 72px 16px 16px;
    backdrop-filter: blur(3px);
    -webkit-backdrop-filter: blur(3px);
    animation: aicFadeIn 0.15s ease;
}

.aic-search-overlay[hidden] {
    display: none !important;
}

@keyframes aicFadeIn {
    from { opacity: 0; }
    to   { opacity: 1; }
}

body.aic-search-open {
    overflow: hidden;
}

/* ── Modal card ───────────────────────────────────────────── */
.aic-search-modal {
    width: 100%;
    max-width: 700px;
    background: #fff;
    border-radius: 14px;
    box-shadow: 0 24px 80px rgba(0, 0, 0, 0.28), 0 0 0 1px rgba(0,0,0,0.06);
    overflow: hidden;
    animation: aicSlideDown 0.18s ease;
}

@keyframes aicSlideDown {
    from { transform: translateY(-14px); opacity: 0; }
    to   { transform: translateY(0);     opacity: 1; }
}

/* ── Header row ───────────────────────────────────────────── */
.aic-search-header {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 14px 18px;
    border-bottom: 1px solid rgba(0,0,0,0.07);
}

.aic-search-input-wrap {
    flex: 1;
    display: flex;
    align-items: center;
    gap: 8px;
    background: #f4f4f5;
    border: 2px solid transparent;
    border-radius: 10px;
    padding: 0 12px;
    transition: border-color 0.15s, background 0.15s;
}

.aic-search-input-wrap:focus-within {
    border-color: var(--aic-accent, #2271b1);
    background: #fff;
}

.aic-search-icon {
    width: 18px;
    height: 18px;
    color: #8b8b9a;
    flex-shrink: 0;
}

.aic-search-input {
    flex: 1;
    border: none !important;
    background: transparent !important;
    outline: none !important;
    box-shadow: none !important;
    font-size: 16px;
    line-height: 1.4;
    padding: 12px 0 !important;
    color: #111;
    margin: 0 !important;
    min-width: 0;
}

.aic-search-input::placeholder {
    color: #aaa;
}

.aic-search-clear {
    background: none;
    border: none;
    cursor: pointer;
    color: #aaa;
    font-size: 22px;
    line-height: 1;
    padding: 0;
    display: flex;
    align-items: center;
}

.aic-search-clear:hover { color: #555; }

.aic-search-close {
    background: none;
    border: none;
    cursor: pointer;
    color: var(--aic-accent, #2271b1);
    font-size: 14px;
    font-weight: 600;
    padding: 6px 2px;
    white-space: nowrap;
    flex-shrink: 0;
}

.aic-search-close:hover { opacity: 0.75; }

/* ── Results list ─────────────────────────────────────────── */
.aic-search-results {
    max-height: 500px;
    overflow-y: auto;
    overscroll-behavior: contain;
    -webkit-overflow-scrolling: touch;
}

/* ── Individual result ────────────────────────────────────── */
.aic-result-item {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 12px 18px;
    text-decoration: none;
    color: inherit;
    border-bottom: 1px solid rgba(0,0,0,0.05);
    transition: background 0.1s;
    position: relative;
    cursor: pointer;
}

.aic-result-item:last-of-type {
    border-bottom: none;
}

.aic-result-item:hover,
.aic-result-item.is-active {
    background: #f8f8ff;
}

/* ── Thumbnail ────────────────────────────────────────────── */
.aic-result-img {
    width: 54px;
    height: 54px;
    flex-shrink: 0;
    border-radius: 8px;
    overflow: hidden;
    background: #f5f5f5;
    border: 1px solid rgba(0,0,0,0.06);
}

.aic-result-img img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

.aic-result-img-ph {
    width: 100%;
    height: 100%;
    background: linear-gradient(135deg, #ebebeb 0%, #d8d8d8 100%);
}

/* ── Text content ─────────────────────────────────────────── */
.aic-result-body {
    flex: 1;
    min-width: 0;
}

.aic-result-title {
    font-size: 15px;
    font-weight: 600;
    color: #111;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    line-height: 1.35;
}

.aic-result-title mark {
    background: rgba(34, 113, 177, 0.14);
    color: var(--aic-accent, #2271b1);
    border-radius: 2px;
    padding: 0 2px;
    font-style: normal;
}

.aic-result-cats {
    font-size: 12px;
    color: #888;
    margin-top: 2px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.aic-result-price {
    font-size: 14px;
    font-weight: 700;
    color: var(--aic-accent, #2271b1);
    margin-top: 4px;
}

.aic-result-price del,
.aic-result-price .woocommerce-Price-amount:first-child del {
    color: #b0b0b0;
    font-weight: 400;
    font-size: 12px;
}

.aic-result-oos {
    font-size: 11px;
    font-weight: 600;
    color: #c0392b;
    margin-top: 3px;
    text-transform: uppercase;
    letter-spacing: 0.03em;
}

/* ── Type badge ───────────────────────────────────────────── */
.aic-result-badge {
    font-size: 10px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--aic-accent, #2271b1);
    background: rgba(34, 113, 177, 0.1);
    border-radius: 4px;
    padding: 3px 7px;
    flex-shrink: 0;
    white-space: nowrap;
}

/* ── States ───────────────────────────────────────────────── */
.aic-search-loading,
.aic-search-empty,
.aic-search-error {
    padding: 36px 20px;
    text-align: center;
    color: #999;
    font-size: 14px;
}

/* Loading dots */
.aic-dots {
    display: inline-flex;
    gap: 6px;
    align-items: center;
}

.aic-dots span {
    display: inline-block;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--aic-accent, #2271b1);
    animation: aicDot 1.1s infinite ease-in-out;
    opacity: 0.5;
}

.aic-dots span:nth-child(2) { animation-delay: 0.18s; }
.aic-dots span:nth-child(3) { animation-delay: 0.36s; }

@keyframes aicDot {
    0%, 80%, 100% { transform: scale(0.65); opacity: 0.4; }
    40%            { transform: scale(1);    opacity: 1; }
}

/* ── View-all footer ──────────────────────────────────────── */
.aic-view-all {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 13px 18px;
    background: #f8f8fc;
    border-top: 1px solid rgba(0,0,0,0.06);
    color: var(--aic-accent, #2271b1);
    font-size: 13px;
    font-weight: 600;
    text-decoration: none;
    transition: background 0.1s;
}

.aic-view-all:hover {
    background: #eeeeff;
    color: var(--aic-accent, #2271b1);
}

/* ── Mobile ───────────────────────────────────────────────── */
@media ( max-width: 600px ) {
    .aic-search-overlay {
        padding: 0;
        align-items: stretch;
    }

    .aic-search-modal {
        border-radius: 0;
        display: flex;
        flex-direction: column;
        min-height: 100%;
    }

    .aic-search-results {
        flex: 1;
        max-height: none;
    }
}
