/* ============================================================================
   PLX CASCA · lateral, trilho, topo, abas da seção e barra de baixo (L3 do redesign, 22/11/2026)
   ----------------------------------------------------------------------------
   As quatro larguras do padrão (IDENTIDADE-E-METODO-REDESIGN.md §1.3), num lugar só:
     ≥ 1200 (desktop)   lateral de 232 px: marca, empresa, 12 itens em 4 grupos, cartão do usuário
     720–1199           trilho de 68 px: só ícones de 44 (o nome vira dica nativa); a empresa sobe para o topo
     < 720 (celular)    sem lateral; barra de baixo de 64 px: Início · Conversas · «+» · Leads · Mais
   O HTML é do index.html; as listas (nav, barra, abas) saem de PLX.NAV (js/nav.js). Só tokens; só as larguras da escala.
   ============================================================================ */

.plx-casca { display: grid; grid-template-columns: var(--lateral-w) minmax(0, 1fr); min-height: 100dvh; background: var(--bg); color: var(--ink); }
.plx-coluna { min-width: 0; display: flex; flex-direction: column; }
.plx-coluna > main#app { width: 100%; min-width: 0; box-sizing: border-box; flex: 1; }

/* ---------- lateral ---------- */
.plx-lateral {
  position: sticky; top: 0; height: 100dvh; min-width: 0; display: flex; flex-direction: column; gap: 6px; padding: 14px 10px;
  overflow-x: hidden; overflow-y: auto; background: var(--surface-2); border-right: 1px solid var(--line);
}
.plx-marca { display: block; padding: 6px 10px 10px; color: var(--ink); text-decoration: none; white-space: nowrap; font: 700 18px/1 var(--font-display); letter-spacing: -.02em; }
.plx-marca span { color: var(--accent-text); }
.plx-ws-lateral { min-width: 0; }
.plx-nav { display: flex; flex-direction: column; gap: 2px; flex: 1; min-height: 0; }
.plx-nav__grupo ul { display: flex; flex-direction: column; gap: 2px; margin: 0; padding: 0; list-style: none; }
.plx-nav__titulo { margin: 0; padding: 16px 10px 6px; color: var(--ink-3); font: 600 var(--fs-min)/1 var(--font); letter-spacing: .1em; text-transform: uppercase; }
.plx-nav__item {
  position: relative; display: flex; align-items: center; gap: 10px; min-height: 40px; padding: 0 10px; border-radius: var(--r-sm);
  color: var(--ink-2); text-decoration: none; white-space: nowrap; font: 500 var(--fs-corpo-sm)/1 var(--font); transition: background .12s;
}
.plx-nav__item:hover { background: var(--fill); }
.plx-nav__item[aria-current="page"] { background: var(--accent-soft); color: var(--accent-text); }
.plx-lateral__pe { margin-top: 8px; }
.plx-user {
  display: flex; align-items: center; gap: 10px; width: 100%; min-height: 48px; padding: 6px 8px; border: 0; border-radius: var(--r-md);
  background: var(--surface); box-shadow: var(--shadow-1); color: var(--ink); text-align: left; cursor: pointer;
}
.plx-user:hover { background: var(--fill); }
.plx-user__avatar { display: grid; place-items: center; flex: none; width: 32px; height: 32px; border-radius: 50%; background: var(--fill-2); color: var(--ink-2); font: 600 var(--fs-min)/1 var(--font); }
.plx-user__quem { min-width: 0; display: flex; flex-direction: column; }
.plx-user__quem b { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font: 600 var(--fs-rotulo)/1.3 var(--font); }
.plx-user__quem span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--ink-3); font-size: var(--fs-min); line-height: 1.3; }

/* seletor de empresa (#wsWrap / #tenantBadge / #wsMenu — os mesmos ids; o nó muda de lugar com a largura) */
.plx-casca .tenant-badge {
  display: flex; align-items: center; gap: 8px; width: 100%; max-width: 100%; min-height: 40px; padding: 0 10px; border: 0; border-radius: var(--r-sm);
  background: var(--fill); color: var(--ink); text-align: left; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  font: 500 var(--fs-corpo-sm)/1.2 var(--font); cursor: default;
}
.plx-casca .tenant-badge.trocavel { cursor: pointer; border: 0; border-radius: var(--r-sm); }
.plx-casca .tenant-badge.trocavel:hover { background: var(--fill-2); color: var(--ink); }
.plx-casca .navmore-wrap { position: relative; min-width: 0; }
.plx-casca .navmore-menu {
  z-index: var(--camada-popover); min-width: 240px; padding: 6px; border: 0; border-radius: var(--r-md); background: var(--surface); box-shadow: var(--shadow-2);
}
.plx-casca .navmore-menu a, .plx-casca .navmore-menu button { color: var(--ink); }
.plx-casca .ws-item { min-height: 44px; border-radius: var(--r-sm); color: var(--ink); font: 500 var(--fs-corpo-sm)/1.3 var(--font); }
.plx-casca .ws-item:hover { background: var(--fill); color: var(--ink); }
.plx-casca .ws-item .ws-papel { color: var(--ink-3); font: 500 var(--fs-min)/1 var(--font); letter-spacing: 0; text-transform: none; }
.plx-ws-lateral .navmore-menu { left: 0; right: auto; top: calc(100% + 6px); }

/* ---------- topo ---------- */
.plx-topo {
  position: sticky; top: 0; z-index: var(--camada-topo); display: flex; align-items: center; gap: 10px; height: var(--topbar-h); padding: 0 16px;
  background: var(--surface); border-bottom: 1px solid var(--line);
}
.plx-topo__secao { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--ink); font: 600 15px/1 var(--font-display); }
.plx-topo__secao:empty { display: none; }
.plx-ws-topo { min-width: 0; max-width: 200px; }
.plx-ws-topo:empty { display: none; }
.plx-ws-topo .navmore-menu { left: 0; right: auto; top: calc(100% + 6px); }
.plx-topo__mola { flex: 1; min-width: 0; }
.plx-busca-topo {
  display: flex; align-items: center; gap: 8px; flex: 0 1 340px; min-width: 0; height: 36px; padding: 0 10px; border: 0; border-radius: var(--r-sm);
  background: var(--fill); color: var(--ink-3); text-align: left; cursor: pointer; font: 400 var(--fs-corpo-sm)/1 var(--font);
}
.plx-busca-topo:hover { background: var(--fill-2); color: var(--ink-2); }
.plx-busca-topo__texto { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.plx-novo { display: inline-flex; align-items: center; gap: 6px; flex: none; height: 36px; padding: 0 14px; border: 0; border-radius: var(--r-sm); background: var(--ink); color: var(--inv); cursor: pointer; font: 600 var(--fs-corpo-sm)/1 var(--font); }
.plx-novo:hover { opacity: .9; }

/* ---------- abas da seção (as telas de hoje que o item absorve) ---------- */
.plx-secao-abas { max-width: 1440px; width: 100%; margin: 0 auto; padding: 12px 24px 0; box-sizing: border-box; }
.plx-secao-abas[hidden] { display: none; }

/* ---------- barra de baixo (celular) ---------- */
.plx-barra-baixo {
  display: none; position: fixed; left: 0; right: 0; bottom: 0; z-index: var(--camada-barra-baixo); justify-content: space-around; align-items: center;
  height: calc(var(--barra-baixo-h) + env(safe-area-inset-bottom, 0px)); padding: 0 6px env(safe-area-inset-bottom, 0px);
  background: var(--surface); border-top: 1px solid var(--line);
}
.plx-barra-baixo__item {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; min-width: 56px; height: 56px; padding: 0 4px;
  border: 0; border-radius: 12px; background: transparent; color: var(--ink-3); text-decoration: none; cursor: pointer; font: 500 var(--fs-min)/1 var(--font);
}
.plx-barra-baixo__item[aria-current="page"], .plx-barra-baixo__item.active { color: var(--accent-text); }
.plx-barra-baixo__novo {
  display: grid; place-items: center; flex: none; width: 48px; height: 48px; padding: 0; border: 0; border-radius: 50%;
  background: var(--ink); color: var(--inv); box-shadow: var(--shadow-1); cursor: pointer;
}

/* popovers do topo e do pé da lateral: ficam no <body> e usam posição fixa (a lateral rola e cortaria o painel) */
.plx-popover--fixo { position: fixed; }
.plx-popover--tema { padding: 6px 8px 8px; }
.plx-popover--tema .plx-seg { width: 100%; }
.plx-popover--tema .plx-seg > button { flex: 1; }

/* ---------- 720 a 1199: trilho de 68 ---------- */
@media (max-width: 1199.98px) {
  .plx-casca { grid-template-columns: var(--trilho-w) minmax(0, 1fr); }
  .plx-lateral { align-items: center; padding: 14px 8px; }
  .plx-marca { display: grid; place-items: center; width: 44px; height: 44px; padding: 0; font-size: 15px; }
  .plx-marca__resto, .plx-nav__titulo, .plx-nav__rotulo, .plx-user__quem { display: none; }
  .plx-nav { align-items: center; width: 100%; }
  .plx-nav__grupo { width: 100%; display: flex; flex-direction: column; align-items: center; }
  .plx-nav__grupo + .plx-nav__grupo { margin-top: 8px; padding-top: 8px; border-top: 1px solid var(--line); }
  .plx-nav__item { width: 44px; height: 44px; min-height: 44px; justify-content: center; padding: 0; }
  .plx-user { width: 44px; min-height: 44px; height: 44px; justify-content: center; padding: 0; background: transparent; box-shadow: none; }
  .plx-ws-lateral { display: none; }
  .plx-secao-abas { padding: 12px 22px 0; }
}
@media (max-width: 1023.98px) { .plx-topo__secao { display: none; } }
@media (min-width: 1200px) { .plx-ws-topo { display: none; } }

/* ---------- abaixo de 720: sem lateral; barra de baixo ---------- */
@media (max-width: 719.98px) {
  .plx-casca { grid-template-columns: minmax(0, 1fr); }
  .plx-lateral { display: none; }
  .plx-barra-baixo { display: flex; }
  .plx-coluna { padding-bottom: calc(var(--barra-baixo-h) + env(safe-area-inset-bottom, 0px)); }
  .plx-topo { padding: 0 12px; }
  .plx-topo__secao { display: none; }
  .plx-busca-topo { flex: 0 0 44px; width: 44px; height: 44px; justify-content: center; padding: 0; }
  .plx-busca-topo__texto, .plx-busca-topo .plx-kbd { display: none; }
  .plx-novo { display: none; }
  .plx-ws-topo { max-width: none; flex: 1; }
  .plx-casca .tenant-badge { min-height: 44px; }
  .plx-secao-abas { padding: 8px 16px 0; }
}
@media (min-width: 720px) and (max-width: 1023.98px) {
  .plx-busca-topo, .plx-novo { height: 44px; }
  .plx-nav__item { width: 44px; }
}
@media (max-width: 1023.98px) {
  .plx-casca .tenant-badge, .plx-user { min-height: 44px; }
}

/* ---------- L6 · Conversas em tela cheia ----------
   A caixa de conversas usa a janela inteira (lista · conversa · contato; o conteúdo da conversa nunca fica abaixo de 600 px a partir de 720),
   como no protótipo aprovado: a lateral, o topo e as abas da casca saem de cena. Quem liga é a própria tela (ilha inbox-app), com
   <html data-tela="conversas">; no celular, com a conversa aberta (<html data-conversa="aberta">) a barra de baixo também sai.
   O caminho para as outras áreas fica no menu da tela («Ir para outra área», que abre a folha «Mais»). */
html[data-tela="conversas"] .plx-casca { grid-template-columns: minmax(0, 1fr); }
html[data-tela="conversas"] .plx-lateral,
html[data-tela="conversas"] .plx-topo,
html[data-tela="conversas"] .plx-secao-abas { display: none; }
html[data-tela="conversas"] .plx-coluna { padding-bottom: 0; }
@media (max-width: 719.98px) {
  html[data-tela="conversas"][data-conversa="aberta"] .plx-barra-baixo { display: none; }
}
