/**
 * ⚡ LIVE SEARCH WIDGET - Autocomplete Navbar
 * 
 * Quick search con dropdown live results
 * Da integrare nella navbar del template
 * 
 * @author axpdev.it
 */

/* =====================================================
   LIVE SEARCH CONTAINER
   ===================================================== */
.live-search-wrapper {
    position: relative;
    min-width: 250px;
}

.live-search-input {
    border-radius: 20px;
    padding: 8px 40px 8px 16px;
    border: 1px solid var(--search-input-border, #dfe1e5);
    font-size: var(--search-font-size-14px, 14px);
    transition: all 0.3s ease;
    background-color: var(--search-input-bg-alpha, rgba(255,255,255,0.9));
}

.live-search-input:focus {
    outline: none;
    border-color: var(--epc-primary, var(--search-widget-color, var(--primary-color)));
    box-shadow: 0 2px 8px var(--search-widget-shadow, rgba(230, 103, 42, 0.2));
    background-color: var(--search-input-bg, white);
}

.live-search-icon {
    position: absolute;
    right: 14px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--search-icon-color, #5f6368);
    pointer-events: none;
}

/* =====================================================
   DROPDOWN RESULTS
   ===================================================== */
.live-search-dropdown {
    position: absolute;
    top: calc(100% + 8px);
    left: 0;
    right: 0;
    background: var(--search-input-bg, white);
    border-radius: 12px;
    box-shadow: 0 8px 32px var(--search-shadow, rgba(0,0,0,0.12));
    max-height: 400px;
    overflow-y: auto;
    z-index: 1050;
    display: none;
    animation: dropdownSlideIn 0.3s ease;
}

.live-search-dropdown.show {
    display: block;
}

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

/* =====================================================
   QUICK RESULT ITEMS
   ===================================================== */
.live-search-item {
    padding: 12px 16px;
    display: flex;
    align-items: center;
    gap: 12px;
    text-decoration: none;
    color: inherit;
    border-bottom: 1px solid var(--search-border-light, #f1f3f4);
    transition: background-color 0.2s;
}

.live-search-item:hover {
    background-color: var(--search-bg-hover, #f8f9fa);
}

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

.live-search-thumb {
    width: 48px;
    height: 48px;
    object-fit: cover;
    border-radius: 6px;
    flex-shrink: 0;
}

.live-search-content {
    flex: 1;
    min-width: 0;
}

.live-search-title {
    font-size: var(--search-font-size-14px, 14px);
    font-weight: var(--search-font-weight-600, 600);
    color: var(--search-text-color, #202124);
    margin: 0;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.live-search-type {
    font-size: var(--search-font-size-11px, 11px);
    color: var(--search-text-muted, #5f6368);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

/* Evidenzia termine */
.live-search-title strong {
    color: var(--epc-primary, var(--search-widget-color, var(--primary-color)));
    font-weight: var(--search-font-weight-700, 700);
}

/* =====================================================
   FOOTER LINK
   ===================================================== */
.live-search-footer {
    padding: 12px 16px;
    text-align: center;
    background-color: var(--search-bg-footer, #f8f9fa);
    border-radius: 0 0 12px 12px;
}

.live-search-footer a {
    color: var(--epc-primary, var(--search-widget-color, var(--primary-color)));
    font-size: var(--search-font-size-13px, 13px);
    font-weight: var(--search-font-weight-600, 600);
    text-decoration: none;
}

.live-search-footer a:hover {
    text-decoration: underline;
}

/* =====================================================
   LOADING STATE
   ===================================================== */
.live-search-loading {
    padding: 20px;
    text-align: center;
    color: var(--search-text-muted, #5f6368);
}

.live-search-spinner {
    width: 20px;
    height: 20px;
    border: 2px solid #f3f3f3;
    border-top: 2px solid var(--epc-primary, var(--search-widget-color, var(--primary-color)));
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
    display: inline-block;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* =====================================================
   EMPTY STATE
   ===================================================== */
.live-search-empty {
    padding: 20px;
    text-align: center;
    color: var(--search-text-muted, #5f6368);
    font-size: var(--search-font-size-13px, 13px);
}

/* =====================================================
   RESPONSIVE
   ===================================================== */
@media (max-width: 768px) {
    .live-search-wrapper {
        min-width: 200px;
    }
    
    .live-search-dropdown {
        left: -50%;
        right: -50%;
        max-width: 90vw;
    }
}

@media (max-width: 576px) {
    .live-search-wrapper {
        width: 100%;
        min-width: auto;
    }
    
    .live-search-dropdown {
        left: 0;
        right: 0;
        max-width: 100%;
    }
}

/* =====================================================
   DARK MODE
   ===================================================== */
@media (prefers-color-scheme: dark) {
    .live-search-input {
        background-color: rgba(48, 49, 52, 0.9);
        border-color: #5f6368;
        color: #e8eaed;
    }
    
    .live-search-input:focus {
        background-color: #303134;
    }
    
    .live-search-dropdown {
        background-color: #303134;
    }
    
    .live-search-item {
        border-color: #3c4043;
    }
    
    .live-search-item:hover {
        background-color: #3c4043;
    }
    
    .live-search-title {
        color: #e8eaed;
    }
    
    .live-search-footer {
        background-color: #3c4043;
    }
}
