/*------------------------------------------------
 * Base form elements
 * ------------------------------------------------*/

input,
select,
textarea {
  background: var(--input-background);
  border: solid 1px var(--border-medium);
  border-radius: var(--radius-md);
  color: var(--color-primary);
  font-family: inherit;
  font-size: 1rem;
  line-height: var(--line-height);
  outline: none;
  padding: 0.5rem 0.75rem;
}

/* Fields show focus with the accent border rather than an outline ring */
input:focus-visible,
select:focus-visible,
textarea:focus-visible {
  border-color: var(--focus-ring);
  box-shadow: 0 0 0 1px var(--focus-ring);
  outline: none;
}

button {
  background: transparent;
  border: none;
  color: inherit;
  cursor: pointer;
  font-family: inherit;
  font-size: 1rem;
  line-height: var(--line-height);
}

textarea,
textarea:focus {
  font-size: 1rem;
}

/*------------------------------------------------
 * Form controls
 * ------------------------------------------------*/

.form-control,
.form-select {
  background-color: var(--input-background);
  border-radius: var(--radius-md);
}

.form-select {
  font-size: inherit;
}

/*------------------------------------------------
 * Error handling
 * ------------------------------------------------*/

form .errorlist {
  padding: 0;
  margin: 0;
  color: var(--error);
}


/*------------------------------------------------
 * File input
 * ------------------------------------------------*/

input[type="file"],
input[type="file"].form-control {
  padding: 0;
}

input[type="file"]::file-selector-button {
  appearance: none;
  -moz-appearance: none;
  background: var(--background-control);
  border: none;
  border-right: solid 1px var(--border-medium);
  border-radius: var(--radius-md) 0 0 var(--radius-md);
  color: var(--color-primary);
  padding: 0.5rem 0.75rem;
  margin-right: 0.75rem;
  cursor: pointer;
}

input[type="file"]::file-selector-button:hover {
  background: var(--border-light);
}

/*------------------------------------------------
 * Filter forms: the inputs in a card's toolbar (.filter, base-app.css),
 * as tall as its square buttons. A set filter takes the selected
 * colours, as a toolbar button does.
 * ------------------------------------------------*/

.filter select,
.filter input[type="text"],
.filter input[type="number"],
.filter input[type="date"] {
  box-sizing: border-box;
  max-width: 100%;
}

.filter input[type="text"] {
  width: 16rem;
}

.filter input[type="text"].selected {
  background: var(--selected-background);
  border-color: var(--selected-border);
  color: var(--selected-color);
}

.filter-select {
  background: var(--background-light);
  max-width: 100%;
  width: 12.5rem;
}

.filter input[type="date"] {
  width: 10rem;
}

/* A period stepper: previous, the period (which may toggle all time),
   next, as one control as tall as a toolbar button */
.month-stepper {
  align-items: stretch;
  background: var(--background-control);
  border: 1px solid var(--border-medium);
  border-radius: var(--radius-md);
  display: inline-flex;
}

.month-stepper button {
  align-items: center;
  background: transparent;
  border: none;
  border-radius: 0;
  display: inline-flex;
  line-height: var(--line-height);
  padding: 0.5rem;
  transition: background 0.15s ease, color 0.15s ease;
}

.month-stepper button i {
  font-size: 1rem;
}

.month-stepper button:first-child {
  border-radius: var(--radius-md) 0 0 var(--radius-md);
}

.month-stepper button:last-child {
  border-radius: 0 var(--radius-md) var(--radius-md) 0;
}

.month-stepper.selected {
  background: var(--selected-background);
  border-color: var(--selected-border);
}

.month-stepper.selected .month-label {
  border-color: var(--selected-border);
  color: var(--selected-color);
}

.month-label {
  align-items: center;
  background: transparent;
  border-radius: 0;
  cursor: pointer;
  display: inline-flex;
  font-weight: normal;
  justify-content: center;
  line-height: var(--line-height);
  min-width: 9rem;
  padding: 0.5rem 0.75rem;
  text-align: center;
}

.month-stepper .month-label {
  border: none;
  border-left: 1px solid var(--border-medium);
  border-right: 1px solid var(--border-medium);
}

/* A label that is not a button (the quarter, the trend's months) */
span.month-label {
  cursor: default;
}

.month-stepper button:disabled {
  color: var(--color-faint);
  cursor: not-allowed;
}

.month-stepper button:disabled:hover {
  background: transparent;
  color: var(--color-faint);
}

/*------------------------------------------------
 * Form layouts
 * ------------------------------------------------*/

.form-compact {
  display: grid;
  gap: 1rem;
}

.form-compact select,
.form-compact input[type="date"],
.form-compact input[type="time"],
.form-compact input[type="text"],
.form-compact input[type="password"],
.form-compact input[type="number"],
.form-compact input[type="email"],
.form-compact textarea {
  box-sizing: border-box;
  max-width: 100%;
  width: 100%;
}

/* A grid item that gives way to its column (min-width) rather than
   hiding its overflow, which clipped the field's focus ring at the sides */
.form-compact .form-group {
  max-width: 100%;
  min-width: 0;
}

.form-compact .form-group label {
  display: block;
  margin-bottom: 0.5rem;
}

.edit-note .form-select {
  max-width: 12.5rem;
}
