/* ============================================================================
   CORREÇÃO PARA TABELAS CORTADAS NA BORDA DIREITA
   Problema: Tabelas ultrapassam container e são clipadas
   Solução: Wrapper com overflow-x auto + largura mínima garantida
   ============================================================================ */

/* 1) WRAPPER PRINCIPAL DA TABELA - SCROLL HORIZONTAL */
.table-wrapper {
  overflow-x: auto !important;
  overflow-y: visible !important;
  -webkit-overflow-scrolling: touch; /* Smooth scroll em iOS */
  width: 100% !important;
  position: relative;
}

/* 2) GARANTIR LARGURA MÍNIMA DA TABELA */
.table-wrapper table,
.table-wrapper .dash-table,
.table-wrapper .dataframe,
.dash-table-container {
  min-width: 960px !important; /* Ajustar conforme necessário */
  width: 100% !important;
}

/* 3) REMOVER CLIPPING DE CONTAINERS PAIS */
.table-container,
.table-section,
.card-body-with-table {
  overflow: visible !important;
  contain: none !important; /* Remove contenção CSS */
}

/* 4) ESTILIZAR SCROLLBAR HORIZONTAL (CHROME/SAFARI) */
.table-wrapper::-webkit-scrollbar {
  height: 8px;
}

.table-wrapper::-webkit-scrollbar-track {
  background: #f1f1f1;
  border-radius: 4px;
}

.table-wrapper::-webkit-scrollbar-thumb {
  background: #888;
  border-radius: 4px;
}

.table-wrapper::-webkit-scrollbar-thumb:hover {
  background: #555;
}

/* 5) ESTILIZAR SCROLLBAR (FIREFOX) */
.table-wrapper {
  scrollbar-width: thin;
  scrollbar-color: #888 #f1f1f1;
}

/* 6) PADDING INTERNO PARA NÃO "COLAR" NA BORDA */
.table-wrapper {
  padding: 0 !important;
  margin: 0 !important;
}

/* 7) GARANTIR QUE CÉLULAS NÃO SEJAM CORTADAS */
.table-wrapper td,
.table-wrapper th {
  white-space: nowrap; /* Evita quebra de linha que pode causar clipping */
  overflow: visible !important;
  text-overflow: clip !important;
}

/* 8) SE USAR DASH DataTable, CONFIGURAÇÕES ESPECÍFICAS */
.dash-spreadsheet-container {
  overflow-x: auto !important;
  max-width: 100% !important;
}

.dash-spreadsheet {
  min-width: 960px !important;
}

/* 9) RESPONSIVO - EM TELAS MENORES, PERMITIR SCROLL */
@media (max-width: 1200px) {
  .table-wrapper table,
  .table-wrapper .dash-table {
    min-width: 800px !important;
  }
}

@media (max-width: 768px) {
  .table-wrapper table,
  .table-wrapper .dash-table {
    min-width: 600px !important;
    font-size: 0.85rem;
  }
}

/* 10) INDICADOR VISUAL DE "MAIS CONTEÚDO À DIREITA" */
.table-wrapper::after {
  content: '';
  position: absolute;
  top: 0;
  right: 0;
  bottom: 0;
  width: 20px;
  background: linear-gradient(to left, rgba(255, 255, 255, 0.8), transparent);
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.3s;
}

.table-wrapper.has-scroll::after {
  opacity: 1;
}

/* 11) QUANDO TABELA ESTÁ NO FIM DO SCROLL, REMOVER INDICADOR */
.table-wrapper.scroll-end::after {
  opacity: 0;
}

/* ============================================================================
   FIM DAS CORREÇÕES DE TABELA
   ============================================================================ */
