/* Styling for template engine v2 (fill-in-the-note editor). Loaded after /assets/site.css. */

/* Compact page header so the note starts near the top */
header.page-header.tf-page-header { padding-top: 14px; padding-bottom: 18px; }
header.page-header.tf-page-header h1 { margin: 2px 0 4px; font-size: 1.75rem; }
header.page-header.tf-page-header .meta { font-size: .72rem; }
header.page-header.tf-page-header p.lead { margin: 0; max-width: none; font-size: .95rem; }
.tf-privacy { color: #526c69; }

.tf-editor {
  margin: 0 0 64px;
}

/* Toolbar: stays available on long notes */
.tf-toolbar { position: sticky; top: 0; z-index: 10; display: flex; flex-wrap: wrap; align-items: center; gap: 12px 20px; padding: 10px 14px; margin-top: 16px; background: #fff; border: 1px solid var(--border); border-radius: 12px; box-shadow: 0 4px 16px #183b3010; }
.tf-progress { font-size: .78rem; color: #526c69; }
.tf-toolbar-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-left: auto; }
.tf-toolbar button { padding: 9px 13px; border: 1px solid var(--border); border-radius: 8px; background: white; color: var(--teal-deep); font-family: inherit; font-size: .85rem; font-weight: 600; cursor: pointer; }
.tf-toolbar button:hover { border-color: var(--teal-deep); }
.tf-toolbar .tf-toolbar-copy { background: var(--teal-deep); border-color: var(--teal-deep); color: white; }
.tf-reset-confirm { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; flex-basis: 100%; border-top: 1px solid var(--border); padding-top: 12px; font-size: .85rem; }
.tf-reset-confirm[hidden] { display: none; }
.tf-reset-confirm span { margin-right: auto; }
.tf-report { display: grid; gap: 10px; flex-basis: 100%; border-top: 1px solid var(--border); padding-top: 12px; }
.tf-report[hidden] { display: none; }
.tf-toolbar .tf-report label { display: grid; gap: 4px; font-size: .8rem; font-weight: 600; color: var(--navy); }
.tf-report textarea, .tf-report input[type="email"] { width: 100%; padding: 10px 12px; border: 1px solid var(--border); border-radius: 8px; font: inherit; font-size: .9rem; color: var(--navy); background: #fff; }
.tf-report textarea { resize: vertical; min-height: 80px; }
.tf-report textarea:focus, .tf-report input[type="email"]:focus { outline: 2px solid var(--teal-light); outline-offset: 1px; }
.tf-report .hp-field { position: absolute; width: 1px; height: 1px; overflow: hidden; opacity: 0; pointer-events: none; }
.tf-report-hint { margin: 0; font-size: .75rem; color: #526c69; max-width: none; }
.tf-report-actions { display: flex; justify-content: flex-end; gap: 8px; }
.tf-toolbar .tf-report-send { background: var(--teal-deep); color: white; }
.tf-toolbar .tf-report-send:disabled { opacity: .7; cursor: default; }
.tf-report .form-status { margin: 0; min-height: 0; }

/* Note card */
.tf-note-card {
  margin-top: 12px;
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-top: 3px solid var(--teal-mid);
  border-radius: 12px;
  padding: 22px 32px 24px;
}

.tf-note-head { display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 14px; margin-bottom: 14px; padding-bottom: 12px; border-bottom: 1px solid var(--border); }
.tf-note-head h3 { margin: 0; font-size: 1.05rem; letter-spacing: -.02em; color: var(--teal-deep); }
.tf-note-hint { margin: 0; font-size: .8rem; color: #526c69; max-width: none; }

.tf-note { font-size: 1.06rem; color: var(--navy); line-height: 1.9; }

/* Each paragraph reads as its own block, with a left accent while you work in it */
.tf-para {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 16px;
  align-items: start;
  padding: 10px 14px;
  /* pulled left by padding + accent bar so the text lines up with the note heading */
  margin: 0 -14px 6px -17px;
  border-left: 3px solid transparent;
  border-radius: 0 8px 8px 0;
  transition: background .12s ease, border-color .12s ease;
}

.tf-para + .tf-para { margin-top: 2px; }
.tf-para:hover { background: #f7faf8; }
.tf-para:focus-within { background: #f4f8f6; border-left-color: var(--teal-light); }

.tf-para-text {
  margin: 0;
  max-width: none;
  min-height: 2em;
  outline: none;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.tf-para-copy {
  font-family: inherit;
  font-size: .75rem;
  font-weight: 600;
  padding: 4px 10px;
  margin-top: 4px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: #fff;
  color: var(--teal-deep);
  cursor: pointer;
  opacity: .35;
  transition: opacity .12s ease;
}

.tf-para:hover .tf-para-copy,
.tf-para:focus-within .tf-para-copy,
.tf-para-copy:focus-visible,
.tf-para-copy.tf-copied,
.tf-cdt .tf-para-copy { opacity: 1; }

.tf-para-copy:hover { border-color: var(--teal-deep); }
.tf-para-copy.tf-copied { background: var(--teal-deep); border-color: var(--teal-deep); color: #fff; }

@media (hover: none) {
  .tf-para-copy { opacity: 1; }
}

/* Field chips */
/* Blanks: a light tinted slot that never breaks across lines */
.tf-chip {
  display: inline;
  padding: 1px 7px;
  border-radius: 5px;
  background: #eef2f5;
  color: #5b6b78;
  font-size: .9em;
  font-weight: 500;
  white-space: nowrap;
  cursor: pointer;
  /* selected as one unit, so a text selection across the note includes whole fields */
  user-select: all;
  -webkit-user-select: all;
  box-decoration-break: clone;
  -webkit-box-decoration-break: clone;
  border: 1px solid transparent;
  border-bottom: 1.5px dashed #9fb0bd;
  transition: background .12s ease, border-color .12s ease;
}

.tf-chip:hover, .tf-chip:focus-visible { background: #e2e8ed; border-bottom-color: var(--teal-mid); outline: none; }

/* Filled values read like finished text: bold with a soft underline, no box */
.tf-chip--filled {
  background: transparent;
  color: var(--navy);
  font-size: 1em;
  font-weight: 700;
  white-space: normal;
  border: 0;
  border-bottom: 2px solid #a8d5c2;
  border-radius: 2px;
  padding: 0 1px;
}

.tf-chip--filled:hover, .tf-chip--filled:focus-visible { background: #e3f0ea; border-bottom-color: var(--teal-mid); }

.tf-chip--active { background: #d6ebe1; border-bottom: 2px solid var(--teal-deep); }
.tf-chip--moving { opacity: .45; outline: 2px dashed var(--teal-mid); outline-offset: 1px; }
.tf-note--moving .tf-para-text { cursor: text; background: #f4f8f6; outline: 1px dashed var(--teal-light); outline-offset: 4px; border-radius: 4px; }

/* Optional phrases are left out of the copied note until their field is filled */
.tf-phrase--off { color: #a3adb5; }
.tf-phrase--off .tf-chip:not(.tf-chip--filled) { opacity: .75; background: #f2f5f7; }

/* Edited wording that was written for a different value of its field */
.tf-switch--stale { text-decoration: underline wavy #c98a2b; text-decoration-thickness: 1px; text-underline-offset: 4px; }

/* Field popover */
.tf-popover {
  position: absolute;
  z-index: 50;
  width: min(420px, calc(100vw - 24px));
  max-height: min(70vh, 520px);
  display: flex;
  flex-direction: column;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 12px;
  box-shadow: 0 12px 40px #183b3026, 0 2px 6px #183b3014;
  font-size: .9rem;
}

.tf-popover-head { display: flex; align-items: center; gap: 8px; padding: 12px 14px 8px; }
.tf-popover-title { flex: 1; font-size: .85rem; font-weight: 700; color: var(--teal-deep); }
.tf-popover-close { border: 0; background: none; font-size: 1.3rem; line-height: 1; color: #526c69; cursor: pointer; padding: 2px 6px; }
.tf-popover-body { padding: 4px 14px 12px; overflow-y: auto; min-height: 0; }
.tf-popover-foot { display: flex; align-items: center; gap: 12px; padding: 10px 14px; border-top: 1px solid var(--border); }
.tf-popover-note { margin: 0 0 8px; padding: 6px 10px; border-left: 3px solid var(--teal-deep); background: #f2f8f7; font-size: .78rem; color: #3d5654; max-width: none; }
.tf-popover-hint { margin: 8px 0 0; font-size: .78rem; color: #526c69; max-width: none; }

.tf-popover-input {
  display: block;
  width: 100%;
  margin: 4px 0 8px;
  padding: 9px 12px;
  font: inherit;
  font-size: 1rem;
  color: var(--navy);
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 8px;
}

.tf-popover-input[hidden] { display: none; }
.tf-popover-input:focus { outline: 2px solid var(--teal-light); outline-offset: 1px; }

.tf-popover-link { border: 0; background: none; padding: 0; font: inherit; font-size: .8rem; font-weight: 600; color: var(--teal-deep); cursor: pointer; }
.tf-popover-link:hover { text-decoration: underline; }
.tf-popover-remove { color: #b3453f; }
.tf-popover-next { margin-left: auto; padding: 7px 12px; border: 0; border-radius: 8px; background: var(--teal-deep); color: #fff; font: inherit; font-size: .8rem; font-weight: 600; cursor: pointer; }

.tf-option-group-label { font-size: .75rem; font-weight: 600; color: #526c69; margin: 8px 0 6px; }
.tf-options { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 4px; }

.tf-option {
  font-family: inherit;
  font-size: .82rem;
  font-weight: 600;
  min-height: 36px;
  padding: 6px 12px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: #fff;
  color: var(--navy);
  cursor: pointer;
  transition: background .12s ease, border-color .12s ease, color .12s ease;
}

.tf-option:hover { border-color: var(--teal-light); }
.tf-option[aria-pressed="true"] { background: var(--teal-mid); border-color: var(--teal-deep); color: #fff; }
.tf-option[aria-pressed="true"]:hover { background: var(--teal-deep); }
.tf-option--other { border-style: dashed; }
.tf-option--other[aria-pressed="true"] { background: var(--teal-deep); border-style: solid; }

/* CDT codes at the end of the note */
.tf-cdt { margin-top: 12px; padding-top: 16px; border-top: 1px solid var(--border); }
.tf-cdt-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 6px; }
.tf-cdt-title { font-size: .78rem; font-weight: 700; letter-spacing: .03em; text-transform: uppercase; color: var(--teal-deep); }
.tf-cdt--empty .tf-cdt-head .tf-para-copy { display: none; }
.tf-cdt-row { display: flex; align-items: baseline; gap: 10px; padding: 5px 0; font-size: .92rem; color: var(--navy); }
.tf-cdt-code { font-weight: 700; flex-shrink: 0; color: var(--navy); }
.tf-cdt-description { flex: 1; color: var(--navy); }
.tf-cdt-remove { border: 0; background: none; color: #b3453f; font-size: 1.05rem; line-height: 1; cursor: pointer; padding: 2px 6px; }
.tf-cdt-remove:hover { color: #8a332e; }

.tf-cdt-picker { margin-top: 10px; padding: 12px; border: 1px solid var(--border); border-radius: 10px; background: #fff; }
.tf-cdt-picker-head { display: flex; align-items: center; gap: 12px; margin-bottom: 10px; }
.tf-cdt-picker-title { flex: 1; font-size: .8rem; font-weight: 700; color: #526c69; }

.tf-cdt-pick {
  display: flex;
  align-items: baseline;
  gap: 8px;
  width: 100%;
  margin-bottom: 6px;
  padding: 8px 10px;
  font: inherit;
  font-size: .85rem;
  text-align: left;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 8px;
  cursor: pointer;
}

.tf-cdt-pick:hover:not(:disabled) { border-color: var(--teal-mid); background: #f4f8f6; }
.tf-cdt-pick:disabled { cursor: default; opacity: .6; background: #f0f3f2; }
.tf-cdt-pick-status { flex-shrink: 0; font-size: .78rem; font-weight: 600; color: var(--teal-deep); }

/* Footer: copy whole note */
.tf-note-foot { margin-top: 20px; }

.tf-copy-button {
  width: 100%;
  padding: 12px 18px;
  font: inherit;
  font-size: .95rem;
  font-weight: 600;
  color: #fff;
  background: var(--teal-mid);
  border: 0;
  border-radius: 8px;
  cursor: pointer;
  transition: background .12s ease;
}

.tf-copy-button:hover, .tf-copy-button.tf-copied { background: var(--teal-deep); }
.tf-copy-status { margin: 10px 0 0; font-size: .85rem; min-height: 1.2em; max-width: none; color: var(--teal-deep); }
.tf-copy-status.form-status-error { color: #b3453f; }

.tf-after-copy[hidden] { display: none; }
.tf-after-copy-row { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; font-size: .9rem; font-weight: 600; color: var(--teal-deep); }
.tf-next-patient { padding: 6px 14px; font: inherit; font-size: .85rem; font-weight: 600; color: var(--teal-deep); background: #fff; border: 1px solid var(--teal-deep); border-radius: 999px; cursor: pointer; }
.tf-next-patient:hover { background: var(--teal-deep); color: #fff; }
.tf-bookmark-hint { margin: 8px 0 0; font-size: .8rem; color: #526c69; max-width: none; }

/* After copy: AI scribe early-access prompt (once per session) */
.tf-waitlist { position: relative; margin-top: 14px; padding: 16px 44px 16px 18px; background: #edf5f1; border: 1px solid #cfe3da; border-radius: 12px; }
.tf-waitlist[hidden] { display: none; }
.tf-waitlist-lead { margin: 0 0 12px; font-size: .9rem; max-width: none; color: var(--navy); }
.tf-waitlist-close { position: absolute; top: 8px; right: 8px; width: 30px; height: 30px; font: inherit; font-size: 1.2rem; line-height: 1; color: #526c69; background: none; border: 0; border-radius: 6px; cursor: pointer; }
.tf-waitlist-close:hover { background: #dbebe4; color: var(--navy); }
.tf-waitlist-form { display: flex; flex-wrap: wrap; gap: 8px; }
.tf-waitlist-form input[type="email"], .tf-waitlist-form select { flex: 1 1 180px; min-width: 0; padding: 9px 12px; font: inherit; font-size: .9rem; color: var(--navy); background: #fff; border: 1px solid var(--border); border-radius: 8px; }
.tf-waitlist-form input:focus, .tf-waitlist-form select:focus { outline: 2px solid var(--teal-light); outline-offset: 1px; }
.tf-waitlist-form button { padding: 9px 16px; font: inherit; font-size: .9rem; font-weight: 600; color: #fff; background: var(--teal-deep); border: 0; border-radius: 8px; cursor: pointer; }
.tf-waitlist-form button:hover:not(:disabled) { background: var(--navy); }
.tf-waitlist-form button:disabled { opacity: .7; cursor: default; }
.tf-waitlist-form .hp-field { position: absolute; width: 1px; height: 1px; overflow: hidden; opacity: 0; pointer-events: none; }
.tf-waitlist-note { margin: 8px 0 0; font-size: .78rem; color: #526c69; max-width: none; }
.tf-waitlist-status { margin: 6px 0 0; font-size: .85rem; min-height: 0; max-width: none; color: var(--teal-deep); }
.tf-waitlist-status:empty { display: none; }
.tf-waitlist-status.form-status-error { color: #b3453f; }

/* Static guide below the editor: how-to, example note, mistakes, FAQ */
.tf-noscript { padding: 14px 16px; background: #fff8e6; border: 1px solid #f0dca8; border-radius: 8px; }
.tf-guide { max-width: 760px; padding: 8px 0 64px; border-top: 1px solid var(--border); }
.tf-guide h2 { font-size: 1.35rem; margin: 40px 0 12px; }
.tf-guide h3 { font-size: 1.05rem; color: var(--teal-deep); margin: 24px 0 6px; }
.tf-guide p { max-width: none; }
.tf-guide ul, .tf-guide ol { padding-left: 22px; }
.tf-guide li { margin-bottom: 8px; }
.tf-example-label { margin: 0 0 8px; font-size: .85rem; color: #526c69; }
.tf-example { padding: 18px 20px; background: #fff; border: 1px solid var(--border); border-left: 4px solid var(--teal-light); border-radius: 8px; font-size: .95rem; }
.tf-example p { margin: 0 0 10px; }
.tf-example p:last-child { margin-bottom: 0; }
.tf-related { columns: 2 260px; column-gap: 32px; }
.tf-related li { break-inside: avoid; }
.tf-disclaimer { margin-top: 32px; font-size: .82rem; color: #526c69; }

/* Phones: popover becomes a bottom sheet */
@media (max-width: 640px) {
  .tf-toolbar { gap: 8px; padding: 10px; }
  .tf-progress { flex-basis: 100%; }
  .tf-toolbar-actions { margin-left: 0; gap: 6px; }
  .tf-toolbar button { padding: 8px 10px; font-size: .78rem; }
  .tf-note-card { padding: 18px 16px; }
  .tf-note { font-size: 1rem; }
  .tf-para { padding: 8px 10px; margin: 0 -10px 6px -13px; }
  header.page-header.tf-page-header { padding-top: 10px; padding-bottom: 14px; }
  header.page-header.tf-page-header h1 { font-size: 1.45rem; }
  .tf-para { grid-template-columns: minmax(0, 1fr); gap: 4px; }
  .tf-para-copy { justify-self: end; margin-top: 0; }
  .tf-popover {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    top: auto;
    width: 100%;
    max-height: 70vh;
    border-radius: 16px 16px 0 0;
  }
  .tf-option { min-height: 42px; }
}

/* Template menu: save the wording as the user's template, or reset it */
.tf-template { position: relative; }
.tf-toolbar .tf-template-toggle::after { content: ""; display: inline-block; margin-left: 8px; vertical-align: 2px; border: 4px solid transparent; border-top-color: currentColor; border-bottom: 0; }
.tf-template-menu { position: absolute; right: 0; top: calc(100% + 6px); z-index: 20; display: grid; min-width: 230px; padding: 6px; background: #fff; border: 1px solid var(--border); border-radius: 10px; box-shadow: 0 12px 32px #183b3022; }
.tf-template-menu[hidden], .tf-template-menu button[hidden] { display: none; }
.tf-toolbar .tf-template-menu button { border: 0; border-radius: 6px; padding: 9px 12px; text-align: left; background: none; }
.tf-toolbar .tf-template-menu button:hover, .tf-toolbar .tf-template-menu button:focus-visible { background: #edf5f1; }
.tf-toolbar-status { flex-basis: 100%; margin: 0; font-size: .82rem; font-weight: 600; color: var(--teal-deep); max-width: none; }
.tf-toolbar-status:empty { display: none; }
.tf-toolbar-status.form-status-error { color: #b3453f; }
@media (max-width: 640px) {
  .tf-template-menu { right: auto; left: 0; }
}

/* "+ Field" button at the caret, and the field picker it opens */
.tf-add-field {
  position: absolute;
  z-index: 40;
  padding: 3px 9px;
  font: inherit;
  font-size: .75rem;
  font-weight: 700;
  line-height: 1.4;
  color: #fff;
  background: var(--teal-deep);
  border: 0;
  border-radius: 999px;
  box-shadow: 0 4px 12px #183b3030;
  cursor: pointer;
}
.tf-add-field[hidden] { display: none; }
.tf-add-field:hover { background: var(--teal-mid); }
.tf-field-picker { width: min(360px, calc(100vw - 24px)); }
.tf-field-list { display: grid; gap: 2px; }
.tf-field-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  width: 100%;
  padding: 8px 10px;
  font: inherit;
  font-size: .85rem;
  font-weight: 600;
  text-align: left;
  color: var(--navy);
  background: none;
  border: 0;
  border-radius: 6px;
  cursor: pointer;
}
.tf-field-item:hover, .tf-field-item:focus-visible { background: #edf5f1; outline: none; }
.tf-field-item-note { font-size: .72rem; font-weight: 600; color: #8a979f; }
