/* ============================================================= SHELL ==== */
.shell {
  display: grid;
  grid-template-columns: var(--sidebar-w) minmax(0, 1fr);
  min-height: 100vh;
}

/* ---------------------------------------------------------- SIDEBAR ---- */
.sidebar {
  position: sticky;
  top: 0;
  align-self: start;
  height: 100vh;
  display: flex;
  flex-direction: column;
  gap: var(--s-2);
  background: var(--surface);
  border-right: 1px solid var(--line);
  padding: var(--s-5) var(--s-3) var(--s-4);
}

.brand {
  display: flex;
  align-items: center;
  gap: var(--s-2);
  padding: 0 var(--s-2) var(--s-2);
  border: 0;
  background: none;
}
.wordmark {
  font-size: var(--fs-h3);
  font-weight: 800;
  letter-spacing: -0.045em;
}
.wordmark .ia { color: var(--brand-500); }
.wordmark .shop { color: var(--ink-900); }

.nav { display: grid; gap: 2px; }
.nav-label {
  padding: var(--s-4) var(--s-2) var(--s-1);
  font-size: 10px;
  font-weight: 800;
  letter-spacing: var(--track-eyebrow);
  text-transform: uppercase;
  color: var(--ink-400);
}
.nav button {
  display: flex;
  align-items: center;
  gap: var(--s-3);
  width: 100%;
  border: 0;
  border-radius: var(--r-md);
  background: none;
  padding: 10px var(--s-3);
  color: var(--ink-700);
  font-size: var(--fs-sm);
  font-weight: 600;
  text-align: left;
  transition: background 0.13s var(--ease), color 0.13s var(--ease);
}
.nav button .icon { flex: none; color: var(--ink-400); transition: color 0.13s var(--ease); }
.nav button:hover { background: var(--surface-2); color: var(--ink-900); }
.nav button:hover .icon { color: var(--ink-700); }
.nav button[aria-current="page"] {
  background: var(--brand-50);
  color: var(--brand-700);
  font-weight: 800;
}
.nav button[aria-current="page"] .icon { color: var(--brand-500); }

.nav-admin { margin-top: auto; border-top: 1px solid var(--line); padding-top: var(--s-3); }

/* --------------------------------------------------- ÁREA DO USUÁRIO --- */
.user-menu-wrap { position: relative; margin-top: var(--s-3); }

.user-chip {
  display: flex;
  align-items: center;
  gap: var(--s-3);
  width: 100%;
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  background: var(--surface);
  padding: var(--s-2);
  text-align: left;
}
.user-chip:hover { border-color: var(--brand-200); background: var(--brand-50); }
.user-chip .who { min-width: 0; flex: 1; }
.user-chip strong {
  display: block;
  font-size: var(--fs-xs);
  font-weight: 700;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.user-chip span { display: block; font-size: 10px; color: var(--ink-500); }

.user-menu {
  position: absolute;
  bottom: calc(100% + var(--s-2));
  left: 0;
  right: 0;
  z-index: 40;
  display: grid;
  gap: 2px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  box-shadow: var(--sh-3);
  padding: var(--s-2);
  animation: riseIn 0.14s var(--ease);
}
.user-menu button {
  display: flex;
  align-items: center;
  gap: var(--s-2);
  width: 100%;
  border: 0;
  border-radius: var(--r-sm);
  background: none;
  padding: 9px var(--s-2);
  color: var(--ink-700);
  font-size: var(--fs-xs);
  font-weight: 600;
  text-align: left;
}
.user-menu button:hover { background: var(--surface-2); color: var(--ink-900); }
.user-menu button .icon { color: var(--ink-400); }
.user-menu hr { border: 0; border-top: 1px solid var(--line); margin: var(--s-1) 0; }

/* ----------------------------------------------------------- TOPBAR ---- */
.topbar {
  position: sticky;
  top: 0;
  z-index: 30;
  display: none;
  align-items: center;
  gap: var(--s-3);
  height: var(--topbar-h);
  background: rgba(255, 255, 255, 0.94);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--line);
  padding: 0 var(--s-4);
}

/* --------------------------------------------------------- CONTEÚDO ---- */
.main { min-width: 0; }
.page {
  max-width: var(--content-max);
  margin: 0 auto;
  padding: var(--s-8) var(--s-6) var(--s-12);
}

.page-head { margin-bottom: var(--s-6); }
.page-head h1 { font-size: var(--fs-h1); letter-spacing: var(--track-display); }
.page-head p { margin-top: 6px; color: var(--ink-500); font-size: var(--fs-sm); max-width: 62ch; }
.page-head .spread { align-items: flex-end; }

/* -------------------------------------------------- NAVEGAÇÃO MOBILE --- */
.bottom-nav { display: none; }

.nav-scrim { display: none; }

@media (max-width: 960px) {
  .shell { grid-template-columns: minmax(0, 1fr); }

  .topbar { display: flex; }

  .sidebar {
    position: fixed;
    top: 0;
    left: 0;
    z-index: 70;
    width: 282px;
    max-width: 86vw;
    transform: translateX(-101%);
    transition: transform 0.22s var(--ease);
    box-shadow: var(--sh-3);
  }
  .shell.nav-open .sidebar { transform: none; }
  .shell.nav-open .nav-scrim {
    display: block;
    position: fixed;
    inset: 0;
    z-index: 65;
    background: rgba(30, 18, 14, 0.4);
  }

  .page { padding: var(--s-5) var(--s-4) calc(var(--bottomnav-h) + var(--s-10)); }

  .bottom-nav {
    position: fixed;
    left: 0; right: 0; bottom: 0;
    z-index: 50;
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    height: var(--bottomnav-h);
    background: rgba(255, 255, 255, 0.97);
    backdrop-filter: blur(8px);
    border-top: 1px solid var(--line);
    padding-bottom: env(safe-area-inset-bottom);
  }
  .bottom-nav button {
    display: grid;
    justify-items: center;
    align-content: center;
    gap: 3px;
    border: 0;
    background: none;
    color: var(--ink-500);
    font-size: 10px;
    font-weight: 700;
  }
  .bottom-nav button .icon { color: var(--ink-400); }
  .bottom-nav button[aria-current="page"] { color: var(--brand-700); }
  .bottom-nav button[aria-current="page"] .icon { color: var(--brand-500); }
}

@media (max-width: 560px) {
  .page-head .spread { flex-direction: column; align-items: stretch; }
  .page-head .spread .btn { width: 100%; }
  .modal { border-radius: var(--r-lg); max-height: calc(100vh - var(--s-6)); }
  .overlay { padding: var(--s-3); }
  .drawer { width: 100%; }
  .modal-foot { flex-direction: column-reverse; }
  .modal-foot .btn { width: 100%; }
}
