/* Escopo geral: somente dentro do modal #modalForm */
.modalForm {
  position: fixed;
  top: 5%;
  left: 50%;
  transform: translate(-50%, -5%);
  background: #fff;
  border-radius: 8px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.15);
  padding: 20px 30px;
  width: 90vw;
  max-width: 900px;
  max-height: 98vh;
  overflow-y: auto;
  z-index: 1001;
  display: none;
  font-family: "Segoe UI", Tahoma, Geneva, Verdana, sans-serif;
  color: #333;
  transition: top 0.3s ease, opacity 0.3s ease;

}

.modal-container {
  /* valores padrão */
  --title-bar-bg: #354461;
  --button-bg: #354461;
  --table-header-bg: #354461;
}

#modalOverlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background-color: rgba(0, 0, 0, 0.7);
  z-index: 1000;
  display: none;
}

/* Modificadores de cor para o modal */
.modal-prepag #modalForm {
  --title-bar-bg: #f58220;
  --button-bg: #f58220;
  --table-header-bg: #f58220;
}

.modal-propag #modalForm {
  --title-bar-bg: #1dbbc4;
  --button-bg: #1dbbc4;
  --table-header-bg: #1dbbc4;
}

/* Logo no topo do modal */
#modalForm .logo-container {
  text-align: center;
  margin-bottom: 12px;
}

#modalForm .logo-container img {
  max-width: 150px;
  height: auto;
}

/* Títulos */
#modalForm h3 {
  margin-top: 0;
  font-weight: 600;
  font-size: 1.4rem;
  color: var(--button-bg);
  margin-bottom: 12px;
}

#modalForm h4 {
  font-weight: 500;
  font-size: 1rem;
  margin-top: 4px;
  margin-bottom: 4px;
  color: #555;
}

/* Layout flex para grupos de campos com duas colunas */
#modalForm .form-row {
  display: flex;
  gap: 12px;
  margin-bottom: 8px;
  align-items: flex-start;
}

#modalForm .form-row.single {
  display: block;
  margin-bottom: 8px;
}

#modalForm .form-group {
  flex: 1;
  display: flex;
  flex-direction: column;
}

/* Razão Social ocupa 3/4 da linha, CNPJ 1/4 */
#modalForm .form-row.razao-cnpj .form-group:first-child {
  flex: 3;
}

#modalForm .form-row.razao-cnpj .form-group:last-child {
  flex: 1;
}

/* Labels */
#modalForm label {
  font-weight: 500;
  color: #444;
  margin-bottom: 2px;
  font-size: 0.85rem;
}

/* Inputs */
#modalForm input[type="text"],
#modalForm input[type="email"] {
  padding: 4px 8px;
  font-size: 0.85rem;
  line-height: 1.2;
  border: 1.5px solid #ccc;
  border-radius: 5px;
  transition: border-color 0.3s ease;
}

#modalForm input[type="text"]:focus,
#modalForm input[type="email"]:focus {
  border-color: #354461;
  outline: none;
}

/* Botões padrão do modal */
.modal-button {
  background-color: var(--button-bg);
  color: white;
  padding: 8px 16px;
  margin-right: 10px;
  border: none;
  border-radius: 5px;
  font-weight: 600;
  font-size: 0.95rem;
  cursor: pointer;
  transition: background-color 0.3s ease;
}

#modalForm .modal-button:hover {
  filter: brightness(1.1);
}

/* Botões ícone do modal (adicionar, excluir) */
#modalForm .modal-btn-icon {
  background: transparent;
  border: none;
  cursor: pointer;
  color: #354461;
  font-size: 1.3rem;
  padding: 4px 8px;
  transition: color 0.25s ease;
}

.modal-prepag .modal-btn-icon:hover {
  color: #8f480b;
}

.modal-propag .modal-btn-icon:hover {
  color: #116d72;
}

/* Tabela estilizada */
#modalForm #filiaisTable {
  width: 100%;
  border-collapse: collapse;
  margin-top: 10px;
  font-size: 0.95rem;
  box-shadow: 0 2px 8px rgb(0 0 0 / 0.1);
  border-radius: 6px;
  overflow: hidden;
}

#modalForm #filiaisTable thead tr {
  background-color: var(--table-header-bg);
  color: white;
  text-align: left;
}

#modalForm #filiaisTable th,
#modalForm #filiaisTable td {
  padding: 4px 4px;
  border-bottom: 1px solid #ddd;
  font-size: 0.85rem;
}

#modalForm #filiaisTable th:nth-child(1),
#modalForm #filiaisTable td:nth-child(1),
#modalForm #filiaisTableBodyOnly th:nth-child(1),
#modalForm #filiaisTableBodyOnly td:nth-child(1) {
  width: 5%;
  text-align: center;
}

#modalForm #filiaisTable th:nth-child(2),
#modalForm #filiaisTable td:nth-child(2),
#modalForm #filiaisTableBodyOnly th:nth-child(2),
#modalForm #filiaisTableBodyOnly td:nth-child(2) {
  width: 45%;
  font-family: monospace;
}

#modalForm #filiaisTable th:nth-child(3),
#modalForm #filiaisTable td:nth-child(3),
#modalForm #filiaisTableBodyOnly th:nth-child(3),
#modalForm #filiaisTableBodyOnly td:nth-child(3) {
  width: 25%;
  font-family: monospace;
}

#modalForm #filiaisTable th:nth-child(4),
#modalForm #filiaisTable td:nth-child(4),
#modalForm #filiaisTableBodyOnly th:nth-child(4),
#modalForm #filiaisTableBodyOnly td:nth-child(4) {
  width: 10%;
  font-family: monospace;
}

#modalForm #filiaisTable th:nth-child(5),
#modalForm #filiaisTable td:nth-child(5),
#modalForm #filiaisTableBodyOnly th:nth-child(5),
#modalForm #filiaisTableBodyOnly td:nth-child(5) {
  width: 5%;
  text-align: center;
}

#modalForm #filiaisTable tbody tr:last-child td {
  border-bottom: none;
}

/* Cabeçalho com logo/texto */
.cabecalho-flex {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 20px 5%;
  border-top: 0px solid #e9e9e9;
  background-color: #fff;
}

.logo-esquerda,
.logo-direita {
  flex: 0 0 auto;
}

.logo-esquerda img,
.logo-direita img {
  max-width: 120px;
  height: auto;
}

.cabecalho-textos {
  flex: 1;
  text-align: center;
  font-family: "PF Beau Bold", sans-serif;
}

.cabecalho-textos h1 {
  font-size: 1.8rem;
  color: #354461;
  margin: 0;
}

.cabecalho-textos h2 {
  font-size: 1.1rem;
  font-weight: normal;
  color: #666;
  margin-top: 5px;
}

/* Container de scroll da tabela */
.filiais-scroll-container {
  max-height: 300px;
  overflow-y: auto;
  overflow-x: hidden;
  scrollbar-width: thin;
  scrollbar-color: #ccc transparent;
}

.filiais-scroll-container::-webkit-scrollbar {
  width: 8px;
}

.filiais-scroll-container::-webkit-scrollbar-track {
  background: transparent;
}

.filiais-scroll-container::-webkit-scrollbar-thumb {
  background-color: #aaa;
  border-radius: 6px;
  background-clip: content-box;
  border: 2px solid transparent;
}

.filiais-scroll-container::-webkit-scrollbar-thumb:hover {
  background-color: #888;
}

/* Garante que a tabela do corpo se alinhe ao cabeçalho */
#filiaisTableBodyOnly {
  width: 100%;
  border-collapse: collapse;
}

#filiaisTableBodyOnly td {
  padding: 4px 4px;
  border-bottom: 1px solid #ddd;
  font-size: 0.85rem;
}

/* Modal de termos */
#modalTermos {
  position: fixed;
  top: 5vh;
  left: 5vw;
  width: 90vw;
  height: 90vh;
  background: white;
  border-radius: 10px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.2);
  z-index: 1100;
  display: none;
  padding: 30px 40px;
  display: flex;
  flex-direction: column;
}

#modalTermos h3 {
  font-size: 1.6rem;
  margin-bottom: 8px;
  color: #0073e6;
}

#modalTermos h4 {
  font-size: 1.2rem;
  margin-bottom: 16px;
  color: #555;
}

#modalTermos .conteudoModalTermos {
  flex: 1;
  overflow-y: auto;
  padding-right: 10px;
  margin-bottom: 20px;
  border-top: 1px solid #ccc;
  padding-top: 10px;
}

#modalTermos .btn-fechar-termos {
  align-self: flex-end;
  background-color: #354461;
  color: white;
  padding: 10px 18px;
  border: none;
  border-radius: 6px;
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  transition: background-color 0.3s ease;
}

#modalTermos .btn-fechar-termos:hover {
  background-color: #2a344d;
}

.empresas-box {
  margin: 20px 0;
}

.empresas-title-bar {
  background-color: var(--title-bar-bg);
  color: white;
  font-weight: bold;
  padding: 8px 12px;
  border-radius: 6px;
  text-align: center;
  font-size: 0.95rem;
  margin-bottom: 10px;
}

.empresas-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 10px;
}

.empresas-grid label {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 8px;
  border: 1px solid #ccc;
  border-radius: 8px;
  background: #f9f9f9;
  transition: background 0.2s;
  cursor: pointer;
  height: 35px;
}

.empresas-grid label:hover {
  background: #eef9f9;
}

.empresas-grid input[type="checkbox"] {
  transform: scale(1.3);
  margin: 0;
}

.empresas-grid img {
  width: 90px;
  max-height: 30px;
  object-fit: contain;
}
