/* ══════════════════════════════════════════════════════════
   spa.css — CSS compartilhado entre todas as páginas da SPA
   Gestor Financeiro Pessoal
   ══════════════════════════════════════════════════════════ */

/* ── Reset ── */
* { box-sizing: border-box; margin: 0; padding: 0; }
html { overflow-x: hidden; scrollbar-gutter: stable; }

/* ── Variáveis CSS ── */
:root {
  --bg: #0e1118;
  --surface: #161b24;
  --surface2: #1c2230;
  --border: #232b3a;
  --border2: #2c3650;
  --text: #f0f4f8;
  --muted: #5a6478;
  --sub: #8892a4;
  --blue: #3b82f6;
  --green: #22c55e;
  --yellow: #f59e0b;
  --red: #ef4444;
  --em: #10b981;
  --em2: #059669;
  --amber: #f59e0b;
  --rose: #f43f5e;
  --sky: #38bdf8;
  --violet: #818cf8;
  --nav-h: 60px;
}

/* ── Body ── */
body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  padding-bottom: var(--nav-h);
  opacity: 0;
  transition: opacity 0.15s;
}
@media (min-width: 768px) { body { padding-bottom: 0; } }

/* ── Containers de página (abas persistentes — show/hide sem fade) ── */
.spa-page {
  width: 100%;
}

/* ── Header ── */
header {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 100;
}
.header-inner {
  max-width: 1300px;
  margin: 0 auto;
  padding: 0 1.5rem;
  height: 56px;
  display: flex;
  align-items: center;
  gap: 2rem;
}
@media (max-width: 420px) { .header-inner { padding: 0 1rem; gap: 0.75rem; } }

/* Logo */
.logo {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  text-decoration: none;
  flex-shrink: 0;
  min-width: 170px;
}
.logo-mark {
  width: 30px;
  height: 30px;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
}
.logo-name {
  font-size: 0.92rem;
  font-weight: 700;
  color: var(--text);
  letter-spacing: -0.02em;
  white-space: nowrap;
}
.logo-name em {
  font-style: normal;
  background: linear-gradient(90deg, #f43f5e, #f59e0b);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

/* Nav links desktop */
.header-nav { display: none; }
@media (min-width: 768px) {
  .header-nav {
    flex: 1;
    display: flex;
    align-items: stretch;
    height: 100%;
  }
  .nav-link {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0 0.9rem;
    font-size: 0.83rem;
    font-weight: 500;
    color: var(--sub);
    text-decoration: none;
    position: relative;
    transition: color 0.18s;
    white-space: nowrap;
  }
  .nav-link:hover { color: var(--text); }
  .nav-link.active { color: var(--em); }
  .nav-link.active::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    height: 2px;
    background: var(--em);
    border-radius: 2px 2px 0 0;
  }
}

/* Direita do header */
.header-right {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  flex-shrink: 0;
  justify-content: flex-end;
  min-width: 160px;
}

/* Dropdown do usuário */
.user-dropdown-wrap { position: relative; }
.user-chip {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  padding: 0.28rem 0.6rem 0.28rem 0.28rem;
  border-radius: 8px;
  border: 1px solid var(--border2);
  cursor: pointer;
  transition: all 0.18s;
  background: none;
  font-family: inherit;
}
.user-chip:hover,
.user-chip.open { border-color: var(--em); background: rgba(16,185,129,.05); }
.avatar-circle {
  width: 26px;
  height: 26px;
  border-radius: 6px;
  background: linear-gradient(135deg, var(--em), var(--sky));
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.68rem;
  font-weight: 800;
  color: #fff;
  flex-shrink: 0;
}
.user-name-chip { font-size: 0.8rem; font-weight: 600; color: var(--text); }
.user-role-chip { font-size: 0.62rem; color: var(--muted); line-height: 1; }
.user-menu {
  display: none;
  position: absolute;
  right: 0;
  top: calc(100% + 6px);
  background: var(--surface2);
  border: 1px solid var(--border2);
  border-radius: 10px;
  min-width: 160px;
  box-shadow: 0 8px 24px rgba(0,0,0,.35);
  z-index: 300;
  overflow: hidden;
}
.user-menu.open { display: block; }
.user-menu-item {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.65rem 1rem;
  font-size: 0.85rem;
  color: var(--text);
  text-decoration: none;
  background: none;
  border: none;
  width: 100%;
  font-family: inherit;
  text-align: left;
  cursor: pointer;
  transition: background 0.15s;
}
.user-menu-item:hover { background: rgba(255,255,255,.06); }
.user-menu-item.danger { color: var(--red); }
.user-menu-item.danger:hover { background: rgba(239,68,68,.1); }
.user-menu-divider { height: 1px; background: var(--border); margin: 0.2rem 0; }

/* ── Bottom nav ── */
.bottom-nav {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  height: var(--nav-h);
  background: var(--surface);
  border-top: 1px solid var(--border);
  display: flex;
  z-index: 20;
}
@media (min-width: 768px) { .bottom-nav { display: none; } }
.nav-item {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.2rem;
  text-decoration: none;
  color: var(--muted);
  font-size: 0.66rem;
  font-weight: 500;
  transition: color 0.2s;
}
.nav-item.active { color: var(--em); }
.nav-item .nav-icon { font-size: 1.2rem; line-height: 1; }

/* ── Toast ── */
.toast-container {
  position: fixed;
  bottom: calc(var(--nav-h) + 1rem);
  left: 50%;
  transform: translateX(-50%);
  z-index: 400;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.5rem;
  pointer-events: none;
}
@media (min-width: 768px) { .toast-container { bottom: 1.5rem; } }
.toast {
  padding: 0.7rem 1.4rem;
  border-radius: 10px;
  font-size: 0.88rem;
  font-weight: 500;
  box-shadow: 0 4px 20px rgba(0,0,0,0.35);
  opacity: 0;
  transform: translateY(8px);
  transition: opacity 0.25s, transform 0.25s;
  white-space: nowrap;
}
.toast.show { opacity: 1; transform: translateY(0); }
.toast.sucesso { background: #166534; color: #bbf7d0; border: 1px solid #22c55e44; }
.toast.erro    { background: #7f1d1d; color: #fecaca; border: 1px solid #ef444444; }

/* ── Botões globais ── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.42rem 0.9rem;
  border-radius: 7px;
  font-size: 0.8rem;
  font-weight: 600;
  cursor: pointer;
  border: none;
  transition: all 0.18s;
  font-family: inherit;
}
.btn-outline { background: none; border: 1px solid var(--border2); color: var(--sub); }
.btn-outline:hover { border-color: var(--em); color: var(--em); }
.btn-outline.on {
  background: rgba(16,185,129,.1);
  border-color: rgba(16,185,129,.3);
  color: var(--em);
}
.btn-solid {
  background: var(--em);
  color: #fff;
  box-shadow: 0 0 14px rgba(16,185,129,.25);
  text-decoration: none;
}
.btn-solid:hover { background: var(--em2); }
a.btn-solid { color: #fff; text-decoration: none; }

/* ── Componentes compartilhados ── */

/* Panel */
.panel { background: var(--surface); border: 1px solid var(--border); border-radius: 12px; overflow: hidden; margin-bottom: 1rem; }
.panel-head { display: flex; align-items: center; justify-content: space-between; padding: .85rem 1.1rem; border-bottom: 1px solid var(--border); }
.panel-title { font-size: .9rem; font-weight: 600; display: flex; align-items: center; gap: .4rem; }
.panel-body { padding: 1rem 1.1rem; }

/* Page bar (cabeçalho de seção com título + ações) */
/* Padding não declarado aqui — cada página define o seu via CSS injetado ou classe scoped */
.page-bar { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: .75rem; border-bottom: 1px solid var(--border); }
.page-bar-left h1 { font-size: 1.25rem; font-weight: 700; margin: 0; }
.page-bar-left p { font-size: .8rem; color: var(--muted); margin: .15rem 0 0; }
.page-bar-right { display: flex; align-items: center; gap: .5rem; flex-wrap: wrap; }
@media (max-width: 599px) { .page-bar { flex-direction: column; align-items: flex-start; } .page-bar-right { width: 100%; } }

/* Empty state */
.empty { text-align: center; padding: 2rem 1rem; color: var(--muted); font-size: .88rem; }

/* ── Keyframes ── */
@keyframes spin { to { transform: rotate(360deg); } }
@keyframes slideUp {
  from { transform: translateY(40px); opacity: 0; }
  to   { transform: none; opacity: 1; }
}
