:root {
  --primary: #080F25;           /* Custom deep navy */
  --primary-dark: #050a1b;      /* Darkest custom navy */
  --primary-light: #182245;     /* Slate highlights/borders */
  --bg: #080F25;                /* Softer dark background */
  --surface: #101935;           /* Custom card surface */
  --surface-light: #182245;     /* Surface light / table headers */
  --text: #f8fafc;              /* Slate 50 text */
  --text-muted: #8f9cae;        /* Softer muted slate text */
  --border: rgba(255, 255, 255, 0.08);   /* Translucent glass border */
  --border-light: rgba(255, 255, 255, 0.04); /* Thin translucent glass border */
  --success: #10b981;
  --danger: #ef4444;
  --warning: #f59e0b;
  --secondary: #d4af37;         /* Elegant Gold */
  --secondary-light: #f3c032;   /* Bright Gold */
  --secondary-dark: #aa841c;    /* Deep Gold */
  --transition-smooth: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

body {
  font-family: 'Inter', sans-serif;
  background-color: var(--bg);
  background-image: 
    radial-gradient(at 0% 0%, rgba(212, 175, 55, 0.03) 0px, transparent 50%),
    radial-gradient(at 100% 100%, rgba(16, 25, 53, 0.6) 0px, transparent 50%);
  background-attachment: fixed;
  color: var(--text);
  margin: 0;
  padding: 0;
  box-sizing: border-box;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

*, *::before, *::after {
  box-sizing: inherit;
}

/* Redirecionamento de fontes para títulos */
h1, h2, h3, h4, h5, h6, .logo-text, .user-name {
  font-family: 'Outfit', sans-serif !important;
}

/* Layout Geral com CSS Grid */
.app-container {
  display: grid;
  grid-template-columns: 260px 1fr;
  grid-template-rows: 64px 1fr auto;
  grid-template-areas: 
    "sidebar header"
    "sidebar content"
    "sidebar footer";
  min-height: 100vh;
  transition: grid-template-columns 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Header */
.app-header {
  grid-area: header;
  background-color: rgba(8, 15, 37, 0.7);
  backdrop-filter: blur(16px) saturate(180%);
  -webkit-backdrop-filter: blur(16px) saturate(180%);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 2rem;
  z-index: 30;
  position: sticky;
  top: 0;
}

.header-left, .header-right {
  display: flex;
  align-items: center;
  gap: 1.25rem;
}

.header-search {
  position: relative;
  width: 320px;
}

.header-search input {
  width: 100%;
  padding: 0.55rem 1rem 0.55rem 2.75rem;
  border: 1px solid var(--border);
  border-radius: 10px;
  background-color: rgba(255, 255, 255, 0.05);
  outline: none;
  font-size: 0.875rem;
  color: var(--text);
  transition: var(--transition-smooth);
}

.header-search input:focus {
  background-color: rgba(255, 255, 255, 0.08);
  border-color: var(--secondary);
  box-shadow: 0 0 0 3px rgba(212, 175, 55, 0.15);
}

.header-search i {
  position: absolute;
  left: 1rem;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-muted);
  font-size: 1.1rem;
}

.user-profile {
  display: flex;
  align-items: center;
  gap: 0.875rem;
  padding: 0.375rem 0.75rem;
  border-radius: 10px;
  transition: var(--transition-smooth);
}

.user-info {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
}

.user-name {
  font-weight: 600;
  font-size: 0.875rem;
  color: var(--text);
}

.user-avatar {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  background-color: var(--secondary);
  color: var(--primary);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 0.875rem;
  border: 1px solid rgba(255, 255, 255, 0.15);
  box-shadow: 0 0 10px rgba(212, 175, 55, 0.2);
}

.notification-btn {
  color: var(--text-muted);
  font-size: 1.5rem;
  text-decoration: none;
  transition: var(--transition-smooth);
  display: flex;
  align-items: center;
  justify-content: center;
  width: 38px;
  height: 38px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background-color: rgba(255, 255, 255, 0.03);
}

.notification-btn:hover {
  color: var(--secondary-light);
  background-color: rgba(255, 255, 255, 0.08);
  border-color: var(--secondary);
}

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

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

/* Sidebar */
.app-sidebar {
  grid-area: sidebar;
  background-color: rgba(8, 15, 37, 0.85);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  z-index: 40;
  position: sticky;
  top: 0;
  height: 100vh;
  transition: width 0.3s cubic-bezier(0.4, 0, 0.2, 1), transform 0.3s ease;
  color: #ffffff;
}

.sidebar-header {
  height: 64px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 1.5rem;
  border-bottom: 1px solid var(--border);
  font-weight: 700;
  font-size: 1.25rem;
  color: var(--secondary);
}

.sidebar-header .text-indigo-600 {
  color: var(--secondary) !important;
}

.sidebar-menu {
  flex: 1;
  overflow-y: auto;
  padding: 1.25rem 0;
}

.sidebar-menu ul {
  list-style: none;
  padding: 0;
  margin: 0;
}

.sidebar-menu li {
  margin: 0.25rem 0.75rem;
}

.sidebar-menu li a {
  display: flex;
  align-items: center;
  padding: 0.65rem 1rem;
  color: var(--text-muted);
  text-decoration: none;
  font-weight: 500;
  font-size: 0.875rem;
  border-radius: 8px;
  transition: var(--transition-smooth);
  gap: 0.75rem;
}

.sidebar-menu li a i,
.sidebar-menu li a .material-symbols-outlined {
  font-size: 1.25rem;
  color: var(--text-muted);
  transition: color 0.2s;
}

.sidebar-menu li a:hover {
  color: #ffffff;
  background-color: rgba(255, 255, 255, 0.05);
}

.sidebar-menu li a:hover i,
.sidebar-menu li a:hover .material-symbols-outlined {
  color: #ffffff;
}

.sidebar-menu li.active > a {
  color: var(--primary) !important;
  background-color: var(--secondary);
  font-weight: 600;
  box-shadow: 0 4px 15px rgba(212, 175, 55, 0.3);
}

.sidebar-menu li.active > a i,
.sidebar-menu li.active > a .material-symbols-outlined {
  color: var(--primary) !important;
}

.sidebar-menu li.has-submenu > ul {
  display: none;
  background-color: rgba(0, 0, 0, 0.3);
  border-radius: 8px;
  margin-top: 0.25rem;
  padding: 0.375rem 0;
  border: 1px solid rgba(255, 255, 255, 0.03);
}

.sidebar-menu li.has-submenu.open > ul {
  display: block;
}

.sidebar-menu li.has-submenu > ul a {
  padding-left: 2.75rem;
  font-size: 0.8rem;
  border-radius: 6px;
  color: var(--text-muted);
}

.sidebar-menu li.has-submenu > ul a:hover {
  color: #ffffff;
  background-color: rgba(255, 255, 255, 0.03);
}

/* Content */
.app-content {
  grid-area: content;
  padding: 2rem;
  background-color: transparent;
  overflow-x: auto;
}

/* Footer */
.app-footer {
  grid-area: footer;
  text-align: center;
  padding: 1.25rem;
  background-color: rgba(8, 15, 37, 0.7);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border-top: 1px solid var(--border);
  color: var(--text-muted);
  font-size: 0.815rem;
}

/* Cards & Glassmorphism */
.card {
  background-color: var(--surface);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border: 1px solid var(--border);
  border-radius: 16px;
  box-shadow: 0 8px 32px 0 rgba(0, 0, 0, 0.2);
  padding: 1.5rem;
  margin-bottom: 1.75rem;
  transition: var(--transition-smooth);
}

.card-hover:hover {
  transform: translateY(-4px);
  background-color: rgba(15, 23, 42, 0.6);
  border-color: rgba(212, 175, 55, 0.3);
  box-shadow: 0 12px 40px 0 rgba(0, 0, 0, 0.3), 0 0 15px rgba(212, 175, 55, 0.1);
}

/* Badges */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 0.25rem 0.625rem;
  border-radius: 9999px;
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.02em;
  border: 1px solid transparent;
}
.badge-primary { 
  background-color: rgba(212, 175, 55, 0.1); 
  color: var(--secondary-light); 
  border-color: rgba(212, 175, 55, 0.2);
}
.badge-secondary { 
  background-color: rgba(255, 255, 255, 0.05); 
  color: var(--text-muted);
  border-color: rgba(255, 255, 255, 0.08);
}
.badge-success { 
  background-color: rgba(16, 185, 129, 0.1); 
  color: #34d399; 
  border-color: rgba(16, 185, 129, 0.2);
}
.badge-warning { 
  background-color: rgba(245, 158, 11, 0.1); 
  color: #fbbf24; 
  border-color: rgba(245, 158, 11, 0.2);
}
.badge-danger { 
  background-color: rgba(239, 68, 68, 0.1); 
  color: #f87171; 
  border-color: rgba(239, 68, 68, 0.2);
}

/* Botões */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0.55rem 1.25rem;
  border-radius: 8px;
  font-weight: 600;
  font-size: 0.875rem;
  cursor: pointer;
  transition: var(--transition-smooth);
  border: 1px solid transparent;
  text-decoration: none;
  gap: 0.5rem;
}
.btn-primary { 
  background-color: var(--secondary) !important; 
  color: var(--primary) !important; 
  border: 1px solid var(--secondary-dark) !important;
  font-weight: 700;
}
.btn-primary:hover { 
  background-color: var(--secondary-light) !important; 
  box-shadow: 0 0 15px rgba(212, 175, 55, 0.4) !important;
  transform: translateY(-2px);
}

.btn-secondary { 
  background-color: #2563eb !important; 
  border-color: #3b82f6 !important; 
  color: #ffffff !important; 
}
.btn-secondary:hover { 
  background-color: #3b82f6 !important; 
  transform: translateY(-2px);
  box-shadow: 0 0 15px rgba(59, 130, 246, 0.4) !important;
}

.btn-success { 
  background-color: #059669 !important; 
  color: #ffffff !important; 
  border: 1px solid #10b981 !important;
}
.btn-success:hover { 
  background-color: #10b981 !important; 
  box-shadow: 0 0 15px rgba(16, 185, 129, 0.4) !important; 
  transform: translateY(-2px);
}

.btn-danger { 
  background-color: #dc2626 !important; 
  color: #ffffff !important; 
  border: 1px solid #ef4444 !important;
}
.btn-danger:hover { 
  background-color: #ef4444 !important; 
  box-shadow: 0 0 15px rgba(239, 68, 68, 0.4) !important; 
  transform: translateY(-2px);
}

.btn-warning { 
  background-color: #d97706 !important; 
  color: #ffffff !important; 
  border: 1px solid #f59e0b !important;
}
.btn-warning:hover { 
  background-color: #f59e0b !important; 
  box-shadow: 0 0 15px rgba(245, 158, 11, 0.4) !important; 
  transform: translateY(-2px);
}

/* Tabelas Glassmorphism */
table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  border-radius: 12px;
  overflow: hidden;
  background-color: rgba(15, 23, 42, 0.25);
  border: 1px solid var(--border);
}

table th {
  padding: 1rem;
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--secondary-light);
  border-bottom: 2px solid var(--border);
  background-color: rgba(15, 23, 42, 0.85);
}

table td {
  padding: 1rem;
  font-size: 0.875rem;
  color: var(--text);
  border-bottom: 1px solid var(--border-light);
}

table tr:last-child td {
  border-bottom: none;
}

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

/* Zebra Striping */
table tbody tr:nth-child(even) {
  background-color: rgba(255, 255, 255, 0.02);
}
table tbody tr:nth-child(odd) {
  background-color: rgba(255, 255, 255, 0.005);
}

/* Row Hover */
table tbody tr:hover {
  background-color: rgba(255, 255, 255, 0.06) !important;
}

/* Inputs, Selects & Forms (Universal adapting) */
input[type="text"], input[type="email"], input[type="password"], input[type="date"], select, textarea {
  background-color: rgba(255, 255, 255, 0.04) !important;
  border: 1px solid var(--border) !important;
  border-radius: 8px !important;
  color: var(--text) !important;
  padding: 0.75rem 1rem !important;
  transition: var(--transition-smooth) !important;
  outline: none !important;
}

input[type="text"]:focus, input[type="email"]:focus, input[type="password"]:focus, input[type="date"]:focus, select:focus, textarea:focus {
  border-color: var(--secondary) !important;
  background-color: rgba(255, 255, 255, 0.08) !important;
  box-shadow: 0 0 0 3px rgba(212, 175, 55, 0.15) !important;
}

/* Make native datepicker calendar icon light in dark mode */
input[type="date"]::-webkit-calendar-picker-indicator {
  filter: invert(1) !important;
  cursor: pointer !important;
}

/* Select pagination limit */
select[name="limite"] {
  min-width: 80px !important;
  padding-top: 0.375rem !important;
  padding-bottom: 0.375rem !important;
  padding-right: 1.75rem !important;
  padding-left: 0.75rem !important;
  height: 38px !important;
  background-position: right 0.5rem center !important;
  background-size: 1.1em !important;
  cursor: pointer !important;
}

select option {
  background-color: #101935 !important;
  color: var(--text) !important;
}

/* Paginação */
nav.flex.gap-1.flex-wrap {
  display: inline-flex !important;
  align-items: center !important;
  gap: 0.375rem !important;
}

nav.flex.gap-1.flex-wrap a,
nav.flex.gap-1.flex-wrap span {
  font-size: 0.875rem !important;
  font-weight: 500 !important;
  color: var(--text-muted) !important;
  background-color: rgba(255, 255, 255, 0.03) !important;
  border: 1px solid var(--border) !important;
  border-radius: 8px !important;
  height: 38px !important;
  display: inline-flex !important;
  align-items: center !important;
  justify-content: center !important;
  text-decoration: none !important;
  transition: var(--transition-smooth) !important;
  box-sizing: border-box !important;
}

nav.flex.gap-1.flex-wrap a:not(:first-child):not(:last-child),
nav.flex.gap-1.flex-wrap span:not(:first-child):not(:last-child) {
  min-width: 38px !important;
  padding: 0 0.5rem !important;
}

nav.flex.gap-1.flex-wrap a:first-child,
nav.flex.gap-1.flex-wrap span:first-child,
nav.flex.gap-1.flex-wrap a:last-child,
nav.flex.gap-1.flex-wrap span:last-child {
  padding: 0 1.25rem !important;
}

nav.flex.gap-1.flex-wrap a:hover {
  background-color: rgba(255, 255, 255, 0.08) !important;
  border-color: var(--secondary) !important;
  color: var(--text) !important;
}

nav.flex.gap-1.flex-wrap a.bg-\[\#0A192F\],
nav.flex.gap-1.flex-wrap a.bg-indigo-600,
nav.flex.gap-1.flex-wrap a[class*="bg-[#0A192F]"] {
  background-color: var(--secondary) !important;
  color: var(--primary) !important;
  border-color: var(--secondary-dark) !important;
  font-weight: 700 !important;
  box-shadow: 0 0 10px rgba(212, 175, 55, 0.3) !important;
}

nav.flex.gap-1.flex-wrap span.cursor-not-allowed,
nav.flex.gap-1.flex-wrap span.bg-gray-50 {
  color: rgba(255, 255, 255, 0.15) !important;
  background-color: rgba(255, 255, 255, 0.01) !important;
  border-color: rgba(255, 255, 255, 0.04) !important;
  cursor: not-allowed !important;
  opacity: 0.5 !important;
}



/* Logout Button */
.logout-btn {
  text-decoration: none !important;
}
.logout-btn:hover {
  background-color: rgba(239, 68, 68, 0.15) !important;
  border-color: rgba(239, 68, 68, 0.3) !important;
  text-decoration: none !important;
}

/* Custom Overrides for Hardcoded Tailwind Colors to Keep Dark Mode Clean */
.text-slate-900, .text-slate-800, .text-slate-700, .text-gray-900, .text-gray-800, .text-indigo-900, .text-gray-950 {
  color: var(--text) !important;
}

.text-slate-500, .text-slate-600, .text-slate-400, .text-gray-500, .text-gray-600, .text-gray-700 {
  color: var(--text-muted) !important;
}

.bg-white, .bg-slate-100 {
  background-color: var(--surface) !important;
}

.bg-gray-50\/50, .bg-gray-50, .bg-slate-50\/50, .bg-slate-50 {
  background-color: rgba(255, 255, 255, 0.02) !important;
}

.border-gray-100, .border-gray-200, .border-slate-100, .border-slate-200 {
  border-color: var(--border) !important;
}

.bg-slate-100.text-\[\#0A192F\], .bg-emerald-50, .bg-blue-50, .bg-amber-50 {
  background-color: rgba(255, 255, 255, 0.04) !important;
  border: 1px solid var(--border) !important;
}

/* Specific KPI Colors overriding for theme consistency */
.bg-emerald-50 i { color: #34d399 !important; }
.bg-blue-50 i { color: #60a5fa !important; }
.bg-amber-50 i { color: #fbbf24 !important; }
.bg-slate-100 i { color: var(--secondary-light) !important; }

/* SweetAlert2 Theme Customization for Dark Mode */
.swal2-popup {
  background: #0f172a !important;
  color: #f8fafc !important;
  border: 1px solid rgba(255, 255, 255, 0.08) !important;
  backdrop-filter: blur(12px) !important;
}
.swal2-title {
  color: #f8fafc !important;
  font-family: 'Outfit', sans-serif !important;
}
.swal2-html-container {
  color: #94a3b8 !important;
}

/* Responsividade */
@media (max-width: 1024px) {
  .header-search { width: 220px; }
}

@media (max-width: 768px) {
  .app-container {
    grid-template-columns: 1fr;
    grid-template-areas: 
      "header"
      "content"
      "footer";
  }
  
  .app-sidebar {
    position: fixed;
    left: 0;
    top: 0;
    bottom: 0;
    width: 260px;
    transform: translateX(-100%);
    box-shadow: 4px 0 20px rgba(0,0,0,0.5);
  }
  
  .app-sidebar.show {
    transform: translateX(0);
  }

  .sidebar-header {
    justify-content: space-between;
    padding: 0 1.5rem;
  }

  .close-sidebar {
    display: block;
  }
  
  .hamburger {
    display: flex !important;
  }
  
  .header-search { display: none; }
  .user-info { display: none; }
  
  .toggle-sidebar-btn {
    display: none !important;
  }
}

/* Collapsed Sidebar Styles on Desktop */
@media (min-width: 769px) {
  .app-container.collapsed {
    grid-template-columns: 70px 1fr;
  }
  
  .app-container.collapsed .app-sidebar {
    width: 70px;
    overflow: hidden;
  }
  
  .app-container.collapsed .logo-text {
    display: none;
  }
  
  .app-container.collapsed .sidebar-header {
    justify-content: center;
    padding: 0;
  }
  
  .app-container.collapsed .toggle-icon {
    transform: rotate(180deg);
  }
  
  .app-container.collapsed .sidebar-menu li {
    margin: 0.25rem 0.35rem;
  }

  .app-container.collapsed .sidebar-menu li a {
    justify-content: center;
    padding: 0.65rem 0;
  }
  
  .app-container.collapsed .sidebar-menu li a .menu-text {
    display: none;
  }
  
  .app-container.collapsed .sidebar-menu li a i,
  .app-container.collapsed .sidebar-menu li a .material-symbols-outlined {
    margin: 0;
  }
  
  .app-container.collapsed .sidebar-menu li.has-submenu > ul {
    display: none !important;
  }
  
  .app-container.collapsed .sidebar-menu li.has-submenu a span:last-child {
    display: none;
  }
}
