/* Form Components */
.form {
  max-width: 100%;
}

/* Form Group */
.form__group {
  margin-bottom: var(--spacing-lg);
}

.form__group:last-child {
  margin-bottom: 0;
}

/* Form Label */
.form__label {
  display: block;
  font-size: var(--font-size-sm);
  font-weight: 500;
  color: var(--color-gray-700);
  margin-bottom: var(--spacing-xs);
}

.form__label--required::after {
  content: " *";
  color: var(--color-danger);
}

.form__required {
  color: var(--color-danger);
  margin-left: var(--spacing-xs);
}

/* Form Input Base */
.form__input,
.form__textarea,
.form__select {
  display: block;
  width: 100%;
  padding: var(--spacing-sm) var(--spacing-md);
  font-family: inherit;
  font-size: var(--font-size-sm);
  line-height: var(--line-height-normal);
  color: var(--color-gray-900);
  background-color: white;
  border: 1px solid var(--color-gray-300);
  border-radius: var(--radius-md);
  transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
  -webkit-appearance: none;
  -moz-appearance: none;
  appearance: none;
}

.form__input:focus,
.form__textarea:focus,
.form__select:focus {
  outline: none;
  border-color: var(--color-primary-500);
  box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.1);
}

.form__input::placeholder,
.form__textarea::placeholder {
  color: var(--color-gray-400);
}

/* Textarea Specific */
.form__textarea {
  min-height: 120px;
  resize: vertical;
}

/* Select Specific */
.form__select {
  background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 20 20'%3e%3cpath stroke='%236b7280' stroke-linecap='round' stroke-linejoin='round' stroke-width='1.5' d='M6 8l4 4 4-4'/%3e%3c/svg%3e");
  background-position: right var(--spacing-sm) center;
  background-repeat: no-repeat;
  background-size: 20px;
  padding-right: var(--spacing-xl);
}

/* Form Help Text */
.form__help {
  font-size: var(--font-size-sm);
  color: var(--color-gray-600);
  margin-top: var(--spacing-xs);
}

/* Form Error States */
.form__group--error .form__input,
.form__group--error .form__textarea,
.form__group--error .form__select {
  border-color: var(--color-danger);
}

.form__group--error .form__input:focus,
.form__group--error .form__textarea:focus,
.form__group--error .form__select:focus {
  border-color: var(--color-danger);
  box-shadow: 0 0 0 3px rgba(239, 68, 68, 0.1);
}

/* HTML5 Validation States */
.form__input:invalid,
.form__textarea:invalid,
.form__select:invalid {
  border-color: var(--color-danger);
}

.form__input:invalid:focus,
.form__textarea:invalid:focus,
.form__select:invalid:focus {
  border-color: var(--color-danger);
  box-shadow: 0 0 0 3px rgba(239, 68, 68, 0.1);
}

.form__input:valid:focus,
.form__textarea:valid:focus,
.form__select:valid:focus {
  border-color: var(--color-success);
  box-shadow: 0 0 0 3px rgba(34, 197, 94, 0.1);
}

/* Disable validation styles until user interacts */
.form__input:not(:focus):invalid,
.form__textarea:not(:focus):invalid,
.form__select:not(:focus):invalid {
  border-color: var(--color-gray-300);
}

/* Form Actions */
.form__actions {
  display: flex;
  gap: var(--spacing-md);
  margin-top: var(--spacing-xl);
  padding-top: var(--spacing-lg);
  border-top: 1px solid var(--color-gray-200);
}

.form__actions--right {
  justify-content: flex-end;
}

/* Inline Form Elements */
.form__inline {
  display: flex;
  gap: var(--spacing-md);
  align-items: flex-start;
}

.form__inline .form__group {
  flex: 1;
  margin-bottom: 0;
}


/* Disabled State */
.form__input:disabled,
.form__textarea:disabled,
.form__select:disabled {
  background-color: var(--color-gray-100);
  color: var(--color-gray-500);
  cursor: not-allowed;
}

/* Small Variants */
.form__input--small,
.form__select--small {
  padding: var(--spacing-xs) var(--spacing-sm);
  font-size: var(--font-size-xs);
}

/* Form Errors Display */
.form__errors {
  background-color: #fef2f2;
  border: 1px solid #fecaca;
  border-radius: var(--radius-md);
  padding: var(--spacing-md);
  margin-bottom: var(--spacing-lg);
}

.form__errors h3 {
  font-size: var(--font-size-base);
  margin-bottom: var(--spacing-sm);
}

.form__errors ul {
  margin: 0;
  padding-left: var(--spacing-lg);
}

/* Form Section Title */
.form__section-title {
  font-size: var(--font-size-lg);
  font-weight: 600;
  margin-bottom: var(--spacing-sm);
  color: var(--color-gray-900);
}