/* cadastros.css — botão "Cadastros" (submenu) + formulário dos cadastros
   tributários de campo. Layout imita as telas do sistema tributário (barra por
   seção, rótulo em negrito, obrigatório em vermelho) no AZUL DO PORTAL BlueGeo
   (#003b73, o do cabeçalho e dos modais — pedido do dono, 28/10/2026). */
:root {
  --cad-azul: #003b73;        /* cabeçalho/modais do portal */
  --cad-azul-escuro: #002550;
  --cad-azul-claro: #1a5276;  /* barras de seção e botões */
  --cad-azul-fundo: #eaf1f8;
}

/* ── Submenu no painel de Ferramentas ─────────────────────────── */
#btnCadastros::after { content: " ▸"; }
#btnCadastros.cad-aberto::after { content: " ▾"; }
#cadastrosSubmenu {
  margin: 0 0 4px 12px;
  padding-left: 8px;
  border-left: 3px solid var(--cad-azul);
}
#cadastrosSubmenu .tool-btn { width: 100%; }

/* ── Painel do formulário ─────────────────────────────────────── */
.cad-panel {
  position: fixed;
  top: 70px;
  left: 50%;
  transform: translateX(-50%);
  width: min(980px, calc(100vw - 32px));
  max-height: calc(100vh - 90px);
  display: flex;
  flex-direction: column;
  background: #fff;
  color: #222;
  border-radius: 8px;
  box-shadow: 0 8px 28px rgba(0, 0, 0, .28);
  z-index: 3000;
  font-size: 13px;
  min-width: 300px;
  min-height: 200px;
}
.cad-panel.hidden { display: none; }
/* "Marcar no mapa": some de vista para o clique cair no mapa, sem perder o que foi digitado */
.cad-panel.cad-minimizado { display: none; }
/* ModalDrag fixa left/top em px; sem isto o translate deslocaria o painel arrastado */
.cad-panel[data-drag-ready] { transform: none; }

.cad-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 14px;
  background: var(--cad-azul);
  color: #fff;
  border-radius: 8px 8px 0 0;
}
.cad-titulo { font-weight: 600; font-size: 15px; }
.cad-x { background: none; border: none; color: #fff; font-size: 18px; cursor: pointer; padding: 0 4px; }

.cad-barra {
  display: flex;
  gap: 8px;
  align-items: center;
  flex-wrap: wrap;
  padding: 8px 14px;
  background: var(--cad-azul-fundo);
  border-bottom: 1px solid #d3dfeb;
}
.cad-btn {
  background: var(--cad-azul-claro);
  color: #fff;
  border: none;
  border-radius: 4px;
  padding: 6px 12px;
  cursor: pointer;
  font-size: 13px;
}
.cad-btn:hover { background: var(--cad-azul); }
.cad-btn:disabled { opacity: .6; cursor: wait; }
.cad-btn-pri { background: var(--cad-azul); font-weight: 600; }
.cad-btn-pri:hover { background: var(--cad-azul-escuro); }
/* "Apagar" do formulário (05/11/2026): só para o administrador do módulo, com um cadastro salvo aberto */
.cad-btn.hidden { display: none; }
.cad-btn-perigo { background: #c0392b; }
.cad-btn-perigo:hover { background: #962d22; }
.cad-status { margin-left: auto; font-size: 12px; color: #555; }
.cad-status-ok { color: #2f9e44; }
.cad-status-erro { color: #c0392b; }

/* Cartão do lote (cd_lote) no alto, fora da área que rola — o mesmo visual do
   "📍 Lote" do Cadastro Social (04/11/2026). */
.cad-lote-card {
  flex-shrink: 0;
  display: flex; align-items: center; gap: 8px; flex-wrap: wrap;
  background: #f0f7f3; border-bottom: 1.5px solid #c8e6c9;
  padding: 8px 14px; color: #1a6b3a;
}
.cad-lote-card:empty { display: none; }
.cad-lote-rot { font-weight: 700; font-size: 0.78rem; text-transform: uppercase; letter-spacing: .04em; }
.cad-lote-cd { font-size: 1.05rem; }
.cad-lote-extra { color: #4b6b57; font-size: 0.78rem; }
.cad-lote-card-ponto { background: #fff4e6; border-bottom-color: #ffd8a8; color: #9a3412; }
.cad-lote-card-ponto .cad-lote-extra { color: #9a3412; }

.cad-body { overflow: auto; padding: 4px 14px 14px; }

.cad-sec { margin-top: 12px; }
.cad-sec-titulo {
  background: var(--cad-azul-claro);
  color: #fff;
  text-align: center;
  font-weight: 600;
  padding: 4px 0;
  border-radius: 2px;
  margin-bottom: 8px;
}
.cad-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 10px 14px;
}
.cad-fld { display: flex; flex-direction: column; gap: 3px; min-width: 0; }
.cad-fld-largo { grid-column: 1 / -1; }
.cad-fld label { font-weight: 600; font-size: 12px; color: #222; }
.cad-fld label.cad-lbl-req { color: #b0003a; }
.cad-req { color: #b0003a; }
.cad-fld input,
.cad-fld select,
.cad-fld textarea {
  border: 1px solid #c9d1d9;
  border-radius: 4px;
  padding: 6px 8px;
  font: inherit;
  background: #fff;
  color: #222;
  width: 100%;
  box-sizing: border-box;
}
.cad-fld input:focus,
.cad-fld select:focus,
.cad-fld textarea:focus { outline: 2px solid var(--cad-azul-claro); outline-offset: -1px; }
.cad-fld textarea { resize: vertical; }
/* Campo preenchido pelo lote do mapa (sugestão): verde claro até a pessoa mexer */
.cad-fld-auto input,
.cad-fld-auto select,
.cad-fld-auto textarea { background: #f0faf4; border-color: #9fd3b0; }
.cad-fld-erro input,
.cad-fld-erro select,
.cad-fld-erro textarea { border-color: #c0392b; background: #fff5f5; }
.cad-erro { color: #c0392b; font-size: 11px; min-height: 0; }
.cad-fld-acao { justify-content: flex-end; }
.cad-rodape { margin-top: 12px; font-size: 12px; color: #666; }

/* ── Lista ────────────────────────────────────────────────────── */
.cad-lista-busca { display: flex; gap: 8px; margin: 12px 0; }
.cad-lista-busca input { flex: 1; border: 1px solid #c9d1d9; border-radius: 4px; padding: 6px 8px; font: inherit; }
.cad-lista-msg { color: #666; padding: 12px 0; }
.cad-tabela { width: 100%; border-collapse: collapse; }
.cad-tabela th { text-align: left; background: var(--cad-azul-fundo); color: var(--cad-azul); padding: 8px 6px; font-size: 12px; }
.cad-tabela td { padding: 8px 6px; border-top: 1px solid #eef0f2; }
.cad-tabela tbody tr { cursor: pointer; }
.cad-tabela tbody tr:hover { background: #eef6fc; }

/* ── Banner do "clique no lote" / "Marcar no mapa" ────────────── */
.cad-banner {
  position: fixed;
  top: 70px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--cad-azul);
  color: #fff;
  padding: 8px 16px;
  border-radius: 20px;
  z-index: 3001;
  box-shadow: 0 4px 12px rgba(0, 0, 0, .25);
  font-size: 13px;
  display: flex;
  align-items: center;
  gap: 12px;
}
.cad-banner-x {
  width: 24px; height: 24px; padding: 0; border-radius: 50%;
  border: 1.5px solid rgba(255, 255, 255, .6);
  background: rgba(255, 255, 255, .2);
  color: #fff; font-size: 16px; line-height: 1; cursor: pointer;
  display: inline-flex; align-items: center; justify-content: center;
}
.cad-banner-x:hover { background: rgba(255, 255, 255, .4); }
/* Tooltip sobre o lote pintado (mesmo visual do Cadastro Social) */
.cad-status-tip {
  position: fixed;
  pointer-events: none;
  z-index: 99999;
  background: rgba(20, 20, 20, 0.92);
  color: #fff;
  padding: 5px 9px;
  border-radius: 5px;
  font-size: 11.5px;
  line-height: 1.35;
  white-space: nowrap;
  display: none;
}

/* ── Celular: uma coluna, tela cheia ──────────────────────────── */
@media (max-width: 640px) {
  .cad-panel {
    top: 0; left: 0; transform: none;
    width: 100vw; max-height: 100vh; height: 100vh;
    border-radius: 0;
  }
  .cad-head { border-radius: 0; }
  .cad-grid { grid-template-columns: 1fr; }
  .cad-tabela { font-size: 12px; }
}

/* ── Tema escuro ──────────────────────────────────────────────── */
html[data-theme="dark"] .cad-panel { background: #1e2329; color: #e6e6e6; }
html[data-theme="dark"] .cad-barra { background: #262c33; border-color: #333a42; }
html[data-theme="dark"] .cad-lote-card { background: #16301f; border-color: #2f7a4a; color: #9be3b4; }
html[data-theme="dark"] .cad-lote-extra { color: #b9d8c4; }
html[data-theme="dark"] .cad-lote-card-ponto { background: #3a2a14; border-color: #7a5a2f; color: #ffc078; }
html[data-theme="dark"] .cad-lote-card-ponto .cad-lote-extra { color: #ffc078; }
html[data-theme="dark"] .cad-fld label { color: #e6e6e6; }
html[data-theme="dark"] .cad-fld label.cad-lbl-req,
html[data-theme="dark"] .cad-req { color: #ff7b9c; }
html[data-theme="dark"] .cad-fld input,
html[data-theme="dark"] .cad-fld select,
html[data-theme="dark"] .cad-fld textarea,
html[data-theme="dark"] .cad-lista-busca input { background: #14181c; color: #e6e6e6; border-color: #3a424b; }
html[data-theme="dark"] .cad-fld-auto input,
html[data-theme="dark"] .cad-fld-auto select,
html[data-theme="dark"] .cad-fld-auto textarea { background: #16301f; border-color: #2f7a4a; }
html[data-theme="dark"] .cad-tabela th { background: #262c33; color: #9cc4ea; }
html[data-theme="dark"] .cad-tabela td { border-color: #333a42; }
html[data-theme="dark"] .cad-tabela tbody tr:hover { background: #24313d; }
html[data-theme="dark"] .cad-rodape,
html[data-theme="dark"] .cad-status { color: #aab2bb; }

/* Arquivos anexados (V277) */
.cad-anexos { display: flex; flex-wrap: wrap; gap: 8px; margin: 6px 0; }
.cad-anexo { position: relative; width: 104px; border: 1px solid #cfd8e3; border-radius: 6px; padding: 4px; background: #fff; text-align: center; font-size: 11px; }
.cad-anexo-novo { border-style: dashed; background: #f3faf5; }
.cad-anexo-img { width: 94px; height: 70px; object-fit: cover; border-radius: 4px; display: block; }
.cad-anexo-pdf { display: flex; align-items: center; justify-content: center; width: 94px; height: 70px; background: #eef2f7; border-radius: 4px; color: #1f4e79; text-decoration: none; font-weight: 600; }
.cad-anexo-nome { display: block; margin-top: 3px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: #555; }
.cad-anexo-x { position: absolute; top: -7px; right: -7px; width: 20px; height: 20px; border-radius: 50%; border: 0; background: #c0392b; color: #fff; font-size: 11px; line-height: 20px; cursor: pointer; padding: 0; }
.cad-anexos-vazio { color: #888; font-size: 12px; }
.cad-anexos-acoes { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.cad-anexos-msg { color: #666; }
html[data-theme="dark"] .cad-anexo { background: #1b2026; border-color: #3a424b; }
html[data-theme="dark"] .cad-anexo-novo { background: #16301f; }
html[data-theme="dark"] .cad-anexo-pdf { background: #262c33; color: #9cc4ea; }
html[data-theme="dark"] .cad-anexo-nome, html[data-theme="dark"] .cad-anexos-msg { color: #aab2bb; }
