/* ============================================
   Design System - Connect Periodontics
   Brand Colors: Dark Navy Header + White Form + Teal Accent
   (Matching the PDF referral form image)
   ============================================ */

:root {
  /* Brand Palette — from the PDF image */
  --color-navy-900: #1A2332;
  --color-navy-800: #1E293B;
  --color-navy-700: #243447;
  --color-navy-600: #2C3E54;
  --color-navy-500: #3A506B;
  --color-gold-500: #C9A84C;
  --color-gold-400: #D4B85E;
  --color-gold-300: #E8D48B;
  --color-gold-200: #F0E2AE;
  --color-gold-600: #A38A3A;

  /* Teal accent — from the thank-you banner in the PDF */
  --color-teal-600: #2A7B88;
  --color-teal-500: #339DA8;
  --color-teal-400: #3DB8C4;
  --color-teal-100: #E0F5F7;

  /* Neutral Palette */
  --color-white: #FFFFFF;
  --color-gray-50: #F8FAFC;
  --color-gray-100: #F1F5F9;
  --color-gray-200: #E2E8F0;
  --color-gray-300: #CBD5E1;
  --color-gray-400: #94A3B8;
  --color-gray-500: #64748B;
  --color-gray-600: #475569;
  --color-gray-700: #334155;
  --color-gray-800: #1E293B;

  /* Semantic */
  --color-error: #EF4444;
  --color-error-bg: rgba(239, 68, 68, 0.08);
  --color-success: #10B981;
  --color-success-bg: rgba(16, 185, 129, 0.08);

  /* Surfaces — Light theme */
  --surface-page: #F0F2F5;
  --surface-card: #FFFFFF;
  --surface-card-border: var(--color-gray-200);
  --surface-input: #FFFFFF;
  --surface-input-border: var(--color-gray-300);
  --surface-input-focus: var(--color-teal-500);

  /* Text — Dark on light */
  --text-primary: var(--color-navy-900);
  --text-secondary: var(--color-gray-600);
  --text-muted: var(--color-gray-500);
  --text-gold: var(--color-gold-600);

  /* Typography */
  --font-sans: 'Roboto', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  --font-serif: 'Roboto Slab', Georgia, serif;

  /* Spacing */
  --space-xs: 0.25rem;
  --space-sm: 0.5rem;
  --space-md: 1rem;
  --space-lg: 1.5rem;
  --space-xl: 2rem;
  --space-2xl: 3rem;
  --space-3xl: 4rem;

  /* Radius */
  --radius-sm: 0.5rem;
  --radius-md: 0.75rem;
  --radius-lg: 1rem;
  --radius-xl: 1.25rem;
  --radius-full: 9999px;

  /* Shadows — softer for light theme */
  --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.06);
  --shadow-md: 0 4px 14px rgba(0, 0, 0, 0.07);
  --shadow-lg: 0 10px 40px rgba(0, 0, 0, 0.1);
  --shadow-gold: 0 0 20px rgba(201, 168, 76, 0.08);
  --shadow-gold-lg: 0 4px 30px rgba(201, 168, 76, 0.12);

  /* Transitions */
  --transition-fast: 150ms cubic-bezier(0.4, 0, 0.2, 1);
  --transition-base: 250ms cubic-bezier(0.4, 0, 0.2, 1);
  --transition-slow: 400ms cubic-bezier(0.4, 0, 0.2, 1);

  /* Accent color for form controls */
  accent-color: var(--color-teal-500);
}


/* ============================================
   Reset & Base
   ============================================ */

*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  font-size: 16px;
  -webkit-text-size-adjust: 100%;
  scroll-behavior: smooth;
}

body {
  font-family: var(--font-sans);
  background: var(--surface-page);
  color: var(--text-primary);
  line-height: 1.6;
  min-height: 100dvh;
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}


/* ============================================
   Background Orbs (Ambient Animation)
   ============================================ */

.bg-orb {
  position: fixed;
  border-radius: 50%;
  filter: blur(120px);
  opacity: 0.06;
  pointer-events: none;
  z-index: 0;
  will-change: transform;
}

.bg-orb--1 {
  width: 350px;
  height: 350px;
  background: var(--color-teal-400);
  top: -100px;
  right: -100px;
  animation: orbFloat1 18s ease-in-out infinite;
}

.bg-orb--2 {
  width: 250px;
  height: 250px;
  background: var(--color-gold-300);
  bottom: 20%;
  left: -80px;
  animation: orbFloat2 22s ease-in-out infinite;
}

.bg-orb--3 {
  width: 200px;
  height: 200px;
  background: var(--color-teal-500);
  bottom: -50px;
  right: 20%;
  animation: orbFloat3 16s ease-in-out infinite;
}

@keyframes orbFloat1 {
  0%, 100% { transform: translate(0, 0) scale(1); }
  33% { transform: translate(-30px, 40px) scale(1.1); }
  66% { transform: translate(20px, -20px) scale(0.95); }
}

@keyframes orbFloat2 {
  0%, 100% { transform: translate(0, 0) scale(1); }
  50% { transform: translate(40px, -30px) scale(1.08); }
}

@keyframes orbFloat3 {
  0%, 100% { transform: translate(0, 0) scale(1); }
  40% { transform: translate(-25px, 25px) scale(1.05); }
  80% { transform: translate(15px, -15px) scale(0.97); }
}


/* ============================================
   Page Layout
   ============================================ */

.form-page {
  position: relative;
  z-index: 1;
  max-width: 720px;
  margin: 0 auto;
  padding: var(--space-md);
  padding-bottom: var(--space-3xl);
}


/* ============================================
   Header Card
   ============================================ */

.form-header {
  background: var(--color-navy-900);
  border: none;
  border-radius: var(--radius-xl);
  padding: var(--space-lg);
  margin-bottom: var(--space-lg);
  box-shadow: var(--shadow-lg);
  animation: fadeSlideUp 0.6s ease-out;
  color: #FFFFFF;
}

.form-header__logo-area {
  display: flex;
  align-items: center;
  justify-content: flex-start;
  margin-bottom: var(--space-lg);
}

.form-header__logo-img {
  max-height: 64px;
  width: auto;
  max-width: 100%;
  display: block;
  object-fit: contain;
}

.form-header__doctor {
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: var(--radius-md);
  padding: var(--space-sm) var(--space-md);
  margin-bottom: var(--space-lg);
}

.form-header__doctor-name {
  font-size: 1rem;
  font-weight: 700;
  color: #FFFFFF;
}

.form-header__dmd {
  font-style: italic;
  color: var(--color-gold-400);
}

.form-header__doctor-cert {
  font-size: 0.8rem;
  color: var(--color-gold-400);
  font-weight: 500;
  letter-spacing: 0.03em;
}

.form-header__contact {
  display: flex;
  flex-direction: column;
  gap: var(--space-sm);
}

.form-header__contact-item {
  display: flex;
  align-items: flex-start;
  gap: var(--space-sm);
  color: rgba(255, 255, 255, 0.8);
  text-decoration: none;
  font-size: 0.85rem;
  padding: var(--space-xs) var(--space-sm);
  border-radius: var(--radius-sm);
  transition: background var(--transition-fast), color var(--transition-fast);
}

.form-header__contact-item:hover,
.form-header__contact-item:focus-visible {
  background: rgba(255, 255, 255, 0.08);
  color: var(--color-gold-300);
}

.form-header__contact-icon {
  font-size: 0.9rem;
  flex-shrink: 0;
  line-height: 1.6;
}


/* ============================================
   Form Heading
   ============================================ */

.referral-form__heading {
  font-family: var(--font-serif);
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--color-navy-900);
  text-align: center;
  margin-bottom: var(--space-xl);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-sm);
  animation: fadeSlideUp 0.6s ease-out 0.1s both;
}

.referral-form__heading-icon {
  font-size: 1.3rem;
}


/* ============================================
   Form Sections
   ============================================ */

.form-section {
  background: var(--surface-card);
  border: 1px solid var(--surface-card-border);
  border-radius: var(--radius-xl);
  padding: var(--space-lg);
  margin-bottom: var(--space-lg);
  box-shadow: var(--shadow-md);
  animation: fadeSlideUp 0.6s ease-out both;
}

.form-section:nth-child(2) { animation-delay: 0.15s; }
.form-section:nth-child(3) { animation-delay: 0.2s; }
.form-section:nth-child(4) { animation-delay: 0.25s; }
.form-section:nth-child(5) { animation-delay: 0.3s; }
.form-section:nth-child(6) { animation-delay: 0.35s; }
.form-section:nth-child(7) { animation-delay: 0.4s; }

.form-section__legend {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  font-family: var(--font-serif);
  font-size: 1.05rem;
  font-weight: 600;
  color: var(--color-navy-900);
  margin-bottom: var(--space-lg);
  padding-bottom: var(--space-sm);
  border-bottom: 1px solid var(--color-gray-200);
}

.form-section__legend-number {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  border-radius: var(--radius-full);
  background: var(--color-navy-900);
  color: #FFFFFF;
  font-family: var(--font-sans);
  font-size: 0.8rem;
  font-weight: 700;
  flex-shrink: 0;
}

.form-section__hint {
  font-size: 0.82rem;
  color: var(--text-muted);
  margin-bottom: var(--space-md);
  font-style: italic;
}


/* ============================================
   Form Grid
   ============================================ */

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


/* ============================================
   Form Fields
   ============================================ */

.form-field {
  display: flex;
  flex-direction: column;
  gap: var(--space-xs);
}

.form-field__label {
  font-size: 0.82rem;
  font-weight: 500;
  color: var(--color-gray-600);
  letter-spacing: 0.02em;
}

.form-field__required {
  color: var(--color-error);
  font-weight: 700;
}

.form-field__input,
.form-field__textarea {
  background: var(--color-gray-50);
  border: 1.5px solid var(--color-gray-300);
  border-radius: var(--radius-md);
  padding: 0.75rem 1rem;
  font-size: 1rem;
  font-family: var(--font-sans);
  color: var(--color-navy-900);
  transition: border-color var(--transition-base), box-shadow var(--transition-base), background var(--transition-base);
  width: 100%;
}

.form-field__input::placeholder,
.form-field__textarea::placeholder {
  color: var(--color-gray-400);
  opacity: 1;
}

.form-field__input:hover,
.form-field__textarea:hover {
  border-color: var(--color-teal-400);
}

.form-field__input:focus,
.form-field__textarea:focus {
  outline: none;
  border-color: var(--color-teal-500);
  box-shadow: 0 0 0 3px rgba(51, 157, 168, 0.12);
  background: #FFFFFF;
}

.form-field__input:user-invalid {
  border-color: var(--color-error);
  box-shadow: 0 0 0 3px var(--color-error-bg);
}

.form-field__textarea {
  resize: vertical;
  min-height: 90px;
}

/* Date input fix */
.form-field__input[type="date"] {
  color-scheme: light;
}

.form-field--other {
  margin-top: var(--space-md);
  animation: fadeSlideUp 0.3s ease-out;
}


/* ============================================
   Checkbox Cards (Procedures)
   ============================================ */

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

.checkbox-card {
  display: flex;
  align-items: center;
  gap: var(--space-md);
  padding: 0.85rem 1rem;
  background: var(--color-gray-50);
  border: 1.5px solid var(--color-gray-200);
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: all var(--transition-base);
  user-select: none;
  -webkit-user-select: none;
  -webkit-tap-highlight-color: transparent;
}

.checkbox-card:hover {
  border-color: var(--color-teal-400);
  background: var(--color-teal-100);
}

.checkbox-card:has(input:checked) {
  border-color: var(--color-teal-500);
  background: var(--color-teal-100);
  box-shadow: 0 0 0 1px rgba(51, 157, 168, 0.2);
}

.checkbox-card input[type="checkbox"] {
  position: absolute;
  opacity: 0;
  width: 0;
  height: 0;
  pointer-events: none;
}

.checkbox-card__check {
  position: relative;
  flex-shrink: 0;
  width: 22px;
  height: 22px;
  border-radius: 6px;
  border: 2px solid var(--color-gray-400);
  transition: all var(--transition-base);
}

.checkbox-card__check::after {
  content: '';
  position: absolute;
  top: 3px;
  left: 6px;
  width: 5px;
  height: 10px;
  border: solid #FFFFFF;
  border-width: 0 2.5px 2.5px 0;
  transform: rotate(45deg) scale(0);
  transition: transform var(--transition-fast);
}

.checkbox-card:has(input:checked) .checkbox-card__check {
  background: var(--color-teal-500);
  border-color: var(--color-teal-500);
}

.checkbox-card:has(input:checked) .checkbox-card__check::after {
  transform: rotate(45deg) scale(1);
}

.checkbox-card:has(input:focus-visible) {
  outline: 2px solid var(--color-teal-400);
  outline-offset: 2px;
}

.checkbox-card__label {
  font-size: 0.9rem;
  color: var(--color-navy-900);
  line-height: 1.4;
}


/* ============================================
   Radio Cards (X-Ray Options)
   ============================================ */

.radio-cards {
  display: flex;
  flex-direction: column;
  gap: var(--space-sm);
}

.radio-card {
  display: flex;
  align-items: flex-start;
  gap: var(--space-md);
  padding: 1rem;
  background: var(--color-gray-50);
  border: 1.5px solid var(--color-gray-200);
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: all var(--transition-base);
  user-select: none;
  -webkit-user-select: none;
  -webkit-tap-highlight-color: transparent;
}

.radio-card:hover {
  border-color: var(--color-teal-400);
}

.radio-card:has(input:checked) {
  border-color: var(--color-teal-500);
  background: var(--color-teal-100);
  box-shadow: 0 0 0 1px rgba(51, 157, 168, 0.15);
}

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

.radio-card__indicator {
  position: relative;
  flex-shrink: 0;
  width: 22px;
  height: 22px;
  border-radius: var(--radius-full);
  border: 2px solid var(--color-gray-400);
  margin-top: 2px;
  transition: all var(--transition-base);
}

.radio-card__indicator::after {
  content: '';
  position: absolute;
  top: 50%;
  left: 50%;
  width: 10px;
  height: 10px;
  border-radius: var(--radius-full);
  background: var(--color-teal-500);
  transform: translate(-50%, -50%) scale(0);
  transition: transform var(--transition-fast);
}

.radio-card:has(input:checked) .radio-card__indicator {
  border-color: var(--color-teal-500);
}

.radio-card:has(input:checked) .radio-card__indicator::after {
  transform: translate(-50%, -50%) scale(1);
}

.radio-card:has(input:focus-visible) {
  outline: 2px solid var(--color-teal-400);
  outline-offset: 2px;
}

.radio-card__title {
  display: block;
  font-size: 0.92rem;
  font-weight: 600;
  color: var(--color-navy-900);
  margin-bottom: 2px;
}

.radio-card__desc {
  display: block;
  font-size: 0.78rem;
  color: var(--color-gray-500);
  line-height: 1.4;
}


/* ============================================
   Teeth Chart
   ============================================ */

.teeth-chart {
  background: var(--color-gray-50);
  border: 1px solid var(--color-gray-200);
  border-radius: var(--radius-lg);
  padding: var(--space-md);
  margin-bottom: var(--space-md);
}

.teeth-chart__jaw {
  display: flex;
  align-items: center;
  gap: 4px;
}

/* Hide RIGHT/LEFT labels on mobile — not enough space */
.teeth-chart__side-label {
  display: none;
  font-size: 0.6rem;
  color: var(--color-gray-500);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  flex-shrink: 0;
  width: 32px;
  text-align: center;
  font-weight: 600;
}

/* Mobile: 4 columns per quadrant → 2 rows of 4 teeth */
.teeth-chart__quadrant {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 5px;
  flex: 1;
}

.teeth-chart__midline {
  width: 2px;
  align-self: stretch;
  background: var(--color-gray-300);
  border-radius: 1px;
  margin: 2px 4px;
  flex-shrink: 0;
}

.teeth-chart__tooth {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  aspect-ratio: 1;
  min-width: 0;
  border-radius: var(--radius-sm);
  border: 1.5px solid var(--color-gray-300);
  background: #FFFFFF;
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--color-gray-600);
  cursor: pointer;
  transition: all var(--transition-fast);
  user-select: none;
  -webkit-user-select: none;
  -webkit-tap-highlight-color: transparent;
  padding: 0;
}

.teeth-chart__tooth:hover {
  border-color: var(--color-teal-400);
  color: var(--color-teal-600);
  background: var(--color-teal-100);
}

.teeth-chart__tooth.is-selected {
  background: var(--color-navy-900);
  border-color: var(--color-navy-900);
  color: #FFFFFF;
  box-shadow: 0 2px 8px rgba(26, 35, 50, 0.25);
  transform: scale(1.05);
}

.teeth-chart__tooth:focus-visible {
  outline: 2px solid var(--color-teal-400);
  outline-offset: 2px;
}

.teeth-chart__divider {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  margin: var(--space-sm) 0;
  padding: 0 4px;
}

.teeth-chart__divider-line {
  flex: 1;
  height: 1px;
  background: var(--color-gray-300);
}

.teeth-chart__divider-label {
  font-size: 0.65rem;
  color: var(--color-gray-500);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  white-space: nowrap;
}

.teeth-chart__selected {
  display: flex;
  align-items: flex-start;
  gap: var(--space-sm);
  font-size: 0.82rem;
  color: var(--color-gray-600);
  padding: var(--space-sm);
  background: var(--color-teal-100);
  border-radius: var(--radius-sm);
}

.teeth-chart__selected-label {
  font-weight: 600;
  color: var(--color-teal-600);
  flex-shrink: 0;
}

.teeth-chart__selected-list {
  color: var(--color-navy-900);
}


/* ============================================
   Submit Section
   ============================================ */

.form-submit {
  text-align: center;
  padding: var(--space-xl) 0;
  animation: fadeSlideUp 0.6s ease-out 0.5s both;
}

.form-submit__button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-sm);
  width: 100%;
  max-width: 400px;
  padding: 1rem 2rem;
  background: var(--color-navy-900);
  color: #FFFFFF;
  border: none;
  border-radius: var(--radius-full);
  font-family: var(--font-sans);
  font-size: 1.05rem;
  font-weight: 700;
  letter-spacing: 0.02em;
  cursor: pointer;
  transition: all var(--transition-base);
  box-shadow: 0 4px 20px rgba(26, 35, 50, 0.25);
  position: relative;
  overflow: hidden;
}

.form-submit__button::before {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(135deg, transparent, rgba(255, 255, 255, 0.08), transparent);
  transform: translateX(-100%);
  transition: transform 0.6s ease;
}

.form-submit__button:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 30px rgba(26, 35, 50, 0.35);
  background: var(--color-navy-700);
}

.form-submit__button:hover::before {
  transform: translateX(100%);
}

.form-submit__button:active {
  transform: translateY(0);
  box-shadow: 0 2px 10px rgba(26, 35, 50, 0.2);
}

.form-submit__button:focus-visible {
  outline: 2px solid var(--color-teal-400);
  outline-offset: 3px;
}

.form-submit__button:disabled {
  opacity: 0.6;
  cursor: not-allowed;
  transform: none;
}

.form-submit__button-icon svg {
  transition: transform var(--transition-base);
}

.form-submit__button:hover .form-submit__button-icon svg {
  transform: translate(2px, -2px);
}

.form-submit__disclaimer {
  margin-top: var(--space-md);
  font-size: 0.72rem;
  color: var(--color-gray-500);
  max-width: 400px;
  margin-inline: auto;
  line-height: 1.5;
}


/* ============================================
   Thank You Banner
   ============================================ */

.form-thankyou {
  background: var(--color-teal-600);
  border: none;
  border-radius: var(--radius-lg);
  padding: var(--space-md) var(--space-lg);
  text-align: center;
  margin-top: var(--space-md);
}

.form-thankyou__text {
  font-family: var(--font-serif);
  font-size: 0.88rem;
  color: #FFFFFF;
  font-weight: 500;
  line-height: 1.5;
}


/* ============================================
   Success Modal (using <dialog>)
   ============================================ */

.success-modal {
  border: none;
  border-radius: var(--radius-xl);
  background: #FFFFFF;
  color: var(--color-navy-900);
  padding: var(--space-2xl);
  max-width: min(90vw, 420px);
  width: min(90vw, 420px);
  box-shadow: var(--shadow-lg);
  animation: modalSlideUp 0.4s ease-out;
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  margin: 0;
}

.success-modal::backdrop {
  background: rgba(26, 35, 50, 0.6);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
}

.success-modal__content {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: var(--space-md);
}

.success-modal__icon {
  animation: successPop 0.5s ease-out 0.2s both;
}

.success-modal__circle {
  stroke-dasharray: 190;
  stroke-dashoffset: 190;
  animation: drawCircle 0.8s ease-out 0.3s forwards;
}

.success-modal__check {
  stroke-dasharray: 40;
  stroke-dashoffset: 40;
  animation: drawCheck 0.5s ease-out 0.8s forwards;
}

.success-modal__title {
  font-family: var(--font-serif);
  font-size: 1.4rem;
  font-weight: 700;
  color: var(--color-teal-600);
}

.success-modal__message {
  font-size: 0.9rem;
  color: var(--color-gray-600);
  line-height: 1.6;
}

.success-modal__button {
  padding: 0.75rem 2.5rem;
  background: var(--color-navy-900);
  color: #FFFFFF;
  border: none;
  border-radius: var(--radius-full);
  font-family: var(--font-sans);
  font-size: 0.95rem;
  font-weight: 600;
  cursor: pointer;
  transition: all var(--transition-base);
  margin-top: var(--space-sm);
}

.success-modal__button:hover {
  background: var(--color-navy-700);
  box-shadow: var(--shadow-md);
  transform: translateY(-1px);
}

.success-modal__button:focus-visible {
  outline: 2px solid var(--color-teal-400);
  outline-offset: 3px;
}


/* ============================================
   Footer
   ============================================ */

.form-footer {
  position: relative;
  z-index: 1;
  text-align: center;
  padding: var(--space-lg) var(--space-md);
  border-top: 1px solid var(--color-gray-200);
}

.form-footer__text {
  font-size: 0.75rem;
  color: var(--color-gray-500);
}


/* ============================================
   Animations
   ============================================ */

@keyframes fadeSlideUp {
  from {
    opacity: 0;
    transform: translateY(20px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes modalSlideUp {
  from {
    opacity: 0;
    transform: translateY(30px) scale(0.95);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

@keyframes successPop {
  from {
    transform: scale(0.5);
    opacity: 0;
  }
  to {
    transform: scale(1);
    opacity: 1;
  }
}

@keyframes drawCircle {
  to { stroke-dashoffset: 0; }
}

@keyframes drawCheck {
  to { stroke-dashoffset: 0; }
}

@keyframes shake {
  0%, 100% { transform: translateX(0); }
  25% { transform: translateX(-6px); }
  50% { transform: translateX(6px); }
  75% { transform: translateX(-4px); }
}

.form-field--error .form-field__input,
.form-field--error .form-field__textarea {
  border-color: var(--color-error);
  animation: shake 0.4s ease-out;
}

.form-field__error-message {
  font-size: 0.75rem;
  color: var(--color-error);
  margin-top: 2px;
}


/* ============================================
   HIPAA Consent
   ============================================ */

.hipaa-consent {
  background: #EFF9FA;
  border: 1.5px solid #B3DFE4;
  border-radius: var(--radius-lg);
  padding: var(--space-md) var(--space-lg);
  margin-bottom: var(--space-lg);
}

.hipaa-consent__label {
  display: flex;
  align-items: flex-start;
  gap: var(--space-md);
  cursor: pointer;
}

/* Hide native checkbox */
.hipaa-consent__label input[type="checkbox"] {
  position: absolute;
  opacity: 0;
  width: 0;
  height: 0;
}

/* Custom checkbox box */
.hipaa-consent__box {
  flex-shrink: 0;
  width: 22px;
  height: 22px;
  border: 2px solid var(--color-teal-400);
  border-radius: 5px;
  background: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-top: 1px;
  transition: all var(--transition-fast);
}

.hipaa-consent__label input[type="checkbox"]:checked ~ .hipaa-consent__box {
  background: var(--color-teal-500);
  border-color: var(--color-teal-500);
}

.hipaa-consent__label input[type="checkbox"]:checked ~ .hipaa-consent__box::after {
  content: '';
  display: block;
  width: 5px;
  height: 10px;
  border: 2.5px solid #fff;
  border-top: none;
  border-left: none;
  transform: rotate(45deg) translate(-1px, -1px);
}

.hipaa-consent__label input[type="checkbox"]:focus-visible ~ .hipaa-consent__box {
  outline: 2px solid var(--color-teal-400);
  outline-offset: 2px;
}

.hipaa-consent__text {
  font-size: 0.82rem;
  color: var(--color-gray-600);
  line-height: 1.6;
}

.hipaa-consent__link {
  color: var(--color-teal-600);
  text-decoration: underline;
  margin-left: 4px;
}

.hipaa-consent__link:hover {
  color: var(--color-teal-700);
}




/* ============================================
   Responsive: Tablet (≥ 480px)
   ============================================ */

@media (min-width: 480px) {
  .form-grid {
    grid-template-columns: 1fr 1fr;
  }

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

  .checkbox-grid {
    grid-template-columns: 1fr 1fr;
  }

  /* Teeth chart: switch to full 8-column dental chart */
  .teeth-chart__quadrant {
    grid-template-columns: repeat(8, 1fr);
    gap: 4px;
  }

  .teeth-chart__side-label {
    display: block;
  }

  .teeth-chart__divider {
    padding: 0 36px;
  }

  .teeth-chart__tooth {
    font-size: 0.75rem;
  }

  .form-header__logo-img {
    max-height: 80px;
  }

  .form-header__logo-area {
    margin-bottom: 0;
  }
}


/* ============================================
   Responsive: Desktop (≥ 768px)
   ============================================ */

@media (min-width: 768px) {
  .form-page {
    padding: var(--space-2xl) var(--space-lg);
  }

  .form-header {
    padding: var(--space-xl);
    display: grid;
    grid-template-columns: 1fr auto;
    grid-template-rows: auto auto;
    gap: var(--space-lg);
  }

  .form-header__logo-area {
    grid-column: 1;
    grid-row: 1;
    margin-bottom: 0;
  }

  .form-header__doctor {
    grid-column: 2;
    grid-row: 1;
    margin-bottom: 0;
    align-self: center;
  }

  .form-header__contact {
    grid-column: 1 / -1;
    grid-row: 2;
    flex-direction: row;
    flex-wrap: wrap;
    gap: var(--space-md);
  }

  .form-header__logo-img {
    max-height: 88px;
  }

  .form-header__title {
    font-size: 1.4rem;
  }

  .form-section {
    padding: var(--space-xl);
  }

  .form-section__legend {
    font-size: 1.15rem;
  }

  .teeth-chart__tooth {
    font-size: 0.82rem;
  }

  .teeth-chart__side-label {
    font-size: 0.7rem;
    width: 38px;
  }

  .teeth-chart__quadrant {
    gap: 5px;
  }

  .teeth-chart {
    padding: var(--space-lg);
  }

  .referral-form__heading {
    font-size: 1.75rem;
  }

  .radio-cards {
    flex-direction: row;
  }

  .radio-card {
    flex: 1;
  }

  .bg-orb--1 { width: 500px; height: 500px; }
  .bg-orb--2 { width: 350px; height: 350px; }
  .bg-orb--3 { width: 300px; height: 300px; }
}


/* ============================================
   Reduced Motion
   ============================================ */

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }

  .bg-orb { display: none; }
}


/* ============================================
   Loading state for submit button
   ============================================ */

.form-submit__button.is-loading {
  pointer-events: none;
  opacity: 0.8;
}

.form-submit__button.is-loading .form-submit__button-text {
  visibility: hidden;
}

.form-submit__button.is-loading .form-submit__button-icon {
  visibility: hidden;
}

.form-submit__button.is-loading::after {
  content: '';
  position: absolute;
  width: 22px;
  height: 22px;
  border: 3px solid rgba(255, 255, 255, 0.3);
  border-top-color: #FFFFFF;
  border-radius: var(--radius-full);
  animation: spin 0.7s linear infinite;
}

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