/* Estilos específicos para a página de Empresas */

body.modal-open {
  overflow: hidden !important;
  padding-right: 0 !important;
}

/* Tabela de Empresas */
#empresasTable {
  font-size: 0.85rem;
  min-width: 2000px; /* Largura mínima para acomodar todas as colunas */
  table-layout: fixed; /* Força o uso dos widths definidos */
  width: 100%;
}

.table-responsive {
  overflow-x: auto;
  overflow-y: auto;
}

#empresasTable thead th {
  font-weight: 600;
  color: #333;
  border-bottom: 2px solid #dee2e6;
  position: sticky;
  top: 0;
  background: #f8f9fa;
  z-index: 10;
  padding: 12px 16px;
  width: 200px;
}

#empresasTable tbody tr {
  border-bottom: 1px solid #f0f0f0;
  transition: background-color 0.2s ease;
}

#empresasTable tbody tr:hover {
  background-color: #f8f9fa;
}

#empresasTable tbody td {
  vertical-align: middle;
  padding: 10px 12px;
  white-space: normal;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Respeitar widths inline definidos no HTML */
#empresasTable thead th:first-child,
#empresasTable tbody td:first-child {
  width: 60px;
  min-width: 60px;
  max-width: 60px;
}

#empresasTable thead th:last-child,
#empresasTable tbody td:last-child {
  width: 120px;
  min-width: 120px;
  max-width: 120px;
}

/* Texto indefinido */
.text-indefinido {
  color: #999;
  font-style: italic;
}

/* Barra de busca */
#searchInput {
  border-radius: 8px 0 0 8px;
}

#searchBtn {
  border-radius: 0 8px 8px 0;
  border-left: none;
}

/* Botões de ação */
.btn-dark {
  background-color: #6c757d;
  border-color: #6c757d;
}

.btn-dark:hover {
  background-color: #5a6268;
  border-color: #5a6268;
}

/* Barra de progresso */
#progressBar {
  transition: width 0.3s ease;
  background-color: #c6254e;
}

/* Responsividade */
@media (max-width: 768px) {
  #empresasTable {
    font-size: 0.8rem;
  }

  #empresasTable tbody td {
    padding: 8px 12px;
  }

  .empresa-icon {
    font-size: 0.8rem;
  }
}

/* Scrollbar customizada para a tabela */
.table-responsive::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}

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

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

.table-responsive::-webkit-scrollbar-thumb:hover {
  background: #a01e3f;
}

/* Estilos para Modal de Ordenação */
#sortModal {
  z-index: 1055 !important;
}

#sortModal .modal-dialog {
  z-index: 1056 !important;
  position: relative;
}

.modal-backdrop {
  z-index: 1050 !important;
  background-color: rgba(0, 0, 0, 0.5) !important;
  position: fixed !important;
  top: 0 !important;
  left: 0 !important;
  width: 100vw !important;
  height: 100vh !important;
}

.modal-backdrop.show {
  opacity: 0.5 !important;
}

/* Garantir que o modal fique acima de tudo */
.modal.show {
  display: block !important;
  z-index: 1055 !important;
}

/* Remover backdrops duplicados */
body.modal-open {
  overflow: hidden !important;
  padding-right: 0 !important;
}

/* Garantir que apenas um backdrop exista */
.modal-backdrop:not(:first-of-type) {
  display: none !important;
}

/* Estilos para seleção de produtos */
#produtosContainer {
  position: relative;
}

#produtosTags .badge {
  padding: 0.375rem 0.5rem;
  font-weight: 500;
}

#produtosTags .badge i {
  margin-left: 0.25rem;
  opacity: 0.8;
  transition: opacity 0.2s;
}

#produtosTags .badge i:hover {
  opacity: 1;
}

#produtosDropdown {
  box-shadow: 0 0.5rem 1rem rgba(0, 0, 0, 0.15) !important;
}

#produtosList .list-group-item {
  border-left: none;
  border-right: none;
  padding: 0.75rem 1rem;
}

#produtosList .list-group-item:hover {
  background-color: #f8f9fa;
}

#produtosList .list-group-item.active {
  background-color: #0d6efd;
  color: white;
}

#pessoasContainer .pessoa-item .remove-pessoa-btn {
  color: #dc3545;
  cursor: pointer;
  transition: color 0.2s;
}

#pessoasContainer .pessoa-item .remove-pessoa-btn:hover {
  color: #a71d2a;
}

#adicionarPessoaBtn {
  text-decoration: none;
  font-weight: 500;
}

#adicionarPessoaBtn:hover {
  text-decoration: underline;
}

/* Estilos para seção de redes sociais */
.form-label {
  font-weight: 500;
  margin-bottom: 0.5rem;
}

input[id^="empresa"]:focus {
  border-color: #c6254e;
  box-shadow: 0 0 0 0.2rem rgba(198, 37, 78, 0.25);
}

/* Estilos para links de "Ver Produtos" e "Ver Pessoas" */
.table a.text-primary {
  font-weight: 500;
  transition: all 0.2s ease;
}

/* Estilos para modais de visualização */
#viewProdutosModal .modal-body,
#viewPessoasModal .modal-body {
  padding: 1.5rem;
}

#viewProdutosModal .table,
#viewPessoasModal .table {
  margin-bottom: 0;
}

#viewProdutosModal .table thead th,
#viewPessoasModal .table thead th {
  background-color: #f8f9fa;
  border-bottom: 2px solid #dee2e6;
  font-weight: 600;
  padding: 0.75rem;
}

#viewProdutosModal .table tbody td,
#viewPessoasModal .table tbody td {
  padding: 0.75rem;
  vertical-align: middle;
}

/* Estilos para botões de ação */
.btn.btn-outline-primary.btn-sm {
  width: 120px;
}

#addEmpresaBtn {
  background-color: #c6254e;
  border-color: #c6254e;
}

#addEmpresaBtn:hover {
  background-color: #a01e3f;
  border-color: #a01e3f;
}

#addEmpresaBtn:active {
  background-color: #a01e3f !important;
  border-color: #a01e3f !important;
}

#addEmpresaBtn:focus-visible {
  background-color: #a01e3f !important;
  border-color: #a01e3f !important;
}

#empresaDetailsExcluirBtn:active {
  color: white !important;
}

#empresaDetailsExcluirBtn:focus-visible {
  color: white !important;
}

.btn-group .btn {
  border-radius: 0;
}

.btn-group .btn:first-child {
  border-top-left-radius: 0.25rem;
  border-bottom-left-radius: 0.25rem;
}

.btn-group .btn:last-child {
  border-top-right-radius: 0.25rem;
  border-bottom-right-radius: 0.25rem;
}

.btn-group .btn-danger:hover {
  background-color: #c82333;
  border-color: #bd2130;
}

#viewEmpresaContent .form-label {
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  font-weight: 600;
}

#viewEmpresaContent p {
  font-size: 0.95rem;
}

/* Estilos para o novo modal de visualizar empresa */
#viewEmpresaModal .modal-dialog {
  z-index: 1056 !important;
  position: relative;
  max-width: 95vw;
  margin: 1.75rem auto;
}

#viewEmpresaModal .modal-content {
  height: 85vh;
  max-height: 85vh;
}

#viewEmpresaModal .modal-body {
  overflow-y: auto;
  height: calc(85vh - 200px);
}

/* Badge circle para responsável */
.badge-circle {
  width: 24px;
  height: 24px;
  font-size: 0.7rem;
}

.badge-circle-small {
  width: 20px;
  height: 20px;
}

.icon-small {
  font-size: 0.8rem;
}

/* WhatsApp numbers card */
.whatsapp-numbers-card {
  display: none;
  z-index: 1060;
  min-width: 250px;
  max-width: 300px;
}

.whatsapp-numbers-card.show {
  display: block;
}

/* Estilos para funcionalidade Ver mais/Ver menos */
.descricao-container {
  word-wrap: break-word;
  word-break: break-word;
  line-height: 1.4;
}

.descricao-toggle {
  font-size: 0.85rem;
  font-weight: 500;
  transition: color 0.2s ease;
}

.descricao-toggle:hover {
  color: #0056b3 !important;
  text-decoration: underline !important;
}

/* Estilos para edição inline dos campos da empresa */
.empresa-cnpj-display:hover,
.empresa-cnpj-add:hover,
.empresa-razao-display:hover,
.empresa-razao-add:hover,
.empresa-categoria-display:hover,
.empresa-categoria-add:hover,
.empresa-origem-display:hover,
.empresa-origem-add:hover,
.empresa-responsavel-display:hover,
.empresa-responsavel-add:hover,
.empresa-setor-display:hover,
.empresa-setor-add:hover,
.empresa-descricao-display:hover,
.empresa-descricao-add:hover,
.empresa-email-display:hover,
.empresa-email-add:hover,
.empresa-celular-display:hover,
.empresa-celular-add:hover,
.empresa-whatsapp-display:hover,
.empresa-whatsapp-add:hover,
.empresa-telefone-display:hover,
.empresa-telefone-add:hover,
.empresa-website-display:hover,
.empresa-website-add:hover,
.empresa-cadastrado-display:hover,
.empresa-cadastrado-add:hover {
  color: #6f42c1 !important;
}

.empresa-cnpj-edit.show,
.empresa-razao-edit.show,
.empresa-categoria-edit.show,
.empresa-origem-edit.show,
.empresa-responsavel-edit.show,
.empresa-setor-edit.show,
.empresa-descricao-edit.show,
.empresa-email-edit.show,
.empresa-celular-edit.show,
.empresa-whatsapp-edit.show,
.empresa-telefone-edit.show,
.empresa-website-edit.show,
.empresa-cadastrado-edit.show {
  display: block !important;
}

.empresa-cnpj-edit .form-control-sm,
.empresa-razao-edit .form-control-sm,
.empresa-categoria-edit .form-select-sm,
.empresa-origem-edit .form-select-sm,
.empresa-responsavel-edit .form-select-sm,
.empresa-setor-edit .form-select-sm,
.empresa-descricao-edit .form-control-sm,
.empresa-email-edit .form-control-sm,
.empresa-celular-edit .form-control-sm,
.empresa-whatsapp-edit .form-control-sm,
.empresa-telefone-edit .form-control-sm,
.empresa-website-edit .form-control-sm,
.empresa-cadastrado-edit .form-select-sm {
  font-size: 0.875rem;
  border-radius: 0.25rem;
}

.empresa-cnpj-edit .btn-sm,
.empresa-razao-edit .btn-sm,
.empresa-categoria-edit .btn-sm,
.empresa-origem-edit .btn-sm,
.empresa-responsavel-edit .btn-sm,
.empresa-setor-edit .btn-sm,
.empresa-descricao-edit .btn-sm,
.empresa-email-edit .btn-sm,
.empresa-celular-edit .btn-sm,
.empresa-whatsapp-edit .btn-sm,
.empresa-telefone-edit .btn-sm,
.empresa-website-edit .btn-sm,
.empresa-cadastrado-edit .btn-sm {
  padding: 0.25rem 0.5rem;
  font-size: 0.75rem;
}

/* Estilos para edição inline do email no header */
.empresa-header-email-edit.show {
  display: block !important;
}

/* Estilos para edição inline do telefone no header */
.empresa-header-telefone-edit.show {
  display: block !important;
}

#empresaDetailsTelefoneEditContainer {
  margin-top: 5px;
}

#empresaDetailsTelefoneEditContainer .form-control-sm {
  font-size: 0.875rem;
  border-radius: 0.25rem;
}

#empresaDetailsTelefoneEditContainer .btn-sm {
  padding: 0.25rem 0.5rem;
  font-size: 0.75rem;
}

.empresa-header-email-edit .form-control-sm {
  font-size: 0.875rem;
  border-radius: 0.25rem;
}

.empresa-header-email-edit .btn-sm {
  padding: 0.25rem 0.5rem;
  font-size: 0.75rem;
}

/* Estilos para modal de excluir empresa */
#deleteEmpresaModal .modal-header {
  background-color: #dc3545;
}

/* Estilos genéricos para tabelas (compatibilidade) */
.table thead th {
  font-weight: 600;
  color: #333;
  border-bottom: 2px solid #dee2e6;
  position: sticky;
  top: 0;
  background: #f8f9fa;
  z-index: 10;
}

.table tbody tr {
  border-bottom: 1px solid #f0f0f0;
}

.table tbody tr:hover {
  background-color: #f8f9fa;
}

.table tbody td {
  vertical-align: middle;
  padding: 12px 16px;
}

@media (max-width: 768px) {
  .table-responsive {
    font-size: 0.875rem;
  }

  .table tbody td {
    padding: 8px 12px;
  }
}

#empresaNegociosTable {
  font-size: 1rem;
  min-width: 2000px;
  table-layout: fixed;
  width: 100%;
}

#empresaNegociosTable thead th:first-child,
#empresaNegociosTable tbody td:first-child {
  width: 60px;
  min-width: 60px;
  max-width: 60px;
}

#empresaNegociosTable thead th {
  font-weight: 600;
  color: #333;
  border-bottom: 2px solid #dee2e6;
  position: sticky;
  top: 0;
  background: #f8f9fa;
  z-index: 10;
  padding: 12px 16px;
  width: 200px;
}

#empresaNegociosTable tbody tr {
  border-bottom: 1px solid #f0f0f0;
  transition: background-color 0.2s ease;
}

#empresaNegociosTable tbody td {
  vertical-align: middle;
  padding: 10px 12px;
  white-space: normal;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Estilos para edição inline do Endereço (card style) */
.endereco-edit-cell {
  position: relative;
}

.endereco-display {
  cursor: pointer;
  border-radius: 4px;
  transition: background-color 0.2s;
}

.endereco-edit-card {
  box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1), 0 2px 4px rgba(0, 0, 0, 0.06);
  border: 1px solid #dee2e6;
}

.endereco-edit-card .card-header {
  background-color: #f8f9fa;
  border-bottom: 1px solid #dee2e6;
  padding: 0.75rem 1rem;
}

.endereco-edit-card .card-body {
  padding: 1rem;
  max-height: 70vh;
  overflow-y: auto;
}

.endereco-edit-card .form-label {
  font-weight: 500;
  margin-bottom: 0.25rem;
}

.endereco-edit-card .form-control-sm {
  font-size: 0.875rem;
}

.endereco-edit-card-positioned {
  display: none;
  z-index: 1050;
  min-width: 400px;
  max-width: 500px;
  top: -200px;
  transform: translateX(-35%);
}

.text-max-width-60 {
  max-width: 60%;
  word-wrap: break-word;
}

.icon-edit {
  font-size: 0.875rem;
}

/* Estilos para edição inline das redes sociais */
.empresa-facebook-display:hover,
.empresa-twitter-display:hover,
.empresa-linkedin-display:hover,
.empresa-instagram-display:hover,
.empresa-skype-display:hover {
  color: #6f42c1 !important;
  text-decoration: underline;
}

.empresa-facebook-add:hover,
.empresa-twitter-add:hover,
.empresa-linkedin-add:hover,
.empresa-instagram-add:hover,
.empresa-skype-add:hover {
  color: #6f42c1 !important;
  text-decoration: underline;
}

/* Forçar esconder os containers de edição quando não estão ativos */
div[id*="_edit"]:not(.show) {
  display: none !important;
}

/* Mostrar os containers de edição quando estão ativos */
div[id*="_edit"].show {
  display: flex !important;
  align-items: center;
  gap: 0.5rem;
}

.dropdown-toggle::after {
  display: none;
}

#empresaPessoasTable {
  font-size: 1rem;
  min-width: 1400px;
  table-layout: fixed;
  width: 100%;
}

#empresaPessoasTable thead th:first-child,
#empresaPessoasTable tbody td:first-child {
  width: 60px;
  min-width: 60px;
  max-width: 60px;
}

#empresaPessoasTable thead th {
  font-weight: 600;
  color: #333;
  border-bottom: 2px solid #dee2e6;
  position: sticky;
  top: 0;
  background: #f8f9fa;
  z-index: 10;
  padding: 12px 16px;
  width: 200px;
}

#empresaPessoasTable tbody tr {
  border-bottom: 1px solid #f0f0f0;
  transition: background-color 0.2s ease;
}

#empresaPessoasTable tbody td {
  vertical-align: middle;
  padding: 10px 12px;
  white-space: normal;
  overflow: hidden;
  text-overflow: ellipsis;
}
