:host {
  display: block;
}

.floating-label {
  position: relative;
  display: block;

  ::ng-deep .form-control {
    padding-block: 1.125rem 0.375rem;
    min-height: 3.25rem;
    border-radius: 0.5rem;
    transition: border-color 0.2s ease, box-shadow 0.2s ease;

    &::placeholder {
      color: transparent;
    }
  }

  ::ng-deep .form-control:focus {
    border-color: var(--color-primary);
    box-shadow: 0 0 0 0.2rem color-mix(in srgb, var(--color-primary) 20%, transparent);
  }

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

  &:focus-within > label,
  &.floating-label--float > label {
    top: 0;
    transform: translateY(-50%) scale(0.85);
    color: var(--color-primary) !important;
  }

  &.floating-label--invalid > label {
    color: var(--color-danger) !important;
  }
}

:host-context(.dark) .floating-label > label,
:host-context(.dark) .floating-label:focus-within > label,
:host-context(.dark) .floating-label.floating-label--float > label {
  background: var(--color-bodybg) !important;
}

:host-context(.dark) .floating-label ::ng-deep .form-control:focus {
  box-shadow: 0 0 0 0.2rem color-mix(in srgb, var(--color-primary) 25%, transparent);
}
