/*
 * This is a manifest file that'll be compiled into application.css.
 *
 * With Propshaft, assets are served efficiently without preprocessing steps. You can still include
 * application-wide styles in this file, but keep in mind that CSS precedence will follow the standard
 * cascading order, meaning styles declared later in the document or manifest will override earlier ones,
 * depending on specificity.
 *
 * Consider organizing styles into separate files for maintainability.
 */

/* ─── Variables ─────────────────────────────────────────────── */
:root {
  --blue-dark:   #003899;
  --blue-mid:    #0055cc;
  --blue-accent: #1a7fe0;
  --blue-bright: #3399ff;
  --blue-light:  #e6f0ff;
  --blue-grad:   linear-gradient(135deg, #1a7fe0 0%, #003899 100%);
  --green:       #1a7a4a;
  --green-light: #e8f5ee;
  --red:         #c0392b;
  --red-light:   #fdf0ee;
  --yellow-light:#fffbea;
  --amber:       #f0b429;
  --amber-dark:  #d69a1a;
  --amber-light: #fff3d6;
  --amber-text:  #4d3800;
  --grey-50:     #f5f7fb;
  --grey-100:    #edf0f7;
  --grey-200:    #d8dce8;
  --grey-500:    #8a92a3;
  --grey-700:    #4a5468;
  --grey-900:    #1a1f2e;
  --radius:      6px;
  --shadow-sm:   0 1px 3px rgba(0,0,0,.08);
  --shadow-md:   0 4px 16px rgba(0,56,153,.12);
}

/* ─── Reset & Base ───────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

/* Author rules for elements like `form` can otherwise override the browser's
   default [hidden] { display: none } — pin it so `hidden` always wins. */
[hidden] { display: none !important; }

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  font-size: 15px;
  line-height: 1.6;
  color: var(--grey-900);
  background: var(--grey-50);
}

a { color: var(--blue-accent); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ─── Header ─────────────────────────────────────────────────── */
.app-header {
  background: var(--blue-grad);
  color: #fff;
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: var(--shadow-md);
}

.app-header__inner {
  max-width: 1100px;
  margin: 0 auto;
  padding: 0 24px;
  height: 56px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.app-header__logo {
  display: flex;
  align-items: center;
  gap: 8px;
  color: #fff;
  font-weight: 600;
  font-size: 16px;
  letter-spacing: .3px;
  text-decoration: none;
}

.app-header__logo svg { opacity: .9; }

.app-header__nav a {
  color: rgba(255,255,255,.75);
  font-size: 14px;
  font-weight: 500;
  padding: 4px 10px;
  border-radius: var(--radius);
  transition: background .15s, color .15s;
  text-decoration: none;
}

.app-header__nav a:hover {
  background: rgba(255,255,255,.1);
  color: #fff;
}

/* ─── Main layout ────────────────────────────────────────────── */
.app-main {
  max-width: 1100px;
  margin: 0 auto;
  padding: 36px 24px 64px;
}

/* ─── Page header ────────────────────────────────────────────── */
.page-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 28px;
}

/* Patient-level at-a-glance tags (see PatientSummarizer) — one line per tag, label then value.
   The value keeps the grey/italic "AI-generated, not authoritative" treatment used everywhere else
   a generated summary shows up (document list rows, the document detail panel); the label doesn't,
   since a label ("Dijagnoze") is just a category name, not a claim about the patient.

   Just a border, no fill — background stays whatever's behind it (the page background), so this
   reads as an outlined pane rather than a card sitting on top of the page. */
.patient-tags {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 2px;
  margin-top: 14px;
  padding: 8px 12px;
  border: 1px solid var(--grey-200);
  border-radius: var(--radius);
}

/* Sits half over the top border, like a fieldset legend — the background color has to match
   whatever's actually behind the pane (.portal-main's grey-50, since this page always renders
   inside the clinic portal layout) to visually "cut" the border rather than just overlapping it. */
.patient-tags__title {
  position: absolute;
  top: -8px;
  left: 10px;
  padding: 0 5px;
  background: var(--grey-50);
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .5px;
  color: var(--grey-500);
}

/* Only present with more than one tag (see show.html.erb) — the whole pane is the click target,
   not just the first tag, so the collapsed state (just one line) is just as clickable as expanded. */
.patient-tags--collapsible {
  cursor: pointer;
}

.patient-tags--collapsible:hover {
  border-color: var(--blue-accent);
}

.patient-tag { font-size: 14px; }

.patient-tag__label {
  font-weight: 600;
  color: var(--grey-700);
}

.patient-tag__label::after { content: ": "; }

.patient-tag__value {
  font-style: italic;
  color: var(--grey-500);
}

.patient-tags__ellipsis {
  font-style: italic;
  color: var(--grey-500);
  margin-left: 2px;
}

.patient-tags__rest {
  display: flex;
  flex-direction: column;
  gap: 2px;
  margin-top: 2px;
}

.page-header h1 {
  font-size: 22px;
  font-weight: 700;
  color: var(--blue-mid);
  letter-spacing: -.3px;
}

/* ─── Buttons ────────────────────────────────────────────────── */
.button,
input[type="submit"],
.manual-document-form__finalize {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: var(--blue-accent);
  color: #fff;
  font-size: 14px;
  font-weight: 600;
  padding: 8px 18px;
  border-radius: var(--radius);
  border: none;
  cursor: pointer;
  text-decoration: none;
  transition: background .15s, box-shadow .15s;
  box-shadow: var(--shadow-sm);
}

.button:hover,
input[type="submit"]:hover,
.manual-document-form__finalize:hover {
  background: var(--blue-mid);
  text-decoration: none;
  color: #fff;
}

.manual-document-form ~ .button_to {
  display: inline-block;
  margin-top: 16px;
}

.manual-document-form__finalize .spinner {
  display: inline-block;
  width: 13px;
  height: 13px;
  margin-left: 8px;
  border-radius: 50%;
  border: 2px solid rgba(255, 255, 255, .4);
  border-top-color: #fff;
  animation: annotate-spin .7s linear infinite;
  vertical-align: -2px;
}

.manual-document-form__finalize:disabled { opacity: .8; cursor: default; }

.button:disabled,
input[type="submit"]:disabled {
  background: var(--grey-200);
  color: var(--grey-500);
  cursor: not-allowed;
  box-shadow: none;
}

.button--danger { background: var(--red); }
.button--danger:hover { background: #a5301f; }

/* ─── Table ──────────────────────────────────────────────────── */
table {
  width: 100%;
  border-collapse: collapse;
  background: #fff;
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
}

thead {
  background: var(--blue-grad);
  color: #fff;
}

thead th {
  padding: 12px 16px;
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .6px;
  text-align: left;
}

tbody tr {
  border-bottom: 1px solid var(--grey-100);
  transition: background .1s;
}

tbody tr:last-child { border-bottom: none; }
tbody tr:hover { background: var(--blue-light); }

tbody td {
  padding: 13px 16px;
  font-size: 14px;
  color: var(--grey-700);
}

tbody td:first-child {
  font-weight: 600;
  color: var(--grey-900);
}

.uploads-table__actions { width: 1%; text-align: right; }

.uploads-table__delete {
  background: none;
  border: none;
  padding: 4px;
  cursor: pointer;
  color: var(--grey-500);
  transition: color .1s;
}

.uploads-table__delete:hover { color: var(--red); }

.uploads-table__delete svg {
  width: 15px;
  height: 15px;
  display: block;
}

/* ─── Status badges ──────────────────────────────────────────── */
.status {
  display: inline-block;
  padding: 2px 9px;
  border-radius: 20px;
  font-size: 12px;
  font-weight: 600;
  text-transform: capitalize;
}

.status--pending    { background: var(--yellow-light); color: #856404; }
.status--collecting { background: var(--yellow-light); color: #856404; }
.status--processing { background: var(--blue-light);   color: var(--blue-mid); }
.status--processed  { background: var(--green-light);  color: var(--green); }
.status--failed     { background: var(--red-light);    color: var(--red); }

/* ─── Form ───────────────────────────────────────────────────── */
form {
  display: flex;
  flex-direction: column;
  gap: 24px;
  max-width: 640px;
}

fieldset {
  background: #fff;
  border: 1px solid var(--grey-200);
  border-radius: var(--radius);
  padding: 20px 24px;
  box-shadow: var(--shadow-sm);
}

legend {
  font-size: 13px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .6px;
  color: var(--blue-accent);
  padding: 0 6px;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 5px;
  margin-top: 16px;
}

.field:first-of-type { margin-top: 12px; }

label, .field > label {
  font-size: 13px;
  font-weight: 600;
  color: var(--grey-700);
}

input[type="text"],
input[type="date"],
select,
textarea {
  width: 100%;
  padding: 9px 12px;
  border: 1px solid var(--grey-200);
  border-radius: var(--radius);
  font-size: 14px;
  color: var(--grey-900);
  background: #fff;
  transition: border-color .15s, box-shadow .15s;
  outline: none;
}

input[type="text"]:focus,
input[type="date"]:focus,
select:focus,
textarea:focus {
  border-color: var(--blue-accent);
  box-shadow: 0 0 0 3px rgba(45,125,210,.15);
}

input[type="file"] {
  font-size: 13px;
  color: var(--grey-700);
}

textarea { resize: vertical; }

.or-divider {
  text-align: center;
  color: var(--grey-500);
  font-size: 13px;
  margin: 14px 0 0;
}

.optional {
  font-weight: 400;
  color: var(--grey-500);
  font-size: 12px;
  text-transform: none;
  letter-spacing: 0;
}

.locked-patient {
  font-size: 14px;
  color: var(--grey-700);
  margin-top: 12px;
}

.locked-patient strong { color: var(--grey-900); }

.locked-patient a {
  margin-left: 8px;
  font-size: 13px;
  color: var(--grey-500);
}

.locked-patient a:hover { color: var(--grey-900); }

.actions {
  display: flex;
  align-items: center;
  gap: 14px;
}

.actions a {
  font-size: 14px;
  color: var(--grey-500);
}

.actions a:hover { color: var(--grey-900); }

.actions button[type="reset"] {
  background: none;
  border: none;
  padding: 0;
  font-size: 14px;
  color: var(--grey-500);
  cursor: pointer;
}

.actions button[type="reset"]:hover { color: var(--grey-900); }

/* ─── Manual document form (rich-text editor gets the leftover space) ── */
.manual-document-form {
  display: flex;
  flex-direction: column;
}

.manual-document-form__body {
  flex: 1;
  display: flex;
  flex-direction: column;
}

.template-picker {
  position: relative;
  align-self: flex-end;
  margin-bottom: 8px;
}

.template-picker__trigger {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  border: 1px solid var(--grey-200);
  border-radius: var(--radius);
  background: #fff;
  color: var(--grey-700);
  font-family: inherit;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: border-color .15s, background .15s, color .15s;
}

.template-picker__trigger:hover {
  border-color: var(--blue-accent);
  background: var(--blue-light);
  color: var(--blue-accent);
}

.template-picker__panel {
  position: absolute;
  top: calc(100% + 6px);
  right: 0;
  z-index: 20;
  width: 280px;
  background: #fff;
  border: 1px solid var(--grey-200);
  border-radius: var(--radius);
  box-shadow: var(--shadow-md);
  overflow: hidden;
}

/* Two classes so this beats the global input[type="text"] rule's border/padding/radius — an
   attribute selector alone outweighs one class, per CSS specificity. */
.template-picker .template-picker__search {
  width: 100%;
  padding: 10px 12px;
  border: none;
  border-radius: 0;
  border-bottom: 1px solid var(--grey-100);
  font-size: 13px;
  outline: none;
}

.template-picker__list {
  list-style: none;
  max-height: 260px;
  overflow-y: auto;
  padding: 4px;
}

.template-picker__item {
  padding: 8px 10px;
  border-radius: 4px;
  font-size: 13px;
  color: var(--grey-900);
  cursor: pointer;
}

.template-picker__item:hover,
.template-picker__item--active {
  background: var(--blue-light);
  color: var(--blue-mid);
}

.template-picker__empty {
  padding: 12px 10px;
  text-align: center;
  font-size: 13px;
  color: var(--grey-500);
}

.manual-document-form__body trix-editor {
  min-height: 60vh;
  border-color: var(--grey-200);
  border-radius: var(--radius);
  font-size: 14px;
  color: var(--grey-900);
}

.manual-document-form__body trix-editor:focus {
  border-color: var(--blue-accent);
  box-shadow: 0 0 0 3px rgba(45,125,210,.15);
}

/* ─── Notices ────────────────────────────────────────────────── */
.notice {
  background: var(--green-light);
  color: var(--green);
  border: 1px solid #b7dfc8;
  border-radius: var(--radius);
  padding: 12px 16px;
  font-size: 14px;
  font-weight: 500;
  margin-bottom: 24px;
}

/* ─── Toast (JS-driven async-save feedback) ─────────────────── */
.toast {
  position: fixed;
  bottom: 28px;
  right: 28px;
  background: var(--grey-900);
  color: #fff;
  border-radius: var(--radius);
  padding: 12px 18px;
  font-size: 14px;
  font-weight: 500;
  box-shadow: var(--shadow-md);
  opacity: 0;
  transform: translateY(8px);
  transition: opacity .2s, transform .2s;
  pointer-events: none;
  z-index: 1000;
}

.toast--visible { opacity: 1; transform: translateY(0); }
.toast--error { background: var(--red); }

.empty-state {
  text-align: center;
  color: var(--grey-500);
  padding: 64px 0;
  font-size: 15px;
}

/* ─── Upload show layout ─────────────────────────────────────── */
.show-layout {
  display: grid;
  grid-template-columns: 360px 1fr;
  gap: 24px;
  align-items: start;
}

.show-layout--single { grid-template-columns: 1fr; }

/* .portal-main (unlike the old .app-main) has no max-width cap, so on a wide screen this grid
   would otherwise stretch its right column under the fixed .chat-edge-tab (right: 0, 44px wide,
   48px on hover) — margin-right reserves guaranteed clearance regardless of viewport width, and
   the cap keeps very wide screens readable instead of stretching the detail panel edge-to-edge. */
.portal-main .show-layout {
  max-width: 1400px;
  margin-right: 14px;
}

/* ─── Document list (left panel) ────────────────────────────── */
.doc-list {
  background: #fff;
  border: 1px solid var(--grey-200);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
  position: sticky;
  top: 76px;
}

/* Inside the clinic portal shell there's no top navbar to clear — stick flush with .portal-main's
   own top padding instead of the 76px tuned for the old app-header bar. */
.portal-main .doc-list {
  top: 36px;
}

.doc-list__header {
  padding: 16px 18px;
  border-bottom: 1px solid var(--grey-100);
}

.doc-list__header h2 {
  font-size: 16px;
  font-weight: 700;
  color: var(--grey-900);
}

.doc-list__meta {
  font-size: 12px;
  color: var(--grey-500);
  margin-top: 4px;
}

.doc-list__nav {
  display: flex;
  flex-direction: column;
}

.doc-list__item {
  display: flex;
  flex-direction: column;
  padding: 12px 18px;
  border-bottom: 1px solid var(--grey-100);
  text-decoration: none;
  transition: background .1s;
  cursor: pointer;
}

.doc-list__item:last-child { border-bottom: none; }

.doc-list__item:hover { background: var(--blue-light); text-decoration: none; }

.doc-list__item--summary {
  font-size: 14px;
  font-weight: 600;
  color: var(--blue-accent);
}

.doc-list__type {
  font-size: 14px;
  font-weight: 600;
  color: var(--grey-900);
}

.doc-list__subtitle {
  font-size: 12px;
  font-style: italic;
  color: var(--grey-500);
  margin-top: 2px;
}

/* ─── Detail panel (right panel) ────────────────────────────── */
.detail-panel {
  background: #fff;
  border: 1px solid var(--grey-200);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  padding: 28px 32px;
}

.detail-panel__header {
  margin-bottom: 16px;
  padding-bottom: 16px;
  border-bottom: 1px solid var(--grey-100);
}

.detail-panel__title {
  font-size: 20px;
  font-weight: 700;
  color: var(--blue-mid);
}

.detail-panel__subtitle {
  font-size: 14px;
  font-style: italic;
  color: var(--grey-500);
  margin-top: 4px;
}

.detail-panel__date {
  font-size: 13px;
  color: var(--grey-500);
  margin-top: 4px;
}

.detail-panel__summary {
  font-size: 15px;
  line-height: 1.7;
  color: var(--grey-700);
  margin-bottom: 24px;
}

.prose h1, .prose h2, .prose h3 {
  color: var(--blue-mid);
  font-weight: 700;
  margin: 24px 0 8px;
  line-height: 1.3;
}

.prose h1 { font-size: 20px; }
.prose h2 { font-size: 17px; }
.prose h3 { font-size: 15px; }

.prose p { margin-bottom: 14px; }

.prose strong { color: var(--grey-900); font-weight: 600; }

.prose em { font-style: italic; }

.prose ul, .prose ol {
  margin: 8px 0 14px 20px;
}

.prose li { margin-bottom: 4px; }

.prose p:last-child { margin-bottom: 0; }

.prose > :first-child { margin-top: 0; }

.prose table {
  margin: 14px 0;
}

.prose table:last-child { margin-bottom: 0; }

.detail-panel__section-title {
  font-size: 13px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .6px;
  color: var(--blue-accent);
  margin: 24px 0 12px;
}

/* ─── Tabs ───────────────────────────────────────────────────── */
.tabs {
  padding-top: 16px;
}

.tabs__nav {
  display: flex;
  align-items: center;
  gap: 4px;
  border-bottom: 2px solid var(--grey-200);
  margin-bottom: 20px;
}

.tabs__tab {
  padding: 8px 18px;
  font-size: 13px;
  font-weight: 600;
  color: var(--grey-500);
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  margin-bottom: -2px;
  cursor: pointer;
  transition: color .15s, border-color .15s;
}

.tabs__tab:hover { color: var(--grey-900); }

.tabs__tab--active {
  color: var(--blue-accent);
  border-bottom-color: var(--blue-accent);
}

.tabs__panel { display: none; }
.tabs__panel--active { display: block; }

/* ─── Lab results filter ─────────────────────────────────────── */
.lab-filter {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  margin-bottom: 12px;
}

.lab-filter__search {
  flex: 1;
  min-width: 140px;
}

.lab-filter__search input {
  width: 100%;
  padding: 7px 10px;
  border: 1px solid var(--grey-200);
  border-radius: var(--radius);
  font-size: 13px;
  color: var(--grey-900);
  background: #fff;
  outline: none;
  transition: border-color .15s, box-shadow .15s;
}

.lab-filter__search input:focus {
  border-color: var(--blue-accent);
  box-shadow: 0 0 0 3px rgba(45,125,210,.15);
}

.lab-filter__flags {
  display: flex;
  gap: 4px;
}

.lab-filter__flag {
  background: none;
  border: 1px solid var(--grey-200);
  border-radius: var(--radius);
  padding: 6px 11px;
  font-size: 12px;
  font-weight: 600;
  color: var(--grey-700);
  cursor: pointer;
  transition: background .15s, border-color .15s, color .15s;
}

.lab-filter__flag:hover { border-color: var(--blue-accent); color: var(--blue-accent); }

.lab-filter__flag--active {
  background: var(--blue-accent);
  border-color: var(--blue-accent);
  color: #fff;
}

.lab-table__empty td {
  text-align: center;
  color: var(--grey-500);
  padding: 16px;
}

/* ─── Lab results table ──────────────────────────────────────── */
.lab-table {
  font-size: 13px;
}

.lab-table th {
  font-size: 11px;
}

.lab-row--high td, .lab-row--critical_high td { background: #fff8f0; }
.lab-row--low td, .lab-row--critical_low td   { background: #f0f4ff; }

.ref-range { color: var(--grey-500); font-size: 12px; }

.flag {
  display: inline-block;
  padding: 1px 7px;
  border-radius: 10px;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
}

.flag--high, .flag--critical_high { background: #fff0e0; color: #c05000; }
.flag--low, .flag--critical_low   { background: #e8edff; color: #2244aa; }

/* ─── Findings list ──────────────────────────────────────────── */
.findings-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.finding {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 12px 0;
  border-bottom: 1px solid var(--grey-100);
}

/* Jumped to from a chat citation (see highlight_controller.js) — a transient background pulse,
   not a persistent style, so it fades back out on its own once it's done its job of catching the
   eye at the scroll destination. */
@keyframes highlight-flash {
  0%, 100% { background-color: transparent; }
  15%, 55% { background-color: var(--yellow-light); }
}

.highlight-flash { animation: highlight-flash 1.8s ease; }

.finding:last-child { border-bottom: none; }

.finding__category {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .4px;
  color: var(--blue-accent);
}

.finding__text {
  font-size: 14px;
  color: var(--grey-700);
  line-height: 1.6;
}

/* ─── File viewer ────────────────────────────────────────────── */
.file-viewer__nav {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 16px;
}

.file-viewer__btn {
  background: var(--blue-light);
  color: var(--blue-mid);
  border: none;
  border-radius: var(--radius);
  padding: 6px 14px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: background .15s;
}

.file-viewer__btn:hover:not(:disabled) { background: var(--grey-200); }
.file-viewer__btn:disabled { opacity: .4; cursor: default; }

.file-viewer__btn--icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 6px;
}

.file-viewer__counter {
  font-size: 13px;
  color: var(--grey-500);
  min-width: 48px;
  text-align: center;
}

.file-viewer__divider {
  width: 1px;
  height: 20px;
  background: var(--grey-200);
  margin: 0 4px;
}

.file-viewer__slide { display: none; flex-direction: column; gap: 8px; }
.file-viewer__slide--active { display: flex; }

.file-preview__scroll {
  overflow: auto;
  max-height: 700px;
  border: 1px solid var(--grey-200);
  border-radius: var(--radius);
  background: var(--grey-50);
  cursor: grab;
  touch-action: none;
  user-select: none;
}

.file-preview__scroll--grabbing { cursor: grabbing; }

.file-preview__image {
  width: 100%;
  display: block;
  transition: width .2s;
  -webkit-user-drag: none;
}

.file-preview__image--instant { transition: none; }

/* ─── File viewer: fullscreen popup (native <dialog>) ───────────
   Same margin/border/padding reset as .portal-modal — see its comment — but sized to fill most of
   the viewport instead of a fixed form-dialog width, since this is an image, not form content. */
.file-viewer__fullscreen {
  margin: auto;
  border: none;
  border-radius: var(--radius);
  padding: 0;
  width: 92vw;
  height: 92vh;
  max-width: none;
  background: transparent;
}

.file-viewer__fullscreen::backdrop {
  background: rgba(10,16,30,.85);
}

.file-viewer__fullscreen-close {
  position: fixed;
  top: 20px;
  right: 24px;
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(255,255,255,.1);
  border: none;
  border-radius: 50%;
  color: #fff;
  font-size: 22px;
  line-height: 1;
  cursor: pointer;
  transition: background .15s;
}

.file-viewer__fullscreen-close:hover { background: rgba(255,255,255,.2); }

.file-viewer__fullscreen-scroll {
  width: 100%;
  height: 100%;
  max-height: none;
  border: none;
  border-radius: 0;
  background: transparent;
}

.file-preview__pdf {
  width: 100%;
  height: 600px;
  border: 1px solid var(--grey-200);
  border-radius: var(--radius);
}

.file-preview__download {
  font-size: 13px;
  color: var(--blue-accent);
  align-self: flex-start;
}

.transcript {
  font-family: inherit;
  font-size: 13px;
  line-height: 1.7;
  white-space: pre-wrap;
  word-break: break-word;
  color: var(--grey-800);
  margin: 0;
  padding: 4px 0;
}

/* ─── Wizard box (steps + step controls) ────────────────────── */
.wizard-box {
  padding: 0;
  overflow: hidden;
}

.wizard-box__steps {
  padding: 16px 24px;
  background: var(--grey-50);
  border-bottom: 1px solid var(--grey-200);
}

.wizard-box__steps .wizard-steps { margin-bottom: 0; }

.wizard-box__controls {
  padding: 24px;
}

/* ─── Dropzone ───────────────────────────────────────────────── */
.dropzone {
  border: 2px dashed var(--grey-200);
  border-radius: var(--radius);
  padding: 36px 24px;
  text-align: center;
  cursor: pointer;
  transition: border-color .15s, background .15s;
}

.dropzone:hover { border-color: var(--blue-accent); }

.dropzone--active {
  border-color: var(--blue-accent);
  background: var(--blue-light);
}

.dropzone__text {
  font-size: 14px;
  font-weight: 500;
  color: var(--grey-700);
}

.dropzone__browse {
  color: var(--blue-accent);
  font-weight: 600;
  text-decoration: underline;
  text-underline-offset: 2px;
}

.dropzone__hint {
  font-size: 12px;
  color: var(--grey-500);
  margin-top: 4px;
}

.wizard-box__actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 20px;
}

.wizard-box__next {
  display: block;
  max-width: none;
  margin-top: 20px;
  text-align: right;
}

/* Already spaced by .wizard-box__actions itself (flex row with Cancel) — its own margin-top would
   just push it out of alignment with the Cancel button next to it. */
.wizard-box__actions .wizard-box__next { margin-top: 0; }

.wizard-box__next .button {
  padding: 14px 30px;
  font-size: 16px;
  border-radius: 8px;
}

/* ─── Processing status ──────────────────────────────────────── */
.processing-status {
  padding: 32px 24px;
  text-align: center;
  border-radius: var(--radius);
  font-size: 15px;
  font-weight: 500;
}

.processing-status--collecting,
.processing-status--pending { background: var(--yellow-light); color: #856404; }
.processing-status--processing { background: var(--blue-light); color: var(--blue-mid); }
.processing-status--complete { background: var(--green-light); color: var(--green); }
.processing-status--failed { background: var(--red-light); color: var(--red); }

/* ─── Annotate progress ──────────────────────────────────────── */
.annotate-progress {
  display: flex;
  flex-direction: column;
  gap: 2px;
  max-height: 420px;
  overflow-y: auto;
}

.annotate-progress__item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 14px;
  border-radius: var(--radius);
}

.annotate-progress__item:hover { background: var(--grey-50); }

.annotate-progress__title {
  font-size: 14px;
  color: var(--grey-900);
}

.annotate-progress__icon {
  flex: 0 0 auto;
  width: 16px;
  height: 16px;
}

.annotate-progress__icon--spinner {
  border-radius: 50%;
  border: 2px solid var(--blue-light);
  border-top-color: var(--blue-accent);
  animation: annotate-spin .7s linear infinite;
}

.annotate-progress__icon--done {
  color: var(--green);
}

.annotate-progress__icon--failed {
  color: var(--red);
}

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

/* ─── Wizard steps ───────────────────────────────────────────── */
.wizard-steps {
  margin-bottom: 20px;
}

.wizard-steps ol {
  list-style: none;
  display: flex;
  align-items: center;
}

.wizard-steps__step {
  display: flex;
  align-items: center;
  gap: 8px;
}

.wizard-steps__step:not(:last-child)::after {
  content: "";
  display: inline-block;
  width: 28px;
  height: 1px;
  background: var(--grey-200);
  margin-left: 12px;
}

.wizard-steps__number {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  font-size: 12px;
  font-weight: 700;
  flex-shrink: 0;
}

.wizard-steps__label {
  font-size: 13px;
  font-weight: 600;
}

.wizard-steps__step--current .wizard-steps__number { background: var(--blue-accent); color: #fff; }
.wizard-steps__step--current .wizard-steps__label { color: var(--grey-900); }

.wizard-steps__step--upcoming .wizard-steps__number {
  background: var(--grey-100);
  color: var(--grey-500);
  border: 1px solid var(--grey-200);
}

.wizard-steps__step--upcoming .wizard-steps__label { color: var(--grey-500); }

/* ─── Page list (upload wizard, step 1) ─────────────────────── */
.wizard-step {
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.wizard-step__intro {
  display: flex;
  flex-direction: column;
  gap: 20px;
  max-width: 640px;
}

.wizard-step__intro .doc-list__meta { margin-top: -8px; }

.page-list {
  list-style: none;
  background: #fff;
  border: 1px solid var(--grey-200);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
}

.page-list:empty { display: none; }

.page-list__item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 16px;
  border-bottom: 1px solid var(--grey-100);
  font-size: 14px;
  cursor: pointer;
  transition: background .1s;
}

.page-list__item:last-child { border-bottom: none; }

.page-list__item:hover { background: var(--blue-light); }

.page-list__item--active {
  background: var(--blue-light);
  box-shadow: inset 3px 0 0 var(--blue-accent);
}

.page-list__name {
  color: var(--grey-900);
  word-break: break-all;
}

.page-list__remove {
  background: none;
  border: none;
  color: var(--grey-500);
  font-size: 12px;
  cursor: pointer;
  text-decoration: underline;
  text-underline-offset: 2px;
  flex-shrink: 0;
  margin-left: 12px;
}

.page-list__remove:hover { color: var(--red); }

.page-list--errors {
  margin-top: 12px;
  border-color: #f3c9c2;
}

.page-list__item--error {
  color: var(--red);
  background: var(--red-light);
  cursor: default;
}

.page-list__item--error:hover { background: var(--red-light); }

/* ─── Organize tree (wizard step 4) ─────────────────────────── */
/* The tree (Documents) and the Unassigned box below it are two separate boxes stacked in one
   sticky column, rather than one growing list — a long document tree used to push Unassigned (and
   the whole page's scroll height) far below the fold, making drag-and-drop between the two nearly
   impossible on a patient with many documents. Capping the tree box's own height and scrolling
   *inside* it keeps Unassigned always on-screen just below it, and keeps the preview panel in the
   right-hand column from scrolling out of view as the tree grows. */
.organize-tree-column {
  display: flex;
  flex-direction: column;
  gap: 16px;
  position: sticky;
  top: 76px;
}

.organize-tree-box {
  background: #fff;
  border: 1px solid var(--grey-200);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  max-height: 65vh;
}

.organize-tree-box__scroll {
  overflow-y: auto;
  flex: 1;
  min-height: 0; /* lets this actually shrink (and thus scroll) inside a flex column parent */
}

.organize-tree__unassigned-box {
  background: #fff;
  border: 1px solid var(--grey-200);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
}

.organize-tree {
  padding: 6px 0;
  font-size: 13px;
}

.organize-tree__toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 14px;
  border-bottom: 1px solid var(--grey-100);
  margin-bottom: 4px;
}

.organize-tree__toolbar-title {
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .4px;
  color: var(--grey-500);
}

.organize-tree__new-btn {
  background: none;
  border: none;
  padding: 0;
  font-size: 13px;
  font-weight: 600;
  color: var(--blue-accent);
  cursor: pointer;
}

.organize-tree__new-btn:hover { color: var(--blue-mid); }

.organize-tree__row {
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 6px 14px;
  cursor: pointer;
  color: var(--grey-700);
  transition: background .1s;
}

.organize-tree__row:hover { background: var(--blue-light); }

.organize-tree__row--active {
  background: var(--blue-light);
  box-shadow: inset 3px 0 0 var(--blue-accent);
}

.organize-tree__row--folder {
  font-weight: 700;
  color: var(--grey-900);
}

.organize-tree__row--file {
  padding-left: 34px;
  color: var(--grey-500);
}

.organize-tree__row--current { color: var(--grey-900); }

.organize-tree__icon {
  width: 14px;
  height: 14px;
  flex-shrink: 0;
  color: var(--blue-accent);
}

.organize-tree__row--file .organize-tree__icon { color: var(--grey-500); }
.organize-tree__row--current .organize-tree__icon { color: var(--blue-accent); }

.organize-tree__pages {
  list-style: none;
  min-height: 6px;
}

.organize-tree__document--dragover {
  background: var(--blue-light);
  outline: 2px dashed var(--blue-accent);
  outline-offset: -2px;
}

.organize-tree__empty-hint {
  padding: 6px 34px;
  font-size: 12px;
  color: var(--grey-500);
  font-style: italic;
}

.organize-tree__name {
  flex: 1;
  pointer-events: none;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  min-width: 0;
}

.organize-tree__date {
  margin-left: auto;
  padding-left: 10px;
  font-size: 11px;
  font-weight: 400;
  color: var(--grey-500);
  flex-shrink: 0;
  cursor: text;
}

.organize-tree__delete-icon {
  width: 13px;
  height: 13px;
  flex-shrink: 0;
  margin-left: 8px;
  color: var(--grey-500);
  opacity: 0;
  cursor: pointer;
  transition: opacity .1s, color .1s;
}

.organize-tree__row--folder:hover .organize-tree__delete-icon,
.organize-tree__row--file:hover .organize-tree__delete-icon { opacity: 1; }
.organize-tree__delete-icon:hover { color: var(--red); }

.organize-tree__rename-input {
  width: 90%;
  padding: 2px 6px;
  border: 1px solid var(--blue-accent);
  border-radius: 4px;
  font: inherit;
  color: inherit;
  background: #fff;
}

.organize-tree__rename-input--date {
  -webkit-appearance: none;
  appearance: none;
  width: 68px;
  min-width: 62px;
  height: 16px;
  flex-shrink: 1;
  margin-left: auto;
  padding: 0 3px;
  font-size: 9px;
  font-weight: 400;
  line-height: 16px;
}

.organize-tree__rename-input--date::-webkit-calendar-picker-indicator {
  display: none;
  -webkit-appearance: none;
}

.organize-tree__rename-input--date::-webkit-datetime-edit {
  padding: 0;
}

.organize-tree__rename-input--date::-webkit-inner-spin-button {
  display: none;
}

/* ─── Organize detail panel ──────────────────────────────────── */
.organize-edit-form { max-width: 480px; }

.ocr-list {
  list-style: none;
  max-height: 500px;
  overflow-y: auto;
}

.ocr-list__item {
  padding: 10px 0;
  border-bottom: 1px solid var(--grey-100);
  font-size: 14px;
  line-height: 1.6;
  color: var(--grey-700);
  white-space: normal;
}

.ocr-list__item:last-child { border-bottom: none; }

/* ─── Timeline ───────────────────────────────────────────────── */
.timeline-panel {
  max-height: 70vh;
  overflow-y: auto;
  padding: 16px 18px;
}

/* Same cap as .timeline-panel — a patient with many documents otherwise grows this tab (and the
   whole sticky .doc-list box) tall enough to push "Dodaj dokument" and the rest of the page far
   below the fold. */
.doc-list-panel {
  max-height: 70vh;
  overflow-y: auto;
}

.timeline {
  position: relative;
  margin-left: 64px;
}

.timeline__line {
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 2px;
  background: var(--grey-200);
}

.timeline__tick {
  position: absolute;
  left: -64px;
  width: 52px;
  transform: translateY(-50%);
  text-align: right;
  white-space: nowrap;
}

.timeline__tick::after {
  content: "";
  position: absolute;
  right: -12px;
  top: 50%;
  width: 8px;
  height: 1px;
  background: var(--grey-200);
}

.timeline__tick-label {
  font-size: 11px;
  color: var(--grey-500);
}

/* A discharge document's admission-to-discharge span. Drawn over the tick dashes rather than
   reserving its own space — it doesn't need to avoid them, just sit visually above. The top/bottom
   pseudo-elements turn the plain vertical line into a bracket, capped toward the main dot column. */
.timeline__stay {
  position: absolute;
  left: -14px;
  width: 3px;
  border-radius: 1.5px;
  background: var(--blue-accent);
  z-index: 1;
  transition: background .1s;
}

.timeline__stay::before,
.timeline__stay::after {
  content: "";
  position: absolute;
  left: 0;
  height: 3px;
  border-radius: 1.5px;
  background: var(--blue-accent);
  transition: background .1s;
}

.timeline__stay::before { top: -1.5px; width: 12px; } /* reaches .timeline__stay-anchor's left edge */
.timeline__stay::after { bottom: -1.5px; width: 10px; } /* reaches .timeline__dot's left edge */

.timeline__stay--active,
.timeline__stay--active::before,
.timeline__stay--active::after {
  background: var(--blue-mid);
}

/* Closes off the bracket's top end at the admission date — same fill as a real dot, but smaller,
   since it isn't a separate clickable document. Lights up like a dot on hover, though. */
.timeline__stay-anchor {
  position: absolute;
  left: -2px;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--blue-accent);
  border: 1.5px solid var(--blue-accent);
  transform: translateY(-50%);
  z-index: 1;
  transition: transform .1s, background .1s, border-color .1s;
}

.timeline__stay-anchor--active {
  background: var(--blue-mid);
  border-color: var(--blue-mid);
  transform: translateY(-50%) scale(1.4);
}

.timeline__dot {
  position: absolute;
  left: -4px;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--blue-accent);
  border: 2px solid #fff;
  box-shadow: 0 0 0 1px var(--blue-accent);
  transform: translateY(-50%);
  z-index: 1;
  transition: transform .1s, box-shadow .1s;
}

.timeline__dot--active {
  transform: translateY(-50%) scale(1.5);
  box-shadow: 0 0 0 1px var(--blue-accent), 0 0 0 4px var(--blue-light);
}

/* The document's exact date, shown to the left of its dot only while that document is hovered — the
   tick labels alone are too coarse (month/year) to give the real date without opening the document.
   Fixed positioning (top/left set from JS, from the dot's real screen rect) rather than absolute
   within the gutter — that gutter isn't wide enough for the bubble without overlapping the dot, and
   .timeline-panel's overflow-y: auto implicitly clips overflow-x too, so anything positioned outside
   the gutter would just get cut off instead of floating over the content. */
.timeline__dot-date {
  position: fixed;
  transform: translate(-100%, -50%);
  white-space: nowrap;
  font-size: 11px;
  font-weight: 600;
  color: var(--grey-700);
  background: #fff;
  border: 1px solid var(--grey-200);
  border-radius: 4px;
  padding: 2px 6px;
  box-shadow: var(--shadow-sm);
  opacity: 0;
  visibility: hidden;
  transition: opacity .1s;
  pointer-events: none;
  z-index: 300;
}

.timeline__dot-date--active {
  opacity: 1;
  visibility: visible;
}

/* The "add a document" entry point — a persistent footer of the .doc-list box, outside both tab
   panels' own scroll areas (see .timeline-panel/.doc-list-panel), so it stays reachable without
   scrolling regardless of which tab is active or how long that tab's own content is. */
.doc-list__footer {
  padding: 12px 14px;
  border-top: 1px solid var(--grey-100);
}

.add-document {
  /* Reset button chrome (used from a <button>, opening the Uvezi/Kreiraj choice dialog, not
     just an <a>) so it renders identically either way. */
  width: 100%;
  background: none;
  font-family: inherit;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 8px 10px;
  border: 1.5px dashed var(--grey-200);
  border-radius: 4px;
  color: var(--grey-500);
  font-size: 13px;
  font-weight: 600;
  text-decoration: none;
  transition: border-color .15s, color .15s, background .15s;
}

.add-document:hover {
  border-color: var(--blue-accent);
  border-style: solid;
  color: var(--blue-accent);
  background: var(--blue-light);
  text-decoration: none;
}

.timeline__marker {
  position: absolute;
  left: 20px;
  right: 0;
  height: 46px;
  overflow: hidden;
  display: flex;
  align-items: center;
  text-decoration: none;
}

.timeline__label {
  display: flex;
  flex-direction: column;
  min-width: 0;
  width: 100%;
  background: var(--grey-50);
  border-radius: 4px;
  padding: 4px 8px;
}

.timeline__title {
  font-size: 13px;
  line-height: 18px;
  font-weight: 600;
  color: var(--grey-900);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Marks a draft document (see Document#finalize!) wherever it's listed — timeline, undated list,
   List tab — so it's clear at a glance it still needs to be finalized. */
.draft-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 16px;
  height: 16px;
  margin-right: 4px;
  border-radius: 4px;
  background: var(--yellow-light);
  color: #856404;
  vertical-align: -3px;
}

.timeline__marker:hover { text-decoration: none; }
.timeline__marker:hover .timeline__title { color: var(--blue-mid); }

.timeline__subtitle {
  font-size: 11px;
  line-height: 14px;
  font-style: italic;
  color: var(--grey-500);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.timeline__marker.timeline__label--active .timeline__label,
.timeline__group-item.timeline__label--active {
  background: var(--blue-light);
}

.timeline__marker.timeline__label--active .timeline__title,
.timeline__group-item.timeline__label--active .timeline__title {
  color: var(--blue-mid);
}

/* Persistent "this is the document currently open in the detail panel" marker — set by
   active_document_controller, distinct from the transient hover state above (timeline__label--active)
   which clears on mouseleave. Shared across the timeline dots/labels and the List tab's rows. */
.timeline__dot.is-open-document {
  background: var(--blue-mid);
  box-shadow: 0 0 0 1px var(--blue-mid), 0 0 0 4px var(--blue-light);
}

.timeline__marker.is-open-document .timeline__label,
.timeline__group-item.is-open-document {
  background: var(--blue-accent);
}

.timeline__marker.is-open-document .timeline__title,
.timeline__marker.is-open-document .timeline__subtitle,
.timeline__group-item.is-open-document .timeline__title,
.timeline__group-item.is-open-document .timeline__subtitle {
  color: #fff;
}

.doc-list__item.is-open-document {
  background: var(--blue-accent);
}

.doc-list__item.is-open-document .doc-list__type,
.doc-list__item.is-open-document .doc-list__subtitle {
  color: #fff;
}

/* ─── Timeline: clustered labels ─────────────────────────────── */
.timeline__group {
  position: absolute;
  left: 20px;
  right: 0;
  border: 1px solid var(--grey-200);
  border-radius: 4px;
  box-shadow: var(--shadow-sm);
  overflow: hidden;
  background: var(--grey-50);
}

.timeline__group-item {
  display: flex;
  flex-direction: column;
  justify-content: center;
  height: 42px;
  padding: 0 8px;
  text-decoration: none;
  border-bottom: 1px solid var(--grey-100);
}

.timeline__group-item:last-child { border-bottom: none; }

.timeline__group-item:hover { text-decoration: none; }
.timeline__group-item:hover .timeline__title { color: var(--blue-mid); }

.timeline__undated {
  margin: 16px 16px 0;
  padding-top: 12px;
  border-top: 1px solid var(--grey-100);
}

.timeline__undated-title {
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .4px;
  color: var(--grey-500);
  margin-bottom: 4px;
  padding: 0 2px;
}

/* ─── Chat panel (patient assistant) ────────────────────────────
   Fixed to the viewport's right edge rather than laid out inside
   .app-main — on wide screens it lives in the margin beside the
   centered 1100px container instead of shrinking it; on narrower
   screens it slides over the content. */
.chat-edge-tab {
  position: fixed;
  top: 22%;
  right: 0;
  transform: translateY(-50%);
  z-index: 150;
  width: 44px;
  height: 88px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--blue-accent);
  color: #fff;
  border: none;
  border-radius: 10px 0 0 10px;
  box-shadow: var(--shadow-md);
  cursor: pointer;
  transition: background .15s, width .15s;
}

.chat-edge-tab:hover {
  background: var(--blue-mid);
  width: 48px;
}

.chat-panel {
  position: fixed;
  top: 0;
  right: 0;
  height: 100vh;
  width: 900px;
  max-width: 92vw;
  background: #fff;
  border-left: 1px solid var(--grey-200);
  box-shadow: var(--shadow-md);
  display: flex;
  flex-direction: column;
  transform: translateX(100%);
  transition: transform .22s ease;
  z-index: 200;
}

.chat-panel--open { transform: translateX(0); }

.chat-panel__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 18px;
  border-bottom: 1px solid var(--grey-100);
}

.chat-panel__header-chat,
.chat-panel__header-list {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.chat-panel__title {
  font-size: 15px;
  font-weight: 700;
  color: var(--grey-900);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.chat-panel__subtitle {
  font-size: 12px;
  color: var(--grey-500);
  margin-top: 2px;
}

.chat-panel__header-actions {
  display: flex;
  align-items: center;
  gap: 2px;
  flex-shrink: 0;
}

.chat-panel__icon-btn,
.chat-panel__close {
  background: none;
  border: none;
  color: var(--grey-500);
  cursor: pointer;
  padding: 6px;
  line-height: 0;
  border-radius: var(--radius);
}

.chat-panel__icon-btn:hover,
.chat-panel__close:hover {
  color: var(--grey-900);
  background: var(--grey-100);
}

.chat-panel__chat-view {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
}

.chat-panel__messages {
  flex: 1;
  overflow-y: auto;
  padding: 18px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.chat-bubble {
  /* Capped in absolute px too — at 900px panel width, 85% alone would stretch lines
     uncomfortably wide for reading long responses. */
  max-width: min(85%, 640px);
  padding: 10px 14px;
  border-radius: 14px;
  font-size: 14px;
  line-height: 1.55;
}

.chat-bubble--agent {
  align-self: flex-start;
  background: var(--grey-100);
  color: var(--grey-900);
  border-bottom-left-radius: 4px;
}

/* Reference badge attached under a paragraph of the assistant's reply (see
   ApplicationHelper#citation_badge) — a paragraph can have at most one, since the assistant's
   [[cite:...]] tag bundles every id for that paragraph into one badge. */
/* margin-bottom matches .prose p's own margin-bottom (14px) — the citation div sits between two
   <p> tags, so unlike normal paragraph-to-paragraph spacing (which comes entirely from the
   preceding <p>'s margin-bottom), it needs to supply that gap to the paragraph after it itself. */
.chat-citation { margin: 6px 0 14px; }

.chat-citation__toggle {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  background: var(--blue-light);
  color: var(--blue-mid);
  border: none;
  border-radius: 999px;
  padding: 3px 10px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  transition: background .15s;
}

.chat-citation__toggle:hover { background: #d6e6ff; }

/* Disabled while the message is still streaming in (see ApplicationHelper#chat_message_html) —
   every tick replaces this message's HTML wholesale, which would otherwise wipe out an expanded
   badge's open state the instant the next tick arrives. */
.chat-citation__toggle:disabled {
  opacity: .6;
  cursor: default;
}

.chat-citation__toggle:disabled:hover { background: var(--blue-light); }

.chat-citation__toggle svg { transition: transform .15s; }

.chat-citation:has(.chat-citation__list:not([hidden])) .chat-citation__toggle svg {
  transform: rotate(180deg);
}

.chat-citation__list {
  display: flex;
  flex-direction: column;
  gap: 4px;
  margin-top: 6px;
}

.chat-citation__link {
  display: block;
  font-size: 12px;
  color: var(--grey-700);
  background: var(--grey-50);
  border: 1px solid var(--grey-200);
  border-radius: 6px;
  padding: 6px 10px;
  text-decoration: none;
  transition: background .15s, color .15s;
}

.chat-citation__link:hover {
  background: var(--blue-light);
  color: var(--blue-mid);
  text-decoration: none;
}

.chat-bubble--user {
  align-self: flex-end;
  background: var(--blue-accent);
  color: #fff;
  border-bottom-right-radius: 4px;
}

.chat-panel__input {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  padding: 14px;
  border-top: 1px solid var(--grey-100);
}

.chat-panel__textarea {
  flex: 1;
  resize: none;
  border: 1px solid var(--grey-200);
  border-radius: var(--radius);
  padding: 9px 12px;
  font-size: 14px;
  font-family: inherit;
  line-height: 1.5;
  max-height: 140px;
}

.chat-panel__textarea:focus {
  outline: none;
  border-color: var(--blue-accent);
}

.chat-panel__send {
  padding: 9px 16px;
}

.typing-dots {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 0;
}

.typing-dots__dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--grey-500);
  animation: typing-bounce 1.2s infinite ease-in-out;
}

.typing-dots__dot:nth-child(2) { animation-delay: .15s; }
.typing-dots__dot:nth-child(3) { animation-delay: .3s; }

@keyframes typing-bounce {
  0%, 60%, 100% { transform: translateY(0); opacity: .4; }
  30% { transform: translateY(-4px); opacity: 1; }
}

.chat-panel__list-view {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
}

.chat-panel__conv-list {
  display: flex;
  flex-direction: column;
}

.chat-panel__conv-item {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 3px;
  width: 100%;
  padding: 14px 18px;
  border: none;
  border-bottom: 1px solid var(--grey-100);
  background: none;
  text-align: left;
  cursor: pointer;
}

.chat-panel__conv-item:hover { background: var(--blue-light); }

.chat-panel__conv-new {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  padding: 14px 18px;
  border: none;
  border-bottom: 1px solid var(--grey-100);
  background: none;
  text-align: left;
  cursor: pointer;
  color: var(--blue-accent);
  font-size: 14px;
  font-weight: 600;
}

.chat-panel__conv-new:hover { background: var(--blue-light); }

.chat-panel__conv-title {
  font-size: 14px;
  font-weight: 600;
  color: var(--grey-900);
}

.chat-panel__conv-date {
  font-size: 12px;
  color: var(--grey-500);
}

.chat-panel__list-empty {
  padding: 24px 18px;
  font-size: 13px;
  color: var(--grey-500);
  text-align: center;
}

/* ─── Notebook panel (doctor's private scratchpad) ───────────────
   Same slide-out mechanics as the chat panel above, positioned as a second edge tab directly below
   it (22% + chat's own half-height + a gap), in amber instead of blue so the two are never
   confused at a glance despite sharing the same interaction pattern. */
.notebook-edge-tab {
  position: fixed;
  top: calc(22% + 54px);
  right: 0;
  z-index: 150;
  width: 44px;
  height: 88px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--amber);
  color: var(--amber-text);
  border: none;
  border-radius: 10px 0 0 10px;
  box-shadow: var(--shadow-md);
  cursor: pointer;
  transition: background .15s, width .15s;
}

.notebook-edge-tab:hover {
  background: var(--amber-dark);
  width: 48px;
}

.notebook-panel {
  position: fixed;
  top: 0;
  right: 0;
  height: 100vh;
  width: 900px;
  max-width: 92vw;
  background: #fff;
  border-left: 1px solid var(--grey-200);
  box-shadow: var(--shadow-md);
  display: flex;
  flex-direction: column;
  transform: translateX(100%);
  transition: transform .22s ease;
  z-index: 200;
}

.notebook-panel--open { transform: translateX(0); }

.notebook-panel__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 18px;
  border-bottom: 1px solid var(--grey-100);
}

.notebook-panel__header-editor,
.notebook-panel__header-list {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.notebook-panel__title {
  font-size: 15px;
  font-weight: 700;
  color: var(--grey-900);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.notebook-panel__subtitle {
  font-size: 12px;
  color: var(--grey-500);
  margin-top: 2px;
  min-height: 15px; /* reserves space so the "Čuva se…"/"Sačuvano" indicator appearing/disappearing doesn't shift the header */
}

.notebook-panel__header-actions {
  display: flex;
  align-items: center;
  gap: 2px;
  flex-shrink: 0;
}

.notebook-panel__icon-btn,
.notebook-panel__close {
  background: none;
  border: none;
  color: var(--grey-500);
  cursor: pointer;
  padding: 6px;
  line-height: 0;
  border-radius: var(--radius);
}

.notebook-panel__icon-btn:hover,
.notebook-panel__close:hover {
  color: var(--grey-900);
  background: var(--grey-100);
}

.notebook-panel__editor-view {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  padding: 4px 18px 18px;
}

.notebook-panel__editor-view trix-editor {
  border: none;
  min-height: 100%;
  padding: 0;
  outline: none;
}

.notebook-panel__list-view {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
}

.notebook-panel__note-list {
  display: flex;
  flex-direction: column;
}

.notebook-panel__note-item {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  padding: 14px 18px;
  border: none;
  border-bottom: 1px solid var(--grey-100);
  background: none;
  text-align: left;
  cursor: pointer;
}

.notebook-panel__note-item:hover { background: var(--amber-light); }

.notebook-panel__note-title {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 14px;
  font-weight: 600;
  color: var(--grey-900);
}

.notebook-panel__note-date {
  flex-shrink: 0;
  font-size: 12px;
  color: var(--grey-500);
}

.notebook-panel__note-delete {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 22px;
  height: 22px;
  border-radius: var(--radius);
  color: var(--grey-500);
  opacity: 0;
  cursor: pointer;
  transition: opacity .1s, color .1s, background .1s;
}

.notebook-panel__note-item:hover .notebook-panel__note-delete { opacity: 1; }
.notebook-panel__note-delete:hover { color: var(--red); background: var(--red-light); }

.notebook-panel__note-new {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  padding: 14px 18px;
  border: none;
  border-bottom: 1px solid var(--grey-100);
  background: none;
  text-align: left;
  cursor: pointer;
  color: var(--amber-dark);
  font-size: 14px;
  font-weight: 600;
}

.notebook-panel__note-new:hover { background: var(--amber-light); }

.notebook-panel__list-empty {
  padding: 24px 18px;
  font-size: 13px;
  color: var(--grey-500);
  text-align: center;
}
