/**
 * Shell unificado PESA — padrão visual do Centro de Alertas
 * (sidebar + topbar de página + conteúdo).
 * Carregar após assets/pesa-tokens.css.
 */
:root {
  --pesa-shell-side-width: 248px;
  --pesa-shell-radius: 12px;
  --pesa-shell-shadow: 0 1px 2px rgba(15, 23, 42, 0.04), 0 8px 24px rgba(2, 33, 61, 0.04);
}

body.pesa-shell-on {
  margin: 0;
  font-family: "Segoe UI", system-ui, -apple-system, "Helvetica Neue", sans-serif;
  background: var(--fundo, #f4f7fb);
  color: var(--texto, #102a43);
}

body.pesa-shell-on > .shell {
  display: grid;
  grid-template-columns: var(--pesa-shell-side-width) minmax(0, 1fr);
  min-height: 100vh;
  min-height: 100dvh;
  min-width: 0;
}

@media (max-width: 1023px) {
  body.pesa-shell-on > .shell {
    grid-template-columns: 1fr;
  }
  body.pesa-shell-on > .shell > .side-nav {
    display: none;
  }
}

/* ——— Side nav ——— */
.shell > .side-nav,
body.pesa-shell-on .side-nav {
  background: linear-gradient(180deg, #02213d 0%, #031a30 100%);
  color: #e2e8f0;
  padding: 1.15rem 0.85rem 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
  position: sticky;
  top: 0;
  height: 100vh;
  height: 100dvh;
  overflow-y: auto;
  z-index: 5;
}

.side-brand {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  padding: 0.35rem 0.55rem 1rem;
  text-decoration: none;
  color: #fff;
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
  margin-bottom: 0.85rem;
}

.side-brand img {
  width: 44px;
  height: 44px;
  border-radius: 999px;
  object-fit: cover;
  background: #fff;
  flex-shrink: 0;
}

.side-brand strong {
  display: block;
  font-size: 1rem;
  letter-spacing: 0.02em;
}

.side-brand span {
  font-size: 0.7rem;
  color: #94a3b8;
}

.side-spacer {
  flex: 1;
  min-height: 0.75rem;
}

.side-meta {
  font-size: 0.7rem;
  color: #94a3b8;
  padding: 0.85rem 0.55rem 0.2rem;
  border-top: 1px solid rgba(255, 255, 255, 0.08);
  margin-top: 0.5rem;
  line-height: 1.35;
}

.pesa-nav-group {
  margin: 0.55rem 0 0.2rem;
  padding: 0 0.55rem;
  font-size: 0.65rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: #64748b;
}

[data-pesa-nav="side"] {
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
}

[data-pesa-nav="side"] .pesa-nav-link {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  border-radius: 10px;
  padding: 0.58rem 0.75rem;
  border: none;
  background: transparent;
  color: #cbd5e1;
  font-size: 0.86rem;
  font-weight: 600;
  text-decoration: none;
  transition: background 0.15s ease, color 0.15s ease;
}

[data-pesa-nav="side"] .pesa-nav-link:hover {
  background: rgba(255, 255, 255, 0.08);
  color: #fff;
}

[data-pesa-nav="side"] .pesa-nav-link.ativo {
  background: rgba(13, 148, 136, 0.38);
  color: #fff;
  box-shadow: inset 3px 0 0 #0d9488;
}

[data-pesa-nav="side"] .pesa-nav-link.pesa-nav-alertas.ativo {
  background: rgba(198, 40, 40, 0.35);
  box-shadow: inset 3px 0 0 #ef4444;
}

/* ——— Main column ——— */
.shell > .main,
body.pesa-shell-on .main {
  display: flex;
  flex-direction: column;
  min-width: 0;
  min-height: 100vh;
  min-height: 100dvh;
  background: var(--fundo, #f4f7fb);
}

body.pesa-shell-on .topbar {
  background: rgba(255, 255, 255, 0.92);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--pesa-borda, #d1dce5);
  padding: 0.95rem 1.5rem;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
  position: sticky;
  top: 0;
  z-index: 8;
}

body.pesa-shell-on .greet h1,
body.pesa-shell-on .topbar .greet h1 {
  margin: 0;
  font-size: clamp(1.25rem, 2vw, 1.5rem);
  color: #0f172a;
  font-weight: 750;
  letter-spacing: -0.01em;
}

body.pesa-shell-on .greet .sub,
body.pesa-shell-on .topbar .greet .sub {
  margin-top: 0.28rem;
  font-size: 0.88rem;
  color: var(--muted, #7b8794);
  max-width: 52rem;
  line-height: 1.4;
}

body.pesa-shell-on .top-actions {
  display: flex;
  gap: 0.45rem;
  flex-wrap: wrap;
  align-items: center;
}

/* Legacy chrome hidden after upgrade */
body.pesa-shell-on .topbar-left,
body.pesa-shell-on .pesa-shell-hide-legacy {
  display: none !important;
}

body.pesa-shell-on .btn {
  border-radius: 999px;
  padding: 0.48rem 0.95rem;
  font-size: 0.8rem;
  font-weight: 700;
  border: 1px solid var(--pesa-borda, #d1dce5);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  text-decoration: none;
  background: #fff;
  color: var(--texto, #102a43);
  min-height: 40px;
}

body.pesa-shell-on .btn:hover {
  border-color: var(--pesa-azul-claro, #1f6fb2);
}

body.pesa-shell-on .btn-primary {
  background: var(--pesa-accent, #0d9488);
  border-color: var(--pesa-accent, #0d9488);
  color: #fff;
}

body.pesa-shell-on .btn-primary:hover {
  filter: brightness(1.05);
}

body.pesa-shell-on .btn-alert {
  background: var(--critica, #b91c1c);
  border-color: var(--critica, #b91c1c);
  color: #fff;
}

body.pesa-shell-on .btn-outline {
  background: #fff;
  border-color: var(--pesa-borda, #d1dce5);
}

body.pesa-shell-on .content {
  padding: 1.25rem clamp(1rem, 2vw, 1.75rem) 2rem;
  flex: 1;
  width: 100%;
  min-width: 0;
}

/* Cards suaves no conteúdo (páginas genéricas) */
body.pesa-shell-on .content .card,
body.pesa-shell-on .content .analise-card,
body.pesa-shell-on .content .analytics-card {
  box-shadow: var(--pesa-shell-shadow);
}

body.pesa-shell-on .pesa-footer {
  margin-top: auto;
  background: var(--pesa-azul-escuro, #02213d);
  color: #e2e8f0;
  border-top: 1px solid rgba(255, 255, 255, 0.08);
  padding: 1rem 1.5rem;
  font-size: 0.8rem;
}

body.pesa-shell-on .pesa-footer a {
  color: #7dd3fc;
}

body.pesa-shell-on .pesa-footer strong {
  color: #fff;
}

/* Admin compacto: shell com side, conteúdo mais estreito */
body.pesa-shell-on[data-pesa-shell-mode="admin"] .content {
  max-width: 1100px;
}

/* Drawer fora do fluxo (evita menu fantasma no rodapé em desktop) */
.pesa-nav-drawer {
  display: none;
}

.pesa-nav-drawer[hidden] {
  display: none !important;
}

body.pesa-shell-on .pesa-bottom-nav {
  display: none !important;
}

body.pesa-shell-on .pesa-nav-drawer {
  display: none;
}

@media (max-width: 1023px) {
  body.pesa-shell-on .pesa-nav-drawer:not([hidden]) {
    display: flex;
  }
}
