/* Firmador de PDF — estilos propios */

.fp-layout {
  display: grid;
  gap: clamp(1rem, 2.6vw, 1.6rem);
  grid-template-columns: 1fr;
  align-items: start;
}
@media (min-width: 1024px) {
  .fp-layout { grid-template-columns: 1fr 330px; }
}

/* --- Visor --- */
.fp-toolbar {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  flex-wrap: wrap;
  margin-bottom: 0.7rem;
}
.fp-pagina { font-size: var(--t-base); color: var(--text-soft); }
.fp-pagina strong { font-variant-numeric: tabular-nums; color: var(--text); }
.fp-nombre {
  margin-left: auto;
  max-width: 42%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.fp-stage {
  padding: clamp(0.6rem, 2vw, 1.1rem);
  border-radius: var(--r-lg);
  display: grid;
  place-items: center;
  overflow: auto;
}

.fp-page {
  position: relative;
  line-height: 0;
  max-width: 100%;
  box-shadow: 0 10px 28px -12px rgba(20, 25, 45, 0.5);
  border-radius: 4px;
  overflow: hidden;
  background: #fff;
}
.fp-page canvas { display: block; max-width: 100%; height: auto; }

.fp-overlay {
  position: absolute;
  inset: 0;
  line-height: normal;
}

/* --- Elemento colocado sobre la página --- */
.fp-stamp {
  position: absolute;
  cursor: grab;
  touch-action: none;
  border: 1.5px dashed transparent;
  border-radius: 4px;
  transition: border-color 0.18s var(--ease-out), box-shadow 0.18s var(--ease-out);
}
.fp-stamp img {
  width: 100%;
  height: 100%;
  display: block;
  pointer-events: none;
  -webkit-user-drag: none;
  user-select: none;
}
.fp-stamp:hover,
.fp-stamp.is-active {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 18%, transparent);
}
.fp-stamp.is-dragging { cursor: grabbing; }

.fp-handle {
  position: absolute;
  right: -7px;
  bottom: -7px;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: var(--accent);
  border: 2px solid #fff;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.35);
  cursor: nwse-resize;
  touch-action: none;
  opacity: 0;
  transition: opacity 0.18s var(--ease-out);
}
.fp-stamp:hover .fp-handle,
.fp-stamp.is-active .fp-handle { opacity: 1; }

.fp-ayuda { margin-top: 0.6rem; }

/* --- Panel lateral --- */
.fp-panel {
  padding: 1.15rem;
  position: sticky;
  top: 88px;
}
@media (max-width: 1023px) { .fp-panel { position: static; } }

.fp-panel__title {
  font-size: var(--t-xs);
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--text-mute);
  font-family: var(--sans);
  font-weight: 700;
  margin-bottom: 0.75rem;
}
.fp-sep { border: 0; border-top: 1px solid var(--line); margin-block: 1.1rem; }
.fp-tab { margin-top: 0.9rem; }
.fp-tab .field + .field { margin-top: 0.8rem; }

/* --- Zona de dibujo --- */
.fp-pad-wrap {
  position: relative;
  border-radius: var(--r-md);
  background: #fdfdfb;
  box-shadow: var(--neu-in);
  overflow: hidden;
}
.fp-pad {
  display: block;
  width: 100%;
  height: auto;
  aspect-ratio: 600 / 220;
  touch-action: none;
  cursor: crosshair;
}
.fp-pad__linea {
  position: absolute;
  left: 8%;
  right: 8%;
  bottom: 26%;
  height: 1px;
  background: repeating-linear-gradient(90deg, #c9cede 0 7px, transparent 7px 14px);
  pointer-events: none;
}
.fp-pad__pista {
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  font-size: var(--t-sm);
  color: #9aa2b6;
  pointer-events: none;
  transition: opacity 0.2s var(--ease-out);
}
.fp-pad-wrap.is-drawn .fp-pad__pista { opacity: 0; }

.fp-pad-tools {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  flex-wrap: wrap;
  margin-top: 0.6rem;
}
.fp-color, .fp-grosor {
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
  align-items: flex-start;
}
.fp-grosor { flex: 1 1 120px; min-width: 100px; }
.fp-color input[type="color"] {
  -webkit-appearance: none;
  appearance: none;
  width: 44px; height: 30px;
  border: none; padding: 0;
  border-radius: var(--r-xs);
  background: var(--bg);
  box-shadow: var(--neu-out-sm);
  cursor: pointer;
}
.fp-color input[type="color"]::-webkit-color-swatch-wrapper { padding: 4px; }
.fp-color input[type="color"]::-webkit-color-swatch { border: none; border-radius: 5px; }
.fp-color span, .fp-grosor span { color: var(--text-mute); }

/* --- Estilos de firma escrita --- */
.fp-estilos { display: grid; gap: 0.45rem; margin-top: 0.8rem; }
.fp-estilo {
  padding: 0.5rem 0.9rem;
  border-radius: var(--r-sm);
  background: var(--surface);
  border: 1.5px solid var(--line);
  text-align: left;
  font-size: var(--t-xl);
  line-height: 1.25;
  color: #0b2b6b;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  transition: border-color 0.2s var(--ease-out), transform 0.2s var(--ease-out);
}
.fp-estilo:hover { transform: translateX(3px); }
.fp-estilo.is-active { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.fp-estilo--caveat { font-family: "Caveat", cursive; }
.fp-estilo--cursiva { font-family: "Times New Roman", Georgia, serif; font-style: italic; }
.fp-estilo--recta { font-family: var(--display); font-size: var(--t-lg); font-weight: 600; }

/* --- Dropzone mini --- */
.dropzone--mini {
  min-height: 110px;
  padding: 1rem;
  gap: 0.5rem;
}
.dropzone--mini svg { color: var(--accent-text); }

/* --- Firmas guardadas --- */
.fp-guardadas { margin-bottom: 1.1rem; padding-bottom: 1rem; border-bottom: 1px solid var(--line); }
.fp-guardadas__tira { display: flex; flex-wrap: wrap; gap: 0.45rem; }
.fp-firma-g {
  position: relative;
  width: 84px; height: 44px;
  padding: 3px;
  border-radius: var(--r-xs);
  background: #fff;
  border: 1.5px solid var(--line);
  cursor: pointer;
  transition: border-color 0.18s var(--ease-out), transform 0.18s var(--ease-out);
}
.fp-firma-g:hover { border-color: var(--accent); transform: translateY(-2px); }
.fp-firma-g img { width: 100%; height: 100%; object-fit: contain; display: block; }
.fp-firma-g__x {
  position: absolute;
  top: -7px; right: -7px;
  width: 20px; height: 20px;
  border-radius: 50%;
  background: var(--surface);
  border: 1px solid var(--line-strong);
  color: var(--text-mute);
  display: grid; place-items: center;
  font-size: var(--t-xs); line-height: 1;
  opacity: 0;
  transition: opacity 0.18s var(--ease-out);
}
.fp-firma-g:hover .fp-firma-g__x { opacity: 1; }
.fp-firma-g__x:hover { color: var(--err-text); border-color: var(--err); }

/* --- Fila de colocar --- */
.fp-poner {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.45rem;
  margin-top: 0.9rem;
}
.fp-poner .btn { flex: 1 1 auto; }

/* --- Aviso de lote --- */
.fp-lote {
  padding: 0.14rem 0.5rem;
  border-radius: var(--r-pill);
  background: var(--accent-soft);
  color: var(--accent-text);
  font-weight: 650;
  white-space: nowrap;
}

/* --- Campos de formulario del PDF --- */
.fp-formulario .field + .field { margin-top: 0.6rem; }
.fp-formulario .input { padding: 0.5rem 0.7rem; font-size: var(--t-base); }
.fp-formulario .label { font-size: var(--t-xs); }

/* --- Huella del documento --- */
.fp-huella {
  margin-top: 1.1rem;
  padding: 0.9rem 1.1rem;
  border-radius: var(--r-md);
  background: color-mix(in srgb, var(--ok) 10%, var(--surface));
  border-left: 3px solid var(--ok);
}
.fp-huella__t {
  font-size: var(--t-xs);
  font-weight: 700;
  color: color-mix(in srgb, var(--ok) 78%, var(--text));
  margin-bottom: 0.4rem;
}
.fp-huella__v {
  display: block;
  font-family: var(--mono);
  font-size: var(--t-xs);
  line-height: 1.5;
  overflow-wrap: anywhere;
  color: var(--text-soft);
}
.fp-huella__acc {
  display: flex;
  align-items: center;
  gap: 0.7rem;
  flex-wrap: wrap;
  margin-top: 0.6rem;
}

/* --- Verificador --- */
.fp-verificador__cab {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.8rem;
  flex-wrap: wrap;
  margin-bottom: 0.5rem;
}
.fp-verificador__t { font-size: clamp(1.05rem, 2.4vw, 1.25rem); }
.fp-verificador__cuerpo {
  display: grid;
  gap: 1rem;
  grid-template-columns: 1fr;
  align-items: start;
}
@media (min-width: 780px) { .fp-verificador__cuerpo { grid-template-columns: 250px 1fr; } }

.fp-veredicto {
  margin-top: 0.6rem;
  padding: 0.75rem 0.95rem;
  border-radius: var(--r-sm);
  font-size: var(--t-base);
  background: var(--surface-2);
  border-left: 3px solid var(--line-strong);
  color: var(--text-soft);
  overflow-wrap: anywhere;
}
.fp-veredicto .mono { font-size: var(--t-xs); display: block; margin-top: 0.3rem; }
.fp-veredicto.is-bien { border-left-color: var(--ok); color: color-mix(in srgb, var(--ok) 80%, var(--text)); }
.fp-veredicto.is-mal { border-left-color: var(--err); color: color-mix(in srgb, var(--err) 80%, var(--text)); }

/* --- Lista de colocados --- */
.fp-colocados { list-style: none; display: grid; gap: 0.4rem; }
.fp-colocado {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  padding: 0.4rem 0.55rem;
  border-radius: var(--r-sm);
  background: var(--surface);
  border: 1px solid var(--line);
  font-size: var(--t-sm);
}
.fp-colocado img {
  width: 40px; height: 24px;
  object-fit: contain;
  background: #fff;
  border-radius: 3px;
  flex: none;
}
.fp-colocado__txt { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.fp-colocado button {
  color: var(--text-mute);
  padding: 0.2rem;
  border-radius: 5px;
  flex: none;
}
.fp-colocado button:hover { color: var(--err-text); background: color-mix(in srgb, var(--err) 12%, transparent); }
.fp-colocado svg { width: 15px; height: 15px; display: block; }

/* =============================================================
   Ergonomía táctil (ver styles.css §9b para el porqué de la consulta)
   ============================================================= */
@media (max-width: 700px), (pointer: coarse) {
  /* La aspa de borrar una firma guardada vivía encima de la miniatura y solo
     aparecía al pasar el ratón: en un móvil no hay ratón, así que era una
     zona invisible que borraba al tocarla. Pasa a ser una fila con dos
     objetivos separados —usar la firma y borrarla— siempre visibles. */
  .fp-guardadas__tira { flex-direction: column; gap: 0.55rem; }
  .fp-firma-g {
    display: grid;
    grid-template-columns: 1fr 44px;
    align-items: center;
    gap: 0.55rem;
    width: 100%;
    height: auto;
    min-height: 52px;
    padding: 4px;
  }
  .fp-firma-g img { height: 44px; }
  .fp-firma-g__x {
    position: static;
    opacity: 1;
    width: 44px;
    height: 44px;
    font-size: var(--t-md);
  }

  /* La lista de firmas colocadas quita cada una con un botón de 19 px */
  .fp-colocado button { width: 44px; height: 44px; display: grid; place-items: center; }
  .fp-colocados { gap: 0.55rem; }

  /* El tirador de redimensionar se arrastra con el dedo, no con el ratón */
  .fp-handle { width: 24px; height: 24px; right: -11px; bottom: -11px; }
  .fp-stamp .fp-handle { opacity: 1; }

  .fp-poner, .fp-toolbar { gap: 0.6rem; }
  .fp-pad-tools { gap: 0.85rem; }

  /* Suelo tipográfico */
  .fp-formulario .label,
  .fp-huella__v { font-size: var(--t-xs); }
}
