:host {
  display: block;
  width: 100%;
  min-width: 0;
}

.shared-form-field,
.shared-form-control {
  display: block;
  width: 100%;
  min-width: 0;
}

.shared-form-control {
  position: relative;
}

.shared-form-input {
  display: block;
  width: 100%;
  min-height: 2.5rem;
  padding: 0.75rem 0.75rem 0.5rem;
  border: 1px solid var(--color-inputborder);
  border-radius: 0.5rem;
  background-color: var(--color-white);
  color: var(--color-defaulttextcolor);
  font-size: 0.8125rem;
  line-height: 1.25;
  outline: none;
  box-shadow: none;
  transition: border-color 0.2s ease;
}

.shared-form-input.has-prefix { padding-inline-start: 2.5rem; }
.shared-form-input.has-suffix { padding-inline-end: 2.5rem; }
.shared-form-input::placeholder { color: transparent; }

.shared-form-control.is-focused .shared-form-input,
.shared-form-control.has-value .shared-form-input {
  border-color: var(--color-primary);
}

.shared-floating-label {
  position: absolute;
  inset-inline-start: 0.75rem;
  top: 50%;
  z-index: 2;
  max-width: calc(100% - 1.75rem);
  padding-inline: 0.25rem;
  overflow: hidden;
  transform: translateY(-50%);
  transform-origin: left top;
  background-color: var(--color-white);
  color: #8c9097;
  font-size: 0.75rem;
  line-height: 1;
  text-overflow: ellipsis;
  white-space: nowrap;
  pointer-events: none;
  transition: top 0.2s ease-out, transform 0.2s ease-out, color 0.2s ease-out;
}

.shared-form-control.is-focused .shared-floating-label,
.shared-form-control.has-value .shared-floating-label {
  top: 0;
  transform: translateY(-50%) scale(0.9);
  color: var(--color-primary);
}

.shared-form-control.has-error .shared-form-input { border-color: var(--color-danger); }
.shared-form-control.has-error .shared-floating-label { color: var(--color-danger); }
.shared-form-control.is-disabled { opacity: 0.7; }
.shared-form-control.is-disabled .shared-form-input { cursor: not-allowed; }

.shared-form-prefix,
.shared-form-suffix {
  position: absolute;
  top: 50%;
  z-index: 3;
  display: flex;
  width: 2.5rem;
  align-items: center;
  justify-content: center;
  transform: translateY(-50%);
  color: var(--color-textmuted);
}
.shared-form-prefix { inset-inline-start: 0; }
.shared-form-suffix { inset-inline-end: 0; }
.shared-form-action { border: 0; background: transparent; cursor: pointer; }

.shared-form-input[type='number']::-webkit-inner-spin-button,
.shared-form-input[type='number']::-webkit-outer-spin-button { appearance: none; margin: 0; }
.shared-form-input[type='number'] { -moz-appearance: textfield; }

:host-context(.dark) .shared-form-input,
:host-context(.dark) .shared-floating-label {
  background-color: var(--color-bodybg);
}
