/* ==========================================================================
   Forms — Extends components.css form tokens
   Only styles that don't exist in components.css
   ========================================================================== */

/* Disabled fieldset during submission */
form fieldset:disabled {
  opacity: 0.6;
  pointer-events: none;
}

/* Required asterisk */
.label__required {
  color: var(--error);
  margin-left: 2px;
}

/* Styled select */
.form__select {
  display: block;
  width: 100%;
  padding: var(--space-3) var(--space-4);
  padding-right: var(--space-8);
  font-family: var(--font-body);
  font-size: var(--text-base);
  line-height: var(--leading-normal);
  color: var(--charcoal-900);
  background-color: var(--white);
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%2378716c' stroke-width='2'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right var(--space-3) center;
  background-size: 16px;
  border: 1px solid var(--gray-300);
  border-radius: var(--radius-md);
  appearance: none;
  -webkit-appearance: none;
  cursor: pointer;
  transition:
    border-color var(--duration-fast) var(--ease-default),
    box-shadow var(--duration-fast) var(--ease-default);
}

.form__select:hover {
  border-color: var(--gray-400);
}

.form__select:focus {
  outline: none;
  border-color: var(--gold-500);
  box-shadow: var(--shadow-focus);
}

.form__select.input--error {
  border-color: var(--error);
}

.form__select:disabled {
  opacity: 0.6;
  cursor: not-allowed;
  pointer-events: none;
}

/* Submit button wrapper — relative for spinner overlay */
.form__submit {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
}

/* CSS-only spinner */
.form__btn-spinner {
  display: none;
  width: 18px;
  height: 18px;
  border: 2px solid rgba(255, 255, 255, 0.3);
  border-top-color: var(--white);
  border-radius: 50%;
  animation: form-spin 0.6s linear infinite;
}

.form__submit--loading .form__btn-spinner {
  display: inline-block;
}

.form__submit--loading .form__btn-label {
  opacity: 0.7;
}

@keyframes form-spin {
  to {
    transform: rotate(360deg);
  }
}

/* Success message */
.form__success {
  display: none;
  padding: var(--space-6);
  background-color: var(--success-light);
  border: 1px solid var(--success);
  border-radius: var(--radius-md);
  text-align: center;
  color: var(--charcoal-900);
}

.form__success.is-visible {
  display: block;
}

.form__success-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 48px;
  height: 48px;
  margin: 0 auto var(--space-3);
  background-color: var(--success);
  border-radius: 50%;
  color: var(--white);
}

.form__success-title {
  font-family: var(--font-display);
  font-size: var(--text-lg);
  font-weight: 600;
  margin-bottom: var(--space-2);
}

.form__success-text {
  font-size: var(--text-base);
  color: var(--charcoal-700);
}

/* Global error banner */
.form__error-global {
  display: none;
  padding: var(--space-4);
  margin-bottom: var(--space-4);
  background-color: var(--error-light);
  border: 1px solid var(--error);
  border-radius: var(--radius-md);
  color: var(--error);
  font-size: var(--text-sm);
  text-align: center;
}

.form__error-global.is-visible {
  display: block;
}

/* ==========================================================================
   Unit Count — Number input + "Not sure" checkbox
   ========================================================================== */

.unit-count-wrapper {
  display: flex;
  align-items: center;
  gap: var(--space-3);
}

.unit-count-wrapper .input {
  flex: 1;
  max-width: 140px;
}

.unit-count-wrapper .input:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.not-sure-toggle {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  cursor: pointer;
  font-size: var(--text-sm);
  color: var(--gray-600);
  white-space: nowrap;
  user-select: none;
}

.not-sure-toggle input[type="checkbox"] {
  width: 18px;
  height: 18px;
  accent-color: var(--gold);
  cursor: pointer;
}

.not-sure-toggle input[type="checkbox"]:checked + span {
  color: var(--gold);
  font-weight: 500;
}

/* ==========================================================================
   Multi-step form (Reality Check)
   ========================================================================== */

/* Progress bar */
.form__progress {
  height: 4px;
  background-color: var(--gray-200);
  border-radius: 2px;
  margin-bottom: var(--space-6);
  overflow: hidden;
}

.form__progress-bar {
  height: 100%;
  background-color: var(--gold-500);
  border-radius: 2px;
  transition: width 0.3s var(--ease-default);
}

/* Step indicator */
.form__step-indicator {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  margin-bottom: var(--space-6);
  font-family: var(--font-body);
  font-size: var(--text-sm);
  color: var(--gray-500);
}

.form__step-indicator-current {
  color: var(--gold-500);
  font-weight: 600;
}

/* Step containers */
.form__step {
  display: none;
}

.form__step.is-active {
  display: block;
}

/* Step title */
.form__step-title {
  font-family: var(--font-display);
  font-size: var(--text-display-md);
  font-weight: 600;
  color: var(--charcoal-900);
  margin-bottom: var(--space-2);
}

.form__step-subtitle {
  font-size: var(--text-base);
  color: var(--gray-500);
  margin-bottom: var(--space-6);
}

/* Radio card options */
.form__options {
  display: grid;
  gap: var(--space-3);
}

.form__option {
  position: relative;
  padding: var(--space-4) var(--space-5);
  background-color: var(--white);
  border: 2px solid var(--gray-200);
  border-radius: var(--radius-md);
  cursor: pointer;
  transition:
    border-color var(--duration-fast) var(--ease-default),
    background-color var(--duration-fast) var(--ease-default);
  font-family: var(--font-body);
  font-size: var(--text-base);
  color: var(--charcoal-900);
  font-weight: 500;
  min-height: var(--touch-target-comfortable, 48px);
  display: flex;
  align-items: center;
}

.form__option:hover {
  border-color: var(--gold-400);
}

.form__option input[type="radio"] {
  position: absolute;
  opacity: 0;
  width: 0;
  height: 0;
}

.form__option-check {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 20px;
  height: 20px;
  margin-right: var(--space-3);
  border: 2px solid var(--gray-300);
  border-radius: 50%;
  flex-shrink: 0;
  transition:
    border-color var(--duration-fast) var(--ease-default),
    background-color var(--duration-fast) var(--ease-default);
}

.form__option input[type="radio"]:checked ~ .form__option-check {
  border-color: var(--gold-500);
  background-color: var(--gold-500);
}

.form__option input[type="radio"]:checked ~ .form__option-check::after {
  content: "";
  width: 8px;
  height: 8px;
  background-color: var(--white);
  border-radius: 50%;
}

.form__option:has(input[type="radio"]:checked) {
  border-color: var(--gold-500);
  background-color: var(--gold-100);
}

.form__option:has(input[type="radio"]:focus-visible) {
  outline: 2px solid var(--gold-500);
  outline-offset: 2px;
}

.form__option input[type="radio"]:focus-visible ~ .form__option-check {
  box-shadow: var(--shadow-focus);
}

/* Step navigation */
.form__nav {
  display: flex;
  gap: var(--space-3);
  margin-top: var(--space-6);
}

.form__nav .btn {
  flex: 1;
}

/* ==========================================================================
   2-Column Form Row
   ========================================================================== */

.form__row {
  display: grid;
  grid-template-columns: 1fr;
  gap: var(--space-4);
}

@media (min-width: 768px) {
  .form__row {
    grid-template-columns: repeat(2, 1fr);
  }
}

.form-group--full {
  grid-column: 1 / -1;
}

/* ==========================================================================
   Fieldset & Legend
   ========================================================================== */

.form__fieldset {
  border: none;
  padding: 0;
  margin: 0 0 var(--space-6) 0;
}

.form__fieldset--reset {
  border: none;
  padding: 0;
  margin: 0;
}

.form__legend {
  display: flex;
  align-items: baseline;
  gap: var(--space-3);
  width: 100%;
  font-family: var(--font-display);
  font-size: var(--text-lg);
  font-weight: 600;
  color: var(--charcoal-900);
  padding-bottom: var(--space-3);
  margin-bottom: var(--space-4);
  border-bottom: 1px solid var(--gray-200);
}

.form__legend-note {
  font-family: var(--font-body);
  font-size: var(--text-sm);
  font-weight: 400;
  color: var(--gray-500);
}

.form__submit--full {
  width: 100%;
}

/* ==========================================================================
   Success Steps
   ========================================================================== */

.form__success-steps {
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
  margin: var(--space-4) 0;
  text-align: left;
  max-width: 360px;
  margin-left: auto;
  margin-right: auto;
}

.form__success-step {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  font-size: var(--text-sm);
  color: var(--charcoal-700);
}

.form__success-step-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 24px;
  height: 24px;
  background-color: var(--gold-500);
  color: var(--white);
  border-radius: 50%;
  font-size: var(--text-xs);
  font-weight: 600;
  flex-shrink: 0;
}

.form__success-cta {
  margin-top: var(--space-4);
  font-size: var(--text-sm);
  color: var(--gray-500);
}

.form__success-cta a {
  color: var(--gold-500);
  font-weight: 500;
  text-decoration: underline;
  text-underline-offset: 2px;
}

/* ==========================================================================
   Textarea height
   ========================================================================== */
textarea.input {
  min-height: 120px;
  resize: vertical;
}

/* ==========================================================================
   Mobile-first: base styles are mobile, enhance for desktop
   ========================================================================== */

/* Prevent iOS zoom on focus (mobile base) */
.input,
.form__select,
textarea.input {
  font-size: 16px;
}

.form__nav {
  flex-direction: column;
}

.form__nav .btn {
  width: 100%;
  min-height: var(--touch-target-comfortable, 48px);
}

.form__step-title {
  font-size: var(--text-xl);
}

.form__option {
  padding: var(--space-4) var(--space-4);
  gap: var(--space-3);
}

/* Ensure select meets touch target on mobile */
.form__select {
  min-height: var(--touch-target-comfortable, 48px);
}

/* Ensure standard inputs meet touch target on mobile */
.input,
textarea.input {
  min-height: var(--touch-target-comfortable, 48px);
}

@media (min-width: 768px) {
  .input,
  .form__select,
  textarea.input {
    font-size: var(--text-base);
  }

  .form__nav {
    flex-direction: row;
  }

  .form__nav .btn {
    width: auto;
    min-height: auto;
  }

  .form__step-title {
    font-size: var(--text-display-md);
  }

  .form__option {
    padding: var(--space-4) var(--space-5);
  }
}

/* ==========================================================================
   Readiness Preview (shown between step 4 and contact step)
   ========================================================================== */

.readiness-preview {
  text-align: center;
  padding: var(--space-4);
  margin-bottom: var(--space-4);
  border-radius: var(--radius-lg);
  background: var(--charcoal-700);
  border: 1px solid var(--charcoal-600);
}

.readiness-preview__badge {
  display: inline-block;
  padding: 6px 16px;
  border-radius: 20px;
  font-size: var(--text-sm);
  font-weight: 600;
  margin-bottom: var(--space-2);
}

.readiness-preview__badge--ready {
  background: var(--gold);
  color: var(--charcoal-900);
}

.readiness-preview__badge--almost {
  background: #3b82f6;
  color: white;
}

.readiness-preview__badge--early {
  background: var(--gray-600);
  color: white;
}

.readiness-preview__text {
  font-size: var(--text-sm);
  color: var(--gray-400);
  margin-bottom: var(--space-3);
}

.readiness-preview__cta {
  margin-top: var(--space-3);
}
