@import url('https://fonts.googleapis.com/css2?family=Outfit:wght@300;400;500;600;700&display=swap');

:root {
  /* Light Mode Palette (Default) */
  --bg-app: #f9fafb;
  --bg-sidebar: #ffffff;
  --border-color: #f1f5f9;
  --border-strong: #e2e8f0;
  --text-primary: #0f172a;
  --text-secondary: #475569;
  --text-muted: #94a3b8;
  --accent-purple: #6d28d9; /* Deep Grape */
  --accent-purple-hover: #5b21b6;
  --accent-purple-light: #f5f3ff;
  --accent-green: #10b981; /* Emerald */
  --accent-green-light: #ecfdf5;
  --accent-red: #f43f5e; /* Rose */
  --accent-red-light: #fff1f2;
  --accent-gold: #d97706; /* Warm Gold */
  --accent-gold-light: #fef3c7;
  --card-bg: #ffffff;
  --card-shadow: 0 1px 3px 0 rgba(0, 0, 0, 0.02), 0 1px 2px -1px rgba(0, 0, 0, 0.02), 0 0 0 1px rgba(0, 0, 0, 0.04);
  --header-bg: rgba(255, 255, 255, 0.8);
  --glass-shadow: 0 8px 32px 0 rgba(31, 38, 135, 0.04);
  --radius: 12px;
  --transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

.dark-mode {
  /* Dark Mode Palette */
  --bg-app: #030712; /* Charcoal black */
  --bg-sidebar: #090d16;
  --border-color: #1f2937;
  --border-strong: #374151;
  --text-primary: #f9fafb;
  --text-secondary: #9ca3af;
  --text-muted: #6b7280;
  --accent-purple: #8b5cf6;
  --accent-purple-hover: #a78bfa;
  --accent-purple-light: rgba(139, 92, 246, 0.1);
  --accent-green: #10b981;
  --accent-green-light: rgba(16, 185, 129, 0.1);
  --accent-red: #f43f5e;
  --accent-red-light: rgba(244, 63, 94, 0.1);
  --accent-gold: #f59e0b;
  --accent-gold-light: rgba(245, 158, 11, 0.1);
  --card-bg: #0b0f19;
  --card-shadow: 0 0 0 1px rgba(255, 255, 255, 0.04), 0 4px 20px 0 rgba(0, 0, 0, 0.4);
  --header-bg: rgba(9, 13, 22, 0.8);
  --glass-shadow: 0 8px 32px 0 rgba(0, 0, 0, 0.3);
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: 'Outfit', sans-serif;
  background-color: var(--bg-app);
  color: var(--text-primary);
  transition: var(--transition);
  display: flex;
  min-height: 100vh;
  overflow-x: hidden;
}

/* Scrollbar Stylings */
::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}
::-webkit-scrollbar-track {
  background: transparent;
}
::-webkit-scrollbar-thumb {
  background: var(--border-strong);
  border-radius: 9999px;
}
::-webkit-scrollbar-thumb:hover {
  background: var(--text-muted);
}

/* =========================================================================
   LAYOUT PRINCIPAL
   ========================================================================= */

/* Sidebar */
.sidebar {
  width: 260px;
  background-color: var(--bg-sidebar);
  border-right: 1px solid var(--border-color);
  padding: 24px;
  display: flex;
  flex-direction: column;
  height: 100vh;
  position: fixed;
  left: 0;
  top: 0;
  z-index: 100;
  transition: var(--transition);
}

.brand-section {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 32px;
}

.brand-logo {
  width: 38px;
  height: 38px;
  border-radius: 10px;
  background: linear-gradient(135deg, var(--accent-purple), var(--accent-gold));
  display: flex;
  align-items: center;
  justify-content: center;
  color: #ffffff;
  font-weight: 700;
  font-size: 1.2rem;
  box-shadow: 0 4px 12px rgba(109, 40, 217, 0.2);
}

.brand-info {
  display: flex;
  flex-direction: column;
}

.brand-name {
  font-weight: 600;
  font-size: 1.1rem;
  line-height: 1.2;
}

.brand-sub {
  font-size: 0.75rem;
  color: var(--text-muted);
  letter-spacing: 0.5px;
}

.nav-menu {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 6px;
  flex-grow: 1;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 14px;
  border-radius: 8px;
  color: var(--text-secondary);
  text-decoration: none;
  font-weight: 500;
  font-size: 0.95rem;
  cursor: pointer;
  transition: var(--transition);
}

.nav-item:hover, .nav-item.active {
  color: var(--text-primary);
  background-color: var(--accent-purple-light);
}

.nav-item.active {
  color: var(--accent-purple);
}

.nav-item svg {
  width: 18px;
  height: 18px;
  transition: var(--transition);
}

.nav-item:hover svg, .nav-item.active svg {
  transform: translateX(2px);
}

.sidebar-footer {
  padding-top: 16px;
  border-top: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.user-profile-badge {
  display: flex;
  align-items: center;
  gap: 10px;
}

.avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: var(--accent-purple-light);
  color: var(--accent-purple);
  font-weight: 600;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.9rem;
}

.avatar-info {
  display: flex;
  flex-direction: column;
}

.avatar-name {
  font-weight: 500;
  font-size: 0.85rem;
}

.avatar-role {
  font-size: 0.7rem;
  color: var(--text-muted);
}

/* Area de Conteúdo Principal */
.main-layout {
  flex-grow: 1;
  margin-left: 260px;
  padding: 40px;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  transition: var(--transition);
}

/* Header superior */
.header-wrapper {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 32px;
}

.page-title {
  font-size: 1.8rem;
  font-weight: 700;
  letter-spacing: -0.5px;
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 14px;
}

/* =========================================================================
   ELEMENTOS DE INTERFACE REUTILIZÁVEIS E COMPONENTES COMUNS
   ========================================================================= */

/* Botões */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 8px 16px;
  border-radius: 8px;
  font-weight: 500;
  font-size: 0.9rem;
  cursor: pointer;
  transition: var(--transition);
  border: 1px solid transparent;
  outline: none;
  font-family: inherit;
}

.btn-primary {
  background-color: var(--accent-purple);
  color: #ffffff;
}

.btn-primary:hover {
  background-color: var(--accent-purple-hover);
  box-shadow: 0 4px 12px rgba(109, 40, 217, 0.2);
}

.btn-secondary {
  background-color: var(--card-bg);
  border-color: var(--border-strong);
  color: var(--text-secondary);
}

.btn-secondary:hover {
  background-color: var(--border-color);
  color: var(--text-primary);
}

.btn-circle {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  background-color: var(--card-bg);
  border: 1px solid var(--border-strong);
  color: var(--text-secondary);
  cursor: pointer;
  transition: var(--transition);
}

.btn-circle:hover {
  background-color: var(--border-color);
  color: var(--text-primary);
}

/* Switer de tema */
.theme-switch {
  position: relative;
  display: inline-block;
  width: 48px;
  height: 24px;
}

.theme-switch input {
  opacity: 0;
  width: 0;
  height: 0;
}

.slider {
  position: absolute;
  cursor: pointer;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background-color: var(--border-strong);
  transition: .4s;
  border-radius: 34px;
}

.slider:before {
  position: absolute;
  content: "";
  height: 18px;
  width: 18px;
  left: 3px;
  bottom: 3px;
  background-color: white;
  transition: .4s;
  border-radius: 50%;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

input:checked + .slider {
  background-color: var(--accent-purple);
}

input:checked + .slider:before {
  transform: translateX(24px);
}

/* Cards */
.card {
  background-color: var(--card-bg);
  border-radius: var(--radius);
  padding: 24px;
  box-shadow: var(--card-shadow);
  transition: var(--transition);
  border: 1px solid var(--border-color);
}

.card:hover {
  transform: translateY(-2px);
  box-shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.05), 0 8px 10px -6px rgba(0, 0, 0, 0.05), var(--card-shadow);
}

.card-title {
  font-size: 0.85rem;
  text-transform: uppercase;
  color: var(--text-muted);
  font-weight: 600;
  letter-spacing: 0.7px;
  margin-bottom: 8px;
}

.card-value {
  font-size: 1.8rem;
  font-weight: 700;
  margin-bottom: 6px;
}

.card-desc {
  font-size: 0.78rem;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  gap: 4px;
}

.trend-up {
  color: var(--accent-green);
  font-weight: 600;
}

.trend-down {
  color: var(--accent-red);
  font-weight: 600;
}

/* =========================================================================
   DASHBOARD / METRICS GRID
   ========================================================================= */

.metrics-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 20px;
  margin-bottom: 24px;
}

.dashboard-layout {
  display: grid;
  grid-template-columns: 2fr 1fr;
  gap: 24px;
  margin-bottom: 24px;
}

.chart-card {
  grid-column: span 1;
}

.top-contributors-card {
  grid-column: span 1;
}

/* Listas compactas */
.list-compact {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin-top: 14px;
}

.list-item-compact {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px;
  border-radius: 8px;
  background-color: var(--bg-app);
  border: 1px solid var(--border-color);
  transition: var(--transition);
}

.list-item-compact:hover {
  background-color: var(--card-bg);
  border-color: var(--border-strong);
}

.item-main-info {
  display: flex;
  align-items: center;
  gap: 10px;
}

.item-avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--accent-purple-light);
  color: var(--accent-purple);
  font-weight: 600;
  font-size: 0.8rem;
  display: flex;
  align-items: center;
  justify-content: center;
}

.item-title {
  font-size: 0.88rem;
  font-weight: 500;
}

.item-subtitle {
  font-size: 0.72rem;
  color: var(--text-muted);
}

.item-value {
  font-weight: 600;
  font-size: 0.88rem;
}

/* =========================================================================
   TABELAS E LISTAGENS DETALHADAS
   ========================================================================= */

.data-table-wrapper {
  background-color: var(--card-bg);
  border-radius: var(--radius);
  box-shadow: var(--card-shadow);
  border: 1px solid var(--border-color);
  overflow: hidden;
  margin-bottom: 24px;
}

.table-header {
  padding: 20px 24px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-bottom: 1px solid var(--border-color);
  flex-wrap: wrap;
  gap: 16px;
}

.search-box {
  position: relative;
  display: flex;
  align-items: center;
}

.search-box input {
  padding: 8px 12px 8px 36px;
  border-radius: 8px;
  border: 1px solid var(--border-strong);
  background-color: var(--bg-app);
  color: var(--text-primary);
  font-family: inherit;
  font-size: 0.88rem;
  outline: none;
  width: 250px;
  transition: var(--transition);
}

.search-box input:focus {
  border-color: var(--accent-purple);
  width: 300px;
  background-color: var(--card-bg);
}

.search-box svg {
  position: absolute;
  left: 12px;
  width: 16px;
  height: 16px;
  color: var(--text-muted);
}

.table-filters {
  display: flex;
  align-items: center;
  gap: 10px;
}

.filter-select {
  padding: 8px 12px;
  border-radius: 8px;
  border: 1px solid var(--border-strong);
  background-color: var(--card-bg);
  color: var(--text-secondary);
  font-family: inherit;
  font-size: 0.85rem;
  outline: none;
  cursor: pointer;
}

.filter-select:focus {
  border-color: var(--accent-purple);
}

.data-table {
  width: 100%;
  border-collapse: collapse;
  text-align: left;
}

.data-table th {
  padding: 12px 24px;
  font-size: 0.78rem;
  font-weight: 600;
  text-transform: uppercase;
  color: var(--text-muted);
  border-bottom: 1px solid var(--border-color);
  background-color: var(--bg-sidebar);
}

.data-table td {
  padding: 14px 24px;
  font-size: 0.88rem;
  border-bottom: 1px solid var(--border-color);
  color: var(--text-secondary);
}

.data-table tbody tr {
  transition: var(--transition);
}

.data-table tbody tr:hover {
  background-color: var(--accent-purple-light);
}

/* Badges */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 2px 8px;
  border-radius: 9999px;
  font-size: 0.75rem;
  font-weight: 600;
}

.badge-income {
  background-color: var(--accent-green-light);
  color: var(--accent-green);
}

.badge-expense {
  background-color: var(--accent-red-light);
  color: var(--accent-red);
}

.badge-warning {
  background-color: var(--accent-gold-light);
  color: var(--accent-gold);
}

.badge-info {
  background-color: var(--accent-purple-light);
  color: var(--accent-purple);
}

/* =========================================================================
   SEÇÃO DE DIZIMISTAS & ORÇAMENTOS (WIDGETS ADICIONAIS)
   ========================================================================= */

.dizimistas-dashboard {
  display: grid;
  grid-template-columns: 1fr 1.5fr;
  gap: 24px;
  margin-bottom: 24px;
}

.budget-list {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.budget-progress-container {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.budget-meta-header {
  display: flex;
  justify-content: space-between;
  font-size: 0.85rem;
  font-weight: 500;
}

.budget-progress-bar-bg {
  height: 8px;
  background-color: var(--border-strong);
  border-radius: 9999px;
  overflow: hidden;
  position: relative;
}

.budget-progress-bar-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--accent-purple), var(--accent-gold));
  border-radius: 9999px;
  transition: width 0.6s cubic-bezier(0.4, 0, 0.2, 1);
}

.budget-progress-bar-fill.overflow {
  background: var(--accent-red);
}

/* =========================================================================
   SISTEMA DE MODAIS / DRAWERS (GAVETAS LATERAIS)
   ========================================================================= */

.modal-backdrop {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background-color: rgba(15, 23, 42, 0.4);
  backdrop-filter: blur(4px);
  z-index: 1000;
  display: flex;
  align-items: flex-start; /* Alinhamento flex-start para permitir scroll a partir do topo */
  justify-content: center;
  opacity: 0;
  pointer-events: none;
  transition: var(--transition);
  overflow-y: auto; /* Scroll vertical ativo no backdrop se o modal for maior que a tela */
  padding: 40px 16px; /* Respiro superior/inferior em telas pequenas */
}

.modal-backdrop.open {
  opacity: 1;
  pointer-events: auto;
}

.modal-content {
  background-color: var(--card-bg);
  border-radius: var(--radius);
  width: 90%;
  max-width: 500px;
  padding: 32px;
  box-shadow: var(--glass-shadow);
  border: 1px solid var(--border-color);
  transform: scale(0.9);
  transition: var(--transition);
  margin: auto; /* Centralização automática em telas grandes, preservando alinhamento ao rolar */
}

.modal-backdrop.open .modal-content {
  transform: scale(1);
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 24px;
}

.modal-close {
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 1.5rem;
}

.modal-close:hover {
  color: var(--text-primary);
}

/* Formulários */
.form-group {
  margin-bottom: 16px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.form-group label {
  font-size: 0.85rem;
  font-weight: 500;
  color: var(--text-secondary);
}

.form-control {
  width: 100%;
  box-sizing: border-box;
  padding: 10px 14px;
  border-radius: 8px;
  border: 1px solid var(--border-strong);
  background-color: var(--bg-app);
  color: var(--text-primary);
  font-family: inherit;
  font-size: 0.9rem;
  outline: none;
  transition: var(--transition);
}

.form-control:focus {
  border-color: var(--accent-purple);
  background-color: var(--card-bg);
}

/* Gaveta da IA (Drawer) */
.drawer-backdrop {
  position: fixed;
  top: 0;
  right: 0;
  width: 100vw;
  height: 100vh;
  background-color: rgba(15, 23, 42, 0.3);
  backdrop-filter: blur(2px);
  z-index: 1000;
  opacity: 0;
  pointer-events: none;
  transition: var(--transition);
}

.drawer-backdrop.open {
  opacity: 1;
  pointer-events: auto;
}

.drawer-content {
  position: absolute;
  top: 0;
  right: 0;
  width: 420px;
  height: 100vh;
  background-color: var(--card-bg);
  box-shadow: -8px 0 32px rgba(0, 0, 0, 0.1);
  border-left: 1px solid var(--border-color);
  padding: 32px;
  display: flex;
  flex-direction: column;
  transform: translateX(100%);
  transition: var(--transition);
}

.drawer-backdrop.open .drawer-content {
  transform: translateX(0);
}

/* Painel de Lançamento de IA */
.ai-voice-panel {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 24px;
  border-radius: 12px;
  background-color: var(--bg-app);
  border: 2px dashed var(--border-strong);
  margin-bottom: 24px;
  text-align: center;
  position: relative;
  overflow: hidden;
}

.mic-button {
  width: 64px;
  height: 64px;
  border-radius: 50%;
  background-color: var(--accent-purple-light);
  color: var(--accent-purple);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: var(--transition);
  margin-bottom: 12px;
  box-shadow: 0 4px 12px rgba(139, 92, 246, 0.15);
  border: none;
}

.mic-button:hover, .mic-button.recording {
  background-color: var(--accent-purple);
  color: #ffffff;
  transform: scale(1.05);
}

.mic-button.recording {
  animation: pulse 1.5s infinite;
}

@keyframes pulse {
  0% { box-shadow: 0 0 0 0 rgba(139, 92, 246, 0.6); }
  70% { box-shadow: 0 0 0 15px rgba(139, 92, 246, 0); }
  100% { box-shadow: 0 0 0 0 rgba(139, 92, 246, 0); }
}

.ai-transcription-box {
  width: 100%;
  padding: 12px;
  background: var(--card-bg);
  border-radius: 8px;
  border: 1px solid var(--border-strong);
  min-height: 60px;
  font-size: 0.85rem;
  color: var(--text-secondary);
  margin-top: 14px;
  text-align: left;
}

.ai-suggestions-box {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin-top: 16px;
  flex-grow: 1;
  overflow-y: auto;
}

.suggestion-card {
  padding: 14px;
  border-radius: 10px;
  border: 1px solid var(--border-color);
  background-color: var(--bg-app);
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.suggestion-header {
  display: flex;
  justify-content: space-between;
  font-size: 0.72rem;
  text-transform: uppercase;
  color: var(--text-muted);
  font-weight: 600;
}

.suggestion-val {
  font-size: 1.1rem;
  font-weight: 700;
}

/* =========================================================================
   SEMANAS MENSAL GRID
   ========================================================================= */
.weeks-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}

.week-card {
  background-color: var(--card-bg);
  padding: 18px;
  border-radius: 10px;
  border: 1px solid var(--border-color);
  text-align: center;
  box-shadow: var(--card-shadow);
}

.week-title {
  font-size: 0.8rem;
  text-transform: uppercase;
  font-weight: 600;
  color: var(--text-muted);
  margin-bottom: 8px;
}

.week-value {
  font-size: 1.3rem;
  font-weight: 700;
}

/* Roteamento de telas */
.page-screen {
  display: none;
}

.page-screen.active {
  display: flex;
  flex-direction: column;
}

/* =========================================================================
   MEDIA QUERIES (MOBILE E RESPONSIVIDADE)
   ========================================================================= */

@media (max-width: 900px) {
  .sidebar {
    width: 70px;
    padding: 16px 8px;
    align-items: center;
  }
  .brand-name, .brand-sub, .avatar-info, .sidebar-footer {
    display: none;
  }
  .nav-item {
    justify-content: center;
    padding: 12px;
  }
  .nav-item span {
    display: none;
  }
  .main-layout {
    margin-left: 70px;
    padding: 20px;
  }
  .dashboard-layout {
    grid-template-columns: 1fr;
  }
  .dizimistas-dashboard {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 600px) {
  .sidebar {
    height: 60px;
    width: 100vw;
    top: auto;
    bottom: 0;
    flex-direction: row;
    justify-content: space-around;
    padding: 0;
    border-right: none;
    border-top: 1px solid var(--border-color);
  }
  .brand-section {
    display: none;
  }
  .nav-menu {
    flex-direction: row;
    justify-content: space-around;
    width: 100%;
  }
  .main-layout {
    margin-left: 0;
    margin-bottom: 60px;
    padding: 16px;
  }
  .header-wrapper {
    flex-direction: column;
    align-items: flex-start;
    gap: 12px;
  }
}

/* Custom Active Sub-Tab Style */
.btn.active-subtab {
  background-color: var(--accent-purple-light) !important;
  color: var(--accent-purple) !important;
  border-color: var(--accent-purple) !important;
  font-weight: 600;
}

/* Grid layout responsivo para o modal de Gerenciar Equipe */
.users-grid-layout {
  display: grid;
  grid-template-columns: 1.2fr 1fr;
  gap: 24px;
  text-align: left;
}

.users-list-pane {
  border-right: 1px solid var(--border-color);
  padding-right: 24px;
}

@media (max-width: 650px) {
  .users-grid-layout {
    grid-template-columns: 1fr;
    gap: 24px;
  }
  .users-list-pane {
    border-right: none;
    border-bottom: 1px solid var(--border-color);
    padding-right: 0;
    padding-bottom: 24px;
  }
}

/* Ocultar elementos do painel antes da autenticação (evita flash visual antes do redirecionamento) */
body:not(.authenticated) .sidebar,
body:not(.authenticated) .main-layout {
  display: none !important;
}



