body { background: #f6f7f9; }

/* Previsualización: canvas + recuadro de firma superpuesto */
.preview-wrap {
  position: relative;
  width: 100%;
  min-height: 240px;
  background: #fff;
  border: 1px solid #dee2e6;
  border-radius: .5rem;
  overflow: hidden;
  display: flex;
  justify-content: center;
}
.preview-wrap canvas { max-width: 100%; height: auto; display: block; }

.preview-empty {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 1rem;
}

/* Imagen de firma actual (miniatura en la tarjeta) */
.sig-current {
  max-height: 48px;
  max-width: 180px;
  border: 1px solid #e3e6ea;
  border-radius: .35rem;
  background: #fff;
  padding: 2px 6px;
}

/* Recuadro arrastrable/redimensionable de la firma */
.sig-box {
  position: absolute;
  top: 0; left: 0;
  box-sizing: border-box;
  border: 2px solid #0d6efd;
  background: rgba(13, 110, 253, .08);
  border-radius: .25rem;
  cursor: move;
  touch-action: none;           /* necesario para arrastre táctil con interact.js */
  background-size: contain;
  background-position: center;
  background-repeat: no-repeat;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 5;
}
.sig-box.with-image { background-color: rgba(13, 110, 253, .04); }
.sig-box.with-image .sig-box-label { display: none; }
.sig-box-label {
  font-size: .75rem;
  color: #0d6efd;
  font-weight: 600;
  pointer-events: none;
  user-select: none;
}

/* Modal simple (sin dependencia de JS de Bootstrap) */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, .45);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
  z-index: 1050;
}
.modal-card {
  background: #fff;
  border-radius: .75rem;
  padding: 1.25rem;
  width: 100%;
  max-width: 420px;
  box-shadow: 0 10px 40px rgba(0, 0, 0, .25);
}
.result-check {
  width: 54px; height: 54px;
  margin: 0 auto;
  border-radius: 50%;
  background: #198754;
  color: #fff;
  font-size: 1.8rem;
  line-height: 54px;
  text-align: center;
}

/* Galería de firmas */
.firma-galeria {
  display: flex;
  flex-wrap: wrap;
  gap: .6rem;
}
.firma-item {
  position: relative;
  width: 140px;
  border: 2px solid #e3e6ea;
  border-radius: .5rem;
  padding: .4rem;
  cursor: pointer;
  background: #fff;
  transition: border-color .15s, box-shadow .15s;
}
.firma-item:hover { border-color: #adb5bd; }
.firma-item.selected { border-color: #0d6efd; box-shadow: 0 0 0 .15rem rgba(13,110,253,.15); }
.firma-item img {
  display: block;
  width: 100%;
  height: 56px;
  object-fit: contain;
  background: #fbfbfc;
  border-radius: .35rem;
}
.firma-item .firma-label {
  font-size: .75rem;
  text-align: center;
  margin-top: .3rem;
  color: #495057;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.firma-item .firma-sel-badge {
  display: none;
  font-size: .68rem;
  text-align: center;
  color: #0d6efd;
  font-weight: 600;
}
.firma-item.selected .firma-sel-badge { display: block; }
.firma-item .firma-del {
  position: absolute;
  top: -8px; right: -8px;
  width: 20px; height: 20px;
  line-height: 18px;
  border-radius: 50%;
  border: 1px solid #dee2e6;
  background: #fff;
  color: #dc3545;
  font-size: 14px;
  cursor: pointer;
  padding: 0;
}
.firma-item .firma-del:hover { background: #dc3545; color: #fff; }

@media (max-width: 575.98px) {
  .preview-wrap { min-height: 320px; }
}
