/* =========================================
   BRIGHTSMILE DENTAL — FORMS
   All form elements + validation states
   ========================================= */

/* ── Form Group ── */
.form-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: var(--space-3);
}

.form-group--inline {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--space-3);
}

@media (max-width: 640px) {
  .form-group--inline {
    grid-template-columns: 1fr;
  }
}

/* ── Label ── */
.form-label {
  font-size: var(--text-sm);
  font-weight: var(--weight-semibold);
  color: var(--color-navy);
  display: block;
}

.form-label--required::after {
  content: ' *';
  color: var(--color-teal);
}

/* ── Input, Select, Textarea ── */
.form-input,
.form-select,
.form-textarea {
  width: 100%;
  padding: 12px var(--space-2);
  font-family: var(--font-body);
  font-size: var(--text-base);
  color: var(--color-text-primary);
  background-color: var(--color-white);
  border: 1.5px solid var(--color-border);
  border-radius: var(--radius-sm);
  transition:
    border-color 160ms var(--ease-out-expo),
    box-shadow 160ms var(--ease-out-expo),
    background-color 160ms ease;
  appearance: none;
  -webkit-appearance: none;
  min-height: 48px;
  line-height: var(--leading-normal);
}

.form-input::placeholder,
.form-textarea::placeholder {
  color: var(--color-text-muted);
}

.form-input:hover,
.form-select:hover,
.form-textarea:hover {
  border-color: #CBD5E0;
}

.form-input:focus,
.form-select:focus,
.form-textarea:focus {
  border-color: var(--color-teal);
  box-shadow: 0 0 0 3px rgba(13, 148, 136, 0.12);
  background-color: #f8fffe;
  outline: none;
}

.form-input:focus-visible,
.form-select:focus-visible,
.form-textarea:focus-visible {
  border-color: var(--color-teal);
  box-shadow: 0 0 0 3px rgba(13, 148, 136, 0.12);
  background-color: #f8fffe;
  outline: none;
}

/* Textarea */
.form-textarea {
  min-height: 120px;
  resize: vertical;
  line-height: var(--leading-relaxed);
}

/* Select arrow */
.form-select {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%234A5568' 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: right 12px center;
  background-size: 16px;
  padding-right: 40px;
  cursor: pointer;
}

/* ── Validation States ── */
.form-input--error,
.form-select--error,
.form-textarea--error {
  border-color: var(--color-error);
  background-color: var(--color-error-bg);
  animation: shake 0.38s cubic-bezier(0.36, 0.07, 0.19, 0.97) both;
}

.form-input--error:focus,
.form-select--error:focus,
.form-textarea--error:focus {
  border-color: var(--color-error);
  box-shadow: 0 0 0 3px rgba(220, 38, 38, 0.12);
}

.form-input--success,
.form-select--success,
.form-textarea--success {
  border-color: var(--color-success);
}

/* ── Error Message ── */
.form-error {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: var(--text-xs);
  color: var(--color-error);
  font-weight: var(--weight-medium);
  margin-top: 4px;
}

.form-error svg {
  flex-shrink: 0;
  width: 14px;
  height: 14px;
}

/* ── Hint ── */
.form-hint {
  font-size: var(--text-xs);
  color: var(--color-text-muted);
  margin-top: 4px;
  line-height: var(--leading-normal);
}

/* ── Checkbox & Radio (custom) ── */
.form-check {
  display: flex;
  align-items: flex-start;
  gap: var(--space-2);
  cursor: pointer;
  padding-block: 4px;
  min-height: 44px;
}

.form-check input[type="checkbox"],
.form-check input[type="radio"] {
  appearance: none;
  -webkit-appearance: none;
  width: 20px;
  height: 20px;
  border: 2px solid var(--color-border);
  background-color: var(--color-white);
  cursor: pointer;
  flex-shrink: 0;
  margin-top: 2px;
  transition:
    border-color var(--transition-fast),
    background-color var(--transition-fast),
    box-shadow var(--transition-fast);
}

.form-check input[type="checkbox"] {
  border-radius: var(--radius-sm);
}

.form-check input[type="radio"] {
  border-radius: var(--radius-circle);
}

.form-check input[type="checkbox"]:checked {
  background-color: var(--color-teal);
  border-color: var(--color-teal);
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='white' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='20 6 9 17 4 12'/%3E%3C/svg%3E");
  background-size: 12px;
  background-repeat: no-repeat;
  background-position: center;
}

.form-check input[type="radio"]:checked {
  border-color: var(--color-teal);
  background-color: var(--color-white);
  box-shadow: inset 0 0 0 4px var(--color-teal);
}

.form-check input:focus-visible {
  outline: 2px solid var(--color-teal);
  outline-offset: 2px;
}

.form-check:hover input {
  border-color: var(--color-teal);
}

.form-check__label {
  font-size: var(--text-sm);
  color: var(--color-text-secondary);
  line-height: var(--leading-relaxed);
  cursor: pointer;
}

.form-check__label a {
  color: var(--color-teal);
  text-decoration: underline;
}

/* ── Radio Tile (service selector style) ── */
.radio-tile {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  padding: var(--space-3) var(--space-2);
  border: 2px solid var(--color-border);
  border-radius: var(--radius-lg);
  cursor: pointer;
  transition:
    border-color 160ms var(--ease-out-expo),
    background-color 160ms var(--ease-out-expo),
    box-shadow 200ms var(--ease-out-expo),
    transform 140ms var(--ease-spring);
  text-align: center;
}

.radio-tile:active {
  transform: scale(0.96);
}

.radio-tile input[type="radio"] {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.radio-tile:has(input:checked) {
  border-color: var(--color-teal);
  background-color: var(--color-muted-mint);
  box-shadow: 0 0 0 3px rgba(13, 148, 136, 0.10);
}

.radio-tile:has(input:checked) .radio-tile__icon {
  color: var(--color-teal);
}

.radio-tile:has(input:checked) .radio-tile__label {
  color: var(--color-teal);
  font-weight: var(--weight-semibold);
}

.radio-tile:hover {
  border-color: var(--color-teal);
  background-color: var(--color-muted-mint);
}

.radio-tile:focus-within {
  outline: 2px solid var(--color-teal);
  outline-offset: 2px;
}

.radio-tile__icon {
  font-size: 1.75rem;
  color: var(--color-text-muted);
  transition: color var(--transition-fast);
}

.radio-tile__label {
  font-size: var(--text-sm);
  font-weight: var(--weight-medium);
  color: var(--color-text-secondary);
  transition: color var(--transition-fast);
}

/* ── Multi-step Stepper ── */
.form-progress {
  background: #f8fafc;
  border: 1px solid #e4eaf3;
  border-radius: 16px;
  padding: 24px 32px 20px;
  margin-bottom: 36px;
}

/* Hide the thin bar — stepper connectors replace it */
.form-progress__bar {
  display: none;
}

.form-progress__steps {
  display: flex;
  align-items: flex-start;
}

.form-progress__step {
  display: flex;
  flex-direction: column;
  align-items: center;
  flex: 1;
  position: relative;
  gap: 10px;
}

/* Connector line between steps */
.form-progress__step:not(:last-child)::after {
  content: '';
  position: absolute;
  top: 22px;
  left: calc(50% + 28px);
  right: calc(-50% + 28px);
  height: 2px;
  background-color: #dde3ed;
  border-radius: 2px;
  transition: background-color 400ms ease;
  z-index: 0;
}

.form-progress__step.is-completed:not(:last-child)::after {
  background-color: var(--color-teal);
}

/* Step circle */
.form-progress__num {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  border: 2px solid #d1dae8;
  background: var(--color-white);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  font-weight: 600;
  color: #94a3b8;
  position: relative;
  z-index: 1;
  flex-shrink: 0;
  box-shadow: 0 1px 4px rgba(0,0,0,0.07);
  transition:
    border-color 280ms ease,
    background-color 280ms ease,
    color 280ms ease,
    box-shadow 280ms ease;
}

/* Step label */
.form-progress__label {
  font-size: 12px;
  font-weight: 500;
  color: #94a3b8;
  text-align: center;
  white-space: nowrap;
  letter-spacing: 0.015em;
  transition: color 280ms ease, font-weight 280ms ease;
  line-height: 1.25;
}

/* ── Active step ── */
.form-progress__step.is-active .form-progress__num {
  border-color: var(--color-teal);
  background-color: var(--color-teal);
  color: var(--color-white);
  box-shadow:
    0 0 0 5px rgba(13, 148, 136, 0.13),
    0 2px 10px rgba(13, 148, 136, 0.28);
}

.form-progress__step.is-active .form-progress__label {
  color: #0a7a73;
  font-weight: 600;
}

/* ── Completed step — checkmark ── */
.form-progress__step.is-completed .form-progress__num {
  border-color: var(--color-teal);
  background-color: var(--color-teal);
  color: transparent;
  font-size: 0;
  box-shadow: none;
}

.form-progress__step.is-completed .form-progress__num::before {
  content: '';
  display: block;
  width: 12px;
  height: 7px;
  border-left: 2.5px solid var(--color-white);
  border-bottom: 2.5px solid var(--color-white);
  transform: rotate(-45deg) translate(1px, -1px);
}

.form-progress__step.is-completed .form-progress__label {
  color: #5eada8;
}

/* ── Form Step Container ── */
.form-step {
  display: none;
}

.form-step.is-active {
  display: block;
  animation: slideUp 0.35s var(--ease-out-expo) both;
}

.form-step__title {
  font-family: var(--font-heading);
  font-size: var(--h4-size);
  color: var(--color-navy);
  margin-bottom: var(--space-1);
}

.form-step__subtitle {
  font-size: var(--text-sm);
  color: var(--color-text-muted);
  margin-bottom: var(--space-4);
}

/* ── Form Navigation Buttons ── */
.form-nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: var(--space-5);
  gap: var(--space-2);
}

/* ── Time Slot Grid ── */
.time-slots {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(90px, 1fr));
  gap: var(--space-2);
}

.time-slot {
  padding: 10px var(--space-2);
  border: 2px solid var(--color-border);
  border-radius: var(--radius-md);
  font-size: var(--text-sm);
  font-weight: var(--weight-medium);
  color: var(--color-text-secondary);
  cursor: pointer;
  text-align: center;
  transition:
    border-color 160ms var(--ease-out-expo),
    background-color 160ms var(--ease-out-expo),
    color 160ms ease,
    box-shadow 180ms ease,
    transform 130ms var(--ease-spring);
  background: var(--color-white);
}

.time-slot:active:not(.is-disabled) {
  transform: scale(0.93);
}

.time-slot:hover:not(.is-disabled) {
  border-color: var(--color-teal);
  color: var(--color-teal);
  background-color: var(--color-muted-mint);
}

.time-slot.is-selected {
  border-color: var(--color-teal);
  background-color: var(--color-teal);
  color: var(--color-white);
  box-shadow: 0 2px 8px rgba(13, 148, 136, 0.25);
  animation: pop 0.28s var(--ease-spring) both;
}

.time-slot.is-disabled {
  opacity: 0.35;
  cursor: not-allowed;
  background-color: var(--color-light-gray);
}

/* ── Confirmation Card ── */
.booking-summary {
  background-color: var(--color-soft-blue);
  border-radius: var(--radius-xl);
  padding: var(--space-4);
  border: 1px solid rgba(13, 148, 136, 0.15);
}

.booking-summary__item {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  padding-block: var(--space-2);
  border-bottom: 1px solid var(--color-border);
  gap: var(--space-3);
}

.booking-summary__item:last-child {
  border-bottom: none;
}

.booking-summary__label {
  font-size: var(--text-sm);
  color: var(--color-text-muted);
  font-weight: var(--weight-medium);
}

.booking-summary__value {
  font-size: var(--text-sm);
  color: var(--color-navy);
  font-weight: var(--weight-semibold);
  text-align: right;
}

/* ── Success Screen ── */
.booking-success {
  text-align: center;
  padding: var(--space-8) var(--space-4);
  display: none;
}

.booking-success.is-visible {
  display: block;
  animation: scaleIn 0.4s var(--ease-spring) both;
}

.booking-success__icon {
  width: 80px;
  height: 80px;
  border-radius: var(--radius-circle);
  background-color: var(--color-success-bg);
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0 auto var(--space-3);
  color: var(--color-success);
}

.booking-success__number {
  display: inline-flex;
  align-items: center;
  gap: var(--space-1);
  padding: 8px var(--space-3);
  background-color: var(--color-soft-blue);
  border-radius: var(--radius-pill);
  font-size: var(--text-sm);
  font-weight: var(--weight-semibold);
  color: var(--color-navy);
  margin: var(--space-2) auto;
}
