/* =====================================================
   PORTAL REDE — Navegação
   Shell · Sidebar recolhível · Submenus · Drawer mobile
   Flat: sem degradê, sem sombras.
   ===================================================== */

.app-shell {
  display: grid;
  grid-template-columns: 264px minmax(0, 1fr);
  min-height: 100vh;
  transition: grid-template-columns .3s var(--ease);
}
html.nav-collapsed .app-shell { grid-template-columns: 78px minmax(0, 1fr); }

/* =====================================================
   Sidebar
   ===================================================== */

.sidebar {
  background: var(--pine-deep);
  color: #fff;
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow: hidden;
}

.sidebar-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 20px 14px 14px 20px;
  min-height: 68px;
}
html.nav-collapsed .sidebar-top {
  flex-direction: column;
  padding: 18px 0 10px;
  gap: 14px;
}

/* Marca */
.brand {
  display: flex;
  align-items: center;
  gap: 11px;
  color: #fff;
  text-decoration: none;
  min-width: 0;
}
.brand:hover { text-decoration: none; }
.brand-name {
  font-family: var(--font-display);
  font-size: 17px;
  font-weight: 700;
  letter-spacing: -0.01em;
  white-space: nowrap;
  transition: opacity .2s var(--ease);
}
.brand-name em { font-style: normal; color: var(--lime); }
html.nav-collapsed .sidebar .brand-name { display: none; }

.brand-mark {
  width: 32px; height: 32px;
  border-radius: 9px;
  background: var(--lime);
  position: relative;
  flex-shrink: 0;
}
.brand-mark::before, .brand-mark::after {
  content: "";
  position: absolute;
  border-radius: 50%;
  background: var(--pine-deep);
}
.brand-mark::before { width: 8px; height: 8px; top: 7px; left: 7px; }
.brand-mark::after { width: 12px; height: 12px; bottom: 6px; right: 6px; }

/* Botão de recolher (desktop) */
.rail-toggle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px; height: 28px;
  flex-shrink: 0;
  background: none;
  border: 1px solid rgba(255, 255, 255, .22);
  border-radius: var(--radius-pill);
  color: rgba(255, 255, 255, .65);
  cursor: pointer;
  transition: border-color .2s var(--ease), color .2s var(--ease),
              transform .3s var(--ease), background-color .2s var(--ease);
}
.rail-toggle:hover { border-color: var(--lime); color: var(--lime); }
html.nav-collapsed .rail-toggle { transform: rotate(180deg); }

/* Fechar drawer (mobile) */
.mobile-close { display: none; }

/* =====================================================
   Área de navegação
   ===================================================== */

.nav-scroll {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 4px 14px 16px;
  display: flex;
  flex-direction: column;
  gap: 2px;
  scrollbar-width: thin;
  scrollbar-color: rgba(255, 255, 255, .18) transparent;
}
.nav-scroll::-webkit-scrollbar { width: 7px; }
.nav-scroll::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, .18);
  border-radius: var(--radius-pill);
}
html.nav-collapsed .nav-scroll { padding: 4px 12px 16px; }

.nav-label {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .1em;
  color: rgba(255, 255, 255, .38);
  padding: 18px 12px 8px;
  white-space: nowrap;
}
html.nav-collapsed .nav-label {
  height: 1px;
  padding: 0;
  margin: 14px 10px;
  background: rgba(255, 255, 255, .14);
  overflow: hidden;
  border-radius: 1px;
}

/* Item de navegação */
.nav-link {
  display: flex;
  align-items: center;
  gap: 11px;
  width: 100%;
  padding: 10px 12px;
  border: none;
  border-radius: var(--radius-sm);
  background: none;
  color: rgba(255, 255, 255, .72);
  font-family: var(--font-body);
  font-size: 14px;
  font-weight: 500;
  text-align: left;
  text-decoration: none;
  cursor: pointer;
  transition: background-color .18s var(--ease), color .18s var(--ease);
}
.nav-link:hover { background: rgba(255, 255, 255, .07); color: #fff; text-decoration: none; }
.nav-link.active { background: var(--lime); color: var(--pine-deep); font-weight: 600; }

.nav-ico {
  display: inline-flex;
  flex-shrink: 0;
  transition: transform .2s var(--ease);
}
.nav-link:hover .nav-ico { transform: translateX(1px) scale(1.08); }

.nav-text {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  flex: 1;
}
html.nav-collapsed .sidebar .nav-text,
html.nav-collapsed .sidebar .nav-caret { display: none; }
html.nav-collapsed .sidebar .nav-link { justify-content: center; padding: 11px 0; }

/* =====================================================
   Submenus (acordeão)
   ===================================================== */

.nav-caret {
  flex-shrink: 0;
  color: rgba(255, 255, 255, .45);
  transition: transform .25s var(--ease);
}
.nav-sub.open > .nav-parent .nav-caret { transform: rotate(180deg); }

/* Pai com filho ativo ganha destaque sutil */
.nav-sub.current > .nav-parent { color: #fff; }
.nav-sub.current > .nav-parent .nav-ico { color: var(--lime); }

.nav-subpanel {
  display: grid;
  grid-template-rows: 0fr;
  transition: grid-template-rows .3s var(--ease);
}
.nav-sub.open > .nav-subpanel { grid-template-rows: 1fr; }
html.nav-collapsed .sidebar .nav-subpanel { grid-template-rows: 0fr; }

.nav-subinner {
  overflow: hidden;
  min-height: 0;
  display: flex;
  flex-direction: column;
  gap: 1px;
  margin-left: 21px;
  border-left: 1px solid rgba(255, 255, 255, .16);
  padding-left: 8px;
}

.nav-sublink {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 8px 12px;
  border-radius: var(--radius-sm);
  color: rgba(255, 255, 255, .58);
  font-size: 13.5px;
  font-weight: 500;
  text-decoration: none;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  transition: background-color .18s var(--ease), color .18s var(--ease), padding-left .18s var(--ease);
}
.nav-sublink::before {
  content: "";
  width: 5px; height: 5px;
  flex-shrink: 0;
  border-radius: 50%;
  background: currentColor;
  opacity: .45;
  transition: opacity .18s var(--ease), background-color .18s var(--ease);
}
.nav-sublink:hover {
  background: rgba(255, 255, 255, .06);
  color: #fff;
  padding-left: 15px;
  text-decoration: none;
}
.nav-sublink.active { color: var(--lime); font-weight: 600; }
.nav-sublink.active::before { background: var(--lime); opacity: 1; }

/* =====================================================
   Rodapé da sidebar
   ===================================================== */

.sidebar-footer {
  border-top: 1px solid rgba(255, 255, 255, .12);
  padding: 14px 16px;
  display: flex;
  align-items: center;
  gap: 10px;
}
html.nav-collapsed .sidebar-footer {
  flex-direction: column;
  padding: 14px 0;
  gap: 10px;
}
.sidebar-footer .who { min-width: 0; flex: 1; }
html.nav-collapsed .sidebar-footer .who { display: none; }
.sidebar-footer .who .n {
  font-size: 13.5px; font-weight: 600; color: #fff;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.sidebar-footer .who .r { font-size: 12px; color: rgba(255, 255, 255, .5); }

.logout-btn {
  background: none;
  border: 1px solid rgba(255, 255, 255, .2);
  border-radius: var(--radius-sm);
  color: rgba(255, 255, 255, .7);
  padding: 7px 9px;
  cursor: pointer;
  line-height: 0;
  transition: border-color .15s var(--ease), color .15s var(--ease);
}
.logout-btn:hover { border-color: var(--lime); color: var(--lime); }

/* =====================================================
   Topbar (somente mobile) e backdrop
   ===================================================== */

.topbar { display: none; }

.sidebar-backdrop {
  position: fixed;
  inset: 0;
  z-index: 50;
  background: rgba(13, 27, 20, .5);
  opacity: 0;
  pointer-events: none;
  transition: opacity .25s var(--ease);
}
.sidebar-backdrop.visible { opacity: 1; pointer-events: auto; }

.hamburger {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 38px; height: 38px;
  background: none;
  border: 1px solid rgba(255, 255, 255, .25);
  border-radius: var(--radius-sm);
  color: #fff;
  cursor: pointer;
  transition: border-color .2s var(--ease), color .2s var(--ease);
}
.hamburger:hover { border-color: var(--lime); color: var(--lime); }

/* =====================================================
   Conteúdo
   ===================================================== */

.main { padding: 34px 42px 60px; max-width: 1180px; width: 100%; }

.page-head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 20px;
  margin-bottom: 28px;
  flex-wrap: wrap;
}
.page-head h1 { font-size: 26px; }
.page-head .crumb {
  font-size: 13px;
  color: var(--ink-faint);
  margin-bottom: 6px;
}
.page-head .crumb a { color: var(--ink-faint); }
.page-actions { display: flex; gap: 10px; }

/* =====================================================
   Mobile — drawer off-canvas
   ===================================================== */

@media (max-width: 900px) {
  .app-shell, html.nav-collapsed .app-shell { display: block; }

  .topbar {
    display: flex;
    align-items: center;
    gap: 14px;
    position: sticky;
    top: 0;
    z-index: 30;
    background: var(--pine-deep);
    padding: 12px 16px;
  }
  .topbar .brand-name { font-size: 16px; }

  .sidebar {
    position: fixed;
    top: 0; left: 0; bottom: 0;
    z-index: 60;
    width: min(82vw, 304px);
    height: 100dvh;
    transform: translateX(-103%);
    transition: transform .3s var(--ease);
  }
  .sidebar.mobile-open { transform: translateX(0); }

  /* No mobile o drawer nunca fica em modo trilho */
  html.nav-collapsed .sidebar .nav-text,
  html.nav-collapsed .sidebar .nav-caret { display: initial; }
  html.nav-collapsed .sidebar .nav-text { flex: 1; }
  html.nav-collapsed .sidebar .nav-link { justify-content: flex-start; padding: 10px 12px; }
  html.nav-collapsed .sidebar .nav-subpanel { grid-template-rows: 0fr; }
  html.nav-collapsed .sidebar .nav-sub.open > .nav-subpanel { grid-template-rows: 1fr; }
  html.nav-collapsed .sidebar .brand-name { display: initial; }
  html.nav-collapsed .sidebar-top { flex-direction: row; padding: 20px 14px 14px 20px; }
  html.nav-collapsed .nav-label {
    height: auto;
    background: none;
    padding: 18px 12px 8px;
    margin: 0;
  }
  html.nav-collapsed .sidebar-footer { flex-direction: row; padding: 14px 16px; }
  html.nav-collapsed .sidebar-footer .who { display: block; }

  .rail-toggle { display: none; }

  .mobile-close {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 32px; height: 32px;
    background: none;
    border: 1px solid rgba(255, 255, 255, .22);
    border-radius: var(--radius-pill);
    color: rgba(255, 255, 255, .65);
    cursor: pointer;
    flex-shrink: 0;
    transition: border-color .2s var(--ease), color .2s var(--ease);
  }
  .mobile-close:hover { border-color: var(--lime); color: var(--lime); }

  .main { padding: 24px 20px 48px; }
}

/* Respeita usuários que preferem menos movimento */
@media (prefers-reduced-motion: reduce) {
  .app-shell, .sidebar, .nav-subpanel, .nav-caret, .rail-toggle,
  .sidebar-backdrop, .nav-sublink, .nav-ico { transition: none; }
}
