/* Styling for the report body the model produces.
 *
 * The class names (patient-block, pr/pl/pv, section-heading, echo-list,
 * cath-table, diagnosis-block) are dictated by the system prompt in
 * lib/report-generator.js, so these rules are ported from the live
 * core/css/style.css to keep generated reports looking identical. */

.report-paper {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
  font-family: Arial, sans-serif;
  color: #111;
}

.report-paper__header img,
.report-paper__footer img { width: 100%; display: block; }

.report-body { padding: 14px 22px; }

.report-sig { padding: 12px 22px 18px; border-top: 1px solid #cdd6e0; margin-top: 16px; }
.report-sig p { font-size: 12px; color: #333; margin: 0 0 2px; }
.report-sig__image { max-height: 60px; width: auto; margin: 4px 0; }
.report-sig__name { font-weight: 700; font-size: 14px; color: var(--brand-primary); }
.report-sig__quals { font-size: 10px; color: #666; }

.report-body h2 {
  font-size: 14px; font-weight: 700; text-align: center; letter-spacing: 1px;
  color: var(--brand-primary); margin: 0 0 2px; text-transform: uppercase;
}
.report-body h4 {
  font-size: 11px; font-weight: 400; text-align: center; color: #666;
  margin: 0 0 12px; font-style: italic;
}

.report-body .patient-block {
  background: #f5f8fc; border-left: 3px solid var(--brand-primary);
  padding: 8px 12px; margin: 10px 0 14px;
}
.report-body .pr { display: flex; margin: 3px 0; font-size: 12px; flex-wrap: wrap; }
.report-body .pl { font-weight: 700; color: var(--brand-primary); min-width: 190px; flex-shrink: 0; }
.report-body .pv { color: #111; }

.report-body .salutation { font-size: 12px; color: #333; margin: 0 0 14px; font-style: italic; }
.report-body .section { margin: 0 0 12px; }
.report-body .section-heading {
  font-size: 11px; font-weight: 700; color: var(--brand-primary);
  text-transform: uppercase; letter-spacing: .7px;
  border-bottom: 1.5px solid var(--brand-primary); padding-bottom: 2px; margin-bottom: 6px;
}

.report-body ul { margin: 3px 0; padding-left: 16px; }
.report-body li { margin: 2px 0; font-size: 12px; }
.report-body ul.echo-list { list-style: none; padding-left: 0; }
.report-body ul.echo-list li { display: flex; margin: 3px 0; flex-wrap: wrap; }
.report-body .echo-label { font-weight: 600; color: #222; min-width: 220px; flex-shrink: 0; font-size: 11.5px; }
.report-body .echo-value { color: #111; font-size: 12px; }

.report-body .diagnosis-block {
  background: #fff8e1; border-left: 3px solid #e6a817; padding: 6px 12px; margin: 8px 0 12px;
}

.report-body table.cath-table { border-collapse: collapse; width: 100%; font-size: 11px; margin: 6px 0; }
.report-body table.cath-table th {
  background: var(--brand-primary); color: #fff; padding: 5px 8px; text-align: left; font-weight: 600;
}
.report-body table.cath-table td { border: 1px solid #ccd6e0; padding: 4px 8px; vertical-align: top; }
.report-body table.cath-table tr:nth-child(even) td { background: #f5f8fc; }
.report-body strong { font-weight: 700; }

/* Editing puts the body into contenteditable; make the target obvious. */
.report-body[contenteditable="true"] {
  outline: 2px dashed var(--brand-primary);
  outline-offset: 4px;
  background: #fffdf5;
}

.print-page { background: #fff; }
.report-paper--print { border: none; border-radius: 0; max-width: 210mm; margin: 0 auto; }

/* A printed submission's title and its "Submitted …" line.
 *
 * Everything below them on that page is inside a `.card`, and a card's 24px
 * padding insets its text — so a heading with no padding of its own hung to
 * the left of every word under it, against the edge of the paper. The number
 * is the card's, deliberately: this has to move with it. */
.submission-print__head { padding: 0 24px; }

@media print {
  .report-paper { border: none; }
  .print-page { background: #fff; }
}

/* ------------------------- the prescription document --------------------- */
/* Everything below prints. A script is read by a pharmacist in a hurry: the
   date and the pre-authorisation number are what they look for first, then
   the medicines with their codes. */

.rx-head {
  display: flex; align-items: flex-start; justify-content: space-between;
  gap: 16px; margin: 0 0 10px;
}
.rx-head__right { text-align: right; flex-shrink: 0; }
.rx-date__label {
  font-size: 10px; font-weight: 700; letter-spacing: .08em;
  text-transform: uppercase; color: #666;
}
.rx-date__value { font-size: 15px; font-weight: 700; color: #111; }

.rx-preauth {
  display: inline-block; padding: 5px 10px;
  border: 1px solid #cdd6e0; border-radius: 6px; background: #f5f8fb;
  font-size: 12px;
}
.rx-preauth__label { font-weight: 700; color: var(--brand-primary); }
.rx-preauth__value { font-weight: 700; letter-spacing: .03em; }

/* The medicine table. Codes are monospaced so a mistyped digit is visible. */
.rx-items { width: 100%; border-collapse: collapse; font-size: 12px; }
.rx-items th {
  text-align: left; padding: 6px 8px;
  border-bottom: 1px solid #111; font-size: 10px;
  letter-spacing: .06em; text-transform: uppercase; color: #333;
}
.rx-items td { padding: 7px 8px; border-bottom: 1px solid #e3e8ee; vertical-align: top; }
.rx-items__no { width: 26px; color: #666; }
.rx-items__name { font-weight: 700; }
.rx-items__code { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; white-space: nowrap; }

.rx-notes__text {
  margin: 0; padding: 8px 10px;
  border-left: 3px solid var(--brand-primary); background: #f5f8fb;
  font-size: 12px; white-space: pre-wrap;
}


/* ------------------------------- letters --------------------------------- */
/* The Admin Office's documents. Layout normalised from the five real letters
   the practice sent us — docs/LETTERS-NOTES.md — which disagree with each
   other about the order of the date and the details block and about whether
   the values are bold. */

.letter-paper {
  background: #fff;
  color: #111;
  font-family: Arial, sans-serif;
  max-width: 210mm;
  margin: 0 auto;
  /* A4, as a flex column, so that a four-line sick note still prints its
     footer at the bottom of the page instead of tucked under the signature.
     Header and footer sit in the flow, so a letter that runs to two pages puts
     the header on the first and the footer on the last — which is what the
     practice asked for, and is not what the Word originals do. */
  min-height: 297mm;
  display: flex;
  flex-direction: column;
}

.letter-main { padding: 18px 26px; flex: 1 1 auto; }
.letter-paper .report-paper__footer { margin-top: auto; }

.letter-title {
  font-size: 15px; font-weight: 700; text-align: center; text-transform: uppercase;
  letter-spacing: .04em; margin: 6px 0 18px; color: #111;
}

.letter-date { text-align: right; font-size: 12px; margin: 0 0 14px; }

.letter-details { margin: 0 0 18px; font-size: 12px; }
.letter-details__row { display: flex; gap: 10px; margin: 0 0 4px; }
.letter-details dt { flex: 0 0 150px; margin: 0; color: #333; }
.letter-details dd { margin: 0; font-weight: 700; white-space: pre-line; }

.letter-recipient { font-size: 12px; margin: 0 0 12px; white-space: pre-line; }
.letter-subject {
  font-size: 12px; font-weight: 700; text-transform: uppercase; margin: 0 0 14px;
}
.letter-salutation { font-size: 12px; margin: 0 0 12px; }

.letter-body { font-size: 12px; line-height: 1.55; }
.letter-body p { margin: 0 0 10px; }
.letter-body ul { margin: 0 0 10px; padding-left: 20px; }
.letter-body li { margin: 0 0 4px; }

.letter-sig { margin-top: 26px; font-size: 12px; }
.letter-sig p { margin: 0 0 2px; }
.letter-sig__off { margin-bottom: 4px; }
.letter-sig__image { max-height: 60px; width: auto; margin: 2px 0; display: block; }
.letter-sig__name { font-weight: 700; }
.letter-sig__quals { font-size: 10px; color: #666; }

/* What the letter does on paper — the page size, and the height that puts the
   footer at the bottom of it — is in letter-print.css, which only the print
   view loads. `@page` is document-wide, and this file is on every screen. */

/* ----------------------- writing one, in the portal ---------------------- */
/* These are portal chrome rather than document, so they use theme tokens. */

.letter-tabs { display: flex; gap: 6px; margin: 0 0 14px; }
.letter-tab {
  padding: 7px 14px; border: 1px solid var(--line); border-radius: 6px;
  background: transparent; color: var(--text); font: inherit; font-size: 13px;
  cursor: pointer;
}
.letter-tab.is-active {
  background: var(--brand-primary); border-color: var(--brand-primary); color: #fff;
}

.letter-editor {
  min-height: 320px; padding: 14px 16px; border: 1px solid var(--line);
  border-radius: 6px; background: var(--surface); color: var(--text);
  font-family: Arial, sans-serif; font-size: 13px; line-height: 1.55;
  overflow-wrap: break-word;
}
.letter-editor:focus { outline: 2px solid var(--brand-primary); outline-offset: 2px; }
.letter-editor p { margin: 0 0 10px; }
.letter-editor ul { margin: 0 0 10px; padding-left: 20px; }
/* An empty contenteditable gives no hint what to do with it. */
.letter-editor:empty::before {
  content: attr(data-placeholder); color: var(--text-dim); pointer-events: none;
}

.letter-brief {
  white-space: pre-wrap; font-family: inherit; font-size: 12px;
  background: var(--surface-2); border: 1px solid var(--line); border-radius: 6px;
  padding: 12px 14px; margin: 0; color: var(--text);
}

/* A static tile in the Quick Actions grid: a label, not a link. */
.qa-btn--static {
  display: flex; flex-direction: column; gap: 2px; align-items: flex-start;
  padding: 10px 12px; border: 1px dashed var(--line); border-radius: 8px;
}

/* ⚠️ A blank a template could not fill.

   Marked in the editor so it is impossible to miss, and marked again on the
   printed page so a letter that went out unfinished is obvious rather than
   reading as complete. The practice's own Word templates use `______` for the
   same purpose; this is that, in a colour. */
.letter-blank {
  background: var(--warn-bg);
  color: var(--warn);
  border: 1px solid var(--warn-line);
  border-radius: 4px;
  padding: 0 5px;
  font-weight: 600;
  white-space: nowrap;
}

/* ⚠️ A period, drawn as the two pickers it takes to say one.

   "Date/s of absence" is one row to the reader and two days to a date input,
   so the pair sits on one line with the word between them and reads as the
   single field it is. It wraps on a narrow screen rather than squeezing two
   pickers into half a column each — a date input has a minimum width below
   which the browser hides the calendar button, which is the whole point of
   it. */
.field__dates {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}
.field__dates .field__input {
  flex: 1 1 150px;
  min-width: 150px;
}
.field__between {
  color: var(--ink-muted);
  font-size: 13px;
}
