/* ============================================
   Online new patient forms (submit-forms.html)
   Builds on referrals.css components (ref-*)
   ============================================ */

.pf-section {
  padding-top: clamp(var(--space-8), 5vw, var(--space-12));
}

/* ---------- Progress ---------- */

.pf-progress {
  list-style: none;
  padding: 0;
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: var(--space-2);
  margin-bottom: var(--space-6);
  counter-reset: none;
}

.pf-progress button {
  width: 100%;
  display: flex;
  align-items: center;
  gap: var(--space-2);
  padding: var(--space-3);
  border: 1px solid var(--color-divider);
  border-radius: var(--radius-md);
  background: var(--color-surface);
  font: inherit;
  font-size: var(--text-xs);
  font-weight: 600;
  color: var(--color-text-muted);
  text-align: left;
  line-height: 1.25;
  cursor: pointer;
  transition: border-color var(--transition-interactive), background var(--transition-interactive);
}

.pf-progress button span {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  width: 24px;
  height: 24px;
  border-radius: var(--radius-full);
  background: var(--color-surface-offset);
  color: var(--color-text-muted);
}

.pf-progress button:disabled {
  cursor: default;
  opacity: 0.6;
}

.pf-progress .is-done button span {
  background: var(--color-accent-light);
  color: var(--color-accent-hover);
}

.pf-progress .is-current button {
  border-color: var(--color-primary);
  background: var(--color-primary-light);
  color: var(--color-primary);
}

.pf-progress .is-current button span {
  background: var(--color-primary);
  color: #fff;
}

.pf-progress__mobile {
  display: none;
  font-size: var(--text-sm);
  font-weight: 600;
  color: var(--color-primary);
  margin-bottom: var(--space-4);
}

/* ---------- Steps ---------- */

.pf-step__title {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  font-family: var(--font-display);
  font-weight: 400;
  font-size: var(--text-xl);
  color: var(--color-text);
  margin-bottom: var(--space-6);
}

.pf-step .ref-fieldset:first-of-type {
  border-top: 0;
  padding-top: 0;
}

.ref-grid + .ref-grid {
  margin-top: var(--space-5);
}

.ref-grid--3 {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.ref-grid--4 {
  grid-template-columns: repeat(4, minmax(0, 1fr));
}

.pf-subhead {
  font-size: var(--text-sm);
  font-weight: 600;
  color: var(--color-text);
  margin: var(--space-5) 0 var(--space-3);
}

.pf-subhead:first-of-type {
  margin-top: var(--space-4);
}

/* Prior treatments: checkbox + detail field per row */
.pf-treatments {
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
  margin-top: var(--space-4);
}

.pf-treatments > .pf-treatment__check {
  align-self: flex-start;
}

.pf-treatment {
  display: grid;
  grid-template-columns: 250px minmax(0, 1fr);
  align-items: center;
  gap: var(--space-3);
}

.pf-treatment__check {
  justify-content: flex-start;
}

.pf-treatment input[type="text"] {
  width: 100%;
  font: inherit;
  font-size: var(--text-base);
  color: var(--color-text);
  background: #fff;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  padding: 0.6rem 0.85rem;
  min-height: 44px;
}

.pf-treatment input[type="text"]:focus {
  outline: none;
  border-color: var(--color-primary);
  box-shadow: 0 0 0 3px rgba(14, 54, 103, 0.15);
}

/* Collapsible sections */
.pf-details {
  border: 1px solid var(--color-divider);
  border-radius: var(--radius-lg);
  padding: var(--space-4) var(--space-5);
  margin-bottom: var(--space-6);
}

.pf-details summary {
  cursor: pointer;
  font-weight: 600;
  color: var(--color-primary);
}

.pf-details[open] summary {
  margin-bottom: var(--space-4);
}

.pf-details .ref-fieldset {
  margin-bottom: var(--space-4);
}

.pf-details--inline {
  margin: var(--space-3) 0 var(--space-4);
  padding: var(--space-3) var(--space-4);
}

/* ---------- Consents ---------- */

.pf-consent {
  border: 1px solid var(--color-divider);
  border-radius: var(--radius-lg);
  padding: var(--space-5) var(--space-6);
  margin-bottom: var(--space-5);
  background: var(--color-bg);
}

.pf-consent h3 {
  font-family: var(--font-display);
  font-weight: 400;
  font-size: var(--text-lg);
  color: var(--color-text);
  margin-bottom: var(--space-3);
}

.pf-consent .ref-grid {
  margin: 0 0 var(--space-4);
}

.pf-consent__text {
  font-size: var(--text-sm);
  line-height: 1.65;
  color: var(--color-text-muted);
  margin-bottom: var(--space-4);
}

.pf-consent__text p + p {
  margin-top: var(--space-3);
}

.pf-consent__text--scroll {
  max-height: 220px;
  overflow-y: auto;
  padding: var(--space-4);
  background: var(--color-surface);
  border: 1px solid var(--color-divider);
  border-radius: var(--radius-md);
}

.pf-agree {
  display: flex;
  align-items: flex-start;
  gap: var(--space-3);
  font-size: var(--text-sm);
  font-weight: 600;
  color: var(--color-text);
  cursor: pointer;
}

.pf-agree input {
  flex-shrink: 0;
  width: 20px;
  height: 20px;
  margin-top: 1px;
  accent-color: var(--color-primary);
}

.pf-signature {
  border-top: 0;
  padding-top: var(--space-2);
}

/* ---------- Navigation ---------- */

.pf-error {
  margin: 0 0 var(--space-4);
  padding: var(--space-3) var(--space-4);
  border-left: 3px solid #B4412F;
  background: #FBEDEA;
  border-radius: var(--radius-md);
  font-size: var(--text-sm);
  font-weight: 600;
  color: #8A2E20;
}

.pf-nav {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: var(--space-3);
  padding-top: var(--space-6);
  border-top: 1px solid var(--color-divider);
}

.pf-nav__right {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-3);
  margin-left: auto;
}

.pf-nav .btn {
  font-size: var(--text-base);
  font-weight: 600;
  padding: var(--space-3) var(--space-6);
}

.pf-nav .btn:disabled {
  opacity: 0.7;
  cursor: progress;
}

.pf-nav__note {
  margin-top: var(--space-4);
  font-size: var(--text-sm);
  color: var(--color-text-muted);
}

.pf-nav__note a {
  color: var(--color-primary);
  font-weight: 600;
  text-decoration: none;
  border-bottom: 1px solid var(--color-accent);
}

/* ---------- Responsive ---------- */

@media (max-width: 720px) {
  .pf-progress:not([hidden]) {
    display: none;
  }

  .pf-progress__mobile:not([hidden]) {
    display: block;
  }

  .ref-grid--3,
  .ref-grid--4 {
    grid-template-columns: 1fr 1fr;
  }

  .pf-treatment {
    grid-template-columns: 1fr;
    gap: var(--space-2);
  }

  .pf-consent {
    padding: var(--space-4);
  }

  .pf-nav .btn {
    flex: 1 1 auto;
    justify-content: center;
  }

  .pf-nav__right {
    width: 100%;
  }
}
