/*
 * Profile: the profile modal, its medical-conditions dropdown and the place
 * autocomplete. Fields, rows, the dialog and its footer are the design
 * system's (.field, .field-row, .input, .select, .modal-dialog, .modal-actions):
 * what is left here is only what the design system has no name for.
 */

/* Custom Dropdown per Condizioni Mediche */
.custom-dropdown {
  position: relative;
  width: 100%;
}

.dropdown-selected {
  width: 100%;
  padding: 12px;
  cursor: pointer;
  display: flex;
  justify-content: space-between;
  align-items: center;
  transition: border-color 0.3s;
  user-select: none;
}

.dropdown-selected:hover {
  border-color: var(--neutral-300);
}

.dropdown-selected.active {
  border-color: var(--brand-500);
}

.selected-text {
  flex: 1;
  font-size: 14px;
  color: var(--neutral-900);
}

.dropdown-arrow {
  font-size: 12px;
  color: var(--neutral-600);
  transition: transform 0.3s;
}

.dropdown-selected.active .dropdown-arrow {
  transform: rotate(180deg);
}

.dropdown-options {
  position: absolute;
  top: 100%;
  left: 0;
  right: 0;
  margin-top: 4px;
  background: var(--surface-card);
  border: 2px solid var(--neutral-200);
  border-radius: 8px;
  box-shadow: var(--elevation-2);
  max-height: 250px;
  overflow-y: auto;
  z-index: var(--z-overlay);
  display: none;
}

.dropdown-options.show {
  display: block;
}

.dropdown-option {
  display: flex;
  align-items: center;
  padding: 10px 12px;
  cursor: pointer;
  transition: background-color 0.2s;
  user-select: none;
}

.dropdown-option input[type="checkbox"] {
  margin-right: 10px;
  width: 18px;
  height: 18px;
  cursor: pointer;
}

.dropdown-option span {
  font-size: 14px;
  color: var(--neutral-900);
}

.dropdown-option input[type="checkbox"]:checked + span {
  font-weight: 600;
  color: var(--brand-700);
}

.form-hint {
  display: block;
  margin-top: 6px;
  font-size: 12px;
  color: var(--neutral-600);
  font-style: italic;
}

.profile-success {
  background: var(--success-surface);
  border: 1px solid var(--success);
  color: var(--success-text);
  padding: var(--space-3) var(--space-4);
  border-radius: var(--radius-lg);
  margin-top: 15px;
  text-align: center;
  font-weight: var(--font-medium);
}

/* Autocomplete Styles */
.autocomplete-container {
  position: relative;
}

.autocomplete-suggestions {
  position: absolute;
  top: 100%;
  left: 0;
  right: 0;
  background: var(--surface-card);
  border: 1px solid var(--neutral-200);
  border-top: none;
  border-radius: 0 0 8px 8px;
  max-height: 200px;
  overflow-y: auto;
  z-index: var(--z-overlay);
  display: none;
}

.autocomplete-suggestions.show {
  display: block;
}

.autocomplete-suggestion {
  padding: 10px 12px;
  cursor: pointer;
  border-bottom: 1px solid var(--neutral-50);
  transition: background-color 0.2s;
}

.autocomplete-suggestion:hover,
.autocomplete-suggestion.highlighted {
  background-color: var(--neutral-50);
}

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

.autocomplete-loading {
  padding: 10px 12px;
  text-align: center;
  color: var(--neutral-600);
  font-style: italic;
}

/* Il form ha sette voci: tre gruppi con un titolo, invece di una lista piatta. */
.profile-form {
  display: flex;
  flex-direction: column;
  gap: var(--space-6);
}

.profile-fieldset {
  display: flex;
  flex-direction: column;
  gap: var(--gap-field);
  min-width: 0;
  margin: 0;
  padding: 0;
  border: 0;
}

.profile-fieldset-title {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  width: 100%;
  margin-bottom: var(--space-3);
  padding: 0;
  font-size: var(--text-xs);
  font-weight: var(--font-bold);
  letter-spacing: var(--tracking-caps);
  text-transform: uppercase;
  color: var(--fg-heading);
}

.profile-fieldset-title::after {
  content: "";
  flex: 1;
  height: 1px;
  background-color: var(--border-subtle);
}

/* La tendina delle condizioni e' un .select: stesso bordo, stessa freccia e
   stessi stati degli altri campi. Il testo scelto prende la misura del campo. */
.dropdown-selected.select .selected-text {
  font-size: inherit;
  color: inherit;
}

/* Le azioni stanno nel form, che scorre: restano ancorate in fondo al corpo,
   cosi' "Salva" non sparisce mentre si compila. I margini negativi le portano
   al bordo del pannello, oltre il padding del corpo. */
.profile-form .modal-actions {
  position: sticky;
  bottom: calc(-1 * var(--space-5));
  margin: 0 calc(-1 * var(--space-5)) calc(-1 * var(--space-5));
}

.profile-form .modal-actions .btn {
  flex: 1;
}

.profile-modal .profile-success {
  margin-top: 0;
}
