/* ===================================
   AUTOCOMPLETE COMUNI - STYLES
   =================================== */

/* Container suggerimenti */
.comuni-suggestions {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: white;
    border: 1px solid #ddd;
    border-top: none;
    border-radius: 0 0 4px 4px;
    box-shadow: 0 4px 6px rgba(0,0,0,0.1);
    max-height: 300px;
    overflow-y: auto;
    z-index: 1000;
    display: none;
}

/* Singolo suggerimento */
.suggestion-item {
    padding: 12px 15px;
    cursor: pointer;
    border-bottom: 1px solid #f0f0f0;
    transition: background-color 0.2s;
}

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

.suggestion-item:hover,
.suggestion-item.active {
    background-color: #f0f7ff;
}

.suggestion-item strong {
    display: block;
    color: #333;
    font-size: 14px;
    margin-bottom: 3px;
}

.suggestion-meta {
    display: block;
    color: #666;
    font-size: 12px;
}

/* Stati speciali */
.suggestion-loading,
.suggestion-empty,
.suggestion-error {
    padding: 12px 15px;
    text-align: center;
    color: #666;
    font-size: 13px;
}

.suggestion-loading::before {
    content: "⏳ ";
}

.suggestion-empty::before {
    content: "🔍 ";
}

.suggestion-error {
    color: #dc3545;
}

.suggestion-error::before {
    content: "⚠️ ";
}

/* Input con autocomplete attivo */
.form-group {
    position: relative;
}

input.autocomplete-active {
    border-bottom-left-radius: 0;
    border-bottom-right-radius: 0;
}

/* Scrollbar personalizzata per i suggerimenti */
.comuni-suggestions::-webkit-scrollbar {
    width: 8px;
}

.comuni-suggestions::-webkit-scrollbar-track {
    background: #f1f1f1;
}

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

.comuni-suggestions::-webkit-scrollbar-thumb:hover {
    background: #555;
}

/* Stile per provincia auto-compilata */
input.auto-filled {
    background-color: #f0f7ff;
    border-color: #0066cc;
}

/* Rimuovo lo stile per readonly perché ora il CAP resta editabile */
select.form-control[name*="cap"] {
    background-image: url('data:image/svg+xml;charset=US-ASCII,%3Csvg%20xmlns%3D%22http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%22%20width%3D%22292.4%22%20height%3D%22292.4%22%3E%3Cpath%20fill%3D%22%23666%22%20d%3D%22M287%2069.4a17.6%2017.6%200%200%200-13-5.4H18.4c-5%200-9.3%201.8-12.9%205.4A17.6%2017.6%200%200%200%200%2082.2c0%205%201.8%209.3%205.4%2012.9l128%20127.9c3.6%203.6%207.8%205.4%2012.8%205.4s9.2-1.8%2012.8-5.4L287%2095c3.5-3.5%205.4-7.8%205.4-12.8%200-5-1.9-9.2-5.5-12.8z%22%2F%3E%3C%2Fsvg%3E');
    background-repeat: no-repeat;
    background-position: right 10px center;
    background-size: 12px;
    padding-right: 30px;
}

/* Responsive */
@media (max-width: 768px) {
    .comuni-suggestions {
        max-height: 200px;
    }
    
    .suggestion-item {
        padding: 10px 12px;
    }
    
    .suggestion-item strong {
        font-size: 13px;
    }
    
    .suggestion-meta {
        font-size: 11px;
    }
}

/* Animazione apertura suggerimenti */
@keyframes slideDown {
    from {
        opacity: 0;
        transform: translateY(-10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.comuni-suggestions {
    animation: slideDown 0.2s ease-out;
}

/* Evidenziazione testo che matcha */
.suggestion-item .highlight {
    background-color: #ffffcc;
    font-weight: bold;
}

/* Loading inline nel campo input */
.input-with-loading {
    position: relative;
}

.input-with-loading::after {
    content: "";
    position: absolute;
    right: 10px;
    top: 50%;
    transform: translateY(-50%);
    width: 16px;
    height: 16px;
    border: 2px solid #f3f3f3;
    border-top: 2px solid #0066cc;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

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

/* Stile per provincia auto-compilata */
input.auto-filled {
    background-color: #f0f7ff;
    border-color: #0066cc;
}

/* Tooltip CAP multipli */
.cap-info-tooltip {
    display: inline-block;
    margin-left: 5px;
    color: #0066cc;
    cursor: help;
    font-size: 12px;
}

.cap-info-tooltip:hover::after {
    content: attr(data-tooltip);
    position: absolute;
    background: #333;
    color: white;
    padding: 5px 10px;
    border-radius: 4px;
    font-size: 11px;
    white-space: nowrap;
    margin-left: 10px;
    z-index: 1001;
}
