/* Layout comum das telas logadas (KAN-68). Cores, tipografia e raios vem do tokens.css (KAN-72). */
:root {
  --shell-navbar-height: 56px;
  --shell-sidebar-width: 240px;
}

/* A tela de conta da v2 centraliza o corpo (grid + place-items); com o layout, o corpo vira coluna
   normal. place-items tambem precisa voltar ao normal: navegadores novos aplicam justify-items ao
   layout de bloco e centralizariam a navbar e o layout na largura minima. */
body.has-shell {
  display: block;
  place-items: normal;
  padding: 0;
  min-height: 100vh;
}

/* O layout entra em paginas que tem estilos proprios para elementos (o auth-ui/style.css da margem,
   largura e negrito a todo <button>). Aqui so zeramos o que muda a posicao; tamanho e cor vem das
   classes do shell, mais especificas. */
.shell-navbar button,
.shell-sidebar button {
  margin: 0;
}

.shell-navbar {
  position: sticky;
  top: 0;
  z-index: 30;
  display: flex;
  align-items: center;
  gap: 12px;
  height: var(--shell-navbar-height);
  padding: 0 16px;
  background: var(--color-surface);
  color: var(--color-text);
  border-bottom: 1px solid var(--color-border);
}

.shell-brand {
  font-weight: 700;
  font-size: var(--text-lg);
  color: var(--color-text);
  text-decoration: none;
}

.shell-navbar :focus-visible,
.shell-sidebar :focus-visible {
  outline: 2px solid var(--color-focus);
  outline-offset: 2px;
}

.shell-icon-button {
  display: none;
  width: 40px;
  height: 40px;
  padding: 0;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  background: transparent;
  color: var(--color-text);
  cursor: pointer;
}

.shell-burger,
.shell-burger::before,
.shell-burger::after {
  display: block;
  width: 18px;
  height: 2px;
  margin: 0 auto;
  background: currentColor;
  border-radius: 1px;
  content: '';
}

.shell-burger {
  position: relative;
}

.shell-burger::before {
  position: absolute;
  top: -6px;
}

.shell-burger::after {
  position: absolute;
  top: 6px;
}

.shell-user {
  position: relative;
  margin-left: auto;
}

.shell-avatar {
  display: grid;
  place-items: center;
  width: 38px;
  height: 38px;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: var(--color-primary);
  color: var(--color-on-primary);
  font: inherit;
  font-weight: 600;
  font-size: var(--text-sm);
  cursor: pointer;
}

.shell-menu {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  min-width: 220px;
  max-width: calc(100vw - 32px);
  padding: 6px;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg);
}

/* Menu do layout em React (Radix): o posicionamento vem do proprio Radix. */
.shell-menu--floating {
  position: static;
}

.shell-menu[hidden] {
  display: none;
}

.shell-menu-identity {
  display: flex;
  flex-direction: column;
  padding: 8px 10px 10px;
  margin-bottom: 4px;
  border-bottom: 1px solid var(--color-border);
  overflow-wrap: anywhere;
}

.shell-menu-email {
  color: var(--color-text-muted);
  font-size: var(--text-sm);
}

.shell-menu [role='menuitem'] {
  display: block;
  width: 100%;
  padding: 8px 10px;
  border: 0;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--color-text);
  font: inherit;
  font-weight: 400;
  text-align: left;
  text-decoration: none;
  cursor: pointer;
}

.shell-menu [role='menuitem']:hover,
.shell-menu [role='menuitem']:focus {
  background: var(--color-surface-2);
  outline: none;
}

.shell-layout {
  display: grid;
  grid-template-columns: var(--shell-sidebar-width) minmax(0, 1fr);
  min-height: calc(100vh - var(--shell-navbar-height));
}

.shell-sidebar {
  position: sticky;
  top: var(--shell-navbar-height);
  align-self: start;
  height: calc(100vh - var(--shell-navbar-height));
  overflow-y: auto;
  padding: 16px 12px;
  background: var(--color-surface);
  border-right: 1px solid var(--color-border);
}

.shell-nav,
.shell-nav-children {
  margin: 0;
  padding: 0;
  list-style: none;
}

.shell-nav a {
  display: block;
  padding: 8px 10px;
  border-radius: var(--radius-md);
  color: var(--color-text);
  text-decoration: none;
}

.shell-nav a:hover {
  background: var(--color-surface-2);
}

.shell-nav a[aria-current='page'] {
  background: var(--color-primary-soft);
  color: var(--color-primary);
  font-weight: 600;
}

.shell-nav-group {
  display: block;
  padding: 14px 10px 4px;
  color: var(--color-text-muted);
  font-size: var(--text-xs);
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.shell-nav-children a {
  padding-left: 18px;
}

.shell-content {
  min-width: 0;
  padding: 16px;
}

@media (max-width: 900px) {
  .shell-icon-button {
    display: grid;
    place-items: center;
  }

  .shell-layout {
    grid-template-columns: minmax(0, 1fr);
  }

  .shell-sidebar {
    position: fixed;
    top: var(--shell-navbar-height);
    left: 0;
    z-index: 20;
    width: min(var(--shell-sidebar-width), 85vw);
    transform: translateX(-100%);
    transition: transform 0.2s ease;
    visibility: hidden;
  }

  body.shell-sidebar-open .shell-sidebar {
    transform: none;
    visibility: visible;
    box-shadow: var(--shadow-lg);
  }
}

@media (prefers-reduced-motion: reduce) {
  .shell-sidebar {
    transition: none;
  }
}
