/**
 * Estilos para animações dos cards de estatísticas
 * Tarefa 4.1 - Implementar atualização de cards estatísticos
 */

/* Animação de atualização de valores */
.main-value.updating,
.info-value.updating {
  animation: value-update 0.3s ease-in-out;
  color: #3b82f6;
  font-weight: 600;
}

@keyframes value-update {
  0% {
    transform: scale(1);
    opacity: 1;
  }
  50% {
    transform: scale(1.05);
    opacity: 0.8;
  }
  100% {
    transform: scale(1);
    opacity: 1;
  }
}

/* Skeleton loading para cards */
.skeleton-loading {
  background: linear-gradient(90deg, #f0f0f0 25%, #e0e0e0 50%, #f0f0f0 75%);
  background-size: 200% 100%;
  animation: skeleton-pulse 1.5s infinite;
  border-radius: 4px;
  height: 1.2em;
  width: 100%;
  display: inline-block;
}

.skeleton-loading.small {
  height: 0.9em;
  width: 80%;
}

@keyframes skeleton-pulse {
  0% {
    background-position: 200% 0;
  }
  100% {
    background-position: -200% 0;
  }
}

/* Estados de alerta para cards */
.resumo-card.alert-low {
  border-left: 4px solid #f59e0b;
  background: linear-gradient(135deg, #fffbeb 0%, #ffffff 100%);
}

.resumo-card.alert-medium {
  border-left: 4px solid #ef4444;
  background: linear-gradient(135deg, #fef2f2 0%, #ffffff 100%);
}

.resumo-card.alert-high {
  border-left: 4px solid #dc2626;
  background: linear-gradient(135deg, #fef2f2 0%, #ffffff 100%);
  box-shadow: 0 4px 12px rgba(220, 38, 38, 0.15);
}

/* Animação de entrada dos cards */
.resumo-card {
  animation: card-fade-in 0.5s ease-out;
}

@keyframes card-fade-in {
  0% {
    opacity: 0;
    transform: translateY(20px);
  }
  100% {
    opacity: 1;
    transform: translateY(0);
  }
}

/* Barras de progresso animadas */
.progress-bar {
  transition: width 0.6s ease-in-out;
  background: linear-gradient(90deg, #3b82f6, #1d4ed8);
  border-radius: 4px;
  height: 6px;
  position: relative;
  overflow: hidden;
}

.progress-bar::after {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: linear-gradient(90deg, transparent, rgba(255,255,255,0.3), transparent);
  animation: progress-shine 2s infinite;
}

@keyframes progress-shine {
  0% {
    transform: translateX(-100%);
  }
  100% {
    transform: translateX(100%);
  }
}

/* Estados especiais dos cards */
.resumo-card.estado-vazio {
  opacity: 0.6;
  background: #f9fafb;
}

.resumo-card.estado-vazio .main-value,
.resumo-card.estado-vazio .info-value {
  color: #9ca3af;
}

/* Erro nos cards */
.erro-loading {
  color: #dc2626;
  font-weight: 500;
}

/* Transições suaves para valores */
.main-value,
.info-value {
  transition: all 0.3s ease-in-out;
}

/* Hover effects para cards */
.resumo-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 25px rgba(0, 0, 0, 0.1);
  transition: all 0.3s ease-in-out;
}

/* Responsividade para animações */
@media (prefers-reduced-motion: reduce) {
  .main-value.updating,
  .info-value.updating,
  .resumo-card,
  .progress-bar {
    animation: none;
    transition: none;
  }
  
  .resumo-card:hover {
    transform: none;
  }
}

/* Indicadores visuais para diferentes tipos de valores */
.valor-positivo {
  color: #059669;
}

.valor-negativo {
  color: #dc2626;
}

.valor-neutro {
  color: #6b7280;
}

/* Badges de status nos cards */
.status-badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 12px;
  font-size: 0.75rem;
  font-weight: 500;
  text-transform: uppercase;
}

.status-badge.status-paga {
  background: #d1fae5;
  color: #065f46;
}

.status-badge.status-vencida {
  background: #fee2e2;
  color: #991b1b;
}

.status-badge.status-pendente {
  background: #fef3c7;
  color: #92400e;
}

.status-badge.status-cancelada {
  background: #f3f4f6;
  color: #374151;
}

/* Correções de layout e sobreposição */
.resumo-cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 20px;
  margin-bottom: 30px;
  z-index: 1;
  position: relative;
}

.resumo-card {
  background: white;
  border-radius: 12px;
  padding: 20px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
  border: 1px solid #e5e7eb;
  position: relative;
  z-index: 2;
  overflow: hidden;
}

/* Evitar sobreposição de texto */
.main-value,
.info-value {
  word-wrap: break-word;
  overflow-wrap: break-word;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  line-height: 1.2;
  z-index: 3;
  position: relative;
}

/* Correções para tabela - ALINHAMENTO PERFEITO */
.tabela-container {
  position: relative;
  z-index: 1;
  background: white;
  border-radius: 8px;
  overflow-x: auto;
  overflow-y: visible;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
  margin-top: 20px;
  /* Garantir que a tabela nunca quebre */
  -webkit-overflow-scrolling: touch;
}

.tabela-multas {
  width: 100%;
  min-width: 1650px; /* Largura mínima para todas as colunas */
  border-collapse: collapse;
  font-size: 14px;
  table-layout: fixed; /* Layout fixo para controle preciso */
}

/* DEFINIÇÕES PRECISAS DE LARGURA PARA CADA COLUNA */
.tabela-multas th:nth-child(1),  /* PLACA */
.tabela-multas td:nth-child(1) {
  width: 100px;
  min-width: 100px;
  max-width: 100px;
}

.tabela-multas th:nth-child(2),  /* MARCA/MODELO */
.tabela-multas td:nth-child(2) {
  width: 150px;
  min-width: 150px;
  max-width: 150px;
}

.tabela-multas th:nth-child(3),  /* RENAVAM */
.tabela-multas td:nth-child(3) {
  width: 120px;
  min-width: 120px;
  max-width: 120px;
}

.tabela-multas th:nth-child(4),  /* AUTO */
.tabela-multas td:nth-child(4) {
  width: 100px;
  min-width: 100px;
  max-width: 100px;
}

.tabela-multas th:nth-child(5),  /* LOCATÁRIO */
.tabela-multas td:nth-child(5) {
  width: 150px;
  min-width: 150px;
  max-width: 150px;
}

.tabela-multas th:nth-child(6),  /* DATA */
.tabela-multas td:nth-child(6) {
  width: 100px;
  min-width: 100px;
  max-width: 100px;
}

.tabela-multas th:nth-child(7),  /* INFRAÇÃO */
.tabela-multas td:nth-child(7) {
  width: 300px;
  min-width: 300px;
  max-width: 300px;
}

.tabela-multas th:nth-child(8),  /* GRAVIDADE */
.tabela-multas td:nth-child(8) {
  width: 120px;
  min-width: 120px;
  max-width: 120px;
}

.tabela-multas th:nth-child(9),  /* PONTOS */
.tabela-multas td:nth-child(9) {
  width: 80px;
  min-width: 80px;
  max-width: 80px;
}

.tabela-multas th:nth-child(10), /* VALOR */
.tabela-multas td:nth-child(10) {
  width: 120px;
  min-width: 120px;
  max-width: 120px;
}

.tabela-multas th:nth-child(11), /* STATUS */
.tabela-multas td:nth-child(11) {
  width: 100px;
  min-width: 100px;
  max-width: 100px;
}

.tabela-multas th:nth-child(12), /* ÓRGÃO */
.tabela-multas td:nth-child(12) {
  width: 200px;
  min-width: 200px;
  max-width: 200px;
}

.tabela-multas th:nth-child(13), /* AÇÕES */
.tabela-multas td:nth-child(13) {
  width: 120px;
  min-width: 120px;
  max-width: 120px;
}

.tabela-multas th,
.tabela-multas td {
  padding: 12px 8px;
  text-align: left;
  border-bottom: 1px solid #e5e7eb;
  vertical-align: middle;
  position: relative;
  /* Controle de overflow para cada célula */
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Exceção para coluna de infração - permitir quebra de texto */
.tabela-multas th:nth-child(7),
.tabela-multas td:nth-child(7) {
  white-space: normal;
  word-wrap: break-word;
  overflow-wrap: break-word;
  line-height: 1.4;
}

.tabela-multas th {
  background: #f9fafb;
  font-weight: 600;
  color: #374151;
  position: sticky;
  top: 0;
  z-index: 10;
  /* Garantir que cabeçalhos não quebrem */
  white-space: nowrap;
}

/* Correções para modal */
.modal {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.5);
  z-index: 9999;
  display: flex;
  align-items: center;
  justify-content: center;
}

.modal[style*="display: none"] {
  display: none !important;
}

.modal-content {
  background: white;
  border-radius: 12px;
  max-width: 800px;
  width: 90%;
  max-height: 90vh;
  overflow-y: auto;
  position: relative;
  z-index: 10000;
  box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.1);
}

.modal-header {
  padding: 20px 24px;
  border-bottom: 1px solid #e5e7eb;
  display: flex;
  justify-content: space-between;
  align-items: center;
  position: sticky;
  top: 0;
  background: white;
  z-index: 10001;
}

.modal-body {
  padding: 24px;
  position: relative;
  z-index: 10000;
}

/* Botões de ação */
.acoes-btn {
  background: none;
  border: none;
  padding: 8px;
  margin: 0 2px;
  border-radius: 6px;
  cursor: pointer;
  transition: all 0.2s ease;
  color: #6b7280;
  font-size: 14px;
}

.acoes-btn:hover {
  background: #f3f4f6;
  color: #374151;
  transform: translateY(-1px);
}

.acoes-btn.editar:hover {
  background: #dbeafe;
  color: #2563eb;
}

.acoes-btn.excluir:hover {
  background: #fee2e2;
  color: #dc2626;
}

/* Responsividade melhorada */
@media (max-width: 768px) {
  .resumo-cards {
    grid-template-columns: 1fr;
    gap: 15px;
  }
  
  .resumo-card {
    padding: 16px;
  }
  
  .tabela-container {
    overflow-x: auto;
  }
  
  .tabela-multas {
    min-width: 800px;
  }
  
  .modal-content {
    width: 95%;
    margin: 10px;
  }
  
  .modal-body {
    padding: 16px;
  }
}

/* Correções específicas para elementos sobrepostos */
.dashboard-header,
.page-header {
  position: relative;
  z-index: 5;
  background: white;
  margin-bottom: 20px;
}

.filtros-container {
  position: relative;
  z-index: 4;
  background: white;
  padding: 16px;
  border-radius: 8px;
  margin-bottom: 20px;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

/* Evitar conflitos de z-index */
.mv-sidebar {
  z-index: 1000;
}

.navbar,
.header {
  z-index: 999;
}

/* Correções para elementos flutuantes */
.floating-element {
  position: relative;
  z-index: 100;
}

/* Garantir que tooltips apareçam acima de tudo */
.tooltip,
[title]:hover::after {
  z-index: 10002;
}