/* Estilo para o preview de cores */
.color-preview {
  display: inline-block;
  width: 24px;
  height: 24px;
  border-radius: 4px;
  border: 1px solid #d1d5db; /* gray-300 */
  vertical-align: middle;
  margin-left: 8px;
}

.sortable-controls button {
  background: none;
  border: none;
  cursor: pointer;
  padding: 2px;
  margin: 0 2px;
}

.sortable-controls button:hover {
  background-color: rgba(0,0,0,0.1);
  border-radius: 4px;
}

[contenteditable="true"]:focus {
  outline: 2px solid #3b82f6; /* Tailwind blue-500 */
  border-radius: 4px;
}

.sidebar {
  transition: all 0.3s ease;
  z-index: 50;
}

.sidebar.collapsed {
  width: 64px;
}

.sidebar.collapsed .sidebar-text {
  display: none;
}

.main-content {
	transition: all 0.3s ease;
}

.tab-content {
  display: none;
  opacity: 0;
  transition: opacity 0.3s ease;
}

.tab-content.active {
  display: block;
  opacity: 1;
}

#scrapeModal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.5); 
    z-index: 1000;
}

#scrapeModalContent {
    z-index: 1002;
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    min-width: 800px;
    min-height: 600px;
    width: 90vw;
    height: 90vh;
    background-color: white;
    border-radius: 0.5rem;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04);
    resize: both;
}

#scrapeModalBody {
    position: relative;
    flex: 1;
    display: flex;
    overflow: hidden;
}

#scrapeBrowser {
    flex: 1;
    border: none;
    width: 100%;
    height: 100%;
    background-color: #f8fafc; /* Tailwind gray-50 */
}

#staticPreviewContainer, #dynamicPreviewContainer {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: white;
    border: 1px solid #e2e8f0; /* Tailwind gray-200 */
    border-radius: 0.25rem;
    overflow: auto;
    padding: 1rem;
}

.element-highlight {
    position: absolute;
    background-color: rgba(59, 130, 246, 0.3);
    border: 2px dashed #3b82f6;
    z-index: 999998;
    pointer-events: none;
}

.element-info {
    position: absolute;
    background-color: white;
    border: 1px solid #e2e8f0;
    padding: 0.5rem;
    font-size: 0.75rem;
    z-index: 999999;
    pointer-events: none;
    border-radius: 0.25rem;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
    max-width: 300px;
}

.scrape-toolbar {
    position: absolute;
    top: 10px;
    left: 10px;
    z-index: 999999;
    background: white;
    padding: 0.5rem;
    border-radius: 0.25rem;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
    display: flex;
    gap: 0.5rem;
}

.scrape-toolbar-button {
    padding: 0.25rem 0.5rem;
    font-size: 0.75rem;
    border-radius: 0.25rem;
    background-color: #f1f5f9; /* gray-100 */
    color: #334155; /* gray-700 */
    border: 1px solid #cbd5e1; /* gray-300 */
    cursor: pointer;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    gap: 0.25rem;
}

.scrape-toolbar-button:hover {
    background-color: #e2e8f0; /* gray-200 */
}

.scrape-toolbar-button.active {
    background-color: #2563eb; /* blue-600 */
    color: white;
    border-color: #1d4ed8; /* blue-700 */
}

.capture-mode {
    cursor: crosshair !important;
}

body.capture-mode #scrapeBrowser {
    cursor: crosshair !important;
}

.switch {
  position: relative;
  display: inline-block;
  width: 50px;
  height: 24px;
}

.switch input {
  opacity: 0;
  width: 0;
  height: 0;
}

.slider {
  position: absolute;
  cursor: pointer;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background-color: #ccc;
  transition: .4s;
  border-radius: 24px;
}

.slider:before {
  position: absolute;
  content: "";
  height: 16px;
  width: 16px;
  left: 4px;
  bottom: 4px;
  background-color: white;
  transition: .4s;
  border-radius: 50%;
}

input:checked + .slider {
  background-color: #3b82f6; /* Tailwind blue-500 */
}

input:checked + .slider:before {
  transform: translateX(26px);
}

#scrapeProgressCounter {
  /* Estilos gerenciados por Tailwind no HTML */
}

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

/* --- INÍCIO: ESTILO CORRETO E CONSOLIDADO PARA TABELA --- */

#recordTable {
  width: auto;
  table-layout: auto;
  border-collapse: separate;
  border-spacing: 0;
}

/* Aumenta a largura mínima das colunas de Ações e Grupo e previne o corte do conteúdo */
#recordTable th.col-actions, #recordTable td.col-actions {
    min-width: 80px; /* AUMENTO: de 130px para 150px */
    overflow: visible; /* ADIÇÃO: Permite que o conteúdo (botão/dropdown) ultrapasse a célula se necessário */
}
#recordTable th.col-group, #recordTable td.col-group {
    min-width: 130px; /* AUMENTO: de 180px para 200px */
    overflow: visible; /* ADIÇÃO: Garante que o dropdown não seja cortado */
}
/* --- FIM DA CORREÇÃO --- */

#recordTable th,
#recordTable td {
  padding: 8px 12px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  vertical-align: middle;
}

/* REMOÇÃO: As regras de largura fixa para as colunas foram removidas */
/* #recordTable th:nth-child(1), #recordTable td:nth-child(1) { ... } */
/* #recordTable th:nth-child(2), #recordTable td:nth-child(2) { ... } */
/* #recordTable th:nth-child(3), #recordTable td:nth-child(3) { ... } */

/* Outras colunas (agora se aplica a todas as colunas de dados) */
#recordTable td { /* Seletor simplificado */
  max-width: 250px;
}

#recordTable td[contenteditable="true"]:focus {
  white-space: normal;
  overflow: visible;
  text-overflow: clip;
  height: auto;
  min-height: 38px;
}

#recordTable thead th {
  position: sticky;
  top: 0;
  z-index: 10;
  font-weight: 600;
  font-size: 0.875rem;
}

#recordTable thead th .header-content-wrapper {
  display: flex;
  justify-content: space-between;
  align-items: center;
  height: 150px;
  width: 100%;
}

#recordTable thead th .header-text {
  writing-mode: vertical-rl;
  text-orientation: mixed;
  transform: rotate(180deg);
  white-space: nowrap;
}

#recordTable thead th .header-controls {
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 2px;
  writing-mode: horizontal-tb;
  transform: none;
}

/* --- FIM DOS ESTILOS DA TABELA --- */


#recordTable th {
  width: 250px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

#recordTable thead {
  /*background-color: #f1f5f9;*/ /* Tailwind gray-100 */
}

#recordTable thead th {
    position: sticky;
    top: 0;
    /*background-color: #f1f5f9;*/ /* Tailwind gray-100 */
    z-index: 10;
    font-weight: 600;
    /*color: #374151;*/ /* Tailwind gray-700 */
    font-size: 0.875rem;
}

/* --- REGRAS PARA CABEÇALHO VERTICAL --- */
#recordTable thead th .header-content-wrapper {
  display: flex;
  justify-content: space-between;
  align-items: center;
  height: 150px;
  width: 100%;
}

#recordTable thead th .header-text {
  writing-mode: vertical-rl;
  text-orientation: mixed;
  transform: rotate(180deg);
  white-space: nowrap;
}

#recordTable thead th .header-controls {
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 2px;
  writing-mode: horizontal-tb; /* Garante que os controles fiquem horizontais */
  transform: none;
}

#toggleHttpSettingsBtn i,
#toggleHttpSettingsBtn span,
#toggleGroupHttpSettingsBtn i,
#toggleGroupHttpSettingsBtn span {
  pointer-events: none;
}

.data-table {
  border-collapse: separate;
  border-spacing: 0;
}

.data-table th {
  position: sticky;
  top: 0;
  background-color: #f8fafc;
  z-index: 10;
}

.card:hover {
  box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05); /* Tailwind shadow-lg */
}

.input-field {
    border: 1px solid #cbd5e1; /* Tailwind border-gray-300 */
    border-radius: 0.25rem; /* Tailwind rounded */
    padding: 0.5rem; /* Tailwind p-2 */
    font-size: 0.875rem; /* Tailwind text-sm */
    width: 100%;
    transition: border-color 0.2s;
}

.input-field:focus {
    outline: none;
    border-color: #2563eb; /* Tailwind blue-600 */
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

#scrapeModalHeader {
    padding: 1rem;
    background-color: #2563eb;
    color: white;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-top-left-radius: 0.5rem;
    border-top-right-radius: 0.5rem;
    cursor: move;
}

#scrapeModalHeader h3 {
    color: #FFFFFF !important; 
}

.resize-handle {
    position: absolute;
    right: 0;
    bottom: 0;
    width: 20px;
    height: 20px;
    cursor: nwse-resize;
    background-color: #2563eb;
    border-radius: 4px 0 0 0;
}

#scrapeProgressBar {
  transition: width 0.2s ease-out;
}

[data-tooltip] {
  position: relative;
}

[data-tooltip]:hover::after {
  content: attr(data-tooltip);
  position: absolute;
  bottom: 100%;
  left: 50%;
  transform: translateX(-50%);
  background-color: #333;
  color: white;
  padding: 4px 8px;
  border-radius: 4px;
  font-size: 12px;
  white-space: nowrap;
  z-index: 100;
  animation: fadeIn 0.2s ease-out;
}

.dark-mode-toggle {
  position: relative;
  display: inline-block;
  width: 50px;
  height: 24px;
}

.dark-mode-toggle input {
  opacity: 0;
  width: 0;
  height: 0;
}

.dark-mode-slider {
  position: absolute;
  cursor: pointer;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background-color: #ccc;
  transition: .4s;
  border-radius: 24px;
}

.dark-mode-slider:before {
  position: absolute;
  content: "";
  height: 16px;
  width: 16px;
  left: 4px;
  bottom: 4px;
  background-color: white;
  transition: .4s;
  border-radius: 50%;
}

.dark-mode-toggle input:checked + .dark-mode-slider {
  background-color: #3b82f6; /* blue-500 */
}

.dark-mode-toggle input:checked + .dark-mode-slider:before {
  transform: translateX(26px);
}

.tab-button {
  padding: 0.75rem 1.5rem;
  border-bottom: 2px solid transparent;
  cursor: pointer;
  transition: all 0.2s ease;
}
.tab-button.active {
  border-bottom-color: #3b82f6;
  color: #3b82f6;
  font-weight: 600;
}
.tab-button.inactive {
  color: #6b7280;
}
.tab-button:hover:not(.active) {
  color: #4b5563;
}

.filter-row {
  display: flex;
  align-items: center;
  gap: 0.5rem; 
  margin-bottom: 0.5rem;
  padding: 0.5rem;
  border: 1px solid #e5e7eb; 
  border-radius: 0.25rem; 
  background-color: #f9fafb; 
}
.filter-type {
  flex-basis: 120px; 
  flex-shrink: 0;
}
.filter-params-container {
  flex-grow: 1;
  display: flex;
  gap: 0.25rem; 
}
.filter-params-container input {
  flex-grow: 1; 
  min-width: 60px; 
}
.filter-row button {
  padding: 0.25rem 0.5rem;
  background-color: transparent;
  border: none;
  /* A linha 'color' foi REMOVIDA daqui */
  cursor: pointer;
}

.filter-row button:hover {
  /* O background vermelho no hover foi REMOVIDO para permitir que o hover do Tailwind funcione */
  border-radius: 0.25rem;
}

.editor-sub-tab-content {
  display: none;
  opacity: 0;
  transition: opacity 0.3s ease;
}

.editor-sub-tab-content.active {
  display: block;
  opacity: 1;
}

.modal-tab-button {
    padding: 0.75rem 1rem;
    border-bottom: 3px solid transparent;
    color: #6b7280; /* gray-500 */
    cursor: pointer;
    transition: all 0.2s;
    flex-grow: 1; 
    text-align: center;
}
.modal-tab-button:hover {
    background-color: #f3f4f6; /* gray-100 */
    color: #1f2937; /* gray-800 */
}
.modal-tab-button.active {
    color: #2563eb; /* blue-600 */
    border-bottom-color: #2563eb;
    background-color: #f9fafb; /* gray-50 */
}
.modal-tab-content {
    display: none;
}
.modal-tab-content.active {
    display: block;
}

#staticPreview {
  white-space: pre-wrap;
  word-wrap: break-word;
}

/* --- FIX: SOLUÇÃO PARA SOBREPOSIÇÃO DA TABELA --- */
.overflow-x-auto {
    position: relative; /* Necessário para o z-index do cabeçalho sticky funcionar corretamente em relação à sidebar */
    z-index: 1; /* Garante que o container esteja em seu próprio contexto de empilhamento */
}

.filter-type-select {
    height: 28px; /* Altura fixa e compacta */
    padding-top: 2px !important; /* Sobrescreve padding do Tailwind */
    padding-bottom: 2px !important; /* Sobrescreve padding do Tailwind */
    line-height: 1.2; /* Ajusta a altura da linha do texto */
}

#scrapeModalBody > .flex-1.relative {
    position: relative;
}

#cancelPreviewLoadBtn {
    /* Mantém a aparência, mas remove o posicionamento absoluto */
    background-color: #dc2626;
    color: white;
    padding: 0.5rem 1rem;
    border-radius: 0.5rem;
    box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
    display: flex;
    align-items: center;
    gap: 0.5rem;
    cursor: pointer;
    border: none;
    transition: background-color 0.2s;
}

#cancelPreviewLoadBtn:hover {
    background-color: #b91c1c;
}

#cancelPreviewLoadBtn i {
    margin-right: 0.5rem;
}

/* --- ESTILOS PARA SEÇÃO EXPANSÍVEL DO MODAL DE SCRAPE --- */
#expandableControlsContent {
    max-height: 1000px;
    overflow: hidden;
    transition: all 0.4s ease-in-out;
}

#expandableControlsContent.hidden {
    max-height: 0;
    padding-top: 0;
    padding-bottom: 0;
    margin-top: 0;
    margin-bottom: 0;
    border-top: none;
}

/* --- ESTILOS PARA AJUSTE DO RODAPÉ DO MODAL DE SCRAPE --- */
#scrapeControls {
    /* --- POSICIONAMENTO --- */
    position: absolute; /* MUITO IMPORTANTE: Torna-o um painel flutuante */
    top: 0;
    bottom: 0;
    right: 0; /* Começa alinhado à direita */
    z-index: 10; /* Garante que fique sobre o painel de preview */

    /* --- TAMANHO E APARÊNCIA --- */
    width: 320px; /* Largura fixa (equivalente a w-80). Usar px aqui é mais robusto. */
    height: 100%;
    background-color: #f9fafb; /* bg-gray-50 */
    border-left: 1px solid #e5e7eb; /* border-l border-gray-200 */
    
    /* --- ESTRUTURA INTERNA E TRANSIÇÃO --- */
    display: flex;
    flex-direction: column;
    overflow: hidden;
    transition: transform 0.3s ease-in-out; /* A transição que fará a mágica */
}

#scrapeControls.is-collapsed {
    /* Move o painel 100% de sua própria largura para a direita, escondendo-o */
    transform: translateX(100%);
}

#scrapeControls .flex-1.overflow-y-auto {
    flex-grow: 1;
}

#scrapeControlsFooter {
    flex-shrink: 0;
}

/* --- ESTILOS PARA O CONTAINER DA TABELA DE REGISTROS --- */
.table-container-wrapper {
    width: 100%;
    overflow-x: auto;
}

.table-scroll-container {
    max-height: 700px;
    overflow: auto; /* Controla ambas as rolagens (vertical e horizontal) */
    width: 1225px;
    display: block;
    position: relative;
}

.table-nav-controls {
    /* Alinha os controles à direita por padrão */
}

.table-nav-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 32px;  /* Largura fixa */
    height: 32px; /* Altura fixa */
    background-color: #e5e7eb; /* bg-gray-200 */
    color: #4b5563;       /* text-gray-600 */
    border: 1px solid #d1d5db; /* border-gray-300 */
    border-radius: 50%;   /* Circular */
    cursor: pointer;
    transition: all 0.2s ease-in-out;
}

.table-nav-btn:hover:not(:disabled) {
    background-color: #d1d5db; /* bg-gray-300 */
    color: #1f2937;       /* text-gray-800 */
    box-shadow: 0 1px 3px rgba(0,0,0,0.1);
}

.table-nav-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* --- INÍCIO DA ALTERAÇÃO --- */
#centralCancelScrapeContainer {
    display: none; /* Começa escondido */
    justify-content: center;
    align-items: center;
    padding: 8px 0;
}
/* --- FIM DA ALTERAÇÃO --- */

#recordTable thead th:focus-within {
    background-color: #dbeafe !important; /* Tailwind's blue-100, para um destaque sutil */
    outline: 2px solid #3b82f6; /* Tailwind's blue-500, para uma borda clara */
    outline-offset: -2px; /* Move o outline para dentro para não alterar o layout */
}

/* Transição suave para a altura do modal */
#bulkActionModal > div {
    transition: all 0.3s ease-in-out;
}

/* Estilos para o painel de relatório */
#bulkActionReportContainer {
    /* A linha "display: none;" foi REMOVIDA para corrigir o bug do relatório. */
    padding-top: 1rem;
    margin-top: 1rem;
    border-top: 1px solid #e5e7eb; /* gray-200 */
}

/* Estilo para cada item do relatório */
.report-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.5rem 0;
    border-bottom: 1px solid #f3f4f6; /* gray-100 */
    font-size: 0.875rem; /* text-sm */
}

.report-item:last-child {
    border-bottom: none;
}

.report-item-label {
    color: #4b5563; /* gray-600 */
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.report-item-value {
    font-weight: 600;
    color: #1f2937; /* gray-800 */
    background-color: #e5e7eb; /* gray-200 */
    padding: 0.125rem 0.5rem;
    border-radius: 9999px; /* rounded-full */
    font-size: 0.75rem; /* text-xs */
    min-width: 24px;
    text-align: center;
}

/* Cores específicas para os contadores */
#reportValueSuccess { background-color: #dcfce7; color: #166534; } /* green */
#reportValueError { background-color: #fee2e2; color: #991b1b; } /* red */
#reportValueSkipped { background-color: #fef3c7; color: #92400e; } /* amber */
#reportValuePartial { background-color: #e0e7ff; color: #3730a3; } /* indigo */

/* Destaque para o registro atual */
#reportCurrentItemValue {
    background-color: #f3f4f6;
    padding: 0.5rem;
    border-radius: 0.25rem;
    font-family: monospace;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 250px; /* Ajuste conforme necessário */
}

/* --- INÍCIO DA ALTERAÇÃO --- */
/* Estilo para os botões de filtro do relatório */
.report-filter-btn {
    border: none;
    cursor: default; /* Cursor padrão quando desabilitado */
}

.report-filter-btn:not(:disabled) {
    cursor: pointer;
    transition: transform 0.1s ease-in-out, box-shadow 0.1s ease-in-out;
}

.report-filter-btn:not(:disabled):hover {
    transform: scale(1.1);
    box-shadow: 0 2px 8px rgba(0,0,0,0.15);
}
/* --- FIM DA ALTERAÇÃO --- */

/* --- ESTILOS PARA LISTA DE COLETORES COM PAGINAÇÃO --- */
#collectorsListWrapper {
    display: flex;
    flex-direction: column;
    /* A altura será controlada pelo JS para sincronizar com o formulário */
}

#collectorsListContainer {
    flex-grow: 1;
    overflow-y: auto;
    border: 1px solid #e5e7eb; /* gray-200 */
    border-radius: 0.25rem;
}

.collector-pagination-controls {
    flex-shrink: 0;
    padding-top: 0.5rem;
}

/* NOVAS REGRAS PARA A COLUNA DE GRUPOS EXPANSÍVEL */
#collectorGroupsColumn.collapsed {
    flex-grow: 0;
    flex-shrink: 0;
    width: 50px; /* Largura da coluna quando recolhida */
    padding-left: 0.5rem;
    padding-right: 0.5rem;
    overflow: hidden;
}

#collectorGroupsColumn.collapsed .sidebar-text {
    display: none; /* Esconde todo o conteúdo, exceto o botão de toggle */
}

#collectorGroupsColumn.collapsed #toggleGroupsColumnBtn {
    margin: 0 auto; /* Centraliza o botão quando recolhido */
}

#toggleGroupsColumnBtn i {
    transition: transform 0.3s ease-in-out; /* Anima a rotação do ícone */
}

#collectorGroupsColumn.collapsed #toggleGroupsColumnBtn i {
    transform: rotate(180deg); /* Gira a seta para a direita */
}

.remove-condition-group-btn {
  margin-left: auto;
  background-color: #f87171; /* vermelho claro */
  color: white;
  padding: 4px 8px;
  border: none;
  border-radius: 4px;
  cursor: pointer;
}

body.login-active #main-content {
    filter: blur(8px) grayscale(50%);
    transition: filter 0.3s ease-in-out;
    pointer-events: none; /* Impede cliques no fundo */
    user-select: none;    /* Impede seleção de texto no fundo */
}

.template-list-search {
    width: 100%;
    padding: 8px;
    border: 1px solid #d1d5db; /* gray-300 */
    border-radius: 4px;
    margin-bottom: 8px;
    font-size: 0.875rem; /* text-sm */
}

/* Estilos para Drag and Drop de Linhas */
tr.draggable-row {
    cursor: grab;
}
tr.draggable-row:active {
    cursor: grabbing;
}
tr.dragging {
    opacity: 0.4;
    background-color: #e0f2fe; /* blue-100 */
    border: 2px dashed #3b82f6;
}
tr.drag-over {
    border-top: 3px solid #3b82f6; /* Linha azul indicando onde vai cair */
    transition: border-top 0.1s;
}

/* Drag and Drop de Colunas (Cabeçalhos) */
th.draggable-header {
    cursor: grab;
    position: relative;
}
th.draggable-header:active {
    cursor: grabbing;
}
th.column-dragging {
    opacity: 0.4;
    background-color: #e0f2fe; /* blue-100 */
    border: 2px dashed #3b82f6;
}
th.drop-target-left {
    border-left: 4px solid #3b82f6 !important; /* Linha azul à esquerda */
}
th.drop-target-right {
    border-right: 4px solid #3b82f6 !important; /* Linha azul à direita */
}
/* Garante que o ícone de grip apareça */
.header-grip {
    cursor: grab;
    color: #9ca3af; /* gray-400 */
    margin-right: 6px;
}
.header-grip:hover {
    color: #4b5563; /* gray-600 */
}