/* ---------- Estilos da tela logada: layout "Dashboard" ----------
   Tudo aqui vale só com body.dash-active (aplicado por app.js quando o
   layout efetivo da conta é "dashboard"). Nenhum nó do feed/conta muda de
   lugar: a sidebar é fixa e o conteúdo recebe padding à esquerda. O visual
   clássico (styles.css) segue intocado; a última seção (seletor em Minha
   conta) é comum aos dois layouts. */

:root {
  --dash-sidebar-w: 248px;
  --dash-nav-h: 64px;
  --dash-bg: #F6F7F9;
  --dash-card: var(--white);
  --dash-radius: 16px;
}

html[data-theme="dark"] {
  --dash-bg: #101216;
  --dash-card: #1A1E24;
}

/* ----- Casca ----- */

body.dash-active {
  background: var(--dash-bg);
}

/* Sidebar fixa sob a topnav (que segue sticky) */
body.dash-active .dash-sidebar {
  position: fixed;
  top: var(--dash-nav-h);
  left: 0;
  bottom: 0;
  width: var(--dash-sidebar-w);
  overflow-y: auto;
  padding: 20px 14px 24px;
  background: var(--dash-card);
  border-right: 1px solid var(--border);
  z-index: 15;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

/* Conteúdo logado deslocado. #inbox é a seção que contém tudo. */
body.dash-active #inbox {
  padding-left: var(--dash-sidebar-w);
}

/* A largura do .container é medida do espaço restante */
body.dash-active #inbox > .container,
body.dash-active #inbox .dark-section > .container {
  width: min(1120px, 100%);
}

/* Topbar: itens duplicados pela sidebar somem (o logotipo fica) */
body.dash-active #messagesBtn,
body.dash-active #accountBtn,
body.dash-active #adminBtn {
  display: none !important;
}

/* Cabeçalho do feed mais discreto: a Visão geral tem o título da página */
body.dash-active .feed-bar {
  padding-top: 28px;
  padding-bottom: 16px;
}

body.dash-active.dash-view-overview .feed-bar .page-title {
  display: none;
}

body.dash-active.dash-view-overview .feed-bar .session-meta {
  margin-top: 0;
}

/* ----- Feed sob o Dashboard -----
   A sidebar já escolhe superfície (Recuperadas / Leitura privada) e filtro
   por tipo, então os cards de superfície e os chips somem; fica a busca. O
   feed ocupa a mesma largura da Visão geral e a barra do WhatsApp vira um
   card (mesma paleta escura, que os controles de pareamento já usam). */

body.dash-active .feed-bar .page-title {
  font-size: 26px;
}

body.dash-active #feedSurfaces,
body.dash-active #feedFilters {
  display: none !important;
}

body.dash-active .feed {
  padding-top: 8px;
}

body.dash-active .feed-filters {
  justify-content: flex-end;
  margin-bottom: 16px;
}

body.dash-active .feed-search {
  flex: 0 1 380px;
}

body.dash-active .feed-search input {
  border-radius: 999px;
  background: var(--dash-card);
}

body.dash-active .list,
body.dash-active .feed-live,
body.dash-active .feed-pager,
body.dash-active .empty,
body.dash-active .enc-banner,
body.dash-active .silent-intro {
  max-width: none;
}

body.dash-active .msg {
  border-radius: var(--dash-radius);
}

/* Barra do WhatsApp: de faixa de borda a borda para card alinhado ao conteúdo */
body.dash-active .dark-section.waha-compact {
  width: calc(100% - 64px);
  max-width: 1120px;
  margin: 0 auto 8px;
  padding: 12px 22px;
  border-radius: var(--dash-radius);
}

body.dash-active #inbox .dark-section.waha-compact > .container {
  width: 100%;
  padding-inline: 0;
}

@media (max-width: 896px) {
  body.dash-active .dark-section.waha-compact {
    width: calc(100% - 32px);
  }
}

/* ----- Sidebar: itens ----- */

/* O logotipo já está na topnav (que segue visível em todas as larguras) */
body.dash-active .dash-brand {
  display: none;
}

body.dash-active .dash-nav {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

body.dash-active .dash-sub {
  list-style: none;
  margin: 2px 0 4px;
  padding: 0 0 0 32px;
  display: flex;
  flex-direction: column;
  gap: 1px;
}

body.dash-active .dash-group {
  margin: 14px 0 4px;
  padding: 0 12px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
}

body.dash-active .dash-item {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 12px;
  border: 0;
  border-radius: 10px;
  background: none;
  color: var(--text-2);
  font: inherit;
  font-size: 14px;
  font-weight: 600;
  text-align: left;
  cursor: pointer;
  transition: background 0.15s ease, color 0.15s ease;
}

body.dash-active .dash-item:hover {
  background: color-mix(in srgb, var(--ink) 5%, transparent);
  color: var(--ink);
}

body.dash-active .dash-item.is-active {
  background: color-mix(in srgb, var(--yellow) 18%, var(--dash-card));
  color: var(--ink);
}

body.dash-active .dash-item.is-parent-active {
  color: var(--ink);
}

body.dash-active .dash-item.is-sub {
  padding: 6px 10px;
  font-size: 13px;
  font-weight: 500;
  color: var(--slate);
}

body.dash-active .dash-item.is-sub.is-active {
  color: var(--ink);
  font-weight: 600;
}

body.dash-active .dash-ico {
  width: 18px;
  height: 18px;
  flex: 0 0 auto;
  color: var(--slate);
}

body.dash-active .dash-item.is-active .dash-ico {
  color: var(--yellow-active);
}

body.dash-active .dash-item > span:first-of-type {
  flex: 1 1 auto;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

body.dash-active .dash-count {
  flex: 0 0 auto;
  min-width: 22px;
  padding: 1px 7px;
  border-radius: 999px;
  background: color-mix(in srgb, var(--ink) 7%, transparent);
  color: var(--text-2);
  font-size: 11px;
  font-weight: 700;
  text-align: center;
  font-feature-settings: "tnum";
}

body.dash-active .dash-item.is-active .dash-count {
  background: var(--yellow);
  color: var(--on-yellow);
}

body.dash-active .dash-chevron {
  color: var(--muted);
  font-size: 18px;
  line-height: 1;
}

/* Botão do drawer: só em telas estreitas */
body.dash-active .dash-menu-btn {
  display: none;
}

/* ----- Visão geral ----- */

body.dash-active .dash-overview {
  padding-top: 28px;
  padding-bottom: 48px;
  display: flex;
  flex-direction: column;
  gap: 18px;
}

body.dash-active .dash-head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
}

body.dash-active .dash-head .page-title {
  font-size: 26px;
}

body.dash-active .dash-search {
  display: flex;
  align-items: center;
  gap: 8px;
  width: min(380px, 100%);
  padding: 0 14px;
  height: 42px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--dash-card);
  color: var(--muted);
}

body.dash-active .dash-search:focus-within {
  border-color: var(--yellow);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--yellow) 25%, transparent);
}

body.dash-active .dash-search svg {
  width: 16px;
  height: 16px;
  flex: 0 0 auto;
}

body.dash-active .dash-search input {
  flex: 1 1 auto;
  min-width: 0;
  border: 0;
  background: none;
  color: var(--ink);
  font: inherit;
  font-size: 14px;
  outline: none;
}

body.dash-active .dash-search input::-webkit-search-decoration {
  -webkit-appearance: none;
}

body.dash-active .dash-card {
  background: var(--dash-card);
  border: 1px solid var(--border);
  border-radius: var(--dash-radius);
  box-shadow: var(--shadow-card);
}

/* Proteção */
body.dash-active .dash-protection {
  display: grid;
  grid-template-columns: auto 1fr auto auto;
  align-items: center;
  gap: 16px;
  padding: 18px 22px;
}

body.dash-active .dash-dot {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: var(--slate);
  box-shadow: 0 0 0 4px color-mix(in srgb, var(--slate) 18%, transparent);
}

body.dash-active .dash-dot.is-ok {
  background: var(--green);
  box-shadow: 0 0 0 4px color-mix(in srgb, var(--green) 22%, transparent);
}

body.dash-active .dash-dot.is-off {
  background: var(--red);
  box-shadow: 0 0 0 4px color-mix(in srgb, var(--red) 22%, transparent);
}

body.dash-active .dash-protection-copy {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

body.dash-active .dash-protection-copy strong {
  font-size: 16px;
  font-weight: 700;
  color: var(--ink);
}

body.dash-active .dash-protection-copy span,
body.dash-active .dash-protection-side {
  font-size: 13px;
  color: var(--slate);
}

body.dash-active .dash-protection-side {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  text-align: right;
}

body.dash-active .dash-protection-side span:first-child {
  color: var(--text-2);
  font-weight: 600;
}

body.dash-active .dash-protection-side span:first-child:empty + span {
  display: none;
}

/* Novidades */
body.dash-active .dash-news {
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 18px;
  padding: 20px 22px;
  background: linear-gradient(135deg,
    color-mix(in srgb, var(--yellow) 22%, var(--dash-card)),
    var(--dash-card) 70%);
}

body.dash-active .dash-news-icon {
  display: grid;
  place-items: center;
  width: 42px;
  height: 42px;
  border-radius: 12px;
  background: var(--yellow);
  color: var(--on-yellow);
  font-size: 20px;
}

body.dash-active .dash-news-copy {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

body.dash-active .dash-now {
  margin: 0;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
}

body.dash-active .dash-news-copy strong {
  font-size: 20px;
  font-weight: 700;
  color: var(--ink);
}

body.dash-active .dash-news-copy > span {
  font-size: 13px;
  color: var(--slate);
}

body.dash-active .dash-news-preview {
  margin: 6px 0 0;
  font-size: 13px;
  color: var(--text-2);
}

body.dash-active .dash-news-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

/* Contadores */
body.dash-active .dash-stats {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 14px;
}

body.dash-active .dash-stat {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 8px;
  padding: 18px 20px;
  font: inherit;
  color: inherit;
  text-align: left;
  cursor: pointer;
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}

body.dash-active .dash-stat:hover {
  transform: translateY(-1px);
  box-shadow: var(--shadow-card-hover);
}

body.dash-active .dash-stat-head {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  font-weight: 600;
  color: var(--slate);
}

body.dash-active .dash-stat-head .i3d {
  width: 22px;
  height: 22px;
}

body.dash-active .dash-stat-num {
  font-size: 30px;
  font-weight: 700;
  line-height: 1;
  color: var(--ink);
  font-feature-settings: "tnum";
}

body.dash-active .dash-stat-sub {
  min-height: 1.2em;
  font-size: 12px;
  color: var(--muted);
}

/* Expiração (exemplo rotulado) */
body.dash-active .dash-expiring {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  padding: 12px 18px;
  border-radius: 12px;
  background: color-mix(in srgb, var(--red) 8%, var(--dash-card));
  border: 1px solid color-mix(in srgb, var(--red) 25%, transparent);
  font-size: 14px;
  color: var(--text-2);
}

body.dash-active .dash-expiring p {
  margin: 0;
  flex: 1 1 auto;
}

body.dash-active .dash-demo-tag {
  padding: 1px 8px;
  border-radius: 999px;
  border: 1px dashed var(--muted);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--muted);
}

/* Eventos recentes */
body.dash-active .dash-section-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}

body.dash-active .dash-section-head h2 {
  margin: 0;
  font-size: 18px;
  font-weight: 700;
  color: var(--ink);
}

body.dash-active .dash-recent {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

/* Cartão do feed em modo compacto: sem animação de entrada, bolhas menores */
body.dash-active .msg.is-compact {
  animation: none;
  padding: 12px 16px;
}

body.dash-active .msg.is-compact .fm-chat {
  margin-top: 6px;
}

body.dash-active .msg.is-compact .fm-bubble {
  max-width: min(640px, 100%);
}

body.dash-active .msg.is-compact .msg-time,
body.dash-active .msg.is-compact .msg-footer {
  display: none;
}

/* Contatos protegidos (em breve) */
body.dash-active .dash-contacts {
  padding: 18px 22px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

body.dash-active .dash-contacts-count {
  margin: 4px 0;
  font-size: 14px;
  color: var(--slate);
}

body.dash-active .dash-contacts-count strong {
  font-size: 22px;
  color: var(--ink);
  margin-right: 6px;
}

/* ----- Telas estreitas: sidebar vira drawer ----- */

@media (max-width: 900px) {
  body.dash-active #inbox {
    padding-left: 0;
  }

  body.dash-active .dash-menu-btn {
    display: inline-grid;
  }

  body.dash-active .dash-sidebar {
    transform: translateX(-100%);
    transition: transform 0.2s ease;
    box-shadow: none;
    width: min(300px, 86vw);
  }

  body.dash-active.dash-drawer-open .dash-sidebar {
    transform: none;
    box-shadow: 0 12px 40px rgba(0, 0, 0, 0.25);
  }

  /* Véu atrás do drawer */
  body.dash-active.dash-drawer-open::before {
    content: "";
    position: fixed;
    inset: var(--dash-nav-h) 0 0 0;
    background: rgba(12, 14, 18, 0.45);
    z-index: 14;
  }

  body.dash-active .dash-stats {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  body.dash-active .dash-protection {
    grid-template-columns: auto 1fr;
  }

  body.dash-active .dash-protection-side {
    grid-column: 2;
    align-items: flex-start;
    text-align: left;
  }

  body.dash-active .dash-protection > .btn {
    grid-column: 1 / -1;
    justify-self: start;
  }

  body.dash-active .dash-news {
    grid-template-columns: auto 1fr;
  }

  body.dash-active .dash-news-actions {
    grid-column: 1 / -1;
    justify-content: flex-start;
  }
}

@media (max-width: 560px) {
  body.dash-active .dash-stats {
    grid-template-columns: 1fr;
  }
}

/* ---------- Minha conta: seletor de aparência (comum aos dois layouts) ---------- */

.layout-zone {
  margin-top: 24px;
  padding-top: 20px;
  border-top: 1px solid var(--border);
}

.layout-picker {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
  margin-top: 12px;
}

.layout-option {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 14px;
  border: 1px solid var(--border);
  border-radius: 14px;
  background: var(--white);
  cursor: pointer;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.layout-option:hover {
  border-color: color-mix(in srgb, var(--yellow) 60%, var(--border));
}

.layout-option input {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  margin: 0;
  opacity: 0;
  cursor: pointer;
}

.layout-option:has(input:checked) {
  border-color: var(--yellow);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--yellow) 25%, transparent);
}

.layout-option:has(input:focus-visible) {
  outline: 2px solid var(--focus-blue);
  outline-offset: 2px;
}

.layout-option:has(input:disabled) {
  opacity: 0.6;
  cursor: progress;
}

/* Miniatura esquemática do layout */
.layout-thumb {
  display: grid;
  gap: 4px;
  height: 64px;
  padding: 6px;
  border-radius: 8px;
  background: var(--snow);
  border: 1px solid var(--border);
}

.layout-thumb i {
  display: block;
  border-radius: 3px;
  background: color-mix(in srgb, var(--ink) 12%, transparent);
}

.layout-thumb.is-classic {
  grid-template-rows: 10px 1fr 1fr;
}

.layout-thumb.is-classic i:first-child {
  background: var(--yellow);
}

.layout-thumb.is-dashboard {
  grid-template-columns: 22px 1fr;
  grid-template-rows: 1fr 1fr;
}

.layout-thumb.is-dashboard i:first-child {
  grid-row: 1 / -1;
  background: color-mix(in srgb, var(--ink) 22%, transparent);
}

.layout-thumb.is-dashboard i:nth-child(2) {
  background: var(--yellow);
}

.layout-option-copy {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.layout-option-copy strong {
  font-size: 14px;
  color: var(--ink);
}

.layout-option-copy em {
  font-style: normal;
  font-size: 12px;
  color: var(--slate);
}

@media (max-width: 560px) {
  .layout-picker {
    grid-template-columns: 1fr;
  }
}

/* Painel master: campo de política ocupa a linha inteira (4º campo da grade
   1fr 2fr 1fr cairia na coluna estreita) e badge na lista de contas */
.inst-grid .acct-layout-field {
  grid-column: 1 / -1;
}

.acct-layout-field select {
  max-width: 420px;
}

.inst-badge.layout {
  background: color-mix(in srgb, var(--yellow) 18%, var(--white));
  color: var(--yellow-active);
}
