/**
 * SEARCH AUTOCOMPLETE BETA - CSS
 * Stili per dropdown autocomplete search bar
 * Solo per utenti beta (ID 20 e 67)
 * Version: 1.0
 */

/* ============================================
   CONTAINER AUTOCOMPLETE
   ============================================ */
.ui-autocomplete {
    position: absolute;
    top: 100%;
    left: 0;
    z-index: 99999 !important;
    display: block !important;  /* SEMPRE VISIBILE quando creato */
    float: left;
    min-width: 600px;  /* Aumentato da 100% */
    max-width: 800px;  /* Aumentato da 500px */
    width: auto;
    padding: 0;
    margin: 2px 0 0;
    list-style: none;
    font-size: 14px;
    text-align: left;
    background-color: #fff;
    border: 1px solid #e0e0e0;
    border-radius: 6px;
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.15);
    background-clip: padding-box;
    max-height: 450px;
    overflow-y: auto;
}

/* ============================================
   SINGOLO ITEM AUTOCOMPLETE
   ============================================ */
.ui-autocomplete .ui-menu-item {
    display: block;
    padding: 0;
    margin: 0;
    border-bottom: 1px solid #f5f5f5;
}

.ui-autocomplete .ui-menu-item:last-child {
    border-bottom: none;
}

.ui-autocomplete .ui-menu-item-wrapper {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    padding: 12px 16px;
    cursor: pointer;
    text-decoration: none;
    transition: all 0.2s ease;
    color: #333;
    gap: 12px;
}

/* Hover state */
.ui-autocomplete .ui-menu-item-wrapper:hover,
.ui-autocomplete .ui-menu-item-wrapper.ui-state-active {
    background-color: #fff8e6;
    border-left: 3px solid #f3bb27;
    padding-left: 13px;
}

/* ============================================
   CONTENUTO ITEM
   ============================================ */
.autocomplete-item-content {
    flex: 1;
    min-width: 0;
}

.autocomplete-item-title {
    font-size: 14px;
    font-weight: 600;
    color: #1a1a1a;
    margin: 0 0 4px 0;
    line-height: 1.3;
    white-space: nowrap;  /* Impedisce a capo */
    overflow: hidden;
    text-overflow: ellipsis;  /* Mostra ... se troppo lungo */
}

.autocomplete-item-meta {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
    margin-top: 4px;
}

.autocomplete-item-code {
    font-size: 12px;
    color: #666;
    font-family: 'Courier New', monospace;
    background: #f5f5f5;
    padding: 2px 6px;
    border-radius: 3px;
}

.autocomplete-item-brand {
    font-size: 12px;
    color: #f3bb27;
    font-weight: 600;
}

/* ============================================
   BADGE DISPONIBILITÀ
   ============================================ */
.autocomplete-item-badge {
    font-size: 11px;
    padding: 3px 8px;
    border-radius: 12px;
    font-weight: 600;
    white-space: nowrap;
    align-self: flex-start;
    margin-top: 2px;
}

.autocomplete-item-badge.disponibile {
    background: #e8f5e9;
    color: #2e7d32;
}

.autocomplete-item-badge.esaurito {
    background: #ffebee;
    color: #c62828;
}

.autocomplete-item-badge.preordine {
    background: #f3e5f5;
    color: #6a1b9a;
}

/* ============================================
   PREZZO
   ============================================ */
.autocomplete-item-price {
    font-size: 15px;
    font-weight: 700;
    color: #1a1a1a;
    white-space: nowrap;
    align-self: flex-start;
    margin-top: 2px;
}

/* ============================================
   CATEGORIE (Separatori)
   ============================================ */
.ui-autocomplete .ui-autocomplete-category {
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    color: #999;
    padding: 8px 16px 6px 16px;
    background: #fafafa;
    border-bottom: 1px solid #e0e0e0;
    margin: 0;
    letter-spacing: 0.5px;
    cursor: default;
}

.ui-autocomplete .ui-autocomplete-category:first-child {
    border-top-left-radius: 6px;
    border-top-right-radius: 6px;
}

/* ============================================
   ITEM TIPO MARCA
   ============================================ */
.autocomplete-item-marca {
    display: flex;
    align-items: center;
    gap: 8px;
}

.autocomplete-item-marca-icon {
    font-size: 20px;
}

.autocomplete-item-marca-name {
    font-size: 14px;
    font-weight: 600;
    color: #1a1a1a;
}

.autocomplete-item-marca-count {
    font-size: 12px;
    color: #666;
}

/* ============================================
   ITEM RICERCA COMPLETA (fallback)
   ============================================ */
.autocomplete-item-search {
    display: flex;
    align-items: center;
    gap: 10px;
}

.autocomplete-item-search-icon {
    font-size: 18px;
    color: #f3bb27;
}

.autocomplete-item-search-text {
    font-size: 13px;
    color: #666;
    font-style: italic;
}

/* ============================================
   LOADING STATE
   ============================================ */
.ui-autocomplete.loading::before {
    content: '';
    display: block;
    width: 100%;
    height: 3px;
    background: linear-gradient(90deg, transparent, #f3bb27, transparent);
    background-size: 200% 100%;
    animation: loading 1.5s infinite;
    position: sticky;
    top: 0;
    z-index: 1;
}

@keyframes loading {
    0% {
        background-position: 200% 0;
    }
    100% {
        background-position: -200% 0;
    }
}

/* ============================================
   SCROLLBAR CUSTOM
   ============================================ */
.ui-autocomplete::-webkit-scrollbar {
    width: 8px;
}

.ui-autocomplete::-webkit-scrollbar-track {
    background: #f5f5f5;
    border-radius: 0 6px 6px 0;
}

.ui-autocomplete::-webkit-scrollbar-thumb {
    background: #ccc;
    border-radius: 4px;
}

.ui-autocomplete::-webkit-scrollbar-thumb:hover {
    background: #999;
}

/* ============================================
   RESPONSIVE
   ============================================ */
@media (max-width: 768px) {
    .ui-autocomplete {
        max-width: calc(100vw - 40px);
        font-size: 13px;
    }

    .ui-autocomplete .ui-menu-item-wrapper {
        padding: 10px 12px;
        flex-direction: column;
        align-items: flex-start;
        gap: 8px;
    }

    .autocomplete-item-title {
        font-size: 13px;
    }

    .autocomplete-item-price {
        font-size: 14px;
        align-self: flex-end;
        margin-top: -20px;
    }

    .autocomplete-item-badge {
        font-size: 10px;
        padding: 2px 6px;
    }
}

/* ============================================
   FOCUS INPUT SEARCH
   ============================================ */
.bz-bottom-middle-form-2 input#chiave:focus {
    outline: none;
    border-color: #f3bb27;
    box-shadow: 0 0 0 3px rgba(243, 187, 39, 0.1);
}

/* ============================================
   HELPER CLASS - Evidenzia match
   ============================================ */
.autocomplete-match {
    font-weight: 700;
    color: #f3bb27;
    background: rgba(243, 187, 39, 0.1);
    padding: 0 2px;
    border-radius: 2px;
}

/* ============================================
   BADGE NOVITÀ E SCONTO - Aggiunti
   ============================================ */
.autocomplete-item-badge.novita {
    background: #fff3e0;
    color: #e65100;
    font-weight: 700;
}

.autocomplete-item-badge.sconto {
    background: #fff9c4;
    color: #f57f17;
    font-weight: 700;
}
