/**
 * City Search Pro - Frontend Styles (Aggiornato con Dropdown Dinamico)
 */

/* Header e titolo principale */
.csp-search-container .csp-search-header {
    text-align: center;
    margin-bottom: 40px;
}

.csp-search-title{
    margin: 30px 0;
}

/* Container principale */
.csp-search-container {
    position: relative; /* IMPORTANTE: per il posizionamento del dropdown */
    margin: 30px 0;
    margin-top: 50px;
    max-width: 100%;
    padding: 0 15px;
}

/* Form di ricerca */
.csp-search-form {
    margin-bottom: 30px;
}

.csp-search-wrapper {
    display: flex;
    gap: 15px;
    margin-bottom: 15px;
}

.csp-city-input {
    flex: 1;
    padding: 15px 18px;
    border: 2px solid #ddd;
    border-radius: 5px;
    font-size: 16px;
    transition: border-color 0.3s ease;
}

.csp-city-input:focus {
    outline: none;
    border-color: #0073aa;
    box-shadow: 0 0 0 3px rgba(0, 115, 170, 0.1);
}

.csp-search-button {
    padding: 15px 30px;
    background: #0073aa;
    color: white;
    border: none;
    border-radius: 5px;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    gap: 8px;
}

.csp-search-button:hover {
    background: #005a87;
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(0, 115, 170, 0.3);
}

.csp-search-button:disabled {
    background: #ccc;
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
}

.csp-loading-spinner {
    animation: spin 1s linear infinite;
}

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

/* ==========================================
   STILI DROPDOWN AUTOCOMPLETE MIGLIORATI
   ========================================== */

/* Widget autocomplete jQuery UI personalizzato */
.csp-autocomplete-widget {
    background: white !important;
    border: 1px solid #ddd !important;
    border-radius: 8px !important;
    box-shadow: 0 8px 25px rgba(0, 0, 0, 0.15) !important;
    padding: 0 !important;
    margin: 0 !important;
    font-family: inherit !important;
    z-index: 9999 !important;
    max-height: 300px;
    overflow-y: auto;
    overflow-x: hidden;
}

/* Override degli stili jQuery UI di default */
.ui-autocomplete {
    border: 1px solid #ddd !important;
    border-radius: 8px !important;
    box-shadow: 0 8px 25px rgba(0, 0, 0, 0.15) !important;
    padding: 5px 0 !important;
    font-family: inherit !important;
    z-index: 9999 !important;
    max-width: none !important;
}

/* Elementi del menu autocomplete */
.ui-menu-item {
    margin: 0 !important;
    padding: 0 !important;
    border: none !important;
    background: none !important;
}

.ui-menu-item-wrapper {
    padding: 12px 20px !important;
    margin: 0 5px !important;
    border-radius: 6px !important;
    cursor: pointer !important;
    transition: all 0.2s ease !important;
    border: none !important;
    font-size: 15px !important;
    color: #333 !important;
    display: block !important;
    position: relative !important;
}

/* Stati hover e focus */
.ui-menu-item-wrapper:hover,
.ui-state-active,
.ui-state-focus {
    background: #f8f9ff !important;
    color: #FF6000 !important;
    border: none !important;
    transform: translateX(3px) !important;
    box-shadow: inset 4px 0 0 #FF6000 !important;
}

/* Rimuovi outline di default */
.ui-menu-item-wrapper:focus {
    outline: none !important;
}

/* Stile per quando non ci sono risultati */
.ui-autocomplete:empty::before {
    content: "Nessun risultato trovato";
    display: block;
    padding: 15px 20px;
    color: #999;
    font-style: italic;
    text-align: center;
}

/* Scrollbar personalizzata per il dropdown */
.ui-autocomplete::-webkit-scrollbar {
    width: 6px;
}

.ui-autocomplete::-webkit-scrollbar-track {
    background: #f1f1f1;
    border-radius: 3px;
}

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

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

/* Firefox scrollbar */
.ui-autocomplete {
    scrollbar-width: thin;
    scrollbar-color: #c1c1c1 #f1f1f1;
}

/* Indicatore di caricamento per autocomplete */
.csp-city-input.csp-loading {
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='20' height='20' viewBox='0 0 20 20'%3E%3Cpath fill='%23999' d='M10 3.5a6.5 6.5 0 100 13 6.5 6.5 0 000-13zm0-1.5a8 8 0 110 16 8 8 0 010-16z' opacity='0.4'/%3E%3Cpath fill='%23666' d='M10 2a8 8 0 018 8h-2a6 6 0 00-6-6V2z'%3E%3CanimateTransform attributeName='transform' type='rotate' values='0 10 10;360 10 10' dur='1s' repeatCount='indefinite'/%3E%3C/path%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 15px center;
    background-size: 20px 20px;
}

/* ==========================================
   STILI ORIGINALI MANTENUTI
   ========================================== */

/* Contatore città */
.csp-city-count {
    text-align: center;
    color: #666;
    font-size: 14px;
    margin-top: 15px;
    margin-bottom: 10px;
}

/* Risultati ricerca */
.csp-search-results {
    margin-top: 30px;
}

.csp-city-result {
    background: #f9f9f9;
    border: 1px solid #e5e5e5;
    border-radius: 8px;
    padding: 25px;
    margin-bottom: 25px;
    animation: fadeIn 0.5s ease;
}

.csp-city-result:last-child {
    margin-bottom: 0;
}

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

.csp-city-header {
    margin-bottom: 20px;
}

.csp-city-name {
    font-size: 24px;
    margin: 0 0 15px 0;
    color: #333;
    display: flex;
    align-items: center;
    gap: 15px;
    flex-wrap: wrap;
}

.csp-status {
    font-size: 14px;
    padding: 6px 15px;
    border-radius: 20px;
    font-weight: normal;
}

.csp-status-partnered {
    background: #d4edda;
    color: #155724;
    border: 1px solid #c3e6cb;
}

.csp-status-not-partnered {
    background: #fff3cd;
    color: #856404;
    border: 1px solid #ffeaa7;
}

.csp-city-description {
    color: #666;
    line-height: 1.6;
    margin-top: 15px;
}

/* Contenuto città convenzionata */
.csp-partnered-content {
    text-align: center;
    padding: 25px;
}

.csp-success-message {
    color: #155724;
    background: #d4edda;
    border: 1px solid #c3e6cb;
    padding: 18px;
    border-radius: 5px;
    margin-bottom: 25px;
}

.csp-download-section {
    margin-top: 25px;
}



/* Contenuto città non convenzionata */
.csp-not-partnered-content {
    padding: 25px;
}

.csp-info-message {
    color: #856404;
    background: #fff3cd;
    border: 1px solid #ffeaa7;
    padding: 18px;
    border-radius: 5px;
    margin-bottom: 25px;
}

/* Form iscrizione */
.csp-subscription-form {
    background: white;
    border: 1px solid #e5e5e5;
    border-radius: 8px;
    padding: 30px;
    margin-top: 25px;
}

.csp-subscription-form h4 {
    margin: 0 0 15px 0;
    color: #333;
    font-size: 20px;
}

.csp-email-wrapper {
    display: flex;
    gap: 15px;
    margin: 20px 0;
}

.csp-email-input {
    flex: 1;
    padding: 15px 18px;
    border: 2px solid #ddd;
    border-radius: 5px;
    font-size: 16px;
    transition: border-color 0.3s ease;
}

.csp-email-input:focus {
    outline: none;
    border-color: #0073aa;
    box-shadow: 0 0 0 3px rgba(0, 115, 170, 0.1);
}

.csp-subscribe-button {
    padding: 15px 30px;
    background: #0073aa;
    color: white;
    border: none;
    border-radius: 5px;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    white-space: nowrap;
}

.csp-subscribe-button:hover {
    background: #005a87;
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(0, 115, 170, 0.3);
}

.csp-privacy-note {
    color: #666;
    font-size: 12px;
    line-height: 1.4;
    margin-top: 15px;
}

/* Messaggi di feedback */
.csp-subscribe-results {
    margin-top: 20px;
}

.csp-success,
.csp-error,
.csp-loading {
    padding: 15px;
    border-radius: 5px;
    margin-top: 15px;
}

.csp-success {
    background: #d4edda;
    color: #155724;
    border: 1px solid #c3e6cb;
}

.csp-error {
    background: #f8d7da;
    color: #721c24;
    border: 1px solid #f5c6cb;
}

.csp-loading {
    background: #cfe2ff;
    color: #084298;
    border: 1px solid #b6d4fe;
    text-align: center;
}

/* Temi alternativi */
.csp-theme-modern {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}

.csp-theme-modern .csp-search-button,
.csp-theme-modern .csp-subscribe-button {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    border-radius: 25px;
}

.csp-theme-modern .csp-city-input,
.csp-theme-modern .csp-email-input {
    border-radius: 25px;
    border: 1px solid #e0e0e0;
    background: #f8f8f8;
}

.csp-theme-modern .ui-autocomplete {
    border-radius: 15px !important;
}

/* Responsive */
@media (max-width: 768px) {
    .csp-search-container {
        padding: 0 5px;
    }
    
    .csp-search-wrapper,
    .csp-email-wrapper {
        flex-direction: column;
        gap: 12px;
    }
    
    .csp-search-button,
    .csp-subscribe-button {
        width: 100%;
        justify-content: center;
    }
    
    .csp-city-name {
        font-size: 20px;
    }
    
    .csp-city-result {
        padding: 20px;
        margin-bottom: 20px;
    }
    
    .csp-subscription-form {
        padding: 15px;
    }
    
    /* Dropdown responsive */
    .ui-autocomplete {
        left: 10px !important;
        right: 10px !important;
        width: auto !important;
        max-width: calc(100vw - 20px) !important;
    }
}

@media (max-width: 480px) {
    .csp-search-container {
        margin: 20px 0;
    }
    
    .csp-city-name {
        font-size: 18px;
    }
    

    
    .csp-city-result {
        padding: 15px;
        margin-bottom: 15px;
    }
    
    /* Menu autocomplete più compatto su mobile */
    .ui-menu-item-wrapper {
        padding: 10px 15px !important;
        font-size: 14px !important;
    }
}