/* Stili di base per il popup */
.search-select-popup {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.5);
    z-index: 1050;
    justify-content: center;
    align-items: center;
}

.search-select-popup-content {
    background-color: #fff;
    border-radius: 8px;
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.2);
    width: 500px;
    max-width: 90%;
    max-height: 80vh;
    display: flex;
    flex-direction: column;
    animation: popupFadeIn 0.3s ease;
}

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

/* Header del popup */
.search-select-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 15px 20px;
    border-bottom: 1px solid #e9ecef;
}

.search-select-header h5 {
    margin: 0;
    font-weight: 600;
    color: #1565c0;
}

.search-select-header .close-popup {
    background: none;
    border: none;
    font-size: 1.2rem;
    color: #6c757d;
    cursor: pointer;
    padding: 0;
    transition: color 0.2s;
}

.search-select-header .close-popup:hover {
    color: #343a40;
}

/* Corpo del popup */
.search-select-body {
    padding: 20px;
    overflow-y: auto;
    flex-grow: 1;
    max-height: calc(80vh - 60px);
}

/* Input di ricerca */
.search-input-wrapper {
    margin-bottom: 15px;
    position: relative;
}

.search-input-wrapper input {
    padding-left: 5px;
    border-radius: 20px;
    border: 2px solid #e0e0e0;
    transition: all 0.3s;
}

.search-input-wrapper input:focus {
    border-color: #1565c0;
    box-shadow: 0 0 0 3px rgba(21, 101, 192, 0.2);
}

.search-input-wrapper::before {
    content: "\f002";
    font-family: "Font Awesome 5 Free";
    font-weight: 900;
    position: absolute;
    left: 12px;
    top: 50%;
    transform: translateY(-50%);
    color: #6c757d;
}

/* Contenitore dei risultati */
.search-results-container {
    background-color: #f8f9fa;
    border-radius: 6px;
    overflow: hidden;
}

.search-results-list {
    overflow-y: auto;
    max-height: 300px;
}

/* Elementi dei risultati */
.search-result-item {
    padding: 12px 15px;
    border-bottom: 1px solid #e9ecef;
    cursor: pointer;
    transition: background-color 0.2s;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

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

.search-result-item:hover, 
.search-result-item.selected {
    background-color: #e9f0f7;
}

.search-result-item.selected {
    background-color: #e3f2fd;
}

.result-value {
    font-weight: 500;
    color: #212529;
}

.result-comment {
    font-size: 0.8rem;
    color: #1565c0;
    font-style: italic;
    text-align: right;
    margin-left: 10px;
}

/* Campo di selezione nel form */
.search-select-field {
    position: relative;
}

.search-select-field input {
    padding-right: 5px;
    cursor: pointer;
    background-color: white;
}

.search-select-field .search-trigger {
    position: absolute;
    right: 10px;
    top: 50%;
    transform: translateY(-50%);
    color: #6c757d;
    cursor: pointer;
    font-size: 1rem;
    transition: color 0.2s;
}

.search-select-field .search-trigger:hover {
    color: #1565c0;
}

/* Visualizzazione corrente */
.search-select-current {
    display: flex;
    justify-content: space-between;
    align-items: center;
    cursor: pointer;
    padding: 0.375rem 0.75rem;
    border: 1px solid #ced4da;
    border-radius: 0.25rem;
    background-color: #fff;
    transition: border-color 0.15s ease-in-out;
    position: relative;
}

.search-select-current:hover {
    border-color: #adb5bd;
}

.search-select-current .current-value {
    flex-grow: 1;
}

.search-select-current .current-comment {
    font-size: 0.75rem;
    color: #1565c0;
    font-style: italic;
    margin-left: 10px;
    margin-right: 25px;
}

/* Dropdown */
.search-select-dropdown {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background-color: #fff;
    border: 1px solid #ced4da;
    border-top: none;
    border-radius: 0 0 .25rem .25rem;
    box-shadow: 0 2px 5px rgba(0,0,0,.15);
    z-index: 10;
    display: none;
}

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

.search-select-dropdown .search-result-item {
    padding: 0.5rem 0.75rem;
}

/* Stili per la visualizzazione degli errori nei campi del form */
.form-group.has-error .form-control,
.form-group.has-error .search-select-current {
    border: 2px solid #dc3545;
    box-shadow: 0 0 0 0.25rem rgba(220, 53, 69, 0.25);
}

.form-group.has-error .form-label {
    color: #dc3545;
    font-weight: 500;
}

.error-message {
    color: #dc3545;
    font-size: 0.875rem;
    margin-top: 0.25rem;
}

.form-group.has-error.corrected .form-control,
.form-group.has-error.corrected .search-select-current {
    border-color: #198754;
    box-shadow: 0 0 0 0.25rem rgba(25, 135, 84, 0.25);
}

.form-group.has-error.corrected .error-message {
    display: none;
}

.validation-marker {
    position: absolute;
    right: 10px;
    top: 50%;
    transform: translateY(-50%);
    font-size: 1rem;
    z-index: 5;
}

.validation-marker.error {
    color: #dc3545;
}

.validation-marker.corrected {
    color: #198754;
}

/* Piccolo trattino rosso a fianco del campo obbligatorio con errore */
.form-group.has-error .form-label:after {
    content: "*";
    color: #dc3545;
    margin-left: 4px;
}

.input-group {
    position: relative;
}

/* Stili per il focus sui campi con errore */
.form-group.has-error input:focus,
.form-group.has-error select:focus,
.form-group.has-error textarea:focus,
.form-group.has-error .search-select-current:focus-within {
    box-shadow: 0 0 0 0.25rem rgba(220, 53, 69, 0.4);
    border-color: #dc3545;
    outline: none;
}

/* Animazione per attirare l'attenzione quando si usa il tasto Invio */
@keyframes pulse-error {
    0% { transform: translateY(0); }
    25% { transform: translateY(-5px); }
    50% { transform: translateY(0); }
    75% { transform: translateY(-3px); }
    100% { transform: translateY(0); }
}

.form-group.attention {
    animation: pulse-error 0.7s ease;
}

/* Stilizzare il campo attualmente selezionato */
.form-control:focus,
.search-select-current:focus-within {
    border-color: #1976d2;
    box-shadow: 0 0 0 0.25rem rgba(25, 118, 210, 0.25);
}
