/*
  Baseline Enterprise — Indigo Flux design system utilities.
  Tailwind CSS handles most styling via CDN + inline config in _Layout.cshtml.
  This file supplements with scrollbar theming, transitions, and component-level
  tweaks that Tailwind utilities alone can't express.
*/

/* Smooth color transitions for theme switching; font-size scales via html % (site.js) */
html {
  transition: background-color 0.2s ease, color 0.2s ease, font-size 0.15s ease;
}

/* Custom scrollbar for sidebar and main content */
.baseline-scrollbar::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}

.baseline-scrollbar::-webkit-scrollbar-track {
  background: transparent;
}

.baseline-scrollbar::-webkit-scrollbar-thumb {
  border-radius: 3px;
}

html:not(.dark) .baseline-scrollbar::-webkit-scrollbar-thumb {
  background: #c7c4d7;
}

html.dark .baseline-scrollbar::-webkit-scrollbar-thumb {
  background: #464554;
}

/* Study worklist — fixed columns; series preview scrolls inside the row width. */
#studies-worklist-table {
  table-layout: fixed;
}

#studies-worklist-table thead a.worklist-sort-link {
  color: inherit;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  gap: 0.15rem;
  max-width: 100%;
}

#studies-worklist-table thead a.worklist-sort-link:hover {
  text-decoration: underline;
}

#studies-worklist-table thead a.worklist-sort-link:focus-visible {
  outline: 2px solid currentColor;
  outline-offset: 2px;
}

#studies-worklist-table thead .worklist-sort-icons {
  display: inline-flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  line-height: 0;
}

#studies-worklist-table thead .worklist-sort-icons--neutral {
  gap: 0.14rem;
  margin-left: 0.05rem;
  color: var(--color-on-surface-variant, #6b7280);
  opacity: 0.55;
}

html.dark #studies-worklist-table thead .worklist-sort-icons--neutral {
  color: var(--color-dark-on-surface-variant, #9ca3af);
  opacity: 0.65;
}

#studies-worklist-table thead .worklist-sort-icons--active {
  margin-left: 0.1rem;
  color: inherit;
  opacity: 0.95;
}

#studies-worklist-table thead .worklist-sort-icons--default {
  opacity: 0.72;
}

#studies-worklist-table thead .worklist-sort-arrow {
  display: block;
  width: 0.5rem;
  height: 0.3125rem;
}

#studies-worklist-table thead .worklist-sort-icons--active .worklist-sort-arrow {
  width: 0.5625rem;
  height: 0.375rem;
}

#studies-worklist-table thead .worklist-sort-th--active .worklist-sort-link {
  font-weight: 600;
}

/* Worklist search — preset dropdown + date range in one bordered control */
.worklist-date-range-combo {
  display: flex;
  align-items: stretch;
  width: 100%;
  min-height: 2.25rem;
  border-radius: 0.375rem;
  border: 1px solid color-mix(in srgb, var(--color-outline-variant, #c4c7cf) 40%, transparent);
  background: var(--color-surface, #fff);
  overflow: hidden;
  transition: box-shadow 0.15s ease, border-color 0.15s ease;
}

html.dark .worklist-date-range-combo {
  border-color: color-mix(in srgb, var(--color-dark-outline-variant, #5c5f66) 50%, transparent);
  background: var(--color-dark-surface-container-high, #2b2930);
}

.worklist-date-range-combo:focus-within {
  border-color: transparent;
  box-shadow: 0 0 0 2px var(--color-primary, #4f46e5);
}

html.dark .worklist-date-range-combo:focus-within {
  box-shadow: 0 0 0 2px var(--color-primary-light, #818cf8);
}

.worklist-date-preset {
  flex: 0 0 auto;
  width: 6.75rem;
  max-width: 42%;
  padding: 0.35rem 1.35rem 0.35rem 0.5rem;
  border: 0;
  border-right: 1px solid color-mix(in srgb, var(--color-outline-variant, #c4c7cf) 35%, transparent);
  background-color: transparent;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 12 12'%3E%3Cpath fill='%236b7280' d='M2.2 4.2 6 8.1l3.8-3.9H2.2z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 0.35rem center;
  background-size: 0.65rem;
  color: inherit;
  font-size: 0.8125rem;
  line-height: 1.25rem;
  appearance: none;
  cursor: pointer;
}

html.dark .worklist-date-preset {
  border-right-color: color-mix(in srgb, var(--color-dark-outline-variant, #5c5f66) 45%, transparent);
}

.worklist-date-range-input {
  flex: 1 1 auto;
  min-width: 0;
  width: 100%;
  padding: 0.35rem 0.5rem;
  border: 0;
  background: transparent;
  color: inherit;
  font-size: 0.8125rem;
  line-height: 1.25rem;
}

.worklist-date-range-input:focus {
  outline: none;
}

.worklist-date-range-input::placeholder {
  color: var(--color-outline, #9ca3af);
}

html.dark .worklist-date-range-input::placeholder {
  color: var(--color-dark-outline, #9ca3af);
}

#studies-worklist-table tbody tr.study-row > td {
  overflow: hidden;
  vertical-align: top;
}

/* Ellipsis in fixed-layout cells (max-width:0 trick); skip icon/action columns. */
#studies-worklist-table tbody tr.study-row > td.worklist-cell-ellipsis {
  max-width: 0;
}

#studies-worklist-table .worklist-cell-ellipsis__text {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  min-width: 0;
}

#studies-worklist-table tbody tr.study-row > td.worklist-cell-actions {
  overflow: visible;
}

#studies-worklist-table .study-series-row > td {
  padding: 0;
  overflow: hidden;
  /* Colspan cell must not grow with flex/card min-content (keeps Rad.Group+ columns visible). */
  width: 100%;
  max-width: 0;
}

.study-series-preview-pane {
  overflow-x: auto;
  overflow-y: hidden;
  width: 100%;
  max-width: 100%;
  scrollbar-width: thin;
}

/* Studies worklist — responsive card / row / table (docs/design/studies-worklist-responsive.html). */
.studies-worklist-responsive-root {
  container-type: inline-size;
  container-name: studies-worklist;
}

.studies-worklist-cards,
.studies-worklist-rows,
.studies-worklist-table-mount {
  display: none;
}

.worklist-responsive-empty {
  margin: 0;
  padding: 2rem 0.5rem;
  text-align: center;
  color: var(--color-on-surface-variant, #6b7280);
}

html.dark .worklist-responsive-empty {
  color: var(--color-dark-on-surface-variant, #9ca3af);
}

.worklist-responsive-select-all {
  margin-bottom: 0.75rem;
}

.worklist-responsive-select-all__label {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  min-height: 2.75rem;
  font-size: 0.875rem;
  color: var(--color-on-surface-variant, #6b7280);
}

.worklist-study-card {
  border: 1px solid color-mix(in srgb, var(--color-outline-variant, #c4c7cf) 35%, transparent);
  border-radius: 0.5rem;
  padding: 0.5rem 0.75rem 0.75rem;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  background: var(--color-surface, #fff);
}

html.dark .worklist-study-card {
  border-color: color-mix(in srgb, var(--color-dark-outline-variant, #5c5f66) 45%, transparent);
  background: var(--color-dark-surface-container, #1d1f2b);
}

.worklist-study-card__top {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.35rem;
}

.worklist-study-card__top .study-row-check {
  min-width: 1.125rem;
  min-height: 1.125rem;
}

.worklist-study-card__when {
  margin-left: auto;
  font-size: 0.875rem;
  font-weight: 600;
  text-align: right;
}

.worklist-study-card__dot {
  display: inline-block;
  width: 0.625rem;
  height: 0.625rem;
  border-radius: 50%;
}

.worklist-study-card__qc {
  font-size: 0.8125rem;
  font-weight: 700;
}

.worklist-study-card__mod {
  font-weight: 700;
  font-size: 0.8125rem;
  margin-left: 0.35rem;
}

.worklist-study-card__name,
.worklist-study-row__name {
  margin: 0;
  font-size: 1rem;
  line-height: 1.375rem;
  font-weight: 600;
  overflow-wrap: anywhere;
}

.worklist-study-card__demo,
.worklist-study-row__demo {
  margin: 0;
  font-size: 0.875rem;
  line-height: 1.25rem;
  color: var(--color-on-surface-variant, #6b7280);
}

html.dark .worklist-study-card__demo,
html.dark .worklist-study-row__demo {
  color: var(--color-dark-on-surface-variant, #9ca3af);
}

.worklist-study-card__ids {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.5rem;
  margin: 0;
}

.worklist-study-card__ids dt {
  font-size: 0.75rem;
  font-weight: 500;
  color: var(--color-on-surface-variant, #6b7280);
}

.worklist-study-card__ids dd {
  margin: 0;
  font-family: ui-monospace, "Cascadia Mono", monospace;
  font-size: 0.875rem;
  overflow-wrap: anywhere;
}

.worklist-study-card__desc,
.worklist-study-card__meta,
.worklist-study-row__line,
.worklist-study-row__referrer {
  margin: 0;
  font-size: 0.875rem;
  line-height: 1.25rem;
}

.worklist-study-card__meta,
.worklist-study-row__line--meta,
.worklist-study-row__referrer {
  color: var(--color-on-surface-variant, #6b7280);
}

.worklist-study-card__series-toggle,
.worklist-study-row__series-toggle {
  width: 100%;
  min-height: 2.75rem;
  border-radius: 0.25rem;
  border: 1px solid color-mix(in srgb, var(--color-outline-variant, #c4c7cf) 40%, transparent);
  background: transparent;
  color: var(--color-primary, #4338ca);
  font-size: 0.875rem;
  cursor: pointer;
}

html.dark .worklist-study-card__series-toggle,
html.dark .worklist-study-row__series-toggle {
  border-color: color-mix(in srgb, var(--color-dark-outline-variant, #5c5f66) 50%, transparent);
  color: var(--color-primary-light, #c0c1ff);
}

.worklist-study-row {
  display: grid;
  grid-template-columns: 2.75rem minmax(0, 1fr) 11rem;
  gap: 0.5rem;
  padding: 0.75rem;
  border-bottom: 1px solid color-mix(in srgb, var(--color-outline-variant, #c4c7cf) 25%, transparent);
  align-items: start;
}

html.dark .worklist-study-row {
  border-bottom-color: color-mix(in srgb, var(--color-dark-outline-variant, #5c5f66) 35%, transparent);
}

.worklist-study-row:last-child {
  border-bottom: 0;
}

.worklist-study-row__check {
  padding-top: 0.15rem;
}

.worklist-study-row__main {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  min-width: 0;
}

.worklist-study-row__title-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.35rem;
}

.worklist-task-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.25rem;
}

.worklist-task-icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  border-radius: 0.25rem;
  border: 1px solid color-mix(in srgb, var(--color-outline-variant, #c4c7cf) 40%, transparent);
  background: var(--color-surface, #fff);
  color: var(--color-primary, #4338ca);
  text-decoration: none;
  cursor: pointer;
  transition: background-color 0.15s ease;
}

.worklist-task-icon-btn:hover {
  background: color-mix(in srgb, var(--color-primary, #4338ca) 10%, transparent);
}

html.dark .worklist-task-icon-btn {
  border-color: color-mix(in srgb, var(--color-dark-outline-variant, #5c5f66) 50%, transparent);
  background: var(--color-dark-surface-container-high, #272936);
  color: var(--color-primary-light, #c0c1ff);
}

html.dark .worklist-task-icon-btn:hover {
  background: color-mix(in srgb, var(--color-primary-light, #c0c1ff) 12%, transparent);
}

.worklist-task-icon-btn__svg {
  width: 0.875rem;
  height: 0.875rem;
}

/* Table task column — compact icons (legacy w-7 h-7). */
.worklist-task-actions--table {
  gap: 0.125rem;
}

.worklist-task-actions--table .worklist-task-icon-btn {
  width: 1.75rem;
  height: 1.75rem;
}

/* Phone cards — horizontal row of touch-friendly square icons. */
.worklist-task-actions--card {
  gap: 0.5rem;
}

.worklist-task-actions--card .worklist-task-icon-btn {
  width: 2.75rem;
  height: 2.75rem;
}

.worklist-task-actions--card .worklist-task-icon-btn__svg {
  width: 1.125rem;
  height: 1.125rem;
}

/* Tablet rows — vertical stack pinned in the actions column. */
.worklist-study-row__actions {
  min-width: 0;
}

.worklist-task-actions--row {
  flex-direction: column;
  align-items: stretch;
  width: 100%;
  gap: 0.5rem;
}

.worklist-task-actions--row .worklist-task-icon-btn {
  width: 100%;
  min-height: 2.75rem;
  height: 2.75rem;
}

.worklist-task-actions--row .worklist-task-icon-btn__svg {
  width: 1.125rem;
  height: 1.125rem;
}

.worklist-assign-fields {
  display: grid;
  gap: 0.5rem;
}

.worklist-assign-field {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}

.worklist-assign-field__label {
  font-size: 0.75rem;
  font-weight: 500;
  color: var(--color-on-surface-variant, #6b7280);
}

.worklist-assign-field__select {
  min-height: 2.75rem;
  width: 100%;
  border-radius: 0.25rem;
  border: 1px solid color-mix(in srgb, var(--color-outline-variant, #c4c7cf) 40%, transparent);
  background: var(--color-surface, #fff);
  padding: 0 0.5rem;
  font-size: 0.8125rem;
}

html.dark .worklist-assign-field__select {
  border-color: color-mix(in srgb, var(--color-dark-outline-variant, #5c5f66) 50%, transparent);
  background: var(--color-dark-surface-container-high, #272936);
}

.worklist-assign-field__readonly {
  min-height: 2.75rem;
  display: flex;
  align-items: center;
  font-size: 0.8125rem;
}

/* Below 1280px viewport: phone cards or tablet stacked rows (by worklist container width). */
@media (max-width: 1279px) {
  @container studies-worklist (max-width: 479px) {
    .studies-worklist-cards {
      display: flex;
      flex-direction: column;
      gap: 0.75rem;
      padding-bottom: 0.75rem;
    }
  }

  @container studies-worklist (min-width: 480px) {
    .studies-worklist-rows {
      display: flex;
      flex-direction: column;
      border: 1px solid color-mix(in srgb, var(--color-outline-variant, #c4c7cf) 30%, transparent);
      border-radius: 0.5rem;
      overflow: hidden;
      margin: 0 0.75rem 0.75rem;
    }

    html.dark .studies-worklist-rows {
      border-color: color-mix(in srgb, var(--color-dark-outline-variant, #5c5f66) 40%, transparent);
    }

    .worklist-assign-fields--responsive {
      grid-template-columns: 1fr 1fr;
    }
  }
}

/* Desktop (1280px+ viewport): full fluid table — not the enclosed card/row layouts. */
@media (min-width: 1280px) {
  .studies-worklist-responsive-root .studies-worklist-cards,
  .studies-worklist-responsive-root .studies-worklist-rows {
    display: none !important;
  }

  .studies-worklist-responsive-root .studies-worklist-table-mount {
    display: block !important;
  }

  .studies-worklist-responsive-root #studies-worklist-table {
    min-width: 1280px;
  }
}

/* Application shell footer — legal links + Ver X · company (build/Baseline.Version.props). */
.baseline-app-shell-footer {
  line-height: 1.125rem;
  letter-spacing: 0.01em;
}

.baseline-app-version-footer__sep {
  margin: 0 0.35rem;
  opacity: 0.65;
}

.baseline-app-version-inline {
  white-space: nowrap;
}

/* Login — version + company pinned to right panel bottom without page scroll */
.baseline-auth-version-footer {
  flex-shrink: 0;
  padding-bottom: max(0.75rem, env(safe-area-inset-bottom, 0px));
}

.baseline-app-build-version {
  line-height: 1.125rem;
  letter-spacing: 0.01em;
}

/* Study arrival toast — top-center, below the h-14 header; never covers worklist pagination. */
#baseline-study-arrival-toast {
  position: fixed;
  top: 5rem;
  left: 50%;
  transform: translateX(-50%);
  z-index: 9999;
  max-width: min(28rem, calc(100vw - 2rem));
  pointer-events: none;
}

/* Worklist status toast — error text must contrast on dark-first theme (not text-error alone). */
#study-worklist-toast.baseline-toast-error,
#baseline-study-arrival-toast.baseline-toast-error {
  border-color: rgb(147 0 10 / 0.45);
  background-color: rgb(255 218 214 / 0.55);
  color: #93000a;
}

html.dark #study-worklist-toast.baseline-toast-error,
html.dark #baseline-study-arrival-toast.baseline-toast-error {
  background-color: rgb(147 0 10 / 0.38);
  border-color: rgb(255 180 171 / 0.35);
  color: #ffdad6;
}

#study-worklist-toast.baseline-toast-success,
#baseline-study-arrival-toast.baseline-toast-success {
  border-color: rgb(73 75 214 / 0.35);
  background-color: rgb(225 224 255 / 0.55);
  color: #2d303c;
}

html.dark #study-worklist-toast.baseline-toast-success,
html.dark #baseline-study-arrival-toast.baseline-toast-success {
  background-color: rgb(39 41 54 / 0.95);
  border-color: rgb(192 193 255 / 0.28);
  color: #e1e1f2;
}

/* Sidebar collapse/expand animation — skipped until html[data-sidebar-ready] so restore is not animated. */
.baseline-sidebar-transition {
  transition: width 0.2s ease-in-out, transform 0.2s ease-in-out;
}

html:not([data-sidebar-ready]) .baseline-sidebar-transition {
  transition: none;
}

/* html[data-sidebar-collapsed] is set in <head> from localStorage so first paint is already collapsed. */
html[data-sidebar-collapsed="true"] #baseline-sidebar .sidebar-nav-item,
#baseline-sidebar[data-collapsed="true"] .sidebar-nav-item {
  gap: 0;
}

@media (min-width: 1024px) {
  html[data-sidebar-collapsed="true"] #baseline-sidebar {
    width: 4rem;
  }

  html[data-sidebar-collapsed="true"] #baseline-sidebar .sidebar-nav-item,
  #baseline-sidebar[data-collapsed="true"] .sidebar-nav-item {
    justify-content: center;
    padding-left: 0;
    padding-right: 0;
  }

  html[data-sidebar-collapsed="true"] #baseline-sidebar .sidebar-brand,
  #baseline-sidebar[data-collapsed="true"] .sidebar-brand {
    justify-content: center;
    padding-left: 0;
    padding-right: 0;
  }

  html[data-sidebar-collapsed="true"] #baseline-sidebar .sidebar-nav,
  #baseline-sidebar[data-collapsed="true"] .sidebar-nav {
    padding-left: 0.375rem;
    padding-right: 0.375rem;
  }

  html[data-sidebar-collapsed="true"] #baseline-sidebar .sidebar-footer,
  #baseline-sidebar[data-collapsed="true"] .sidebar-footer {
    padding-left: 0.375rem;
    padding-right: 0.375rem;
  }

  /* Keep title row height so icons do not jump up when the sidebar width animates. */
  html[data-sidebar-collapsed="true"] #baseline-sidebar .sidebar-section-title,
  #baseline-sidebar[data-collapsed="true"] .sidebar-section-title {
    visibility: hidden;
    overflow: hidden;
    white-space: nowrap;
  }

  html[data-sidebar-collapsed="true"] #baseline-sidebar .sidebar-label,
  #baseline-sidebar[data-collapsed="true"] .sidebar-label {
    display: none;
  }

  html[data-sidebar-collapsed="true"] #baseline-sidebar .sidebar-storage-widget,
  #baseline-sidebar[data-collapsed="true"] .sidebar-storage-widget {
    padding-left: 0.25rem;
    padding-right: 0.25rem;
  }

  html[data-sidebar-collapsed="true"] #baseline-sidebar .sidebar-storage-widget .h-1\.5,
  #baseline-sidebar[data-collapsed="true"] .sidebar-storage-widget .h-1\.5 {
    display: block;
    margin-left: auto;
    margin-right: auto;
    width: 1.25rem;
  }
}

/* Table row hover highlight */
.baseline-table-row {
  transition: background-color 0.1s ease;
}

/* Status badge pill */
.baseline-status-badge {
  display: inline-flex;
  align-items: center;
  padding: 2px 10px;
  border-radius: 9999px;
  font-size: 0.75rem;
  font-weight: 500;
  line-height: 1.25rem;
  letter-spacing: 0.025em;
  white-space: nowrap;
}

/* Login page — ambient glow under the login card (right), not the collage */
.baseline-auth-bg {
  background:
    radial-gradient(ellipse at 78% 42%, rgba(192, 193, 255, 0.14) 0%, transparent 56%),
    radial-gradient(ellipse at 86% 86%, rgba(164, 118, 255, 0.07) 0%, transparent 48%);
}

html.dark .baseline-auth-bg {
  background:
    radial-gradient(ellipse at 78% 42%, rgba(192, 193, 255, 0.18) 0%, transparent 56%),
    radial-gradient(ellipse at 86% 86%, rgba(164, 118, 255, 0.1) 0%, transparent 48%);
}

/*
  Login left panel — muted radiology collage so the sign-in card stays the focus.
  Pattern asset: wwwroot/img/auth/radiology-pattern.svg
*/
.baseline-auth-radiology-panel {
  background-color: #161824;
  background-image:
    linear-gradient(105deg, rgba(16, 19, 30, 0.58) 0%, rgba(16, 19, 30, 0.72) 58%, rgba(16, 19, 30, 0.94) 100%),
    url("../img/auth/radiology-pattern.svg?v=4");
  background-repeat: no-repeat;
  background-size: 100% 100%, cover;
  background-position: center, center left;
}

.baseline-auth-card {
  box-shadow:
    0 24px 48px -12px rgba(0, 0, 0, 0.5),
    0 0 0 1px rgba(192, 193, 255, 0.08),
    0 0 72px -16px rgba(192, 193, 255, 0.32);
}

.baseline-auth-collimator {
  position: absolute;
  width: 2rem;
  height: 2rem;
  border-color: rgba(192, 193, 255, 0.16);
  border-style: solid;
  pointer-events: none;
}

.baseline-auth-collimator--tl {
  top: 1.5rem;
  left: 1.5rem;
  border-width: 2px 0 0 2px;
}

.baseline-auth-collimator--tr {
  top: 1.5rem;
  right: 1.5rem;
  border-width: 2px 2px 0 0;
}

.baseline-auth-collimator--bl {
  bottom: 1.5rem;
  left: 1.5rem;
  border-width: 0 0 2px 2px;
}

.baseline-auth-collimator--br {
  bottom: 1.5rem;
  right: 1.5rem;
  border-width: 0 2px 2px 0;
}

/* Focus ring consistent with design system */
.baseline-focus-ring:focus {
  outline: 2px solid #494bd6;
  outline-offset: 2px;
}

html.dark .baseline-focus-ring:focus {
  outline-color: #c0c1ff;
}

/* Theme-safe flash banners (Manage Report, admin pages). */
.baseline-flash-success {
  border-radius: 0.5rem;
  border: 1px solid rgba(22, 163, 74, 0.35);
  background: #bbf7d0;
  color: #14532d;
  padding: 0.75rem 1rem;
}

html.dark .baseline-flash-success {
  border-color: rgba(74, 222, 128, 0.35);
  background: rgba(16, 185, 129, 0.14);
  color: #bbf7d0;
}

.baseline-flash-error {
  border-radius: 0.5rem;
  border: 1px solid rgba(220, 38, 38, 0.35);
  background: #ffdad6;
  color: #7f1d1d;
  padding: 0.75rem 1rem;
}

html.dark .baseline-flash-error {
  border-color: rgba(248, 113, 113, 0.35);
  background: rgba(239, 68, 68, 0.14);
  color: #fecaca;
}

/* Primary action button — keep white label on indigo in both themes. */
.baseline-btn-primary {
  background-color: #494bd6;
  color: #ffffff;
}

.baseline-btn-primary:hover {
  opacity: 0.92;
}

html.dark .baseline-btn-primary {
  background-color: #494bd6;
  color: #ffffff;
}

/* Manage Report tab bar — inactive labels must stay readable on dark chrome. */
.manage-report-tab {
  color: #464554;
}

html.dark .manage-report-tab {
  color: #c7c4d7;
}

.manage-report-tab.is-active {
  color: #494bd6;
  background-color: #f0f0fa;
}

html.dark .manage-report-tab.is-active {
  color: #c0c1ff;
  background-color: #10131e;
}

.manage-report-tab:hover:not(.is-active) {
  background-color: rgba(240, 240, 250, 0.8);
}

html.dark .manage-report-tab:hover:not(.is-active) {
  background-color: rgba(39, 41, 54, 0.85);
}

/* Empty-state hints (key images, placeholders). */
.baseline-empty-state-hint {
  color: #464554;
}

html.dark .baseline-empty-state-hint {
  color: #c7c4d7;
}

/* Study section panel titles — enforce readable contrast in dark mode. */
html.dark .study-section-title.text-on-surface {
  color: #e1e1f2;
}

/* Prevent FOUC: hide body until theme class is applied */
html:not(.theme-ready) body {
  visibility: hidden;
}

html.theme-ready body {
  visibility: visible;
}

/* Urgent flag pill switch — Studies Show header (Rails study-urgent-toggle parity) */
.study-urgent-switch {
  position: relative;
  display: inline-flex;
  align-items: center;
  width: 2.75rem;
  height: 1.375rem;
  flex-shrink: 0;
  cursor: pointer;
}

.study-urgent-switch input {
  position: absolute;
  opacity: 0;
  width: 0;
  height: 0;
  margin: 0;
}

.study-urgent-slider {
  position: absolute;
  inset: 0;
  border-radius: 9999px;
  background-color: #e0e0e0;
  transition: background-color 0.2s ease;
}

.study-urgent-slider::before {
  content: '';
  position: absolute;
  height: 1rem;
  width: 1rem;
  left: 3px;
  top: 3px;
  border-radius: 50%;
  background-color: #a0a0a0;
  transition: transform 0.25s ease, background-color 0.2s ease;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.15);
}

.study-urgent-switch input:checked + .study-urgent-slider {
  background-color: #e8e0f5;
}

.study-urgent-switch input:checked + .study-urgent-slider::before {
  transform: translateX(1.375rem);
  background-color: #7b68ee;
}

html.dark .study-urgent-switch input:not(:checked) + .study-urgent-slider {
  background-color: #464554;
}

html.dark .study-urgent-switch input:not(:checked) + .study-urgent-slider::before {
  background-color: #908fa0;
}

html.dark .study-urgent-switch input:checked + .study-urgent-slider {
  background-color: rgba(128, 131, 255, 0.35);
}

html.dark .study-urgent-switch input:checked + .study-urgent-slider::before {
  background-color: #c0c1ff;
}

.study-urgent-switch.is-disabled {
  opacity: 0.55;
  cursor: not-allowed;
  pointer-events: none;
}

.study-urgent-switch.is-saving {
  opacity: 0.7;
  pointer-events: none;
}

html.dark .flatpickr-calendar {
    background: #1d1f2b;
    border-color: #464554;
    box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.4);
}

html.dark .flatpickr-months .flatpickr-month,
html.dark .flatpickr-current-month .flatpickr-monthDropdown-months,
html.dark .flatpickr-weekdays,
html.dark span.flatpickr-weekday {
    background: #1d1f2b;
    color: #e1e1f2;
}

html.dark .flatpickr-day {
    color: #e1e1f2;
}

html.dark .flatpickr-day:hover,
html.dark .flatpickr-day:focus {
    background: #272936;
    border-color: #272936;
}

html.dark .flatpickr-day.selected,
html.dark .flatpickr-day.startRange,
html.dark .flatpickr-day.endRange,
html.dark .flatpickr-day.selected.inRange,
html.dark .flatpickr-day.startRange.inRange,
html.dark .flatpickr-day.endRange.inRange {
    background: #494bd6;
    border-color: #494bd6;
    color: #fff;
}

html.dark .flatpickr-day.inRange {
    background: rgba(73, 75, 214, 0.25);
    border-color: transparent;
    box-shadow: -5px 0 0 rgba(73, 75, 214, 0.25), 5px 0 0 rgba(73, 75, 214, 0.25);
}

html.dark .flatpickr-months .flatpickr-prev-month,
html.dark .flatpickr-months .flatpickr-next-month {
    fill: #c7c4d7;
}

html.dark .flatpickr-months .flatpickr-prev-month:hover,
html.dark .flatpickr-months .flatpickr-next-month:hover {
    fill: #fff;
}

/* Report / dashboard date inputs — clickable calendar affordance */
.report-date-input {
    cursor: pointer;
}

/* Study dialogs, structured report fields, admin settings — readable in light/dark (not browser default white box). */
.study-form-field {
  color: #2d303c;
  background-color: #f3f3f9;
  border: 1px solid rgba(45, 48, 60, 0.25);
}

html.dark .study-form-field {
  color: #e1e1f2;
  background-color: #1d1f2b;
  border-color: rgba(225, 225, 242, 0.2);
}

.study-form-field::placeholder {
  color: #908fa0;
}

html.dark .study-form-field::placeholder {
  color: #908fa0;
}

html.dark .study-form-field option {
  color: #e1e1f2;
  background-color: #1d1f2b;
}

/* Structured report preview — editable section blocks */
.structured-preview-block {
  border-radius: 0.375rem;
  border: 1px solid rgba(45, 48, 60, 0.12);
  background: rgba(255, 255, 255, 0.35);
  padding: 0.625rem 0.75rem;
}

html.dark .structured-preview-block {
  border-color: rgba(225, 225, 242, 0.12);
  background: rgba(29, 31, 43, 0.55);
}

.structured-preview-block--edited {
  border-color: rgba(99, 102, 241, 0.45);
}

.structured-preview-block__title {
  font-size: 0.8125rem;
  font-weight: 600;
  line-height: 1.25rem;
  color: #5c5d6e;
}

html.dark .structured-preview-block__title {
  color: #b8b7c8;
}

.structured-preview-block__text {
  margin-top: 0.25rem;
  white-space: pre-wrap;
}

.structured-preview-block__editor {
  margin-top: 0.375rem;
  width: 100%;
  min-height: 4.5rem;
  font-size: inherit;
  line-height: 1.4;
  resize: vertical;
}

.structured-preview-block__actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-top: 0.375rem;
}

.structured-preview-block__stale {
  font-size: 0.6875rem;
  color: #b45309;
}

html.dark .structured-preview-block__stale {
  color: #fbbf24;
}

.structured-preview-blocks__empty {
  color: #5c5d6e;
}

html.dark .structured-preview-blocks__empty {
  color: #908fa0;
}

/* Structured report preview — compact measurements column beside impression */
.structured-measurement-summary {
  font-size: 0.6875rem;
  line-height: 1.25rem;
}

.structured-measurement-summary__title {
  font-size: 0.8125rem;
  line-height: 1.125rem;
}

.structured-measurement-summary__section-title,
.structured-measurement-summary__table,
.structured-measurement-summary__thead {
  font-size: inherit;
  line-height: inherit;
}

.structured-measurement-summary__thead {
  color: var(--color-on-surface-variant, #5c5d6e);
}

html.dark .structured-measurement-summary__thead {
  color: var(--color-dark-on-surface-variant, #908fa0);
}

/* Structured echo — Measurements / Observations bands and collapsible panels */
.structured-echo-band__panels .structured-echo-panel {
  height: 100%;
}

.structured-echo-band--observations .structured-echo-band__panels {
  grid-template-columns: 1fr;
}

@media (min-width: 768px) {
  .structured-echo-band--observations .structured-echo-band__panels {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

.structured-echo-panel__title::-webkit-details-marker {
  display: none;
}

.structured-narrative-collapse > summary::-webkit-details-marker {
  display: none;
}

.structured-report-signature-placeholder {
  width: 180px;
  height: 50px;
  border: 1px solid color-mix(in srgb, var(--color-outline-variant, #79747e) 70%, transparent);
  border-radius: 0.25rem;
  background: color-mix(in srgb, var(--color-surface-container, #f3edf7) 40%, transparent);
}

html.dark .structured-report-signature-placeholder {
  border-color: color-mix(in srgb, var(--color-dark-outline-variant, #938f99) 60%, transparent);
  background: color-mix(in srgb, var(--color-dark-surface-container, #2b2930) 50%, transparent);
}

.structured-echo-panel__title::before {
  content: "▾ ";
  display: inline-block;
  transition: transform 0.15s ease;
}

.structured-echo-panel:not([open]) .structured-echo-panel__title::before {
  transform: rotate(-90deg);
}

/* Reporting Option 2 — TinyMCE toolbar chrome matches Indigo Flux panels */
.structured-report-form .tox-tinymce {
  border-radius: 0.375rem;
  border-color: rgba(45, 48, 60, 0.25) !important;
}

html.dark .structured-report-form .tox-tinymce {
  border-color: rgba(225, 225, 242, 0.2) !important;
}

/* Study show — section title (body-md) larger than panel content (label-md). */
.study-section-title {
  font-size: 0.875rem;
  line-height: 1.25rem;
  font-weight: 600;
}

.study-section-content {
  font-size: 0.75rem;
  line-height: 1.125rem;
  font-weight: 400;
}

.study-section-content :is(p, li, td, th, span, div, a, strong, em) {
  font-size: inherit;
  line-height: inherit;
}

/* TinyMCE may emit inline font sizes — normalize on read-only study panels. */
#case-instruction-body .study-section-content,
#clinical-history-body .study-section-content,
#case-instruction-body .study-section-content *,
#clinical-history-body .study-section-content * {
  font-size: 0.75rem !important;
  line-height: 1.125rem !important;
}

.study-section-field-label {
  font-size: 0.875rem;
  line-height: 1.25rem;
  font-weight: 600;
}

.study-section-field-value {
  font-size: 0.75rem;
  line-height: 1.125rem;
  font-weight: 400;
}

/* Send Studies dialog — worklist C-STORE progress (matches Radpanel move UI density). */
.send-studies-dialog {
  font-size: 0.8125rem;
  line-height: 1.25rem;
  color: #2a2a3a;
}

html.dark .send-studies-dialog {
  color: #e8e8f2;
}

.send-studies-node-table-head {
  background: #ececf4;
}

/* Structured template Manage — field table layout and compact inputs. */
#structured-fields-table {
  table-layout: fixed;
}

#structured-fields-table .structured-field-unit-input {
  width: 100%;
  max-width: 5.5ch;
}

#structured-fields-table .structured-field-meta-grid {
  display: grid;
  grid-template-columns: 5.5ch minmax(0, 1fr);
  gap: 0.75rem;
  align-items: start;
}

/* Structured template Manage — alternating field-group backgrounds (tbody per field). */
#structured-fields-table tbody.structured-field-group--odd > tr > td {
  background-color: #e1e0ff;
}

#structured-fields-table tbody.structured-field-group--even > tr > td {
  background-color: #f5f5fc;
}

html.dark #structured-fields-table tbody.structured-field-group--odd > tr > td {
  background-color: #191b27;
}

html.dark #structured-fields-table tbody.structured-field-group--even > tr > td {
  background-color: #2e3140;
}

html.dark .send-studies-node-table-head {
  background: #353545;
}

.send-studies-node-th {
  font-size: 0.75rem;
  line-height: 1.125rem;
  font-weight: 600;
  color: #3d3d4d;
}

html.dark .send-studies-node-th {
  color: #e8e8f2;
}

.send-studies-dialog-title {
  font-size: 1rem;
  line-height: 1.375rem;
}

.send-studies-text {
  font-size: 0.8125rem;
  line-height: 1.25rem;
}

.send-studies-text-sm {
  font-size: 0.75rem;
  line-height: 1.125rem;
}

.send-studies-status {
  font-size: 0.8125rem;
  line-height: 1.25rem;
  font-weight: 500;
}

.send-studies-overall-label,
.send-studies-overall-count {
  font-size: 0.75rem;
  line-height: 1.125rem;
}

html.dark .send-studies-overall-label,
html.dark .send-studies-overall-count {
  color: #b8b8cc;
}

.send-studies-column-title {
  font-size: 0.75rem;
  line-height: 1.125rem;
  font-weight: 600;
}

html.dark .send-studies-column-title {
  color: #e8e8f2;
}

html.dark .send-studies-status {
  color: #ececf4;
}

.send-studies-study-list {
  font-size: 0.75rem;
  line-height: 1.125rem;
}

.send-studies-study-card {
  padding: 0.5rem 0.625rem;
  border-radius: 0.375rem;
  border: 1px solid rgba(0, 0, 0, 0.08);
  background: #ebebf3;
}

html.dark .send-studies-study-card {
  border-color: rgba(255, 255, 255, 0.1);
  background: #2c2c3a;
}

.send-studies-study-card-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 0.5rem;
  margin-bottom: 0.25rem;
}

.send-studies-study-card-label {
  font-size: 0.75rem;
  line-height: 1.125rem;
  font-weight: 500;
  min-width: 0;
  color: #2a2a3a;
}

html.dark .send-studies-study-card-label {
  color: #ececf4;
}

.send-studies-study-card-status {
  font-size: 0.75rem;
  line-height: 1.125rem;
  font-weight: 600;
  flex-shrink: 0;
}

.send-studies-study-card-status.is-done {
  color: #22c55e;
}

.send-studies-study-card-status.is-failed {
  color: #ef4444;
}

.send-studies-study-card-status.is-skipped {
  color: #f59e0b;
}

.send-studies-study-card-status.is-sending {
  color: #6366f1;
}

html.dark .send-studies-study-card-status.is-sending {
  color: #818cf8;
}

.send-studies-study-card-count {
  font-size: 0.75rem;
  line-height: 1.125rem;
  color: #5c5c6e;
  margin-top: 0.125rem;
}

html.dark .send-studies-study-card-count {
  color: #a1a1b5;
}

.send-studies-log {
  font-size: 0.6875rem;
  line-height: 1.4;
}

.send-studies-progress {
  appearance: none;
  -webkit-appearance: none;
  border: none;
  background-color: #d8d8e4;
  overflow: hidden;
}

html.dark .send-studies-progress {
  background-color: #3d3d4d;
}

.send-studies-progress-overall {
  height: 0.5rem;
}

.send-studies-progress-study {
  height: 0.25rem;
  margin-bottom: 0.125rem;
}

.send-studies-progress::-webkit-progress-bar {
  background-color: #d8d8e4;
  border-radius: 0.25rem;
}

html.dark .send-studies-progress::-webkit-progress-bar {
  background-color: #3d3d4d;
}

.send-studies-progress::-webkit-progress-value {
  background-color: #22c55e;
  border-radius: 0.25rem;
}

.send-studies-progress::-moz-progress-bar {
  background-color: #22c55e;
  border-radius: 0.25rem;
}

.send-studies-btn-primary {
  font-size: 0.8125rem;
  line-height: 1.25rem;
}

.send-studies-btn-secondary {
  font-size: 0.8125rem;
  line-height: 1.25rem;
}

/* Structured report — locked fields remain viewable; print settings stay editable. */
.structured-report-fields--locked .structured-field-input:disabled,
.structured-report-fields--locked .structured-repeater-add:disabled {
  opacity: 0.85;
  cursor: not-allowed;
}

.structured-report-fields--locked .structured-echo-panel summary {
  cursor: default;
}

/* Structured report Images tab — maps to Rails study-gallery-grid cols-* */
.structured-report-gallery-grid.cols-1 {
  grid-template-columns: 1fr;
}

.structured-report-gallery-grid.cols-2 {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.structured-report-gallery-grid.cols-3 {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

@media (max-width: 640px) {
  .structured-report-gallery-grid.cols-2,
  .structured-report-gallery-grid.cols-3 {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

/* Password reveal — eye icon overlay on login, user/doctor create, and reset-password fields.
   Stretch the button to the input height and center the SVG with flex (avoid top:50% +
   translateY, which fights Tailwind inset utilities and overflows the field). */
.baseline-password-field {
  position: relative;
  display: block;
  width: 100%;
}

.baseline-password-field input {
  padding-right: 2.75rem;
}

.baseline-password-field input::-ms-reveal,
.baseline-password-field input::-ms-clear {
  display: none;
}

.baseline-password-toggle {
  position: absolute;
  top: 0;
  right: 0.25rem;
  bottom: 0;
  z-index: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 2.25rem;
  height: auto;
  margin: 0;
  padding: 0;
  border: 0;
  border-radius: 0.375rem;
  background: transparent;
  color: #908fa0;
  cursor: pointer;
  line-height: 0;
  appearance: none;
}

.baseline-password-toggle:hover {
  color: #2d303c;
}

html.dark .baseline-password-toggle {
  color: #c7c4d7;
}

html.dark .baseline-password-toggle:hover {
  color: #e1e1f2;
}

.baseline-password-toggle:focus-visible {
  outline: 2px solid #494bd6;
  outline-offset: 1px;
}

.baseline-password-toggle svg {
  width: 1.25rem;
  height: 1.25rem;
}

.baseline-password-toggle svg.hidden {
  display: none;
}

/* DICOM node connectivity test (Ping / DICOM Echo). */
.dicom-connectivity-actions {
  white-space: nowrap;
}

.dicom-connectivity-action-wrap {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
}

.dicom-connectivity-status {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  cursor: help;
  line-height: 0;
}

.dicom-connectivity-status-success {
  color: #22c55e;
}

.dicom-connectivity-status-error {
  color: #ef4444;
}

.dicom-connectivity-status-svg {
  display: block;
}

.dicom-connectivity-status-spinner {
  width: 1rem;
  height: 1rem;
  border: 2px solid #9ca3af;
  border-top-color: #494bd6;
  border-radius: 50%;
  animation: dicom-connectivity-spin 0.7s linear infinite;
}

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

/* Fixed tooltip; mounted on body or inside <dialog> (top layer) to avoid clipping. */
.dicom-connectivity-floating-tooltip {
  position: fixed;
  z-index: 10050;
  max-width: min(22rem, calc(100vw - 1rem));
  padding: 0.45rem 0.65rem;
  border-radius: 0.375rem;
  background: #1f1f28;
  color: #f3f3f8;
  font-size: 0.75rem;
  line-height: 1.25rem;
  white-space: normal;
  word-break: break-word;
  text-align: left;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.35);
  pointer-events: none;
}

dialog > .dicom-connectivity-floating-tooltip {
  z-index: 2;
}

.dicom-connectivity-floating-tooltip.hidden {
  display: none;
}
