/* ==========================================================================
   FOLHAS DE CAIXA & TESOURARIA — DESIGN SYSTEM MODERNO & ELEGANTE
   ========================================================================== */

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

:root {
  color-scheme: dark;

  /* Paleta Dark Mode (Predefinido - Elegante & Executivo) */
  --bg-primary: #0a0e17;
  --bg-secondary: #111827;
  --bg-card: rgba(17, 24, 39, 0.75);
  --bg-card-hover: rgba(31, 41, 55, 0.85);
  --bg-glass: rgba(17, 24, 39, 0.65);
  --border-color: rgba(255, 255, 255, 0.08);
  --border-focus: #3b82f6;

  /* Cores de Destaque */
  --primary: #2563eb;
  --primary-hover: #1d4ed8;
  --primary-light: rgba(37, 99, 235, 0.15);
  --primary-glow: rgba(37, 99, 235, 0.35);

  --accent: #8b5cf6;
  --accent-light: rgba(139, 92, 246, 0.15);

  --success: #10b981;
  --success-bg: rgba(16, 185, 129, 0.15);
  --success-glow: rgba(16, 185, 129, 0.35);

  --danger: #ef4444;
  --danger-bg: rgba(239, 68, 68, 0.15);
  --danger-glow: rgba(239, 68, 68, 0.35);

  --warning: #f59e0b;
  --warning-bg: rgba(245, 158, 11, 0.15);

  --info: #06b6d4;
  --info-bg: rgba(6, 182, 212, 0.15);

  /* Variáveis Semânticas para Textos de Métodos e Destaques */
  --metodo-dinheiro: #34d399;
  --metodo-multibanco: #60a5fa;
  --metodo-credito: #a78bfa;
  --metodo-factura-extra: #f59e0b;
  --metodo-danger: #f87171;

  /* Tipografia & Texto */
  --font-heading: 'Outfit', sans-serif;
  --font-body: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  --text-main: #f9fafb;
  --text-muted: #9ca3af;
  --text-sub: #6b7280;

  /* Efeitos */
  --shadow-sm: 0 2px 4px rgba(0, 0, 0, 0.3);
  --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.4);
  --shadow-lg: 0 10px 25px rgba(0, 0, 0, 0.5);
  --shadow-glow: 0 0 20px var(--primary-glow);
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 18px;
  --radius-full: 9999px;
  --transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

[data-theme="light"] {
  color-scheme: light;

  /* Paleta Light Mode (Limpo, Executivo e de Alto Contraste) */
  --bg-primary: #f8fafc;
  --bg-secondary: #ffffff;
  --bg-card: #ffffff;
  --bg-card-hover: #f1f5f9;
  --bg-glass: rgba(255, 255, 255, 0.95);
  --border-color: #e2e8f0;
  --border-focus: #2563eb;

  --primary: #2563eb;
  --primary-hover: #1d4ed8;
  --primary-light: rgba(37, 99, 235, 0.1);
  --primary-glow: rgba(37, 99, 235, 0.2);

  --accent: #7c3aed;
  --accent-light: rgba(124, 58, 237, 0.1);

  --success: #059669;
  --success-bg: rgba(5, 150, 105, 0.12);
  --success-glow: rgba(5, 150, 105, 0.25);

  --danger: #dc2626;
  --danger-bg: rgba(220, 38, 38, 0.1);
  --danger-glow: rgba(220, 38, 38, 0.25);

  --warning: #d97706;
  --warning-bg: rgba(217, 119, 6, 0.12);

  --info: #0284c7;
  --info-bg: rgba(2, 132, 199, 0.12);

  /* Variáveis Semânticas para Textos de Métodos e Destaques no Tema Claro (Alta Legibilidade) */
  --metodo-dinheiro: #047857;
  --metodo-multibanco: #1d4ed8;
  --metodo-credito: #7c3aed;
  --metodo-factura-extra: #d97706;
  --metodo-danger: #dc2626;

  --text-main: #0f172a;
  --text-muted: #475569;
  --text-sub: #64748b;

  --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.06), 0 1px 2px rgba(0, 0, 0, 0.04);
  --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.07), 0 2px 4px -1px rgba(0, 0, 0, 0.04);
  --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.08), 0 4px 6px -2px rgba(0, 0, 0, 0.04);
  --shadow-glow: 0 0 15px rgba(37, 99, 235, 0.15);
}

/* ==========================================================================
   ÍCONES NATIVOS DE CALENDÁRIO / DATA & TIME (DARK & LIGHT MODE)
   ========================================================================== */
input[type="date"],
input[type="datetime-local"],
input[type="month"],
input[type="time"] {
  color-scheme: dark;
}

[data-theme="light"] input[type="date"],
[data-theme="light"] input[type="datetime-local"],
[data-theme="light"] input[type="month"],
[data-theme="light"] input[type="time"] {
  color-scheme: light;
}

/* No tema escuro: Ícone SVG branco com stroke nítido, 100% visível e destacado */
input[type="date"]::-webkit-calendar-picker-indicator,
input[type="datetime-local"]::-webkit-calendar-picker-indicator,
input[type="month"]::-webkit-calendar-picker-indicator,
input[type="time"]::-webkit-calendar-picker-indicator {
  cursor: pointer;
  background-image: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="%23ffffff" stroke-width="2.2" stroke-linecap="round" stroke-linejoin="round"><rect x="3" y="4" width="18" height="18" rx="2" ry="2"></rect><line x1="16" y1="2" x2="16" y2="6"></line><line x1="8" y1="2" x2="8" y2="6"></line><line x1="3" y1="10" x2="21" y2="10"></line></svg>') !important;
  background-repeat: no-repeat !important;
  background-position: center !important;
  background-size: 18px 18px !important;
  width: 22px !important;
  height: 22px !important;
  opacity: 0.95 !important;
  filter: none !important;
  padding: 2px !important;
  border-radius: 4px;
  transition: opacity 0.2s ease, transform 0.2s ease;
}

input[type="date"]::-webkit-calendar-picker-indicator:hover,
input[type="datetime-local"]::-webkit-calendar-picker-indicator:hover {
  opacity: 1 !important;
  transform: scale(1.1);
}

/* No tema claro: Ícone SVG escuro de alto contraste */
[data-theme="light"] input[type="date"]::-webkit-calendar-picker-indicator,
[data-theme="light"] input[type="datetime-local"]::-webkit-calendar-picker-indicator,
[data-theme="light"] input[type="month"]::-webkit-calendar-picker-indicator,
[data-theme="light"] input[type="time"]::-webkit-calendar-picker-indicator {
  background-image: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="%230f172a" stroke-width="2.2" stroke-linecap="round" stroke-linejoin="round"><rect x="3" y="4" width="18" height="18" rx="2" ry="2"></rect><line x1="16" y1="2" x2="16" y2="6"></line><line x1="8" y1="2" x2="8" y2="6"></line><line x1="3" y1="10" x2="21" y2="10"></line></svg>') !important;
  opacity: 0.85 !important;
  filter: none !important;
}

[data-theme="light"] input[type="date"]::-webkit-calendar-picker-indicator:hover,
[data-theme="light"] input[type="datetime-local"]::-webkit-calendar-picker-indicator:hover {
  opacity: 1 !important;
  transform: scale(1.1);
}

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

body {
  font-family: var(--font-body);
  background-color: var(--bg-primary);
  color: var(--text-main);
  line-height: 1.5;
  min-height: 100vh;
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
}

/* Background com Efeito Mesh Gradient Suave */
body::before {
  content: '';
  position: fixed;
  top: -150px;
  left: 20%;
  width: 600px;
  height: 600px;
  background: radial-gradient(circle, rgba(37, 99, 235, 0.08) 0%, rgba(0,0,0,0) 70%);
  pointer-events: none;
  z-index: 0;
}

body::after {
  content: '';
  position: fixed;
  bottom: -150px;
  right: 10%;
  width: 500px;
  height: 500px;
  background: radial-gradient(circle, rgba(139, 92, 246, 0.06) 0%, rgba(0,0,0,0) 70%);
  pointer-events: none;
  z-index: 0;
}

/* Layout Estrutural da Aplicação */
.app-container {
  display: flex;
  min-height: 100vh;
  position: relative;
  z-index: 1;
}

/* Sidebar Moderna */
.sidebar {
  width: 280px;
  background: var(--bg-secondary);
  border-right: 1px solid var(--border-color);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0;
  bottom: 0;
  left: 0;
  z-index: 100;
  transition: var(--transition);
  backdrop-filter: blur(12px);
}

.sidebar-header {
  padding: 24px 20px;
  display: flex;
  align-items: center;
  gap: 14px;
  border-bottom: 1px solid var(--border-color);
}

.sidebar-logo {
  width: 44px;
  height: 44px;
  border-radius: var(--radius-md);
  object-fit: cover;
  box-shadow: 0 4px 10px rgba(0,0,0,0.3);
  border: 1px solid var(--border-color);
}

.brand-text h1 {
  font-family: var(--font-heading);
  font-size: 1.15rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  color: var(--text-main);
  line-height: 1.2;
}

.brand-text span {
  font-size: 0.75rem;
  color: var(--text-muted);
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.sidebar-nav {
  padding: 20px 14px;
  flex: 1;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.nav-section-label {
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-sub);
  padding: 12px 12px 6px 12px;
  font-weight: 600;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 14px;
  border-radius: var(--radius-sm);
  color: var(--text-muted);
  text-decoration: none;
  font-size: 0.92rem;
  font-weight: 500;
  transition: var(--transition);
  cursor: pointer;
  border: 1px solid transparent;
}

.nav-item:hover {
  color: var(--text-main);
  background: rgba(255, 255, 255, 0.04);
  transform: translateX(3px);
}

.nav-item.active {
  color: #ffffff;
  background: linear-gradient(135deg, var(--primary) 0%, #1d4ed8 100%);
  box-shadow: 0 4px 14px var(--primary-glow);
  font-weight: 600;
}

.nav-item svg {
  width: 20px;
  height: 20px;
  flex-shrink: 0;
}

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

.user-snippet {
  display: flex;
  align-items: center;
  gap: 10px;
  overflow: hidden;
}

.user-avatar {
  width: 38px;
  height: 38px;
  border-radius: var(--radius-full);
  background: linear-gradient(135deg, var(--primary), var(--accent));
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 0.95rem;
  flex-shrink: 0;
}

.user-info-text {
  overflow: hidden;
}

.user-name {
  font-size: 0.88rem;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

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

.btn-icon {
  background: transparent;
  border: none;
  color: var(--text-muted);
  width: 34px;
  height: 34px;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: var(--transition);
}

.btn-icon:hover {
  color: var(--text-main);
  background: rgba(255, 255, 255, 0.08);
}

/* Área Principal de Conteúdo */
.main-content {
  margin-left: 280px;
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
}

/* Topbar */
.topbar {
  height: 72px;
  background: var(--bg-glass);
  backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--border-color);
  padding: 0 32px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky;
  top: 0;
  z-index: 90;
}

.topbar-left {
  display: flex;
  align-items: center;
  gap: 18px;
}

.mobile-menu-toggle {
  display: none;
  background: transparent;
  border: none;
  color: var(--text-main);
  cursor: pointer;
}

.page-title-area h2 {
  font-family: var(--font-heading);
  font-size: 1.4rem;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.topbar-right {
  display: flex;
  align-items: center;
  gap: 16px;
}

.date-indicator-badge {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 16px;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-full);
  font-size: 0.85rem;
  font-weight: 500;
  color: var(--text-muted);
}

.date-indicator-badge span.pulse-dot {
  width: 8px;
  height: 8px;
  background: var(--success);
  border-radius: var(--radius-full);
  box-shadow: 0 0 8px var(--success-glow);
}

/* Conteúdo da Página */
.page-view {
  padding: 28px 32px 48px 32px;
  display: none;
  animation: fadeIn 0.3s ease-out;
}

.page-view.active {
  display: block;
}

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

/* Responsividade para Ecrãs Intermédios / Portáteis (1025px - 1440px) */
@media (min-width: 1025px) and (max-width: 1440px) {
  .sidebar {
    width: 240px;
  }
  .main-content {
    margin-left: 240px;
  }
  .page-view {
    padding: 20px 18px 40px 18px;
  }
  .topbar {
    padding: 0 24px;
  }
}

/* Responsividade Básica (Mobile / Tablets) */
@media (max-width: 1024px) {
  .sidebar {
    transform: translateX(-100%);
  }
  .sidebar.open {
    transform: translateX(0);
    box-shadow: 0 0 30px rgba(0,0,0,0.7);
  }
  .main-content {
    margin-left: 0;
  }
  .mobile-menu-toggle {
    display: block;
  }
  .topbar {
    padding: 0 20px;
  }
  .page-view {
    padding: 20px 16px 40px 16px;
  }
}

/* Ajustes de Estrutura para Light Mode */
[data-theme="light"] .nav-item:hover {
  color: var(--text-main);
  background: #f1f5f9;
}

[data-theme="light"] .btn-icon:hover {
  color: var(--text-main);
  background: #f1f5f9;
}

[data-theme="light"] .date-indicator-badge {
  background: #f1f5f9;
  border-color: #cbd5e1;
  color: #334155;
}

[data-theme="light"] .sidebar {
  box-shadow: 2px 0 10px rgba(0, 0, 0, 0.03);
}

[data-theme="light"] .topbar {
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.03);
}

