/* Editor de PDF — estilos propios */

/* --- Barra de estado y selección --- */
.hp-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.8rem;
  flex-wrap: wrap;
  padding-bottom: 0.85rem;
  border-bottom: 1px solid var(--line);
}
.hp-bar__info { font-size: var(--t-base); color: var(--text-soft); }
.hp-bar__info strong { color: var(--text); font-variant-numeric: tabular-nums; }
.hp-bar__acciones { display: flex; flex-wrap: wrap; gap: 0.4rem; }

/* --- Operaciones --- */
.hp-ops {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem;
  margin-top: 0.9rem;
}
.hp-ops .btn { padding: 0.6rem 1rem; font-size: var(--t-base); }
.hp-ops__sep { flex: 1 1 auto; min-width: 0; }

/* --- Rango --- */
.hp-rango { margin-top: 0.9rem; }
.hp-rango__fila { display: flex; gap: 0.5rem; align-items: stretch; }
.hp-rango__fila .input { flex: 1; min-width: 0; }
.hp-rango__fila .btn { flex: none; white-space: nowrap; }

/* --- Cuadrícula de páginas --- */
.hp-grid {
  list-style: none;
  display: grid;
  gap: 0.7rem;
  grid-template-columns: repeat(auto-fill, minmax(112px, 1fr));
  margin-top: 1.1rem;
  max-height: 62vh;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 0.35rem;
}

.hp-pagina {
  position: relative;
  border-radius: var(--r-sm);
  background: var(--surface);
  border: 2px solid var(--line);
  padding: 0.35rem;
  cursor: pointer;
  transition: border-color 0.2s var(--ease-out), transform 0.2s var(--ease-out), box-shadow 0.2s var(--ease-out);
  animation: hpIn 0.3s var(--ease-out) backwards;
}
@keyframes hpIn {
  from { opacity: 0; transform: scale(0.94); }
  to   { opacity: 1; transform: none; }
}
.hp-pagina:hover { transform: translateY(-3px); box-shadow: var(--neu-out-sm); }
.hp-pagina.is-sel {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}
.hp-pagina.is-arrastrando { opacity: 0.35; }
.hp-pagina.is-destino { border-color: var(--accent-2); border-style: dashed; }

.hp-pagina__lienzo {
  width: 100%;
  aspect-ratio: 1 / 1.35;
  display: grid;
  place-items: center;
  background: #fff;
  border-radius: 3px;
  overflow: hidden;
}
.hp-pagina__lienzo img {
  max-width: 100%;
  max-height: 100%;
  display: block;
  transition: transform 0.28s var(--ease-out);
}
.hp-pagina[data-rot="90"]  .hp-pagina__lienzo img { transform: rotate(90deg)  scale(0.74); }
.hp-pagina[data-rot="180"] .hp-pagina__lienzo img { transform: rotate(180deg); }
.hp-pagina[data-rot="270"] .hp-pagina__lienzo img { transform: rotate(270deg) scale(0.74); }

.hp-pagina__pie {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.2rem;
  margin-top: 0.3rem;
  font-size: var(--t-xs);
  color: var(--text-mute);
}
.hp-pagina__n { font-variant-numeric: tabular-nums; font-weight: 700; }
.hp-pagina__mover { display: flex; gap: 0.1rem; }
.hp-pagina__mover button {
  width: 18px; height: 18px;
  display: grid; place-items: center;
  border-radius: 4px;
  color: var(--text-mute);
  line-height: 1;
}
.hp-pagina__mover button:hover { color: var(--accent-text); background: var(--accent-soft); }
.hp-pagina__mover svg { width: 11px; height: 11px; }

.hp-pagina__check {
  position: absolute;
  top: 0.45rem; left: 0.45rem;
  width: 19px; height: 19px;
  border-radius: 5px;
  background: var(--surface);
  border: 2px solid var(--line-strong);
  display: grid; place-items: center;
  pointer-events: none;
  transition: background-color 0.18s var(--ease-out), border-color 0.18s var(--ease-out);
}
.hp-pagina__check svg { width: 12px; height: 12px; color: #fff; opacity: 0; transition: opacity 0.18s; }
.hp-pagina.is-sel .hp-pagina__check {
  background: var(--accent);
  border-color: var(--accent);
}
.hp-pagina.is-sel .hp-pagina__check svg { opacity: 1; }

.hp-pagina__fuente {
  position: absolute;
  top: 0.45rem; right: 0.45rem;
  padding: 0.05rem 0.35rem;
  border-radius: var(--r-pill);
  font-size: var(--t-xs);
  font-weight: 700;
  background: var(--accent-2);
  color: #fff;
  opacity: 0.9;
}

/* --- Paneles plegables de opciones --- */
.hp-extra {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  margin-top: 0.9rem;
  padding-top: 0.9rem;
  border-top: 1px solid var(--line);
}

.hp-panel {
  margin-top: 0.8rem;
  padding: 1rem 1.1rem;
  border-radius: var(--r-md);
  background: var(--bg);
  box-shadow: var(--neu-in);
  animation: hpPanel 0.25s var(--ease-out);
}
@keyframes hpPanel {
  from { opacity: 0; transform: translateY(-6px); }
  to   { opacity: 1; transform: none; }
}
.hp-panel .field-row + .field-row { margin-top: 0.7rem; }
.hp-panel > .label { margin-bottom: 0.6rem; }
.hp-sep { border: 0; border-top: 1px solid var(--line); margin-block: 1rem; }

.hp-texto-vista {
  margin-top: 0.8rem;
  max-height: 220px;
  overflow: auto;
  padding: 0.8rem 0.9rem;
  border-radius: var(--r-sm);
  background: var(--surface);
  border: 1px solid var(--line);
  font-family: var(--mono);
  font-size: var(--t-xs);
  line-height: 1.55;
  white-space: pre-wrap;
  color: var(--text-soft);
}

/* --- Recorte marcado sobre la miniatura --- */
.hp-pagina__recorte {
  position: absolute;
  inset: 0;
  pointer-events: none;
  border-style: solid;
  border-color: color-mix(in srgb, var(--err) 26%, transparent);
  transition: border-width 0.15s var(--ease-out);
}

/* --- Ampliación al pasar el ratón --- */
.hp-zoom {
  position: fixed;
  z-index: 60;
  padding: 6px;
  border-radius: var(--r-sm);
  background: var(--surface);
  border: 1px solid var(--line-strong);
  box-shadow: 0 18px 44px -14px rgba(15, 20, 40, 0.55);
  pointer-events: none;
  animation: hpZoom 0.16s var(--ease-out);
}
@keyframes hpZoom { from { opacity: 0; transform: scale(0.96); } to { opacity: 1; transform: none; } }
.hp-zoom canvas {
  display: block;
  border-radius: 3px;
  background: #fff;
  max-width: 340px;
  height: auto;
}
.hp-zoom__n {
  display: block;
  text-align: center;
  font-family: var(--mono);
  font-size: var(--t-xs);
  color: var(--text-mute);
  padding-top: 4px;
}
@media (hover: none) { .hp-zoom { display: none !important; } }

/* --- Acciones finales --- */
.hp-final {
  display: flex;
  flex-wrap: wrap;
  gap: 0.55rem;
  margin-top: 1.1rem;
  padding-top: 1rem;
  border-top: 1px solid var(--line);
}

/* --- Bloque Office --- */
.hp-office__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.8rem;
  flex-wrap: wrap;
  margin-bottom: 1rem;
}
.hp-office__title { font-size: clamp(1.05rem, 2.4vw, 1.25rem); }

.hp-office__body {
  display: grid;
  gap: 1rem;
  grid-template-columns: 1fr;
  align-items: start;
}
@media (min-width: 820px) { .hp-office__body { grid-template-columns: 1fr 1fr; } }

.dropzone--mini { min-height: 150px; padding: 1.2rem; gap: 0.45rem; }
.dropzone--mini svg { color: var(--accent-text); }

.hp-office__aviso { font-size: var(--t-base); }

.hp-office__estado {
  margin-top: 1rem;
  padding: 0.85rem 1rem;
  border-radius: var(--r-sm);
  background: var(--surface-2);
  font-size: var(--t-base);
}

/* Vista previa de lo que se va a imprimir: es el mismo HTML que recibe
   el motor de impresión, así que lo que se ve es lo que sale. */
.hp-vista {
  max-height: 320px;
  overflow: auto;
  margin-top: 0.7rem;
  padding: 1rem 1.15rem;
  border-radius: var(--r-sm);
  background: #ffffff;
  color: #17181d;
  border: 1px solid var(--line-strong);
  font-family: Georgia, "Times New Roman", serif;
  font-size: var(--t-base);
  line-height: 1.55;
}
.hp-vista h1 { font-size: var(--t-xl); margin: 0 0 0.5em; }
.hp-vista h2 { font-size: var(--t-lg); margin: 1em 0 0.35em; }
.hp-vista h3 { font-size: var(--t-md); margin: 0.9em 0 0.3em; }
.hp-vista p { margin: 0 0 0.6em; }
.hp-vista ul, .hp-vista ol { margin: 0 0 0.6em 1.1rem; }
.hp-vista img { max-width: 100%; height: auto; }
.hp-vista table { border-collapse: collapse; width: 100%; margin-bottom: 0.8em; font-size: var(--t-sm); }
.hp-vista td, .hp-vista th { border: 1px solid #c3c9d6; padding: 3px 6px; text-align: left; }
.hp-vista th { background: #eef1f7; font-weight: 700; }

/* =============================================================
   Ergonomía táctil (ver styles.css §9b para el porqué de la consulta)
   ============================================================= */
@media (max-width: 700px), (pointer: coarse) {
  /* Las flechas de reordenar medían 18×18 y estaban a 1,6 px la una de la
     otra: la miniatura da 119 px de ancho útil y ahí caben dos objetivos de
     44 con 8 de separación, así que se agrandan de verdad en vez de con un
     pseudo-elemento —que aquí solaparía las dos zonas. */
  .hp-pagina__mover { gap: 0.5rem; }
  .hp-pagina__mover button { width: 44px; height: 44px; border-radius: var(--r-xs); flex: none; }
  .hp-pagina__mover svg { width: 15px; height: 15px; }
  /* El número de página pasa a su propia línea: en una miniatura de 119 px
     útiles no caben en fila el número y dos objetivos de 44, y al apretarlos
     el flex encogía los botones a 41. */
  .hp-pagina__pie { flex-wrap: wrap; justify-content: center; gap: 0.15rem; }
  .hp-pagina__n { flex: 1 0 100%; text-align: center; }
  /* Con las flechas a 44 la miniatura necesita un mínimo algo mayor para que
     sigan cabiendo dos columnas en un móvil de 360. */
  .hp-grid { grid-template-columns: repeat(auto-fill, minmax(132px, 1fr)); }

  .hp-bar__acciones,
  .hp-ops,
  .hp-extra,
  .hp-rango__fila { gap: 0.55rem; }
  .hp-final { gap: 0.6rem; }

  /* Suelo tipográfico */
  .hp-pagina__pie,
  .hp-pagina__fuente,
  .hp-zoom__n { font-size: var(--t-xs); }
}
