/**
 * ADDRESS SUGGESTIONS DROPDOWN - Mobile & Desktop
 * Versione: 2.0.0 - AGGRESSIVE OVERRIDE
 *
 * Rimuove il backdrop fuorviante e trasforma i suggerimenti in un dropdown
 * pulito che appare sotto il campo di ricerca su tutti i dispositivi
 */

/* ===================================
   OVERRIDE AGGRESSIVO: RIMUOVI BACKDROP MODALE
   Questi stili devono sovrascrivere address-hero-mobile.css
   =================================== */

/* RIMUOVI COMPLETAMENTE IL BACKDROP SU TUTTI I DISPOSITIVI */
.suggestions-backdrop,
#suggestions-backdrop {
    display: none !important;
    opacity: 0 !important;
    visibility: hidden !important;
    pointer-events: none !important;
    width: 0 !important;
    height: 0 !important;
    background: transparent !important;
    backdrop-filter: none !important;
    -webkit-backdrop-filter: none !important;
}

/* OVERLAY NON È PIÙ FIXED - È ABSOLUTE */
.suggestions-overlay,
#suggestions-overlay {
    position: absolute !important;
    top: 100% !important;
    left: 0 !important;
    right: 0 !important;
    bottom: auto !important;
    margin-top: 0.5rem !important;
    z-index: 1050 !important;
    padding: 0 !important;
    padding-top: 0 !important;
    background: transparent !important;
    backdrop-filter: none !important;
    -webkit-backdrop-filter: none !important;
}

/* PANEL COME DROPDOWN SOTTO L'INPUT */
.suggestions-panel,
#address-suggestions {
    position: relative !important;
    top: auto !important;
    left: auto !important;
    right: auto !important;
    bottom: auto !important;
    transform: none !important;
    z-index: 1051 !important;
    background: #ffffff !important;
    border-radius: 12px !important;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.15) !important;
    max-height: 60vh !important;
    overflow-y: auto !important;
    margin: 0 !important;
    border: 1px solid rgba(0, 0, 0, 0.1) !important;
}

/* Container principale RELATIVO */
.unified-input-field,
.address-input-wrapper,
.address-input-hero,
.hero-input-wrapper {
    position: relative !important;
}

/* BODY NON SI BLOCCA PIÙ */
body.overlay-active {
    overflow: auto !important;
    position: static !important;
    height: auto !important;
}

/* ===================================
   DROPDOWN PULITO - TUTTI I DISPOSITIVI
   =================================== */

/* Container suggerimenti con animazione fluida */
.suggestions-overlay {
    transition: opacity 0.2s ease, transform 0.2s ease !important;
    opacity: 0;
    transform: translateY(-8px);
    pointer-events: none;
}

.suggestions-overlay.active {
    opacity: 1 !important;
    transform: translateY(0) !important;
    pointer-events: auto !important;
}

/* Panel suggerimenti ottimizzato */
.suggestions-panel {
    background: white;
    border-radius: 12px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.12);
    border: 1px solid rgba(0, 0, 0, 0.08);
    overflow: hidden;
}

/* ===================================
   SUGGESTION ITEMS - MIGLIORATI
   =================================== */

.suggestion-item {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 1rem;
    cursor: pointer;
    transition: all 0.15s ease;
    border-bottom: 1px solid rgba(0, 0, 0, 0.05);
    background: white;
}

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

.suggestion-item:hover,
.suggestion-item:focus,
.suggestion-item.keyboard-active {
    background: linear-gradient(135deg, #f8f9fa 0%, #e9ecef 100%);
    border-left: 3px solid #3b82f6;
    padding-left: calc(1rem - 3px);
}

.suggestion-item:active {
    transform: scale(0.98);
    background: #e9ecef;
}

/* Icona suggerimento */
.suggestion-icon {
    flex-shrink: 0;
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, #3b82f6 0%, #2563eb 100%);
    border-radius: 10px;
    color: white;
    font-size: 1.1rem;
}

.suggestion-item:hover .suggestion-icon,
.suggestion-item.keyboard-active .suggestion-icon {
    transform: scale(1.1);
    box-shadow: 0 4px 12px rgba(59, 130, 246, 0.3);
}

/* Contenuto suggerimento */
.suggestion-content {
    flex: 1;
    min-width: 0;
    line-height: 1.4;
}

.suggestion-primary {
    font-size: 0.95rem;
    font-weight: 600;
    color: #1e293b;
    margin-bottom: 0.25rem;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.suggestion-secondary {
    font-size: 0.8rem;
    color: #64748b;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* Highlight della query */
.highlight {
    background: rgba(59, 130, 246, 0.15);
    color: #2563eb;
    font-weight: 700;
    padding: 0 2px;
    border-radius: 2px;
}

/* ===================================
   NO RESULTS STATE
   =================================== */

.no-results {
    text-align: center;
    padding: 2rem 1.5rem;
    color: #64748b;
}

.no-results i {
    font-size: 2.5rem;
    margin-bottom: 1rem;
    color: #cbd5e1;
}

.no-results p {
    font-size: 0.95rem;
    margin: 0;
    line-height: 1.5;
}

/* ===================================
   LOADING STATE
   =================================== */

.loading-state {
    padding: 2rem;
    text-align: center;
}

.loading-spinner {
    width: 40px;
    height: 40px;
    border: 4px solid #e9ecef;
    border-top-color: #3b82f6;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
    margin: 0 auto 1rem;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* ===================================
   SCROLLBAR PERSONALIZZATA
   =================================== */

.suggestions-panel::-webkit-scrollbar {
    width: 8px;
}

.suggestions-panel::-webkit-scrollbar-track {
    background: #f1f5f9;
    border-radius: 0 12px 12px 0;
}

.suggestions-panel::-webkit-scrollbar-thumb {
    background: #cbd5e1;
    border-radius: 4px;
}

.suggestions-panel::-webkit-scrollbar-thumb:hover {
    background: #94a3b8;
}

/* ===================================
   RESPONSIVE: SMALL MOBILE
   =================================== */

@media (max-width: 375px) {
    .suggestions-panel {
        max-height: 50vh !important;
    }

    .suggestion-item {
        padding: 0.875rem;
        gap: 0.625rem;
    }

    .suggestion-icon {
        width: 36px;
        height: 36px;
        font-size: 1rem;
    }

    .suggestion-primary {
        font-size: 0.9rem;
    }

    .suggestion-secondary {
        font-size: 0.75rem;
    }
}

/* ===================================
   RESPONSIVE: TABLET & DESKTOP
   =================================== */

@media (min-width: 769px) {
    /* Desktop mantiene dropdown pulito */
    .suggestions-overlay {
        position: absolute !important;
        top: calc(100% + 0.5rem) !important;
        left: 0 !important;
        right: 0 !important;
        z-index: 1050 !important;
    }

    .suggestions-panel {
        max-height: 400px !important;
        border-radius: 12px !important;
    }

    .suggestion-item {
        padding: 0.875rem 1rem;
    }

    /* Hover effects più pronunciati su desktop */
    .suggestion-item:hover {
        box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
    }
}

/* ===================================
   ACCESSIBILITY
   =================================== */

/* Focus visibile per navigazione tastiera */
.suggestion-item:focus-visible {
    outline: 3px solid #3b82f6;
    outline-offset: -3px;
    z-index: 1;
}

/* Reduced motion support */
@media (prefers-reduced-motion: reduce) {
    .suggestions-overlay,
    .suggestion-item,
    .suggestion-icon {
        transition: none !important;
        animation: none !important;
    }
}

/* High contrast mode */
@media (prefers-contrast: high) {
    .suggestion-item {
        border: 2px solid currentColor;
    }

    .suggestion-item:hover,
    .suggestion-item:focus {
        background: #000;
        color: #fff;
    }
}

/* ===================================
   DARK MODE SUPPORT
   =================================== */

@media (prefers-color-scheme: dark) {
    .suggestions-panel {
        background: #1e293b !important;
        border-color: #334155 !important;
        box-shadow: 0 8px 32px rgba(0, 0, 0, 0.5) !important;
    }

    .suggestion-item {
        background: #1e293b;
        border-bottom-color: #334155;
    }

    .suggestion-item:hover,
    .suggestion-item:focus,
    .suggestion-item.keyboard-active {
        background: linear-gradient(135deg, #334155 0%, #475569 100%);
    }

    .suggestion-primary {
        color: #f1f5f9;
    }

    .suggestion-secondary {
        color: #94a3b8;
    }

    .no-results {
        color: #94a3b8;
    }

    .no-results i {
        color: #475569;
    }
}

/* ===================================
   Z-INDEX MANAGEMENT
   =================================== */

/* Assicura che il dropdown sia sopra altri elementi ma sotto modali */
.suggestions-overlay {
    z-index: 1050 !important;
}

.suggestions-panel {
    z-index: 1051 !important;
}

/* Se c'è un header fisso, il dropdown deve essere sotto */
body.has-fixed-header .suggestions-overlay {
    z-index: 1040 !important;
}

/* ===================================
   DRAG HANDLE RIMOSSO (non necessario)
   =================================== */

.drag-handle {
    display: none !important;
}

/* ===================================
   BODY LOCK RIMOSSO (non serve più)
   =================================== */

body.overlay-active {
    overflow: auto !important;
    position: static !important;
}

/* ===================================
   ANIMATION ENTRANCE
   =================================== */

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

.suggestions-overlay.active .suggestions-panel {
    animation: slideDown 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

/* ===================================
   ERROR STATE
   =================================== */

.error-suggestion {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 1rem;
    background: #fef2f2;
    border-left: 4px solid #ef4444;
    margin: 0.5rem;
    border-radius: 8px;
    font-size: 0.9rem;
    color: #991b1b;
}

.error-suggestion i {
    color: #ef4444;
    font-size: 1.25rem;
}

/* ===================================
   SKELETON LOADING
   =================================== */

.suggestion-skeleton {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 1rem;
    border-bottom: 1px solid rgba(0, 0, 0, 0.05);
}

.skeleton-icon {
    width: 40px;
    height: 40px;
    background: linear-gradient(90deg, #f1f5f9 0%, #e2e8f0 50%, #f1f5f9 100%);
    background-size: 200% 100%;
    border-radius: 10px;
    animation: shimmer 1.5s ease-in-out infinite;
}

.skeleton-text {
    flex: 1;
}

.skeleton-line {
    height: 12px;
    background: linear-gradient(90deg, #f1f5f9 0%, #e2e8f0 50%, #f1f5f9 100%);
    background-size: 200% 100%;
    border-radius: 6px;
    animation: shimmer 1.5s ease-in-out infinite;
    margin-bottom: 0.5rem;
}

.skeleton-line:last-child {
    width: 70%;
    margin-bottom: 0;
}

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