/* ============================================================================
   layout.css — reset leve, shell (sidebar + header + conteúdo), tela de login
   ============================================================================ */

*, *::before, *::after { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  font-family: var(--font);
  font-weight: var(--fw-300);
  font-size: var(--fs-base);
  line-height: 1.5;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
}
h1, h2, h3, h4 { font-weight: var(--fw-400); margin: 0; letter-spacing: -0.01em; }
h1 { font-size: var(--fs-2xl); font-weight: var(--fw-300); }
a { color: inherit; }
button { font-family: inherit; }

/* foco visível por teclado — anel único e consistente no app inteiro */
:focus-visible { outline: var(--focus-ring); outline-offset: 2px; }

/* scrollbar segue tema+acento em vez do padrão do SO, em qualquer área rolável */
* { scrollbar-color: var(--color-mauve-500) var(--surface-2); scrollbar-width: thin; }
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: var(--surface-2); }
::-webkit-scrollbar-thumb { background: var(--color-mauve-500); border-radius: var(--radius-pill); border: 2px solid var(--surface-2); }
::-webkit-scrollbar-thumb:hover { background: var(--color-mauve-700); }

/* -------------------------------------------------------------- login ----- */
/* Rodada 8: fundo neutro (cinza claro) atrás do card flutuante — antes usava
   o --bg padrão do app, muito próximo do branco do próprio card. */
.login {
  position: relative;
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: var(--sp-5);
  background: var(--color-black);
}
/* fundo: mesma imagem do hero, escurecida para legibilidade do card */
.login::before {
  content: "";
  position: absolute; inset: 0; z-index: 0;
  background: url("../img/hero-banner-bw.webp") center / cover no-repeat;
}
.login-card {
  position: relative; z-index: 1;
  display: block;
  width: 100%;
  max-width: 460px;
  background: var(--surface);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow);
  overflow: hidden;
}
.login__logo {
  font-size: var(--fs-xl);
  font-weight: var(--fw-200);
  letter-spacing: 0.04em;
  margin-bottom: var(--sp-3);
}
.login__logo b { font-weight: var(--fw-500); }

.login-form {
  padding: var(--sp-7);
  display: flex;
  flex-direction: column;
  justify-content: center;
}
.login-form__sub { color: var(--text-muted); margin: 0 0 var(--sp-6); }
.login-form__labelrow { display: flex; justify-content: space-between; align-items: baseline; }
.login-form__labelrow a { font-size: var(--fs-xs); color: var(--text-muted); text-decoration: none; }
.login-form__labelrow a:hover { color: var(--text); text-decoration: underline; }
.login-form__pass { position: relative; }
.login-form__pass .input { padding-right: 44px; }
.login-form__pass button {
  position: absolute; right: 4px; top: 50%; transform: translateY(-50%);
  background: none; border: none; cursor: pointer; color: var(--text-faint);
  width: 36px; height: 36px; display: grid; place-items: center; border-radius: var(--radius-sm);
}
.login-form__pass button:hover, .login-form__pass button.is-on { color: var(--text); }
.login-form__pass button svg { width: 18px; height: 18px; }
.login-form__divider {
  display: flex; align-items: center; gap: var(--sp-3);
  color: var(--text-faint); font-size: var(--fs-sm);
  margin: var(--sp-5) 0;
}
.login-form__divider::before, .login-form__divider::after {
  content: ""; flex: 1; height: 1px; background: var(--border);
}
.login-form__signup { text-align: center; font-size: var(--fs-sm); color: var(--text-muted); margin: var(--sp-5) 0 0; }
.login-form__signup a { color: var(--text); font-weight: var(--fw-500); text-decoration: none; }
.login-form__signup a:hover { text-decoration: underline; }

/* card único e centralizado — ajuste fino em telas estreitas */
@media (max-width: 480px) {
  .login-card { max-width: 100%; }
  .login-form { padding: var(--sp-6); }
}

/* ----------------------------------------------------------- app shell ---- */
.shell {
  display: grid;
  grid-template-columns: var(--sidebar-w) 1fr;
  min-height: 100vh;
}
.shell.collapsed { grid-template-columns: var(--sidebar-w-collapsed) 1fr; }

.sidebar {
  background: var(--surface);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
}
.sidebar__brand {
  height: var(--header-h);
  display: flex;
  align-items: center;
  gap: var(--sp-2);
  padding: 0 var(--sp-4) 0 var(--sp-5);
  font-size: var(--fs-lg);
  font-weight: var(--fw-200);
  letter-spacing: 0.04em;
  white-space: nowrap;
  overflow: hidden;
}
.sidebar__brand b { font-weight: var(--fw-500); display: inline-flex; }
.sidebar__brand svg { width: 22px; height: 22px; }
.sidebar__brand .collapse-btn { margin-left: auto; flex-shrink: 0; }

.nav {
  flex: 1; padding: var(--sp-3) var(--sp-3); overflow-y: auto;
  display: flex; flex-direction: column; gap: var(--sp-1);
}
.nav__item {
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  padding: var(--sp-3) var(--sp-3);
  border-radius: var(--radius-sm);
  color: var(--text-muted);
  text-decoration: none;
  cursor: pointer;
  white-space: nowrap;
  transition: background var(--transition), color var(--transition);
  border: none;
  background: none;
  width: 100%;
  text-align: left;
  font-size: var(--fs-base);
  position: relative;
}
.nav__item { border-radius: 10px; }
.nav__item:hover { background: var(--surface-2); color: var(--text); }
.nav__item.active { background: var(--surface-2); color: var(--text); font-weight: var(--fw-500); }
.nav__icon { width: 20px; display: inline-flex; align-items: center; justify-content: center; flex-shrink: 0; color: var(--text-faint); }
.nav__item.active .nav__icon, .nav__item:hover .nav__icon { color: var(--text); }
.nav__icon svg { width: 20px; height: 20px; }
.nav__badge {
  margin-left: auto;
  background: var(--danger);
  color: #fff;
  font-size: var(--fs-xs);
  min-width: 18px;
  height: 18px;
  border-radius: var(--radius-pill);
  display: grid;
  place-items: center;
  padding: 0 5px;
}

.sidebar__user { border-top: 1px solid var(--border); position: relative; }
/* item 1/2: rodapé virou um único gatilho (avatar+info+hamburger) que abre um
   mini-menu com Configurações/Sair — sem 2º elemento ao lado do avatar, o
   modo colapsado nunca mais vaza (só o avatar sobra, cabe no rail de 64px). */
.user-menu__trigger {
  display: flex; align-items: center; gap: var(--sp-3); width: 100%;
  padding: var(--sp-3); background: none; border: none; cursor: pointer;
  text-align: left; font: inherit; color: inherit;
}
.user-menu__trigger:hover { background: var(--surface-2); }
.user-menu__trigger .avatar { flex-shrink: 0; }
.user-menu__icon { margin-left: auto; flex-shrink: 0; display: flex; color: var(--text-faint); }
.user-menu__icon svg { width: 18px; height: 18px; }
.sidebar__user-info { overflow: hidden; flex: 1; }
.sidebar__user-info .name { font-size: var(--fs-sm); white-space: nowrap; text-overflow: ellipsis; overflow: hidden; }
.sidebar__user-info .email { font-size: var(--fs-xs); color: var(--text-faint); white-space: nowrap; text-overflow: ellipsis; overflow: hidden; }

.user-menu__pop {
  position: absolute; left: var(--sp-2); bottom: calc(100% + 4px); width: 200px;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-sm);
  box-shadow: var(--shadow); z-index: 50; overflow: hidden;
}
.user-menu__pop button {
  display: flex; align-items: center; gap: var(--sp-2); width: 100%;
  padding: var(--sp-3); background: none; border: none; cursor: pointer;
  text-align: left; font-size: var(--fs-sm); color: var(--text);
}
.user-menu__pop button:hover { background: var(--surface-2); }
.user-menu__pop svg { width: 16px; height: 16px; color: var(--text-faint); flex-shrink: 0; }

.collapsed .sidebar__brand span,
.collapsed .sidebar__brand b.brand-mark,
.collapsed .nav__item .label,
.collapsed .sidebar__user-info,
.collapsed .user-menu__icon { display: none; }
.collapsed .sidebar__brand { justify-content: center; padding: 0 var(--sp-2); }
.collapsed .sidebar__brand .collapse-btn { margin-left: 0; }
.collapsed .nav__item { justify-content: center; }
.collapsed .user-menu__trigger { justify-content: center; padding: var(--sp-3) var(--sp-2); }

/* ------------------------------------------------------------- content ---- */
.content { display: flex; flex-direction: column; min-width: 0; }
.header {
  height: var(--header-h);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 var(--sp-6);
  gap: var(--sp-4);
  position: sticky;
  top: 0;
  background: var(--bg);
  z-index: 10;
}
.header__left { display: flex; align-items: center; gap: var(--sp-4); }
.header__title { font-size: var(--fs-xl); font-weight: var(--fw-300); }
.header__actions { display: flex; gap: var(--sp-3); align-items: center; }
.collapse-btn {
  background: none; border: none; cursor: pointer; color: var(--text-muted);
  font-size: var(--fs-lg); padding: var(--sp-2); border-radius: var(--radius-sm);
}
.collapse-btn:hover { background: var(--surface-2); }
.collapse-btn svg { width: 20px; height: 20px; display: block; }

.module { padding: var(--sp-6); flex: 1; }
/* transição de rota: fade + subida sutil. Navegar é ação frequente (dezenas/
   dia) → curto e discreto (160ms/6px), nunca "vistoso" */
.module.module-enter { animation: moduleIn var(--dur-fast) var(--ease-out); }
@keyframes moduleIn { from { opacity: 0; transform: translateY(6px); } }
.module__toolbar {
  display: flex; align-items: center; gap: var(--sp-3);
  margin-bottom: var(--sp-5); flex-wrap: wrap;
}
.module__toolbar .spacer { flex: 1; }

/* -------------------------------------------------------- responsivo ------ */
@media (max-width: 1200px) {
  .shell { grid-template-columns: var(--sidebar-w-collapsed) 1fr; }
  .sidebar__brand span, .sidebar__brand b.brand-mark, .sidebar .nav__item .label, .sidebar__user-info { display: none; }
  .sidebar__brand { justify-content: center; padding: 0 var(--sp-2); }
  .sidebar__brand .collapse-btn { margin-left: 0; }
  .nav__item { justify-content: center; }
  .user-menu__icon { display: none; }
  .user-menu__trigger { justify-content: center; padding: var(--sp-3) var(--sp-2); }
}

/* mobile (≤900px): a sidebar sai de cena — a navegação principal é a .tabbar
   fixa no rodapé (Rodada 7 mobile). Header compacto; conteúdo ganha folga
   inferior p/ tabbar + FAB não cobrirem as últimas linhas. */
@media (max-width: 900px) {
  .shell, .shell.collapsed { grid-template-columns: 1fr; }
  .sidebar { display: none; }
  .header { height: 56px; padding: 0 var(--sp-4); }
  .header__title { font-size: var(--fs-lg); }
  .module {
    padding: var(--sp-4);
    padding-bottom: calc(var(--tabbar-h) + env(safe-area-inset-bottom) + 88px);
  }
}

/* ------------------------------------------------------------- tabbar ------ */
/* barra de abas mobile: 4 rotas fixas + "Mais" (app.js popula o #tabbar).
   Só existe ≤900px; safe-area p/ iPhone com home indicator. */
.tabbar { display: none; }
@media (max-width: 900px) {
  .tabbar {
    position: fixed; left: 0; right: 0; bottom: 0; z-index: 90;
    display: grid; grid-template-columns: repeat(5, 1fr);
    height: calc(var(--tabbar-h) + env(safe-area-inset-bottom));
    padding-bottom: env(safe-area-inset-bottom);
    background: var(--surface); border-top: 1px solid var(--border);
  }
  .tabbar__item {
    display: flex; flex-direction: column; align-items: center; justify-content: center;
    gap: 2px; background: none; border: none; cursor: pointer;
    color: var(--text-faint); font-size: var(--fs-xs); font-family: inherit;
  }
  .tabbar__item svg { width: 22px; height: 22px; }
  .tabbar__item.active { color: var(--text); font-weight: var(--fw-500); }
}
