/* Select Concura - Frontend Styles */

.select-concura-wrapper {
    margin: 20px 0;
    padding: 24px;
    background: #ffffff;
    border-radius: 12px;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
    border: 1px solid #e5e7eb;
}

.select-concura-field {
    margin-bottom: 20px;
}

.select-concura-field label {
    display: block;
    margin-bottom: 8px;
    font-weight: 500;
    color: #374151;
    font-size: 14px;
    line-height: 1.4;
}

/* Personalizzazioni Select2 */
.select-concura-wrapper .select2-container {
    margin-bottom: 10px;
}

.select-concura-wrapper .select2-container--default .select2-selection--single {
    height: 45px;
    border: 1px solid #d1d5db;
    border-radius: 8px;
    transition: all 0.3s ease;
    background: #ffffff;
    box-shadow: 0 1px 3px 0 rgba(0, 0, 0, 0.1);
}

.select-concura-wrapper .select2-container--default .select2-selection--single:focus,
.select-concura-wrapper .select2-container--default.select2-container--focus .select2-selection--single {
    border-color: #004b8b;
    outline: none;
    box-shadow: 0 0 0 3px rgba(0, 75, 139, 0.1), 0 1px 3px 0 rgba(0, 0, 0, 0.1);
}

.select-concura-wrapper .select2-container--default .select2-selection--single .select2-selection__rendered {
    line-height: 43px;
    padding-left: 16px;
    padding-right: 40px;
    color: #374151;
    font-size: 14px;
    font-weight: 400;
    display: flex;
    align-items: center;
    height: 43px;
}

.select-concura-wrapper .select2-container--default .select2-selection--single .select2-selection__placeholder {
    color: #9ca3af;
    font-weight: 400;
    line-height: 43px;
    display: flex;
    align-items: center;
    height: 43px;
}

.select-concura-wrapper .select2-container--default .select2-selection--single .select2-selection__arrow {
    height: 43px;
    right: 12px;
    width: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.select-concura-wrapper .select2-container--default .select2-selection--single .select2-selection__arrow b {
    border-color: #6b7280 transparent transparent transparent;
    border-style: solid;
    border-width: 6px 4px 0 4px;
    height: 0;
    left: 50%;
    margin-left: -4px;
    margin-top: 0;
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    width: 0;
}

/* Stili per la X di clear */
.select-concura-wrapper .select2-container--default .select2-selection--single .select2-selection__clear {
    position: absolute;
    right: 12px;
    top: 50%;
    transform: translateY(-50%);
    cursor: pointer;
    font-size: 18px;
    font-weight: bold;
    color: #6b7280;
    width: 20px;
    height: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    transition: all 0.2s ease;
}

.select-concura-wrapper .select2-container--default .select2-selection--single .select2-selection__clear:hover {
    color: #374151;
    background-color: #f3f4f6;
}

/* Nasconde la freccia quando c'è la X */
.select-concura-wrapper .select2-container--default .select2-selection--single:has(.select2-selection__clear) .select2-selection__arrow {
    display: none;
}

/* Fallback per browser che non supportano :has() */
.select-concura-wrapper .select2-container--default .select2-selection--single .select2-selection__clear ~ .select2-selection__arrow {
    display: none;
}

/* Stati disabilitati */
.select-concura-wrapper .select2-container--default .select2-selection--single[aria-disabled="true"] {
    background-color: #f9fafb;
    color: #9ca3af;
    border-color: #e5e7eb;
    cursor: not-allowed;
}

.select-concura-wrapper .select2-container--default .select2-selection--single[aria-disabled="true"] .select2-selection__rendered {
    color: #9ca3af;
}

.select-concura-wrapper .select2-container--default .select2-selection--single[aria-disabled="true"] .select2-selection__arrow b {
    border-color: #d1d5db transparent transparent transparent;
}

.select-concura-wrapper .select2-container--default .select2-selection--multiple {
    border: 2px solid #ddd;
    border-radius: 6px;
    min-height: 40px;
    transition: border-color 0.3s ease;
}

.select-concura-wrapper .select2-container--default.select2-container--focus .select2-selection--multiple {
    border-color: #004b8b;
    box-shadow: 0 0 0 2px rgba(0, 75, 139, 0.2);
}

.select-concura-wrapper .select2-container--default .select2-selection--multiple .select2-selection__choice {
    background-color: #004b8b;
    border: 1px solid #004b8b;
    border-radius: 4px;
    color: white;
    margin: 5px 5px 0 0;
    padding: 2px 8px;
}

.select-concura-wrapper .select2-container--default .select2-selection--multiple .select2-selection__choice__remove {
    color: rgba(255,255,255,0.8);
    margin-right: 6px;
}

.select-concura-wrapper .select2-container--default .select2-selection--multiple .select2-selection__choice__remove:hover {
    color: white;
}

/* Dropdown personalizzato */
.select2-container--default .select2-dropdown {
    border: 1px solid #d1d5db;
    border-radius: 8px;
    box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
    background: #ffffff;
    margin-top: 4px;
}

.select2-container--default .select2-results__option {
    padding: 12px 16px;
    transition: background-color 0.2s ease;
    color: #374151;
    font-size: 14px;
    line-height: 1.4;
}

.select2-container--default .select2-results__option--highlighted {
    background-color: #004b8b;
    color: white;
}

.select2-container--default .select2-results__option:hover {
    background-color: #f3f4f6;
}

.select2-container--default .select2-results__option--highlighted:hover {
    background-color: #004b8b;
}

/* Template personalizzato per i risultati */
.select-concura-title {
    font-weight: 600;
    color: #333;
    margin-bottom: 4px;
}

.select-concura-address {
    font-size: 12px;
    color: #666;
    font-style: italic;
}

.select2-results__option--highlighted .select-concura-title,
.select2-results__option--highlighted .select-concura-address {
    color: white;
}

/* Sezione risultati */
.select-concura-results {
    margin-top: 30px;
    padding: 20px;
    background: white;
    border-radius: 8px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

.select-concura-results h4 {
    margin: 0 0 20px 0;
    color: #333;
    font-size: 18px;
    border-bottom: 2px solid #004b8b;
    padding-bottom: 10px;
}

/* Intestazione risultati auto-ricerca */
.results-header {
    margin-bottom: 20px;
    padding-bottom: 15px;
    border-bottom: 2px solid #004b8b;
}

.results-header h4 {
    margin: 0;
    color: #004b8b;
    font-size: 18px;
    font-weight: 600;
}

/* Indicatore di caricamento */
.loading-indicator {
    text-align: center;
    padding: 40px 20px;
    color: #666;
}

.loading-indicator p {
    margin: 0;
    font-size: 16px;
    position: relative;
    display: inline-block;
}

.loading-indicator p:after {
    content: '';
    position: absolute;
    right: -25px;
    top: 50%;
    transform: translateY(-50%);
    width: 16px;
    height: 16px;
    border: 2px solid #ddd;
    border-top: 2px solid #004b8b;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

/* Messaggio nessun risultato */
.no-results-message {
    text-align: center;
    padding: 40px 20px;
    color: #666;
    font-style: italic;
    background: #f8f9fa;
    border-radius: 6px;
    border: 1px dashed #ddd;
}

.result-item {
    padding: 15px;
    margin-bottom: 15px;
    background: #f8f9fa;
    border-left: 4px solid #004b8b;
    border-radius: 4px;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.result-item:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(0,0,0,0.1);
}

/* Layout per contenuto risultato */
.result-content {
    display: flex;
    align-items: center;
    gap: 15px;
}

/* Container immagine */
.result-image-container {
    flex-shrink: 0;
    width: 120px;
    height: auto;
    max-height: 72px;
    overflow: hidden;
    border-radius: 6px;
    display: flex;
    align-items: center;
}

.result-image {
    width: 100%;
    height: auto;
    max-height: 72px;
    object-fit: cover;
    border-radius: 6px;
    background: #f8f9fa;
    border: 1px solid #e2e8f0;
    display: block;
}

/* Container dettagli */
.result-details {
    flex: 1;
    min-width: 0; /* Permette al testo di troncarsi se necessario */
}

.result-title {
    font-weight: 600;
    font-size: 16px;
    color: #004b8b;
    margin-bottom: 5px;
    line-height: 1.3;
}

.result-address {
    font-size: 14px;
    color: #666;
    line-height: 1.4;
    margin: 0;
}

.result-item h5 {
    margin: 0 0 10px 0;
    color: #004b8b;
    font-size: 16px;
    font-weight: 600;
}

.result-item p {
    margin: 5px 0;
    color: #555;
    font-size: 14px;
    line-height: 1.4;
}

.result-item p strong {
    color: #333;
}

.result-image {
    max-width: 150px;
    max-height: 100px;
    border-radius: 4px;
    margin-top: 10px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

/* Responsive */
@media (max-width: 768px) {
    .select-concura-wrapper {
        padding: 15px;
        margin: 15px 0;
    }
    
    .select-concura-field {
        margin-bottom: 15px;
    }
    
    .result-item {
        padding: 12px;
    }
    
    .result-content {
        gap: 10px;
    }
    
    .result-image-container {
        width: 100px;
        max-height: 60px; /* 60% di 100px */
    }
    
    .result-image {
        max-height: 60px;
    }
    
    .result-title {
        font-size: 15px;
    }
    
    .result-address {
        font-size: 13px;
    }
}

/* Loading states */
.select2-container--default .select2-selection--single .select2-selection__placeholder {
    color: #999;
}

.select2-container--default .select2-search--dropdown {
    padding: 8px 12px;
    border-bottom: 1px solid #e5e7eb;
}

.select2-container--default .select2-search--dropdown .select2-search__field {
    border: 1px solid #d1d5db;
    border-radius: 6px;
    padding: 8px 12px;
    font-size: 14px;
    background: #ffffff;
    width: 100% !important;
    box-sizing: border-box;
}

.select2-container--default .select2-search--dropdown .select2-search__field:focus {
    border-color: #004b8b;
    outline: none;
    box-shadow: 0 0 0 2px rgba(0, 75, 139, 0.1);
}

/* Error states */
.select-concura-wrapper .select2-container--default .select2-selection.error {
    border-color: #dc3545;
}

.select-concura-wrapper .select2-container--default .select2-selection.error:focus {
    border-color: #dc3545;
    box-shadow: 0 0 0 2px rgba(220, 53, 69, 0.2);
}

/* Success states */
.select-concura-wrapper .select2-container--default .select2-selection.success {
    border-color: #28a745;
}

.select-concura-wrapper .select2-container--default .select2-selection.success:focus {
    border-color: #28a745;
    box-shadow: 0 0 0 2px rgba(40, 167, 69, 0.2);
}

/* Loading states */
.select-concura-wrapper .select2-container--default .select2-selection.loading {
    background-image: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24"><circle cx="12" cy="12" r="3" fill="%23999"><animate attributeName="r" values="3;8;3" dur="1s" repeatCount="indefinite"/></circle></svg>');
    background-repeat: no-repeat;
    background-position: calc(100% - 30px) center;
    background-size: 16px 16px;
}

.select-concura-wrapper .select2-container--default .select2-selection.loading:after {
    content: '';
    position: absolute;
    right: 30px;
    top: 50%;
    transform: translateY(-50%);
    width: 16px;
    height: 16px;
    border: 2px solid #ddd;
    border-top: 2px solid #004b8b;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    0% { transform: translateY(-50%) rotate(0deg); }
    100% { transform: translateY(-50%) rotate(360deg); }
}