/* Form layout, inputs and inline validation output. */

.form {
  display: flex;
  flex-direction: column;
  gap: var(--space-md);
}

.form__field {
  display: flex;
  flex-direction: column;
  gap: var(--space-2xs);
}

.form__field--inline {
  flex-direction: row;
  align-items: center;
  gap: var(--space-xs);
}

.form__label-row {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: var(--space-xs);
}

.form__label {
  font-size: var(--font-size-sm);
  font-weight: 600;
  color: var(--color-text);
}

.form__label-link {
  font-size: var(--font-size-xs);
  font-weight: 600;
  text-decoration: none;
}

.form__label-link:hover {
  text-decoration: underline;
}

.form__input {
  width: 100%;
  padding: 0.625rem var(--space-sm);
  color: var(--color-text);
  background: var(--color-surface);
  border: 1px solid var(--color-border-strong);
  border-radius: var(--radius-md);
  font-family: inherit;
  font-size: var(--font-size-sm);
  line-height: 1.4;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.form__input::placeholder {
  color: var(--color-text-subtle);
}

.form__input:focus {
  outline: none;
  border-color: var(--color-brand);
  box-shadow: 0 0 0 3px var(--color-brand-soft);
}

.form__input:disabled {
  background: var(--color-surface-muted);
  color: var(--color-text-muted);
}

/* Room for the reveal toggle that sits inside the password field. */
.form__input--password {
  padding-right: 3.5rem;
}

.form__input-group {
  position: relative;
  display: flex;
  align-items: center;
}

.form__reveal {
  position: absolute;
  right: var(--space-2xs);
  padding: var(--space-2xs) var(--space-xs);
  color: var(--color-text-muted);
  background: transparent;
  border: 0;
  border-radius: var(--radius-sm);
  font-family: inherit;
  font-size: var(--font-size-xs);
  font-weight: 600;
  cursor: pointer;
}

.form__reveal:hover {
  color: var(--color-text);
  background: var(--color-surface-muted);
}

.form__hint {
  font-size: var(--font-size-xs);
  color: var(--color-text-muted);
}

.form__checkbox {
  width: 1rem;
  height: 1rem;
  margin: 0;
  accent-color: var(--color-brand);
}

.form__checkbox-label {
  font-size: var(--font-size-sm);
  color: var(--color-text-muted);
}

.form__actions {
  display: flex;
  flex-direction: column;
  gap: var(--space-xs);
  margin-top: var(--space-2xs);
}

.form__errors {
  padding: var(--space-sm) var(--space-md);
  color: var(--color-alert);
  background: var(--color-alert-bg);
  border: 1px solid var(--color-alert-border);
  border-radius: var(--radius-md);
}

.form__errors-title {
  font-size: var(--font-size-sm);
  font-weight: 600;
}

.form__errors-list {
  margin: var(--space-2xs) 0 0;
  padding-left: var(--space-md);
  font-size: var(--font-size-sm);
}

.form__note {
  padding: var(--space-xs) var(--space-sm);
  color: var(--color-text-muted);
  background: var(--color-surface-muted);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  font-size: var(--font-size-xs);
}

/* Rails wraps an errored input -- and its label -- in a `div.field_with_errors`.
   That extra block element sits between .form__input-group and the input,
   which knocks the absolutely positioned reveal button out of the field.
   `display: contents` removes the wrapper from layout entirely while keeping
   it as a styling hook. Guarded by a spec in spec/requests/devise_screens_spec.rb. */
.field_with_errors {
  display: contents;
}

.field_with_errors .form__label {
  color: var(--color-alert);
}

.field_with_errors .form__input {
  border-color: var(--color-alert);
}

.field_with_errors .form__input:focus {
  border-color: var(--color-alert);
  box-shadow: 0 0 0 3px var(--color-alert-bg);
}
