/* ================================================================
   RESPONSIVE — Layout responsivo: sidebar lateral + desktop ≥768px
   ================================================================ */

/* ── Hamburger button ────────────────────────────────────────── */
.ham-btn {
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 5px;
  width: 34px;
  height: 34px;
  padding: 7px 6px;
  border-radius: 8px;
  background: var(--s2);
  border: 1px solid var(--bdr2);
  cursor: pointer;
  flex-shrink: 0;
  transition: background 0.15s;
}

.ham-btn:hover { background: var(--s3); }

.ham-line {
  display: block;
  width: 100%;
  height: 2px;
  background: var(--txt);
  border-radius: 2px;
}

/* ── Header left (hamburger + brand) ─────────────────────────── */
.header-left {
  display: flex;
  align-items: center;
  gap: 10px;
}

/* Oculta hamburger no mobile enquanto sidebar está aberta */
@media (max-width: 767px) {
  body.sidebar-open .ham-btn { display: none; }

  /* Compacta o sync-badge no mobile: só o dot, sem texto */
  .sync-badge {
    padding: 0;
    width: 30px;
    height: 30px;
    justify-content: center;
    border-radius: 50%;
  }
  #syncLabel { display: none; }

  /* Aperta o espaço entre os botões de ação */
  .header-actions { gap: 6px; }
}

/* ── Sidebar overlay (backdrop no mobile) ─────────────────────── */
.sidebar-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.55);
  z-index: 91;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s ease;
  backdrop-filter: blur(2px);
  -webkit-backdrop-filter: blur(2px);
}

body.sidebar-open .sidebar-overlay {
  opacity: 1;
  pointer-events: all;
}

/* ── Sidebar ──────────────────────────────────────────────────── */
.sidebar {
  position: fixed;
  left: 0;
  top: 0;
  bottom: 0;
  width: 240px;
  z-index: 92;
  background: var(--s1);
  border-right: 1px solid var(--bdr);
  display: flex;
  flex-direction: column;
  overflow-y: auto;
  overflow-x: hidden;
  transform: translateX(-240px);
  transition: transform 0.25s cubic-bezier(0.4, 0, 0.2, 1),
              width 0.22s cubic-bezier(0.4, 0, 0.2, 1);
  scrollbar-width: none;
}

.sidebar::-webkit-scrollbar { display: none; }

body.sidebar-open .sidebar {
  transform: translateX(0);
}

/* ── Sidebar: header (brand + fechar) ─────────────────────────── */
.sidebar-brand {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 22px 16px 16px;
  border-bottom: 1px solid var(--bdr);
  flex-shrink: 0;
  overflow: hidden;
}

.sidebar-close {
  width: 28px;
  height: 28px;
  border-radius: 6px;
  background: var(--s2);
  border: 1px solid var(--bdr2);
  color: var(--muted);
  font-size: 14px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  flex-shrink: 0;
  transition: background 0.15s, color 0.15s;
}

.sidebar-close:hover {
  background: var(--s3);
  color: var(--txt);
}

/* ── Sidebar: perfil do usuário ───────────────────────────────── */
.sidebar-user {
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 14px 16px;
  border-bottom: 1px solid var(--bdr);
  flex-shrink: 0;
  cursor: pointer;
  transition: background 0.15s;
  overflow: hidden;
}

.sidebar-user:hover { background: var(--s2); }

.sidebar-avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: var(--purple-bg);
  border: 1.5px solid var(--purple-d);
  color: var(--purple);
  font-family: var(--font-display);
  font-size: 14px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.sidebar-user-info {
  min-width: 0;
  overflow: hidden;
}

.sidebar-user-name {
  font-size: 13px;
  font-weight: 600;
  color: var(--txt);
  line-height: 1.3;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.sidebar-user-email {
  font-size: 11px;
  color: var(--muted);
  margin-top: 1px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* ── Sidebar: nav items ───────────────────────────────────────── */
.sidebar-nav {
  flex: 1;
  padding: 8px 8px 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.snav-item {
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 10px 12px;
  border-radius: var(--rs);
  cursor: pointer;
  font-size: 14px;
  color: var(--muted);
  font-weight: 500;
  transition: background 0.15s, color 0.15s;
  user-select: none;
  white-space: nowrap;
  overflow: hidden;
  position: relative;
}

.snav-item:hover {
  background: var(--s2);
  color: var(--txt);
}

.snav-item.on {
  background: var(--purple-bg);
  color: var(--purple);
  font-weight: 600;
}

.snav-icon {
  font-size: 18px;
  flex-shrink: 0;
  width: 22px;
  text-align: center;
  line-height: 1;
}

.snav-label {
  overflow: hidden;
  text-overflow: ellipsis;
  transition: opacity 0.15s;
}

/* ── Sidebar: rodapé ──────────────────────────────────────────── */
.sidebar-bottom {
  padding: 12px 8px;
  border-top: 1px solid var(--bdr);
  display: flex;
  flex-direction: column;
  gap: 7px;
  flex-shrink: 0;
  overflow: hidden;
}

.sidebar-fab-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
  padding: 11px;
  background: var(--purple);
  border-radius: var(--rs);
  color: #fff;
  font-family: var(--font-display);
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
  transition: opacity 0.15s, transform 0.15s, width 0.22s, height 0.22s, border-radius 0.22s, padding 0.22s;
  box-shadow: 0 3px 14px rgba(167, 139, 250, 0.28);
  white-space: nowrap;
  overflow: hidden;
}

.sidebar-fab-btn:hover { opacity: 0.9; }
.sidebar-fab-btn:active { transform: scale(0.97); }

.fab-label {
  transition: opacity 0.15s;
}

.sidebar-logout-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
  padding: 9px;
  background: none;
  border: 1px solid var(--bdr2);
  border-radius: var(--rs);
  color: var(--red);
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s, width 0.22s, padding 0.22s;
  white-space: nowrap;
  overflow: hidden;
}

.sidebar-logout-btn:hover {
  background: var(--red-bg);
  border-color: var(--red-d);
}

.logout-label {
  transition: opacity 0.15s;
}

/* ================================================================
   MODO COLAPSADO (apenas ícones, 62px)
   ================================================================ */
body.sidebar-collapsed .sidebar {
  width: 62px;
}

/* Oculta textos no sidebar-brand */
body.sidebar-collapsed .sidebar-brand {
  justify-content: center;
  padding: 20px 0 14px;
}

body.sidebar-collapsed .sidebar-close { display: none; }

body.sidebar-collapsed .sidebar-brand .brand > span {
  display: none;
}

/* Oculta info do usuário */
body.sidebar-collapsed .sidebar-user {
  justify-content: center;
  padding: 12px 0;
  gap: 0;
}

body.sidebar-collapsed .sidebar-user-info { display: none; }

/* Nav items: apenas ícone centralizado */
body.sidebar-collapsed .snav-item {
  justify-content: center;
  padding: 12px 0;
  gap: 0;
}

body.sidebar-collapsed .snav-label { display: none; }

/* Tooltip nativo nos items colapsados */
body.sidebar-collapsed .snav-item::after {
  content: attr(data-label);
  position: absolute;
  left: 62px;
  top: 50%;
  transform: translateY(-50%);
  background: var(--s2);
  border: 1px solid var(--bdr2);
  border-radius: 8px;
  padding: 6px 12px;
  font-size: 13px;
  font-weight: 500;
  color: var(--txt);
  white-space: nowrap;
  z-index: 200;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.15s;
  box-shadow: 0 4px 16px rgba(0,0,0,0.25);
}

body.sidebar-collapsed .snav-item:hover::after {
  opacity: 1;
}

/* Rodapé colapsado */
body.sidebar-collapsed .sidebar-bottom {
  align-items: center;
  padding: 12px 0;
}

body.sidebar-collapsed .fab-label { display: none; }

body.sidebar-collapsed .sidebar-fab-btn {
  width: 42px;
  height: 42px;
  border-radius: 12px;
  padding: 0;
  gap: 0;
}

body.sidebar-collapsed .logout-label { display: none; }

body.sidebar-collapsed .sidebar-logout-btn {
  width: 38px;
  height: 38px;
  border-radius: 10px;
  padding: 0;
  border-color: transparent;
}

/* ── Cartões: widget full-width no mobile ─────────────────────── */
@media (max-width: 767px) {
  .cc-widget {
    width: calc(85vw - 36px);
    max-width: 320px;
  }
  .cc-widget-all {
    min-width: 72px;
  }
}

/* ================================================================
   BREAKPOINT DESKTOP ≥ 768px
   ================================================================ */
@media (min-width: 768px) {
  /* Remove restrição de largura mobile */
  body {
    max-width: none;
    margin: 0;
    transition: padding-left 0.22s cubic-bezier(0.4, 0, 0.2, 1);
  }

  /* Sidebar expandida: empurra conteúdo 240px */
  body.sidebar-open {
    padding-left: 240px;
  }

  /* Sidebar colapsada: empurra conteúdo 62px */
  body.sidebar-open.sidebar-collapsed {
    padding-left: 62px;
  }

  /* No desktop, sidebar é fixa (sem overlay) */
  .sidebar-overlay {
    display: none !important;
  }

  /* Oculta bottom nav no desktop */
  .bnav {
    display: none;
  }

  /* Reduz padding inferior das seções (sem bottom nav) */
  .sec {
    padding-bottom: 40px;
    min-height: calc(100dvh - 200px);
  }

  /* Reduz padding top do header (sem notch do iOS) */
  .header {
    padding-top: 16px;
  }

  /* Ajusta posição do user menu dropdown */
  .user-menu {
    top: 60px;
  }

  /* ── Oculta saldo-card e mês nas seções que não precisam ─────── */
  body[data-section="perfil"] .saldo-card,
  body[data-section="perfil"] .mes-row,
  body[data-section="user-profile"] .saldo-card,
  body[data-section="user-profile"] .mes-row,
  body[data-section="exportar"] .saldo-card,
  body[data-section="exportar"] .mes-row {
    display: none;
  }
}
