/* ═══════════════════════════════════════════════════════════════════════
   SHELL — lateral + barra superior COMUNS a todas as páginas logadas.
   O body vira grid: coluna 1 = lateral (sticky), coluna 2 = barra + conteúdo
   da página como ele já é (nada é movido). Montado por /js/shell.js.
   Tokens vêm do app.css/type.css; funciona no claro e no escuro.
   ═══════════════════════════════════════════════════════════════════════ */
:root {
  --mf-sb-w: 248px;
  --mf-top-h: var(--topbar-h, 60px);
  --mf-card-shadow: 0 1px 0 rgba(60,44,20,.04), 0 10px 30px -18px rgba(60,44,20,.35);
  --mf-ring: 0 0 0 3px rgba(108,71,30,.16);
}
[data-theme="dark"] { --mf-card-shadow: 0 1px 0 rgba(0,0,0,.25), 0 14px 34px -20px rgba(0,0,0,.7); --mf-ring: 0 0 0 3px rgba(207,168,114,.22); }

body.mf-shell-on {
  display: grid !important;
  grid-template-columns: var(--mf-sb-w) minmax(0, 1fr);
  grid-auto-rows: max-content;
  align-content: start;
  min-height: 100dvh;
}
body.mf-shell-on > * { grid-column: 2; min-width: 0; }
body.mf-shell-on > .mf-sidebar { grid-column: 1; grid-row: 1 / span 9999; }
body.mf-shell-on > .mf-legacy-hidden, body.mf-shell-on > header.topbar { display: none !important; }
body.mf-shell-on .mf-legacy-hidden { display: none !important; }
/* páginas antigas presas a 1100px: com a lateral, usam a tela toda */
body.mf-shell-on .page-content { max-width: none; }
/* rodapé antigo empurrado pro fim */
body.mf-shell-on > footer.footer { align-self: end; }

/* ── Lateral ─────────────────────────────────────────────────────── */
.mf-sidebar {
  position: sticky; top: 0; height: 100dvh; overflow-y: auto; overscroll-behavior: contain;
  background: var(--surface); border-right: 1px solid var(--border);
  display: flex; flex-direction: column; padding: 14px 12px; gap: 6px; z-index: 40;
  font-family: var(--font-ui);
}
.mf-brand { display: flex; align-items: center; gap: 12px; padding: 8px 8px 16px; border-bottom: 1px solid var(--border); margin-bottom: 8px; color: inherit; text-decoration: none; }
.mf-brand__logo { width: 46px; height: 46px; border-radius: var(--r-ctl, 10px); flex: none; background: #ede5d7 url('/img/brand/samara-logo.svg') center / 112% auto no-repeat; box-shadow: inset 0 0 0 1px rgba(108,71,30,.18); }
.mf-brand__name { font-family: var(--font-ui); font-weight: 800; letter-spacing: -.02em; font-size: 17px; line-height: 1.1; color: var(--text); }
.mf-brand__sys { font-size: 11px; color: var(--text-muted); margin-top: 3px; letter-spacing: .04em; }
.mf-nav { display: flex; flex-direction: column; gap: 2px; }
/* white-space:nowrap: com "Central de …" o rótulo ficou mais longo e, sem isso,
   quebraria em duas linhas na lateral de 248px em vez de ficar numa linha só. */
.mf-nav__item { display: flex; align-items: center; gap: 12px; padding: 10px 12px; border-radius: var(--r-ctl, 10px); color: var(--text-muted); font-weight: 600; font-size: 13.5px; text-decoration: none; transition: background .15s, color .15s; position: relative; background: none; border: 0; width: 100%; text-align: left; cursor: pointer; font-family: inherit; white-space: nowrap; }
.mf-nav__item:hover { background: var(--surface2); color: var(--text); }
.mf-nav__item.is-active { background: var(--gold); color: var(--surface); box-shadow: 0 8px 18px -10px rgba(108,71,30,.7); }
[data-theme="dark"] .mf-nav__item.is-active { color: #1b130b; }
.mf-nav__item svg { width: 19px; height: 19px; flex: none; }
.mf-nav__item .ti { font-size: 19px; flex: none; width: 19px; text-align: center; }
.mf-nav__item .mf-chev { margin-left: auto; opacity: .55; font-size: 15px; width: 15px; transition: transform .2s; }
/* No grupo Configurações a seta é o botão de abrir/fechar as 3 opções (o resto do item abre a página) */
.mf-nav__toggle .mf-chev { padding: 4px; margin-right: -4px; border-radius: 6px; cursor: pointer; }
.mf-nav__toggle .mf-chev:hover { opacity: 1; background: var(--surface2); }
.mf-nav__badge { margin-left: auto; min-width: 20px; height: 20px; padding: 0 6px; border-radius: 10px; background: var(--red); color: var(--surface); font-size: 11px; font-weight: 800; display: none; align-items: center; justify-content: center; }
.mf-nav__badge.on { display: inline-flex; }
.mf-nav__group.open .mf-nav__toggle .mf-chev { transform: rotate(90deg); }
.mf-nav__toggle.is-open { color: var(--text); }
.mf-nav__sub { display: none; flex-direction: column; gap: 2px; padding: 2px 0 4px 14px; }
.mf-nav__group.open .mf-nav__sub { display: flex; }
.mf-nav__sub-item { padding: 8px 12px; font-size: 13px; }
.mf-nav__sub-item .ti { font-size: 16px; width: 16px; }
.mf-sidebar__spacer { flex: 1; }
.mf-me { display: flex; align-items: center; gap: 10px; padding: 10px 8px; border-top: 1px solid var(--border); margin-top: 8px; }
.mf-avatar { width: 38px; height: 38px; border-radius: 50%; background: var(--gold); color: var(--surface); display: grid; place-items: center; font-weight: 800; font-size: 15px; flex: none; font-family: var(--font-ui); }
[data-theme="dark"] .mf-avatar { color: #1b130b; }
.mf-me__name { font-weight: 700; font-size: 13px; }
.mf-me__mail { font-size: 11px; color: var(--text-muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 150px; }
.mf-logout { color: var(--text-muted); }
.mf-logout:hover { background: var(--red-bg); color: var(--red); }

/* ── Barra superior ──────────────────────────────────────────────── */
.mf-top { position: sticky; top: 0; z-index: 30; display: flex; align-items: center; gap: 12px; height: var(--mf-top-h); padding: 0 22px; background: color-mix(in srgb, var(--surface) 82%, transparent); backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px); border-bottom: 1px solid var(--border); font-family: var(--font-ui); }
.mf-icon-btn { width: 40px; height: 40px; border-radius: var(--r-ctl, 10px); border: 1px solid var(--border); background: var(--surface); color: var(--text); display: grid; place-items: center; cursor: pointer; position: relative; transition: background .15s, transform .15s; flex: none; }
.mf-icon-btn:hover { background: var(--surface2); }
.mf-icon-btn:active { transform: scale(.96); }
.mf-icon-btn svg { width: 19px; height: 19px; }
.mf-icon-btn .ti { font-size: 19px; }
.mf-icon-btn .mf-dot { position: absolute; top: -4px; right: -4px; min-width: 18px; height: 18px; padding: 0 5px; border-radius: 9px; background: var(--red); color: var(--surface); font-size: 10.5px; font-weight: 800; display: none; align-items: center; justify-content: center; border: 2px solid var(--surface); }
.mf-icon-btn .mf-dot.on { display: inline-flex; }
.mf-search { flex: 1; max-width: 520px; display: flex; align-items: center; gap: 10px; height: 42px; padding: 0 12px 0 14px; border-radius: var(--r-ctl, 10px); background: var(--surface2); border: 1px solid transparent; color: var(--text-muted); position: relative; min-width: 0; }
.mf-search:focus-within { border-color: var(--gold-border); box-shadow: var(--mf-ring); background: var(--surface); }
.mf-search .ti { font-size: 18px; }
.mf-search input { flex: 1; min-width: 0; border: 0; background: none; outline: 0; color: var(--text); font: inherit; font-size: 13.5px; }
.mf-search kbd { font: 600 10.5px var(--font-ui); color: var(--text-muted); border: 1px solid var(--border); border-radius: 6px; padding: 2px 6px; background: var(--surface); }
.mf-search__pop { position: absolute; left: 0; right: 0; top: calc(100% + 8px); background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-card, 16px); box-shadow: var(--mf-card-shadow); padding: 6px; display: none; max-height: 340px; overflow: auto; z-index: 60; }
.mf-search__pop.on { display: block; }
.mf-search__item { display: flex; align-items: center; gap: 10px; padding: 9px 10px; border-radius: var(--r-ctl, 10px); cursor: pointer; color: var(--text); font-size: 13px; }
.mf-search__item:hover, .mf-search__item.is-hi { background: var(--surface2); }
.mf-search__item small { color: var(--text-muted); margin-left: auto; font-size: 11px; }
.mf-top__actions { display: flex; align-items: center; gap: 8px; min-width: 0; flex-wrap: nowrap; }
.mf-top__actions > * { flex: none; }
.mf-top__spacer { flex: 1; }
.mf-top__who { text-align: right; line-height: 1.2; }
.mf-top__who b { font-size: 13.5px; display: block; }
.mf-top__who span { font-size: 11.5px; color: var(--text-muted); }
.mf-top__sep { width: 1px; height: 28px; background: var(--border); }
.mf-scrim { position: fixed; inset: 0; background: rgba(27,19,11,.45); z-index: 35; display: none; }
.mf-scrim.on { display: block; }

/* ── Responsivo ──────────────────────────────────────────────────── */
@media (max-width: 1024px) {
  body.mf-shell-on { grid-template-columns: minmax(0, 1fr); }
  body.mf-shell-on > * { grid-column: 1; }
  body.mf-shell-on > .mf-sidebar { position: fixed; left: 0; top: 0; width: min(300px, 86vw); transform: translateX(-104%); transition: transform .25s cubic-bezier(.2,.7,.2,1); z-index: 50; box-shadow: 0 20px 60px rgba(0,0,0,.35); grid-row: auto; }
  body.mf-shell-on > .mf-sidebar.open { transform: none; }
  .mf-top__who, .mf-top__sep { display: none; }
}
@media (max-width: 640px) {
  .mf-top { padding: 0 12px; gap: 8px; }
  .mf-search kbd { display: none; }
  .mf-top__actions .btn, .mf-top__actions button { font-size: 12px; padding: 6px 10px; }
}
@media (max-width: 480px) { .mf-top__actions > span { display: none; } }
/* ── Lateral em GAVETA (qualquer largura) ────────────────────────────
   Pedido do dono (08/09/2026): na Central de Enquetes a lateral fixa some e
   a pagina inteira fica pros cards das enquetes. Quem precisa do menu abre
   no botao ☰ da barra de cima — o mesmo comportamento que o celular ja tem. */
body.mf-shell-on.mf-side-drawer { grid-template-columns: minmax(0, 1fr); }
body.mf-shell-on.mf-side-drawer > * { grid-column: 1; }
body.mf-shell-on.mf-side-drawer > .mf-sidebar {
  position: fixed; left: 0; top: 0; width: min(300px, 86vw);
  transform: translateX(-104%); transition: transform .25s cubic-bezier(.2,.7,.2,1);
  z-index: 120; box-shadow: 0 20px 60px rgba(0,0,0,.35); grid-row: auto;
}
body.mf-shell-on.mf-side-drawer > .mf-sidebar.open { transform: none; }
/* O escurecido tambem sobe: as abas da Central de Enquetes ficam em 90 e o
   calendario em 80 — com o scrim em 35 o menu abria POR BAIXO deles. */
body.mf-shell-on.mf-side-drawer > .mf-scrim { z-index: 110; }

/* Com a lateral ja fixa na tela, o ☰ nao abre nada — some (pedido do dono,
   08/09/2026). Ele continua onde faz falta: na gaveta da Central de Enquetes
   e no celular, onde a lateral fica escondida. */
@media (min-width: 1025px) {
  body.mf-shell-on:not(.mf-side-drawer) #btnMenu { display: none; }
}

@media print { .mf-sidebar, .mf-top, .mf-scrim { display: none !important; } body.mf-shell-on { display: block !important; } }
