/* Shared application chrome: account switcher, folder nav, view toggle,
   avatars, section headings, status messages, and empty states. */

/* The navigation panel is a fixed column: a static top, a scrolling middle that
   holds either folders and filters or the conversation list, and the account
   switcher pinned to the bottom. */
.app-nav-panel {
  display: flex;
  flex-direction: column;
  gap: 0;
  padding: 0;
  overflow: hidden;
}

.app-nav-panel__top {
  display: flex;
  flex-direction: column;
  gap: var(--wf-space-3);
  padding: var(--wf-space-4) var(--wf-space-4) var(--wf-space-3);
}

/* Messenger mode separates its menu from the conversation list below. */
.app-nav-panel__top--divided {
  border-bottom: 1px solid var(--wf-border);
}

.app-nav-panel__top .app-search {
  width: 100%;
}

/* Compose sits inside the scrolling region, below the folder list. */
.app-nav-panel__scroll > .wf-button {
  margin-inline: var(--wf-space-1);
}

.app-nav-panel__scroll {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  gap: var(--wf-space-4);
  overflow: auto;
  /* Top padding keeps the first row clear of the divider above it. */
  padding: var(--wf-space-3) var(--wf-space-2) var(--wf-space-3);
}

.app-nav-panel__foot {
  flex: 0 0 auto;
  padding: var(--wf-space-3) var(--wf-space-3);
  border-top: 1px solid var(--wf-border);
  background: var(--wf-surface);
}

.wf-shell--wide-nav {
  --wf-left-panel-width: 336px;
}

[data-mode-top][hidden],
[data-mode-panel][hidden] {
  display: none;
}

.app-nav-intro {
  margin: 0;
  padding: 0 var(--wf-space-3) var(--wf-space-2);
  color: var(--wf-text-subtle);
  font-size: var(--wf-text-xs);
  line-height: var(--wf-line);
}

.app-brand {
  display: flex;
  align-items: center;
  gap: var(--wf-space-2);
  color: var(--wf-text);
  font-size: var(--wf-text-lg);
  font-weight: 700;
  text-decoration: none;
}

.app-brand .wf-icon {
  width: 20px;
  height: 20px;
  color: var(--wf-gray-600);
}

/* Account switcher */

.app-account {
  display: block;
}

.app-account .wf-dropdown,
.app-account .wf-dropdown__panel {
  width: 100%;
}

.app-account__trigger {
  width: 100%;
  min-height: 52px;
  display: flex;
  align-items: center;
  gap: var(--wf-space-3);
  padding: var(--wf-space-2) var(--wf-space-3);
  border: 1px solid var(--wf-border);
  border-radius: var(--wf-radius-3);
  background: var(--wf-gray-25);
  color: var(--wf-text);
  text-align: left;
  font-weight: 400;
}

.app-account__trigger:hover {
  background: var(--wf-gray-100);
}

.app-account__body {
  min-width: 0;
  flex: 1;
}

.app-account__address {
  display: block;
  overflow: hidden;
  font-size: var(--wf-text-sm);
  font-weight: 700;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.app-account__state {
  display: block;
  color: var(--wf-text-subtle);
  font-size: var(--wf-text-xs);
}

.app-account__state--warn {
  color: var(--wf-gray-700);
  font-weight: 700;
}

.wf-dropdown__panel--up {
  top: auto;
  bottom: calc(100% + var(--wf-space-2));
}

.app-dropdown__heading {
  padding: var(--wf-space-2) var(--wf-space-3);
  color: var(--wf-text-subtle);
  font-size: var(--wf-text-2xs);
  font-weight: 700;
  letter-spacing: .08em;
  text-transform: uppercase;
}

/* Header user menu. The trigger is a header icon button so it reads as a peer
   of the mail-check control beside it. Identity lives inside
   the panel, because the header has no room for a name at narrow widths. */

.app-user > .wf-dropdown__panel {
  min-width: 260px;
}

.app-user__identity {
  display: flex;
  align-items: center;
  gap: var(--wf-space-3);
  padding: var(--wf-space-2) var(--wf-space-3);
}

.app-user__body {
  min-width: 0;
  flex: 1;
}

.app-user__name {
  display: block;
  overflow: hidden;
  font-size: var(--wf-text-sm);
  font-weight: 700;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.app-user__email {
  display: block;
  overflow: hidden;
  color: var(--wf-text-subtle);
  font-size: var(--wf-text-xs);
  text-overflow: ellipsis;
  white-space: nowrap;
}

.app-dropdown__divider {
  height: 1px;
  margin: var(--wf-space-2) 0;
  border: 0;
  background: var(--wf-border);
}

/* Folder and section navigation */

.app-nav {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.app-nav__heading {
  padding: var(--wf-space-2) var(--wf-space-3) var(--wf-space-1);
  color: var(--wf-text-subtle);
  font-size: var(--wf-text-2xs);
  font-weight: 700;
  letter-spacing: .08em;
  text-transform: uppercase;
}

.app-nav__section-head {
  min-height: 32px;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: var(--wf-space-2);
  padding-right: var(--wf-space-2);
}

.app-nav__section-head .app-nav__heading {
  min-width: 0;
  padding-right: 0;
}

.filter-heading__actions {
  display: inline-flex;
  align-self: center;
  align-items: center;
  justify-content: flex-end;
  gap: var(--wf-space-1);
  white-space: nowrap;
}

.filter-heading__actions[hidden] {
  display: none;
}

.filter-heading__action {
  width: 28px;
  height: 28px;
  display: inline-grid;
  flex: 0 0 auto;
  place-items: center;
  padding: 0;
  border: 0;
  border-radius: var(--wf-radius-2);
  background: transparent;
  color: var(--wf-gray-600);
  font: inherit;
  line-height: 0;
  text-decoration: none;
  vertical-align: middle;
  cursor: pointer;
}

.filter-heading__action:hover,
.filter-heading__action:focus-visible {
  background: var(--wf-gray-100);
  color: var(--wf-text);
}

.filter-heading__actions .wf-dropdown {
  display: inline-flex;
  align-items: center;
}

.filter-heading__action > [data-wf-icon] {
  width: 16px;
  height: 16px;
  display: inline-grid;
  place-items: center;
}

.filter-heading__action .wf-icon {
  position: static;
  width: 16px;
  height: 16px;
  display: block;
  transform: none;
}

.filter-sort-menu {
  min-width: 172px;
}

.filter-sort-menu__check {
  width: 16px;
  height: 16px;
  display: inline-grid;
  flex: 0 0 auto;
  place-items: center;
}

.filter-sort-menu__check[data-visible="false"] {
  visibility: hidden;
}

.filter-sort-menu__check .wf-icon {
  width: 14px;
  height: 14px;
}

.app-nav[data-filter-editing="true"] .app-nav__link {
  cursor: grab;
  user-select: none;
}

.app-nav[data-filter-editing="true"] .app-nav__link:active {
  cursor: grabbing;
}

.app-nav[data-filter-editing="true"] .app-nav__link[data-filter-dragging="true"] {
  opacity: .45;
}

.app-nav[data-filter-editing="true"] .app-nav__link[data-filter-drop-target="true"] {
  box-shadow: inset 0 2px 0 var(--wf-gray-600);
}

.app-nav__link {
  display: flex;
  align-items: center;
  gap: var(--wf-space-3);
  min-height: 34px;
  padding: 0 var(--wf-space-3);
  border-radius: var(--wf-radius-2);
  color: var(--wf-text);
  font-size: var(--wf-text-sm);
  text-decoration: none;
}

.app-nav__button {
  width: 100%;
  border: 0;
  background: transparent;
  text-align: left;
}

.app-nav__link:hover {
  background: var(--wf-gray-100);
}

.app-nav__link[aria-current="page"] {
  background: var(--wf-gray-100);
  font-weight: 700;
}

.app-nav__link .wf-icon {
  width: 16px;
  height: 16px;
  color: var(--wf-gray-500);
}

.app-nav__link[aria-current="page"] .wf-icon {
  color: var(--wf-gray-700);
}

.app-nav__label {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.app-nav__count {
  color: var(--wf-text-subtle);
  font-size: var(--wf-text-xs);
  font-weight: 700;
}

.app-nav__link[aria-current="page"] .app-nav__count {
  color: var(--wf-text);
}

/* Header */

.wf-shell__header {
  gap: var(--wf-space-3);
  /* The bundled panel layout sets `overflow: hidden` here so a long screen
     title ellipses against the header box. That also clips anything that
     escapes the header, and the user menu's popover is 166px tall inside a
     64px header, so it was being cut to a sliver. Let the header overflow and
     make the title clip itself instead. */
  overflow: visible;
}

.app-title {
  min-width: 0;
  margin: 0;
  overflow: hidden;
  font-size: var(--wf-text-lg);
  font-weight: 700;
  line-height: var(--wf-line-tight);
  text-overflow: ellipsis;
  white-space: nowrap;
}

.app-title-group {
  min-width: 0;
  display: flex;
  align-items: center;
  gap: var(--wf-space-2);
}

.app-title__icon {
  flex: 0 0 auto;
  color: var(--wf-gray-600);
}

.app-title__icon .wf-icon {
  width: 18px;
  height: 18px;
}

.app-search {
  width: min(420px, 40vw);
  position: relative;
  display: block;
}

.app-search > [data-wf-icon="search"] > .wf-icon {
  position: absolute;
  z-index: 1;
  top: 50%;
  left: var(--wf-space-3);
  width: 16px;
  height: 16px;
  color: var(--wf-gray-500);
  transform: translateY(-50%);
  pointer-events: none;
}

.app-search__input {
  width: 100%;
  display: block;
  box-sizing: border-box;
  min-height: 36px;
  padding: 0 var(--wf-space-3) 0 var(--wf-space-8);
  border: 1px solid var(--wf-border-strong);
  border-radius: 999px;
  background: var(--wf-gray-50);
  color: var(--wf-text);
  font-size: var(--wf-text-sm);
}

.app-search__input:focus {
  background: var(--wf-white);
}

.app-search-suggestions {
  position: absolute;
  z-index: 50;
  top: calc(100% + var(--wf-space-2));
  left: 0;
  right: 0;
  width: auto;
  box-sizing: border-box;
  max-height: min(360px, 55vh);
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: var(--wf-space-2);
  border: 1px solid var(--wf-border);
  border-radius: var(--wf-radius-3);
  background: var(--wf-surface);
  box-shadow: var(--wf-shadow-2);
}

.app-search-suggestions[hidden] {
  display: none;
}

.app-search-suggestion {
  width: 100%;
  display: grid;
  gap: var(--wf-space-1);
  padding: var(--wf-space-2);
  border: 0;
  border-radius: var(--wf-radius-2);
  background: transparent;
  color: var(--wf-text);
  text-align: left;
  cursor: pointer;
}

.app-search-suggestion:hover,
.app-search-suggestion[aria-selected="true"] {
  background: var(--wf-gray-100);
}

.app-search-suggestion__identity,
.app-search-suggestion__message {
  min-width: 0;
  display: grid;
  gap: 2px;
}

.app-search-suggestion__identity {
  font-size: var(--wf-text-xs);
}

.app-search-suggestion__message {
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: baseline;
  gap: var(--wf-space-2);
}

.app-search-suggestion__identity span,
.app-search-suggestion__message time {
  color: var(--wf-text-subtle);
  font-size: var(--wf-text-2xs);
}

.app-search-suggestion__identity span,
.app-search-suggestion__message span {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.app-search-suggestion__identity strong {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.app-search-suggestions__empty {
  margin: 0;
  padding: var(--wf-space-3) var(--wf-space-2);
  color: var(--wf-text-subtle);
  font-size: var(--wf-text-xs);
  text-align: center;
}

/* View selector */

.app-view-select {
  align-self: center;
}

.app-view-select__trigger {
  min-height: 34px;
  align-items: center;
  padding: 0 var(--wf-space-3);
  font-size: var(--wf-text-sm);
  white-space: nowrap;
}

.app-view-select__trigger > [data-wf-icon] {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  line-height: 0;
}

.app-view-select__trigger [data-view-current-label] {
  display: inline-flex;
  align-items: center;
  line-height: 1;
}

.app-view-select__trigger .wf-icon,
.app-view-select__option .wf-icon {
  width: 15px;
  height: 15px;
}

.app-view-select__menu {
  min-width: 172px;
}

.app-view-select__option[aria-current="page"] {
  background: var(--wf-gray-100);
  font-weight: 700;
}

.app-view-select__check {
  margin-left: auto;
  visibility: hidden;
}

.app-view-select__option[aria-current="page"] .app-view-select__check {
  visibility: visible;
}

.app-check {
  display: flex;
  align-items: center;
  gap: var(--wf-space-2);
  padding: 0;
  border: 0;
  background: transparent;
  color: var(--wf-text-subtle);
  font-size: var(--wf-text-xs);
  white-space: nowrap;
  cursor: pointer;
}

.app-check .wf-icon {
  width: 14px;
  height: 14px;
}

.app-check:disabled {
  cursor: wait;
}

/* Below 992px the bundled layout hides the whole header end while the
   navigation overlay is open, so the view toggle and mail-check control get out of
   the way. That was harmless when the header end held only shortcuts. It is not
   harmless now: the user menu is the only route to Inbox settings, Account
   settings and Sign out, and hiding it strands a person behind an open panel.
   Keep the menu; let the rest go. */
@media (max-width: 991.98px) {
  .wf-shell[data-wf-left-open="true"][data-wf-right-open="false"] .wf-shell__header-end {
    display: flex;
  }

  .wf-shell[data-wf-left-open="true"][data-wf-right-open="false"] .wf-shell__header-end > *:not(.app-user):not(.app-notifications) {
    display: none;
  }
}

/* Avatars */

.app-avatar {
  width: 36px;
  height: 36px;
  display: grid;
  flex: 0 0 auto;
  place-items: center;
  border: 1px solid var(--wf-border-strong);
  border-radius: 999px;
  background: var(--wf-gray-100);
  color: var(--wf-gray-700);
  font-size: var(--wf-text-xs);
  font-weight: 700;
  letter-spacing: .02em;
}

.app-avatar--sm {
  width: 28px;
  height: 28px;
  font-size: var(--wf-text-2xs);
}

.app-avatar--lg {
  width: 44px;
  height: 44px;
  font-size: var(--wf-text-sm);
}

.app-avatar--strong {
  border-color: var(--wf-gray-500);
  background: var(--wf-gray-500);
  color: var(--wf-white);
}

.app-avatar-stack {
  position: relative;
  width: 36px;
  height: 36px;
  flex: 0 0 auto;
}

.app-avatar-stack .app-avatar {
  position: absolute;
  width: 24px;
  height: 24px;
  font-size: 9px;
}

.app-avatar-stack .app-avatar:nth-child(1) {
  top: 0;
  left: 0;
  z-index: 2;
}

.app-avatar-stack .app-avatar:nth-child(2) {
  right: 0;
  bottom: 0;
  z-index: 1;
  background: var(--wf-gray-200);
}

/* Page structure inside the panel centre */

.wf-shell__center {
  padding: 0;
}

.app-region {
  height: 100%;
  display: flex;
  flex-direction: column;
  min-height: 0;
  background: var(--wf-surface);
}

.app-scroll {
  flex: 1;
  min-height: 0;
  overflow: auto;
}

.app-pad {
  padding: var(--wf-space-6);
}

.app-measure {
  width: min(100%, 860px);
  margin-inline: auto;
}

.app-section {
  display: flex;
  flex-direction: column;
  gap: var(--wf-space-4);
  padding: var(--wf-space-5);
  border: 1px solid var(--wf-border);
  border-radius: var(--wf-radius-4);
  background: var(--wf-surface);
}

.app-section + .app-section {
  margin-top: var(--wf-space-5);
}

.app-section__title {
  margin: 0;
  font-size: var(--wf-text-lg);
  line-height: var(--wf-line-tight);
}

.app-section__hint {
  margin: var(--wf-space-1) 0 0;
  color: var(--wf-text-muted);
  font-size: var(--wf-text-sm);
}

.app-toolbar {
  display: flex;
  align-items: center;
  gap: var(--wf-space-2);
  min-height: 52px;
  padding: var(--wf-space-2) var(--wf-space-4);
  border-bottom: 1px solid var(--wf-border);
  background: var(--wf-surface);
}

.app-toolbar__spacer {
  flex: 1;
}

.app-toolbar__count {
  color: var(--wf-text-muted);
  font-size: var(--wf-text-sm);
}

/* Status messages */

.app-status {
  display: flex;
  align-items: center;
  gap: var(--wf-space-3);
  flex: 0 0 auto;
  margin: var(--wf-space-3) var(--wf-space-4);
  padding: var(--wf-space-3) var(--wf-space-4);
  border: 1px solid var(--wf-border-strong);
  border-radius: var(--wf-radius-3);
  background: var(--wf-gray-50);
  color: var(--wf-text);
  font-size: var(--wf-text-sm);
}

.app-status .wf-icon {
  width: 16px;
  height: 16px;
  color: var(--wf-gray-500);
}

.app-status[hidden] {
  display: none;
}

.app-status__text {
  flex: 1;
}

/* Empty states */

.app-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--wf-space-2);
  padding: var(--wf-space-12) var(--wf-space-6);
  text-align: center;
}

.app-empty .wf-icon {
  width: 32px;
  height: 32px;
  color: var(--wf-gray-400);
}

.app-empty__title {
  margin: var(--wf-space-2) 0 0;
  font-size: var(--wf-text-lg);
  font-weight: 700;
}

.app-empty__body {
  margin: 0;
  max-width: 42ch;
  color: var(--wf-text-muted);
  font-size: var(--wf-text-sm);
}

/* Definition rows used by accounts, settings, and conversation details */

.app-facts {
  display: grid;
  gap: var(--wf-space-2);
  margin: 0;
}

.app-facts div {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: var(--wf-space-4);
  font-size: var(--wf-text-sm);
}

.app-facts dt {
  color: var(--wf-text-subtle);
}

.app-facts dd {
  margin: 0;
  text-align: right;
}

.app-list-plain {
  display: flex;
  flex-direction: column;
  margin: 0;
  padding: 0;
  list-style: none;
}

.app-list-plain > li {
  display: flex;
  align-items: center;
  gap: var(--wf-space-3);
  padding: var(--wf-space-3) 0;
  border-bottom: 1px solid var(--wf-border);
  font-size: var(--wf-text-sm);
}

.app-list-plain > li:last-child {
  border-bottom: 0;
}

.app-list-plain__body {
  flex: 1;
  min-width: 0;
}

.app-list-plain__name {
  display: block;
  font-weight: 700;
}

.app-list-plain__meta {
  display: block;
  color: var(--wf-text-subtle);
  font-size: var(--wf-text-xs);
}

@media (max-width: 759.98px) {
  .app-view-select__trigger {
    min-width: 88px;
    padding-inline: var(--wf-space-2);
  }

  .app-view-select__trigger .wf-icon,
  .app-view-select__option .wf-icon {
    width: 16px;
    height: 16px;
  }

  .app-check {
    width: 36px;
    height: 36px;
    justify-content: center;
  }

  .app-check [data-check-text] {
    display: none;
  }

  .app-title {
    overflow: hidden;
    text-overflow: ellipsis;
  }
}

/* Header row for a side panel: title plus its own close control. */
.app-panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--wf-space-3);
}

.app-panel-head .wf-icon {
  width: 16px;
  height: 16px;
}

/* Native form controls default to the browser accent, which is blue. The
   wireframe is grayscale, so pin them to the neutral ramp. */
input[type="checkbox"],
input[type="radio"] {
  accent-color: var(--wf-gray-600);
}
