/* =====================================================================
 *  MÓDULO MAPAS — estilos (prefixo mp- em tudo; não depende de nada)
 *  Variáveis em :root.mp-* para ajustar à identidade do projeto hospedeiro.
 * ===================================================================== */
:root {
  --mp-primaria: #1d4ed8;
  --mp-primaria-escura: #1e40af;
  --mp-perigo: #dc2626;
  --mp-texto: #1f2937;
  --mp-texto-fraco: #6b7280;
  --mp-borda: #e5e7eb;
  --mp-fundo: #f8fafc;
  --mp-painel: #ffffff;
  --mp-fonte: system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
  --mp-raio: 8px;
  --mp-sombra: 0 10px 30px rgba(0,0,0,.18);
}

/* ------------------------------------------------------------ canvas */
.mp-canvas { position: relative; overflow: hidden; background: #e9edf2; touch-action: none; user-select: none; }
.mp-vp { position: absolute; inset: 0; overflow: hidden; cursor: grab; }
.mp-vp:active, .mp-vp.mp-pan { cursor: grabbing; }
.mp-world { position: absolute; left: 0; top: 0; transform-origin: 0 0; will-change: transform; }
.mp-img { display: block; position: absolute; left: 0; top: 0; max-width: none; pointer-events: none; }
.mp-svg { position: absolute; left: 0; top: 0; overflow: visible; }

.mp-poly {
  fill: var(--mp-cor, #2563eb); fill-opacity: .28;
  stroke: var(--mp-cor, #2563eb); stroke-width: 2; vector-effect: non-scaling-stroke;
  stroke-linejoin: round; cursor: pointer; transition: fill-opacity .2s, stroke-opacity .2s;
}
.mp-poly:hover { fill-opacity: .45; }
.mp-poly.mp-est-esmaecido { fill-opacity: .07; stroke-opacity: .25; }
.mp-poly.mp-est-destaque { fill-opacity: .5; stroke-width: 3; }
.mp-poly.mp-est-selecionado { fill-opacity: .35; stroke-width: 2.5; stroke: #dc2626; }
.mp-poly.mp-est-vivo {
  fill-opacity: .55; stroke-width: 3.5; stroke: #fff; filter: drop-shadow(0 0 6px var(--mp-cor, #2563eb));
  animation: mp-pulsa-poly 1.6s ease-in-out infinite;
}
@keyframes mp-pulsa-poly {
  0%, 100% { fill-opacity: .45; stroke-width: 3; }
  50% { fill-opacity: .8; stroke-width: 5; }
}
.mp-label {
  fill: #111827; font-family: var(--mp-fonte); font-weight: 600; text-anchor: middle; dominant-baseline: middle;
  pointer-events: none; paint-order: stroke; stroke: rgba(255,255,255,.9); stroke-width: 3px; stroke-linejoin: round;
}
.mp-label.mp-est-vivo { font-weight: 800; fill: #111827; }

/* edição */
.mp-draw-line { fill: var(--mp-cor, #dc2626); fill-opacity: .12; stroke: var(--mp-cor, #dc2626); stroke-width: 2; vector-effect: non-scaling-stroke; stroke-dasharray: 6 4; }
.mp-draw-elastic { stroke: #dc2626; stroke-width: 1.5; vector-effect: non-scaling-stroke; stroke-dasharray: 4 4; opacity: .8; }
.mp-draw-fecha { opacity: .35; }
.mp-handle { fill: #fff; stroke: #dc2626; stroke-width: 2; vector-effect: non-scaling-stroke; cursor: move; }
.mp-handle-mid { fill: #fde68a; stroke: #b45309; cursor: copy; opacity: .85; }
.mp-handle.mp-sel { fill: #dc2626; }
.mp-handle.mp-primeiro { fill: #86efac; stroke: #15803d; cursor: pointer; }
.mp-snap-ring { fill: none; stroke: #16a34a; stroke-width: 2; vector-effect: non-scaling-stroke; pointer-events: none; }
.mp-canvas[data-tool="poligono"] .mp-vp, .mp-canvas[data-tool="retangulo"] .mp-vp { cursor: crosshair; }
.mp-canvas[data-tool="poligono"] .mp-vp.mp-pan, .mp-canvas[data-tool="retangulo"] .mp-vp.mp-pan { cursor: grabbing; }

/* ------------------------------------------------------------ botões / inputs */
.mp-btn {
  font: 500 13px/1 var(--mp-fonte); color: var(--mp-texto); background: #fff; border: 1px solid var(--mp-borda);
  border-radius: 6px; padding: 7px 10px; cursor: pointer; display: inline-flex; align-items: center; gap: 6px; white-space: nowrap;
}
.mp-btn:hover { background: #f1f5f9; }
.mp-btn.mp-ativo { background: #dbeafe; border-color: #93c5fd; color: var(--mp-primaria-escura); }
.mp-btn-primary { background: var(--mp-primaria); border-color: var(--mp-primaria); color: #fff; }
.mp-btn-primary:hover { background: var(--mp-primaria-escura); }
.mp-btn-danger { color: var(--mp-perigo); border-color: #fecaca; }
.mp-btn-danger:hover { background: #fef2f2; }
.mp-btn-ghost { border-color: transparent; background: transparent; }
.mp-btn:disabled { opacity: .5; cursor: default; }
.mp-btn.mp-pulsa { animation: mp-pulsa-btn 1.2s ease-in-out infinite; }
@keyframes mp-pulsa-btn { 50% { box-shadow: 0 0 0 4px rgba(29,78,216,.25); } }
.mp-btn i { font-style: normal; }
.mp-sep { width: 1px; height: 22px; background: var(--mp-borda); margin: 0 4px; }
.mp-input {
  font: 14px var(--mp-fonte); color: var(--mp-texto); width: 100%; box-sizing: border-box; padding: 7px 9px;
  border: 1px solid var(--mp-borda); border-radius: 6px; background: #fff;
}
.mp-input:focus { outline: 2px solid #bfdbfe; border-color: #93c5fd; }
.mp-input[type="color"] { height: 36px; padding: 2px 4px; }
.mp-campo { display: block; margin: 0 0 10px; }
.mp-campo > span { display: block; font: 600 12px var(--mp-fonte); color: var(--mp-texto-fraco); margin-bottom: 4px; text-transform: uppercase; letter-spacing: .02em; }
.mp-dica { color: var(--mp-texto-fraco); font: 12px var(--mp-fonte); }
.mp-badge { display: inline-block; background: #e0e7ff; color: #3730a3; border-radius: 999px; padding: 1px 8px; font: 600 12px var(--mp-fonte); }
.mp-dot { width: 10px; height: 10px; border-radius: 50%; flex: none; }
.mp-zoom { font: 12px var(--mp-fonte); color: var(--mp-texto-fraco); min-width: 42px; text-align: center; }

/* ------------------------------------------------------------ editor */
.mp-editor { display: flex; flex-direction: column; height: 100vh; height: 100dvh; background: var(--mp-fundo); font-family: var(--mp-fonte); color: var(--mp-texto); }
.mp-editor:fullscreen { height: 100%; }
.mp-ed-top { display: flex; align-items: center; gap: 10px; padding: 8px 12px; background: var(--mp-painel); border-bottom: 1px solid var(--mp-borda); flex-wrap: wrap; }
.mp-ed-titulo { font-weight: 700; font-size: 15px; margin-right: auto; }
.mp-ed-tools { display: flex; align-items: center; gap: 4px; flex-wrap: wrap; }
.mp-ed-body { display: flex; flex: 1; min-height: 0; }
.mp-ed-centro { position: relative; flex: 1; min-width: 0; display: flex; flex-direction: column; }
.mp-ed-canvas { flex: 1; min-height: 0; }
.mp-ed-status { font: 12px/1.4 var(--mp-fonte); color: var(--mp-texto-fraco); background: var(--mp-painel); border-top: 1px solid var(--mp-borda); padding: 5px 12px; min-height: 26px; }
.mp-ed-status b { color: var(--mp-texto); }
.mp-snap-tag { color: #15803d; font-weight: 600; }
.mp-ed-ajuda { position: absolute; left: 12px; top: 10px; max-width: 60%; background: rgba(17,24,39,.85); color: #fff; font: 12px/1.4 var(--mp-fonte); padding: 6px 10px; border-radius: 6px; pointer-events: none; }
.mp-ed-ajuda:empty { display: none; }
.mp-lupa { position: absolute; left: 12px; bottom: 38px; border: 3px solid #fff; border-radius: 10px; box-shadow: var(--mp-sombra); pointer-events: none; background: #fff; }
.mp-lupa.mp-lupa-dir { left: auto; right: 12px; }
.mp-ed-side { width: 340px; flex: none; background: var(--mp-painel); border-left: 1px solid var(--mp-borda); display: flex; flex-direction: column; min-height: 0; }
.mp-ed-side-h { padding: 12px 14px 6px; font-size: 14px; }
.mp-ed-side > .mp-input { width: calc(100% - 28px); margin: 0 14px 8px; }
.mp-ed-lista { list-style: none; margin: 0; padding: 0 6px; overflow: auto; flex: 1; min-height: 120px; border-bottom: 1px solid var(--mp-borda); }
.mp-ed-item { display: flex; gap: 10px; align-items: center; padding: 8px 8px; border-radius: 6px; cursor: pointer; }
.mp-ed-item:hover { background: #f1f5f9; }
.mp-ed-item.mp-ativo { background: #dbeafe; }
.mp-ed-item-t { display: flex; flex-direction: column; min-width: 0; }
.mp-ed-item-t strong { font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.mp-ed-item-t small { color: var(--mp-texto-fraco); font-size: 11px; }
.mp-ed-vazio { padding: 14px; color: var(--mp-texto-fraco); font-size: 13px; }
.mp-ed-form { padding: 12px 14px; overflow: auto; flex: 1.3; min-height: 0; }
.mp-ed-form h3 { margin: 0 0 10px; font-size: 15px; }
.mp-ed-pts { font-size: 12px; color: var(--mp-texto-fraco); margin: -2px 0 10px; }
.mp-ed-pts em { color: var(--mp-perigo); font-style: normal; }
.mp-ed-acoes { display: flex; gap: 8px; margin-top: 8px; position: sticky; bottom: 0; background: var(--mp-painel); padding-top: 8px; }
.mp-ed-acoes .mp-btn-danger { margin-left: auto; }
.mp-fotos { display: grid; grid-template-columns: repeat(auto-fill, minmax(90px, 1fr)); gap: 8px; margin-bottom: 6px; }
.mp-foto { position: relative; margin: 0; }
.mp-foto img { width: 100%; aspect-ratio: 4/3; object-fit: cover; border-radius: 6px; border: 1px solid var(--mp-borda); display: block; }
.mp-foto-legenda { font-size: 11px; padding: 3px 5px; margin-top: 3px; border-color: transparent; background: transparent; }
.mp-foto-x { position: absolute; top: 3px; right: 3px; width: 20px; height: 20px; border-radius: 50%; border: 0; background: rgba(0,0,0,.6); color: #fff; cursor: pointer; line-height: 1; }
.mp-input-file { font: 12px var(--mp-fonte); }
@media (max-width: 860px) {
  .mp-ed-body { flex-direction: column; }
  .mp-ed-side { width: auto; max-height: 45%; border-left: 0; border-top: 1px solid var(--mp-borda); }
  .mp-ed-lista { min-height: 60px; }
  .mp-lupa { width: 120px; height: 120px; }
}

/* ------------------------------------------------------------ seletor (formulário de atividade) */
.mp-seletor { font-family: var(--mp-fonte); color: var(--mp-texto); }
.mp-sel-topo { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin-bottom: 8px; }
.mp-sel-topo .mp-input { width: auto; min-width: 200px; flex: 1; }
.mp-sel-corpo { display: grid; grid-template-columns: 1fr 260px; gap: 10px; }
.mp-sel-canvas { height: 420px; border: 1px solid var(--mp-borda); border-radius: var(--mp-raio); }
.mp-sel-lista { list-style: none; margin: 0; padding: 0; border: 1px solid var(--mp-borda); border-radius: var(--mp-raio); overflow: auto; max-height: 420px; }
.mp-sel-lista li { display: flex; gap: 8px; align-items: center; padding: 8px 10px; font-size: 13px; cursor: pointer; border-bottom: 1px solid #f1f5f9; }
.mp-sel-lista li:hover { background: #f1f5f9; }
.mp-sel-lista li.mp-ativo { background: #dbeafe; font-weight: 600; }
.mp-sel-lista li small { color: var(--mp-texto-fraco); margin-left: auto; white-space: nowrap; }
.mp-sel-escolhido { display: flex; align-items: center; gap: 8px; background: #ecfdf5; border: 1px solid #a7f3d0; color: #065f46; border-radius: 6px; padding: 8px 10px; font-size: 13px; margin-top: 8px; }
.mp-sel-escolhido:empty { display: none; }
.mp-sel-escolhido button { margin-left: auto; }
.mp-sel-vazio { padding: 24px; text-align: center; color: var(--mp-texto-fraco); font-size: 13px; }
@media (max-width: 760px) { .mp-sel-corpo { grid-template-columns: 1fr; } .mp-sel-canvas { height: 300px; } .mp-sel-lista { max-height: 200px; } }

/* ------------------------------------------------------------ visualizador (popup) */
.mp-link { color: var(--mp-primaria); text-decoration: underline dotted; cursor: pointer; }
.mp-link::before { content: "\1F4CD\00a0"; text-decoration: none; }
.mp-modal { position: fixed; inset: 0; z-index: 9999; background: rgba(15,23,42,.72); display: flex; align-items: center; justify-content: center; padding: 16px; font-family: var(--mp-fonte); color: var(--mp-texto); animation: mp-fade .2s; }
@keyframes mp-fade { from { opacity: 0; } }
.mp-modal-box { background: var(--mp-painel); border-radius: 12px; box-shadow: var(--mp-sombra); width: min(1100px, 100%); height: min(760px, 100%); display: flex; flex-direction: column; overflow: hidden; }
.mp-modal-h { display: flex; align-items: center; gap: 10px; padding: 10px 14px; border-bottom: 1px solid var(--mp-borda); }
.mp-modal-h h2 { margin: 0; font-size: 16px; flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.mp-modal-h small { color: var(--mp-texto-fraco); font-weight: 400; }
.mp-modal-corpo { display: flex; flex: 1; min-height: 0; }
.mp-vw-canvas { flex: 1; min-width: 0; }
.mp-vw-info { width: 300px; flex: none; border-left: 1px solid var(--mp-borda); overflow: auto; padding: 14px; }
.mp-vw-info dl { margin: 0 0 12px; display: grid; grid-template-columns: auto 1fr; gap: 4px 10px; font-size: 13px; }
.mp-vw-info dt { color: var(--mp-texto-fraco); font-weight: 600; }
.mp-vw-info dd { margin: 0; }
.mp-vw-tipo { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; font-weight: 600; margin-bottom: 8px; }
.mp-vw-obs { font-size: 13px; background: #fffbeb; border: 1px solid #fde68a; border-radius: 6px; padding: 8px 10px; margin-bottom: 12px; }
.mp-vw-fotos { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.mp-vw-fotos figure { margin: 0; cursor: zoom-in; }
.mp-vw-fotos img { width: 100%; aspect-ratio: 4/3; object-fit: cover; border-radius: 6px; border: 1px solid var(--mp-borda); display: block; }
.mp-vw-fotos figcaption { font-size: 11px; color: var(--mp-texto-fraco); margin-top: 3px; }
.mp-vw-tip { position: absolute; background: rgba(17,24,39,.9); color: #fff; font: 12px var(--mp-fonte); padding: 4px 8px; border-radius: 4px; pointer-events: none; transform: translate(-50%, -130%); white-space: nowrap; z-index: 2; }
.mp-vw-legenda { position: absolute; left: 10px; bottom: 10px; background: rgba(255,255,255,.9); font: 12px var(--mp-fonte); padding: 5px 8px; border-radius: 6px; color: var(--mp-texto-fraco); pointer-events: none; }
.mp-lightbox { position: fixed; inset: 0; z-index: 10000; background: rgba(0,0,0,.9); display: flex; align-items: center; justify-content: center; cursor: zoom-out; }
.mp-lightbox img { max-width: 94vw; max-height: 90vh; border-radius: 6px; }
.mp-lightbox figcaption { position: absolute; bottom: 16px; color: #fff; font: 14px var(--mp-fonte); }
@media (max-width: 760px) {
  .mp-modal { padding: 0; }
  .mp-modal-box { border-radius: 0; height: 100%; }
  .mp-modal-corpo { flex-direction: column; }
  .mp-vw-info { width: auto; max-height: 38%; border-left: 0; border-top: 1px solid var(--mp-borda); }
}

/* ------------------------------------------------------------ avisos */
.mp-toasts { position: fixed; right: 16px; bottom: 16px; z-index: 10001; display: flex; flex-direction: column; gap: 8px; }
.mp-toast { font: 13px var(--mp-fonte); color: #fff; background: #1f2937; padding: 10px 14px; border-radius: 8px; box-shadow: var(--mp-sombra); animation: mp-sobe .25s; }
.mp-toast-ok { background: #15803d; } .mp-toast-erro { background: #b91c1c; }
.mp-toast.mp-sai { opacity: 0; transition: opacity .4s; }
@keyframes mp-sobe { from { transform: translateY(10px); opacity: 0; } }
