/* © 2026 Orpyx Medical Technologies Inc. */

:root {
  --ice-blue: #F2F8FB;
  --light-blue: #B1E0FA;
  --dark-blue: #093F57;
  --slate-blue: #2D7B90;
  --light-grey: #E5ECF0;
  --medium-grey: #9AAEB9;
  --silver-grey: #7D929A;
  --dark-grey: #2D363B;
  --ever-green: #1A9F7F;
  --royal-blue: #256CD7;
  --mellow-yellow: #FFD074;
  --red-alert: #DF1C2F;
  --font-headline: 'Graphik', -apple-system, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
  --font-body: 'Graphik', -apple-system, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-height: 100vh;
  background: linear-gradient(180deg, var(--ice-blue) 0%, #ffffff 55%);
  font-family: var(--font-body);
  color: var(--dark-blue);
  display: flex;
  flex-direction: column;
  align-items: center;
}

header {
  width: 100%;
  padding: 40px 24px 0;
  display: flex;
  justify-content: center;
}

.brand-logo {
  height: 44px;
  width: auto;
}

main {
  flex: 1;
  width: 100%;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding: 56px 24px 64px;
}

/* Narrow, centered login/unauthorized/home-signed-in prompt (../../entra-oauth-spec.md §6) — also
   reused, border/shadow-stripped, as `.operations-content-body .card` below for "coming soon"
   content (e.g. Triage) rendered inside the operations-portal shell. */
.card {
  width: 100%;
  max-width: 460px;
  background: #ffffff;
  border: 1px solid var(--light-grey);
  border-radius: 16px;
  box-shadow: 0 20px 40px -24px rgba(9, 63, 87, 0.25);
  padding: 40px 36px;
}

h1 {
  font-family: var(--font-headline);
  font-weight: 700;
  font-size: 26px;
  margin: 0 0 8px;
  color: var(--dark-blue);
}

.subhead {
  font-family: var(--font-headline);
  font-weight: 500;
  font-size: 15px;
  color: var(--silver-grey);
  margin: 0 0 28px;
  line-height: 1.5;
}

.identity {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 16px;
  background: var(--ice-blue);
  border-radius: 12px;
  margin-bottom: 24px;
}

.identity-avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: var(--ever-green);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 14px;
  flex-shrink: 0;
}

.identity-text {
  font-size: 14px;
  line-height: 1.4;
}

.identity-text .label {
  display: block;
  font-size: 12px;
  color: var(--silver-grey);
}

.identity-text .name {
  font-weight: 600;
  color: var(--dark-blue);
}

.actions {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.btn {
  display: block;
  width: 100%;
  text-align: center;
  text-decoration: none;
  font-family: var(--font-headline);
  font-weight: 600;
  font-size: 15px;
  padding: 13px 20px;
  border-radius: 10px;
  border: 1px solid transparent;
  cursor: pointer;
  transition: background 0.15s ease, border-color 0.15s ease, box-shadow 0.15s ease, transform 0.15s ease;
}

.btn:active { transform: scale(0.98); }

.btn-primary {
  background: var(--royal-blue);
  color: #ffffff;
  box-shadow: 0 8px 16px -8px rgba(37, 108, 215, 0.55);
}

.btn-primary:hover {
  /* Darkens the existing royal-blue background rather than introducing a new hex value not in
     orpyx-brand-guidelines.json's palette. */
  filter: brightness(0.92);
  box-shadow: 0 10px 20px -8px rgba(37, 108, 215, 0.65);
}

.btn-secondary {
  background: #ffffff;
  color: var(--slate-blue);
  border-color: var(--light-grey);
}

.btn-secondary:hover {
  background: var(--ice-blue);
  border-color: var(--light-blue);
}

.btn:disabled {
  cursor: not-allowed;
  opacity: 0.5;
  box-shadow: none;
  transform: none;
}

.banner {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 14px;
  padding: 12px 14px;
  border-radius: 10px;
  margin-bottom: 20px;
}

.banner-error {
  background: #FDECEE;
  color: var(--red-alert);
  border: 1px solid rgba(223, 28, 47, 0.2);
}

.portal-links {
  margin-bottom: 24px;
}

.portal-links .label {
  display: block;
  font-size: 12px;
  color: var(--silver-grey);
  margin-bottom: 8px;
}

.portal-links-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.portal-link {
  color: var(--royal-blue);
  font-size: 14px;
  font-weight: 600;
  text-decoration: none;
}

.portal-link:hover {
  text-decoration: underline;
}

footer {
  padding: 0 24px 28px;
  font-size: 12px;
  color: var(--silver-grey);
  text-align: center;
}

/* --- operations portal shell: portal-router-spec.md §5, portals/operations/shell.ts -------------
   Full viewport height/width — `body.full-bleed` (toggled by shared/dom.ts's `mountMain`) hides
   the page's outer header/footer and lets `#main` stretch edge to edge, since this shell carries
   its own logo and there's no room for the outer chrome once a sidebar + top bar are showing. */
body.full-bleed header,
body.full-bleed footer {
  display: none;
}

body.full-bleed main {
  padding: 0;
  align-items: stretch;
  justify-content: stretch;
}

.operations-shell {
  width: 100%;
  display: flex;
  flex-direction: row;
}

.operations-sidebar {
  flex-shrink: 0;
  width: 232px;
  background: var(--dark-blue);
  display: flex;
  flex-direction: column;
  padding: 24px 14px;
}

.operations-sidebar-logo {
  height: 30px;
  width: auto;
  margin: 4px 10px 12px;
}

.operations-sidebar-caption {
  display: block;
  text-align: center;
  font-family: var(--font-headline);
  font-weight: 700;
  font-size: 11px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--medium-grey);
  margin: 8px 0 22px;
}

.operations-nav {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.operations-nav-item {
  display: flex;
  align-items: center;
  gap: 12px;
  text-decoration: none;
  font-family: var(--font-headline);
  font-weight: 600;
  font-size: 14px;
  color: var(--light-blue);
  padding: 11px 14px;
  border-radius: 10px;
  transition: background 0.15s ease, color 0.15s ease;
}

.operations-nav-item:hover {
  background: rgba(255, 255, 255, 0.08);
  color: #ffffff;
}

/* The active item's rounded highlight — a light pill with dark text, per menubar.png. */
.operations-nav-item-active,
.operations-nav-item-active:hover {
  background: var(--light-blue);
  color: var(--dark-blue);
}

.operations-nav-icon {
  width: 18px;
  height: 18px;
  flex-shrink: 0;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.operations-content {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  overflow-y: auto;
  background: #ffffff;
}

.operations-topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
  padding: 20px clamp(16px, 3vw, 32px);
  border-bottom: 1px solid var(--light-grey);
}

.operations-topbar-title {
  margin: 0;
  font-size: 20px;
}

.operations-topbar-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

.operations-topbar-action {
  position: relative;
}

.operations-avatar-btn {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  border: none;
  background: var(--ever-green);
  color: #fff;
  font-weight: 700;
  font-size: 14px;
  cursor: pointer;
}

.operations-popover {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  z-index: 20;
  min-width: 240px;
  background: #ffffff;
  border: 1px solid var(--light-grey);
  border-radius: 12px;
  box-shadow: 0 20px 40px -24px rgba(9, 63, 87, 0.35);
  padding: 16px;
}

.operations-popover.hidden {
  display: none;
}

.operations-popover-user {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.operations-popover-user-name {
  font-family: var(--font-headline);
  font-weight: 600;
  font-size: 14px;
  color: var(--dark-blue);
}

.operations-content-body {
  flex: 1;
  padding: clamp(16px, 3vw, 32px);
}

.operations-content-body .card {
  border: none;
  box-shadow: none;
  padding: 0;
  max-width: none;
}

/* Sidebar collapses to a horizontal top bar below 768px — not a hamburger drawer, so no extra
   open/close state or JS is needed beyond what the router already does. */
@media (max-width: 768px) {
  .operations-shell {
    flex-direction: column;
  }

  .operations-sidebar {
    width: 100%;
    flex-direction: row;
    align-items: center;
    padding: 12px 16px;
    overflow-x: auto;
  }

  .operations-sidebar-logo {
    height: 22px;
    margin: 0 12px 0 0;
  }

  .operations-sidebar-caption {
    display: none;
  }

  .operations-nav {
    flex-direction: row;
    flex-wrap: wrap;
    gap: 4px;
  }

  .operations-nav-item {
    padding: 8px 10px;
    font-size: 13px;
  }

  .operations-nav-icon {
    width: 16px;
    height: 16px;
  }

  .operations-content {
    overflow-y: visible;
  }
}

/* --- Patients list + create screens: patient-management-spec.md §5c/§5d ---------------------
   Mounted into the operations-portal shell above (.operations-content-body) and directly into the
   customer-care route — this app no longer has a competing sidebar/top-bar
   shell of its own; see patient-management-STATUS.md. */

.patients-heading {
  margin-bottom: 20px;
}

.patients-heading-title {
  margin: 0 0 4px;
  font-family: var(--font-headline);
  font-weight: 700;
  font-size: 20px;
  color: var(--dark-blue);
}

.patients-heading-subtext {
  margin: 0;
  font-size: 13px;
  color: var(--silver-grey);
}

.list-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 16px;
}

.list-toolbar-filters,
.list-toolbar-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

/* `.form-input`'s `width: 100%` is right for a stacked form field, but here it fights flex-wrap —
   each input/select would claim the full toolbar width and force onto its own line. Constrain to
   its content/min-width instead so the search box and Type filter share one row. */
.list-toolbar-filters .form-input {
  width: auto;
  flex: 0 1 auto;
}

.form-input {
  width: 100%;
  min-width: 0;
  font-family: var(--font-body);
  font-size: 14px;
  color: var(--dark-blue);
  background: #ffffff;
  border: 1px solid var(--light-grey);
  border-radius: 8px;
  padding: 9px 12px;
  /* Long <select> option text (e.g. a long clinic name) truncates instead of forcing the field
     — and .form-grid-2col's column — wider than its track. */
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.form-input:focus {
  outline: none;
  border-color: var(--slate-blue);
}

.search-input {
  min-width: 240px;
}

/* `.btn` sizing (width: 100%, block) is right for the narrow login card, wrong here — these
   toolbar/table/modal buttons sit inline next to other controls. */
.list-toolbar .btn,
.pagination .btn,
.modal-actions .btn,
.table-actions .btn {
  display: inline-block;
  width: auto;
  padding: 9px 16px;
  font-size: 13px;
}

.table-wrap {
  overflow-x: auto; /* horizontal scroll within the table's own container, per §5b1 */
  border: 1px solid var(--light-grey);
  border-radius: 12px;
}

.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}

.data-table th,
.data-table td {
  text-align: left;
  padding: 12px 16px;
  white-space: nowrap;
}

.data-table thead th {
  background: var(--ice-blue);
  font-family: var(--font-headline);
  font-weight: 600;
  font-size: 12px;
  color: var(--silver-grey);
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.data-table th.sortable {
  cursor: pointer;
  user-select: none;
}

.data-table th.sortable-active {
  color: var(--dark-blue);
}

.data-table tbody tr {
  border-top: 1px solid var(--light-grey);
}

.data-table tbody tr:hover {
  background: var(--ice-blue);
}

.data-table-row-clickable {
  cursor: pointer;
}

.data-table-row-clickable:focus-visible {
  outline: 2px solid var(--royal-blue);
  outline-offset: -2px;
}

.table-empty {
  padding: 32px;
  text-align: center;
  color: var(--silver-grey);
  font-size: 14px;
  border: 1px solid var(--light-grey);
  border-radius: 12px;
}

/* Status is directly changeable from the list (§5c) — the status cell is a `<select>`, colored
   per value. Reserved-meaning colors (Ever green / Red alert) stay reserved for success/error
   signals elsewhere (§5a) — status uses the secondary accents so it doesn't compete with those.
   `appearance: none` drops the native dropdown arrow entirely (no replacement glyph) so the pill
   reads as a plain colored label; `text-align`/`text-align-last: center` then centers the status
   text itself now that the arrow's reserved space on the right is gone — `text-align-last` is
   needed because a `<select>`'s own displayed value doesn't honor plain `text-align` in every
   browser (Chrome/Edge in particular). */
.status-select {
  font-weight: 600;
  padding: 6px 12px;
  border-radius: 999px;
  border: 1px solid transparent;
  cursor: pointer;
  appearance: none;
  -webkit-appearance: none;
  -moz-appearance: none;
  text-align: center;
  text-align-last: center;
}

.status-select-active {
  background-color: rgba(26, 159, 127, 0.12);
  color: var(--ever-green);
}

.status-select-inactive {
  background-color: var(--light-grey);
  color: var(--silver-grey);
}

.status-select-paused {
  background-color: rgba(255, 208, 116, 0.25);
  color: #8a5a00;
}

.status-select-delete {
  background-color: rgba(223, 28, 47, 0.1);
  color: var(--red-alert);
}

.table-actions {
  display: flex;
  gap: 6px;
}

.btn-table-action {
  padding: 6px 14px;
  font-size: 12px;
  border-radius: 999px;
  background: var(--ice-blue);
  border-color: transparent;
}

.btn-table-action:hover {
  background: var(--light-blue);
  border-color: transparent;
}

/* Per-patient insole toggle (§5c) — an expand/collapse chevron in its own narrow leading column.
   The chevron points down at rest and rotates 180° (up) when expanded, rather than a rotated
   triangle glyph, so it renders as a crisp, consistently-sized icon at any zoom/font setting. */
.row-toggle-btn {
  width: 24px;
  height: 24px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: none;
  background: transparent;
  color: var(--silver-grey);
  cursor: pointer;
  border-radius: 6px;
  transition: background 0.15s ease, color 0.15s ease;
}

.row-toggle-btn:hover {
  background: var(--ice-blue);
  color: var(--dark-blue);
}

.row-toggle-btn-expanded {
  color: var(--dark-blue);
}

.row-toggle-icon {
  width: 14px;
  height: 14px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
  transition: transform 0.15s ease;
}

.row-toggle-btn-expanded .row-toggle-icon {
  transform: rotate(180deg);
}

.insole-subrow td {
  background: var(--ice-blue);
  white-space: normal;
}

/* Left inset matches where the patient table's own "Name" column text starts (toggle column's
   padding + icon width + the gap before the next column) so the insole mini-table reads as a
   left-aligned continuation of the row above it, not a separately-indented block. */
.data-table .insole-subrow-cell {
  padding: 12px 16px 16px 78px;
}

.insole-subrow-empty {
  margin: 0;
  font-size: 13px;
  color: var(--silver-grey);
}

/* A real table, not a flex list, so serial numbers/size/status/actions line up as proper columns
   across every insole a patient has (§5c: "insole rows need to align properly"). Header uses
   `Light blue` and rows use white — both from the documented palette (patient-management-spec.md
   §5a) — so the mini-table reads as distinct from the surrounding `Ice blue` expanded-row
   background without reaching for `Ever green`/`Red alert`, which stay reserved for status. */
.insole-subtable {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

/* `thead th`/`tbody td` (not the bare `th`/`td` used elsewhere in this file) so these win over
   `.data-table thead th`'s ice-blue header and `.insole-subrow td`'s ice-blue row background —
   both apply to *any* descendant th/td, including this nested table's, since CSS descendant
   selectors don't stop at a table boundary. */
.insole-subtable thead th {
  text-align: left;
  font-family: var(--font-headline);
  font-weight: 600;
  font-size: 11px;
  color: var(--dark-blue);
  text-transform: uppercase;
  letter-spacing: 0.03em;
  padding: 6px 12px;
  background: var(--light-blue);
}

.insole-subtable tbody td {
  padding: 6px 12px;
  color: var(--dark-blue);
  vertical-align: middle;
  background: #ffffff;
}

.insole-subtable-row + .insole-subtable-row td {
  border-top: 1px solid var(--light-grey);
}

.insole-status-badge {
  display: inline-block;
  font-family: var(--font-headline);
  font-weight: 600;
  font-size: 12px;
  padding: 3px 10px;
  border-radius: 999px;
}

.insole-status-badge-active {
  background: rgba(26, 159, 127, 0.12);
  color: var(--ever-green);
}

.insole-status-badge-inactive {
  background: var(--light-grey);
  color: var(--silver-grey);
}

.insole-status-badge-broken {
  background: rgba(223, 28, 47, 0.1);
  color: var(--red-alert);
}

/* Distributions Data list's Type column (distributions-view.ts's `typeCellNode`) — same pill
   shape as `.insole-status-badge`, but keyed off `distributionTypeVariant`'s keyword match over
   freeform `distributionType` text rather than a fixed enum. */
.distribution-type-badge {
  display: inline-block;
  font-family: var(--font-headline);
  font-weight: 600;
  font-size: 11px;
  padding: 6px 6px 0px 6px;
  border-radius: 999px;
}

.distribution-type-badge-commercial {
  background: var(--silver-grey);
  color: #fff;
}

.distribution-type-badge-demonstration {
  background: rgba(45, 54, 59, 0.12);
  color: var(--dark-grey);
}

.distribution-type-badge-warranty {
  background: rgba(223, 28, 47, 0.1);
  color: var(--red-alert);
}

.distribution-type-badge-clinical {
  background: var(--light-blue);
  color: var(--dark-blue);
}

.distribution-type-badge-rd {
  background: var(--light-grey);
  color: var(--silver-grey);
}

.distribution-type-badge-default {
  background: var(--light-grey);
  color: var(--dark-blue);
}

/* Distributions Data list's Serials (L/R) column — left/right insole serial numbers stacked in
   one cell rather than two separate columns. */
.serial-line {
  font-size: 12px;
  color: var(--dark-blue);
  white-space: nowrap;
}

.form-readonly-value {
  margin: -6px 0 0;
  font-size: 13px;
  color: var(--silver-grey);
}

.pagination {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  margin-top: 16px;
}

.pagination-per-page {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  color: var(--silver-grey);
}

.pagination-per-page .form-input {
  padding: 6px 10px;
}

.pagination-summary {
  font-size: 13px;
  color: var(--silver-grey);
}

.pagination-nav {
  display: flex;
  gap: 8px;
}

/* --- Modal dialogs (Add patient / Add clinic / Add insole) ---------------------------------- */

.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(9, 63, 87, 0.45);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  z-index: 50;
}

.modal-panel {
  width: 100%;
  max-width: 480px;
  max-height: calc(100vh - 48px);
  overflow-x: hidden;
  overflow-y: auto;
  background: #ffffff;
  border-radius: 16px;
  box-shadow: 0 20px 40px -24px rgba(9, 63, 87, 0.35);
}

/* Wider variant for forms with many fields (e.g. Distributions Data's 29-field form) — paired
   with .form-grid-2col below so two fields sit side by side instead of stacking the whole way
   down, keeping the modal's own scroll height manageable. */
.modal-panel-lg {
  max-width: 920px;
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 20px 24px;
  border-bottom: 1px solid var(--light-grey);
}

.modal-title {
  margin: 0;
  font-family: var(--font-headline);
  font-weight: 700;
  font-size: 17px;
  color: var(--dark-blue);
}

.modal-close {
  border: none;
  background: transparent;
  font-size: 20px;
  line-height: 1;
  color: var(--silver-grey);
  cursor: pointer;
  padding: 4px 8px;
}

.modal-close:hover {
  color: var(--dark-blue);
}

.modal-body {
  padding: 24px;
}

.modal-form {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 4px;
}

.form-field {
  display: flex;
  flex-direction: column;
  gap: 6px;
  /* Without this, a grid item's default min-width is its content's intrinsic (max-content) size
     — a <select> with a long option (e.g. a long clinic name) then refuses to shrink to its 1fr
     track, blowing out .form-grid-2col's column widths and forcing the whole modal to scroll
     horizontally. `min-width: 0` lets it shrink to the track and defer to .form-input's own
     width/truncation rules below instead. */
  min-width: 0;
}

/* Two-fields-per-row layout for long forms — a grid rather than flex-wrap so both columns stay
   evenly sized regardless of label/value length. Nests inside .modal-form (which still supplies
   the vertical gap between the grid and the errors/hint/actions rows around it). */
.form-grid {
  display: grid;
  gap: 14px 20px;
}

.form-grid-2col {
  grid-template-columns: 1fr 1fr;
}

.form-field-full {
  grid-column: 1 / -1;
}

@media (max-width: 640px) {
  .form-grid-2col {
    grid-template-columns: 1fr;
  }
}

.form-field-label {
  font-family: var(--font-headline);
  font-weight: 600;
  font-size: 12px;
  color: var(--silver-grey);
}

.required-asterisk {
  color: var(--red-alert);
}

.form-hint {
  margin: 0;
  font-size: 12px;
  color: var(--silver-grey);
}

.form-errors {
  margin: 0;
  padding: 12px 14px;
  list-style: none;
  background: #FDECEE;
  color: var(--red-alert);
  border: 1px solid rgba(223, 28, 47, 0.2);
  border-radius: 10px;
  font-size: 13px;
}

.form-errors.hidden {
  display: none;
}

@media (max-width: 640px) {
  .list-toolbar {
    flex-direction: column;
    align-items: stretch;
  }

  .list-toolbar-filters,
  .list-toolbar-actions {
    justify-content: stretch;
  }

  .search-input {
    min-width: 0;
    flex: 1;
  }

  .pagination {
    flex-direction: column;
    align-items: stretch;
  }
}

/* Responsive breakpoints for the login/unauthorized narrow card — patient-management-spec.md
   §5b1. Plain media queries, no viewport-detection library, per this app's existing
   no-framework convention. */
@media (max-width: 640px) {
  header {
    padding: 24px 16px 0;
  }

  main {
    padding: 28px 12px 36px;
  }

  .card {
    padding: 24px 18px;
    border-radius: 14px;
  }

  h1 {
    font-size: 22px;
  }

  .identity {
    flex-wrap: wrap;
  }
}
