:root {
  /* Paleta Principal */
  --background: 221 39% 11%;
  --foreground: 220 13% 91%;
  --primary: 188 95% 53%;
  --secondary: 221 83% 53%;
  --card: 220 23% 15%;
  --border: 217 19% 27%;

  /* Gradientes */
  --gradient-primary: linear-gradient(135deg, hsl(221, 83%, 53%), hsl(188, 95%, 53%));
  --gradient-card: linear-gradient(145deg, hsl(220, 23%, 15%), hsl(220, 23%, 18%));

  /* Sombras */
  --shadow-soft: 0 4px 20px -4px hsl(221, 39%, 8%);
  --shadow-glow: 0 0 40px hsla(188, 95%, 53%, 0.15);
  --shadow-card: 0 8px 32px -8px hsl(221, 39%, 6%);

  /* Transições */
  --transition-smooth: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  --transition-bounce: all 0.5s cubic-bezier(0.68, -0.55, 0.265, 1.55);
}

body {
  background: hsl(var(--background));
  color: hsl(var(--foreground));
  font-family: system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
  margin: 0;
  padding: 0;
  min-height: 100vh;
}

.bg-card {
  background: var(--gradient-card);
}

.bg-primary-grad {
  background: var(--gradient-primary);
}

.border-default {
  border-color: hsl(var(--border));
}

.text-foreground {
  color: hsl(var(--foreground));
}

.text-muted {
  color: hsla(220, 13%, 91%, 0.7);
}

.ring-default {
  box-shadow: 0 0 0 1px hsl(var(--border)) inset;
}

.shadow-soft {
  box-shadow: var(--shadow-soft);
}

.shadow-card {
  box-shadow: var(--shadow-card);
}

.shadow-glow {
  box-shadow: var(--shadow-glow);
}

.transition-smooth {
  transition: var(--transition-smooth);
}

.transition-bounce {
  transition: var(--transition-bounce);
}

/* Column visibility checkbox dropdown styles */
.column-checkbox {
  background-color: hsl(var(--card));
  border: 1px solid hsl(var(--border));
  color: hsl(var(--foreground));
  accent-color: hsl(var(--primary));
}

.column-checkbox:checked {
  background-color: hsl(var(--primary));
  border-color: hsl(var(--primary));
}

.column-checkbox:focus {
  outline: none;
  box-shadow: 0 0 0 2px hsla(188, 95%, 53%, 0.3);
}

#column-visibility-dropdown {
  background: hsl(var(--card));
  backdrop-filter: blur(10px);
  box-shadow: var(--shadow-card);
}

#column-visibility-dropdown label:hover {
  background-color: hsla(220, 13%, 91%, 0.05);
}

/* Login page specific styles */
.login-container {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  padding: 1rem;
}

.login-card {
  width: 100%;
  max-width: 400px;
  padding: 2rem;
  border-radius: 1rem;
  border: 1px solid hsl(var(--border));
}

.login-logo {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin-bottom: 2rem;
}

.login-logo-icon {
  height: 2.5rem;
  width: 2.5rem;
  border-radius: 0.5rem;
  background: white/10%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: bold;
  color: white;
}

.form-group {
  margin-bottom: 1.5rem;
}

.form-label {
  display: block;
  margin-bottom: 0.5rem;
  font-size: 0.875rem;
}

.form-input {
  width: 100%;
  padding: 0.75rem 1rem;
  border-radius: 0.5rem;
  background: transparent;
  border: 1px solid hsl(var(--border));
  color: hsl(var(--foreground));
  outline: none;
  transition: var(--transition-smooth);
}

.form-input:focus {
  border-color: hsl(var(--primary));
  box-shadow: 0 0 0 2px hsla(var(--primary), 0.2);
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0.75rem 1.5rem;
  border-radius: 0.5rem;
  font-weight: 500;
  cursor: pointer;
  transition: var(--transition-bounce);
  border: none;
  text-align: center;
  width: 100%;
}

.btn-primary {
  background: var(--gradient-primary);
  color: white;
}

.btn-primary:hover {
  opacity: 0.9;
  transform: translateY(-2px);
}

.error-message {
  color: #ff4d6d;
  font-size: 0.875rem;
  margin-top: 0.5rem;
}

/* Select2 dark theme tweaks */
.select2-container .select2-selection--single {
  height: 42px;
  background: hsl(var(--background));
  border-color: hsl(var(--border));
  color: hsl(var(--foreground));
}

.select2-container--default .select2-selection--single .select2-selection__rendered {
  color: hsl(var(--foreground));
  line-height: 42px;
}

.select2-container--default .select2-selection--single .select2-selection__arrow {
  height: 42px;
}

/* Multiple selection styling */
.select2-container--default .select2-selection--multiple {
  background-color: hsl(var(--background)) !important;
  border-color: hsl(var(--border));
  min-height: 42px;
  padding: 4px;
}

.select2-selection__choice__display {
  padding-left: 12px !important;
}

.select2-selection__choice__remove {
  border-right: 0px !important;
}

.select2-container--default .select2-selection--multiple .select2-selection__choice {
  background-color: hsl(var(--card)) !important;
  ;
  color: hsl(var(--foreground));
  border-color: hsl(var(--border));
  padding: 4px 8px;
  margin: 2px;
  border-radius: 4px;
}

.select2-container--default .select2-selection--multiple .select2-selection__choice__remove {
  color: hsl(var(--foreground));
  margin-right: 6px;
}

.select2-container--default .select2-selection--multiple .select2-selection__choice__remove:hover {
  color: hsl(var(--primary));
}

.select2-container--default.select2-container--focus .select2-selection--multiple {
  border-color: hsl(var(--primary));
  outline: none;
}

.select2-container--default .select2-search--inline .select2-search__field {
  color: hsl(var(--foreground));
  margin-top: 0;
  padding-left: 6px;
}

.select2-dropdown {
  background: hsl(var(--card));
  border-color: hsl(var(--border));
  color: hsl(var(--foreground));
}

.select2-results__option {
  color: hsl(var(--foreground));
  padding: 8px 12px;
}

.select2-container--default .select2-results__option--highlighted[aria-selected] {
  background-color: hsla(188, 95%, 53%, 0.2) !important;
  color: hsl(var(--foreground));
}

.select2-container--default .select2-results__option[aria-selected=true] {
  background-color: hsla(188, 95%, 53%, 0.4) !important;
  color: hsl(var(--foreground));
}

/* Fix para hover em itens selecionados - mantém a cor de seleção */
.select2-container--default .select2-results__option[aria-selected=true]:hover,
.select2-container--default .select2-results__option[aria-selected=true].select2-results__option--highlighted {
  background-color: hsla(188, 95%, 53%, 0.4) !important;
  color: hsl(var(--foreground));
}

.select2-search__field {
  background: hsl(var(--background));
  color: hsl(var(--foreground));
  border-color: hsl(var(--border));
  padding: 6px 8px;
}

/* Large dropdown for selects */
.select2-dropdown-large {
  width: auto !important;
  min-width: 100%;
  max-width: 500px !important;
}

.select2-dropdown-large .select2-results__option {
  white-space: normal;
  word-break: break-word;
}

/* Fix for open dropdown container size */
.select2-container--open {
  min-width: 320px;
  width: 320px;
  max-width: 320px;
  z-index: 9999;
}

/* Dashboard layout */
.dashboard-container {
  display: flex;
  min-height: 100vh;
  position: relative;
}

.sidebar {
  width: 16rem;
  border-right: 1px solid hsla(var(--border), 0.6);
  padding: 1rem;
  transition: var(--transition-smooth);
  position: relative;
  overflow: visible;
}

.sidebar.collapsed {
  width: 4rem;
  overflow: visible;
}

.sidebar.collapsed .sidebar-content {
  opacity: 0;
  visibility: hidden;
  overflow: hidden;
}

.sidebar.collapsed .sidebar-toggle {
  transform: rotate(180deg);
  right: -0.5rem;
  background: hsl(var(--primary));
  color: white;
  box-shadow: var(--shadow-soft);
}

.sidebar.collapsed .sidebar-toggle:hover {
  transform: rotate(180deg) scale(1.1);
  background: hsl(var(--secondary));
}

.sidebar-hidden {
  display: none;
}

.sidebar-toggle {
  position: absolute;
  top: 1rem;
  right: -0.75rem;
  width: 1.5rem;
  height: 1.5rem;
  background: hsl(var(--card));
  border: 1px solid hsl(var(--border));
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: var(--transition-smooth);
  z-index: 20;
  color: hsl(var(--foreground));
}

.sidebar-toggle:hover {
  background: hsl(var(--primary));
  color: white;
  transform: scale(1.1);
  box-shadow: var(--shadow-soft);
}

.sidebar-content {
  transition: var(--transition-smooth);
}

.main-content {
  flex: 1;
  padding: 1rem 2rem;
  transition: var(--transition-smooth);
}

.topbar {
  margin-bottom: 1rem;
}

.nav-button {
  width: 100%;
  text-align: left;
  padding: 0.75rem;
  border-radius: 0.375rem;
  transition: var(--transition-smooth);
  background: transparent;
  border: none;
  color: hsl(var(--foreground));
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.nav-button:hover {
  background: hsla(255, 255, 255, 0.05);
}

.nav-button[data-active="true"] {
  background: hsla(255, 255, 255, 0.1);
  color: white;
}

/* Date filter button */
.btn-date-filter {
  background: hsl(var(--secondary));
  color: white;
  font-weight: 500;
  padding: 0.5rem 1rem;
  border-radius: 0.375rem;
  transition: var(--transition-bounce);
  border: none;
  cursor: pointer;
}

.btn-date-filter:hover {
  background: hsl(var(--secondary), 0.9);
  transform: translateY(-2px);
}

/* Loading spinner */
.spinner-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background-color: rgba(0, 0, 0, 0.5);
  display: flex;
  justify-content: center;
  align-items: center;
  z-index: 1000;
  backdrop-filter: blur(2px);
}

.spinner {
  width: 50px;
  height: 50px;
  border: 3px solid transparent;
  border-top-color: hsl(var(--primary));
  border-radius: 50%;
  animation: spin 1s linear infinite;
}

.spinner-container {
  position: relative;
  width: 50px;
  height: 50px;
}

.spinner-inner {
  position: absolute;
  top: 5px;
  left: 5px;
  right: 5px;
  bottom: 5px;
  border: 3px solid transparent;
  border-top-color: hsl(var(--secondary));
  border-radius: 50%;
  animation: spin 1.5s linear infinite reverse;
}

@keyframes spin {
  0% {
    transform: rotate(0deg);
  }

  100% {
    transform: rotate(360deg);
  }
}

.spinner-small {
  width: 20px;
  height: 20px;
  border-width: 2px;
  display: inline-block;
  vertical-align: middle;
  margin-right: 8px;
}

.spinner-small-inner {
  top: 3px;
  left: 3px;
  right: 3px;
  bottom: 3px;
  border-width: 2px;
}

.btn-loading {
  position: relative;
  color: transparent !important;
}

.btn-loading::after {
  content: "";
  position: absolute;
  width: 16px;
  height: 16px;
  top: calc(50% - 8px);
  left: calc(50% - 8px);
  border: 2px solid transparent;
  border-top-color: currentColor;
  border-radius: 50%;
  animation: spin 1s linear infinite;
}

/* Sort indicators */
.sort-indicator {
  display: inline-block;
  width: 16px;
  height: 16px;
  position: relative;
}

th[data-sort="asc"] .sort-indicator::after {
  content: "↑";
  position: absolute;
  top: 0;
  left: 0;
  color: #38bdf8;
  /* Tailwind cyan-400 */
}

th[data-sort="desc"] .sort-indicator::after {
  content: "↓";
  position: absolute;
  top: 0;
  left: 0;
  color: #38bdf8;
  /* Tailwind cyan-400 */
}

/* Responsive */
@media (min-width: 768px) {
  .sidebar-hidden {
    display: block;
  }

  .mobile-nav {
    display: none;
  }
}

/* Mobile adjustments for sidebar toggle */
@media (max-width: 767px) {
  .sidebar-toggle {
    display: none;
  }
}

/* Improved collapsed state for mobile */
@media (max-width: 1024px) {
  .sidebar.collapsed {
    width: 3rem;
  }

  .sidebar.collapsed .sidebar-toggle {
    right: -0.5rem;
  }
}

/* Utility classes */
.flex {
  display: flex;
}

.items-center {
  align-items: center;
}

.justify-between {
  justify-content: space-between;
}

.gap-2 {
  gap: 0.5rem;
}

.gap-3 {
  gap: 0.75rem;
}

.mb-2 {
  margin-bottom: 0.5rem;
}

.mb-4 {
  margin-bottom: 1rem;
}

.mb-6 {
  margin-bottom: 1.5rem;
}

.p-3 {
  padding: 0.75rem;
}

.p-4 {
  padding: 1rem;
}

.p-6 {
  padding: 1.5rem;
}

.rounded-md {
  border-radius: 0.375rem;
}

.rounded-lg {
  border-radius: 0.5rem;
}

.rounded-xl {
  border-radius: 0.75rem;
}

.text-sm {
  font-size: 0.875rem;
}

.text-xs {
  font-size: 0.75rem;
}

.font-medium {
  font-weight: 500;
}

.font-semibold {
  font-weight: 600;
}

.hidden {
  display: none;
}

.grid {
  display: grid;
}

.grid-cols-1 {
  grid-template-columns: repeat(1, minmax(0, 1fr));
}

@media (min-width: 640px) {
  .sm\:grid-cols-2 {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (min-width: 1280px) {
  .xl\:grid-cols-4 {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }
}

.gap-4 {
  gap: 1rem;
}

.overflow-x-auto {
  overflow-x: auto;
}

.min-w-full {
  min-width: 100%;
}

.text-left {
  text-align: left;
}

.py-2 {
  padding-top: 0.5rem;
  padding-bottom: 0.5rem;
}

.py-3 {
  padding-top: 0.75rem;
  padding-bottom: 0.75rem;
}

.px-3 {
  padding-left: 0.75rem;
  padding-right: 0.75rem;
}

.px-4 {
  padding-left: 1rem;
  padding-right: 1rem;
}

.pr-4 {
  padding-right: 1rem;
}

.min-w-48 {
  min-width: 12rem;
}

.min-w-64 {
  min-width: 20rem;
}

.min-w-20 {
  min-width: 5rem;
}

/* Modal styles for text display */
.whitespace-pre-wrap {
  white-space: pre-wrap;
}

/* Full height modal on mobile */
@media (max-width: 767px) {
  .swal-full-height-mobile {
    padding: 0 !important;
  }

  .swal-full-height-mobile .swal2-popup {
    border-radius: 0 !important;
    width: 100% !important;
    height: 100% !important;
    margin: 0 !important;
    padding: 1rem !important;
    max-height: 100vh !important;
  }

  .swal-full-height-mobile .swal2-html-container {
    max-height: calc(100vh - 200px) !important;
    overflow-y: auto !important;
  }
}

/* Garante que nunca fique cinza após hover ou focus */
.select2-container--default .select2-results__option[aria-selected=true].select2-results__option--highlighted,
.select2-container--default .select2-results__option[aria-selected=true]:focus,
.select2-container--default .select2-results__option[aria-selected=true]:active {
  background-color: hsla(188, 95%, 53%, 0.4) !important;
  color: hsl(var(--foreground)) !important;
}


.select2-container--default .select2-results__option--selected {
  background-color: hsla(188, 95%, 53%, 0.4) !important;
  color: hsl(var(--foreground)) !important;
}