/*
  Wortic macOS UI Kit — Header App
  Barra de aplicação de SISTEMA/PAINEL. Depende de header-shell.css.
  Aqui moram: seletor de workspace/conta, linha de contexto
  (breadcrumb), fita de abas de seção e a pílula de saldo/créditos.

  Regra de densidade: a barra de app é 52px por padrão e 40px com
  .wm-header--compact. A segunda linha (abas ou contexto) NÃO some no
  estreito — ela vira rolagem horizontal, porque em painel o contexto
  é o que diz onde a pessoa está.

  Ficha: docs/header-app.json
*/

@layer components {
  /* ---------- Seletor de workspace / conta ---------- */

  .wm-header-app__workspace {
    display: inline-flex;
    align-items: center;
    gap: var(--wm-space-4);
    max-inline-size: var(--wm-nav-search-width);
    min-inline-size: 0;
    block-size: var(--wm-control-height-lg);
    padding-inline: var(--wm-space-5);
    border: var(--wm-border-width-hairline) solid var(--wm-separator);
    border-radius: var(--wm-radius-md);
    background: var(--wm-fill-quaternary);
    color: var(--wm-label-primary);
    cursor: pointer;
    text-align: start;
  }
  .wm-header-app__workspace:hover {
    background: var(--wm-fill-tertiary);
  }
  .wm-header-app__workspace:focus-visible {
    outline: var(--wm-focus-ring-width) solid var(--wm-accent);
    outline-offset: var(--wm-focus-ring-offset);
    box-shadow: 0 0 0 var(--wm-focus-halo-width) var(--wm-accent-fill);
  }
  .wm-header-app__workspace-mark {
    flex: none;
    inline-size: var(--wm-control-height-sm);
    block-size: var(--wm-control-height-sm);
    display: inline-grid;
    place-items: center;
    border-radius: var(--wm-radius-settings-icon);
    background: var(--wm-accent-gradient);
    color: var(--wm-label-on-accent);
    font-size: var(--wm-font-size-caption2);
    font-weight: var(--wm-font-weight-bold);
  }
  .wm-header-app__workspace-text {
    display: flex;
    flex-direction: column;
    min-inline-size: 0;
  }
  .wm-header-app__workspace-name {
    font-size: var(--wm-font-size-footnote);
    font-weight: var(--wm-font-weight-semibold);
    letter-spacing: var(--wm-tracking-footnote);
    line-height: var(--wm-line-height-tight);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }
  .wm-header-app__workspace-role {
    font-size: var(--wm-font-size-caption2);
    letter-spacing: var(--wm-tracking-caption2);
    line-height: var(--wm-line-height-tight);
    color: var(--wm-label-tertiary);
    white-space: nowrap;
  }
  .wm-header-app__workspace-caret {
    flex: none;
    margin-inline-start: auto;
    color: var(--wm-label-quaternary);
  }

  .wm-header-app__workspace-list {
    max-block-size: calc(var(--wm-control-height-3xl) * 6);
    overflow-y: auto;
    overscroll-behavior: contain;
  }

  /* ---------- Segunda linha: contexto ou abas ---------- */

  .wm-header-app__strip {
    display: flex;
    align-items: center;
    gap: var(--wm-space-6);
    block-size: var(--wm-control-height-2xl);
    padding-inline: var(--wm-space-9);
    background: var(--wm-surface-secondary);
    border-block-end: var(--wm-border-width-hairline) solid
      color-mix(in srgb, var(--wm-separator) 85%, transparent);
    overflow-x: auto;
    overflow-y: hidden;
    scrollbar-width: none;
  }
  .wm-header-app__strip::-webkit-scrollbar {
    display: none;
  }

  .wm-header-app__crumbs {
    display: flex;
    align-items: center;
    gap: var(--wm-space-3);
    margin: 0;
    padding: 0;
    list-style: none;
    white-space: nowrap;
  }
  .wm-header-app__crumb {
    display: inline-flex;
    align-items: center;
    gap: var(--wm-space-3);
    font-size: var(--wm-font-size-footnote);
    letter-spacing: var(--wm-tracking-footnote);
    color: var(--wm-label-tertiary);
  }
  .wm-header-app__crumb-link {
    color: var(--wm-label-secondary);
    text-decoration: none;
    border-radius: var(--wm-radius-xs);
  }
  .wm-header-app__crumb-link:hover {
    color: var(--wm-label-primary);
    text-decoration: underline;
    text-underline-offset: var(--wm-space-1);
  }
  .wm-header-app__crumb-link:focus-visible {
    outline: var(--wm-focus-ring-width) solid var(--wm-accent);
    outline-offset: var(--wm-focus-ring-offset);
  }
  .wm-header-app__crumb[aria-current="page"] {
    color: var(--wm-label-primary);
    font-weight: var(--wm-font-weight-medium);
  }
  .wm-header-app__crumb-sep {
    color: var(--wm-label-quaternary);
  }

  .wm-header-app__tabs {
    display: flex;
    align-items: stretch;
    gap: var(--wm-space-2);
    block-size: 100%;
  }
  .wm-header-app__tab {
    display: inline-flex;
    align-items: center;
    gap: var(--wm-space-3);
    padding-inline: var(--wm-space-6);
    border: none;
    background: transparent;
    border-block-end: var(--wm-border-width-thick) solid transparent;
    color: var(--wm-label-secondary);
    font-size: var(--wm-font-size-footnote);
    font-weight: var(--wm-font-weight-medium);
    letter-spacing: var(--wm-tracking-footnote);
    text-decoration: none;
    white-space: nowrap;
    cursor: pointer;
  }
  .wm-header-app__tab:hover {
    color: var(--wm-label-primary);
  }
  .wm-header-app__tab[aria-current="page"],
  .wm-header-app__tab[aria-selected="true"] {
    color: var(--wm-accent-text);
    border-block-end-color: var(--wm-accent);
  }
  .wm-header-app__tab:focus-visible {
    outline: var(--wm-focus-ring-width) solid var(--wm-accent);
    outline-offset: calc(-1 * var(--wm-focus-ring-offset));
  }
  .wm-header-app__tab-count {
    display: inline-grid;
    place-items: center;
    min-inline-size: var(--wm-icon-md);
    padding-inline: var(--wm-space-2);
    border-radius: var(--wm-radius-pill);
    background: var(--wm-fill-tertiary);
    color: var(--wm-label-secondary);
    font-size: var(--wm-font-size-caption2);
    font-variant-numeric: tabular-nums;
  }

  .wm-header-app__strip-end {
    margin-inline-start: auto;
    display: flex;
    align-items: center;
    gap: var(--wm-space-4);
    flex: none;
  }

  /* ---------- Saldo / créditos ---------- */

  .wm-header-app__credits {
    display: inline-flex;
    align-items: center;
    gap: var(--wm-space-3);
    block-size: var(--wm-control-height-md);
    padding-inline: var(--wm-space-5);
    border: var(--wm-border-width-hairline) solid var(--wm-separator);
    border-radius: var(--wm-radius-pill);
    background: var(--wm-fill-quaternary);
    color: var(--wm-label-primary);
    font-size: var(--wm-font-size-caption);
    font-weight: var(--wm-font-weight-semibold);
    letter-spacing: var(--wm-tracking-caption);
    font-variant-numeric: tabular-nums;
    text-decoration: none;
    cursor: pointer;
  }
  .wm-header-app__credits:hover {
    background: var(--wm-fill-tertiary);
  }
  .wm-header-app__credits:focus-visible {
    outline: var(--wm-focus-ring-width) solid var(--wm-accent);
    outline-offset: var(--wm-focus-ring-offset);
  }
  .wm-header-app__credits-icon {
    flex: none;
    color: var(--wm-accent-text);
  }
  .wm-header-app__credits--low {
    border-color: var(--wm-warning);
    background: var(--wm-warning-fill);
  }
  .wm-header-app__credits--low .wm-header-app__credits-icon {
    color: var(--wm-warning);
  }

  /* ---------- Densidade alta ---------- */

  .wm-header-app__strip--compact {
    block-size: var(--wm-control-height-lg);
  }

  @media (max-width: 679px) {   /* [--wm-bp-md] */
    .wm-header-app__strip {
      padding-inline: var(--wm-space-8);
    }
    /* O caminho inteiro não cabe: mantemos o ÚLTIMO nível (onde a
       pessoa está) e o penúltimo, e escondemos o meio. Nunca o
       último — é ele que responde "onde eu estou". */
    .wm-header-app__crumb--middle {
      display: none;
    }
    .wm-header-app__crumb--ellipsis {
      display: inline-flex;
    }
  }

  .wm-header-app__crumb--ellipsis {
    display: none;
  }

  @media (max-width: 559px) {   /* [--wm-bp-sm] */
    .wm-header-app__workspace {
      max-inline-size: none;
      inline-size: var(--wm-control-height-lg);
      padding-inline: 0;
      justify-content: center;
    }
    .wm-header-app__workspace-text,
    .wm-header-app__workspace-caret {
      display: none;
    }
    .wm-header-app__strip {
      padding-inline: var(--wm-space-6);
    }
  }
}
