/* Staff Messages outside the front desk, laid out as the practitioner deck's .mcard / .tabrow / .mcols.
   Layout only: the card, tabs, fields, rows and type come from the shared rules in index.css. */
#akashic-health-records-patient-portal-root .ahr-cmsgs {
  display: flex;
  flex: 1;
  flex-direction: column;
  min-height: 0;
  overflow: hidden;
  gap: 0;
}

#akashic-health-records-patient-portal-root .ahr-cmsgs__tabs {
  flex: none;
  overflow-x: auto;
  scrollbar-width: none;
}

#akashic-health-records-patient-portal-root .ahr-cmsgs__panel {
  display: flex;
  padding: 0;
  flex: 1;
  flex-direction: column;
  min-height: 0;
}

#akashic-health-records-patient-portal-root .ahr-cmsgs__panel > .grid {
  flex: 1;
  column-gap: 0;
}

#akashic-health-records-patient-portal-root .ahr-cmsgs__panel > .grid > :first-child {
  display: flex;
  flex-direction: column;
  padding: 13px 13px 13px 0;
}

@media (min-width: 768px) {
  #akashic-health-records-patient-portal-root .ahr-cmsgs__panel > .grid {
    grid-template-columns: 352px minmax(0, 1fr);
  }

  #akashic-health-records-patient-portal-root .ahr-cmsgs__panel > .grid > :last-child {
    border-left: 1px solid var(--line);
  }
}

/* The practitioner's intake switch, above the tabs. */
#akashic-health-records-patient-portal-root .ahr-msg-intake {
  display: flex;
  flex: none;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin: 0 0 14px;
  text-align: start;
}

/* A colleague-only page's Inbox beside its directory. Clinicians have one row. */
#akashic-health-records-patient-portal-root .ahr-cmsgs .ahr-mm-subtabs {
  flex: none;
  margin: 0 0 10px;
}

#akashic-health-records-patient-portal-root .ahr-cmsgs .ahr-mm-listwrap {
  display: flex;
  flex: 1;
  flex-direction: column;
  align-items: stretch;
  min-height: 0;
  margin: 0;
  padding: 0;
}

#akashic-health-records-patient-portal-root .ahr-cmsgs .ahr-mm-listbody {
  flex: 1;
  min-width: 0;
  min-height: 0;
  max-height: none;
  padding-right: 1px;
  overflow-y: auto;
  text-align: start;
}

#akashic-health-records-patient-portal-root .ahr-cmsgs .ahr-mm-listbody > *,
#akashic-health-records-patient-portal-root .ahr-cmsgs .ahr-mm-listbody .space-y-1 > * {
  margin-top: 0;
  margin-bottom: 0;
}

/* The search with New message beside it; the deck's .msearch spans the row when the action is absent. */
#akashic-health-records-patient-portal-root .ahr-cmsgs .ahr-mm-listbody > .ahr-mm-searchrow {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 0 0 10px;
}

#akashic-health-records-patient-portal-root .ahr-cmsgs .ahr-mm-listbody > .ahr-mm-listswitch--back {
  display: flex;
  width: fit-content;
  margin: 0 0 10px;
}

#akashic-health-records-patient-portal-root .ahr-cmsgs .ahr-mm-listswitch {
  flex: none;
}

#akashic-health-records-patient-portal-root .ahr-cmsgs .ahr-mm-searchrow > .ahr-mm-search {
  flex: 1;
  min-width: 0;
  width: auto;
  margin: 0;
}

#akashic-health-records-patient-portal-root .ahr-cmsgs .ahr-mm-side {
  flex-direction: row;
  flex: none;
  align-items: center;
  gap: 8px;
}

/* Empty lists start near the top of their pane, as the deck's .mempty does. */
#akashic-health-records-patient-portal-root .ahr-cmsgs__panel .my-auto {
  margin-top: 0;
  margin-bottom: 0;
}

#akashic-health-records-patient-portal-root .ahr-cmsgs .ahr-paginator__search {
  margin: 0 0 10px;
}

/* Nothing chosen: a short invitation at the top of the reading pane. */
#akashic-health-records-patient-portal-root .ahr-cmsgs .ahr-mm-pickwrap {
  flex-direction: column;
  justify-content: flex-start;
}

@media (max-width: 767px) {
  /* A phone shows the list or the conversation, never both. */
  #akashic-health-records-patient-portal-root .ahr-cmsgs__panel > .grid > .hidden {
    display: none;
  }

  #akashic-health-records-patient-portal-root .ahr-cmsgs__tabs {
    justify-content: space-between;
  }

  #akashic-health-records-patient-portal-root .ahr-cmsgs__panel > .grid > :first-child {
    padding: 13px 0;
  }
}

/* A colleague-only page, as the Labs and Platform Manager decks draw it. */
#akashic-health-records-patient-portal-root .ahr-cmsgs .ahr-mm-findlabel {
  display: block;
  margin: 0 0 6px;
  color: var(--ink-muted);
  font-size: 12px;
  text-align: start;
}

#akashic-health-records-patient-portal-root .ahr-cmsgs .ahr-mm-nameline {
  display: flex;
  align-items: baseline;
  gap: 8px;
}

#akashic-health-records-patient-portal-root .ahr-cmsgs .ahr-mm-nameline .ahr-mm-name {
  flex: 1;
  min-width: 0;
}

#akashic-health-records-patient-portal-root .ahr-cmsgs .ahr-mm-nameline .ahr-mm-time {
  flex: none;
  white-space: nowrap;
}

#akashic-health-records-patient-portal-root .ahr-cmsgs .ahr-mm-pickwrap--centred {
  flex: 1;
  justify-content: center;
}

#akashic-health-records-patient-portal-root .ahr-cmsgs .ahr-mm-pickwrap--centred .ahr-desk-pick {
  max-width: 440px;
}

/* A colleague thread signs each bubble underneath, as the portal does: name and time, then You and time. */
#akashic-health-records-patient-portal-root .ahr-chat--colleague .ahr-msg-attr {
  margin-top: 5px;
  font-size: 11px;
}

#akashic-health-records-patient-portal-root .ahr-chat--colleague .ahr-msg-attr--me {
  align-items: flex-start;
}

#akashic-health-records-patient-portal-root .ahr-chat--colleague .ahr-msg-attr--me > div {
  margin-top: 0;
}

#akashic-health-records-patient-portal-root .ahr-chat--colleague .ahr-composer-label {
  flex-basis: 100%;
  margin-bottom: 6px;
  font-size: var(--ak-font-12);
  color: var(--ink-muted);
}

/* The colleague thread as its deck draws it: a white head and composer over the paper-toned log. Bubble type
   stays 12px and headings 400, per Spencer's type rulings. */
#akashic-health-records-patient-portal-root .ahr-chat--colleague .ahr-chat-head {
  align-items: center;
  gap: 10px;
  padding: 16px;
  border-top: 0;
  border-bottom: 1px solid var(--line);
  background: var(--surface);
}

#akashic-health-records-patient-portal-root .ahr-chat--colleague .ahr-thread-title {
  margin: 0 0 4px;
  color: var(--ink-strong);
  font-size: 17px;
}

#akashic-health-records-patient-portal-root .ahr-chat--colleague .ahr-chat-body {
  padding: 20px;
  background: var(--paper);
}

#akashic-health-records-patient-portal-root .ahr-chat--colleague .ahr-chat-day {
  display: block;
  margin: 0 0 20px;
  color: var(--ink-muted);
  font-size: 11px;
  text-align: center;
  text-transform: none;
  letter-spacing: normal;
}

#akashic-health-records-patient-portal-root .ahr-chat--colleague .ahr-chat-day::before,
#akashic-health-records-patient-portal-root .ahr-chat--colleague .ahr-chat-day::after {
  display: none;
}

#akashic-health-records-patient-portal-root .ahr-chat--colleague .ahr-chat-foot {
  padding: 12px 16px;
}

#akashic-health-records-patient-portal-root .ahr-chat--colleague .ahr-msg-bubble {
  margin-right: 0;
  padding: 10px 12px;
  border: 0;
  border-radius: 6px;
}

@media (max-width: 767px) {
  /* On a phone the colleague conversation is a sheet over the inbox, below the header, closed by its X. */
  #akashic-health-records-patient-portal-root .ahr-mm-standalone--thread .ahr-mm-standalone__thread {
    position: fixed;
    inset: 52px 0 0;
    z-index: 50;
    border-radius: 12px 12px 0 0;
    background: var(--surface);
    box-shadow: 0 0 0 100vmax var(--scrim);
  }

  #akashic-health-records-patient-portal-root .ahr-chat--colleague .ahr-chat-body {
    padding: 16px;
  }

  #akashic-health-records-patient-portal-root .ahr-chat--colleague .ahr-chat-foot {
    padding: 12px;
  }

  #akashic-health-records-patient-portal-root .ahr-mm-standalone--thread .ahr-chat--colleague {
    border-radius: 12px 12px 0 0;
  }
}

/* The colleague-only inbox rows, and the clinician's patient rows, each as its own deck draws them. */
#akashic-health-records-patient-portal-root .ahr-mm-standalone .ahr-mm-row {
  gap: 10px;
  padding: 14px 12px;
}

#akashic-health-records-patient-portal-root .ahr-mm-standalone .ahr-mm-preview {
  margin-top: 7px;
}

#akashic-health-records-patient-portal-root .ahr-mm-patients .ahr-mm-row .ahr-inbox-avatar:not(:has(img)) {
  background: var(--primary);
  color: var(--primary-foreground);
  font-size: 11.5px;
}

#akashic-health-records-patient-portal-root .ahr-mm-patients .ahr-mm-preview {
  margin-top: 0;
  color: var(--ink-muted);
  font-size: 11.5px;
}

/* The colleague-only directory: a person card with its own Message button, as the deck draws it. */
#akashic-health-records-patient-portal-root .ahr-cmsgs .ahr-mm-people {
  text-align: start;
}

#akashic-health-records-patient-portal-root .ahr-cmsgs .ahr-mm-person {
  display: flex;
  align-items: center;
  gap: 10px;
}

#akashic-health-records-patient-portal-root .ahr-cmsgs .ahr-mm-person__who {
  display: flex;
  flex: 1;
  flex-direction: column;
  min-width: 0;
}

#akashic-health-records-patient-portal-root .ahr-cmsgs .ahr-mm-person__name {
  overflow: hidden;
  color: var(--ink);
  font-size: 13px;
  font-weight: 500;
  text-overflow: ellipsis;
  white-space: nowrap;
}

#akashic-health-records-patient-portal-root .ahr-cmsgs .ahr-mm-person__sub {
  margin-top: 4px;
  color: var(--ink-muted);
  font-size: 12px;
}

#akashic-health-records-patient-portal-root .ahr-cmsgs .ahr-mm-person .ahr-inbox-avatar {
  flex: none;
  background: var(--blue-soft);
  color: var(--primary);
  font-size: 12px;
}

#akashic-health-records-patient-portal-root .ahr-cmsgs .ahr-mm-person .btn {
  flex-shrink: 0;
}
