/* ✅ INIZIO STILE COMPLETO CON SUPPORTO SELECT CUSTOM */

.title-form {
  color: #f41c1c;
  margin-bottom: 30px;
}

.input-data {
  position: relative;
}

/* Stili base per input, select (non multipla), textarea e display select (singola) */
.input-data input:not([type="radio"]):not([type="checkbox"]),
.input-data select:not([multiple]),
.input-data textarea,
.input-data .selected-option:not(.multiple) {
  width: 100%;
  height: 45px; /* Altezza base */
  border: none;
  background-color: transparent;
  border-bottom: 2px solid rgba(0, 0, 0, 0.12);
  font-size: 14px;
  outline: none;
  padding: 20px 5px 4px 5px;
  border-radius: 5px 5px 0 0;
  box-sizing: border-box;
  display: block;
  margin-bottom: 20px;
}

/* Stile specifico per il display della select multipla */
.input-data .selected-option.multiple {
  width: 100%;
  border: none;
  background-color: transparent;
  border-bottom: 2px solid rgba(0, 0, 0, 0.12);
  font-size: 14px;
  outline: none;
  border-radius: 5px 5px 0 0;
  box-sizing: border-box;
  margin-bottom: 20px;
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
  cursor: pointer;
  position: relative;
  height: 45px;           /* Altezza base fissa */
  min-height: 45px;
  padding-top: 20px;
  align-items: flex-start;
  padding-bottom: 5px;
  padding-right: 65px;
  padding-left: 5px;
  overflow: hidden;
  transition: height 0.15s ease-out;
}

/* Consente l’espansione verticale quando NON c’è summary */
.input-data .selected-option.multiple:not(.show-summary) {
  height: auto;
  min-height: 45px;
}

.input-data textarea {
  min-height: 120px;
  height: auto;
  resize: vertical;
}

.input-data label {
  position: absolute;
  pointer-events: none;
  top: 18px;
  left: 5px;
  font-size: 14px;
  color: #999;
  transition: 0.3s ease;
  max-width: calc(100% - 70px);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.input-data input:focus ~ label,
.input-data textarea:focus ~ label,
.input-data textarea:not(:placeholder-shown) ~ label,
.input-data select:focus ~ label,
.input-data.has-value label,
.input-data.open label {
  top: 6px;
  font-size: 12px;
  color: #ff4d4d;
}

.input-data.has-value .selected-option.multiple ~ label,
.input-data.open .selected-option.multiple ~ label {
  top: 6px;
}

.input-data .btn-group label {
  position: relative;
  pointer-events: auto;
  top: auto;
  left: auto;
  transition: none;
}

.input-data.no-error-highlight label {
  color: #999 !important;
}

.input-data.no-error-highlight .underline:before {
  background: #e0e0e0 !important;
}

.underline {
  position: relative;
  bottom: 20px;
  height: 0;
  pointer-events: none;
}

.underline:before {
  content: "";
  height: 3px;
  width: 100%;
  background: #ff4d4d;
  transform: scaleX(0);
  transition: transform 0.3s ease;
  display: block;
  position: absolute;
  bottom: 0;
}

.input-data input:focus ~ .underline:before,
.input-data textarea:focus ~ .underline:before,
.input-data select:focus ~ .underline:before,
.select-wrapper.open .underline:before {
  transform: scale(1);
}

/* --- MODIFICA INIZIO --- */
/* Stili per Readonly e Disabled - Aumentata Specificità e !important */
.input-data input[readonly],
.input-data textarea[readonly],
.input-data select[readonly],
.input-data input:disabled, /* Selettore originale */
.input-data > input:disabled, /* Aggiunto per specificità */
.input-data textarea:disabled,
.input-data > textarea:disabled, /* Aggiunto per specificità */
.input-data select:disabled,
.input-data.readonly .selected-option, /* Per select custom */
.input-data.disabled .selected-option { /* Per select custom */
  background-color: #f9f9f9 !important; /* Sfondo grigio forzato */
  color: #666;
  cursor: not-allowed;
  border-bottom-style: dashed !important; /* Bordo tratteggiato forzato */
  border-bottom-color: #ccc !important; /* Colore bordo forzato */
  /* Resetta altri bordi per sicurezza */
  border-top-color: transparent;
  border-left-color: transparent;
  border-right-color: transparent;
}

/* Nascondi l'underline per i campi disabilitati */
.input-data input:disabled ~ .underline:before,
.input-data textarea:disabled ~ .underline:before,
.input-data select:disabled ~ .underline:before,
.input-data.disabled .selected-option ~ .underline:before {
  transform: scaleX(0) !important;
  background: none !important; /* Aggiunto per sicurezza */
}

/* Assicura che il focus non attivi l'underline su elementi disabilitati/readonly */
.input-data input[readonly]:focus ~ .underline:before,
.input-data textarea[readonly]:focus ~ .underline:before,
.input-data select[readonly]:focus ~ .underline:before,
.input-data input:disabled:focus ~ .underline:before,
.input-data textarea:disabled:focus ~ .underline:before,
.input-data select:disabled:focus ~ .underline:before {
  transform: scaleX(0) !important;
}

/* Stile label per campi disabilitati/readonly */
.input-data input[readonly] ~ label,
.input-data textarea[readonly] ~ label,
.input-data select[readonly] ~ label,
.input-data input:disabled ~ label,
.input-data textarea:disabled ~ label,
.input-data select:disabled ~ label,
.input-data.readonly label, /* Per select custom */
.input-data.disabled label { /* Per select custom */
  color: #999 !important; /* Colore label più chiaro */
}
/* --- MODIFICA FINE --- */


.error-msg {
  position: absolute;
  bottom: 0px;
  left: 0;
  font-size: 12px;
  color: #ff4d4d;
  margin-top: 2px;
}

/* Select Wrapper e Select Nativa */
.select-wrapper {
  position: relative;
}
.select-wrapper select {
  display: none !important;
}

/* Bottone Clear (X) */
.select-clear {
  position: absolute;
  right: 35px;
  top: 50%;
  transform: translateY(-50%);
  font-size: 25px;
  line-height: 1;
  color: #777;
  cursor: pointer;
  z-index: 2;
  visibility: hidden;
  opacity: 0;
  transition: opacity 0.2s ease;
  padding: 0 5px;
}
.select-wrapper.has-value:not(.open):not(.disabled):hover .select-clear,
.select-wrapper.has-value:not(.open):not(.disabled):focus-within .select-clear {
  visibility: visible;
  opacity: 1;
}
.select-wrapper.disabled .select-clear,
.select-wrapper.readonly .select-clear {
  display: none !important;
  pointer-events: none !important;
}

/* ——— MODIFICHE PER SCROLL SOLO SU RISULTATI ——— */

/* 1) Dropdown nascosto di default */
.select-dropdown {
  display: none;
  position: absolute;
  top: 100%;
  left: 0;
  right: 0;
  background-color: #fff;
  border: 1px solid rgba(0, 0, 0, 0.12);
  border-top: none;
  border-radius: 0 0 5px 5px;
  box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
  z-index: 9999;
  flex-direction: column;
  max-height: none;
  overflow: visible;
}

/* 2) Solo in stato “open” mostro il dropdown come flex */
.select-dropdown.open {
  display: flex;
}


/* 2) Search bar sticky in cima */
.select-search {
  width: 100%;
  box-sizing: border-box;
  padding: 8px 10px;
  border: none;
  border-bottom: 1px solid #ddd;
  outline: none;
  background: #f8f9fa;
  font-size: 14px;
  position: sticky;
  top: 0;
  z-index: 2;
}

/* 3) Scroll **solo** sulla lista opzioni */
.options-list {
  list-style: none;
  margin: 0;
  padding: 0;
  max-height: 300px;
  overflow-y: auto;
}

/* Stili dropdown originari */
.options-list li {
  display: flex;
  align-items: center;
  padding: 6px 8px;
  gap: 3px;
  cursor: pointer;
  font-size: 14px;
  transition: background 0.2s;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.options-list li:hover {
  background-color: #f0f0f0;
}
.options-list li.selected {
  background-color: #ffeded;
  color: #ff4d4d;
  font-weight: 500;
}
.options-list li input[type="checkbox"] {
  appearance: none;
  -webkit-appearance: none;
  -moz-appearance: none;
  box-sizing: border-box;
  background-color: #fff;
  border: 1px solid #ccc;
  border-radius: 3px;
  width: 16px !important;
  height: 16px !important;
  min-width: 16px;
  min-height: 16px;
  padding: 0;
  cursor: pointer;
  position: relative;
  outline: none;
  margin-right: 10px;
  flex-shrink: 0;
  margin-top: 0;
  margin-bottom: 0;
}
.options-list li input[type="checkbox"]:checked {
  background-color: #ff4d4d;
  border-color: #ff4d4d;
}
.options-list li input[type="checkbox"]:checked::after {
  content: '';
  display: block;
  width: 5px;
  height: 9px;
  border: solid white;
  border-width: 0 2px 2px 0;
  transform: translate(-50%, -50%) rotate(45deg);
  position: absolute;
  left: 50%;
  top: 48%;
}
.options-list li input[type="checkbox"]:hover {
  border-color: #aaa;
}
.options-list li input[type="checkbox"]:checked:hover {
  border-color: #e60000;
  background-color: #e60000;
}
.options-list li span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  flex-grow: 1;
}

/* —————————————————————————————————————————— */

.selected-option {
  position: relative;
  cursor: pointer;
  min-height: 45px;
  display: flex;
  align-items: center;
  overflow: hidden;
  text-overflow: ellipsis;
  padding-right: 65px !important; /* Spazio per la X e la freccia */
}
.selected-option::after {
  content: '\f0d7';
  font-family: "Font Awesome 6 Free";
  font-weight: 900;
  position: absolute;
  right: 10px;
  top: 50%;
  transform: translateY(-50%);
  font-size: 14px;
  color: #777;
  pointer-events: none;
  transition: transform 0.2s ease;
  z-index: 3;
  background-color: inherit; /* Eredita il background */
  width: 20px;
  text-align: center;
}
.select-wrapper.open .selected-option::after {
  content: '\f0d8';
}

/* Tag per select multiple */
.tag {
  background-color: #e0e0e0;
  color: #333;
  font-size: 13px;
  border-radius: 4px;
  display: inline-flex;
  align-items: center;
  padding: 2px 0px 2px 8px;
  margin-right: 5px;
  white-space: nowrap;
  box-sizing: border-box;
  overflow: hidden;
  max-width: 100%;
}
.tag .tag-text {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  flex-grow: 1;
  min-width: 0;
}
.tag-remove {
  font-weight: bold;
  cursor: pointer;
  font-size: 14px;
  line-height: 1;
  padding: 0 5px 0 5px;
  flex-shrink: 0;
  margin-left: 4px;
}
.tag-remove:hover {
  color: #ff4d4d;
}

/* Riepilogo select multipla */
.multiple-select-summary {
  font-size: 14px;
  color: #333;
  padding: 0 5px;
  display: inline-block;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: calc(100% - 45px);
}
.selected-option.multiple.show-summary {
  height: 45px;
  min-height: 45px;
  align-items: center;
  overflow: hidden;
  padding-top: 0;
  padding-bottom: 0;
  padding-left: 5px;
  padding-right: 65px;
}

/* Gestione allegati */
.attachments-section {
  position: relative;
  background: transparent;
  border-radius: 5px 5px 0 0;
  padding: 15px 15px 15px 40px;
  cursor: pointer;
  min-height: 65px;
}
.attachment-header {
  position: relative;
  display: flex;
  justify-content: space-between;
  align-items: center;
  min-height: 24px;
  margin-bottom: 5px;
}
.attachment-info {
  font-size: 14px;
  color: #333;
  font-weight: 500;
  padding-right: 10px;
}
.attachment-info i {
  position: absolute;
  left: -30px;
  top: 50%;
  transform: translateY(-50%);
  color: #666;
}
.attachment-clear {
  color: #ff4d4d;
  cursor: pointer;
  font-weight: bold;
  font-size: 22px;
  width: 24px;
  height: 24px;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 2;
}
.attachments-section input[type="file"] {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  opacity: 0;
  cursor: pointer;
  z-index: 1;
}
.attachment-hint {
  font-size: 12px;
  color: #666;
  padding-top: 5px;
  border-top: 2px solid rgba(0, 0, 0, 0.12);
}

/* Gestione campi data */
body .input-data.readonly label {
  top: 4px;
  font-size: 12px;
  color: #999;
}
.input-data:not(.has-value) input[type="date"] {
  color: transparent;
}
.input-data.has-value input[type="date"]:not(:disabled) {
  color: #000;
}
.input-data.has-value input[type="date"]:disabled {
  color: #666;
}

/* Media queries */
@media (max-width: 768px) {
  .form-row {
    flex-direction: column;
  }
  .input-data {
    width: 100%;
    margin: 10px 0;
  }
  .select-clear {
    right: 35px;
  }
  .selected-option::after {
    right: 10px;
  }
}
@media (max-width: 480px) {
  .select-clear {
    font-size: 18px;
    right: 35px;
  }
  .selected-option::after {
    font-size: 12px;
    right: 10px;
  }
}

/* select[required]:not([multiple]) + .underline + label::before, */

/* Aggiunta asterisco campi required */
input[required]:not([type='checkbox']):not([type='radio']) + .underline + label::before,
input[required]:not([type='checkbox']):not([type='radio']) + i + .underline + label::before,
textarea[required] + .underline + label::before,
select[required]:not([multiple]) + .underline + label::before,
.select-wrapper:has(select[required]) > label::before,
.select-wrapper:has(select[required]) .selected-option + .underline + label::before,
.attachments-section:has(input[required]) .attachment-info::before {
  content: "* ";
  color: red;
}


.input-data.radio-type {
  margin-top: -5px;
}
.label-fit{
  margin-left: -5px;
  color: #6c7383 !important;
}
#fittizio-container{
  padding-left: 20px;
}

/* Aggiungere queste regole per gestire meglio i testi lunghi nelle select */
.input-data .selected-option {
  overflow: hidden;
  text-overflow: ellipsis;
  padding-right: 65px !important; /* Spazio per la X e la freccia */
  position: relative;
}

/* Assicura che la select possa mostrare correttamente testi lunghi */
.input-data .selected-option > span:not(.tag) {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: calc(100% - 65px);
  display: inline-block;
}

/* Garantisce che la X sia sempre visibile e accessibile */
.select-clear {
  position: absolute;
  right: 35px;
  top: 50%;
  transform: translateY(-50%);
  font-size: 22px;
  line-height: 1;
  color: #777;
  cursor: pointer;
  z-index: 4; /* Aumentato per garantire che stia sopra */
  visibility: hidden;
  opacity: 0;
  transition: opacity 0.2s ease;
  padding: 0 5px;
  background-color: inherit; /* Eredita il background del contenitore */
}

/* Assicura che sia sempre presente un'area cliccabile */
.select-wrapper.has-value:not(.open):not(.disabled):hover .select-clear,
.select-wrapper.has-value:not(.open):not(.disabled):focus-within .select-clear {
  visibility: visible;
  opacity: 1;
}

/* Per mantenere visibile l'icona a destra */
.selected-option::after {
  position: absolute;
  right: 10px;
  top: 50%;
  transform: translateY(-50%);
  background-color: inherit; /* Eredita il background */
  z-index: 4; /* Stesso del clear button */
  width: 20px;
  text-align: center;
}

/* Dropdown più largo per mostrare contenuti lunghi */
@media (min-width: 768px) {
  .select-dropdown {
    min-width: 100%;
    width: auto;
    max-width: 400px; /* Larghezza massima su desktop */
  }
}

/* Opzioni con testo lungo nella dropdown */
.options-list li span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 100%;
}

/* Miglioriamo l'aspetto estetico delle select con testo lungo */

/* Contenitore principale della select */
.input-data .selected-option {
  position: relative;
  padding: 20px 45px 4px 5px !important; /* Ridotto padding destro */
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Miglioriamo l'aspetto del testo selezionato */
.input-data .selected-option > span:not(.tag) {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: calc(100% - 40px); /* Aumenta spazio per il testo */
  display: inline-block;
  font-size: 14px;
  line-height: 1.2;
}

/* Icone e controlli posizionati in modo più compatto */
.select-wrapper .selected-option::after {
  right: 5px;
  font-size: 12px;
  width: 15px;
  padding-left: 5px;
  background: linear-gradient(90deg, transparent 0%, inherit 30%);
}

.select-wrapper .select-clear {
  right: 25px;
  font-size: 18px;
  background: linear-gradient(90deg, transparent 0%, inherit 30%);
  padding: 0 2px;
}

/* Stile per i valori lunghi nelle select */
.input-data .selected-option.long-value {
  font-size: 13px;
  line-height: 1.1;
}

/* Stile migliorato per la dropdown */
.select-dropdown {
  border-radius: 0 0 8px 8px;
  box-shadow: 0 6px 12px rgba(0,0,0,0.15);
}

/* Opzioni più leggibili nella dropdown */
.options-list li {
  padding: 8px 12px;
  border-bottom: 1px solid #f0f0f0;
}

.options-list li:last-child {
  border-bottom: none;
}

.options-list li span {
  font-size: 14px;
  line-height: 1.3;
}

/* Aggiunto javascript per rilevare e gestire valori lunghi */

/* ✅ FINE STILE COMPLETO */
