:root {
  /* Cores de marca Effec (Site-EFFEC/src/app/globals.css) */
  --cor-fundo: #f5f6f8;
  --cor-texto: #16202c;
  --cor-borda: #dadfe6;
  --cor-primaria: #2f5aa8;
  --cor-primaria-escura: #16213e;
  --cor-primaria-clara: #eaf1fb;
  --cor-sucesso-fundo: #e5f6ea;
  --cor-sucesso-texto: #1c6b34;
  --cor-erro-fundo: #fdeaea;
  --cor-erro-texto: #a3271f;
  --cor-cabecalho-tabela: #eaf1fb;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
  background: var(--cor-fundo);
  color: var(--cor-texto);
}

.topo {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 12px;
  padding: 14px 24px;
  background: white;
  border-bottom: 1px solid var(--cor-borda);
}

.marca { font-weight: 700; font-size: 1.1rem; }
.marca-sub { font-weight: 400; color: #6b7280; font-size: 0.85rem; }
.marca-cliente { font-weight: 600; color: var(--cor-primaria); }

nav a {
  margin-left: 18px;
  text-decoration: none;
  color: var(--cor-texto);
  padding-bottom: 4px;
  border-bottom: 2px solid transparent;
}
nav a:first-child { margin-left: 0; }
nav a.ativo, nav a:hover { border-bottom-color: var(--cor-primaria); color: var(--cor-primaria); }
.separador-nav { margin-left: 18px; color: var(--cor-borda); }
.usuario-logado { margin-left: 10px; color: #6b7280; font-size: 0.85rem; }
.link-botao {
  background: none; border: none; color: var(--cor-texto); text-decoration: underline;
  cursor: pointer; font-size: 0.9rem; padding: 0; margin-left: 10px; margin-top: 0;
}
.link-botao:hover { color: var(--cor-primaria); background: none; }

main { max-width: 1080px; margin: 0 auto; padding: 24px; }

h1 { font-size: 1.4rem; margin-bottom: 4px; }
.subtitulo { color: #6b7280; margin-top: 0; margin-bottom: 20px; }

.cartao {
  background: white;
  border: 1px solid var(--cor-borda);
  border-radius: 10px;
  padding: 18px 20px;
  margin-bottom: 20px;
  box-shadow: 0 1px 2px rgba(22, 33, 62, 0.04);
}

.flashes { margin-bottom: 16px; }
.flash { padding: 10px 14px; border-radius: 6px; margin-bottom: 8px; font-size: 0.92rem; }
.flash-sucesso { background: var(--cor-sucesso-fundo); color: var(--cor-sucesso-texto); }
.flash-erro { background: var(--cor-erro-fundo); color: var(--cor-erro-texto); }

table { width: 100%; border-collapse: collapse; font-size: 0.9rem; }
th, td { text-align: left; padding: 8px 10px; border-bottom: 1px solid var(--cor-borda); vertical-align: top; }
th { background: var(--cor-cabecalho-tabela); font-weight: 600; }
tbody tr { transition: background-color 0.15s ease; }
tbody tr:hover { background-color: var(--cor-primaria-clara); }
.tabela-scroll { overflow-x: auto; }

label { display: block; font-size: 0.85rem; font-weight: 600; margin-bottom: 4px; margin-top: 10px; }
input[type=text], input[type=date], input[type=number], input[type=password], input[type=email], select, textarea {
  width: 100%;
  padding: 7px 9px;
  border: 1px solid var(--cor-borda);
  border-radius: 5px;
  font-size: 0.92rem;
  font-family: inherit;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}
input[type=text]:focus, input[type=date]:focus, input[type=number]:focus, input[type=password]:focus,
input[type=email]:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--cor-primaria);
  box-shadow: 0 0 0 3px var(--cor-primaria-clara);
}
input[type=file] { margin-top: 4px; }

.linha-form { display: flex; gap: 16px; flex-wrap: wrap; }
.linha-form > div { flex: 1; min-width: 160px; }

button, .botao {
  display: inline-block;
  background: var(--cor-primaria);
  color: white;
  border: none;
  padding: 9px 16px;
  border-radius: 6px;
  font-size: 0.92rem;
  cursor: pointer;
  text-decoration: none;
  margin-top: 12px;
  transition: background-color 0.15s ease, transform 0.1s ease, opacity 0.15s ease;
}
button:hover, .botao:hover { background: var(--cor-primaria-escura); }
button:active, .botao:active { transform: scale(0.97); }
button:disabled { cursor: default; opacity: 0.7; transform: none; }
button.secundario, .botao.secundario { background: #6b7280; }
button.perigo, .botao.perigo { background: #b3261e; }
button.pequeno { padding: 4px 10px; font-size: 0.8rem; margin-top: 0; }

/* Estado de carregamento do HTMX: esconde o texto original e mostra o
   spinner + rótulo em data-carregando (ex.: hx-indicator no próprio botão). */
.htmx-request .rotulo-padrao { display: none; }
.htmx-request .rotulo-carregando { display: inline-flex !important; }
.rotulo-carregando {
  display: none;
  align-items: center;
  gap: 6px;
}
.spinner {
  width: 13px;
  height: 13px;
  border: 2px solid rgba(255, 255, 255, 0.5);
  border-top-color: white;
  border-radius: 50%;
  animation: girar 0.6s linear infinite;
}
button.secundario .spinner { border-color: rgba(255, 255, 255, 0.5); border-top-color: white; }
@keyframes girar { to { transform: rotate(360deg); } }

/* Conteúdo trocado via HTMX entra com um fade sutil, em vez de "piscar". */
.htmx-swapping { opacity: 0; transition: opacity 0.1s ease-out; }
.htmx-added { opacity: 0; }
tbody tr.htmx-settling, .htmx-settling { opacity: 1; transition: opacity 0.2s ease-in; }

.acoes-linha { display: flex; gap: 6px; }
.acoes-linha form { display: inline; }

.grade-4 { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; text-align: center; }
.grade-4 .stat { background: var(--cor-cabecalho-tabela); border-radius: 6px; padding: 12px; }
.grade-4 .stat .numero { font-size: 1.5rem; font-weight: 700; }
.grade-4 .stat .rotulo { font-size: 0.78rem; color: #6b7280; }

.mensagens-progresso {
  background: #101418;
  color: #cfe6ff;
  font-family: "SFMono-Regular", Consolas, monospace;
  font-size: 0.8rem;
  padding: 10px 12px;
  border-radius: 6px;
  white-space: pre-wrap;
  max-height: 160px;
  overflow-y: auto;
}

code { background: var(--cor-cabecalho-tabela); padding: 1px 5px; border-radius: 4px; }

.ajuda { font-size: 0.82rem; color: #6b7280; }

details.ajuda-import { margin-top: 8px; }

.lista-permissoes {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 18px;
  background: var(--cor-cabecalho-tabela);
  border-radius: 6px;
  padding: 10px 12px;
  margin-top: 4px;
}
.item-permissao { font-size: 0.88rem; font-weight: 400; margin: 0; }

summary.botao, summary.botao.secundario { cursor: pointer; list-style: none; }
summary.botao::-webkit-details-marker { display: none; }

/* Toasts — substituem o antigo bloco de flash messages fixo no topo. */
#toasts {
  position: fixed;
  top: 18px;
  right: 18px;
  z-index: 1000;
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-width: 340px;
}
.toast {
  background: white;
  border-left: 4px solid var(--cor-primaria);
  border-radius: 6px;
  padding: 12px 14px;
  font-size: 0.88rem;
  box-shadow: 0 4px 14px rgba(22, 33, 62, 0.16);
  cursor: pointer;
  opacity: 0;
  transform: translateX(12px);
  transition: opacity 0.2s ease, transform 0.2s ease;
}
.toast-visivel { opacity: 1; transform: translateX(0); }
.toast-sucesso { border-left-color: var(--cor-sucesso-texto); color: var(--cor-sucesso-texto); }
.toast-erro { border-left-color: var(--cor-erro-texto); color: var(--cor-erro-texto); }

/* Modal genérico, populado via HTMX (hx-target="#modal-conteudo"). */
#modal {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(22, 33, 62, 0.45);
  z-index: 900;
  align-items: flex-start;
  justify-content: center;
  padding: 8vh 16px;
}
#modal.modal-aberto { display: flex; }
#modal-conteudo {
  background: white;
  border-radius: 10px;
  padding: 22px 24px;
  width: 100%;
  max-width: 480px;
  max-height: 80vh;
  overflow-y: auto;
  box-shadow: 0 12px 32px rgba(22, 33, 62, 0.25);
}
#modal-conteudo > .cartao { border: none; box-shadow: none; padding: 0; margin-bottom: 0; }
.modal-titulo { margin-top: 0; font-size: 1.1rem; }
.modal-rodape { display: flex; justify-content: flex-end; gap: 8px; margin-top: 16px; }
