/* ==========================================================================
   VP Search — Autocomplétion avec images produit
   ========================================================================== */

.vp-search {
    position: relative;
    max-width: 640px;
    margin: 0 auto;
    width: 100%;
}

.vp-search-form {
    position: relative;
    display: flex;
    align-items: center;
}

.vp-search-input {
    width: 100%;
    height: 52px;
    padding: 0 56px 0 24px;
    border: 2px solid #e5e7eb;
    border-radius: 28px;
    background: #ffffff;
    color: #1a1a1a;
    font-size: 15px;
    font-family: inherit;
    transition: border-color 0.2s, box-shadow 0.2s;
    outline: none;
    -webkit-appearance: none;
    appearance: none;
}

.vp-search-input:focus {
    border-color: #DF0067;
    box-shadow: 0 0 0 4px rgba(223, 0, 103, 0.12);
}

.vp-search-input::placeholder {
    color: #9ca3af;
}

.vp-search-btn {
    position: absolute;
    right: 4px;
    top: 50%;
    transform: translateY(-50%);
    width: 44px;
    height: 44px;
    border-radius: 50%;
    border: 0;
    background: #DF0067;
    color: #fff;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s;
}

.vp-search-btn:hover {
    background: #B80056;
}

.vp-search-btn svg {
    width: 20px;
    height: 20px;
    fill: currentColor;
}

/* Dropdown résultats */
.vp-search-results {
    position: absolute;
    top: calc(100% + 8px);
    left: 0;
    right: 0;
    background: #fff;
    border: 1px solid #e5e7eb;
    border-radius: 12px;
    box-shadow: 0 12px 32px rgba(0, 0, 0, 0.12);
    overflow: hidden;
    z-index: 1000;
    max-height: 480px;
    overflow-y: auto;
    display: none;
}

.vp-search-results.is-open {
    display: block;
}

.vp-search-header {
    padding: 10px 16px;
    background: #f8f8f8;
    border-bottom: 1px solid #f0f0f0;
    font-size: 12px;
    font-weight: 600;
    color: #6b7280;
    text-transform: uppercase;
    letter-spacing: 0.4px;
}

.vp-search-item {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 10px 16px;
    color: #1a1a1a;
    text-decoration: none;
    border-bottom: 1px solid #f5f5f5;
    transition: background 0.15s;
}

.vp-search-item:last-child {
    border-bottom: 0;
}

.vp-search-item:hover,
.vp-search-item.is-active {
    background: #f8f8f8;
}

.vp-search-item-img {
    flex: 0 0 48px;
    width: 48px;
    height: 48px;
    border-radius: 8px;
    background: #f5f5f5;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
}

.vp-search-item-img img {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
}

.vp-search-item-img.is-empty::before {
    content: '';
    display: block;
    width: 24px;
    height: 24px;
    background: #e5e7eb;
    border-radius: 4px;
}

.vp-search-item-info {
    flex: 1;
    min-width: 0;
}

.vp-search-item-name {
    font-size: 14px;
    font-weight: 500;
    color: #1a1a1a;
    line-height: 1.3;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.vp-search-item-price {
    font-size: 14px;
    font-weight: 700;
    color: #DF0067;
    margin-top: 2px;
}

.vp-search-more {
    display: block;
    padding: 12px 16px;
    text-align: center;
    font-size: 13px;
    font-weight: 600;
    color: #DF0067;
    text-decoration: none;
    background: #f8f8f8;
    border-top: 1px solid #f0f0f0;
    transition: background 0.15s;
}

.vp-search-more:hover {
    background: #FCE4EF;
    color: #B80056;
}

.vp-search-empty {
    padding: 24px 16px;
    text-align: center;
    color: #6b7280;
    font-size: 14px;
}

.vp-search-loading {
    padding: 24px 16px;
    text-align: center;
    color: #9ca3af;
    font-size: 13px;
}

/* Masquer l'ancienne UI de ps_searchbar si visible */
.search-widget .ui-autocomplete {
    display: none !important;
}

/* Responsive */
@media (max-width: 767px) {
    .vp-search-input {
        height: 44px;
        font-size: 16px; /* évite le zoom iOS */
        padding: 0 48px 0 18px;
    }

    .vp-search-btn {
        width: 36px;
        height: 36px;
    }

    .vp-search-item-img {
        flex: 0 0 40px;
        width: 40px;
        height: 40px;
    }

    .vp-search-results {
        max-height: 360px;
    }
}

/* Override z-index pour passer au-dessus des modules à z-index élevé (megamenu Pro: 9995) */
.vp-search { position: relative; z-index: 10001; }
.vp-search-results { z-index: 10002 !important; }
