﻿/* ==========================================================================
   1. STILE BASE UNIFICATO (Input, Select, Search, Date)
   ========================================================================== */
input.form-control,
input[type="text"].form-control,
input[type="search"].form-control,
input[type="date"].form-control,
input[type="email"].form-control,
input[type="password"].form-control,
select.form-control,
select.form-select {
    display: flex !important;
    align-items: center !important;
    width: 100% !important;
    height: 46px !important;
    min-height: 46px !important;
    margin-top: 0 !important;
    padding: 0 0.75rem !important; /* Padding semplificato */
    font-size: 15px !important;
    line-height: 44px !important; /* Centra il testo verticalmente */
    color: #4a5568;
    background-color: #ffffff !important;
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    transition: all 0.2s ease-in-out;
    box-sizing: border-box !important;
    appearance: none !important;
    -webkit-appearance: none !important;
    -moz-appearance: none !important;
    cursor: text; /* Forza cursore testo di base */
}

/* Cursore a manina per le select */
select.form-control, select.form-select {
    cursor: pointer !important;
}

    input.form-control:focus,
    select.form-control:focus {
        border-color: #bee3f8;
        outline: 0;
        box-shadow: 0 0 0 0.2rem rgba(66, 153, 225, 0.15);
    }

label {
    color: #4a5568;
    font-weight: 600;
    margin-bottom: 6px;
    display: inline-block;
}

.required::after {
    content: " *";
    color: #f43f5e;
}

/* ==========================================================================
   2. STATI DI VALIDAZIONE (Bordi e Icone)
   ========================================================================== */

/* Comune a tutti gli stati con icona */
.input-validation-error,
.valid,
.has-warning .form-control,
.field-error,
.has-success .form-control,
.has-danger .form-control {
    padding-right: 2.5rem !important;
    background-repeat: no-repeat !important;
    background-position: right 12px center !important;
    background-size: 18px 18px !important;
}

/* Errore (Rosso) */
.input-validation-error, .has-danger .form-control, .field-error {
    border-color: #fecdd3 !important;
    background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 12 12' fill='%23f43f5e'%3e%3ccircle cx='6' cy='6' r='4.5' fill='none' stroke='%23f43f5e'/%3e%3cpath stroke-linejoin='round' d='M5.8 3.6h.4L6 6.5z' stroke='%23f43f5e'/%3e%3ccircle cx='6' cy='8.2' r='.6' fill='%23f43f5e'/%3e%3c/svg%3e") !important;
}

/* Successo (Verde) */
.valid, .has-success .form-control, .field-success {
    border-color: #c6f6d5 !important;
    background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 8 8'%3e%3cpath fill='%2348bb78' d='M2.3 6.73L.6 4.53c-.4-1.04.46-1.4 1.1-.8l1.1 1.4 3.4-3.8c.6-.63 1.6-.27 1.2.7l-4 4.6c-.43.5-.8.4-1.1.1z'/%3e%3c/svg%3e") !important;
}

/* Warning (Arancio) */
.has-warning .form-control, .field-warning {
    border-color: #fbd38d !important;
    background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 8 8'%3e%3cpath fill='%23ed8936' d='M4.4 5.324h-.8v-2.46h.8zm0 1.42h-.8V5.89h.8zM3.76.63L.04 7.075c-.115.2.016.425.26.426h7.397c.242 0 .372-.226.258-.426C6.726 4.924 5.47 2.79 4.253.63c-.113-.174-.39-.174-.494 0z'/%3e%3c/svg%3e") !important;
}

/* ==========================================================================
   3. DISABILITATO / READONLY (Look Chiaro)
   ========================================================================== */

/* Solo i campi realmente DISABLED mostrano il divieto */
input:disabled,
select:disabled,
.form-control:disabled {
    background-color: #f8fafc !important;
    border-color: #cbd5e1 !important;
    color: #64748b !important;
    cursor: not-allowed !important;
    background-image: none !important;
}

/* I campi READONLY restano bianchi e con cursore testo standard */
input[readonly] {
    background-color: #ffffff !important;
    cursor: text !important;
}

/* ==========================================================================
   4. MESSAGGI DI ERRORE SOTTO I CAMPI (BOX PASTELLO)
   ========================================================================== */
.field-validation-error, .field-validation-valid {
    display: block !important;
    margin-top: 8px;
    font-size: 0 !important;
}

    .field-validation-error span {
        display: flex !important;
        align-items: center !important;
        gap: 10px;
        font-size: 13px !important;
        font-weight: 500 !important;
        border-radius: 8px;
        padding: 8px 15px !important;
        box-shadow: 0 1px 2px rgba(0,0,0,0.03);
        background-color: #fff1f2 !important;
        border-left: 4px solid #fecdd3 !important;
        color: #4a5568 !important;
    }

        .field-validation-error span::before {
            content: "✕";
            color: #f43f5e;
            font-weight: bold;
            font-size: 14px;
        }

/* ==========================================================================
   5. COMPONENTI ESTERNI E FIX CALENDARIO
   ========================================================================== */
.ui-datepicker select,
.flatpickr-calendar select,
.datepicker select {
    appearance: auto !important;
    -webkit-appearance: menulist !important;
    height: auto !important;
    min-height: auto !important;
    padding: 2px !important;
    display: inline-block !important;
    width: auto !important;
}

span.input-validation-error,
span[data-valmsg-for].input-validation-error {
    border: none !important;
    background: transparent !important;
    padding: 0 !important;
}
