/* ==========================================================================
   GESTOR DE BOLOS DA MAMÃE 2.0 - DESIGN SYSTEM & MAIN STYLES (DARK LUXO)
   Estética: Confeitaria Premium, Dark Mode Sofisticado, Alto Contraste
   ========================================================================== */

:root {
  /* Paleta Dark Luxo / Noturna */
  --bg-app: #0F0E12;             /* Fundo escuro profundo e aveludado */
  --bg-surface: #17161C;         /* Superfície dos painéis e sidebar */
  --bg-card: #1D1C24;            /* Superfície dos cards */
  --bg-subtle: #24232C;          /* Fundos secundários, inputs e hover sutil */
  --bg-hover: #2F2E38;           /* Hover em botões e linhas */
  
  --border-light: #2C2B36;       /* Bordas sutis */
  --border-medium: #3E3D4A;      /* Bordas em foco e divisores */
  --border-focus: #D97706;

  /* Cores de Marca / Acentos Confeitaria */
  --primary: #C53B3C;           /* Framboesa / Bordô Vibrante */
  --primary-hover: #A82E2F;
  --primary-light: rgba(197, 59, 60, 0.18);
  --primary-text: #FFFFFF;

  --accent: #D97706;            /* Caramelo / Dourado Quente */
  --accent-light: rgba(217, 119, 6, 0.18);
  --accent-hover: #B45309;

  /* Textos de Alta Legibilidade */
  --text-main: #F4F2EE;         /* Branco marfim suave (não cansa a vista) */
  --text-muted: #A8A29E;        /* Cinza quente médio */
  --text-subtle: #78716C;       /* Cinza escuro para detalhes */
  
  /* Estados / Semântica */
  --success: #10B981;
  --success-light: rgba(16, 185, 129, 0.18);
  --warning: #F59E0B;
  --warning-light: rgba(245, 158, 11, 0.18);
  --danger: #EF4444;
  --danger-light: rgba(239, 68, 68, 0.18);
  --info: #3B82F6;
  --info-light: rgba(59, 130, 246, 0.18);

  /* Tipografia */
  --font-title: 'Outfit', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  --font-body: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;

  /* Sombras Dark Suaves */
  --shadow-sm: 0 1px 3px 0 rgba(0, 0, 0, 0.4);
  --shadow-md: 0 4px 10px -1px rgba(0, 0, 0, 0.5), 0 2px 4px -2px rgba(0, 0, 0, 0.4);
  --shadow-lg: 0 10px 20px -3px rgba(0, 0, 0, 0.6), 0 4px 6px -4px rgba(0, 0, 0, 0.4);
  --shadow-xl: 0 20px 25px -5px rgba(0, 0, 0, 0.7);

  /* Raios de Borda */
  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 16px;
  --radius-full: 9999px;

  /* Transições */
  --transition-fast: 0.15s cubic-bezier(0.4, 0, 0.2, 1);
  --transition-normal: 0.25s cubic-bezier(0.4, 0, 0.2, 1);
  --transition-drawer: 0.3s cubic-bezier(0.16, 1, 0.3, 1);

  /* Layout */
  --sidebar-width: 270px;
  --topbar-height: 64px;
}

/* Reset & Box Sizing */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

/* Barras de Rolagem Customizadas (Horizontal e Vertical) */
::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}
::-webkit-scrollbar-track {
  background: var(--bg-surface);
}
::-webkit-scrollbar-thumb {
  background: var(--bg-hover);
  border-radius: var(--radius-full);
  border: 2px solid var(--bg-surface);
}
::-webkit-scrollbar-thumb:hover {
  background: var(--border-medium);
}

body {
  font-family: var(--font-body);
  background-color: var(--bg-app);
  color: var(--text-main);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  overflow-x: hidden;
}

/* Estrutura Principal da Aplicação */
.app-layout {
  display: flex;
  min-height: 100vh;
  position: relative;
  width: 100%;
  overflow-x: auto;
}

/* ==========================================================================
   SIDEBAR MODAL / OFFCANVAS TOGGLEABLE EM QUALQUER RESOLUÇÃO
   ========================================================================== */

.sidebar {
  width: var(--sidebar-width);
  background: var(--bg-surface);
  border-right: 1px solid var(--border-light);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0;
  left: 0;
  bottom: 0;
  z-index: 1000;
  transition: transform var(--transition-drawer), opacity var(--transition-fast);
  box-shadow: var(--shadow-md);
  transform: translateX(0);
}

/* Estado Fechado/Oculto da Sidebar (Desktop e Mobile) */
.sidebar.collapsed {
  transform: translateX(-100%);
}

.sidebar-header {
  height: var(--topbar-height);
  padding: 0 1.25rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid var(--border-light);
}

.brand-area {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  text-decoration: none;
  color: inherit;
  overflow: hidden;
}

.brand-logo-wrap {
  width: 38px;
  height: 38px;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-medium);
  background: #24232C;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  flex-shrink: 0;
}

.brand-logo-img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.brand-titles {
  display: flex;
  flex-direction: column;
  white-space: nowrap;
}

.brand-name {
  font-family: var(--font-title);
  font-size: 1rem;
  font-weight: 700;
  color: var(--text-main);
  line-height: 1.15;
}

.brand-subtitle {
  font-size: 0.68rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-weight: 600;
  color: var(--primary);
}

.btn-sidebar-close {
  background: var(--bg-subtle);
  border: 1px solid var(--border-light);
  color: var(--text-muted);
  cursor: pointer;
  padding: 0.4rem;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all var(--transition-fast);
}

.btn-sidebar-close:hover {
  background: var(--bg-hover);
  color: var(--text-main);
}

/* Menu de Navegação da Sidebar */
.sidebar-nav {
  flex: 1;
  padding: 1rem 0.75rem;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
}

.nav-section-title {
  font-size: 0.68rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-subtle);
  padding: 0.5rem 0.75rem 0.25rem;
  margin-top: 0.5rem;
}

.nav-link {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.65rem 0.85rem;
  border-radius: var(--radius-md);
  color: var(--text-muted);
  text-decoration: none;
  font-size: 0.9rem;
  font-weight: 500;
  transition: all var(--transition-fast);
  border: 1px solid transparent;
  background: transparent;
  width: 100%;
  text-align: left;
  cursor: pointer;
}

.nav-link svg {
  width: 19px;
  height: 19px;
  flex-shrink: 0;
  stroke-width: 1.8;
  color: inherit;
}

.nav-link:hover {
  background: var(--bg-subtle);
  color: var(--text-main);
}

.nav-link.active {
  background: var(--primary);
  color: var(--primary-text);
  font-weight: 600;
  box-shadow: 0 2px 8px rgba(197, 59, 60, 0.35);
}

.nav-link.active svg {
  color: #FFF;
}

.nav-badge {
  margin-left: auto;
  font-size: 0.7rem;
  font-weight: 700;
  padding: 0.15rem 0.45rem;
  border-radius: var(--radius-full);
  background: var(--bg-hover);
  color: var(--text-main);
}

.nav-link.active .nav-badge {
  background: rgba(255, 255, 255, 0.25);
  color: #FFF;
}

/* Rodapé da Sidebar */
.sidebar-footer {
  padding: 0.85rem 1rem;
  border-top: 1px solid var(--border-light);
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: var(--bg-surface);
}

.sync-status-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--success);
}

.sync-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--success);
  box-shadow: 0 0 0 2px var(--success-light);
}

/* Backdrop escuro para fechar a sidebar */
.sidebar-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.65);
  backdrop-filter: blur(3px);
  z-index: 999;
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--transition-normal);
}

.sidebar-backdrop.active {
  opacity: 1;
  pointer-events: auto;
}

/* ==========================================================================
   CONTEÚDO PRINCIPAL & TOPBAR
   ========================================================================== */

.main-wrapper {
  flex: 1;
  display: flex;
  flex-direction: column;
  margin-left: var(--sidebar-width);
  min-height: 100vh;
  transition: margin-left var(--transition-drawer);
  width: calc(100% - var(--sidebar-width));
  overflow-x: auto;
}

.main-wrapper.full-width {
  margin-left: 0;
  width: 100%;
}

/* Topbar Superior */
.topbar {
  height: var(--topbar-height);
  background: var(--bg-surface);
  border-bottom: 1px solid var(--border-light);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 1.5rem;
  position: sticky;
  top: 0;
  z-index: 500;
  box-shadow: var(--shadow-sm);
}

.topbar-left {
  display: flex;
  align-items: center;
  gap: 1rem;
}

.btn-toggle-menu {
  background: var(--bg-subtle);
  border: 1px solid var(--border-light);
  color: var(--text-main);
  width: 38px;
  height: 38px;
  border-radius: var(--radius-md);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all var(--transition-fast);
}

.btn-toggle-menu:hover {
  background: var(--bg-hover);
  border-color: var(--border-medium);
}

.page-current-title {
  font-family: var(--font-title);
  font-size: 1.15rem;
  font-weight: 700;
  color: var(--text-main);
}

.topbar-right {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.topbar-saldo-widget {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  background: var(--bg-subtle);
  border: 1px solid var(--border-medium);
  padding: 0.35rem 0.85rem;
  border-radius: var(--radius-md);
  transition: all var(--transition-fast);
  user-select: none;
}

.topbar-saldo-widget:hover {
  background: var(--bg-hover);
  border-color: var(--border-focus);
}

/* Container de Conteúdo das Abas com Suporte a Rolagem Horizontal */
.content-body {
  flex: 1;
  padding: 1.5rem;
  max-width: 100%;
  width: 100%;
  margin: 0 auto;
  overflow-x: auto;
}

/* Abas com Display Control (sem recarregar página) */
.tab-content {
  display: none;
  animation: fadeIn 0.2s ease-out;
  min-width: 0;
}

.tab-content.active {
  display: block;
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(3px); }
  to { opacity: 1; transform: translateY(0); }
}

/* ==========================================================================
   RESPONSIVIDADE
   ========================================================================== */

@media (max-width: 1024px) {
  .sidebar {
    transform: translateX(-100%);
  }

  .sidebar.open {
    transform: translateX(0);
    box-shadow: var(--shadow-xl);
  }

  .main-wrapper {
    margin-left: 0;
    width: 100%;
  }
}

@media (max-width: 640px) {
  .content-body {
    padding: 1rem 0.75rem;
  }

  .topbar {
    padding: 0 1rem;
  }

  .page-current-title {
    font-size: 1rem;
  }
}
