/* Função mapa: Histórico — UI externa (não altera o carregamento do mapa) */

.sl-hist-btn {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  border: 1px solid #e2e8f0;
  background: #fff;
  color: #64748b;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  padding: 0;
  flex-shrink: 0;
}

.sl-hist-btn:hover {
  background: #f8fafc;
  color: #1976d2;
  border-color: #90caf9;
}

.sl-hist-btn.is-active {
  background: #1976d2;
  color: #fff;
  border-color: #1976d2;
}

.sl-hist-btn svg {
  width: 18px;
  height: 18px;
  display: block;
}

#sl-hist-panel {
  position: fixed;
  left: 50%;
  top: 72px;
  transform: translateX(-50%);
  z-index: 4500;
  /* Largura dinâmica: conteúdo + margem (sem faixa vazia) */
  width: fit-content;
  max-width: calc(100vw - 24px);
  background: #fff;
  border-radius: 14px;
  box-shadow: 0 16px 40px rgba(15, 23, 42, 0.22);
  border: 1px solid #e2e8f0;
  padding: 14px 16px 16px;
}

#sl-hist-panel[hidden] {
  display: none !important;
}

.sl-hist-panel__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
}

.sl-hist-panel__head h2 {
  margin: 0;
  font-size: 15px;
  font-weight: 800;
  color: #1e293b;
}

.sl-hist-panel__head p {
  margin: 2px 0 0;
  font-size: 12px;
  color: #64748b;
}

.sl-hist-panel__close {
  border: 0;
  background: #f1f5f9;
  width: 32px;
  height: 32px;
  border-radius: 8px;
  cursor: pointer;
  font-size: 18px;
  line-height: 1;
  color: #475569;
}

.sl-hist-filters {
  display: flex;
  flex-wrap: nowrap;
  gap: 8px;
  margin-bottom: 12px;
  overflow-x: auto;
}

.sl-hist-chip {
  border: 1px solid #cbd5e1;
  background: #fff;
  color: #334155;
  border-radius: 999px;
  padding: 7px 12px;
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
}

.sl-hist-chip.is-selected {
  background: #eff6ff;
  border-color: #1976d2;
  color: #1565c0;
}

.sl-hist-actions {
  display: flex;
  gap: 8px;
  align-items: center;
}

.sl-hist-run {
  border: 0;
  border-radius: 10px;
  background: #1976d2;
  color: #fff;
  font-weight: 700;
  font-size: 13px;
  padding: 10px 16px;
  cursor: pointer;
}

.sl-hist-run:disabled {
  opacity: 0.65;
  cursor: default;
}

.sl-hist-status {
  font-size: 12px;
  color: #64748b;
}

.sl-hist-status.is-error {
  color: #b91c1c;
}

#sl-hist-badge {
  position: fixed;
  top: 72px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 4600;
  max-width: min(480px, calc(100vw - 32px));
  background: rgba(15, 23, 42, 0.92);
  color: #fff;
  border-radius: 12px;
  padding: 12px 14px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.28);
  display: flex;
  gap: 12px;
  align-items: center;
}

#sl-hist-badge[hidden] {
  display: none !important;
}

#sl-hist-badge .sl-hist-badge__text {
  font-size: 13px;
  line-height: 1.4;
  font-weight: 600;
  text-align: center;
  flex: 1;
}

#sl-hist-badge .sl-hist-badge__close {
  border: 0;
  background: rgba(255, 255, 255, 0.14);
  color: #fff;
  border-radius: 8px;
  width: 28px;
  height: 28px;
  cursor: pointer;
  flex-shrink: 0;
  font-size: 16px;
}

.sl-hist-marker {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  border: 2px solid #fff;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.35);
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-size: 11px;
  font-weight: 800;
  cursor: pointer;
}

.sl-hist-marker--start {
  background: #16a34a;
}

.sl-hist-marker--end {
  background: #dc2626;
}

.sl-hist-marker--stop {
  background: #f59e0b;
  min-width: 22px;
  width: auto;
  height: 22px;
  padding: 0 5px;
  box-sizing: border-box;
  font-size: 11px;
}

#sl-hist-summary {
  position: fixed;
  right: 16px;
  bottom: 20px;
  z-index: 4600;
  width: min(340px, calc(100vw - 24px));
  max-height: min(68vh, 560px);
  overflow: auto;
  background: #fff;
  color: #0f172a;
  border-radius: 14px;
  padding: 12px 14px 8px;
  box-shadow: 0 12px 32px rgba(15, 23, 42, 0.28);
  font-family: Arial, Helvetica, sans-serif;
}

#sl-hist-summary[hidden] {
  display: none !important;
}

.sl-hist-summary__head {
  font-size: 13px;
  font-weight: 800;
  letter-spacing: 0.01em;
  margin-bottom: 2px;
}

.sl-hist-summary__device {
  margin: 0 0 4px;
  font-size: 12px;
  line-height: 1.2;
  color: #475569;
}

.sl-hist-summary__grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 0;
}

.sl-hist-summary__kv {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  padding: 2px 0;
  border-top: 1px solid #e2e8f0;
  font-size: 12px;
  line-height: 1.25;
}

.sl-hist-summary__kv span {
  color: #64748b;
}

.sl-hist-summary__kv strong {
  text-align: right;
  font-weight: 700;
}

.sl-hist-popup {
  font-family: Arial, Helvetica, sans-serif;
  font-size: 12px;
  color: #0f172a;
  min-width: 180px;
}

.sl-hist-popup strong {
  display: block;
  margin-bottom: 6px;
  font-size: 13px;
}

.sl-hist-popup div {
  margin: 2px 0;
}
