/* "Your procedures" page (procedures.html). Builds on style.css for
   the tokens, button and avatar styles. */

.procedures-page {
  display: grid;
  grid-template-columns: 330px minmax(0, 1fr) 380px;   /* rail width as on the note page */
  min-height: 100vh;
  margin: 0;
  background: var(--surface);
  color: var(--text);
}
.proc-side { padding: 28px 32px; border-right: 1px solid var(--border); }
/* The grey rail, styled exactly like the note page's (#tools-rail):
   account block at the top, the assistant chat filling the rest with
   its messages pinned to the bottom. It is one screen tall and sticks
   while the procedure list scrolls -- align-self keeps the grid from
   stretching it to the full page height, which would push the chat
   off the bottom of the screen. */
.proc-account {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 0.75rem;
  align-self: start;
  height: 100vh;
  position: sticky;
  top: 0;
  box-sizing: border-box;
  padding: 16px 24px 24px;
  background: #f5f5f5;
}
.proc-account #assistant-panel { flex: 1; min-height: 0; display: flex; }
.proc-main { --proc-x-w: 36px; padding: 28px calc(40px + var(--proc-x-w)) 80px 40px; border-right: 1px solid var(--border); }

.proc-title { margin: 36px 0 16px 8px; font: 600 18px/1.3 var(--font); }
.proc-search {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 16px;          /* 8px above/below the text, 16px before it */
  border: 1px solid #d5dae0;
  border-radius: 999px;
  color: var(--text-muted);
}
.proc-search input {
  flex: 1;
  min-width: 0;
  border: 0;
  outline: none;
  background: none;
  padding: 0;
  font: 400 14px/1.4 var(--font);
  color: var(--text);
}
.proc-search input::placeholder { color: var(--text-muted); }
.proc-side-actions { display: flex; justify-content: flex-end; margin-top: 16px; }
.proc-side-actions .btn-dark { margin: 0; }   /* same button as Send to Epic (style.css .btn-dark) */

/* The account block and its menu are the note page's (#rail-account in
   style.css); the menu hangs below the name, aligned to its left. */
.proc-account .account-menu { left: 0; right: auto; }

.proc-status { min-height: 20px; margin-bottom: 8px; color: var(--text-muted); font: 400 14px/1.4 var(--font); }
.proc-status.is-error { color: var(--error); }
.proc-empty { color: var(--text-muted); font: 400 16px/1.4 var(--font); }

/* One procedure */
.proc-card { padding: 28px 0 36px; }
.proc-card + .proc-card { border-top: 0; }
.proc-head {
  display: flex;
  align-items: baseline;
  gap: 12px;
  padding-bottom: 10px;
  border-bottom: 1px solid #c9ced3;
}
.proc-name {
  margin: 0;
  min-width: 2ch;
  outline: none;
  font: 600 18px/1.3 var(--font);
  color: var(--text);
}
.proc-dot { color: #b9bec4; font-size: 12px; }
.proc-key { font: italic 400 18px/1.3 var(--font); color: #5f6368; }
.proc-saved { margin-left: auto; color: var(--text-muted); font: 400 13px/1 var(--font); }
.proc-saved.is-error { color: var(--error); }
.proc-more {
  margin: 0;
  padding: 0 8px;
  min-height: 0;
  height: 28px;
  background: none;
  color: #5f6368;
  font-size: 22px;
  line-height: 1;
  align-self: center;
  border-radius: 6px;
}
.proc-more:hover { background: #f3f3f3; filter: none; }

.proc-alias { margin: 16px 0 18px; font: 400 16px/1.5 var(--font); }
.proc-alias-text { outline: none; min-width: 4ch; display: inline; }

/* Read-only state: no placeholders, no add row, no remove tabs, toggles inert. */
.proc-card:not(.is-editing) [data-placeholder]:empty::before { content: none; }
.proc-card:not(.is-editing) .proc-add-field { display: none; }
.proc-card:not(.is-editing) .proc-row-x { display: none; }
.proc-card:not(.is-editing) .proc-toggle { cursor: default; }
.proc-card:not(.is-editing) .proc-toggle:hover { border-color: #c6d3d6; background: rgba(215, 230, 233, 0.2); }
.proc-toggle:disabled { opacity: 1; }
/* The toggle's caret only while editing. */
.proc-card:not(.is-editing) .proc-toggle::after { display: none; }

/* Editable text: no box until focused, then a soft underline. */
[contenteditable][data-placeholder]:empty::before { content: attr(data-placeholder); color: #9aa0a6; }
[contenteditable]:focus { outline: none; }   /* the caret is the only focus indicator */

/* Field table */
.proc-table {
  width: 100%;
  border: 1px solid #d5dae0;
  border-collapse: separate;
  border-spacing: 0;
  border-radius: 4px;
  font: 400 14px/1.4 var(--font);   /* everything in the table is 14px */
}
.proc-table th {
  padding: 12px 14px;
  background: #f6f7f8;
  border-bottom: 1px solid #d5dae0;
  text-align: left;
  font: 600 14px/1.4 var(--font);
}
.proc-table td { padding: 16px 14px; vertical-align: top; border-bottom: 1px solid #d5dae0; }
.proc-table tbody tr:last-child td { border-bottom: 0; }
.proc-td-field { width: 30%; }
.proc-label { min-width: 4ch; }
/* A new field's empty name is drawn as a pill ("Type here"), like the
   toggles beside it, until something is typed. */
.proc-label:empty {
  display: inline-block;
  box-sizing: border-box;
  height: 22px;
  padding: 0 8px;
  border: 1px solid #c6d3d6;
  border-radius: 6px;
  background: rgba(215, 230, 233, 0.2);
  color: #51657e;
  font: 600 12px/20px var(--font);
}
.proc-label:empty::before { color: #51657e; }
.proc-fkey {
  display: none;              /* system key; the label is what clinicians see */
  margin-top: 6px;
  padding: 2px 8px;
  border-radius: 4px;
  background: #f1f3f4;
  font: 400 14px/1.5 ui-monospace, SFMono-Regular, Menlo, monospace;
  min-width: 3ch;
}
/* The toggle: the note's pill with a label and a caret. Spec: 22px
   high, radius 6, 1px #C6D3D6 outline, #D7E6E9 at 20% fill, 12px
   semibold #51657E text, 8px between outline and text. */
.proc-toggle {
  box-sizing: border-box;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin: 0;
  min-height: 0;
  height: 22px;
  padding: 0 8px;
  border: 1px solid #c6d3d6;
  border-radius: 6px;
  background: rgba(215, 230, 233, 0.2);
  color: #51657e;
  font: 600 12px/1 var(--font);
  cursor: pointer;
  white-space: nowrap;
}
.proc-toggle::after {
  content: "";
  width: 0; height: 0;
  border-left: 4px solid transparent;
  border-right: 4px solid transparent;
  border-top: 5px solid #51657e;
}
/* No hover state; the gradient outline only while the toggle is open (focused). */
.proc-toggle:focus-visible {
  border-color: transparent;
  background:
    linear-gradient(rgba(215, 230, 233, 0.2), rgba(215, 230, 233, 0.2)) padding-box,
    linear-gradient(#fff, #fff) padding-box,
    linear-gradient(90deg, #9cbef5 0%, #4bb0e9 44%, #96aee7 99%) border-box;
  outline: none;
  filter: none;
}
.proc-td-options { width: 38%; }
.proc-options { min-width: 6ch; }
.proc-options > div { position: relative; padding-left: 1.1em; }
.proc-options > div::before { content: "\2022"; position: absolute; left: 0.2em; }
.proc-hint { display: none; }   /* ghost text in the note; kept in the data, not edited here */
.proc-unit-wrap { font: 400 14px/1.4 var(--font); }
.proc-unit { color: var(--text); min-width: 2ch; display: inline-block; }
.proc-row[data-kind="choice"] .proc-hint { display: none; }
.proc-row:not([data-kind="choice"]) .proc-options { display: none; }
.proc-row:not([data-kind="number"]) .proc-unit-wrap { display: none; }
/* Remove-row control: a tab on the table's right edge, the height of
   its row, shown while that row is being edited (or hovered). */
/* A zero-width last cell anchors the tab to the table's right edge. */
.proc-th-x, .proc-td-x { width: 0; padding: 0 !important; position: relative; }
.proc-row-x {
  position: absolute;
  top: -1px;
  bottom: -1px;
  right: calc(-1 * var(--proc-x-w) - 1px);
  width: var(--proc-x-w);
  margin: 0;
  padding: 0;
  min-height: 0;
  border: 1px solid #d5dae0;
  border-left: 0;
  border-radius: 0 6px 6px 0;
  background: #fafbfc;
  color: #5f6368;
  font-size: 16px;
  line-height: 1;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.12s;
}
.proc-row:hover .proc-row-x, .proc-row:focus-within .proc-row-x { opacity: 1; pointer-events: auto; }
.proc-row-x:hover { background: #f1f3f4; color: var(--text); filter: none; }

/* Add-field row: 1px #E0E0E0 dashes, 5px dash / 5px gap, radius 5.
   A CSS dashed border can't set the dash length, so the outline is an
   SVG stroke (2px, half of it clipped outside = 1px visible). */
.proc-add-field {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  margin: 10px 0 0;
  min-height: 0;
  height: 44px;
  padding: 0;
  border: 0;
  border-radius: 5px;
  background-color: transparent;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg'%3E%3Crect width='100%25' height='100%25' rx='5' ry='5' fill='none' stroke='%23E0E0E0' stroke-width='2' stroke-dasharray='5 5'/%3E%3C/svg%3E");
  color: var(--text);
  line-height: 0;
}
.proc-add-field:hover { background-color: #f8f9fa; filter: none; }

/* ... menu */
.proc-menu {
  position: fixed;
  z-index: 60;
  min-width: 220px;
  padding: 4px;
  background: #fff;
  border: 1px solid var(--panel-border);
  border-radius: 6px;
  box-shadow: var(--panel-shadow);
  font: 400 14px/1.3 var(--font);
}
.proc-menu button {
  display: block;
  width: 100%;
  margin: 0;
  min-height: 0;
  padding: 6px 8px;
  border: 0;
  border-radius: 5px;
  background: none;
  color: var(--text);
  font: inherit;
  text-align: left;
}
.proc-menu button:hover { background: #f3f3f3; filter: none; }
.proc-menu button[hidden] { display: none; }
.proc-menu button:disabled { opacity: 0.4; }

.proc-hidden { margin-top: 24px; color: var(--text-muted); font: 400 15px/1.5 var(--font); }
.proc-hidden button { margin: 0 0 0 6px; padding: 0; min-height: 0; background: none; color: var(--primary); font: inherit; }

@media (max-width: 1100px) {
  .procedures-page { grid-template-columns: 1fr; }
  .proc-side, .proc-main { border-right: 0; }
  .proc-account { display: none; }
}
