/* =========================================================
   Form components
   --------------------------------------------------------
   Use either standalone .form-input or wrap the Django field
   inside .form-field — descendant selectors will style any
   <input>, <select>, <textarea> consistently.
   ========================================================= */

.form-field {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  min-width: 0;
}

.form-field__label {
  font-size: var(--text-sm);
  font-weight: 600;
  color: var(--text);
  letter-spacing: -0.005em;
}

.form-field__hint {
  font-size: var(--text-xs);
  color: var(--text-subtle);
  line-height: var(--leading-snug);
}

.form-field__error {
  font-size: var(--text-xs);
  color: var(--danger-600);
  font-weight: 600;
}

/* Inputs */
.form-input,
.form-field input:not([type="checkbox"]):not([type="radio"]):not([type="file"]):not([type="submit"]):not([type="button"]),
.form-field select,
.form-field textarea {
  appearance: none;
  -webkit-appearance: none;
  width: 100%;
  min-height: 46px;
  padding: 0.75rem 0.95rem;
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  font: inherit;
  font-size: var(--text-base);
  line-height: 1.4;
  box-shadow: var(--shadow-xs);
  transition:
    border-color var(--t-fast),
    box-shadow var(--t-fast),
    background var(--t-fast);
}

.form-field textarea {
  min-height: 110px;
  resize: vertical;
}

.form-input::placeholder,
.form-field input::placeholder,
.form-field textarea::placeholder {
  color: var(--text-subtle);
  font-size: var(--text-sm);
}

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

.form-input:disabled,
.form-field input:disabled,
.form-field select:disabled,
.form-field textarea:disabled {
  background: var(--surface-3);
  color: var(--text-muted);
  cursor: not-allowed;
}

/* Error state */
.form-field--error .form-field__label {
  color: var(--danger-600);
}
.form-field--error input,
.form-field--error select,
.form-field--error textarea,
.form-field--error .form-input {
  border-color: var(--danger-500);
  box-shadow: 0 0 0 4px rgba(239, 68, 68, 0.15);
}

/* Icon prefixed input */
.form-field--has-icon {
  position: relative;
}
.form-field--has-icon .form-field__icon {
  position: absolute;
  left: 0.95rem;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-subtle);
  pointer-events: none;
}
.form-field--has-icon .form-field__icon svg {
  width: 18px;
  height: 18px;
}
.form-field--has-icon .form-input,
.form-field--has-icon input {
  padding-left: 2.6rem;
}

/* Layouts */
.form-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: var(--space-4);
}

@media (min-width: 720px) {
  .form-grid--2 {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

/* Django default markup */
.form-field ul.errorlist {
  list-style: none;
  padding: 0;
  margin: 0;
  color: var(--danger-600);
  font-size: var(--text-xs);
  font-weight: 600;
}

.form-field .helptext,
.form-field .helptext * {
  font-size: var(--text-xs);
  color: var(--text-subtle);
  line-height: var(--leading-snug);
}

/* Checkbox / radio polish */
.form-field input[type="checkbox"],
.form-field input[type="radio"] {
  width: 18px;
  height: 18px;
  accent-color: var(--brand-600);
}
