/* ── Shared form field styling ── */
/* Add the .form-field--dark modifier when the field sits on a dark background (e.g., the navy sidebar). */

.form-field {
  margin-bottom: var(--space-5);
}

.form-field label,
.form-field legend {
  display: block;
  font-size: 0.875rem;
  font-weight: 700;
  color: var(--color-text-strong);
  margin-bottom: 0;
  padding: 0;
}

/* Lets a <fieldset> take on .form-field's spacing without the browser's default
   border/padding/min-width, for radio/checkbox groups that need a <legend>. */
.form-fieldset {
  border: none;
  padding: 0;
  min-width: 0;
}

.form-field input:not([type="checkbox"]),
.form-field select,
.form-field textarea {
  width: 100%;
  box-sizing: border-box;
  background: transparent;
  border: none;
  border-bottom: 1px solid #000;
  border-radius: var(--space-1) var(--space-1) 0 0;
  padding: var(--space-1);
  font-size: 0.9375rem;
  color: var(--color-text-primary);
  font-family: inherit;
  background-color: rgba(0, 0, 0, 0.03);
}

.form-field textarea {
  resize: vertical;
  min-height: 4rem;
}

.form-field select {
  appearance: none;
  -webkit-appearance: none;
  -moz-appearance: none;
  padding-right: 1.25rem;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23000000' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: 98% center;
  background-size: 1rem;
}

.form-field--dark select {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23ffffff' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E");
}

.form-field input[type="number"]::-webkit-inner-spin-button,
.form-field input[type="number"]::-webkit-outer-spin-button {
  -webkit-appearance: none;
}

.form-field input[type="number"] {
  -moz-appearance: textfield;
}

.form-field input::placeholder,
.form-field textarea::placeholder {
  color: rgba(0, 0, 0, 0.5);
}

.form-field input:focus,
.form-field select:focus,
.form-field textarea:focus {
  outline: none;
  box-shadow: var(--focus-ring-shadow);
  background-color: var(--focus-ring-bg);
}

/* ── Dark background modifier ── */
.form-field--dark label {
  color: var(--color-white);
}

.form-field--dark input,
.form-field--dark input:not([type="checkbox"]) {
  background: transparent;
  color: var(--color-white);
  border-bottom-color: rgba(255, 255, 255, 0.35);
}

.form-field--dark input::placeholder {
  color: rgba(255, 255, 255, 0.4);
}

.form-field--dark input:focus {
  border-bottom: 1px solid var(--color-accent-green);
}

/* ── Prefixed amount input (e.g., "$") ── */

.form-field .amount-field {
  display: flex;
  align-items: baseline;
  border-bottom: 1px solid #000;
}

.form-field--dark .amount-field {
  border-bottom-color: rgba(255, 255, 255, 0.35);
}

.form-field .amount-field:focus-within {
  border-bottom: 1px solid var(--color-brand-blue);
}

.form-field--dark .amount-field:focus-within {
  border-bottom: 1px solid var(--color-accent-green);
}

.form-field .amount-field input {
  border-bottom: none;
  flex: 1;
}

.amount-field-prefix {
  font-size: 0.9375rem;
  color: var(--color-text-primary);
}

.amount-field:has(input:placeholder-shown) .amount-field-prefix {
  display: none;
}

.form-field--dark .amount-field-prefix {
  color: var(--color-white);
}

/* ── Checkbox ── */

.form-checkbox {
  width: 1.125rem;
  height: 1.125rem;
  margin: 0;
  cursor: pointer;
  accent-color: var(--color-brand-blue);
  flex-shrink: 0;
}

/* ── Validation ── */

.valid.modified:not([type="checkbox"]) {
  outline: none;
  border-bottom: 2px solid var(--color-success-accent);
  padding-bottom: calc(0.5rem - 1px);
}

.form-field input.invalid,
.form-field textarea.invalid {
  outline: none;
  border-bottom: 2px solid var(--color-validation-error);
  padding-bottom: calc(0.5rem - 1px);
}

.validation-message {
  color: var(--color-validation-error);
  font-size: 0.8125rem;
  margin-top: var(--space-2);
}
